1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2019 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
42 #define VDEV_ARGS_SIZE 100
43 #define MAX_NB_SESSIONS 4
46 #define OUT_OF_PLACE 1
48 static int gbl_driver_id;
50 struct crypto_testsuite_params {
51 struct rte_mempool *mbuf_pool;
52 struct rte_mempool *large_mbuf_pool;
53 struct rte_mempool *op_mpool;
54 struct rte_mempool *session_mpool;
55 struct rte_mempool *session_priv_mpool;
56 struct rte_cryptodev_config conf;
57 struct rte_cryptodev_qp_conf qp_conf;
59 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
60 uint8_t valid_dev_count;
63 struct crypto_unittest_params {
64 struct rte_crypto_sym_xform cipher_xform;
65 struct rte_crypto_sym_xform auth_xform;
66 struct rte_crypto_sym_xform aead_xform;
68 struct rte_cryptodev_sym_session *sess;
70 struct rte_crypto_op *op;
72 struct rte_mbuf *obuf, *ibuf;
77 #define ALIGN_POW2_ROUNDUP(num, align) \
78 (((num) + (align) - 1) & ~((align) - 1))
81 * Forward declarations.
84 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
85 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
89 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
90 struct crypto_unittest_params *ut_params,
91 struct crypto_testsuite_params *ts_param,
92 const uint8_t *cipher,
93 const uint8_t *digest,
96 static struct rte_mbuf *
97 setup_test_string(struct rte_mempool *mpool,
98 const char *string, size_t len, uint8_t blocksize)
100 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
101 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
103 memset(m->buf_addr, 0, m->buf_len);
105 char *dst = rte_pktmbuf_append(m, t_len);
112 rte_memcpy(dst, string, t_len);
114 memset(dst, 0, t_len);
120 /* Get number of bytes in X bits (rounding up) */
122 ceil_byte_length(uint32_t num_bits)
125 return ((num_bits >> 3) + 1);
127 return (num_bits >> 3);
130 static struct rte_crypto_op *
131 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
133 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
134 printf("Error sending packet for encryption");
140 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
146 static struct crypto_testsuite_params testsuite_params = { NULL };
147 static struct crypto_unittest_params unittest_params;
150 testsuite_setup(void)
152 struct crypto_testsuite_params *ts_params = &testsuite_params;
153 struct rte_cryptodev_info info;
154 uint32_t i = 0, nb_devs, dev_id;
158 memset(ts_params, 0, sizeof(*ts_params));
160 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
161 if (ts_params->mbuf_pool == NULL) {
162 /* Not already created so create */
163 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
165 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
167 if (ts_params->mbuf_pool == NULL) {
168 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
173 ts_params->large_mbuf_pool = rte_mempool_lookup(
174 "CRYPTO_LARGE_MBUFPOOL");
175 if (ts_params->large_mbuf_pool == NULL) {
176 /* Not already created so create */
177 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
178 "CRYPTO_LARGE_MBUFPOOL",
181 if (ts_params->large_mbuf_pool == NULL) {
183 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
188 ts_params->op_mpool = rte_crypto_op_pool_create(
189 "MBUF_CRYPTO_SYM_OP_POOL",
190 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
191 NUM_MBUFS, MBUF_CACHE_SIZE,
193 sizeof(struct rte_crypto_sym_xform) +
196 if (ts_params->op_mpool == NULL) {
197 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
201 /* Create an AESNI MB device if required */
202 if (gbl_driver_id == rte_cryptodev_driver_id_get(
203 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
204 nb_devs = rte_cryptodev_device_count_by_driver(
205 rte_cryptodev_driver_id_get(
206 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
209 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
211 TEST_ASSERT(ret == 0,
212 "Failed to create instance of"
214 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
218 /* Create an AESNI GCM device if required */
219 if (gbl_driver_id == rte_cryptodev_driver_id_get(
220 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
221 nb_devs = rte_cryptodev_device_count_by_driver(
222 rte_cryptodev_driver_id_get(
223 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
225 TEST_ASSERT_SUCCESS(rte_vdev_init(
226 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
227 "Failed to create instance of"
229 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
233 /* Create a SNOW 3G device if required */
234 if (gbl_driver_id == rte_cryptodev_driver_id_get(
235 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
236 nb_devs = rte_cryptodev_device_count_by_driver(
237 rte_cryptodev_driver_id_get(
238 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
240 TEST_ASSERT_SUCCESS(rte_vdev_init(
241 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
242 "Failed to create instance of"
244 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
248 /* Create a KASUMI device if required */
249 if (gbl_driver_id == rte_cryptodev_driver_id_get(
250 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
251 nb_devs = rte_cryptodev_device_count_by_driver(
252 rte_cryptodev_driver_id_get(
253 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
255 TEST_ASSERT_SUCCESS(rte_vdev_init(
256 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
257 "Failed to create instance of"
259 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
263 /* Create a ZUC device if required */
264 if (gbl_driver_id == rte_cryptodev_driver_id_get(
265 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
266 nb_devs = rte_cryptodev_device_count_by_driver(
267 rte_cryptodev_driver_id_get(
268 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
270 TEST_ASSERT_SUCCESS(rte_vdev_init(
271 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
272 "Failed to create instance of"
274 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
278 /* Create a NULL device if required */
279 if (gbl_driver_id == rte_cryptodev_driver_id_get(
280 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
281 nb_devs = rte_cryptodev_device_count_by_driver(
282 rte_cryptodev_driver_id_get(
283 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
286 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
288 TEST_ASSERT(ret == 0,
289 "Failed to create instance of"
291 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
295 /* Create an OPENSSL device if required */
296 if (gbl_driver_id == rte_cryptodev_driver_id_get(
297 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
298 nb_devs = rte_cryptodev_device_count_by_driver(
299 rte_cryptodev_driver_id_get(
300 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
303 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
306 TEST_ASSERT(ret == 0, "Failed to create "
307 "instance of pmd : %s",
308 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
312 /* Create a ARMv8 device if required */
313 if (gbl_driver_id == rte_cryptodev_driver_id_get(
314 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
315 nb_devs = rte_cryptodev_device_count_by_driver(
316 rte_cryptodev_driver_id_get(
317 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
320 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
323 TEST_ASSERT(ret == 0, "Failed to create "
324 "instance of pmd : %s",
325 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
329 /* Create a MVSAM device if required */
330 if (gbl_driver_id == rte_cryptodev_driver_id_get(
331 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
332 nb_devs = rte_cryptodev_device_count_by_driver(
333 rte_cryptodev_driver_id_get(
334 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
337 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
340 TEST_ASSERT(ret == 0, "Failed to create "
341 "instance of pmd : %s",
342 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
346 /* Create an CCP device if required */
347 if (gbl_driver_id == rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
349 nb_devs = rte_cryptodev_device_count_by_driver(
350 rte_cryptodev_driver_id_get(
351 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
354 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
357 TEST_ASSERT(ret == 0, "Failed to create "
358 "instance of pmd : %s",
359 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
363 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
364 char vdev_args[VDEV_ARGS_SIZE] = {""};
365 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
366 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
367 uint16_t slave_core_count = 0;
368 uint16_t socket_id = 0;
370 if (gbl_driver_id == rte_cryptodev_driver_id_get(
371 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
373 /* Identify the Slave Cores
374 * Use 2 slave cores for the device args
376 RTE_LCORE_FOREACH_SLAVE(i) {
377 if (slave_core_count > 1)
379 snprintf(vdev_args, sizeof(vdev_args),
380 "%s%d", temp_str, i);
381 strcpy(temp_str, vdev_args);
382 strlcat(temp_str, ";", sizeof(temp_str));
384 socket_id = rte_lcore_to_socket_id(i);
386 if (slave_core_count != 2) {
388 "Cryptodev scheduler test require at least "
389 "two slave cores to run. "
390 "Please use the correct coremask.\n");
393 strcpy(temp_str, vdev_args);
394 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
395 temp_str, socket_id);
396 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
397 nb_devs = rte_cryptodev_device_count_by_driver(
398 rte_cryptodev_driver_id_get(
399 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
402 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
404 TEST_ASSERT(ret == 0,
405 "Failed to create instance %u of"
407 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
410 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
412 nb_devs = rte_cryptodev_count();
414 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
418 /* Create list of valid crypto devs */
419 for (i = 0; i < nb_devs; i++) {
420 rte_cryptodev_info_get(i, &info);
421 if (info.driver_id == gbl_driver_id)
422 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
425 if (ts_params->valid_dev_count < 1)
428 /* Set up all the qps on the first of the valid devices found */
430 dev_id = ts_params->valid_devs[0];
432 rte_cryptodev_info_get(dev_id, &info);
434 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
435 ts_params->conf.socket_id = SOCKET_ID_ANY;
436 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
438 unsigned int session_size =
439 rte_cryptodev_sym_get_private_session_size(dev_id);
442 * Create mempool with maximum number of sessions * 2,
443 * to include the session headers
445 if (info.sym.max_nb_sessions != 0 &&
446 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
447 RTE_LOG(ERR, USER1, "Device does not support "
448 "at least %u sessions\n",
453 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
454 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
456 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
457 "session mempool allocation failed");
459 ts_params->session_priv_mpool = rte_mempool_create(
463 0, 0, NULL, NULL, NULL,
466 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
467 "session mempool allocation failed");
471 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
473 "Failed to configure cryptodev %u with %u qps",
474 dev_id, ts_params->conf.nb_queue_pairs);
476 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
477 ts_params->qp_conf.mp_session = ts_params->session_mpool;
478 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
480 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
481 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
482 dev_id, qp_id, &ts_params->qp_conf,
483 rte_cryptodev_socket_id(dev_id)),
484 "Failed to setup queue pair %u on cryptodev %u",
492 testsuite_teardown(void)
494 struct crypto_testsuite_params *ts_params = &testsuite_params;
496 if (ts_params->mbuf_pool != NULL) {
497 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
498 rte_mempool_avail_count(ts_params->mbuf_pool));
501 if (ts_params->op_mpool != NULL) {
502 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
503 rte_mempool_avail_count(ts_params->op_mpool));
506 /* Free session mempools */
507 if (ts_params->session_priv_mpool != NULL) {
508 rte_mempool_free(ts_params->session_priv_mpool);
509 ts_params->session_priv_mpool = NULL;
512 if (ts_params->session_mpool != NULL) {
513 rte_mempool_free(ts_params->session_mpool);
514 ts_params->session_mpool = NULL;
521 struct crypto_testsuite_params *ts_params = &testsuite_params;
522 struct crypto_unittest_params *ut_params = &unittest_params;
526 /* Clear unit test parameters before running test */
527 memset(ut_params, 0, sizeof(*ut_params));
529 /* Reconfigure device to default parameters */
530 ts_params->conf.socket_id = SOCKET_ID_ANY;
531 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
532 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
533 ts_params->qp_conf.mp_session = ts_params->session_mpool;
534 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
536 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
538 "Failed to configure cryptodev %u",
539 ts_params->valid_devs[0]);
541 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
542 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
543 ts_params->valid_devs[0], qp_id,
545 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
546 "Failed to setup queue pair %u on cryptodev %u",
547 qp_id, ts_params->valid_devs[0]);
551 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
553 /* Start the device */
554 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
555 "Failed to start cryptodev %u",
556 ts_params->valid_devs[0]);
564 struct crypto_testsuite_params *ts_params = &testsuite_params;
565 struct crypto_unittest_params *ut_params = &unittest_params;
566 struct rte_cryptodev_stats stats;
568 /* free crypto session structure */
569 if (ut_params->sess) {
570 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
572 rte_cryptodev_sym_session_free(ut_params->sess);
573 ut_params->sess = NULL;
576 /* free crypto operation structure */
578 rte_crypto_op_free(ut_params->op);
581 * free mbuf - both obuf and ibuf are usually the same,
582 * so check if they point at the same address is necessary,
583 * to avoid freeing the mbuf twice.
585 if (ut_params->obuf) {
586 rte_pktmbuf_free(ut_params->obuf);
587 if (ut_params->ibuf == ut_params->obuf)
591 if (ut_params->ibuf) {
592 rte_pktmbuf_free(ut_params->ibuf);
596 if (ts_params->mbuf_pool != NULL)
597 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
598 rte_mempool_avail_count(ts_params->mbuf_pool));
600 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
602 /* Stop the device */
603 rte_cryptodev_stop(ts_params->valid_devs[0]);
607 test_device_configure_invalid_dev_id(void)
609 struct crypto_testsuite_params *ts_params = &testsuite_params;
610 uint16_t dev_id, num_devs = 0;
612 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
613 "Need at least %d devices for test", 1);
615 /* valid dev_id values */
616 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
618 /* Stop the device in case it's started so it can be configured */
619 rte_cryptodev_stop(dev_id);
621 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
622 "Failed test for rte_cryptodev_configure: "
623 "invalid dev_num %u", dev_id);
625 /* invalid dev_id values */
628 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
629 "Failed test for rte_cryptodev_configure: "
630 "invalid dev_num %u", dev_id);
634 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
635 "Failed test for rte_cryptodev_configure:"
636 "invalid dev_num %u", dev_id);
642 test_device_configure_invalid_queue_pair_ids(void)
644 struct crypto_testsuite_params *ts_params = &testsuite_params;
645 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
647 /* Stop the device in case it's started so it can be configured */
648 rte_cryptodev_stop(ts_params->valid_devs[0]);
650 /* valid - one queue pairs */
651 ts_params->conf.nb_queue_pairs = 1;
653 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
655 "Failed to configure cryptodev: dev_id %u, qp_id %u",
656 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
659 /* valid - max value queue pairs */
660 ts_params->conf.nb_queue_pairs = orig_nb_qps;
662 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
664 "Failed to configure cryptodev: dev_id %u, qp_id %u",
665 ts_params->valid_devs[0],
666 ts_params->conf.nb_queue_pairs);
669 /* invalid - zero queue pairs */
670 ts_params->conf.nb_queue_pairs = 0;
672 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
674 "Failed test for rte_cryptodev_configure, dev_id %u,"
676 ts_params->valid_devs[0],
677 ts_params->conf.nb_queue_pairs);
680 /* invalid - max value supported by field queue pairs */
681 ts_params->conf.nb_queue_pairs = UINT16_MAX;
683 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
685 "Failed test for rte_cryptodev_configure, dev_id %u,"
687 ts_params->valid_devs[0],
688 ts_params->conf.nb_queue_pairs);
691 /* invalid - max value + 1 queue pairs */
692 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
694 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
696 "Failed test for rte_cryptodev_configure, dev_id %u,"
698 ts_params->valid_devs[0],
699 ts_params->conf.nb_queue_pairs);
701 /* revert to original testsuite value */
702 ts_params->conf.nb_queue_pairs = orig_nb_qps;
708 test_queue_pair_descriptor_setup(void)
710 struct crypto_testsuite_params *ts_params = &testsuite_params;
711 struct rte_cryptodev_info dev_info;
712 struct rte_cryptodev_qp_conf qp_conf = {
713 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
718 /* Stop the device in case it's started so it can be configured */
719 rte_cryptodev_stop(ts_params->valid_devs[0]);
722 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
724 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
726 "Failed to configure cryptodev %u",
727 ts_params->valid_devs[0]);
730 * Test various ring sizes on this device. memzones can't be
731 * freed so are re-used if ring is released and re-created.
733 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
734 qp_conf.mp_session = ts_params->session_mpool;
735 qp_conf.mp_session_private = ts_params->session_priv_mpool;
737 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
738 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
739 ts_params->valid_devs[0], qp_id, &qp_conf,
740 rte_cryptodev_socket_id(
741 ts_params->valid_devs[0])),
743 "rte_cryptodev_queue_pair_setup: num_inflights "
744 "%u on qp %u on cryptodev %u",
745 qp_conf.nb_descriptors, qp_id,
746 ts_params->valid_devs[0]);
749 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
751 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
752 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
753 ts_params->valid_devs[0], qp_id, &qp_conf,
754 rte_cryptodev_socket_id(
755 ts_params->valid_devs[0])),
757 " rte_cryptodev_queue_pair_setup: num_inflights"
758 " %u on qp %u on cryptodev %u",
759 qp_conf.nb_descriptors, qp_id,
760 ts_params->valid_devs[0]);
763 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
765 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
766 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
767 ts_params->valid_devs[0], qp_id, &qp_conf,
768 rte_cryptodev_socket_id(
769 ts_params->valid_devs[0])),
771 "rte_cryptodev_queue_pair_setup: num_inflights"
772 " %u on qp %u on cryptodev %u",
773 qp_conf.nb_descriptors, qp_id,
774 ts_params->valid_devs[0]);
777 /* invalid number of descriptors - max supported + 2 */
778 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
780 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
781 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
782 ts_params->valid_devs[0], qp_id, &qp_conf,
783 rte_cryptodev_socket_id(
784 ts_params->valid_devs[0])),
785 "Unexpectedly passed test for "
786 "rte_cryptodev_queue_pair_setup:"
787 "num_inflights %u on qp %u on cryptodev %u",
788 qp_conf.nb_descriptors, qp_id,
789 ts_params->valid_devs[0]);
792 /* invalid number of descriptors - max value of parameter */
793 qp_conf.nb_descriptors = UINT32_MAX-1;
795 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
796 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
797 ts_params->valid_devs[0], qp_id, &qp_conf,
798 rte_cryptodev_socket_id(
799 ts_params->valid_devs[0])),
800 "Unexpectedly passed test for "
801 "rte_cryptodev_queue_pair_setup:"
802 "num_inflights %u on qp %u on cryptodev %u",
803 qp_conf.nb_descriptors, qp_id,
804 ts_params->valid_devs[0]);
807 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
809 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
810 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
811 ts_params->valid_devs[0], qp_id, &qp_conf,
812 rte_cryptodev_socket_id(
813 ts_params->valid_devs[0])),
815 " rte_cryptodev_queue_pair_setup:"
816 "num_inflights %u on qp %u on cryptodev %u",
817 qp_conf.nb_descriptors, qp_id,
818 ts_params->valid_devs[0]);
821 /* invalid number of descriptors - max supported + 1 */
822 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
824 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
825 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
826 ts_params->valid_devs[0], qp_id, &qp_conf,
827 rte_cryptodev_socket_id(
828 ts_params->valid_devs[0])),
829 "Unexpectedly passed test for "
830 "rte_cryptodev_queue_pair_setup:"
831 "num_inflights %u on qp %u on cryptodev %u",
832 qp_conf.nb_descriptors, qp_id,
833 ts_params->valid_devs[0]);
836 /* test invalid queue pair id */
837 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
839 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
841 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
842 ts_params->valid_devs[0],
844 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
845 "Failed test for rte_cryptodev_queue_pair_setup:"
846 "invalid qp %u on cryptodev %u",
847 qp_id, ts_params->valid_devs[0]);
849 qp_id = 0xffff; /*invalid*/
851 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
852 ts_params->valid_devs[0],
854 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
855 "Failed test for rte_cryptodev_queue_pair_setup:"
856 "invalid qp %u on cryptodev %u",
857 qp_id, ts_params->valid_devs[0]);
862 /* ***** Plaintext data for tests ***** */
864 const char catch_22_quote_1[] =
865 "There was only one catch and that was Catch-22, which "
866 "specified that a concern for one's safety in the face of "
867 "dangers that were real and immediate was the process of a "
868 "rational mind. Orr was crazy and could be grounded. All he "
869 "had to do was ask; and as soon as he did, he would no longer "
870 "be crazy and would have to fly more missions. Orr would be "
871 "crazy to fly more missions and sane if he didn't, but if he "
872 "was sane he had to fly them. If he flew them he was crazy "
873 "and didn't have to; but if he didn't want to he was sane and "
874 "had to. Yossarian was moved very deeply by the absolute "
875 "simplicity of this clause of Catch-22 and let out a "
876 "respectful whistle. \"That's some catch, that Catch-22\", he "
877 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
879 const char catch_22_quote[] =
880 "What a lousy earth! He wondered how many people were "
881 "destitute that same night even in his own prosperous country, "
882 "how many homes were shanties, how many husbands were drunk "
883 "and wives socked, and how many children were bullied, abused, "
884 "or abandoned. How many families hungered for food they could "
885 "not afford to buy? How many hearts were broken? How many "
886 "suicides would take place that same night, how many people "
887 "would go insane? How many cockroaches and landlords would "
888 "triumph? How many winners were losers, successes failures, "
889 "and rich men poor men? How many wise guys were stupid? How "
890 "many happy endings were unhappy endings? How many honest men "
891 "were liars, brave men cowards, loyal men traitors, how many "
892 "sainted men were corrupt, how many people in positions of "
893 "trust had sold their souls to bodyguards, how many had never "
894 "had souls? How many straight-and-narrow paths were crooked "
895 "paths? How many best families were worst families and how "
896 "many good people were bad people? When you added them all up "
897 "and then subtracted, you might be left with only the children, "
898 "and perhaps with Albert Einstein and an old violinist or "
899 "sculptor somewhere.";
901 #define QUOTE_480_BYTES (480)
902 #define QUOTE_512_BYTES (512)
903 #define QUOTE_768_BYTES (768)
904 #define QUOTE_1024_BYTES (1024)
908 /* ***** SHA1 Hash Tests ***** */
910 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
912 static uint8_t hmac_sha1_key[] = {
913 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
914 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
915 0xDE, 0xF4, 0xDE, 0xAD };
917 /* ***** SHA224 Hash Tests ***** */
919 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
922 /* ***** AES-CBC Cipher Tests ***** */
924 #define CIPHER_KEY_LENGTH_AES_CBC (16)
925 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
927 static uint8_t aes_cbc_key[] = {
928 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
929 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
931 static uint8_t aes_cbc_iv[] = {
932 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
933 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
936 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
938 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
939 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
940 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
941 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
942 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
943 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
944 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
945 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
946 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
947 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
948 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
949 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
950 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
951 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
952 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
953 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
954 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
955 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
956 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
957 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
958 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
959 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
960 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
961 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
962 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
963 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
964 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
965 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
966 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
967 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
968 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
969 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
970 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
971 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
972 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
973 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
974 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
975 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
976 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
977 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
978 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
979 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
980 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
981 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
982 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
983 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
984 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
985 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
986 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
987 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
988 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
989 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
990 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
991 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
992 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
993 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
994 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
995 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
996 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
997 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
998 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
999 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1000 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1001 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1002 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1005 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1006 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1007 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1008 0x18, 0x8c, 0x1d, 0x32
1012 /* Multisession Vector context Test */
1013 /*Begin Session 0 */
1014 static uint8_t ms_aes_cbc_key0[] = {
1015 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1016 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1019 static uint8_t ms_aes_cbc_iv0[] = {
1020 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1021 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1024 static const uint8_t ms_aes_cbc_cipher0[] = {
1025 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1026 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1027 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1028 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1029 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1030 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1031 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1032 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1033 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1034 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1035 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1036 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1037 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1038 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1039 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1040 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1041 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1042 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1043 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1044 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1045 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1046 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1047 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1048 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1049 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1050 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1051 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1052 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1053 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1054 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1055 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1056 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1057 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1058 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1059 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1060 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1061 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1062 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1063 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1064 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1065 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1066 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1067 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1068 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1069 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1070 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1071 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1072 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1073 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1074 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1075 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1076 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1077 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1078 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1079 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1080 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1081 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1082 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1083 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1084 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1085 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1086 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1087 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1088 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1092 static uint8_t ms_hmac_key0[] = {
1093 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1094 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1095 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1096 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1097 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1098 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1099 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1100 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1103 static const uint8_t ms_hmac_digest0[] = {
1104 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1105 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1106 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1107 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1108 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1109 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1110 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1111 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1115 /* Begin session 1 */
1117 static uint8_t ms_aes_cbc_key1[] = {
1118 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1119 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1122 static uint8_t ms_aes_cbc_iv1[] = {
1123 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1124 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1127 static const uint8_t ms_aes_cbc_cipher1[] = {
1128 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1129 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1130 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1131 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1132 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1133 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1134 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1135 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1136 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1137 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1138 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1139 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1140 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1141 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1142 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1143 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1144 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1145 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1146 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1147 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1148 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1149 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1150 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1151 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1152 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1153 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1154 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1155 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1156 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1157 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1158 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1159 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1160 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1161 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1162 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1163 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1164 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1165 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1166 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1167 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1168 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1169 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1170 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1171 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1172 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1173 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1174 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1175 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1176 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1177 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1178 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1179 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1180 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1181 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1182 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1183 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1184 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1185 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1186 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1187 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1188 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1189 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1190 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1191 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1195 static uint8_t ms_hmac_key1[] = {
1196 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1197 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1198 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1199 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1200 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1201 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1202 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1203 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1206 static const uint8_t ms_hmac_digest1[] = {
1207 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1208 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1209 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1210 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1211 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1212 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1213 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1214 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1217 /* Begin Session 2 */
1218 static uint8_t ms_aes_cbc_key2[] = {
1219 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1220 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1223 static uint8_t ms_aes_cbc_iv2[] = {
1224 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1225 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1228 static const uint8_t ms_aes_cbc_cipher2[] = {
1229 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1230 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1231 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1232 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1233 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1234 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1235 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1236 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1237 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1238 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1239 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1240 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1241 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1242 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1243 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1244 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1245 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1246 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1247 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1248 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1249 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1250 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1251 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1252 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1253 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1254 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1255 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1256 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1257 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1258 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1259 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1260 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1261 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1262 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1263 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1264 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1265 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1266 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1267 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1268 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1269 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1270 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1271 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1272 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1273 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1274 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1275 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1276 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1277 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1278 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1279 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1280 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1281 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1282 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1283 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1284 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1285 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1286 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1287 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1288 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1289 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1290 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1291 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1292 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1295 static uint8_t ms_hmac_key2[] = {
1296 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1297 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1298 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1299 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1300 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1301 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1302 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1303 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1306 static const uint8_t ms_hmac_digest2[] = {
1307 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1308 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1309 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1310 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1311 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1312 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1313 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1314 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1321 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1323 struct crypto_testsuite_params *ts_params = &testsuite_params;
1324 struct crypto_unittest_params *ut_params = &unittest_params;
1326 /* Generate test mbuf data and space for digest */
1327 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1328 catch_22_quote, QUOTE_512_BYTES, 0);
1330 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1331 DIGEST_BYTE_LENGTH_SHA1);
1332 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1334 /* Setup Cipher Parameters */
1335 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1336 ut_params->cipher_xform.next = &ut_params->auth_xform;
1338 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1339 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1340 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1341 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1342 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1343 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1345 /* Setup HMAC Parameters */
1346 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1348 ut_params->auth_xform.next = NULL;
1350 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1351 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1352 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1353 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1354 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1356 ut_params->sess = rte_cryptodev_sym_session_create(
1357 ts_params->session_mpool);
1359 /* Create crypto session*/
1360 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1361 ut_params->sess, &ut_params->cipher_xform,
1362 ts_params->session_priv_mpool);
1363 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1365 /* Generate crypto op data structure */
1366 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1367 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1368 TEST_ASSERT_NOT_NULL(ut_params->op,
1369 "Failed to allocate symmetric crypto operation struct");
1371 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1373 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1375 /* set crypto operation source mbuf */
1376 sym_op->m_src = ut_params->ibuf;
1378 /* Set crypto operation authentication parameters */
1379 sym_op->auth.digest.data = ut_params->digest;
1380 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1381 ut_params->ibuf, QUOTE_512_BYTES);
1383 sym_op->auth.data.offset = 0;
1384 sym_op->auth.data.length = QUOTE_512_BYTES;
1386 /* Copy IV at the end of the crypto operation */
1387 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1388 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1390 /* Set crypto operation cipher parameters */
1391 sym_op->cipher.data.offset = 0;
1392 sym_op->cipher.data.length = QUOTE_512_BYTES;
1394 /* Process crypto operation */
1395 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1396 ut_params->op), "failed to process sym crypto op");
1398 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1399 "crypto op processing failed");
1402 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1405 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1406 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1408 "ciphertext data not as expected");
1410 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1412 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1413 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1414 gbl_driver_id == rte_cryptodev_driver_id_get(
1415 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1416 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1417 DIGEST_BYTE_LENGTH_SHA1,
1418 "Generated digest data not as expected");
1420 return TEST_SUCCESS;
1423 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1425 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1427 static uint8_t hmac_sha512_key[] = {
1428 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1429 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1430 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1431 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1432 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1433 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1434 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1435 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1437 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1438 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1439 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1440 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1441 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1442 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1443 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1444 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1445 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1450 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1451 struct crypto_unittest_params *ut_params,
1452 uint8_t *cipher_key,
1456 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1457 struct crypto_unittest_params *ut_params,
1458 struct crypto_testsuite_params *ts_params,
1459 const uint8_t *cipher,
1460 const uint8_t *digest,
1465 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1466 struct crypto_unittest_params *ut_params,
1467 uint8_t *cipher_key,
1471 /* Setup Cipher Parameters */
1472 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1473 ut_params->cipher_xform.next = NULL;
1475 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1476 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1477 ut_params->cipher_xform.cipher.key.data = cipher_key;
1478 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1479 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1480 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1482 /* Setup HMAC Parameters */
1483 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1484 ut_params->auth_xform.next = &ut_params->cipher_xform;
1486 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1487 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1488 ut_params->auth_xform.auth.key.data = hmac_key;
1489 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1490 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1492 return TEST_SUCCESS;
1497 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1498 struct crypto_unittest_params *ut_params,
1499 struct crypto_testsuite_params *ts_params,
1500 const uint8_t *cipher,
1501 const uint8_t *digest,
1504 /* Generate test mbuf data and digest */
1505 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1508 QUOTE_512_BYTES, 0);
1510 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1511 DIGEST_BYTE_LENGTH_SHA512);
1512 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1514 rte_memcpy(ut_params->digest,
1516 DIGEST_BYTE_LENGTH_SHA512);
1518 /* Generate Crypto op data structure */
1519 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1520 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1521 TEST_ASSERT_NOT_NULL(ut_params->op,
1522 "Failed to allocate symmetric crypto operation struct");
1524 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1526 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1528 /* set crypto operation source mbuf */
1529 sym_op->m_src = ut_params->ibuf;
1531 sym_op->auth.digest.data = ut_params->digest;
1532 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1533 ut_params->ibuf, QUOTE_512_BYTES);
1535 sym_op->auth.data.offset = 0;
1536 sym_op->auth.data.length = QUOTE_512_BYTES;
1538 /* Copy IV at the end of the crypto operation */
1539 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1540 iv, CIPHER_IV_LENGTH_AES_CBC);
1542 sym_op->cipher.data.offset = 0;
1543 sym_op->cipher.data.length = QUOTE_512_BYTES;
1545 /* Process crypto operation */
1546 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1547 ut_params->op), "failed to process sym crypto op");
1549 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1550 "crypto op processing failed");
1552 ut_params->obuf = ut_params->op->sym->m_src;
1555 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1556 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1559 "Plaintext data not as expected");
1562 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1563 "Digest verification failed");
1565 return TEST_SUCCESS;
1569 test_AES_cipheronly_mb_all(void)
1571 struct crypto_testsuite_params *ts_params = &testsuite_params;
1574 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1575 ts_params->op_mpool,
1576 ts_params->session_mpool, ts_params->session_priv_mpool,
1577 ts_params->valid_devs[0],
1578 rte_cryptodev_driver_id_get(
1579 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1580 BLKCIPHER_AES_CIPHERONLY_TYPE);
1582 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1584 return TEST_SUCCESS;
1588 test_AES_docsis_mb_all(void)
1590 struct crypto_testsuite_params *ts_params = &testsuite_params;
1593 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1594 ts_params->op_mpool,
1595 ts_params->session_mpool, ts_params->session_priv_mpool,
1596 ts_params->valid_devs[0],
1597 rte_cryptodev_driver_id_get(
1598 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1599 BLKCIPHER_AES_DOCSIS_TYPE);
1601 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1603 return TEST_SUCCESS;
1607 test_AES_docsis_qat_all(void)
1609 struct crypto_testsuite_params *ts_params = &testsuite_params;
1612 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1613 ts_params->op_mpool,
1614 ts_params->session_mpool, ts_params->session_priv_mpool,
1615 ts_params->valid_devs[0],
1616 rte_cryptodev_driver_id_get(
1617 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1618 BLKCIPHER_AES_DOCSIS_TYPE);
1620 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1622 return TEST_SUCCESS;
1626 test_DES_docsis_qat_all(void)
1628 struct crypto_testsuite_params *ts_params = &testsuite_params;
1631 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1632 ts_params->op_mpool,
1633 ts_params->session_mpool, ts_params->session_priv_mpool,
1634 ts_params->valid_devs[0],
1635 rte_cryptodev_driver_id_get(
1636 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1637 BLKCIPHER_DES_DOCSIS_TYPE);
1639 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1641 return TEST_SUCCESS;
1645 test_authonly_mb_all(void)
1647 struct crypto_testsuite_params *ts_params = &testsuite_params;
1650 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1651 ts_params->op_mpool,
1652 ts_params->session_mpool, ts_params->session_priv_mpool,
1653 ts_params->valid_devs[0],
1654 rte_cryptodev_driver_id_get(
1655 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1656 BLKCIPHER_AUTHONLY_TYPE);
1658 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1660 return TEST_SUCCESS;
1664 test_authonly_qat_all(void)
1666 struct crypto_testsuite_params *ts_params = &testsuite_params;
1669 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1670 ts_params->op_mpool,
1671 ts_params->session_mpool, ts_params->session_priv_mpool,
1672 ts_params->valid_devs[0],
1673 rte_cryptodev_driver_id_get(
1674 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1675 BLKCIPHER_AUTHONLY_TYPE);
1677 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1679 return TEST_SUCCESS;
1683 test_AES_chain_null_all(void)
1685 struct crypto_testsuite_params *ts_params = &testsuite_params;
1688 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1689 ts_params->op_mpool,
1690 ts_params->session_mpool, ts_params->session_priv_mpool,
1691 ts_params->valid_devs[0],
1692 rte_cryptodev_driver_id_get(
1693 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1694 BLKCIPHER_AES_CHAIN_TYPE);
1696 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1698 return TEST_SUCCESS;
1702 test_AES_cipheronly_null_all(void)
1704 struct crypto_testsuite_params *ts_params = &testsuite_params;
1707 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1708 ts_params->op_mpool,
1709 ts_params->session_mpool, ts_params->session_priv_mpool,
1710 ts_params->valid_devs[0],
1711 rte_cryptodev_driver_id_get(
1712 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1713 BLKCIPHER_AES_CIPHERONLY_TYPE);
1715 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1717 return TEST_SUCCESS;
1721 test_authonly_null_all(void)
1723 struct crypto_testsuite_params *ts_params = &testsuite_params;
1726 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1727 ts_params->op_mpool,
1728 ts_params->session_mpool, ts_params->session_priv_mpool,
1729 ts_params->valid_devs[0],
1730 rte_cryptodev_driver_id_get(
1731 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1732 BLKCIPHER_AUTHONLY_TYPE);
1734 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1736 return TEST_SUCCESS;
1740 test_AES_chain_mb_all(void)
1742 struct crypto_testsuite_params *ts_params = &testsuite_params;
1745 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1746 ts_params->op_mpool,
1747 ts_params->session_mpool, ts_params->session_priv_mpool,
1748 ts_params->valid_devs[0],
1749 rte_cryptodev_driver_id_get(
1750 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1751 BLKCIPHER_AES_CHAIN_TYPE);
1753 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1755 return TEST_SUCCESS;
1758 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1761 test_AES_cipheronly_scheduler_all(void)
1763 struct crypto_testsuite_params *ts_params = &testsuite_params;
1766 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1767 ts_params->op_mpool,
1768 ts_params->session_mpool, ts_params->session_priv_mpool,
1769 ts_params->valid_devs[0],
1770 rte_cryptodev_driver_id_get(
1771 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1772 BLKCIPHER_AES_CIPHERONLY_TYPE);
1774 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1776 return TEST_SUCCESS;
1780 test_AES_chain_scheduler_all(void)
1782 struct crypto_testsuite_params *ts_params = &testsuite_params;
1785 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1786 ts_params->op_mpool,
1787 ts_params->session_mpool, ts_params->session_priv_mpool,
1788 ts_params->valid_devs[0],
1789 rte_cryptodev_driver_id_get(
1790 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1791 BLKCIPHER_AES_CHAIN_TYPE);
1793 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1795 return TEST_SUCCESS;
1799 test_authonly_scheduler_all(void)
1801 struct crypto_testsuite_params *ts_params = &testsuite_params;
1804 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1805 ts_params->op_mpool,
1806 ts_params->session_mpool, ts_params->session_priv_mpool,
1807 ts_params->valid_devs[0],
1808 rte_cryptodev_driver_id_get(
1809 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1810 BLKCIPHER_AUTHONLY_TYPE);
1812 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1814 return TEST_SUCCESS;
1817 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1820 test_AES_chain_openssl_all(void)
1822 struct crypto_testsuite_params *ts_params = &testsuite_params;
1825 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1826 ts_params->op_mpool,
1827 ts_params->session_mpool, ts_params->session_priv_mpool,
1828 ts_params->valid_devs[0],
1829 rte_cryptodev_driver_id_get(
1830 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1831 BLKCIPHER_AES_CHAIN_TYPE);
1833 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1835 return TEST_SUCCESS;
1839 test_AES_cipheronly_openssl_all(void)
1841 struct crypto_testsuite_params *ts_params = &testsuite_params;
1844 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1845 ts_params->op_mpool,
1846 ts_params->session_mpool, ts_params->session_priv_mpool,
1847 ts_params->valid_devs[0],
1848 rte_cryptodev_driver_id_get(
1849 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1850 BLKCIPHER_AES_CIPHERONLY_TYPE);
1852 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1854 return TEST_SUCCESS;
1858 test_AES_chain_ccp_all(void)
1860 struct crypto_testsuite_params *ts_params = &testsuite_params;
1863 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1864 ts_params->op_mpool,
1865 ts_params->session_mpool, ts_params->session_priv_mpool,
1866 ts_params->valid_devs[0],
1867 rte_cryptodev_driver_id_get(
1868 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1869 BLKCIPHER_AES_CHAIN_TYPE);
1871 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1873 return TEST_SUCCESS;
1877 test_AES_cipheronly_ccp_all(void)
1879 struct crypto_testsuite_params *ts_params = &testsuite_params;
1882 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1883 ts_params->op_mpool,
1884 ts_params->session_mpool, ts_params->session_priv_mpool,
1885 ts_params->valid_devs[0],
1886 rte_cryptodev_driver_id_get(
1887 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1888 BLKCIPHER_AES_CIPHERONLY_TYPE);
1890 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1892 return TEST_SUCCESS;
1896 test_AES_chain_qat_all(void)
1898 struct crypto_testsuite_params *ts_params = &testsuite_params;
1901 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1902 ts_params->op_mpool,
1903 ts_params->session_mpool, ts_params->session_priv_mpool,
1904 ts_params->valid_devs[0],
1905 rte_cryptodev_driver_id_get(
1906 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1907 BLKCIPHER_AES_CHAIN_TYPE);
1909 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1911 return TEST_SUCCESS;
1915 test_AES_cipheronly_qat_all(void)
1917 struct crypto_testsuite_params *ts_params = &testsuite_params;
1920 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1921 ts_params->op_mpool,
1922 ts_params->session_mpool, ts_params->session_priv_mpool,
1923 ts_params->valid_devs[0],
1924 rte_cryptodev_driver_id_get(
1925 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1926 BLKCIPHER_AES_CIPHERONLY_TYPE);
1928 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1930 return TEST_SUCCESS;
1934 test_AES_cipheronly_virtio_all(void)
1936 struct crypto_testsuite_params *ts_params = &testsuite_params;
1939 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1940 ts_params->op_mpool,
1941 ts_params->session_mpool, ts_params->session_priv_mpool,
1942 ts_params->valid_devs[0],
1943 rte_cryptodev_driver_id_get(
1944 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1945 BLKCIPHER_AES_CIPHERONLY_TYPE);
1947 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1949 return TEST_SUCCESS;
1953 test_AES_chain_caam_jr_all(void)
1955 struct crypto_testsuite_params *ts_params = &testsuite_params;
1958 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1959 ts_params->op_mpool,
1960 ts_params->session_mpool, ts_params->session_priv_mpool,
1961 ts_params->valid_devs[0],
1962 rte_cryptodev_driver_id_get(
1963 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1964 BLKCIPHER_AES_CHAIN_TYPE);
1966 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1968 return TEST_SUCCESS;
1972 test_AES_cipheronly_caam_jr_all(void)
1974 struct crypto_testsuite_params *ts_params = &testsuite_params;
1977 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1978 ts_params->op_mpool,
1979 ts_params->session_mpool, ts_params->session_priv_mpool,
1980 ts_params->valid_devs[0],
1981 rte_cryptodev_driver_id_get(
1982 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1983 BLKCIPHER_AES_CIPHERONLY_TYPE);
1985 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1987 return TEST_SUCCESS;
1991 test_authonly_caam_jr_all(void)
1993 struct crypto_testsuite_params *ts_params = &testsuite_params;
1996 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1997 ts_params->op_mpool,
1998 ts_params->session_mpool, ts_params->session_priv_mpool,
1999 ts_params->valid_devs[0],
2000 rte_cryptodev_driver_id_get(
2001 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2002 BLKCIPHER_AUTHONLY_TYPE);
2004 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2006 return TEST_SUCCESS;
2011 test_AES_chain_dpaa_sec_all(void)
2013 struct crypto_testsuite_params *ts_params = &testsuite_params;
2016 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2017 ts_params->op_mpool,
2018 ts_params->session_mpool, ts_params->session_priv_mpool,
2019 ts_params->valid_devs[0],
2020 rte_cryptodev_driver_id_get(
2021 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2022 BLKCIPHER_AES_CHAIN_TYPE);
2024 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2026 return TEST_SUCCESS;
2030 test_AES_cipheronly_dpaa_sec_all(void)
2032 struct crypto_testsuite_params *ts_params = &testsuite_params;
2035 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2036 ts_params->op_mpool,
2037 ts_params->session_mpool, ts_params->session_priv_mpool,
2038 ts_params->valid_devs[0],
2039 rte_cryptodev_driver_id_get(
2040 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2041 BLKCIPHER_AES_CIPHERONLY_TYPE);
2043 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2045 return TEST_SUCCESS;
2049 test_authonly_dpaa_sec_all(void)
2051 struct crypto_testsuite_params *ts_params = &testsuite_params;
2054 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2055 ts_params->op_mpool,
2056 ts_params->session_mpool, ts_params->session_priv_mpool,
2057 ts_params->valid_devs[0],
2058 rte_cryptodev_driver_id_get(
2059 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2060 BLKCIPHER_AUTHONLY_TYPE);
2062 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2064 return TEST_SUCCESS;
2068 test_AES_chain_dpaa2_sec_all(void)
2070 struct crypto_testsuite_params *ts_params = &testsuite_params;
2073 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2074 ts_params->op_mpool,
2075 ts_params->session_mpool, ts_params->session_priv_mpool,
2076 ts_params->valid_devs[0],
2077 rte_cryptodev_driver_id_get(
2078 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2079 BLKCIPHER_AES_CHAIN_TYPE);
2081 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2083 return TEST_SUCCESS;
2087 test_AES_cipheronly_dpaa2_sec_all(void)
2089 struct crypto_testsuite_params *ts_params = &testsuite_params;
2092 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2093 ts_params->op_mpool,
2094 ts_params->session_mpool, ts_params->session_priv_mpool,
2095 ts_params->valid_devs[0],
2096 rte_cryptodev_driver_id_get(
2097 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2098 BLKCIPHER_AES_CIPHERONLY_TYPE);
2100 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2102 return TEST_SUCCESS;
2106 test_authonly_dpaa2_sec_all(void)
2108 struct crypto_testsuite_params *ts_params = &testsuite_params;
2111 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2112 ts_params->op_mpool,
2113 ts_params->session_mpool, ts_params->session_priv_mpool,
2114 ts_params->valid_devs[0],
2115 rte_cryptodev_driver_id_get(
2116 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2117 BLKCIPHER_AUTHONLY_TYPE);
2119 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2121 return TEST_SUCCESS;
2125 test_authonly_openssl_all(void)
2127 struct crypto_testsuite_params *ts_params = &testsuite_params;
2130 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2131 ts_params->op_mpool,
2132 ts_params->session_mpool, ts_params->session_priv_mpool,
2133 ts_params->valid_devs[0],
2134 rte_cryptodev_driver_id_get(
2135 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2136 BLKCIPHER_AUTHONLY_TYPE);
2138 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2140 return TEST_SUCCESS;
2144 test_authonly_ccp_all(void)
2146 struct crypto_testsuite_params *ts_params = &testsuite_params;
2149 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2150 ts_params->op_mpool,
2151 ts_params->session_mpool, ts_params->session_priv_mpool,
2152 ts_params->valid_devs[0],
2153 rte_cryptodev_driver_id_get(
2154 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2155 BLKCIPHER_AUTHONLY_TYPE);
2157 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2159 return TEST_SUCCESS;
2163 test_AES_chain_armv8_all(void)
2165 struct crypto_testsuite_params *ts_params = &testsuite_params;
2168 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2169 ts_params->op_mpool,
2170 ts_params->session_mpool, ts_params->session_priv_mpool,
2171 ts_params->valid_devs[0],
2172 rte_cryptodev_driver_id_get(
2173 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2174 BLKCIPHER_AES_CHAIN_TYPE);
2176 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2178 return TEST_SUCCESS;
2182 test_AES_chain_mrvl_all(void)
2184 struct crypto_testsuite_params *ts_params = &testsuite_params;
2187 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2188 ts_params->op_mpool,
2189 ts_params->session_mpool, ts_params->session_priv_mpool,
2190 ts_params->valid_devs[0],
2191 rte_cryptodev_driver_id_get(
2192 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2193 BLKCIPHER_AES_CHAIN_TYPE);
2195 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2197 return TEST_SUCCESS;
2201 test_AES_cipheronly_mrvl_all(void)
2203 struct crypto_testsuite_params *ts_params = &testsuite_params;
2206 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2207 ts_params->op_mpool,
2208 ts_params->session_mpool, ts_params->session_priv_mpool,
2209 ts_params->valid_devs[0],
2210 rte_cryptodev_driver_id_get(
2211 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2212 BLKCIPHER_AES_CIPHERONLY_TYPE);
2214 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2216 return TEST_SUCCESS;
2220 test_authonly_mrvl_all(void)
2222 struct crypto_testsuite_params *ts_params = &testsuite_params;
2225 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2226 ts_params->op_mpool,
2227 ts_params->session_mpool, ts_params->session_priv_mpool,
2228 ts_params->valid_devs[0],
2229 rte_cryptodev_driver_id_get(
2230 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2231 BLKCIPHER_AUTHONLY_TYPE);
2233 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2235 return TEST_SUCCESS;
2239 test_3DES_chain_mrvl_all(void)
2241 struct crypto_testsuite_params *ts_params = &testsuite_params;
2244 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2245 ts_params->op_mpool,
2246 ts_params->session_mpool, ts_params->session_priv_mpool,
2247 ts_params->valid_devs[0],
2248 rte_cryptodev_driver_id_get(
2249 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2250 BLKCIPHER_3DES_CHAIN_TYPE);
2252 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2254 return TEST_SUCCESS;
2258 test_3DES_cipheronly_mrvl_all(void)
2260 struct crypto_testsuite_params *ts_params = &testsuite_params;
2263 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2264 ts_params->op_mpool,
2265 ts_params->session_mpool, ts_params->session_priv_mpool,
2266 ts_params->valid_devs[0],
2267 rte_cryptodev_driver_id_get(
2268 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2269 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2271 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2273 return TEST_SUCCESS;
2277 test_AES_chain_octeontx_all(void)
2279 struct crypto_testsuite_params *ts_params = &testsuite_params;
2282 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2283 ts_params->op_mpool, ts_params->session_mpool,
2284 ts_params->session_priv_mpool,
2285 ts_params->valid_devs[0],
2286 rte_cryptodev_driver_id_get(
2287 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2288 BLKCIPHER_AES_CHAIN_TYPE);
2290 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2292 return TEST_SUCCESS;
2296 test_AES_cipheronly_octeontx_all(void)
2298 struct crypto_testsuite_params *ts_params = &testsuite_params;
2301 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2302 ts_params->op_mpool, ts_params->session_mpool,
2303 ts_params->session_priv_mpool,
2304 ts_params->valid_devs[0],
2305 rte_cryptodev_driver_id_get(
2306 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2307 BLKCIPHER_AES_CIPHERONLY_TYPE);
2309 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2311 return TEST_SUCCESS;
2315 test_3DES_chain_octeontx_all(void)
2317 struct crypto_testsuite_params *ts_params = &testsuite_params;
2320 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2321 ts_params->op_mpool, ts_params->session_mpool,
2322 ts_params->session_priv_mpool,
2323 ts_params->valid_devs[0],
2324 rte_cryptodev_driver_id_get(
2325 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2326 BLKCIPHER_3DES_CHAIN_TYPE);
2328 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2330 return TEST_SUCCESS;
2334 test_3DES_cipheronly_octeontx_all(void)
2336 struct crypto_testsuite_params *ts_params = &testsuite_params;
2339 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2340 ts_params->op_mpool, ts_params->session_mpool,
2341 ts_params->session_priv_mpool,
2342 ts_params->valid_devs[0],
2343 rte_cryptodev_driver_id_get(
2344 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2345 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2347 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2349 return TEST_SUCCESS;
2353 test_authonly_octeontx_all(void)
2355 struct crypto_testsuite_params *ts_params = &testsuite_params;
2358 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2359 ts_params->op_mpool, ts_params->session_mpool,
2360 ts_params->session_priv_mpool,
2361 ts_params->valid_devs[0],
2362 rte_cryptodev_driver_id_get(
2363 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2364 BLKCIPHER_AUTHONLY_TYPE);
2366 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2368 return TEST_SUCCESS;
2371 /* ***** SNOW 3G Tests ***** */
2373 create_wireless_algo_hash_session(uint8_t dev_id,
2374 const uint8_t *key, const uint8_t key_len,
2375 const uint8_t iv_len, const uint8_t auth_len,
2376 enum rte_crypto_auth_operation op,
2377 enum rte_crypto_auth_algorithm algo)
2379 uint8_t hash_key[key_len];
2381 struct crypto_testsuite_params *ts_params = &testsuite_params;
2382 struct crypto_unittest_params *ut_params = &unittest_params;
2384 memcpy(hash_key, key, key_len);
2386 debug_hexdump(stdout, "key:", key, key_len);
2388 /* Setup Authentication Parameters */
2389 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2390 ut_params->auth_xform.next = NULL;
2392 ut_params->auth_xform.auth.op = op;
2393 ut_params->auth_xform.auth.algo = algo;
2394 ut_params->auth_xform.auth.key.length = key_len;
2395 ut_params->auth_xform.auth.key.data = hash_key;
2396 ut_params->auth_xform.auth.digest_length = auth_len;
2397 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2398 ut_params->auth_xform.auth.iv.length = iv_len;
2399 ut_params->sess = rte_cryptodev_sym_session_create(
2400 ts_params->session_mpool);
2402 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2403 &ut_params->auth_xform,
2404 ts_params->session_priv_mpool);
2405 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2410 create_wireless_algo_cipher_session(uint8_t dev_id,
2411 enum rte_crypto_cipher_operation op,
2412 enum rte_crypto_cipher_algorithm algo,
2413 const uint8_t *key, const uint8_t key_len,
2416 uint8_t cipher_key[key_len];
2418 struct crypto_testsuite_params *ts_params = &testsuite_params;
2419 struct crypto_unittest_params *ut_params = &unittest_params;
2421 memcpy(cipher_key, key, key_len);
2423 /* Setup Cipher Parameters */
2424 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2425 ut_params->cipher_xform.next = NULL;
2427 ut_params->cipher_xform.cipher.algo = algo;
2428 ut_params->cipher_xform.cipher.op = op;
2429 ut_params->cipher_xform.cipher.key.data = cipher_key;
2430 ut_params->cipher_xform.cipher.key.length = key_len;
2431 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2432 ut_params->cipher_xform.cipher.iv.length = iv_len;
2434 debug_hexdump(stdout, "key:", key, key_len);
2436 /* Create Crypto session */
2437 ut_params->sess = rte_cryptodev_sym_session_create(
2438 ts_params->session_mpool);
2440 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2441 &ut_params->cipher_xform,
2442 ts_params->session_priv_mpool);
2443 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2448 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2449 unsigned int cipher_len,
2450 unsigned int cipher_offset)
2452 struct crypto_testsuite_params *ts_params = &testsuite_params;
2453 struct crypto_unittest_params *ut_params = &unittest_params;
2455 /* Generate Crypto op data structure */
2456 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2457 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2458 TEST_ASSERT_NOT_NULL(ut_params->op,
2459 "Failed to allocate pktmbuf offload");
2461 /* Set crypto operation data parameters */
2462 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2464 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2466 /* set crypto operation source mbuf */
2467 sym_op->m_src = ut_params->ibuf;
2470 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2472 sym_op->cipher.data.length = cipher_len;
2473 sym_op->cipher.data.offset = cipher_offset;
2478 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2479 unsigned int cipher_len,
2480 unsigned int cipher_offset)
2482 struct crypto_testsuite_params *ts_params = &testsuite_params;
2483 struct crypto_unittest_params *ut_params = &unittest_params;
2485 /* Generate Crypto op data structure */
2486 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2487 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2488 TEST_ASSERT_NOT_NULL(ut_params->op,
2489 "Failed to allocate pktmbuf offload");
2491 /* Set crypto operation data parameters */
2492 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2494 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2496 /* set crypto operation source mbuf */
2497 sym_op->m_src = ut_params->ibuf;
2498 sym_op->m_dst = ut_params->obuf;
2501 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2503 sym_op->cipher.data.length = cipher_len;
2504 sym_op->cipher.data.offset = cipher_offset;
2509 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2510 enum rte_crypto_cipher_operation cipher_op,
2511 enum rte_crypto_auth_operation auth_op,
2512 enum rte_crypto_auth_algorithm auth_algo,
2513 enum rte_crypto_cipher_algorithm cipher_algo,
2514 const uint8_t *key, uint8_t key_len,
2515 uint8_t auth_iv_len, uint8_t auth_len,
2516 uint8_t cipher_iv_len)
2519 uint8_t cipher_auth_key[key_len];
2521 struct crypto_testsuite_params *ts_params = &testsuite_params;
2522 struct crypto_unittest_params *ut_params = &unittest_params;
2524 memcpy(cipher_auth_key, key, key_len);
2526 /* Setup Authentication Parameters */
2527 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2528 ut_params->auth_xform.next = NULL;
2530 ut_params->auth_xform.auth.op = auth_op;
2531 ut_params->auth_xform.auth.algo = auth_algo;
2532 ut_params->auth_xform.auth.key.length = key_len;
2533 /* Hash key = cipher key */
2534 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2535 ut_params->auth_xform.auth.digest_length = auth_len;
2536 /* Auth IV will be after cipher IV */
2537 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2538 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2540 /* Setup Cipher Parameters */
2541 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2542 ut_params->cipher_xform.next = &ut_params->auth_xform;
2544 ut_params->cipher_xform.cipher.algo = cipher_algo;
2545 ut_params->cipher_xform.cipher.op = cipher_op;
2546 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2547 ut_params->cipher_xform.cipher.key.length = key_len;
2548 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2549 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2551 debug_hexdump(stdout, "key:", key, key_len);
2553 /* Create Crypto session*/
2554 ut_params->sess = rte_cryptodev_sym_session_create(
2555 ts_params->session_mpool);
2557 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2558 &ut_params->cipher_xform,
2559 ts_params->session_priv_mpool);
2561 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2566 create_wireless_cipher_auth_session(uint8_t dev_id,
2567 enum rte_crypto_cipher_operation cipher_op,
2568 enum rte_crypto_auth_operation auth_op,
2569 enum rte_crypto_auth_algorithm auth_algo,
2570 enum rte_crypto_cipher_algorithm cipher_algo,
2571 const struct wireless_test_data *tdata)
2573 const uint8_t key_len = tdata->key.len;
2574 uint8_t cipher_auth_key[key_len];
2576 struct crypto_testsuite_params *ts_params = &testsuite_params;
2577 struct crypto_unittest_params *ut_params = &unittest_params;
2578 const uint8_t *key = tdata->key.data;
2579 const uint8_t auth_len = tdata->digest.len;
2580 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2581 uint8_t auth_iv_len = tdata->auth_iv.len;
2583 memcpy(cipher_auth_key, key, key_len);
2585 /* Setup Authentication Parameters */
2586 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2587 ut_params->auth_xform.next = NULL;
2589 ut_params->auth_xform.auth.op = auth_op;
2590 ut_params->auth_xform.auth.algo = auth_algo;
2591 ut_params->auth_xform.auth.key.length = key_len;
2592 /* Hash key = cipher key */
2593 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2594 ut_params->auth_xform.auth.digest_length = auth_len;
2595 /* Auth IV will be after cipher IV */
2596 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2597 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2599 /* Setup Cipher Parameters */
2600 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2601 ut_params->cipher_xform.next = &ut_params->auth_xform;
2603 ut_params->cipher_xform.cipher.algo = cipher_algo;
2604 ut_params->cipher_xform.cipher.op = cipher_op;
2605 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2606 ut_params->cipher_xform.cipher.key.length = key_len;
2607 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2608 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2611 debug_hexdump(stdout, "key:", key, key_len);
2613 /* Create Crypto session*/
2614 ut_params->sess = rte_cryptodev_sym_session_create(
2615 ts_params->session_mpool);
2617 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2618 &ut_params->cipher_xform,
2619 ts_params->session_priv_mpool);
2621 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2626 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2627 const struct wireless_test_data *tdata)
2629 return create_wireless_cipher_auth_session(dev_id,
2630 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2631 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2632 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2636 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2637 enum rte_crypto_cipher_operation cipher_op,
2638 enum rte_crypto_auth_operation auth_op,
2639 enum rte_crypto_auth_algorithm auth_algo,
2640 enum rte_crypto_cipher_algorithm cipher_algo,
2641 const uint8_t *key, const uint8_t key_len,
2642 uint8_t auth_iv_len, uint8_t auth_len,
2643 uint8_t cipher_iv_len)
2645 uint8_t auth_cipher_key[key_len];
2647 struct crypto_testsuite_params *ts_params = &testsuite_params;
2648 struct crypto_unittest_params *ut_params = &unittest_params;
2650 memcpy(auth_cipher_key, key, key_len);
2652 /* Setup Authentication Parameters */
2653 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2654 ut_params->auth_xform.auth.op = auth_op;
2655 ut_params->auth_xform.next = &ut_params->cipher_xform;
2656 ut_params->auth_xform.auth.algo = auth_algo;
2657 ut_params->auth_xform.auth.key.length = key_len;
2658 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2659 ut_params->auth_xform.auth.digest_length = auth_len;
2660 /* Auth IV will be after cipher IV */
2661 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2662 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2664 /* Setup Cipher Parameters */
2665 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2666 ut_params->cipher_xform.next = NULL;
2667 ut_params->cipher_xform.cipher.algo = cipher_algo;
2668 ut_params->cipher_xform.cipher.op = cipher_op;
2669 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2670 ut_params->cipher_xform.cipher.key.length = key_len;
2671 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2672 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2674 debug_hexdump(stdout, "key:", key, key_len);
2676 /* Create Crypto session*/
2677 ut_params->sess = rte_cryptodev_sym_session_create(
2678 ts_params->session_mpool);
2680 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2681 &ut_params->auth_xform,
2682 ts_params->session_priv_mpool);
2684 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2690 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2691 unsigned int auth_tag_len,
2692 const uint8_t *iv, unsigned int iv_len,
2693 unsigned int data_pad_len,
2694 enum rte_crypto_auth_operation op,
2695 unsigned int auth_len, unsigned int auth_offset)
2697 struct crypto_testsuite_params *ts_params = &testsuite_params;
2699 struct crypto_unittest_params *ut_params = &unittest_params;
2701 /* Generate Crypto op data structure */
2702 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2703 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2704 TEST_ASSERT_NOT_NULL(ut_params->op,
2705 "Failed to allocate pktmbuf offload");
2707 /* Set crypto operation data parameters */
2708 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2710 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2712 /* set crypto operation source mbuf */
2713 sym_op->m_src = ut_params->ibuf;
2716 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2719 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2720 ut_params->ibuf, auth_tag_len);
2722 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2723 "no room to append auth tag");
2724 ut_params->digest = sym_op->auth.digest.data;
2725 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2726 ut_params->ibuf, data_pad_len);
2727 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2728 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2730 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2732 debug_hexdump(stdout, "digest:",
2733 sym_op->auth.digest.data,
2736 sym_op->auth.data.length = auth_len;
2737 sym_op->auth.data.offset = auth_offset;
2743 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2744 enum rte_crypto_auth_operation op)
2746 struct crypto_testsuite_params *ts_params = &testsuite_params;
2747 struct crypto_unittest_params *ut_params = &unittest_params;
2749 const uint8_t *auth_tag = tdata->digest.data;
2750 const unsigned int auth_tag_len = tdata->digest.len;
2751 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2752 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2754 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2755 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2756 const uint8_t *auth_iv = tdata->auth_iv.data;
2757 const uint8_t auth_iv_len = tdata->auth_iv.len;
2758 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2759 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2761 /* Generate Crypto op data structure */
2762 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2763 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2764 TEST_ASSERT_NOT_NULL(ut_params->op,
2765 "Failed to allocate pktmbuf offload");
2766 /* Set crypto operation data parameters */
2767 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2769 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2771 /* set crypto operation source mbuf */
2772 sym_op->m_src = ut_params->ibuf;
2775 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2776 ut_params->ibuf, auth_tag_len);
2778 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2779 "no room to append auth tag");
2780 ut_params->digest = sym_op->auth.digest.data;
2781 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2782 ut_params->ibuf, data_pad_len);
2783 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2784 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2786 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2788 debug_hexdump(stdout, "digest:",
2789 sym_op->auth.digest.data,
2792 /* Copy cipher and auth IVs at the end of the crypto operation */
2793 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2795 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2796 iv_ptr += cipher_iv_len;
2797 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2799 sym_op->cipher.data.length = cipher_len;
2800 sym_op->cipher.data.offset = 0;
2801 sym_op->auth.data.length = auth_len;
2802 sym_op->auth.data.offset = 0;
2808 create_zuc_cipher_hash_generate_operation(
2809 const struct wireless_test_data *tdata)
2811 return create_wireless_cipher_hash_operation(tdata,
2812 RTE_CRYPTO_AUTH_OP_GENERATE);
2816 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2817 const unsigned auth_tag_len,
2818 const uint8_t *auth_iv, uint8_t auth_iv_len,
2819 unsigned data_pad_len,
2820 enum rte_crypto_auth_operation op,
2821 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2822 const unsigned cipher_len, const unsigned cipher_offset,
2823 const unsigned auth_len, const unsigned auth_offset)
2825 struct crypto_testsuite_params *ts_params = &testsuite_params;
2826 struct crypto_unittest_params *ut_params = &unittest_params;
2828 /* Generate Crypto op data structure */
2829 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2830 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2831 TEST_ASSERT_NOT_NULL(ut_params->op,
2832 "Failed to allocate pktmbuf offload");
2833 /* Set crypto operation data parameters */
2834 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2836 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2838 /* set crypto operation source mbuf */
2839 sym_op->m_src = ut_params->ibuf;
2842 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2843 ut_params->ibuf, auth_tag_len);
2845 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2846 "no room to append auth tag");
2847 ut_params->digest = sym_op->auth.digest.data;
2848 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2849 ut_params->ibuf, data_pad_len);
2850 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2851 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2853 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2855 debug_hexdump(stdout, "digest:",
2856 sym_op->auth.digest.data,
2859 /* Copy cipher and auth IVs at the end of the crypto operation */
2860 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2862 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2863 iv_ptr += cipher_iv_len;
2864 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2866 sym_op->cipher.data.length = cipher_len;
2867 sym_op->cipher.data.offset = cipher_offset;
2868 sym_op->auth.data.length = auth_len;
2869 sym_op->auth.data.offset = auth_offset;
2875 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2876 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2877 const uint8_t *auth_iv, uint8_t auth_iv_len,
2878 unsigned int data_pad_len,
2879 unsigned int cipher_len, unsigned int cipher_offset,
2880 unsigned int auth_len, unsigned int auth_offset,
2883 struct crypto_testsuite_params *ts_params = &testsuite_params;
2884 struct crypto_unittest_params *ut_params = &unittest_params;
2886 /* Generate Crypto op data structure */
2887 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2888 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2889 TEST_ASSERT_NOT_NULL(ut_params->op,
2890 "Failed to allocate pktmbuf offload");
2892 /* Set crypto operation data parameters */
2893 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2895 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2897 /* set crypto operation mbufs */
2898 sym_op->m_src = ut_params->ibuf;
2899 if (op_mode == OUT_OF_PLACE)
2900 sym_op->m_dst = ut_params->obuf;
2903 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2904 (op_mode == IN_PLACE ?
2905 ut_params->ibuf : ut_params->obuf),
2906 uint8_t *, data_pad_len);
2908 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2909 "no room to append auth tag");
2911 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2912 (op_mode == IN_PLACE ?
2913 ut_params->ibuf : ut_params->obuf),
2916 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2918 /* Copy cipher and auth IVs at the end of the crypto operation */
2919 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2920 ut_params->op, uint8_t *, IV_OFFSET);
2922 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2923 iv_ptr += cipher_iv_len;
2924 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2926 sym_op->cipher.data.length = cipher_len;
2927 sym_op->cipher.data.offset = cipher_offset;
2929 sym_op->auth.data.length = auth_len;
2930 sym_op->auth.data.offset = auth_offset;
2936 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2938 struct crypto_testsuite_params *ts_params = &testsuite_params;
2939 struct crypto_unittest_params *ut_params = &unittest_params;
2942 unsigned plaintext_pad_len;
2943 unsigned plaintext_len;
2946 /* Create SNOW 3G session */
2947 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2948 tdata->key.data, tdata->key.len,
2949 tdata->auth_iv.len, tdata->digest.len,
2950 RTE_CRYPTO_AUTH_OP_GENERATE,
2951 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2955 /* alloc mbuf and set payload */
2956 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2958 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2959 rte_pktmbuf_tailroom(ut_params->ibuf));
2961 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2962 /* Append data which is padded to a multiple of */
2963 /* the algorithms block size */
2964 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2965 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2967 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2969 /* Create SNOW 3G operation */
2970 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2971 tdata->auth_iv.data, tdata->auth_iv.len,
2972 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2973 tdata->validAuthLenInBits.len,
2978 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2980 ut_params->obuf = ut_params->op->sym->m_src;
2981 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2982 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2983 + plaintext_pad_len;
2986 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2989 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2990 "SNOW 3G Generated auth tag not as expected");
2996 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2998 struct crypto_testsuite_params *ts_params = &testsuite_params;
2999 struct crypto_unittest_params *ut_params = &unittest_params;
3002 unsigned plaintext_pad_len;
3003 unsigned plaintext_len;
3006 /* Create SNOW 3G session */
3007 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3008 tdata->key.data, tdata->key.len,
3009 tdata->auth_iv.len, tdata->digest.len,
3010 RTE_CRYPTO_AUTH_OP_VERIFY,
3011 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3014 /* alloc mbuf and set payload */
3015 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3017 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3018 rte_pktmbuf_tailroom(ut_params->ibuf));
3020 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3021 /* Append data which is padded to a multiple of */
3022 /* the algorithms block size */
3023 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3024 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3026 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3028 /* Create SNOW 3G operation */
3029 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3031 tdata->auth_iv.data, tdata->auth_iv.len,
3033 RTE_CRYPTO_AUTH_OP_VERIFY,
3034 tdata->validAuthLenInBits.len,
3039 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3041 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3042 ut_params->obuf = ut_params->op->sym->m_src;
3043 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3044 + plaintext_pad_len;
3047 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3056 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3058 struct crypto_testsuite_params *ts_params = &testsuite_params;
3059 struct crypto_unittest_params *ut_params = &unittest_params;
3062 unsigned plaintext_pad_len;
3063 unsigned plaintext_len;
3066 /* Create KASUMI session */
3067 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3068 tdata->key.data, tdata->key.len,
3069 0, tdata->digest.len,
3070 RTE_CRYPTO_AUTH_OP_GENERATE,
3071 RTE_CRYPTO_AUTH_KASUMI_F9);
3075 /* alloc mbuf and set payload */
3076 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3078 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3079 rte_pktmbuf_tailroom(ut_params->ibuf));
3081 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3082 /* Append data which is padded to a multiple of */
3083 /* the algorithms block size */
3084 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3085 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3087 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3089 /* Create KASUMI operation */
3090 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3092 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3093 tdata->plaintext.len,
3098 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3100 ut_params->obuf = ut_params->op->sym->m_src;
3101 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3102 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3103 + plaintext_pad_len;
3106 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3109 DIGEST_BYTE_LENGTH_KASUMI_F9,
3110 "KASUMI Generated auth tag not as expected");
3116 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3118 struct crypto_testsuite_params *ts_params = &testsuite_params;
3119 struct crypto_unittest_params *ut_params = &unittest_params;
3122 unsigned plaintext_pad_len;
3123 unsigned plaintext_len;
3126 /* Create KASUMI session */
3127 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3128 tdata->key.data, tdata->key.len,
3129 0, tdata->digest.len,
3130 RTE_CRYPTO_AUTH_OP_VERIFY,
3131 RTE_CRYPTO_AUTH_KASUMI_F9);
3134 /* alloc mbuf and set payload */
3135 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3137 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3138 rte_pktmbuf_tailroom(ut_params->ibuf));
3140 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3141 /* Append data which is padded to a multiple */
3142 /* of the algorithms block size */
3143 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3144 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3146 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3148 /* Create KASUMI operation */
3149 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3153 RTE_CRYPTO_AUTH_OP_VERIFY,
3154 tdata->plaintext.len,
3159 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3161 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3162 ut_params->obuf = ut_params->op->sym->m_src;
3163 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3164 + plaintext_pad_len;
3167 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3176 test_snow3g_hash_generate_test_case_1(void)
3178 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3182 test_snow3g_hash_generate_test_case_2(void)
3184 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3188 test_snow3g_hash_generate_test_case_3(void)
3190 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3194 test_snow3g_hash_generate_test_case_4(void)
3196 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3200 test_snow3g_hash_generate_test_case_5(void)
3202 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3206 test_snow3g_hash_generate_test_case_6(void)
3208 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3212 test_snow3g_hash_verify_test_case_1(void)
3214 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3219 test_snow3g_hash_verify_test_case_2(void)
3221 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3225 test_snow3g_hash_verify_test_case_3(void)
3227 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3231 test_snow3g_hash_verify_test_case_4(void)
3233 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3237 test_snow3g_hash_verify_test_case_5(void)
3239 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3243 test_snow3g_hash_verify_test_case_6(void)
3245 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3249 test_kasumi_hash_generate_test_case_1(void)
3251 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3255 test_kasumi_hash_generate_test_case_2(void)
3257 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3261 test_kasumi_hash_generate_test_case_3(void)
3263 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3267 test_kasumi_hash_generate_test_case_4(void)
3269 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3273 test_kasumi_hash_generate_test_case_5(void)
3275 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3279 test_kasumi_hash_generate_test_case_6(void)
3281 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3285 test_kasumi_hash_verify_test_case_1(void)
3287 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3291 test_kasumi_hash_verify_test_case_2(void)
3293 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3297 test_kasumi_hash_verify_test_case_3(void)
3299 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3303 test_kasumi_hash_verify_test_case_4(void)
3305 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3309 test_kasumi_hash_verify_test_case_5(void)
3311 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3315 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3317 struct crypto_testsuite_params *ts_params = &testsuite_params;
3318 struct crypto_unittest_params *ut_params = &unittest_params;
3321 uint8_t *plaintext, *ciphertext;
3322 unsigned plaintext_pad_len;
3323 unsigned plaintext_len;
3325 /* Create KASUMI session */
3326 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3327 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3328 RTE_CRYPTO_CIPHER_KASUMI_F8,
3329 tdata->key.data, tdata->key.len,
3330 tdata->cipher_iv.len);
3334 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3336 /* Clear mbuf payload */
3337 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3338 rte_pktmbuf_tailroom(ut_params->ibuf));
3340 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3341 /* Append data which is padded to a multiple */
3342 /* of the algorithms block size */
3343 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3344 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3346 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3348 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3350 /* Create KASUMI operation */
3351 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3352 tdata->cipher_iv.len,
3353 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3354 tdata->validCipherOffsetInBits.len);
3358 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3360 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3362 ut_params->obuf = ut_params->op->sym->m_dst;
3363 if (ut_params->obuf)
3364 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3366 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3368 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3370 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3371 (tdata->validCipherOffsetInBits.len >> 3);
3373 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3375 reference_ciphertext,
3376 tdata->validCipherLenInBits.len,
3377 "KASUMI Ciphertext data not as expected");
3382 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3384 struct crypto_testsuite_params *ts_params = &testsuite_params;
3385 struct crypto_unittest_params *ut_params = &unittest_params;
3389 unsigned int plaintext_pad_len;
3390 unsigned int plaintext_len;
3392 uint8_t buffer[10000];
3393 const uint8_t *ciphertext;
3395 struct rte_cryptodev_info dev_info;
3397 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3399 uint64_t feat_flags = dev_info.feature_flags;
3401 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3402 printf("Device doesn't support in-place scatter-gather. "
3407 /* Create KASUMI session */
3408 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3409 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3410 RTE_CRYPTO_CIPHER_KASUMI_F8,
3411 tdata->key.data, tdata->key.len,
3412 tdata->cipher_iv.len);
3416 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3419 /* Append data which is padded to a multiple */
3420 /* of the algorithms block size */
3421 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3423 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3424 plaintext_pad_len, 10, 0);
3426 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3428 /* Create KASUMI operation */
3429 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3430 tdata->cipher_iv.len,
3431 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3432 tdata->validCipherOffsetInBits.len);
3436 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3438 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3440 ut_params->obuf = ut_params->op->sym->m_dst;
3442 if (ut_params->obuf)
3443 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3444 plaintext_len, buffer);
3446 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3447 tdata->validCipherOffsetInBits.len >> 3,
3448 plaintext_len, buffer);
3451 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3453 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3454 (tdata->validCipherOffsetInBits.len >> 3);
3456 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3458 reference_ciphertext,
3459 tdata->validCipherLenInBits.len,
3460 "KASUMI Ciphertext data not as expected");
3465 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3467 struct crypto_testsuite_params *ts_params = &testsuite_params;
3468 struct crypto_unittest_params *ut_params = &unittest_params;
3471 uint8_t *plaintext, *ciphertext;
3472 unsigned plaintext_pad_len;
3473 unsigned plaintext_len;
3475 /* Create KASUMI session */
3476 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3477 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3478 RTE_CRYPTO_CIPHER_KASUMI_F8,
3479 tdata->key.data, tdata->key.len,
3480 tdata->cipher_iv.len);
3484 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3485 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3487 /* Clear mbuf payload */
3488 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3489 rte_pktmbuf_tailroom(ut_params->ibuf));
3491 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3492 /* Append data which is padded to a multiple */
3493 /* of the algorithms block size */
3494 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3495 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3497 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3498 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3500 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3502 /* Create KASUMI operation */
3503 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3504 tdata->cipher_iv.len,
3505 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3506 tdata->validCipherOffsetInBits.len);
3510 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3512 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3514 ut_params->obuf = ut_params->op->sym->m_dst;
3515 if (ut_params->obuf)
3516 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3518 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3520 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3522 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3523 (tdata->validCipherOffsetInBits.len >> 3);
3525 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3527 reference_ciphertext,
3528 tdata->validCipherLenInBits.len,
3529 "KASUMI Ciphertext data not as expected");
3534 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3536 struct crypto_testsuite_params *ts_params = &testsuite_params;
3537 struct crypto_unittest_params *ut_params = &unittest_params;
3540 unsigned int plaintext_pad_len;
3541 unsigned int plaintext_len;
3543 const uint8_t *ciphertext;
3544 uint8_t buffer[2048];
3546 struct rte_cryptodev_info dev_info;
3548 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3550 uint64_t feat_flags = dev_info.feature_flags;
3551 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3552 printf("Device doesn't support out-of-place scatter-gather "
3553 "in both input and output mbufs. "
3558 /* Create KASUMI session */
3559 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3560 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3561 RTE_CRYPTO_CIPHER_KASUMI_F8,
3562 tdata->key.data, tdata->key.len,
3563 tdata->cipher_iv.len);
3567 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3568 /* Append data which is padded to a multiple */
3569 /* of the algorithms block size */
3570 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3572 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3573 plaintext_pad_len, 10, 0);
3574 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3575 plaintext_pad_len, 3, 0);
3577 /* Append data which is padded to a multiple */
3578 /* of the algorithms block size */
3579 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3581 /* Create KASUMI operation */
3582 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3583 tdata->cipher_iv.len,
3584 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3585 tdata->validCipherOffsetInBits.len);
3589 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3591 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3593 ut_params->obuf = ut_params->op->sym->m_dst;
3594 if (ut_params->obuf)
3595 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3596 plaintext_pad_len, buffer);
3598 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3599 tdata->validCipherOffsetInBits.len >> 3,
3600 plaintext_pad_len, buffer);
3602 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3603 (tdata->validCipherOffsetInBits.len >> 3);
3605 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3607 reference_ciphertext,
3608 tdata->validCipherLenInBits.len,
3609 "KASUMI Ciphertext data not as expected");
3615 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3617 struct crypto_testsuite_params *ts_params = &testsuite_params;
3618 struct crypto_unittest_params *ut_params = &unittest_params;
3621 uint8_t *ciphertext, *plaintext;
3622 unsigned ciphertext_pad_len;
3623 unsigned ciphertext_len;
3625 /* Create KASUMI session */
3626 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3627 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3628 RTE_CRYPTO_CIPHER_KASUMI_F8,
3629 tdata->key.data, tdata->key.len,
3630 tdata->cipher_iv.len);
3634 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3635 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3637 /* Clear mbuf payload */
3638 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3639 rte_pktmbuf_tailroom(ut_params->ibuf));
3641 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3642 /* Append data which is padded to a multiple */
3643 /* of the algorithms block size */
3644 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3645 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3646 ciphertext_pad_len);
3647 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3648 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3650 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3652 /* Create KASUMI operation */
3653 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3654 tdata->cipher_iv.len,
3655 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3656 tdata->validCipherOffsetInBits.len);
3660 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3662 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3664 ut_params->obuf = ut_params->op->sym->m_dst;
3665 if (ut_params->obuf)
3666 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3668 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3670 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3672 const uint8_t *reference_plaintext = tdata->plaintext.data +
3673 (tdata->validCipherOffsetInBits.len >> 3);
3675 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3677 reference_plaintext,
3678 tdata->validCipherLenInBits.len,
3679 "KASUMI Plaintext data not as expected");
3684 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3686 struct crypto_testsuite_params *ts_params = &testsuite_params;
3687 struct crypto_unittest_params *ut_params = &unittest_params;
3690 uint8_t *ciphertext, *plaintext;
3691 unsigned ciphertext_pad_len;
3692 unsigned ciphertext_len;
3694 /* Create KASUMI session */
3695 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3696 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3697 RTE_CRYPTO_CIPHER_KASUMI_F8,
3698 tdata->key.data, tdata->key.len,
3699 tdata->cipher_iv.len);
3703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3705 /* Clear mbuf payload */
3706 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3707 rte_pktmbuf_tailroom(ut_params->ibuf));
3709 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3710 /* Append data which is padded to a multiple */
3711 /* of the algorithms block size */
3712 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3713 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3714 ciphertext_pad_len);
3715 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3717 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3719 /* Create KASUMI operation */
3720 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3721 tdata->cipher_iv.len,
3722 tdata->ciphertext.len,
3723 tdata->validCipherOffsetInBits.len);
3727 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3729 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3731 ut_params->obuf = ut_params->op->sym->m_dst;
3732 if (ut_params->obuf)
3733 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3735 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3737 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3739 const uint8_t *reference_plaintext = tdata->plaintext.data +
3740 (tdata->validCipherOffsetInBits.len >> 3);
3742 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3744 reference_plaintext,
3745 tdata->validCipherLenInBits.len,
3746 "KASUMI Plaintext data not as expected");
3751 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3753 struct crypto_testsuite_params *ts_params = &testsuite_params;
3754 struct crypto_unittest_params *ut_params = &unittest_params;
3757 uint8_t *plaintext, *ciphertext;
3758 unsigned plaintext_pad_len;
3759 unsigned plaintext_len;
3761 /* Create SNOW 3G session */
3762 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3763 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3764 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3765 tdata->key.data, tdata->key.len,
3766 tdata->cipher_iv.len);
3770 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3772 /* Clear mbuf payload */
3773 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3774 rte_pktmbuf_tailroom(ut_params->ibuf));
3776 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3777 /* Append data which is padded to a multiple of */
3778 /* the algorithms block size */
3779 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3780 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3782 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3784 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3786 /* Create SNOW 3G operation */
3787 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3788 tdata->cipher_iv.len,
3789 tdata->validCipherLenInBits.len,
3794 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3796 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3798 ut_params->obuf = ut_params->op->sym->m_dst;
3799 if (ut_params->obuf)
3800 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3802 ciphertext = plaintext;
3804 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3807 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3809 tdata->ciphertext.data,
3810 tdata->validDataLenInBits.len,
3811 "SNOW 3G Ciphertext data not as expected");
3817 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3819 struct crypto_testsuite_params *ts_params = &testsuite_params;
3820 struct crypto_unittest_params *ut_params = &unittest_params;
3821 uint8_t *plaintext, *ciphertext;
3824 unsigned plaintext_pad_len;
3825 unsigned plaintext_len;
3827 /* Create SNOW 3G session */
3828 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3829 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3830 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3831 tdata->key.data, tdata->key.len,
3832 tdata->cipher_iv.len);
3836 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3837 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3839 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3840 "Failed to allocate input buffer in mempool");
3841 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3842 "Failed to allocate output buffer in mempool");
3844 /* Clear mbuf payload */
3845 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3846 rte_pktmbuf_tailroom(ut_params->ibuf));
3848 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3849 /* Append data which is padded to a multiple of */
3850 /* the algorithms block size */
3851 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3852 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3854 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3855 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3857 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3859 /* Create SNOW 3G operation */
3860 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3861 tdata->cipher_iv.len,
3862 tdata->validCipherLenInBits.len,
3867 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3869 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3871 ut_params->obuf = ut_params->op->sym->m_dst;
3872 if (ut_params->obuf)
3873 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3875 ciphertext = plaintext;
3877 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3880 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3882 tdata->ciphertext.data,
3883 tdata->validDataLenInBits.len,
3884 "SNOW 3G Ciphertext data not as expected");
3889 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3891 struct crypto_testsuite_params *ts_params = &testsuite_params;
3892 struct crypto_unittest_params *ut_params = &unittest_params;
3895 unsigned int plaintext_pad_len;
3896 unsigned int plaintext_len;
3897 uint8_t buffer[10000];
3898 const uint8_t *ciphertext;
3900 struct rte_cryptodev_info dev_info;
3902 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3904 uint64_t feat_flags = dev_info.feature_flags;
3906 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3907 printf("Device doesn't support out-of-place scatter-gather "
3908 "in both input and output mbufs. "
3913 /* Create SNOW 3G session */
3914 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3915 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3916 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3917 tdata->key.data, tdata->key.len,
3918 tdata->cipher_iv.len);
3922 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3923 /* Append data which is padded to a multiple of */
3924 /* the algorithms block size */
3925 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3927 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3928 plaintext_pad_len, 10, 0);
3929 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3930 plaintext_pad_len, 3, 0);
3932 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3933 "Failed to allocate input buffer in mempool");
3934 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3935 "Failed to allocate output buffer in mempool");
3937 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3939 /* Create SNOW 3G operation */
3940 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3941 tdata->cipher_iv.len,
3942 tdata->validCipherLenInBits.len,
3947 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3949 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3951 ut_params->obuf = ut_params->op->sym->m_dst;
3952 if (ut_params->obuf)
3953 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3954 plaintext_len, buffer);
3956 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3957 plaintext_len, buffer);
3959 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3962 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3964 tdata->ciphertext.data,
3965 tdata->validDataLenInBits.len,
3966 "SNOW 3G Ciphertext data not as expected");
3971 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3973 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3975 uint8_t curr_byte, prev_byte;
3976 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3977 uint8_t lower_byte_mask = (1 << offset) - 1;
3980 prev_byte = buffer[0];
3981 buffer[0] >>= offset;
3983 for (i = 1; i < length_in_bytes; i++) {
3984 curr_byte = buffer[i];
3985 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3986 (curr_byte >> offset);
3987 prev_byte = curr_byte;
3992 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3994 struct crypto_testsuite_params *ts_params = &testsuite_params;
3995 struct crypto_unittest_params *ut_params = &unittest_params;
3996 uint8_t *plaintext, *ciphertext;
3998 uint32_t plaintext_len;
3999 uint32_t plaintext_pad_len;
4000 uint8_t extra_offset = 4;
4001 uint8_t *expected_ciphertext_shifted;
4003 /* Create SNOW 3G session */
4004 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4005 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4006 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4007 tdata->key.data, tdata->key.len,
4008 tdata->cipher_iv.len);
4012 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4013 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4015 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4016 "Failed to allocate input buffer in mempool");
4017 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4018 "Failed to allocate output buffer in mempool");
4020 /* Clear mbuf payload */
4021 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4022 rte_pktmbuf_tailroom(ut_params->ibuf));
4024 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4026 * Append data which is padded to a
4027 * multiple of the algorithms block size
4029 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4031 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4034 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4036 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4037 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4039 #ifdef RTE_APP_TEST_DEBUG
4040 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4042 /* Create SNOW 3G operation */
4043 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4044 tdata->cipher_iv.len,
4045 tdata->validCipherLenInBits.len,
4050 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4052 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4054 ut_params->obuf = ut_params->op->sym->m_dst;
4055 if (ut_params->obuf)
4056 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4058 ciphertext = plaintext;
4060 #ifdef RTE_APP_TEST_DEBUG
4061 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4064 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4066 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4067 "failed to reserve memory for ciphertext shifted\n");
4069 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4070 ceil_byte_length(tdata->ciphertext.len));
4071 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4074 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4076 expected_ciphertext_shifted,
4077 tdata->validDataLenInBits.len,
4079 "SNOW 3G Ciphertext data not as expected");
4083 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4085 struct crypto_testsuite_params *ts_params = &testsuite_params;
4086 struct crypto_unittest_params *ut_params = &unittest_params;
4090 uint8_t *plaintext, *ciphertext;
4091 unsigned ciphertext_pad_len;
4092 unsigned ciphertext_len;
4094 /* Create SNOW 3G session */
4095 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4096 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4097 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4098 tdata->key.data, tdata->key.len,
4099 tdata->cipher_iv.len);
4103 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4105 /* Clear mbuf payload */
4106 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4107 rte_pktmbuf_tailroom(ut_params->ibuf));
4109 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4110 /* Append data which is padded to a multiple of */
4111 /* the algorithms block size */
4112 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4113 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4114 ciphertext_pad_len);
4115 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4117 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4119 /* Create SNOW 3G operation */
4120 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4121 tdata->cipher_iv.len,
4122 tdata->validCipherLenInBits.len,
4123 tdata->cipher.offset_bits);
4127 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4129 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4130 ut_params->obuf = ut_params->op->sym->m_dst;
4131 if (ut_params->obuf)
4132 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4134 plaintext = ciphertext;
4136 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4139 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4140 tdata->plaintext.data,
4141 tdata->validDataLenInBits.len,
4142 "SNOW 3G Plaintext data not as expected");
4146 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4148 struct crypto_testsuite_params *ts_params = &testsuite_params;
4149 struct crypto_unittest_params *ut_params = &unittest_params;
4153 uint8_t *plaintext, *ciphertext;
4154 unsigned ciphertext_pad_len;
4155 unsigned ciphertext_len;
4157 /* Create SNOW 3G session */
4158 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4159 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4160 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4161 tdata->key.data, tdata->key.len,
4162 tdata->cipher_iv.len);
4166 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4167 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4169 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4170 "Failed to allocate input buffer");
4171 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4172 "Failed to allocate output buffer");
4174 /* Clear mbuf payload */
4175 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4176 rte_pktmbuf_tailroom(ut_params->ibuf));
4178 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4179 rte_pktmbuf_tailroom(ut_params->obuf));
4181 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4182 /* Append data which is padded to a multiple of */
4183 /* the algorithms block size */
4184 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4185 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4186 ciphertext_pad_len);
4187 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4188 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4190 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4192 /* Create SNOW 3G operation */
4193 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4194 tdata->cipher_iv.len,
4195 tdata->validCipherLenInBits.len,
4200 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4202 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4203 ut_params->obuf = ut_params->op->sym->m_dst;
4204 if (ut_params->obuf)
4205 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4207 plaintext = ciphertext;
4209 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4212 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4213 tdata->plaintext.data,
4214 tdata->validDataLenInBits.len,
4215 "SNOW 3G Plaintext data not as expected");
4220 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4222 struct crypto_testsuite_params *ts_params = &testsuite_params;
4223 struct crypto_unittest_params *ut_params = &unittest_params;
4227 uint8_t *plaintext, *ciphertext;
4228 unsigned int plaintext_pad_len;
4229 unsigned int plaintext_len;
4231 struct rte_cryptodev_sym_capability_idx cap_idx;
4233 /* Check if device supports ZUC EEA3 */
4234 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4235 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4237 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4241 /* Check if device supports ZUC EIA3 */
4242 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4243 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4245 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4249 /* Create ZUC session */
4250 retval = create_zuc_cipher_auth_encrypt_generate_session(
4251 ts_params->valid_devs[0],
4255 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4257 /* clear mbuf payload */
4258 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4259 rte_pktmbuf_tailroom(ut_params->ibuf));
4261 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4262 /* Append data which is padded to a multiple of */
4263 /* the algorithms block size */
4264 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4265 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4267 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4269 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4271 /* Create ZUC operation */
4272 retval = create_zuc_cipher_hash_generate_operation(tdata);
4276 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4278 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4279 ut_params->obuf = ut_params->op->sym->m_src;
4280 if (ut_params->obuf)
4281 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4283 ciphertext = plaintext;
4285 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4287 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4289 tdata->ciphertext.data,
4290 tdata->validDataLenInBits.len,
4291 "ZUC Ciphertext data not as expected");
4293 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4294 + plaintext_pad_len;
4297 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4301 "ZUC Generated auth tag not as expected");
4306 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4308 struct crypto_testsuite_params *ts_params = &testsuite_params;
4309 struct crypto_unittest_params *ut_params = &unittest_params;
4313 uint8_t *plaintext, *ciphertext;
4314 unsigned plaintext_pad_len;
4315 unsigned plaintext_len;
4317 /* Create SNOW 3G session */
4318 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4319 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4320 RTE_CRYPTO_AUTH_OP_GENERATE,
4321 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4322 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4323 tdata->key.data, tdata->key.len,
4324 tdata->auth_iv.len, tdata->digest.len,
4325 tdata->cipher_iv.len);
4328 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4330 /* clear mbuf payload */
4331 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4332 rte_pktmbuf_tailroom(ut_params->ibuf));
4334 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4335 /* Append data which is padded to a multiple of */
4336 /* the algorithms block size */
4337 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4338 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4340 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4342 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4344 /* Create SNOW 3G operation */
4345 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4346 tdata->digest.len, tdata->auth_iv.data,
4348 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4349 tdata->cipher_iv.data, tdata->cipher_iv.len,
4350 tdata->validCipherLenInBits.len,
4352 tdata->validAuthLenInBits.len,
4358 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4360 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4361 ut_params->obuf = ut_params->op->sym->m_src;
4362 if (ut_params->obuf)
4363 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4365 ciphertext = plaintext;
4367 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4369 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4371 tdata->ciphertext.data,
4372 tdata->validDataLenInBits.len,
4373 "SNOW 3G Ciphertext data not as expected");
4375 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4376 + plaintext_pad_len;
4379 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4382 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4383 "SNOW 3G Generated auth tag not as expected");
4388 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4389 uint8_t op_mode, uint8_t verify)
4391 struct crypto_testsuite_params *ts_params = &testsuite_params;
4392 struct crypto_unittest_params *ut_params = &unittest_params;
4396 uint8_t *plaintext = NULL, *ciphertext = NULL;
4397 unsigned int plaintext_pad_len;
4398 unsigned int plaintext_len;
4399 unsigned int ciphertext_pad_len;
4400 unsigned int ciphertext_len;
4402 struct rte_cryptodev_info dev_info;
4404 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4406 uint64_t feat_flags = dev_info.feature_flags;
4408 if (op_mode == OUT_OF_PLACE) {
4409 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4410 printf("Device doesn't support digest encrypted.\n");
4415 /* Create SNOW 3G session */
4416 retval = create_wireless_algo_auth_cipher_session(
4417 ts_params->valid_devs[0],
4418 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4419 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4420 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4421 : RTE_CRYPTO_AUTH_OP_GENERATE),
4422 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4423 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4424 tdata->key.data, tdata->key.len,
4425 tdata->auth_iv.len, tdata->digest.len,
4426 tdata->cipher_iv.len);
4431 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4432 if (op_mode == OUT_OF_PLACE)
4433 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4435 /* clear mbuf payload */
4436 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4437 rte_pktmbuf_tailroom(ut_params->ibuf));
4438 if (op_mode == OUT_OF_PLACE)
4439 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4440 rte_pktmbuf_tailroom(ut_params->obuf));
4442 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4443 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4444 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4445 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4448 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4449 ciphertext_pad_len);
4450 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4451 if (op_mode == OUT_OF_PLACE)
4452 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4453 debug_hexdump(stdout, "ciphertext:", ciphertext,
4456 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4458 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4459 if (op_mode == OUT_OF_PLACE)
4460 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4461 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4464 /* Create SNOW 3G operation */
4465 retval = create_wireless_algo_auth_cipher_operation(
4467 tdata->cipher_iv.data, tdata->cipher_iv.len,
4468 tdata->auth_iv.data, tdata->auth_iv.len,
4469 (tdata->digest.offset_bytes == 0 ?
4470 (verify ? ciphertext_pad_len : plaintext_pad_len)
4471 : tdata->digest.offset_bytes),
4472 tdata->validCipherLenInBits.len,
4473 tdata->cipher.offset_bits,
4474 tdata->validAuthLenInBits.len,
4475 tdata->auth.offset_bits,
4481 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4484 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4486 ut_params->obuf = (op_mode == IN_PLACE ?
4487 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4490 if (ut_params->obuf)
4491 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4494 plaintext = ciphertext +
4495 (tdata->cipher.offset_bits >> 3);
4497 debug_hexdump(stdout, "plaintext:", plaintext,
4498 (tdata->plaintext.len >> 3) - tdata->digest.len);
4499 debug_hexdump(stdout, "plaintext expected:",
4500 tdata->plaintext.data,
4501 (tdata->plaintext.len >> 3) - tdata->digest.len);
4503 if (ut_params->obuf)
4504 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4507 ciphertext = plaintext;
4509 debug_hexdump(stdout, "ciphertext:", ciphertext,
4511 debug_hexdump(stdout, "ciphertext expected:",
4512 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4514 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4515 + (tdata->digest.offset_bytes == 0 ?
4516 plaintext_pad_len : tdata->digest.offset_bytes);
4518 debug_hexdump(stdout, "digest:", ut_params->digest,
4520 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4526 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4528 tdata->plaintext.data,
4529 tdata->plaintext.len >> 3,
4530 "SNOW 3G Plaintext data not as expected");
4532 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4534 tdata->ciphertext.data,
4535 tdata->validDataLenInBits.len,
4536 "SNOW 3G Ciphertext data not as expected");
4538 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4541 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4542 "SNOW 3G Generated auth tag not as expected");
4548 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4550 struct crypto_testsuite_params *ts_params = &testsuite_params;
4551 struct crypto_unittest_params *ut_params = &unittest_params;
4555 uint8_t *plaintext, *ciphertext;
4556 unsigned plaintext_pad_len;
4557 unsigned plaintext_len;
4559 /* Create KASUMI session */
4560 retval = create_wireless_algo_auth_cipher_session(
4561 ts_params->valid_devs[0],
4562 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4563 RTE_CRYPTO_AUTH_OP_GENERATE,
4564 RTE_CRYPTO_AUTH_KASUMI_F9,
4565 RTE_CRYPTO_CIPHER_KASUMI_F8,
4566 tdata->key.data, tdata->key.len,
4567 0, tdata->digest.len,
4568 tdata->cipher_iv.len);
4571 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4573 /* clear mbuf payload */
4574 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4575 rte_pktmbuf_tailroom(ut_params->ibuf));
4577 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4578 /* Append data which is padded to a multiple of */
4579 /* the algorithms block size */
4580 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4581 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4583 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4585 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4587 /* Create KASUMI operation */
4588 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4589 tdata->cipher_iv.data, tdata->cipher_iv.len,
4592 tdata->validCipherLenInBits.len,
4593 tdata->validCipherOffsetInBits.len,
4594 tdata->validAuthLenInBits.len,
4601 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4603 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4604 if (ut_params->op->sym->m_dst)
4605 ut_params->obuf = ut_params->op->sym->m_dst;
4607 ut_params->obuf = ut_params->op->sym->m_src;
4609 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4610 tdata->validCipherOffsetInBits.len >> 3);
4612 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4613 (tdata->validCipherOffsetInBits.len >> 3);
4615 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4617 reference_ciphertext,
4618 tdata->validCipherLenInBits.len,
4619 "KASUMI Ciphertext data not as expected");
4620 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4621 + plaintext_pad_len;
4624 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4627 DIGEST_BYTE_LENGTH_KASUMI_F9,
4628 "KASUMI Generated auth tag not as expected");
4633 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4635 struct crypto_testsuite_params *ts_params = &testsuite_params;
4636 struct crypto_unittest_params *ut_params = &unittest_params;
4640 uint8_t *plaintext, *ciphertext;
4641 unsigned plaintext_pad_len;
4642 unsigned plaintext_len;
4644 /* Create KASUMI session */
4645 retval = create_wireless_algo_cipher_auth_session(
4646 ts_params->valid_devs[0],
4647 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4648 RTE_CRYPTO_AUTH_OP_GENERATE,
4649 RTE_CRYPTO_AUTH_KASUMI_F9,
4650 RTE_CRYPTO_CIPHER_KASUMI_F8,
4651 tdata->key.data, tdata->key.len,
4652 0, tdata->digest.len,
4653 tdata->cipher_iv.len);
4657 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4659 /* clear mbuf payload */
4660 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4661 rte_pktmbuf_tailroom(ut_params->ibuf));
4663 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4664 /* Append data which is padded to a multiple of */
4665 /* the algorithms block size */
4666 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4667 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4669 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4671 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4673 /* Create KASUMI operation */
4674 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4675 tdata->digest.len, NULL, 0,
4676 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4677 tdata->cipher_iv.data, tdata->cipher_iv.len,
4678 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4679 tdata->validCipherOffsetInBits.len,
4680 tdata->validAuthLenInBits.len,
4686 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4688 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4690 if (ut_params->op->sym->m_dst)
4691 ut_params->obuf = ut_params->op->sym->m_dst;
4693 ut_params->obuf = ut_params->op->sym->m_src;
4695 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4696 tdata->validCipherOffsetInBits.len >> 3);
4698 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4699 + plaintext_pad_len;
4701 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4702 (tdata->validCipherOffsetInBits.len >> 3);
4704 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4706 reference_ciphertext,
4707 tdata->validCipherLenInBits.len,
4708 "KASUMI Ciphertext data not as expected");
4711 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4714 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4715 "KASUMI Generated auth tag not as expected");
4720 test_zuc_encryption(const struct wireless_test_data *tdata)
4722 struct crypto_testsuite_params *ts_params = &testsuite_params;
4723 struct crypto_unittest_params *ut_params = &unittest_params;
4726 uint8_t *plaintext, *ciphertext;
4727 unsigned plaintext_pad_len;
4728 unsigned plaintext_len;
4730 struct rte_cryptodev_sym_capability_idx cap_idx;
4732 /* Check if device supports ZUC EEA3 */
4733 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4734 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4736 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4740 /* Create ZUC session */
4741 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4742 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4743 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4744 tdata->key.data, tdata->key.len,
4745 tdata->cipher_iv.len);
4749 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4751 /* Clear mbuf payload */
4752 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4753 rte_pktmbuf_tailroom(ut_params->ibuf));
4755 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4756 /* Append data which is padded to a multiple */
4757 /* of the algorithms block size */
4758 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4759 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4761 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4763 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4765 /* Create ZUC operation */
4766 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4767 tdata->cipher_iv.len,
4768 tdata->plaintext.len,
4773 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4775 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4777 ut_params->obuf = ut_params->op->sym->m_dst;
4778 if (ut_params->obuf)
4779 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4781 ciphertext = plaintext;
4783 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4786 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4788 tdata->ciphertext.data,
4789 tdata->validCipherLenInBits.len,
4790 "ZUC Ciphertext data not as expected");
4795 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4797 struct crypto_testsuite_params *ts_params = &testsuite_params;
4798 struct crypto_unittest_params *ut_params = &unittest_params;
4802 unsigned int plaintext_pad_len;
4803 unsigned int plaintext_len;
4804 const uint8_t *ciphertext;
4805 uint8_t ciphertext_buffer[2048];
4806 struct rte_cryptodev_info dev_info;
4808 struct rte_cryptodev_sym_capability_idx cap_idx;
4810 /* Check if device supports ZUC EEA3 */
4811 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4812 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4814 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4818 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4820 uint64_t feat_flags = dev_info.feature_flags;
4822 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4823 printf("Device doesn't support in-place scatter-gather. "
4828 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4830 /* Append data which is padded to a multiple */
4831 /* of the algorithms block size */
4832 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4834 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4835 plaintext_pad_len, 10, 0);
4837 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4838 tdata->plaintext.data);
4840 /* Create ZUC session */
4841 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4842 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4843 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4844 tdata->key.data, tdata->key.len,
4845 tdata->cipher_iv.len);
4849 /* Clear mbuf payload */
4851 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4853 /* Create ZUC operation */
4854 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4855 tdata->cipher_iv.len, tdata->plaintext.len,
4860 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4862 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4864 ut_params->obuf = ut_params->op->sym->m_dst;
4865 if (ut_params->obuf)
4866 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4867 0, plaintext_len, ciphertext_buffer);
4869 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4870 0, plaintext_len, ciphertext_buffer);
4873 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4876 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4878 tdata->ciphertext.data,
4879 tdata->validCipherLenInBits.len,
4880 "ZUC Ciphertext data not as expected");
4886 test_zuc_authentication(const struct wireless_test_data *tdata)
4888 struct crypto_testsuite_params *ts_params = &testsuite_params;
4889 struct crypto_unittest_params *ut_params = &unittest_params;
4892 unsigned plaintext_pad_len;
4893 unsigned plaintext_len;
4896 struct rte_cryptodev_sym_capability_idx cap_idx;
4898 /* Check if device supports ZUC EIA3 */
4899 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4900 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4902 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4906 /* Create ZUC session */
4907 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4908 tdata->key.data, tdata->key.len,
4909 tdata->auth_iv.len, tdata->digest.len,
4910 RTE_CRYPTO_AUTH_OP_GENERATE,
4911 RTE_CRYPTO_AUTH_ZUC_EIA3);
4915 /* alloc mbuf and set payload */
4916 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4918 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4919 rte_pktmbuf_tailroom(ut_params->ibuf));
4921 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4922 /* Append data which is padded to a multiple of */
4923 /* the algorithms block size */
4924 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4925 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4927 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4929 /* Create ZUC operation */
4930 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4931 tdata->auth_iv.data, tdata->auth_iv.len,
4932 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4933 tdata->validAuthLenInBits.len,
4938 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4940 ut_params->obuf = ut_params->op->sym->m_src;
4941 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4942 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4943 + plaintext_pad_len;
4946 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4949 DIGEST_BYTE_LENGTH_KASUMI_F9,
4950 "ZUC Generated auth tag not as expected");
4956 test_kasumi_encryption_test_case_1(void)
4958 return test_kasumi_encryption(&kasumi_test_case_1);
4962 test_kasumi_encryption_test_case_1_sgl(void)
4964 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4968 test_kasumi_encryption_test_case_1_oop(void)
4970 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4974 test_kasumi_encryption_test_case_1_oop_sgl(void)
4976 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4980 test_kasumi_encryption_test_case_2(void)
4982 return test_kasumi_encryption(&kasumi_test_case_2);
4986 test_kasumi_encryption_test_case_3(void)
4988 return test_kasumi_encryption(&kasumi_test_case_3);
4992 test_kasumi_encryption_test_case_4(void)
4994 return test_kasumi_encryption(&kasumi_test_case_4);
4998 test_kasumi_encryption_test_case_5(void)
5000 return test_kasumi_encryption(&kasumi_test_case_5);
5004 test_kasumi_decryption_test_case_1(void)
5006 return test_kasumi_decryption(&kasumi_test_case_1);
5010 test_kasumi_decryption_test_case_1_oop(void)
5012 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5016 test_kasumi_decryption_test_case_2(void)
5018 return test_kasumi_decryption(&kasumi_test_case_2);
5022 test_kasumi_decryption_test_case_3(void)
5024 return test_kasumi_decryption(&kasumi_test_case_3);
5028 test_kasumi_decryption_test_case_4(void)
5030 return test_kasumi_decryption(&kasumi_test_case_4);
5034 test_kasumi_decryption_test_case_5(void)
5036 return test_kasumi_decryption(&kasumi_test_case_5);
5039 test_snow3g_encryption_test_case_1(void)
5041 return test_snow3g_encryption(&snow3g_test_case_1);
5045 test_snow3g_encryption_test_case_1_oop(void)
5047 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5051 test_snow3g_encryption_test_case_1_oop_sgl(void)
5053 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5058 test_snow3g_encryption_test_case_1_offset_oop(void)
5060 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5064 test_snow3g_encryption_test_case_2(void)
5066 return test_snow3g_encryption(&snow3g_test_case_2);
5070 test_snow3g_encryption_test_case_3(void)
5072 return test_snow3g_encryption(&snow3g_test_case_3);
5076 test_snow3g_encryption_test_case_4(void)
5078 return test_snow3g_encryption(&snow3g_test_case_4);
5082 test_snow3g_encryption_test_case_5(void)
5084 return test_snow3g_encryption(&snow3g_test_case_5);
5088 test_snow3g_decryption_test_case_1(void)
5090 return test_snow3g_decryption(&snow3g_test_case_1);
5094 test_snow3g_decryption_test_case_1_oop(void)
5096 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5100 test_snow3g_decryption_test_case_2(void)
5102 return test_snow3g_decryption(&snow3g_test_case_2);
5106 test_snow3g_decryption_test_case_3(void)
5108 return test_snow3g_decryption(&snow3g_test_case_3);
5112 test_snow3g_decryption_test_case_4(void)
5114 return test_snow3g_decryption(&snow3g_test_case_4);
5118 test_snow3g_decryption_test_case_5(void)
5120 return test_snow3g_decryption(&snow3g_test_case_5);
5124 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5125 * Pattern digest from snow3g_test_data must be allocated as
5126 * 4 last bytes in plaintext.
5129 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5130 struct snow3g_hash_test_data *output)
5132 if ((pattern != NULL) && (output != NULL)) {
5133 output->key.len = pattern->key.len;
5135 memcpy(output->key.data,
5136 pattern->key.data, pattern->key.len);
5138 output->auth_iv.len = pattern->auth_iv.len;
5140 memcpy(output->auth_iv.data,
5141 pattern->auth_iv.data, pattern->auth_iv.len);
5143 output->plaintext.len = pattern->plaintext.len;
5145 memcpy(output->plaintext.data,
5146 pattern->plaintext.data, pattern->plaintext.len >> 3);
5148 output->digest.len = pattern->digest.len;
5150 memcpy(output->digest.data,
5151 &pattern->plaintext.data[pattern->digest.offset_bytes],
5152 pattern->digest.len);
5154 output->validAuthLenInBits.len =
5155 pattern->validAuthLenInBits.len;
5160 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5163 test_snow3g_decryption_with_digest_test_case_1(void)
5165 struct snow3g_hash_test_data snow3g_hash_data;
5168 * Function prepare data for hash veryfication test case.
5169 * Digest is allocated in 4 last bytes in plaintext, pattern.
5171 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5173 return test_snow3g_decryption(&snow3g_test_case_7) &
5174 test_snow3g_authentication_verify(&snow3g_hash_data);
5178 test_snow3g_cipher_auth_test_case_1(void)
5180 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5184 test_snow3g_auth_cipher_test_case_1(void)
5186 return test_snow3g_auth_cipher(
5187 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5191 test_snow3g_auth_cipher_test_case_2(void)
5193 return test_snow3g_auth_cipher(
5194 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5198 test_snow3g_auth_cipher_test_case_2_oop(void)
5200 return test_snow3g_auth_cipher(
5201 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5205 test_snow3g_auth_cipher_part_digest_enc(void)
5207 return test_snow3g_auth_cipher(
5208 &snow3g_auth_cipher_partial_digest_encryption,
5213 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5215 return test_snow3g_auth_cipher(
5216 &snow3g_auth_cipher_partial_digest_encryption,
5221 test_snow3g_auth_cipher_verify_test_case_1(void)
5223 return test_snow3g_auth_cipher(
5224 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5228 test_snow3g_auth_cipher_verify_test_case_2(void)
5230 return test_snow3g_auth_cipher(
5231 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5235 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5237 return test_snow3g_auth_cipher(
5238 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5242 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5244 return test_snow3g_auth_cipher(
5245 &snow3g_auth_cipher_partial_digest_encryption,
5250 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5252 return test_snow3g_auth_cipher(
5253 &snow3g_auth_cipher_partial_digest_encryption,
5258 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5260 return test_snow3g_auth_cipher(
5261 &snow3g_test_case_7, IN_PLACE, 0);
5265 test_kasumi_auth_cipher_test_case_1(void)
5267 return test_kasumi_auth_cipher(&kasumi_test_case_3);
5271 test_kasumi_cipher_auth_test_case_1(void)
5273 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5277 test_zuc_encryption_test_case_1(void)
5279 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5283 test_zuc_encryption_test_case_2(void)
5285 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5289 test_zuc_encryption_test_case_3(void)
5291 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5295 test_zuc_encryption_test_case_4(void)
5297 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5301 test_zuc_encryption_test_case_5(void)
5303 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5307 test_zuc_encryption_test_case_6_sgl(void)
5309 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5313 test_zuc_hash_generate_test_case_1(void)
5315 return test_zuc_authentication(&zuc_test_case_auth_1b);
5319 test_zuc_hash_generate_test_case_2(void)
5321 return test_zuc_authentication(&zuc_test_case_auth_90b);
5325 test_zuc_hash_generate_test_case_3(void)
5327 return test_zuc_authentication(&zuc_test_case_auth_577b);
5331 test_zuc_hash_generate_test_case_4(void)
5333 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5337 test_zuc_hash_generate_test_case_5(void)
5339 return test_zuc_authentication(&zuc_test_auth_5670b);
5343 test_zuc_hash_generate_test_case_6(void)
5345 return test_zuc_authentication(&zuc_test_case_auth_128b);
5349 test_zuc_hash_generate_test_case_7(void)
5351 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5355 test_zuc_hash_generate_test_case_8(void)
5357 return test_zuc_authentication(&zuc_test_case_auth_584b);
5361 test_zuc_cipher_auth_test_case_1(void)
5363 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5367 test_zuc_cipher_auth_test_case_2(void)
5369 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5373 test_3DES_chain_qat_all(void)
5375 struct crypto_testsuite_params *ts_params = &testsuite_params;
5378 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5379 ts_params->op_mpool,
5380 ts_params->session_mpool, ts_params->session_priv_mpool,
5381 ts_params->valid_devs[0],
5382 rte_cryptodev_driver_id_get(
5383 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5384 BLKCIPHER_3DES_CHAIN_TYPE);
5386 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5388 return TEST_SUCCESS;
5392 test_DES_cipheronly_qat_all(void)
5394 struct crypto_testsuite_params *ts_params = &testsuite_params;
5397 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5398 ts_params->op_mpool,
5399 ts_params->session_mpool, ts_params->session_priv_mpool,
5400 ts_params->valid_devs[0],
5401 rte_cryptodev_driver_id_get(
5402 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5403 BLKCIPHER_DES_CIPHERONLY_TYPE);
5405 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5407 return TEST_SUCCESS;
5411 test_DES_cipheronly_openssl_all(void)
5413 struct crypto_testsuite_params *ts_params = &testsuite_params;
5416 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5417 ts_params->op_mpool,
5418 ts_params->session_mpool, ts_params->session_priv_mpool,
5419 ts_params->valid_devs[0],
5420 rte_cryptodev_driver_id_get(
5421 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5422 BLKCIPHER_DES_CIPHERONLY_TYPE);
5424 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5426 return TEST_SUCCESS;
5430 test_DES_docsis_openssl_all(void)
5432 struct crypto_testsuite_params *ts_params = &testsuite_params;
5435 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5436 ts_params->op_mpool,
5437 ts_params->session_mpool, ts_params->session_priv_mpool,
5438 ts_params->valid_devs[0],
5439 rte_cryptodev_driver_id_get(
5440 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5441 BLKCIPHER_DES_DOCSIS_TYPE);
5443 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5445 return TEST_SUCCESS;
5449 test_DES_cipheronly_mb_all(void)
5451 struct crypto_testsuite_params *ts_params = &testsuite_params;
5454 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5455 ts_params->op_mpool,
5456 ts_params->session_mpool, ts_params->session_priv_mpool,
5457 ts_params->valid_devs[0],
5458 rte_cryptodev_driver_id_get(
5459 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5460 BLKCIPHER_DES_CIPHERONLY_TYPE);
5462 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5464 return TEST_SUCCESS;
5467 test_3DES_cipheronly_mb_all(void)
5469 struct crypto_testsuite_params *ts_params = &testsuite_params;
5472 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5473 ts_params->op_mpool,
5474 ts_params->session_mpool, ts_params->session_priv_mpool,
5475 ts_params->valid_devs[0],
5476 rte_cryptodev_driver_id_get(
5477 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5478 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5480 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5482 return TEST_SUCCESS;
5486 test_DES_docsis_mb_all(void)
5488 struct crypto_testsuite_params *ts_params = &testsuite_params;
5491 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5492 ts_params->op_mpool,
5493 ts_params->session_mpool, ts_params->session_priv_mpool,
5494 ts_params->valid_devs[0],
5495 rte_cryptodev_driver_id_get(
5496 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5497 BLKCIPHER_DES_DOCSIS_TYPE);
5499 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5501 return TEST_SUCCESS;
5505 test_3DES_chain_caam_jr_all(void)
5507 struct crypto_testsuite_params *ts_params = &testsuite_params;
5510 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5511 ts_params->op_mpool,
5512 ts_params->session_mpool, ts_params->session_priv_mpool,
5513 ts_params->valid_devs[0],
5514 rte_cryptodev_driver_id_get(
5515 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5516 BLKCIPHER_3DES_CHAIN_TYPE);
5518 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5520 return TEST_SUCCESS;
5524 test_3DES_cipheronly_caam_jr_all(void)
5526 struct crypto_testsuite_params *ts_params = &testsuite_params;
5529 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5530 ts_params->op_mpool,
5531 ts_params->session_mpool, ts_params->session_priv_mpool,
5532 ts_params->valid_devs[0],
5533 rte_cryptodev_driver_id_get(
5534 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5535 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5537 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5539 return TEST_SUCCESS;
5543 test_3DES_chain_dpaa_sec_all(void)
5545 struct crypto_testsuite_params *ts_params = &testsuite_params;
5548 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5549 ts_params->op_mpool,
5550 ts_params->session_mpool, ts_params->session_priv_mpool,
5551 ts_params->valid_devs[0],
5552 rte_cryptodev_driver_id_get(
5553 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5554 BLKCIPHER_3DES_CHAIN_TYPE);
5556 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5558 return TEST_SUCCESS;
5562 test_3DES_cipheronly_dpaa_sec_all(void)
5564 struct crypto_testsuite_params *ts_params = &testsuite_params;
5567 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5568 ts_params->op_mpool,
5569 ts_params->session_mpool, ts_params->session_priv_mpool,
5570 ts_params->valid_devs[0],
5571 rte_cryptodev_driver_id_get(
5572 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5573 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5575 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5577 return TEST_SUCCESS;
5581 test_3DES_chain_dpaa2_sec_all(void)
5583 struct crypto_testsuite_params *ts_params = &testsuite_params;
5586 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5587 ts_params->op_mpool,
5588 ts_params->session_mpool, ts_params->session_priv_mpool,
5589 ts_params->valid_devs[0],
5590 rte_cryptodev_driver_id_get(
5591 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5592 BLKCIPHER_3DES_CHAIN_TYPE);
5594 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5596 return TEST_SUCCESS;
5600 test_3DES_cipheronly_dpaa2_sec_all(void)
5602 struct crypto_testsuite_params *ts_params = &testsuite_params;
5605 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5606 ts_params->op_mpool,
5607 ts_params->session_mpool, ts_params->session_priv_mpool,
5608 ts_params->valid_devs[0],
5609 rte_cryptodev_driver_id_get(
5610 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5611 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5613 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5615 return TEST_SUCCESS;
5619 test_3DES_chain_ccp_all(void)
5621 struct crypto_testsuite_params *ts_params = &testsuite_params;
5624 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5625 ts_params->op_mpool,
5626 ts_params->session_mpool, ts_params->session_priv_mpool,
5627 ts_params->valid_devs[0],
5628 rte_cryptodev_driver_id_get(
5629 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5630 BLKCIPHER_3DES_CHAIN_TYPE);
5632 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5634 return TEST_SUCCESS;
5638 test_3DES_cipheronly_ccp_all(void)
5640 struct crypto_testsuite_params *ts_params = &testsuite_params;
5643 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5644 ts_params->op_mpool,
5645 ts_params->session_mpool, ts_params->session_priv_mpool,
5646 ts_params->valid_devs[0],
5647 rte_cryptodev_driver_id_get(
5648 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5649 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5651 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5653 return TEST_SUCCESS;
5657 test_3DES_cipheronly_qat_all(void)
5659 struct crypto_testsuite_params *ts_params = &testsuite_params;
5662 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5663 ts_params->op_mpool,
5664 ts_params->session_mpool, ts_params->session_priv_mpool,
5665 ts_params->valid_devs[0],
5666 rte_cryptodev_driver_id_get(
5667 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5668 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5670 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5672 return TEST_SUCCESS;
5676 test_3DES_chain_openssl_all(void)
5678 struct crypto_testsuite_params *ts_params = &testsuite_params;
5681 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5682 ts_params->op_mpool,
5683 ts_params->session_mpool, ts_params->session_priv_mpool,
5684 ts_params->valid_devs[0],
5685 rte_cryptodev_driver_id_get(
5686 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5687 BLKCIPHER_3DES_CHAIN_TYPE);
5689 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5691 return TEST_SUCCESS;
5695 test_3DES_cipheronly_openssl_all(void)
5697 struct crypto_testsuite_params *ts_params = &testsuite_params;
5700 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5701 ts_params->op_mpool,
5702 ts_params->session_mpool, ts_params->session_priv_mpool,
5703 ts_params->valid_devs[0],
5704 rte_cryptodev_driver_id_get(
5705 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5706 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5708 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5710 return TEST_SUCCESS;
5713 /* ***** AEAD algorithm Tests ***** */
5716 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5717 enum rte_crypto_aead_operation op,
5718 const uint8_t *key, const uint8_t key_len,
5719 const uint16_t aad_len, const uint8_t auth_len,
5722 uint8_t aead_key[key_len];
5724 struct crypto_testsuite_params *ts_params = &testsuite_params;
5725 struct crypto_unittest_params *ut_params = &unittest_params;
5727 memcpy(aead_key, key, key_len);
5729 /* Setup AEAD Parameters */
5730 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5731 ut_params->aead_xform.next = NULL;
5732 ut_params->aead_xform.aead.algo = algo;
5733 ut_params->aead_xform.aead.op = op;
5734 ut_params->aead_xform.aead.key.data = aead_key;
5735 ut_params->aead_xform.aead.key.length = key_len;
5736 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5737 ut_params->aead_xform.aead.iv.length = iv_len;
5738 ut_params->aead_xform.aead.digest_length = auth_len;
5739 ut_params->aead_xform.aead.aad_length = aad_len;
5741 debug_hexdump(stdout, "key:", key, key_len);
5743 /* Create Crypto session*/
5744 ut_params->sess = rte_cryptodev_sym_session_create(
5745 ts_params->session_mpool);
5747 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5748 &ut_params->aead_xform,
5749 ts_params->session_priv_mpool);
5751 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5757 create_aead_xform(struct rte_crypto_op *op,
5758 enum rte_crypto_aead_algorithm algo,
5759 enum rte_crypto_aead_operation aead_op,
5760 uint8_t *key, const uint8_t key_len,
5761 const uint8_t aad_len, const uint8_t auth_len,
5764 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5765 "failed to allocate space for crypto transform");
5767 struct rte_crypto_sym_op *sym_op = op->sym;
5769 /* Setup AEAD Parameters */
5770 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5771 sym_op->xform->next = NULL;
5772 sym_op->xform->aead.algo = algo;
5773 sym_op->xform->aead.op = aead_op;
5774 sym_op->xform->aead.key.data = key;
5775 sym_op->xform->aead.key.length = key_len;
5776 sym_op->xform->aead.iv.offset = IV_OFFSET;
5777 sym_op->xform->aead.iv.length = iv_len;
5778 sym_op->xform->aead.digest_length = auth_len;
5779 sym_op->xform->aead.aad_length = aad_len;
5781 debug_hexdump(stdout, "key:", key, key_len);
5787 create_aead_operation(enum rte_crypto_aead_operation op,
5788 const struct aead_test_data *tdata)
5790 struct crypto_testsuite_params *ts_params = &testsuite_params;
5791 struct crypto_unittest_params *ut_params = &unittest_params;
5793 uint8_t *plaintext, *ciphertext;
5794 unsigned int aad_pad_len, plaintext_pad_len;
5796 /* Generate Crypto op data structure */
5797 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5798 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5799 TEST_ASSERT_NOT_NULL(ut_params->op,
5800 "Failed to allocate symmetric crypto operation struct");
5802 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5804 /* Append aad data */
5805 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5806 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5807 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5809 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5810 "no room to append aad");
5812 sym_op->aead.aad.phys_addr =
5813 rte_pktmbuf_iova(ut_params->ibuf);
5814 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5815 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5816 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5819 /* Append IV at the end of the crypto operation*/
5820 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5821 uint8_t *, IV_OFFSET);
5823 /* Copy IV 1 byte after the IV pointer, according to the API */
5824 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5825 debug_hexdump(stdout, "iv:", iv_ptr,
5828 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5829 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5831 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5832 "no room to append aad");
5834 sym_op->aead.aad.phys_addr =
5835 rte_pktmbuf_iova(ut_params->ibuf);
5836 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5837 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5840 /* Append IV at the end of the crypto operation*/
5841 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5842 uint8_t *, IV_OFFSET);
5844 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5845 debug_hexdump(stdout, "iv:", iv_ptr,
5849 /* Append plaintext/ciphertext */
5850 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5851 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5852 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5854 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5856 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5857 debug_hexdump(stdout, "plaintext:", plaintext,
5858 tdata->plaintext.len);
5860 if (ut_params->obuf) {
5861 ciphertext = (uint8_t *)rte_pktmbuf_append(
5863 plaintext_pad_len + aad_pad_len);
5864 TEST_ASSERT_NOT_NULL(ciphertext,
5865 "no room to append ciphertext");
5867 memset(ciphertext + aad_pad_len, 0,
5868 tdata->ciphertext.len);
5871 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5872 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5874 TEST_ASSERT_NOT_NULL(ciphertext,
5875 "no room to append ciphertext");
5877 memcpy(ciphertext, tdata->ciphertext.data,
5878 tdata->ciphertext.len);
5879 debug_hexdump(stdout, "ciphertext:", ciphertext,
5880 tdata->ciphertext.len);
5882 if (ut_params->obuf) {
5883 plaintext = (uint8_t *)rte_pktmbuf_append(
5885 plaintext_pad_len + aad_pad_len);
5886 TEST_ASSERT_NOT_NULL(plaintext,
5887 "no room to append plaintext");
5889 memset(plaintext + aad_pad_len, 0,
5890 tdata->plaintext.len);
5894 /* Append digest data */
5895 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5896 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5897 ut_params->obuf ? ut_params->obuf :
5899 tdata->auth_tag.len);
5900 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5901 "no room to append digest");
5902 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5903 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5904 ut_params->obuf ? ut_params->obuf :
5909 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5910 ut_params->ibuf, tdata->auth_tag.len);
5911 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5912 "no room to append digest");
5913 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5915 plaintext_pad_len + aad_pad_len);
5917 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5918 tdata->auth_tag.len);
5919 debug_hexdump(stdout, "digest:",
5920 sym_op->aead.digest.data,
5921 tdata->auth_tag.len);
5924 sym_op->aead.data.length = tdata->plaintext.len;
5925 sym_op->aead.data.offset = aad_pad_len;
5931 test_authenticated_encryption(const struct aead_test_data *tdata)
5933 struct crypto_testsuite_params *ts_params = &testsuite_params;
5934 struct crypto_unittest_params *ut_params = &unittest_params;
5937 uint8_t *ciphertext, *auth_tag;
5938 uint16_t plaintext_pad_len;
5941 /* Create AEAD session */
5942 retval = create_aead_session(ts_params->valid_devs[0],
5944 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5945 tdata->key.data, tdata->key.len,
5946 tdata->aad.len, tdata->auth_tag.len,
5951 if (tdata->aad.len > MBUF_SIZE) {
5952 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5953 /* Populate full size of add data */
5954 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5955 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5957 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5959 /* clear mbuf payload */
5960 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5961 rte_pktmbuf_tailroom(ut_params->ibuf));
5963 /* Create AEAD operation */
5964 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5968 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5970 ut_params->op->sym->m_src = ut_params->ibuf;
5972 /* Process crypto operation */
5973 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5974 ut_params->op), "failed to process sym crypto op");
5976 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5977 "crypto op processing failed");
5979 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5981 if (ut_params->op->sym->m_dst) {
5982 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5984 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5985 uint8_t *, plaintext_pad_len);
5987 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5989 ut_params->op->sym->cipher.data.offset);
5990 auth_tag = ciphertext + plaintext_pad_len;
5993 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5994 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5997 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5999 tdata->ciphertext.data,
6000 tdata->ciphertext.len,
6001 "Ciphertext data not as expected");
6003 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6005 tdata->auth_tag.data,
6006 tdata->auth_tag.len,
6007 "Generated auth tag not as expected");
6014 test_AES_GCM_authenticated_encryption_test_case_1(void)
6016 return test_authenticated_encryption(&gcm_test_case_1);
6020 test_AES_GCM_authenticated_encryption_test_case_2(void)
6022 return test_authenticated_encryption(&gcm_test_case_2);
6026 test_AES_GCM_authenticated_encryption_test_case_3(void)
6028 return test_authenticated_encryption(&gcm_test_case_3);
6032 test_AES_GCM_authenticated_encryption_test_case_4(void)
6034 return test_authenticated_encryption(&gcm_test_case_4);
6038 test_AES_GCM_authenticated_encryption_test_case_5(void)
6040 return test_authenticated_encryption(&gcm_test_case_5);
6044 test_AES_GCM_authenticated_encryption_test_case_6(void)
6046 return test_authenticated_encryption(&gcm_test_case_6);
6050 test_AES_GCM_authenticated_encryption_test_case_7(void)
6052 return test_authenticated_encryption(&gcm_test_case_7);
6056 test_AES_GCM_auth_encryption_test_case_192_1(void)
6058 return test_authenticated_encryption(&gcm_test_case_192_1);
6062 test_AES_GCM_auth_encryption_test_case_192_2(void)
6064 return test_authenticated_encryption(&gcm_test_case_192_2);
6068 test_AES_GCM_auth_encryption_test_case_192_3(void)
6070 return test_authenticated_encryption(&gcm_test_case_192_3);
6074 test_AES_GCM_auth_encryption_test_case_192_4(void)
6076 return test_authenticated_encryption(&gcm_test_case_192_4);
6080 test_AES_GCM_auth_encryption_test_case_192_5(void)
6082 return test_authenticated_encryption(&gcm_test_case_192_5);
6086 test_AES_GCM_auth_encryption_test_case_192_6(void)
6088 return test_authenticated_encryption(&gcm_test_case_192_6);
6092 test_AES_GCM_auth_encryption_test_case_192_7(void)
6094 return test_authenticated_encryption(&gcm_test_case_192_7);
6098 test_AES_GCM_auth_encryption_test_case_256_1(void)
6100 return test_authenticated_encryption(&gcm_test_case_256_1);
6104 test_AES_GCM_auth_encryption_test_case_256_2(void)
6106 return test_authenticated_encryption(&gcm_test_case_256_2);
6110 test_AES_GCM_auth_encryption_test_case_256_3(void)
6112 return test_authenticated_encryption(&gcm_test_case_256_3);
6116 test_AES_GCM_auth_encryption_test_case_256_4(void)
6118 return test_authenticated_encryption(&gcm_test_case_256_4);
6122 test_AES_GCM_auth_encryption_test_case_256_5(void)
6124 return test_authenticated_encryption(&gcm_test_case_256_5);
6128 test_AES_GCM_auth_encryption_test_case_256_6(void)
6130 return test_authenticated_encryption(&gcm_test_case_256_6);
6134 test_AES_GCM_auth_encryption_test_case_256_7(void)
6136 return test_authenticated_encryption(&gcm_test_case_256_7);
6140 test_AES_GCM_auth_encryption_test_case_aad_1(void)
6142 return test_authenticated_encryption(&gcm_test_case_aad_1);
6146 test_AES_GCM_auth_encryption_test_case_aad_2(void)
6148 return test_authenticated_encryption(&gcm_test_case_aad_2);
6152 test_authenticated_decryption(const struct aead_test_data *tdata)
6154 struct crypto_testsuite_params *ts_params = &testsuite_params;
6155 struct crypto_unittest_params *ut_params = &unittest_params;
6161 /* Create AEAD session */
6162 retval = create_aead_session(ts_params->valid_devs[0],
6164 RTE_CRYPTO_AEAD_OP_DECRYPT,
6165 tdata->key.data, tdata->key.len,
6166 tdata->aad.len, tdata->auth_tag.len,
6171 /* alloc mbuf and set payload */
6172 if (tdata->aad.len > MBUF_SIZE) {
6173 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6174 /* Populate full size of add data */
6175 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6176 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6178 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6180 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6181 rte_pktmbuf_tailroom(ut_params->ibuf));
6183 /* Create AEAD operation */
6184 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6188 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6190 ut_params->op->sym->m_src = ut_params->ibuf;
6192 /* Process crypto operation */
6193 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6194 ut_params->op), "failed to process sym crypto op");
6196 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6197 "crypto op processing failed");
6199 if (ut_params->op->sym->m_dst)
6200 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6203 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6205 ut_params->op->sym->cipher.data.offset);
6207 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6210 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6212 tdata->plaintext.data,
6213 tdata->plaintext.len,
6214 "Plaintext data not as expected");
6216 TEST_ASSERT_EQUAL(ut_params->op->status,
6217 RTE_CRYPTO_OP_STATUS_SUCCESS,
6218 "Authentication failed");
6223 test_AES_GCM_authenticated_decryption_test_case_1(void)
6225 return test_authenticated_decryption(&gcm_test_case_1);
6229 test_AES_GCM_authenticated_decryption_test_case_2(void)
6231 return test_authenticated_decryption(&gcm_test_case_2);
6235 test_AES_GCM_authenticated_decryption_test_case_3(void)
6237 return test_authenticated_decryption(&gcm_test_case_3);
6241 test_AES_GCM_authenticated_decryption_test_case_4(void)
6243 return test_authenticated_decryption(&gcm_test_case_4);
6247 test_AES_GCM_authenticated_decryption_test_case_5(void)
6249 return test_authenticated_decryption(&gcm_test_case_5);
6253 test_AES_GCM_authenticated_decryption_test_case_6(void)
6255 return test_authenticated_decryption(&gcm_test_case_6);
6259 test_AES_GCM_authenticated_decryption_test_case_7(void)
6261 return test_authenticated_decryption(&gcm_test_case_7);
6265 test_AES_GCM_auth_decryption_test_case_192_1(void)
6267 return test_authenticated_decryption(&gcm_test_case_192_1);
6271 test_AES_GCM_auth_decryption_test_case_192_2(void)
6273 return test_authenticated_decryption(&gcm_test_case_192_2);
6277 test_AES_GCM_auth_decryption_test_case_192_3(void)
6279 return test_authenticated_decryption(&gcm_test_case_192_3);
6283 test_AES_GCM_auth_decryption_test_case_192_4(void)
6285 return test_authenticated_decryption(&gcm_test_case_192_4);
6289 test_AES_GCM_auth_decryption_test_case_192_5(void)
6291 return test_authenticated_decryption(&gcm_test_case_192_5);
6295 test_AES_GCM_auth_decryption_test_case_192_6(void)
6297 return test_authenticated_decryption(&gcm_test_case_192_6);
6301 test_AES_GCM_auth_decryption_test_case_192_7(void)
6303 return test_authenticated_decryption(&gcm_test_case_192_7);
6307 test_AES_GCM_auth_decryption_test_case_256_1(void)
6309 return test_authenticated_decryption(&gcm_test_case_256_1);
6313 test_AES_GCM_auth_decryption_test_case_256_2(void)
6315 return test_authenticated_decryption(&gcm_test_case_256_2);
6319 test_AES_GCM_auth_decryption_test_case_256_3(void)
6321 return test_authenticated_decryption(&gcm_test_case_256_3);
6325 test_AES_GCM_auth_decryption_test_case_256_4(void)
6327 return test_authenticated_decryption(&gcm_test_case_256_4);
6331 test_AES_GCM_auth_decryption_test_case_256_5(void)
6333 return test_authenticated_decryption(&gcm_test_case_256_5);
6337 test_AES_GCM_auth_decryption_test_case_256_6(void)
6339 return test_authenticated_decryption(&gcm_test_case_256_6);
6343 test_AES_GCM_auth_decryption_test_case_256_7(void)
6345 return test_authenticated_decryption(&gcm_test_case_256_7);
6349 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6351 return test_authenticated_decryption(&gcm_test_case_aad_1);
6355 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6357 return test_authenticated_decryption(&gcm_test_case_aad_2);
6361 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6363 struct crypto_testsuite_params *ts_params = &testsuite_params;
6364 struct crypto_unittest_params *ut_params = &unittest_params;
6367 uint8_t *ciphertext, *auth_tag;
6368 uint16_t plaintext_pad_len;
6370 /* Create AEAD session */
6371 retval = create_aead_session(ts_params->valid_devs[0],
6373 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6374 tdata->key.data, tdata->key.len,
6375 tdata->aad.len, tdata->auth_tag.len,
6380 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6381 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6383 /* clear mbuf payload */
6384 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6385 rte_pktmbuf_tailroom(ut_params->ibuf));
6386 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6387 rte_pktmbuf_tailroom(ut_params->obuf));
6389 /* Create AEAD operation */
6390 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6394 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6396 ut_params->op->sym->m_src = ut_params->ibuf;
6397 ut_params->op->sym->m_dst = ut_params->obuf;
6399 /* Process crypto operation */
6400 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6401 ut_params->op), "failed to process sym crypto op");
6403 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6404 "crypto op processing failed");
6406 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6408 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6409 ut_params->op->sym->cipher.data.offset);
6410 auth_tag = ciphertext + plaintext_pad_len;
6412 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6413 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6416 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6418 tdata->ciphertext.data,
6419 tdata->ciphertext.len,
6420 "Ciphertext data not as expected");
6422 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6424 tdata->auth_tag.data,
6425 tdata->auth_tag.len,
6426 "Generated auth tag not as expected");
6433 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6435 return test_authenticated_encryption_oop(&gcm_test_case_5);
6439 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6441 struct crypto_testsuite_params *ts_params = &testsuite_params;
6442 struct crypto_unittest_params *ut_params = &unittest_params;
6447 /* Create AEAD session */
6448 retval = create_aead_session(ts_params->valid_devs[0],
6450 RTE_CRYPTO_AEAD_OP_DECRYPT,
6451 tdata->key.data, tdata->key.len,
6452 tdata->aad.len, tdata->auth_tag.len,
6457 /* alloc mbuf and set payload */
6458 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6459 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6461 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6462 rte_pktmbuf_tailroom(ut_params->ibuf));
6463 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6464 rte_pktmbuf_tailroom(ut_params->obuf));
6466 /* Create AEAD operation */
6467 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6471 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6473 ut_params->op->sym->m_src = ut_params->ibuf;
6474 ut_params->op->sym->m_dst = ut_params->obuf;
6476 /* Process crypto operation */
6477 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6478 ut_params->op), "failed to process sym crypto op");
6480 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6481 "crypto op processing failed");
6483 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6484 ut_params->op->sym->cipher.data.offset);
6486 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6489 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6491 tdata->plaintext.data,
6492 tdata->plaintext.len,
6493 "Plaintext data not as expected");
6495 TEST_ASSERT_EQUAL(ut_params->op->status,
6496 RTE_CRYPTO_OP_STATUS_SUCCESS,
6497 "Authentication failed");
6502 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6504 return test_authenticated_decryption_oop(&gcm_test_case_5);
6508 test_authenticated_encryption_sessionless(
6509 const struct aead_test_data *tdata)
6511 struct crypto_testsuite_params *ts_params = &testsuite_params;
6512 struct crypto_unittest_params *ut_params = &unittest_params;
6515 uint8_t *ciphertext, *auth_tag;
6516 uint16_t plaintext_pad_len;
6517 uint8_t key[tdata->key.len + 1];
6519 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6521 /* clear mbuf payload */
6522 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6523 rte_pktmbuf_tailroom(ut_params->ibuf));
6525 /* Create AEAD operation */
6526 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6530 /* Create GCM xform */
6531 memcpy(key, tdata->key.data, tdata->key.len);
6532 retval = create_aead_xform(ut_params->op,
6534 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6535 key, tdata->key.len,
6536 tdata->aad.len, tdata->auth_tag.len,
6541 ut_params->op->sym->m_src = ut_params->ibuf;
6543 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6544 RTE_CRYPTO_OP_SESSIONLESS,
6545 "crypto op session type not sessionless");
6547 /* Process crypto operation */
6548 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6549 ut_params->op), "failed to process sym crypto op");
6551 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6553 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6554 "crypto op status not success");
6556 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6558 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6559 ut_params->op->sym->cipher.data.offset);
6560 auth_tag = ciphertext + plaintext_pad_len;
6562 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6563 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6566 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6568 tdata->ciphertext.data,
6569 tdata->ciphertext.len,
6570 "Ciphertext data not as expected");
6572 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6574 tdata->auth_tag.data,
6575 tdata->auth_tag.len,
6576 "Generated auth tag not as expected");
6583 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6585 return test_authenticated_encryption_sessionless(
6590 test_authenticated_decryption_sessionless(
6591 const struct aead_test_data *tdata)
6593 struct crypto_testsuite_params *ts_params = &testsuite_params;
6594 struct crypto_unittest_params *ut_params = &unittest_params;
6598 uint8_t key[tdata->key.len + 1];
6600 /* alloc mbuf and set payload */
6601 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6603 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6604 rte_pktmbuf_tailroom(ut_params->ibuf));
6606 /* Create AEAD operation */
6607 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6611 /* Create AEAD xform */
6612 memcpy(key, tdata->key.data, tdata->key.len);
6613 retval = create_aead_xform(ut_params->op,
6615 RTE_CRYPTO_AEAD_OP_DECRYPT,
6616 key, tdata->key.len,
6617 tdata->aad.len, tdata->auth_tag.len,
6622 ut_params->op->sym->m_src = ut_params->ibuf;
6624 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6625 RTE_CRYPTO_OP_SESSIONLESS,
6626 "crypto op session type not sessionless");
6628 /* Process crypto operation */
6629 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6630 ut_params->op), "failed to process sym crypto op");
6632 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6634 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6635 "crypto op status not success");
6637 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6638 ut_params->op->sym->cipher.data.offset);
6640 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6643 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6645 tdata->plaintext.data,
6646 tdata->plaintext.len,
6647 "Plaintext data not as expected");
6649 TEST_ASSERT_EQUAL(ut_params->op->status,
6650 RTE_CRYPTO_OP_STATUS_SUCCESS,
6651 "Authentication failed");
6656 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6658 return test_authenticated_decryption_sessionless(
6663 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6665 return test_authenticated_encryption(&ccm_test_case_128_1);
6669 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6671 return test_authenticated_encryption(&ccm_test_case_128_2);
6675 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6677 return test_authenticated_encryption(&ccm_test_case_128_3);
6681 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6683 return test_authenticated_decryption(&ccm_test_case_128_1);
6687 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6689 return test_authenticated_decryption(&ccm_test_case_128_2);
6693 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6695 return test_authenticated_decryption(&ccm_test_case_128_3);
6699 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6701 return test_authenticated_encryption(&ccm_test_case_192_1);
6705 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6707 return test_authenticated_encryption(&ccm_test_case_192_2);
6711 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6713 return test_authenticated_encryption(&ccm_test_case_192_3);
6717 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6719 return test_authenticated_decryption(&ccm_test_case_192_1);
6723 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6725 return test_authenticated_decryption(&ccm_test_case_192_2);
6729 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6731 return test_authenticated_decryption(&ccm_test_case_192_3);
6735 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6737 return test_authenticated_encryption(&ccm_test_case_256_1);
6741 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6743 return test_authenticated_encryption(&ccm_test_case_256_2);
6747 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6749 return test_authenticated_encryption(&ccm_test_case_256_3);
6753 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6755 return test_authenticated_decryption(&ccm_test_case_256_1);
6759 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6761 return test_authenticated_decryption(&ccm_test_case_256_2);
6765 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6767 return test_authenticated_decryption(&ccm_test_case_256_3);
6773 struct crypto_testsuite_params *ts_params = &testsuite_params;
6774 struct rte_cryptodev_stats stats;
6775 struct rte_cryptodev *dev;
6776 cryptodev_stats_get_t temp_pfn;
6778 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6779 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6780 &stats) == -ENODEV),
6781 "rte_cryptodev_stats_get invalid dev failed");
6782 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6783 "rte_cryptodev_stats_get invalid Param failed");
6784 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6785 temp_pfn = dev->dev_ops->stats_get;
6786 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6787 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6789 "rte_cryptodev_stats_get invalid Param failed");
6790 dev->dev_ops->stats_get = temp_pfn;
6792 /* Test expected values */
6794 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6796 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6798 "rte_cryptodev_stats_get failed");
6799 TEST_ASSERT((stats.enqueued_count == 1),
6800 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6801 TEST_ASSERT((stats.dequeued_count == 1),
6802 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6803 TEST_ASSERT((stats.enqueue_err_count == 0),
6804 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6805 TEST_ASSERT((stats.dequeue_err_count == 0),
6806 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6808 /* invalid device but should ignore and not reset device stats*/
6809 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6810 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6812 "rte_cryptodev_stats_get failed");
6813 TEST_ASSERT((stats.enqueued_count == 1),
6814 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6816 /* check that a valid reset clears stats */
6817 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6818 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6820 "rte_cryptodev_stats_get failed");
6821 TEST_ASSERT((stats.enqueued_count == 0),
6822 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6823 TEST_ASSERT((stats.dequeued_count == 0),
6824 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6826 return TEST_SUCCESS;
6829 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6830 struct crypto_unittest_params *ut_params,
6831 enum rte_crypto_auth_operation op,
6832 const struct HMAC_MD5_vector *test_case)
6836 memcpy(key, test_case->key.data, test_case->key.len);
6838 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6839 ut_params->auth_xform.next = NULL;
6840 ut_params->auth_xform.auth.op = op;
6842 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6844 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6845 ut_params->auth_xform.auth.key.length = test_case->key.len;
6846 ut_params->auth_xform.auth.key.data = key;
6848 ut_params->sess = rte_cryptodev_sym_session_create(
6849 ts_params->session_mpool);
6851 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6852 ut_params->sess, &ut_params->auth_xform,
6853 ts_params->session_priv_mpool);
6855 if (ut_params->sess == NULL)
6858 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6860 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6861 rte_pktmbuf_tailroom(ut_params->ibuf));
6866 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6867 const struct HMAC_MD5_vector *test_case,
6868 uint8_t **plaintext)
6870 uint16_t plaintext_pad_len;
6872 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6874 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6877 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6879 memcpy(*plaintext, test_case->plaintext.data,
6880 test_case->plaintext.len);
6882 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6883 ut_params->ibuf, MD5_DIGEST_LEN);
6884 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6885 "no room to append digest");
6886 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6887 ut_params->ibuf, plaintext_pad_len);
6889 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6890 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6891 test_case->auth_tag.len);
6894 sym_op->auth.data.offset = 0;
6895 sym_op->auth.data.length = test_case->plaintext.len;
6897 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6898 ut_params->op->sym->m_src = ut_params->ibuf;
6904 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6906 uint16_t plaintext_pad_len;
6907 uint8_t *plaintext, *auth_tag;
6909 struct crypto_testsuite_params *ts_params = &testsuite_params;
6910 struct crypto_unittest_params *ut_params = &unittest_params;
6912 if (MD5_HMAC_create_session(ts_params, ut_params,
6913 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6916 /* Generate Crypto op data structure */
6917 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6918 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6919 TEST_ASSERT_NOT_NULL(ut_params->op,
6920 "Failed to allocate symmetric crypto operation struct");
6922 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6925 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6928 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6929 ut_params->op), "failed to process sym crypto op");
6931 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6932 "crypto op processing failed");
6934 if (ut_params->op->sym->m_dst) {
6935 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6936 uint8_t *, plaintext_pad_len);
6938 auth_tag = plaintext + plaintext_pad_len;
6941 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6943 test_case->auth_tag.data,
6944 test_case->auth_tag.len,
6945 "HMAC_MD5 generated tag not as expected");
6947 return TEST_SUCCESS;
6951 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6955 struct crypto_testsuite_params *ts_params = &testsuite_params;
6956 struct crypto_unittest_params *ut_params = &unittest_params;
6958 if (MD5_HMAC_create_session(ts_params, ut_params,
6959 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6963 /* Generate Crypto op data structure */
6964 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6965 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6966 TEST_ASSERT_NOT_NULL(ut_params->op,
6967 "Failed to allocate symmetric crypto operation struct");
6969 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6972 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6973 ut_params->op), "failed to process sym crypto op");
6975 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6976 "HMAC_MD5 crypto op processing failed");
6978 return TEST_SUCCESS;
6982 test_MD5_HMAC_generate_case_1(void)
6984 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6988 test_MD5_HMAC_verify_case_1(void)
6990 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6994 test_MD5_HMAC_generate_case_2(void)
6996 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
7000 test_MD5_HMAC_verify_case_2(void)
7002 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
7006 test_multi_session(void)
7008 struct crypto_testsuite_params *ts_params = &testsuite_params;
7009 struct crypto_unittest_params *ut_params = &unittest_params;
7011 struct rte_cryptodev_info dev_info;
7012 struct rte_cryptodev_sym_session **sessions;
7016 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
7017 aes_cbc_key, hmac_sha512_key);
7020 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7022 sessions = rte_malloc(NULL,
7023 (sizeof(struct rte_cryptodev_sym_session *) *
7024 MAX_NB_SESSIONS) + 1, 0);
7026 /* Create multiple crypto sessions*/
7027 for (i = 0; i < MAX_NB_SESSIONS; i++) {
7029 sessions[i] = rte_cryptodev_sym_session_create(
7030 ts_params->session_mpool);
7032 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7033 sessions[i], &ut_params->auth_xform,
7034 ts_params->session_priv_mpool);
7035 TEST_ASSERT_NOT_NULL(sessions[i],
7036 "Session creation failed at session number %u",
7039 /* Attempt to send a request on each session */
7040 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
7044 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
7045 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
7047 "Failed to perform decrypt on request number %u.", i);
7048 /* free crypto operation structure */
7050 rte_crypto_op_free(ut_params->op);
7053 * free mbuf - both obuf and ibuf are usually the same,
7054 * so check if they point at the same address is necessary,
7055 * to avoid freeing the mbuf twice.
7057 if (ut_params->obuf) {
7058 rte_pktmbuf_free(ut_params->obuf);
7059 if (ut_params->ibuf == ut_params->obuf)
7060 ut_params->ibuf = 0;
7061 ut_params->obuf = 0;
7063 if (ut_params->ibuf) {
7064 rte_pktmbuf_free(ut_params->ibuf);
7065 ut_params->ibuf = 0;
7069 /* Next session create should fail */
7070 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7071 sessions[i], &ut_params->auth_xform,
7072 ts_params->session_priv_mpool);
7073 TEST_ASSERT_NULL(sessions[i],
7074 "Session creation succeeded unexpectedly!");
7076 for (i = 0; i < MAX_NB_SESSIONS; i++) {
7077 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
7079 rte_cryptodev_sym_session_free(sessions[i]);
7084 return TEST_SUCCESS;
7087 struct multi_session_params {
7088 struct crypto_unittest_params ut_params;
7089 uint8_t *cipher_key;
7091 const uint8_t *cipher;
7092 const uint8_t *digest;
7096 #define MB_SESSION_NUMBER 3
7099 test_multi_session_random_usage(void)
7101 struct crypto_testsuite_params *ts_params = &testsuite_params;
7102 struct rte_cryptodev_info dev_info;
7103 struct rte_cryptodev_sym_session **sessions;
7105 struct multi_session_params ut_paramz[] = {
7108 .cipher_key = ms_aes_cbc_key0,
7109 .hmac_key = ms_hmac_key0,
7110 .cipher = ms_aes_cbc_cipher0,
7111 .digest = ms_hmac_digest0,
7112 .iv = ms_aes_cbc_iv0
7115 .cipher_key = ms_aes_cbc_key1,
7116 .hmac_key = ms_hmac_key1,
7117 .cipher = ms_aes_cbc_cipher1,
7118 .digest = ms_hmac_digest1,
7119 .iv = ms_aes_cbc_iv1
7122 .cipher_key = ms_aes_cbc_key2,
7123 .hmac_key = ms_hmac_key2,
7124 .cipher = ms_aes_cbc_cipher2,
7125 .digest = ms_hmac_digest2,
7126 .iv = ms_aes_cbc_iv2
7131 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7133 sessions = rte_malloc(NULL,
7134 (sizeof(struct rte_cryptodev_sym_session *)
7135 * MAX_NB_SESSIONS) + 1, 0);
7137 for (i = 0; i < MB_SESSION_NUMBER; i++) {
7138 sessions[i] = rte_cryptodev_sym_session_create(
7139 ts_params->session_mpool);
7141 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
7142 sizeof(struct crypto_unittest_params));
7144 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
7145 &ut_paramz[i].ut_params,
7146 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
7148 /* Create multiple crypto sessions*/
7149 rte_cryptodev_sym_session_init(
7150 ts_params->valid_devs[0],
7152 &ut_paramz[i].ut_params.auth_xform,
7153 ts_params->session_priv_mpool);
7155 TEST_ASSERT_NOT_NULL(sessions[i],
7156 "Session creation failed at session number %u",
7162 for (i = 0; i < 40000; i++) {
7164 j = rand() % MB_SESSION_NUMBER;
7166 TEST_ASSERT_SUCCESS(
7167 test_AES_CBC_HMAC_SHA512_decrypt_perform(
7169 &ut_paramz[j].ut_params,
7170 ts_params, ut_paramz[j].cipher,
7171 ut_paramz[j].digest,
7173 "Failed to perform decrypt on request number %u.", i);
7175 if (ut_paramz[j].ut_params.op)
7176 rte_crypto_op_free(ut_paramz[j].ut_params.op);
7179 * free mbuf - both obuf and ibuf are usually the same,
7180 * so check if they point at the same address is necessary,
7181 * to avoid freeing the mbuf twice.
7183 if (ut_paramz[j].ut_params.obuf) {
7184 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
7185 if (ut_paramz[j].ut_params.ibuf
7186 == ut_paramz[j].ut_params.obuf)
7187 ut_paramz[j].ut_params.ibuf = 0;
7188 ut_paramz[j].ut_params.obuf = 0;
7190 if (ut_paramz[j].ut_params.ibuf) {
7191 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
7192 ut_paramz[j].ut_params.ibuf = 0;
7196 for (i = 0; i < MB_SESSION_NUMBER; i++) {
7197 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
7199 rte_cryptodev_sym_session_free(sessions[i]);
7204 return TEST_SUCCESS;
7208 test_null_cipher_only_operation(void)
7210 struct crypto_testsuite_params *ts_params = &testsuite_params;
7211 struct crypto_unittest_params *ut_params = &unittest_params;
7213 /* Generate test mbuf data and space for digest */
7214 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7215 catch_22_quote, QUOTE_512_BYTES, 0);
7217 /* Setup Cipher Parameters */
7218 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7219 ut_params->cipher_xform.next = NULL;
7221 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7222 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7224 ut_params->sess = rte_cryptodev_sym_session_create(
7225 ts_params->session_mpool);
7227 /* Create Crypto session*/
7228 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7230 &ut_params->cipher_xform,
7231 ts_params->session_priv_mpool);
7232 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7234 /* Generate Crypto op data structure */
7235 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7236 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7237 TEST_ASSERT_NOT_NULL(ut_params->op,
7238 "Failed to allocate symmetric crypto operation struct");
7240 /* Set crypto operation data parameters */
7241 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7243 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7245 /* set crypto operation source mbuf */
7246 sym_op->m_src = ut_params->ibuf;
7248 sym_op->cipher.data.offset = 0;
7249 sym_op->cipher.data.length = QUOTE_512_BYTES;
7251 /* Process crypto operation */
7252 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7254 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7256 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7257 "crypto operation processing failed");
7260 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7261 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7264 "Ciphertext data not as expected");
7266 return TEST_SUCCESS;
7268 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
7269 0xab, 0xab, 0xab, 0xab,
7270 0xab, 0xab, 0xab, 0xab,
7271 0xab, 0xab, 0xab, 0xab};
7273 test_null_auth_only_operation(void)
7275 struct crypto_testsuite_params *ts_params = &testsuite_params;
7276 struct crypto_unittest_params *ut_params = &unittest_params;
7279 /* Generate test mbuf data and space for digest */
7280 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7281 catch_22_quote, QUOTE_512_BYTES, 0);
7283 /* create a pointer for digest, but don't expect anything to be written
7284 * here in a NULL auth algo so no mbuf append done.
7286 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7288 /* prefill the memory pointed to by digest */
7289 memcpy(digest, orig_data, sizeof(orig_data));
7291 /* Setup HMAC Parameters */
7292 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7293 ut_params->auth_xform.next = NULL;
7295 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7296 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7298 ut_params->sess = rte_cryptodev_sym_session_create(
7299 ts_params->session_mpool);
7301 /* Create Crypto session*/
7302 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7303 ut_params->sess, &ut_params->auth_xform,
7304 ts_params->session_priv_mpool);
7305 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7307 /* Generate Crypto op data structure */
7308 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7309 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7310 TEST_ASSERT_NOT_NULL(ut_params->op,
7311 "Failed to allocate symmetric crypto operation struct");
7313 /* Set crypto operation data parameters */
7314 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7316 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7318 sym_op->m_src = ut_params->ibuf;
7320 sym_op->auth.data.offset = 0;
7321 sym_op->auth.data.length = QUOTE_512_BYTES;
7322 sym_op->auth.digest.data = digest;
7323 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7326 /* Process crypto operation */
7327 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7329 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7331 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7332 "crypto operation processing failed");
7333 /* Make sure memory pointed to by digest hasn't been overwritten */
7334 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7338 "Memory at digest ptr overwritten unexpectedly");
7340 return TEST_SUCCESS;
7345 test_null_cipher_auth_operation(void)
7347 struct crypto_testsuite_params *ts_params = &testsuite_params;
7348 struct crypto_unittest_params *ut_params = &unittest_params;
7351 /* Generate test mbuf data and space for digest */
7352 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7353 catch_22_quote, QUOTE_512_BYTES, 0);
7355 /* create a pointer for digest, but don't expect anything to be written
7356 * here in a NULL auth algo so no mbuf append done.
7358 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7360 /* prefill the memory pointed to by digest */
7361 memcpy(digest, orig_data, sizeof(orig_data));
7363 /* Setup Cipher Parameters */
7364 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7365 ut_params->cipher_xform.next = &ut_params->auth_xform;
7367 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7368 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7370 /* Setup HMAC Parameters */
7371 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7372 ut_params->auth_xform.next = NULL;
7374 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7375 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7377 ut_params->sess = rte_cryptodev_sym_session_create(
7378 ts_params->session_mpool);
7380 /* Create Crypto session*/
7381 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7382 ut_params->sess, &ut_params->cipher_xform,
7383 ts_params->session_priv_mpool);
7384 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7386 /* Generate Crypto op data structure */
7387 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7388 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7389 TEST_ASSERT_NOT_NULL(ut_params->op,
7390 "Failed to allocate symmetric crypto operation struct");
7392 /* Set crypto operation data parameters */
7393 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7395 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7397 sym_op->m_src = ut_params->ibuf;
7399 sym_op->cipher.data.offset = 0;
7400 sym_op->cipher.data.length = QUOTE_512_BYTES;
7402 sym_op->auth.data.offset = 0;
7403 sym_op->auth.data.length = QUOTE_512_BYTES;
7404 sym_op->auth.digest.data = digest;
7405 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7408 /* Process crypto operation */
7409 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7411 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7413 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7414 "crypto operation processing failed");
7417 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7418 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7421 "Ciphertext data not as expected");
7422 /* Make sure memory pointed to by digest hasn't been overwritten */
7423 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7427 "Memory at digest ptr overwritten unexpectedly");
7429 return TEST_SUCCESS;
7433 test_null_auth_cipher_operation(void)
7435 struct crypto_testsuite_params *ts_params = &testsuite_params;
7436 struct crypto_unittest_params *ut_params = &unittest_params;
7439 /* Generate test mbuf data */
7440 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7441 catch_22_quote, QUOTE_512_BYTES, 0);
7443 /* create a pointer for digest, but don't expect anything to be written
7444 * here in a NULL auth algo so no mbuf append done.
7446 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7448 /* prefill the memory pointed to by digest */
7449 memcpy(digest, orig_data, sizeof(orig_data));
7451 /* Setup Cipher Parameters */
7452 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7453 ut_params->cipher_xform.next = NULL;
7455 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7456 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7458 /* Setup HMAC Parameters */
7459 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7460 ut_params->auth_xform.next = &ut_params->cipher_xform;
7462 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7463 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7465 ut_params->sess = rte_cryptodev_sym_session_create(
7466 ts_params->session_mpool);
7468 /* Create Crypto session*/
7469 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7470 ut_params->sess, &ut_params->cipher_xform,
7471 ts_params->session_priv_mpool);
7472 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7474 /* Generate Crypto op data structure */
7475 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7476 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7477 TEST_ASSERT_NOT_NULL(ut_params->op,
7478 "Failed to allocate symmetric crypto operation struct");
7480 /* Set crypto operation data parameters */
7481 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7483 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7485 sym_op->m_src = ut_params->ibuf;
7487 sym_op->cipher.data.offset = 0;
7488 sym_op->cipher.data.length = QUOTE_512_BYTES;
7490 sym_op->auth.data.offset = 0;
7491 sym_op->auth.data.length = QUOTE_512_BYTES;
7492 sym_op->auth.digest.data = digest;
7493 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7496 /* Process crypto operation */
7497 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7499 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7501 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7502 "crypto operation processing failed");
7505 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7506 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7509 "Ciphertext data not as expected");
7510 /* Make sure memory pointed to by digest hasn't been overwritten */
7511 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7515 "Memory at digest ptr overwritten unexpectedly");
7517 return TEST_SUCCESS;
7522 test_null_invalid_operation(void)
7524 struct crypto_testsuite_params *ts_params = &testsuite_params;
7525 struct crypto_unittest_params *ut_params = &unittest_params;
7528 /* Setup Cipher Parameters */
7529 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7530 ut_params->cipher_xform.next = NULL;
7532 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7533 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7535 ut_params->sess = rte_cryptodev_sym_session_create(
7536 ts_params->session_mpool);
7538 /* Create Crypto session*/
7539 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7540 ut_params->sess, &ut_params->cipher_xform,
7541 ts_params->session_priv_mpool);
7542 TEST_ASSERT(ret < 0,
7543 "Session creation succeeded unexpectedly");
7546 /* Setup HMAC Parameters */
7547 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7548 ut_params->auth_xform.next = NULL;
7550 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7551 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7553 ut_params->sess = rte_cryptodev_sym_session_create(
7554 ts_params->session_mpool);
7556 /* Create Crypto session*/
7557 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7558 ut_params->sess, &ut_params->auth_xform,
7559 ts_params->session_priv_mpool);
7560 TEST_ASSERT(ret < 0,
7561 "Session creation succeeded unexpectedly");
7563 return TEST_SUCCESS;
7567 #define NULL_BURST_LENGTH (32)
7570 test_null_burst_operation(void)
7572 struct crypto_testsuite_params *ts_params = &testsuite_params;
7573 struct crypto_unittest_params *ut_params = &unittest_params;
7575 unsigned i, burst_len = NULL_BURST_LENGTH;
7577 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7578 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7580 /* Setup Cipher Parameters */
7581 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7582 ut_params->cipher_xform.next = &ut_params->auth_xform;
7584 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7585 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7587 /* Setup HMAC Parameters */
7588 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7589 ut_params->auth_xform.next = NULL;
7591 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7592 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7594 ut_params->sess = rte_cryptodev_sym_session_create(
7595 ts_params->session_mpool);
7597 /* Create Crypto session*/
7598 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7599 ut_params->sess, &ut_params->cipher_xform,
7600 ts_params->session_priv_mpool);
7601 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7603 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7604 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7605 burst_len, "failed to generate burst of crypto ops");
7607 /* Generate an operation for each mbuf in burst */
7608 for (i = 0; i < burst_len; i++) {
7609 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7611 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7613 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7617 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7619 burst[i]->sym->m_src = m;
7622 /* Process crypto operation */
7623 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7624 0, burst, burst_len),
7626 "Error enqueuing burst");
7628 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7629 0, burst_dequeued, burst_len),
7631 "Error dequeuing burst");
7634 for (i = 0; i < burst_len; i++) {
7636 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7637 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7639 "data not as expected");
7641 rte_pktmbuf_free(burst[i]->sym->m_src);
7642 rte_crypto_op_free(burst[i]);
7645 return TEST_SUCCESS;
7649 generate_gmac_large_plaintext(uint8_t *data)
7653 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7654 memcpy(&data[i], &data[0], 32);
7658 create_gmac_operation(enum rte_crypto_auth_operation op,
7659 const struct gmac_test_data *tdata)
7661 struct crypto_testsuite_params *ts_params = &testsuite_params;
7662 struct crypto_unittest_params *ut_params = &unittest_params;
7663 struct rte_crypto_sym_op *sym_op;
7665 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7667 /* Generate Crypto op data structure */
7668 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7669 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7670 TEST_ASSERT_NOT_NULL(ut_params->op,
7671 "Failed to allocate symmetric crypto operation struct");
7673 sym_op = ut_params->op->sym;
7675 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7676 ut_params->ibuf, tdata->gmac_tag.len);
7677 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7678 "no room to append digest");
7680 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7681 ut_params->ibuf, plaintext_pad_len);
7683 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7684 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7685 tdata->gmac_tag.len);
7686 debug_hexdump(stdout, "digest:",
7687 sym_op->auth.digest.data,
7688 tdata->gmac_tag.len);
7691 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7692 uint8_t *, IV_OFFSET);
7694 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7696 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7698 sym_op->cipher.data.length = 0;
7699 sym_op->cipher.data.offset = 0;
7701 sym_op->auth.data.offset = 0;
7702 sym_op->auth.data.length = tdata->plaintext.len;
7707 static int create_gmac_session(uint8_t dev_id,
7708 const struct gmac_test_data *tdata,
7709 enum rte_crypto_auth_operation auth_op)
7711 uint8_t auth_key[tdata->key.len];
7713 struct crypto_testsuite_params *ts_params = &testsuite_params;
7714 struct crypto_unittest_params *ut_params = &unittest_params;
7716 memcpy(auth_key, tdata->key.data, tdata->key.len);
7718 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7719 ut_params->auth_xform.next = NULL;
7721 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7722 ut_params->auth_xform.auth.op = auth_op;
7723 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7724 ut_params->auth_xform.auth.key.length = tdata->key.len;
7725 ut_params->auth_xform.auth.key.data = auth_key;
7726 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7727 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7730 ut_params->sess = rte_cryptodev_sym_session_create(
7731 ts_params->session_mpool);
7733 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7734 &ut_params->auth_xform,
7735 ts_params->session_priv_mpool);
7737 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7743 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7745 struct crypto_testsuite_params *ts_params = &testsuite_params;
7746 struct crypto_unittest_params *ut_params = &unittest_params;
7750 uint8_t *auth_tag, *plaintext;
7751 uint16_t plaintext_pad_len;
7753 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7754 "No GMAC length in the source data");
7756 retval = create_gmac_session(ts_params->valid_devs[0],
7757 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7762 if (tdata->plaintext.len > MBUF_SIZE)
7763 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7765 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7766 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7767 "Failed to allocate input buffer in mempool");
7769 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7770 rte_pktmbuf_tailroom(ut_params->ibuf));
7772 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7774 * Runtime generate the large plain text instead of use hard code
7775 * plain text vector. It is done to avoid create huge source file
7776 * with the test vector.
7778 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7779 generate_gmac_large_plaintext(tdata->plaintext.data);
7781 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7783 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7785 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7786 debug_hexdump(stdout, "plaintext:", plaintext,
7787 tdata->plaintext.len);
7789 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7795 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7797 ut_params->op->sym->m_src = ut_params->ibuf;
7799 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7800 ut_params->op), "failed to process sym crypto op");
7802 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7803 "crypto op processing failed");
7805 if (ut_params->op->sym->m_dst) {
7806 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7807 uint8_t *, plaintext_pad_len);
7809 auth_tag = plaintext + plaintext_pad_len;
7812 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7814 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7816 tdata->gmac_tag.data,
7817 tdata->gmac_tag.len,
7818 "GMAC Generated auth tag not as expected");
7824 test_AES_GMAC_authentication_test_case_1(void)
7826 return test_AES_GMAC_authentication(&gmac_test_case_1);
7830 test_AES_GMAC_authentication_test_case_2(void)
7832 return test_AES_GMAC_authentication(&gmac_test_case_2);
7836 test_AES_GMAC_authentication_test_case_3(void)
7838 return test_AES_GMAC_authentication(&gmac_test_case_3);
7842 test_AES_GMAC_authentication_test_case_4(void)
7844 return test_AES_GMAC_authentication(&gmac_test_case_4);
7848 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7850 struct crypto_testsuite_params *ts_params = &testsuite_params;
7851 struct crypto_unittest_params *ut_params = &unittest_params;
7853 uint32_t plaintext_pad_len;
7856 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7857 "No GMAC length in the source data");
7859 retval = create_gmac_session(ts_params->valid_devs[0],
7860 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7865 if (tdata->plaintext.len > MBUF_SIZE)
7866 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7868 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7869 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7870 "Failed to allocate input buffer in mempool");
7872 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7873 rte_pktmbuf_tailroom(ut_params->ibuf));
7875 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7878 * Runtime generate the large plain text instead of use hard code
7879 * plain text vector. It is done to avoid create huge source file
7880 * with the test vector.
7882 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7883 generate_gmac_large_plaintext(tdata->plaintext.data);
7885 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7887 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7889 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7890 debug_hexdump(stdout, "plaintext:", plaintext,
7891 tdata->plaintext.len);
7893 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7899 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7901 ut_params->op->sym->m_src = ut_params->ibuf;
7903 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7904 ut_params->op), "failed to process sym crypto op");
7906 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7907 "crypto op processing failed");
7914 test_AES_GMAC_authentication_verify_test_case_1(void)
7916 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7920 test_AES_GMAC_authentication_verify_test_case_2(void)
7922 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7926 test_AES_GMAC_authentication_verify_test_case_3(void)
7928 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7932 test_AES_GMAC_authentication_verify_test_case_4(void)
7934 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7937 struct test_crypto_vector {
7938 enum rte_crypto_cipher_algorithm crypto_algo;
7951 const uint8_t *data;
7956 const uint8_t *data;
7960 enum rte_crypto_auth_algorithm auth_algo;
7968 const uint8_t *data;
7978 static const struct test_crypto_vector
7979 hmac_sha1_test_crypto_vector = {
7980 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7982 .data = plaintext_hash,
7987 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7988 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7989 0xDE, 0xF4, 0xDE, 0xAD
7995 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7996 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7997 0x3F, 0x91, 0x64, 0x59
8003 static const struct test_crypto_vector
8004 aes128_gmac_test_vector = {
8005 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
8007 .data = plaintext_hash,
8012 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
8013 0x08, 0x09, 0x0A, 0x0B
8019 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
8020 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
8026 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
8027 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
8033 static const struct test_crypto_vector
8034 aes128cbc_hmac_sha1_test_vector = {
8035 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
8038 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
8039 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
8045 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
8046 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
8051 .data = plaintext_hash,
8055 .data = ciphertext512_aes128cbc,
8058 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
8061 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
8062 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
8063 0xDE, 0xF4, 0xDE, 0xAD
8069 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
8070 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
8071 0x18, 0x8C, 0x1D, 0x32
8078 data_corruption(uint8_t *data)
8084 tag_corruption(uint8_t *data, unsigned int tag_offset)
8086 data[tag_offset] += 1;
8090 create_auth_session(struct crypto_unittest_params *ut_params,
8092 const struct test_crypto_vector *reference,
8093 enum rte_crypto_auth_operation auth_op)
8095 struct crypto_testsuite_params *ts_params = &testsuite_params;
8096 uint8_t auth_key[reference->auth_key.len + 1];
8098 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
8100 /* Setup Authentication Parameters */
8101 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8102 ut_params->auth_xform.auth.op = auth_op;
8103 ut_params->auth_xform.next = NULL;
8104 ut_params->auth_xform.auth.algo = reference->auth_algo;
8105 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
8106 ut_params->auth_xform.auth.key.data = auth_key;
8107 ut_params->auth_xform.auth.digest_length = reference->digest.len;
8109 /* Create Crypto session*/
8110 ut_params->sess = rte_cryptodev_sym_session_create(
8111 ts_params->session_mpool);
8113 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8114 &ut_params->auth_xform,
8115 ts_params->session_priv_mpool);
8117 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8123 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
8125 const struct test_crypto_vector *reference,
8126 enum rte_crypto_auth_operation auth_op,
8127 enum rte_crypto_cipher_operation cipher_op)
8129 struct crypto_testsuite_params *ts_params = &testsuite_params;
8130 uint8_t cipher_key[reference->cipher_key.len + 1];
8131 uint8_t auth_key[reference->auth_key.len + 1];
8133 memcpy(cipher_key, reference->cipher_key.data,
8134 reference->cipher_key.len);
8135 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
8137 /* Setup Authentication Parameters */
8138 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8139 ut_params->auth_xform.auth.op = auth_op;
8140 ut_params->auth_xform.auth.algo = reference->auth_algo;
8141 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
8142 ut_params->auth_xform.auth.key.data = auth_key;
8143 ut_params->auth_xform.auth.digest_length = reference->digest.len;
8145 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
8146 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
8147 ut_params->auth_xform.auth.iv.length = reference->iv.len;
8149 ut_params->auth_xform.next = &ut_params->cipher_xform;
8151 /* Setup Cipher Parameters */
8152 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8153 ut_params->cipher_xform.next = NULL;
8154 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
8155 ut_params->cipher_xform.cipher.op = cipher_op;
8156 ut_params->cipher_xform.cipher.key.data = cipher_key;
8157 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
8158 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8159 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
8162 /* Create Crypto session*/
8163 ut_params->sess = rte_cryptodev_sym_session_create(
8164 ts_params->session_mpool);
8166 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8167 &ut_params->auth_xform,
8168 ts_params->session_priv_mpool);
8170 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8176 create_auth_operation(struct crypto_testsuite_params *ts_params,
8177 struct crypto_unittest_params *ut_params,
8178 const struct test_crypto_vector *reference,
8179 unsigned int auth_generate)
8181 /* Generate Crypto op data structure */
8182 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8183 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8184 TEST_ASSERT_NOT_NULL(ut_params->op,
8185 "Failed to allocate pktmbuf offload");
8187 /* Set crypto operation data parameters */
8188 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8190 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8192 /* set crypto operation source mbuf */
8193 sym_op->m_src = ut_params->ibuf;
8196 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8197 ut_params->ibuf, reference->digest.len);
8199 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8200 "no room to append auth tag");
8202 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8203 ut_params->ibuf, reference->plaintext.len);
8206 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8208 memcpy(sym_op->auth.digest.data,
8209 reference->digest.data,
8210 reference->digest.len);
8212 debug_hexdump(stdout, "digest:",
8213 sym_op->auth.digest.data,
8214 reference->digest.len);
8216 sym_op->auth.data.length = reference->plaintext.len;
8217 sym_op->auth.data.offset = 0;
8223 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
8224 struct crypto_unittest_params *ut_params,
8225 const struct test_crypto_vector *reference,
8226 unsigned int auth_generate)
8228 /* Generate Crypto op data structure */
8229 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8230 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8231 TEST_ASSERT_NOT_NULL(ut_params->op,
8232 "Failed to allocate pktmbuf offload");
8234 /* Set crypto operation data parameters */
8235 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8237 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8239 /* set crypto operation source mbuf */
8240 sym_op->m_src = ut_params->ibuf;
8243 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8244 ut_params->ibuf, reference->digest.len);
8246 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8247 "no room to append auth tag");
8249 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8250 ut_params->ibuf, reference->ciphertext.len);
8253 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8255 memcpy(sym_op->auth.digest.data,
8256 reference->digest.data,
8257 reference->digest.len);
8259 debug_hexdump(stdout, "digest:",
8260 sym_op->auth.digest.data,
8261 reference->digest.len);
8263 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8264 reference->iv.data, reference->iv.len);
8266 sym_op->cipher.data.length = 0;
8267 sym_op->cipher.data.offset = 0;
8269 sym_op->auth.data.length = reference->plaintext.len;
8270 sym_op->auth.data.offset = 0;
8276 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
8277 struct crypto_unittest_params *ut_params,
8278 const struct test_crypto_vector *reference,
8279 unsigned int auth_generate)
8281 /* Generate Crypto op data structure */
8282 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8283 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8284 TEST_ASSERT_NOT_NULL(ut_params->op,
8285 "Failed to allocate pktmbuf offload");
8287 /* Set crypto operation data parameters */
8288 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8290 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8292 /* set crypto operation source mbuf */
8293 sym_op->m_src = ut_params->ibuf;
8296 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8297 ut_params->ibuf, reference->digest.len);
8299 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8300 "no room to append auth tag");
8302 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8303 ut_params->ibuf, reference->ciphertext.len);
8306 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8308 memcpy(sym_op->auth.digest.data,
8309 reference->digest.data,
8310 reference->digest.len);
8312 debug_hexdump(stdout, "digest:",
8313 sym_op->auth.digest.data,
8314 reference->digest.len);
8316 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8317 reference->iv.data, reference->iv.len);
8319 sym_op->cipher.data.length = reference->ciphertext.len;
8320 sym_op->cipher.data.offset = 0;
8322 sym_op->auth.data.length = reference->ciphertext.len;
8323 sym_op->auth.data.offset = 0;
8329 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8330 struct crypto_unittest_params *ut_params,
8331 const struct test_crypto_vector *reference)
8333 return create_auth_operation(ts_params, ut_params, reference, 0);
8337 create_auth_verify_GMAC_operation(
8338 struct crypto_testsuite_params *ts_params,
8339 struct crypto_unittest_params *ut_params,
8340 const struct test_crypto_vector *reference)
8342 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8346 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8347 struct crypto_unittest_params *ut_params,
8348 const struct test_crypto_vector *reference)
8350 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8354 test_authentication_verify_fail_when_data_corruption(
8355 struct crypto_testsuite_params *ts_params,
8356 struct crypto_unittest_params *ut_params,
8357 const struct test_crypto_vector *reference,
8358 unsigned int data_corrupted)
8364 /* Create session */
8365 retval = create_auth_session(ut_params,
8366 ts_params->valid_devs[0],
8368 RTE_CRYPTO_AUTH_OP_VERIFY);
8372 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8373 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8374 "Failed to allocate input buffer in mempool");
8376 /* clear mbuf payload */
8377 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8378 rte_pktmbuf_tailroom(ut_params->ibuf));
8380 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8381 reference->plaintext.len);
8382 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8383 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8385 debug_hexdump(stdout, "plaintext:", plaintext,
8386 reference->plaintext.len);
8388 /* Create operation */
8389 retval = create_auth_verify_operation(ts_params, ut_params, reference);
8395 data_corruption(plaintext);
8397 tag_corruption(plaintext, reference->plaintext.len);
8399 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8401 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8402 TEST_ASSERT_EQUAL(ut_params->op->status,
8403 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8404 "authentication not failed");
8406 ut_params->obuf = ut_params->op->sym->m_src;
8407 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8413 test_authentication_verify_GMAC_fail_when_corruption(
8414 struct crypto_testsuite_params *ts_params,
8415 struct crypto_unittest_params *ut_params,
8416 const struct test_crypto_vector *reference,
8417 unsigned int data_corrupted)
8422 /* Create session */
8423 retval = create_auth_cipher_session(ut_params,
8424 ts_params->valid_devs[0],
8426 RTE_CRYPTO_AUTH_OP_VERIFY,
8427 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8431 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8432 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8433 "Failed to allocate input buffer in mempool");
8435 /* clear mbuf payload */
8436 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8437 rte_pktmbuf_tailroom(ut_params->ibuf));
8439 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8440 reference->plaintext.len);
8441 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8442 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8444 debug_hexdump(stdout, "plaintext:", plaintext,
8445 reference->plaintext.len);
8447 /* Create operation */
8448 retval = create_auth_verify_GMAC_operation(ts_params,
8456 data_corruption(plaintext);
8458 tag_corruption(plaintext, reference->aad.len);
8460 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8462 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8463 TEST_ASSERT_EQUAL(ut_params->op->status,
8464 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8465 "authentication not failed");
8467 ut_params->obuf = ut_params->op->sym->m_src;
8468 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8474 test_authenticated_decryption_fail_when_corruption(
8475 struct crypto_testsuite_params *ts_params,
8476 struct crypto_unittest_params *ut_params,
8477 const struct test_crypto_vector *reference,
8478 unsigned int data_corrupted)
8482 uint8_t *ciphertext;
8484 /* Create session */
8485 retval = create_auth_cipher_session(ut_params,
8486 ts_params->valid_devs[0],
8488 RTE_CRYPTO_AUTH_OP_VERIFY,
8489 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8493 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8494 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8495 "Failed to allocate input buffer in mempool");
8497 /* clear mbuf payload */
8498 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8499 rte_pktmbuf_tailroom(ut_params->ibuf));
8501 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8502 reference->ciphertext.len);
8503 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8504 memcpy(ciphertext, reference->ciphertext.data,
8505 reference->ciphertext.len);
8507 /* Create operation */
8508 retval = create_cipher_auth_verify_operation(ts_params,
8516 data_corruption(ciphertext);
8518 tag_corruption(ciphertext, reference->ciphertext.len);
8520 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8523 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8524 TEST_ASSERT_EQUAL(ut_params->op->status,
8525 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8526 "authentication not failed");
8528 ut_params->obuf = ut_params->op->sym->m_src;
8529 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8535 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8536 const struct aead_test_data *tdata,
8537 void *digest_mem, uint64_t digest_phys)
8539 struct crypto_testsuite_params *ts_params = &testsuite_params;
8540 struct crypto_unittest_params *ut_params = &unittest_params;
8542 const unsigned int auth_tag_len = tdata->auth_tag.len;
8543 const unsigned int iv_len = tdata->iv.len;
8544 unsigned int aad_len = tdata->aad.len;
8546 /* Generate Crypto op data structure */
8547 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8548 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8549 TEST_ASSERT_NOT_NULL(ut_params->op,
8550 "Failed to allocate symmetric crypto operation struct");
8552 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8554 sym_op->aead.digest.data = digest_mem;
8556 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8557 "no room to append digest");
8559 sym_op->aead.digest.phys_addr = digest_phys;
8561 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8562 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8564 debug_hexdump(stdout, "digest:",
8565 sym_op->aead.digest.data,
8569 /* Append aad data */
8570 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8571 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8572 uint8_t *, IV_OFFSET);
8574 /* Copy IV 1 byte after the IV pointer, according to the API */
8575 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8577 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8579 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8580 ut_params->ibuf, aad_len);
8581 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8582 "no room to prepend aad");
8583 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8586 memset(sym_op->aead.aad.data, 0, aad_len);
8587 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8588 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8590 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8591 debug_hexdump(stdout, "aad:",
8592 sym_op->aead.aad.data, aad_len);
8594 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8595 uint8_t *, IV_OFFSET);
8597 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8599 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8600 ut_params->ibuf, aad_len);
8601 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8602 "no room to prepend aad");
8603 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8606 memset(sym_op->aead.aad.data, 0, aad_len);
8607 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8609 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8610 debug_hexdump(stdout, "aad:",
8611 sym_op->aead.aad.data, aad_len);
8614 sym_op->aead.data.length = tdata->plaintext.len;
8615 sym_op->aead.data.offset = aad_len;
8620 #define SGL_MAX_NO 16
8623 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8624 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8626 struct crypto_testsuite_params *ts_params = &testsuite_params;
8627 struct crypto_unittest_params *ut_params = &unittest_params;
8628 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8631 int to_trn_tbl[SGL_MAX_NO];
8633 unsigned int trn_data = 0;
8634 uint8_t *plaintext, *ciphertext, *auth_tag;
8636 if (fragsz > tdata->plaintext.len)
8637 fragsz = tdata->plaintext.len;
8639 uint16_t plaintext_len = fragsz;
8640 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8642 if (fragsz_oop > tdata->plaintext.len)
8643 frag_size_oop = tdata->plaintext.len;
8646 void *digest_mem = NULL;
8648 uint32_t prepend_len = tdata->aad.len;
8650 if (tdata->plaintext.len % fragsz != 0) {
8651 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8654 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8659 * For out-op-place we need to alloc another mbuf
8662 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8663 rte_pktmbuf_append(ut_params->obuf,
8664 frag_size_oop + prepend_len);
8665 buf_oop = ut_params->obuf;
8668 /* Create AEAD session */
8669 retval = create_aead_session(ts_params->valid_devs[0],
8671 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8672 tdata->key.data, tdata->key.len,
8673 tdata->aad.len, tdata->auth_tag.len,
8678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8680 /* clear mbuf payload */
8681 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8682 rte_pktmbuf_tailroom(ut_params->ibuf));
8684 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8687 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8689 trn_data += plaintext_len;
8691 buf = ut_params->ibuf;
8694 * Loop until no more fragments
8697 while (trn_data < tdata->plaintext.len) {
8699 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8700 (tdata->plaintext.len - trn_data) : fragsz;
8702 to_trn_tbl[ecx++] = to_trn;
8704 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8707 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8708 rte_pktmbuf_tailroom(buf));
8711 if (oop && !fragsz_oop) {
8712 buf_last_oop = buf_oop->next =
8713 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8714 buf_oop = buf_oop->next;
8715 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8716 0, rte_pktmbuf_tailroom(buf_oop));
8717 rte_pktmbuf_append(buf_oop, to_trn);
8720 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8723 memcpy(plaintext, tdata->plaintext.data + trn_data,
8726 if (trn_data == tdata->plaintext.len) {
8729 digest_mem = rte_pktmbuf_append(buf_oop,
8730 tdata->auth_tag.len);
8732 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8733 tdata->auth_tag.len);
8737 uint64_t digest_phys = 0;
8739 ut_params->ibuf->nb_segs = segs;
8742 if (fragsz_oop && oop) {
8746 if (frag_size_oop == tdata->plaintext.len) {
8747 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8748 tdata->auth_tag.len);
8750 digest_phys = rte_pktmbuf_iova_offset(
8752 tdata->plaintext.len + prepend_len);
8755 trn_data = frag_size_oop;
8756 while (trn_data < tdata->plaintext.len) {
8759 (tdata->plaintext.len - trn_data <
8761 (tdata->plaintext.len - trn_data) :
8764 to_trn_tbl[ecx++] = to_trn;
8766 buf_last_oop = buf_oop->next =
8767 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8768 buf_oop = buf_oop->next;
8769 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8770 0, rte_pktmbuf_tailroom(buf_oop));
8771 rte_pktmbuf_append(buf_oop, to_trn);
8775 if (trn_data == tdata->plaintext.len) {
8776 digest_mem = rte_pktmbuf_append(buf_oop,
8777 tdata->auth_tag.len);
8781 ut_params->obuf->nb_segs = segs;
8785 * Place digest at the end of the last buffer
8788 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8789 if (oop && buf_last_oop)
8790 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8792 if (!digest_mem && !oop) {
8793 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8794 + tdata->auth_tag.len);
8795 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8796 tdata->plaintext.len);
8799 /* Create AEAD operation */
8800 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8801 tdata, digest_mem, digest_phys);
8806 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8808 ut_params->op->sym->m_src = ut_params->ibuf;
8810 ut_params->op->sym->m_dst = ut_params->obuf;
8812 /* Process crypto operation */
8813 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8814 ut_params->op), "failed to process sym crypto op");
8816 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8817 "crypto op processing failed");
8820 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8821 uint8_t *, prepend_len);
8823 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8824 uint8_t *, prepend_len);
8828 fragsz = fragsz_oop;
8830 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8832 tdata->ciphertext.data,
8834 "Ciphertext data not as expected");
8836 buf = ut_params->op->sym->m_src->next;
8838 buf = ut_params->op->sym->m_dst->next;
8840 unsigned int off = fragsz;
8844 ciphertext = rte_pktmbuf_mtod(buf,
8847 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8849 tdata->ciphertext.data + off,
8851 "Ciphertext data not as expected");
8853 off += to_trn_tbl[ecx++];
8857 auth_tag = digest_mem;
8858 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8860 tdata->auth_tag.data,
8861 tdata->auth_tag.len,
8862 "Generated auth tag not as expected");
8868 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8870 return test_authenticated_encryption_SGL(
8871 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8875 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8877 return test_authenticated_encryption_SGL(
8878 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8882 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8884 return test_authenticated_encryption_SGL(
8885 &gcm_test_case_8, OUT_OF_PLACE, 400,
8886 gcm_test_case_8.plaintext.len);
8890 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8893 return test_authenticated_encryption_SGL(
8894 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8898 test_authentication_verify_fail_when_data_corrupted(
8899 struct crypto_testsuite_params *ts_params,
8900 struct crypto_unittest_params *ut_params,
8901 const struct test_crypto_vector *reference)
8903 return test_authentication_verify_fail_when_data_corruption(
8904 ts_params, ut_params, reference, 1);
8908 test_authentication_verify_fail_when_tag_corrupted(
8909 struct crypto_testsuite_params *ts_params,
8910 struct crypto_unittest_params *ut_params,
8911 const struct test_crypto_vector *reference)
8913 return test_authentication_verify_fail_when_data_corruption(
8914 ts_params, ut_params, reference, 0);
8918 test_authentication_verify_GMAC_fail_when_data_corrupted(
8919 struct crypto_testsuite_params *ts_params,
8920 struct crypto_unittest_params *ut_params,
8921 const struct test_crypto_vector *reference)
8923 return test_authentication_verify_GMAC_fail_when_corruption(
8924 ts_params, ut_params, reference, 1);
8928 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8929 struct crypto_testsuite_params *ts_params,
8930 struct crypto_unittest_params *ut_params,
8931 const struct test_crypto_vector *reference)
8933 return test_authentication_verify_GMAC_fail_when_corruption(
8934 ts_params, ut_params, reference, 0);
8938 test_authenticated_decryption_fail_when_data_corrupted(
8939 struct crypto_testsuite_params *ts_params,
8940 struct crypto_unittest_params *ut_params,
8941 const struct test_crypto_vector *reference)
8943 return test_authenticated_decryption_fail_when_corruption(
8944 ts_params, ut_params, reference, 1);
8948 test_authenticated_decryption_fail_when_tag_corrupted(
8949 struct crypto_testsuite_params *ts_params,
8950 struct crypto_unittest_params *ut_params,
8951 const struct test_crypto_vector *reference)
8953 return test_authenticated_decryption_fail_when_corruption(
8954 ts_params, ut_params, reference, 0);
8958 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8960 return test_authentication_verify_fail_when_data_corrupted(
8961 &testsuite_params, &unittest_params,
8962 &hmac_sha1_test_crypto_vector);
8966 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8968 return test_authentication_verify_fail_when_tag_corrupted(
8969 &testsuite_params, &unittest_params,
8970 &hmac_sha1_test_crypto_vector);
8974 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8976 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8977 &testsuite_params, &unittest_params,
8978 &aes128_gmac_test_vector);
8982 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8984 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8985 &testsuite_params, &unittest_params,
8986 &aes128_gmac_test_vector);
8990 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8992 return test_authenticated_decryption_fail_when_data_corrupted(
8995 &aes128cbc_hmac_sha1_test_vector);
8999 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
9001 return test_authenticated_decryption_fail_when_tag_corrupted(
9004 &aes128cbc_hmac_sha1_test_vector);
9007 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9009 /* global AESNI slave IDs for the scheduler test */
9010 uint8_t aesni_ids[2];
9013 test_scheduler_attach_slave_op(void)
9015 struct crypto_testsuite_params *ts_params = &testsuite_params;
9016 uint8_t sched_id = ts_params->valid_devs[0];
9017 uint32_t nb_devs, i, nb_devs_attached = 0;
9021 /* create 2 AESNI_MB if necessary */
9022 nb_devs = rte_cryptodev_device_count_by_driver(
9023 rte_cryptodev_driver_id_get(
9024 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
9026 for (i = nb_devs; i < 2; i++) {
9027 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
9028 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
9030 ret = rte_vdev_init(vdev_name, NULL);
9032 TEST_ASSERT(ret == 0,
9033 "Failed to create instance %u of"
9035 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9039 /* attach 2 AESNI_MB cdevs */
9040 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
9042 struct rte_cryptodev_info info;
9043 unsigned int session_size;
9045 rte_cryptodev_info_get(i, &info);
9046 if (info.driver_id != rte_cryptodev_driver_id_get(
9047 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
9050 session_size = rte_cryptodev_sym_get_private_session_size(i);
9052 * Create the session mempool again, since now there are new devices
9053 * to use the mempool.
9055 if (ts_params->session_mpool) {
9056 rte_mempool_free(ts_params->session_mpool);
9057 ts_params->session_mpool = NULL;
9059 if (ts_params->session_priv_mpool) {
9060 rte_mempool_free(ts_params->session_priv_mpool);
9061 ts_params->session_priv_mpool = NULL;
9064 if (info.sym.max_nb_sessions != 0 &&
9065 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
9067 "Device does not support "
9068 "at least %u sessions\n",
9073 * Create mempool with maximum number of sessions,
9074 * to include the session headers
9076 if (ts_params->session_mpool == NULL) {
9077 ts_params->session_mpool =
9078 rte_cryptodev_sym_session_pool_create(
9080 MAX_NB_SESSIONS, 0, 0, 0,
9082 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
9083 "session mempool allocation failed");
9087 * Create mempool with maximum number of sessions,
9088 * to include device specific session private data
9090 if (ts_params->session_priv_mpool == NULL) {
9091 ts_params->session_priv_mpool = rte_mempool_create(
9092 "test_sess_mp_priv",
9095 0, 0, NULL, NULL, NULL,
9096 NULL, SOCKET_ID_ANY,
9099 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
9100 "session mempool allocation failed");
9103 ts_params->qp_conf.mp_session = ts_params->session_mpool;
9104 ts_params->qp_conf.mp_session_private =
9105 ts_params->session_priv_mpool;
9107 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
9110 TEST_ASSERT(ret == 0,
9111 "Failed to attach device %u of pmd : %s", i,
9112 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9114 aesni_ids[nb_devs_attached] = (uint8_t)i;
9123 test_scheduler_detach_slave_op(void)
9125 struct crypto_testsuite_params *ts_params = &testsuite_params;
9126 uint8_t sched_id = ts_params->valid_devs[0];
9130 for (i = 0; i < 2; i++) {
9131 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
9133 TEST_ASSERT(ret == 0,
9134 "Failed to detach device %u", aesni_ids[i]);
9141 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
9143 struct crypto_testsuite_params *ts_params = &testsuite_params;
9144 uint8_t sched_id = ts_params->valid_devs[0];
9146 return rte_cryptodev_scheduler_mode_set(sched_id,
9151 test_scheduler_mode_roundrobin_op(void)
9153 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
9154 0, "Failed to set roundrobin mode");
9160 test_scheduler_mode_multicore_op(void)
9162 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
9163 0, "Failed to set multicore mode");
9169 test_scheduler_mode_failover_op(void)
9171 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
9172 0, "Failed to set failover mode");
9178 test_scheduler_mode_pkt_size_distr_op(void)
9180 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
9181 0, "Failed to set pktsize mode");
9186 static struct unit_test_suite cryptodev_scheduler_testsuite = {
9187 .suite_name = "Crypto Device Scheduler Unit Test Suite",
9188 .setup = testsuite_setup,
9189 .teardown = testsuite_teardown,
9190 .unit_test_cases = {
9192 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9193 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 test_AES_chain_scheduler_all),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_AES_cipheronly_scheduler_all),
9198 TEST_CASE_ST(ut_setup, ut_teardown,
9199 test_authonly_scheduler_all),
9200 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9203 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9204 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_AES_chain_scheduler_all),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_AES_cipheronly_scheduler_all),
9209 TEST_CASE_ST(ut_setup, ut_teardown,
9210 test_authonly_scheduler_all),
9211 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9214 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9215 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
9216 TEST_CASE_ST(ut_setup, ut_teardown,
9217 test_AES_chain_scheduler_all),
9218 TEST_CASE_ST(ut_setup, ut_teardown,
9219 test_AES_cipheronly_scheduler_all),
9220 TEST_CASE_ST(ut_setup, ut_teardown,
9221 test_authonly_scheduler_all),
9222 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9225 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9226 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
9227 TEST_CASE_ST(ut_setup, ut_teardown,
9228 test_AES_chain_scheduler_all),
9229 TEST_CASE_ST(ut_setup, ut_teardown,
9230 test_AES_cipheronly_scheduler_all),
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_authonly_scheduler_all),
9233 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9235 TEST_CASES_END() /**< NULL terminate unit test array */
9239 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
9241 static struct unit_test_suite cryptodev_qat_testsuite = {
9242 .suite_name = "Crypto QAT Unit Test Suite",
9243 .setup = testsuite_setup,
9244 .teardown = testsuite_teardown,
9245 .unit_test_cases = {
9246 TEST_CASE_ST(ut_setup, ut_teardown,
9247 test_device_configure_invalid_dev_id),
9248 TEST_CASE_ST(ut_setup, ut_teardown,
9249 test_device_configure_invalid_queue_pair_ids),
9250 TEST_CASE_ST(ut_setup, ut_teardown,
9251 test_queue_pair_descriptor_setup),
9252 TEST_CASE_ST(ut_setup, ut_teardown,
9253 test_multi_session),
9255 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
9256 TEST_CASE_ST(ut_setup, ut_teardown,
9257 test_AES_cipheronly_qat_all),
9258 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
9259 TEST_CASE_ST(ut_setup, ut_teardown,
9260 test_3DES_cipheronly_qat_all),
9261 TEST_CASE_ST(ut_setup, ut_teardown,
9262 test_DES_cipheronly_qat_all),
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 test_AES_docsis_qat_all),
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_DES_docsis_qat_all),
9267 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
9268 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
9270 /** AES CCM Authenticated Encryption 128 bits key */
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_AES_CCM_authenticated_encryption_test_case_128_1),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_AES_CCM_authenticated_encryption_test_case_128_2),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_AES_CCM_authenticated_encryption_test_case_128_3),
9278 /** AES CCM Authenticated Decryption 128 bits key*/
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_AES_CCM_authenticated_decryption_test_case_128_1),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_AES_CCM_authenticated_decryption_test_case_128_2),
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_AES_CCM_authenticated_decryption_test_case_128_3),
9286 /** AES GCM Authenticated Encryption */
9287 TEST_CASE_ST(ut_setup, ut_teardown,
9288 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9289 TEST_CASE_ST(ut_setup, ut_teardown,
9290 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9291 TEST_CASE_ST(ut_setup, ut_teardown,
9292 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9293 TEST_CASE_ST(ut_setup, ut_teardown,
9294 test_AES_GCM_authenticated_encryption_test_case_1),
9295 TEST_CASE_ST(ut_setup, ut_teardown,
9296 test_AES_GCM_authenticated_encryption_test_case_2),
9297 TEST_CASE_ST(ut_setup, ut_teardown,
9298 test_AES_GCM_authenticated_encryption_test_case_3),
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_AES_GCM_authenticated_encryption_test_case_4),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_AES_GCM_authenticated_encryption_test_case_5),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_AES_GCM_authenticated_encryption_test_case_6),
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_AES_GCM_authenticated_encryption_test_case_7),
9308 /** AES GCM Authenticated Decryption */
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_AES_GCM_authenticated_decryption_test_case_1),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_AES_GCM_authenticated_decryption_test_case_2),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_AES_GCM_authenticated_decryption_test_case_3),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_AES_GCM_authenticated_decryption_test_case_4),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_AES_GCM_authenticated_decryption_test_case_5),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_AES_GCM_authenticated_decryption_test_case_6),
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_AES_GCM_authenticated_decryption_test_case_7),
9324 /** AES GCM Authenticated Encryption 192 bits key */
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_AES_GCM_auth_encryption_test_case_192_1),
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_AES_GCM_auth_encryption_test_case_192_2),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_AES_GCM_auth_encryption_test_case_192_3),
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_AES_GCM_auth_encryption_test_case_192_4),
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_AES_GCM_auth_encryption_test_case_192_5),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_AES_GCM_auth_encryption_test_case_192_6),
9337 TEST_CASE_ST(ut_setup, ut_teardown,
9338 test_AES_GCM_auth_encryption_test_case_192_7),
9340 /** AES GCM Authenticated Decryption 192 bits key */
9341 TEST_CASE_ST(ut_setup, ut_teardown,
9342 test_AES_GCM_auth_decryption_test_case_192_1),
9343 TEST_CASE_ST(ut_setup, ut_teardown,
9344 test_AES_GCM_auth_decryption_test_case_192_2),
9345 TEST_CASE_ST(ut_setup, ut_teardown,
9346 test_AES_GCM_auth_decryption_test_case_192_3),
9347 TEST_CASE_ST(ut_setup, ut_teardown,
9348 test_AES_GCM_auth_decryption_test_case_192_4),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_AES_GCM_auth_decryption_test_case_192_5),
9351 TEST_CASE_ST(ut_setup, ut_teardown,
9352 test_AES_GCM_auth_decryption_test_case_192_6),
9353 TEST_CASE_ST(ut_setup, ut_teardown,
9354 test_AES_GCM_auth_decryption_test_case_192_7),
9356 /** AES GCM Authenticated Encryption 256 bits key */
9357 TEST_CASE_ST(ut_setup, ut_teardown,
9358 test_AES_GCM_auth_encryption_test_case_256_1),
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 test_AES_GCM_auth_encryption_test_case_256_2),
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_AES_GCM_auth_encryption_test_case_256_3),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_AES_GCM_auth_encryption_test_case_256_4),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 test_AES_GCM_auth_encryption_test_case_256_5),
9367 TEST_CASE_ST(ut_setup, ut_teardown,
9368 test_AES_GCM_auth_encryption_test_case_256_6),
9369 TEST_CASE_ST(ut_setup, ut_teardown,
9370 test_AES_GCM_auth_encryption_test_case_256_7),
9372 /** AES GMAC Authentication */
9373 TEST_CASE_ST(ut_setup, ut_teardown,
9374 test_AES_GMAC_authentication_test_case_1),
9375 TEST_CASE_ST(ut_setup, ut_teardown,
9376 test_AES_GMAC_authentication_verify_test_case_1),
9377 TEST_CASE_ST(ut_setup, ut_teardown,
9378 test_AES_GMAC_authentication_test_case_2),
9379 TEST_CASE_ST(ut_setup, ut_teardown,
9380 test_AES_GMAC_authentication_verify_test_case_2),
9381 TEST_CASE_ST(ut_setup, ut_teardown,
9382 test_AES_GMAC_authentication_test_case_3),
9383 TEST_CASE_ST(ut_setup, ut_teardown,
9384 test_AES_GMAC_authentication_verify_test_case_3),
9386 /** SNOW 3G encrypt only (UEA2) */
9387 TEST_CASE_ST(ut_setup, ut_teardown,
9388 test_snow3g_encryption_test_case_1),
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_snow3g_encryption_test_case_2),
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_snow3g_encryption_test_case_3),
9393 TEST_CASE_ST(ut_setup, ut_teardown,
9394 test_snow3g_encryption_test_case_4),
9395 TEST_CASE_ST(ut_setup, ut_teardown,
9396 test_snow3g_encryption_test_case_5),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_snow3g_encryption_test_case_1_oop),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_snow3g_decryption_test_case_1_oop),
9403 /** SNOW 3G generate auth, then encrypt (UEA2) */
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_snow3g_auth_cipher_test_case_1),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_snow3g_auth_cipher_test_case_2),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_snow3g_auth_cipher_test_case_2_oop),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_snow3g_auth_cipher_part_digest_enc),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_snow3g_auth_cipher_part_digest_enc_oop),
9415 /** SNOW 3G decrypt (UEA2), then verify auth */
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_snow3g_auth_cipher_verify_test_case_1),
9418 TEST_CASE_ST(ut_setup, ut_teardown,
9419 test_snow3g_auth_cipher_verify_test_case_2),
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_snow3g_auth_cipher_verify_test_case_2_oop),
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_snow3g_auth_cipher_verify_part_digest_enc),
9424 TEST_CASE_ST(ut_setup, ut_teardown,
9425 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
9427 /** SNOW 3G decrypt only (UEA2) */
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_snow3g_decryption_test_case_1),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_snow3g_decryption_test_case_2),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_snow3g_decryption_test_case_3),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_snow3g_decryption_test_case_4),
9436 TEST_CASE_ST(ut_setup, ut_teardown,
9437 test_snow3g_decryption_test_case_5),
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_snow3g_decryption_with_digest_test_case_1),
9440 TEST_CASE_ST(ut_setup, ut_teardown,
9441 test_snow3g_hash_generate_test_case_1),
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_snow3g_hash_generate_test_case_2),
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_snow3g_hash_generate_test_case_3),
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_snow3g_hash_verify_test_case_1),
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_snow3g_hash_verify_test_case_2),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_snow3g_hash_verify_test_case_3),
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_snow3g_cipher_auth_test_case_1),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_snow3g_auth_cipher_with_digest_test_case_1),
9457 /** ZUC encrypt only (EEA3) */
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_zuc_encryption_test_case_1),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_zuc_encryption_test_case_2),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_zuc_encryption_test_case_3),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_zuc_encryption_test_case_4),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_zuc_encryption_test_case_5),
9469 /** ZUC authenticate (EIA3) */
9470 TEST_CASE_ST(ut_setup, ut_teardown,
9471 test_zuc_hash_generate_test_case_6),
9472 TEST_CASE_ST(ut_setup, ut_teardown,
9473 test_zuc_hash_generate_test_case_7),
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_zuc_hash_generate_test_case_8),
9477 /** ZUC alg-chain (EEA3/EIA3) */
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_zuc_cipher_auth_test_case_1),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_zuc_cipher_auth_test_case_2),
9483 /** HMAC_MD5 Authentication */
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_MD5_HMAC_generate_case_1),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_MD5_HMAC_verify_case_1),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_MD5_HMAC_generate_case_2),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_MD5_HMAC_verify_case_2),
9493 /** NULL algo tests done in chain_all,
9494 * cipheronly and authonly suites
9498 TEST_CASE_ST(ut_setup, ut_teardown,
9499 test_kasumi_hash_generate_test_case_1),
9500 TEST_CASE_ST(ut_setup, ut_teardown,
9501 test_kasumi_hash_generate_test_case_2),
9502 TEST_CASE_ST(ut_setup, ut_teardown,
9503 test_kasumi_hash_generate_test_case_3),
9504 TEST_CASE_ST(ut_setup, ut_teardown,
9505 test_kasumi_hash_generate_test_case_4),
9506 TEST_CASE_ST(ut_setup, ut_teardown,
9507 test_kasumi_hash_generate_test_case_5),
9508 TEST_CASE_ST(ut_setup, ut_teardown,
9509 test_kasumi_hash_generate_test_case_6),
9511 TEST_CASE_ST(ut_setup, ut_teardown,
9512 test_kasumi_hash_verify_test_case_1),
9513 TEST_CASE_ST(ut_setup, ut_teardown,
9514 test_kasumi_hash_verify_test_case_2),
9515 TEST_CASE_ST(ut_setup, ut_teardown,
9516 test_kasumi_hash_verify_test_case_3),
9517 TEST_CASE_ST(ut_setup, ut_teardown,
9518 test_kasumi_hash_verify_test_case_4),
9519 TEST_CASE_ST(ut_setup, ut_teardown,
9520 test_kasumi_hash_verify_test_case_5),
9522 TEST_CASE_ST(ut_setup, ut_teardown,
9523 test_kasumi_encryption_test_case_1),
9524 TEST_CASE_ST(ut_setup, ut_teardown,
9525 test_kasumi_encryption_test_case_3),
9526 TEST_CASE_ST(ut_setup, ut_teardown,
9527 test_kasumi_auth_cipher_test_case_1),
9528 TEST_CASE_ST(ut_setup, ut_teardown,
9529 test_kasumi_cipher_auth_test_case_1),
9531 /** Negative tests */
9532 TEST_CASE_ST(ut_setup, ut_teardown,
9533 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9534 TEST_CASE_ST(ut_setup, ut_teardown,
9535 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9536 TEST_CASE_ST(ut_setup, ut_teardown,
9537 authentication_verify_AES128_GMAC_fail_data_corrupt),
9538 TEST_CASE_ST(ut_setup, ut_teardown,
9539 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9540 TEST_CASE_ST(ut_setup, ut_teardown,
9541 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9542 TEST_CASE_ST(ut_setup, ut_teardown,
9543 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9545 TEST_CASES_END() /**< NULL terminate unit test array */
9549 static struct unit_test_suite cryptodev_virtio_testsuite = {
9550 .suite_name = "Crypto VIRTIO Unit Test Suite",
9551 .setup = testsuite_setup,
9552 .teardown = testsuite_teardown,
9553 .unit_test_cases = {
9554 TEST_CASE_ST(ut_setup, ut_teardown,
9555 test_AES_cipheronly_virtio_all),
9557 TEST_CASES_END() /**< NULL terminate unit test array */
9561 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9562 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9563 .setup = testsuite_setup,
9564 .teardown = testsuite_teardown,
9565 .unit_test_cases = {
9566 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
9567 TEST_CASE_ST(ut_setup, ut_teardown,
9568 test_AES_GCM_authenticated_encryption_test_case_1),
9569 TEST_CASE_ST(ut_setup, ut_teardown,
9570 test_AES_GCM_authenticated_encryption_test_case_2),
9571 TEST_CASE_ST(ut_setup, ut_teardown,
9572 test_AES_GCM_authenticated_encryption_test_case_3),
9573 TEST_CASE_ST(ut_setup, ut_teardown,
9574 test_AES_GCM_authenticated_encryption_test_case_4),
9575 TEST_CASE_ST(ut_setup, ut_teardown,
9576 test_AES_GCM_authenticated_encryption_test_case_5),
9577 TEST_CASE_ST(ut_setup, ut_teardown,
9578 test_AES_GCM_authenticated_encryption_test_case_6),
9579 TEST_CASE_ST(ut_setup, ut_teardown,
9580 test_AES_GCM_authenticated_encryption_test_case_7),
9582 /** AES GCM Authenticated Decryption */
9583 TEST_CASE_ST(ut_setup, ut_teardown,
9584 test_AES_GCM_authenticated_decryption_test_case_1),
9585 TEST_CASE_ST(ut_setup, ut_teardown,
9586 test_AES_GCM_authenticated_decryption_test_case_2),
9587 TEST_CASE_ST(ut_setup, ut_teardown,
9588 test_AES_GCM_authenticated_decryption_test_case_3),
9589 TEST_CASE_ST(ut_setup, ut_teardown,
9590 test_AES_GCM_authenticated_decryption_test_case_4),
9591 TEST_CASE_ST(ut_setup, ut_teardown,
9592 test_AES_GCM_authenticated_decryption_test_case_5),
9593 TEST_CASE_ST(ut_setup, ut_teardown,
9594 test_AES_GCM_authenticated_decryption_test_case_6),
9595 TEST_CASE_ST(ut_setup, ut_teardown,
9596 test_AES_GCM_authenticated_decryption_test_case_7),
9598 /** AES GCM Authenticated Encryption 192 bits key */
9599 TEST_CASE_ST(ut_setup, ut_teardown,
9600 test_AES_GCM_auth_encryption_test_case_192_1),
9601 TEST_CASE_ST(ut_setup, ut_teardown,
9602 test_AES_GCM_auth_encryption_test_case_192_2),
9603 TEST_CASE_ST(ut_setup, ut_teardown,
9604 test_AES_GCM_auth_encryption_test_case_192_3),
9605 TEST_CASE_ST(ut_setup, ut_teardown,
9606 test_AES_GCM_auth_encryption_test_case_192_4),
9607 TEST_CASE_ST(ut_setup, ut_teardown,
9608 test_AES_GCM_auth_encryption_test_case_192_5),
9609 TEST_CASE_ST(ut_setup, ut_teardown,
9610 test_AES_GCM_auth_encryption_test_case_192_6),
9611 TEST_CASE_ST(ut_setup, ut_teardown,
9612 test_AES_GCM_auth_encryption_test_case_192_7),
9614 /** AES GCM Authenticated Decryption 192 bits key */
9615 TEST_CASE_ST(ut_setup, ut_teardown,
9616 test_AES_GCM_auth_decryption_test_case_192_1),
9617 TEST_CASE_ST(ut_setup, ut_teardown,
9618 test_AES_GCM_auth_decryption_test_case_192_2),
9619 TEST_CASE_ST(ut_setup, ut_teardown,
9620 test_AES_GCM_auth_decryption_test_case_192_3),
9621 TEST_CASE_ST(ut_setup, ut_teardown,
9622 test_AES_GCM_auth_decryption_test_case_192_4),
9623 TEST_CASE_ST(ut_setup, ut_teardown,
9624 test_AES_GCM_auth_decryption_test_case_192_5),
9625 TEST_CASE_ST(ut_setup, ut_teardown,
9626 test_AES_GCM_auth_decryption_test_case_192_6),
9627 TEST_CASE_ST(ut_setup, ut_teardown,
9628 test_AES_GCM_auth_decryption_test_case_192_7),
9630 /** AES GCM Authenticated Encryption 256 bits key */
9631 TEST_CASE_ST(ut_setup, ut_teardown,
9632 test_AES_GCM_auth_encryption_test_case_256_1),
9633 TEST_CASE_ST(ut_setup, ut_teardown,
9634 test_AES_GCM_auth_encryption_test_case_256_2),
9635 TEST_CASE_ST(ut_setup, ut_teardown,
9636 test_AES_GCM_auth_encryption_test_case_256_3),
9637 TEST_CASE_ST(ut_setup, ut_teardown,
9638 test_AES_GCM_auth_encryption_test_case_256_4),
9639 TEST_CASE_ST(ut_setup, ut_teardown,
9640 test_AES_GCM_auth_encryption_test_case_256_5),
9641 TEST_CASE_ST(ut_setup, ut_teardown,
9642 test_AES_GCM_auth_encryption_test_case_256_6),
9643 TEST_CASE_ST(ut_setup, ut_teardown,
9644 test_AES_GCM_auth_encryption_test_case_256_7),
9646 /** AES GCM Authenticated Decryption 256 bits key */
9647 TEST_CASE_ST(ut_setup, ut_teardown,
9648 test_AES_GCM_auth_decryption_test_case_256_1),
9649 TEST_CASE_ST(ut_setup, ut_teardown,
9650 test_AES_GCM_auth_decryption_test_case_256_2),
9651 TEST_CASE_ST(ut_setup, ut_teardown,
9652 test_AES_GCM_auth_decryption_test_case_256_3),
9653 TEST_CASE_ST(ut_setup, ut_teardown,
9654 test_AES_GCM_auth_decryption_test_case_256_4),
9655 TEST_CASE_ST(ut_setup, ut_teardown,
9656 test_AES_GCM_auth_decryption_test_case_256_5),
9657 TEST_CASE_ST(ut_setup, ut_teardown,
9658 test_AES_GCM_auth_decryption_test_case_256_6),
9659 TEST_CASE_ST(ut_setup, ut_teardown,
9660 test_AES_GCM_auth_decryption_test_case_256_7),
9662 /** AES GCM Authenticated Encryption big aad size */
9663 TEST_CASE_ST(ut_setup, ut_teardown,
9664 test_AES_GCM_auth_encryption_test_case_aad_1),
9665 TEST_CASE_ST(ut_setup, ut_teardown,
9666 test_AES_GCM_auth_encryption_test_case_aad_2),
9668 /** AES GCM Authenticated Decryption big aad size */
9669 TEST_CASE_ST(ut_setup, ut_teardown,
9670 test_AES_GCM_auth_decryption_test_case_aad_1),
9671 TEST_CASE_ST(ut_setup, ut_teardown,
9672 test_AES_GCM_auth_decryption_test_case_aad_2),
9674 /** Session-less tests */
9675 TEST_CASE_ST(ut_setup, ut_teardown,
9676 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9677 TEST_CASE_ST(ut_setup, ut_teardown,
9678 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9680 /** AES GMAC Authentication */
9681 TEST_CASE_ST(ut_setup, ut_teardown,
9682 test_AES_GMAC_authentication_test_case_1),
9683 TEST_CASE_ST(ut_setup, ut_teardown,
9684 test_AES_GMAC_authentication_verify_test_case_1),
9685 TEST_CASE_ST(ut_setup, ut_teardown,
9686 test_AES_GMAC_authentication_test_case_2),
9687 TEST_CASE_ST(ut_setup, ut_teardown,
9688 test_AES_GMAC_authentication_verify_test_case_2),
9689 TEST_CASE_ST(ut_setup, ut_teardown,
9690 test_AES_GMAC_authentication_test_case_3),
9691 TEST_CASE_ST(ut_setup, ut_teardown,
9692 test_AES_GMAC_authentication_verify_test_case_3),
9693 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
9695 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9696 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9697 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9698 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9699 TEST_CASE_ST(ut_setup, ut_teardown,
9700 test_DES_cipheronly_mb_all),
9701 TEST_CASE_ST(ut_setup, ut_teardown,
9702 test_DES_docsis_mb_all),
9703 TEST_CASE_ST(ut_setup, ut_teardown,
9704 test_3DES_cipheronly_mb_all),
9705 TEST_CASE_ST(ut_setup, ut_teardown,
9706 test_AES_CCM_authenticated_encryption_test_case_128_1),
9707 TEST_CASE_ST(ut_setup, ut_teardown,
9708 test_AES_CCM_authenticated_decryption_test_case_128_1),
9709 TEST_CASE_ST(ut_setup, ut_teardown,
9710 test_AES_CCM_authenticated_encryption_test_case_128_2),
9711 TEST_CASE_ST(ut_setup, ut_teardown,
9712 test_AES_CCM_authenticated_decryption_test_case_128_2),
9713 TEST_CASE_ST(ut_setup, ut_teardown,
9714 test_AES_CCM_authenticated_encryption_test_case_128_3),
9715 TEST_CASE_ST(ut_setup, ut_teardown,
9716 test_AES_CCM_authenticated_decryption_test_case_128_3),
9718 TEST_CASES_END() /**< NULL terminate unit test array */
9722 static struct unit_test_suite cryptodev_openssl_testsuite = {
9723 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9724 .setup = testsuite_setup,
9725 .teardown = testsuite_teardown,
9726 .unit_test_cases = {
9727 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9728 TEST_CASE_ST(ut_setup, ut_teardown,
9729 test_multi_session_random_usage),
9730 TEST_CASE_ST(ut_setup, ut_teardown,
9731 test_AES_chain_openssl_all),
9732 TEST_CASE_ST(ut_setup, ut_teardown,
9733 test_AES_cipheronly_openssl_all),
9734 TEST_CASE_ST(ut_setup, ut_teardown,
9735 test_3DES_chain_openssl_all),
9736 TEST_CASE_ST(ut_setup, ut_teardown,
9737 test_3DES_cipheronly_openssl_all),
9738 TEST_CASE_ST(ut_setup, ut_teardown,
9739 test_DES_cipheronly_openssl_all),
9740 TEST_CASE_ST(ut_setup, ut_teardown,
9741 test_DES_docsis_openssl_all),
9742 TEST_CASE_ST(ut_setup, ut_teardown,
9743 test_authonly_openssl_all),
9745 /** AES GCM Authenticated Encryption */
9746 TEST_CASE_ST(ut_setup, ut_teardown,
9747 test_AES_GCM_authenticated_encryption_test_case_1),
9748 TEST_CASE_ST(ut_setup, ut_teardown,
9749 test_AES_GCM_authenticated_encryption_test_case_2),
9750 TEST_CASE_ST(ut_setup, ut_teardown,
9751 test_AES_GCM_authenticated_encryption_test_case_3),
9752 TEST_CASE_ST(ut_setup, ut_teardown,
9753 test_AES_GCM_authenticated_encryption_test_case_4),
9754 TEST_CASE_ST(ut_setup, ut_teardown,
9755 test_AES_GCM_authenticated_encryption_test_case_5),
9756 TEST_CASE_ST(ut_setup, ut_teardown,
9757 test_AES_GCM_authenticated_encryption_test_case_6),
9758 TEST_CASE_ST(ut_setup, ut_teardown,
9759 test_AES_GCM_authenticated_encryption_test_case_7),
9761 /** AES GCM Authenticated Decryption */
9762 TEST_CASE_ST(ut_setup, ut_teardown,
9763 test_AES_GCM_authenticated_decryption_test_case_1),
9764 TEST_CASE_ST(ut_setup, ut_teardown,
9765 test_AES_GCM_authenticated_decryption_test_case_2),
9766 TEST_CASE_ST(ut_setup, ut_teardown,
9767 test_AES_GCM_authenticated_decryption_test_case_3),
9768 TEST_CASE_ST(ut_setup, ut_teardown,
9769 test_AES_GCM_authenticated_decryption_test_case_4),
9770 TEST_CASE_ST(ut_setup, ut_teardown,
9771 test_AES_GCM_authenticated_decryption_test_case_5),
9772 TEST_CASE_ST(ut_setup, ut_teardown,
9773 test_AES_GCM_authenticated_decryption_test_case_6),
9774 TEST_CASE_ST(ut_setup, ut_teardown,
9775 test_AES_GCM_authenticated_decryption_test_case_7),
9778 /** AES GCM Authenticated Encryption 192 bits key */
9779 TEST_CASE_ST(ut_setup, ut_teardown,
9780 test_AES_GCM_auth_encryption_test_case_192_1),
9781 TEST_CASE_ST(ut_setup, ut_teardown,
9782 test_AES_GCM_auth_encryption_test_case_192_2),
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 test_AES_GCM_auth_encryption_test_case_192_3),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 test_AES_GCM_auth_encryption_test_case_192_4),
9787 TEST_CASE_ST(ut_setup, ut_teardown,
9788 test_AES_GCM_auth_encryption_test_case_192_5),
9789 TEST_CASE_ST(ut_setup, ut_teardown,
9790 test_AES_GCM_auth_encryption_test_case_192_6),
9791 TEST_CASE_ST(ut_setup, ut_teardown,
9792 test_AES_GCM_auth_encryption_test_case_192_7),
9794 /** AES GCM Authenticated Decryption 192 bits key */
9795 TEST_CASE_ST(ut_setup, ut_teardown,
9796 test_AES_GCM_auth_decryption_test_case_192_1),
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_AES_GCM_auth_decryption_test_case_192_2),
9799 TEST_CASE_ST(ut_setup, ut_teardown,
9800 test_AES_GCM_auth_decryption_test_case_192_3),
9801 TEST_CASE_ST(ut_setup, ut_teardown,
9802 test_AES_GCM_auth_decryption_test_case_192_4),
9803 TEST_CASE_ST(ut_setup, ut_teardown,
9804 test_AES_GCM_auth_decryption_test_case_192_5),
9805 TEST_CASE_ST(ut_setup, ut_teardown,
9806 test_AES_GCM_auth_decryption_test_case_192_6),
9807 TEST_CASE_ST(ut_setup, ut_teardown,
9808 test_AES_GCM_auth_decryption_test_case_192_7),
9810 /** AES GCM Authenticated Encryption 256 bits key */
9811 TEST_CASE_ST(ut_setup, ut_teardown,
9812 test_AES_GCM_auth_encryption_test_case_256_1),
9813 TEST_CASE_ST(ut_setup, ut_teardown,
9814 test_AES_GCM_auth_encryption_test_case_256_2),
9815 TEST_CASE_ST(ut_setup, ut_teardown,
9816 test_AES_GCM_auth_encryption_test_case_256_3),
9817 TEST_CASE_ST(ut_setup, ut_teardown,
9818 test_AES_GCM_auth_encryption_test_case_256_4),
9819 TEST_CASE_ST(ut_setup, ut_teardown,
9820 test_AES_GCM_auth_encryption_test_case_256_5),
9821 TEST_CASE_ST(ut_setup, ut_teardown,
9822 test_AES_GCM_auth_encryption_test_case_256_6),
9823 TEST_CASE_ST(ut_setup, ut_teardown,
9824 test_AES_GCM_auth_encryption_test_case_256_7),
9826 /** AES GCM Authenticated Decryption 256 bits key */
9827 TEST_CASE_ST(ut_setup, ut_teardown,
9828 test_AES_GCM_auth_decryption_test_case_256_1),
9829 TEST_CASE_ST(ut_setup, ut_teardown,
9830 test_AES_GCM_auth_decryption_test_case_256_2),
9831 TEST_CASE_ST(ut_setup, ut_teardown,
9832 test_AES_GCM_auth_decryption_test_case_256_3),
9833 TEST_CASE_ST(ut_setup, ut_teardown,
9834 test_AES_GCM_auth_decryption_test_case_256_4),
9835 TEST_CASE_ST(ut_setup, ut_teardown,
9836 test_AES_GCM_auth_decryption_test_case_256_5),
9837 TEST_CASE_ST(ut_setup, ut_teardown,
9838 test_AES_GCM_auth_decryption_test_case_256_6),
9839 TEST_CASE_ST(ut_setup, ut_teardown,
9840 test_AES_GCM_auth_decryption_test_case_256_7),
9842 /** AES GMAC Authentication */
9843 TEST_CASE_ST(ut_setup, ut_teardown,
9844 test_AES_GMAC_authentication_test_case_1),
9845 TEST_CASE_ST(ut_setup, ut_teardown,
9846 test_AES_GMAC_authentication_verify_test_case_1),
9847 TEST_CASE_ST(ut_setup, ut_teardown,
9848 test_AES_GMAC_authentication_test_case_2),
9849 TEST_CASE_ST(ut_setup, ut_teardown,
9850 test_AES_GMAC_authentication_verify_test_case_2),
9851 TEST_CASE_ST(ut_setup, ut_teardown,
9852 test_AES_GMAC_authentication_test_case_3),
9853 TEST_CASE_ST(ut_setup, ut_teardown,
9854 test_AES_GMAC_authentication_verify_test_case_3),
9855 TEST_CASE_ST(ut_setup, ut_teardown,
9856 test_AES_GMAC_authentication_test_case_4),
9857 TEST_CASE_ST(ut_setup, ut_teardown,
9858 test_AES_GMAC_authentication_verify_test_case_4),
9860 /** AES CCM Authenticated Encryption 128 bits key */
9861 TEST_CASE_ST(ut_setup, ut_teardown,
9862 test_AES_CCM_authenticated_encryption_test_case_128_1),
9863 TEST_CASE_ST(ut_setup, ut_teardown,
9864 test_AES_CCM_authenticated_encryption_test_case_128_2),
9865 TEST_CASE_ST(ut_setup, ut_teardown,
9866 test_AES_CCM_authenticated_encryption_test_case_128_3),
9868 /** AES CCM Authenticated Decryption 128 bits key*/
9869 TEST_CASE_ST(ut_setup, ut_teardown,
9870 test_AES_CCM_authenticated_decryption_test_case_128_1),
9871 TEST_CASE_ST(ut_setup, ut_teardown,
9872 test_AES_CCM_authenticated_decryption_test_case_128_2),
9873 TEST_CASE_ST(ut_setup, ut_teardown,
9874 test_AES_CCM_authenticated_decryption_test_case_128_3),
9876 /** AES CCM Authenticated Encryption 192 bits key */
9877 TEST_CASE_ST(ut_setup, ut_teardown,
9878 test_AES_CCM_authenticated_encryption_test_case_192_1),
9879 TEST_CASE_ST(ut_setup, ut_teardown,
9880 test_AES_CCM_authenticated_encryption_test_case_192_2),
9881 TEST_CASE_ST(ut_setup, ut_teardown,
9882 test_AES_CCM_authenticated_encryption_test_case_192_3),
9884 /** AES CCM Authenticated Decryption 192 bits key*/
9885 TEST_CASE_ST(ut_setup, ut_teardown,
9886 test_AES_CCM_authenticated_decryption_test_case_192_1),
9887 TEST_CASE_ST(ut_setup, ut_teardown,
9888 test_AES_CCM_authenticated_decryption_test_case_192_2),
9889 TEST_CASE_ST(ut_setup, ut_teardown,
9890 test_AES_CCM_authenticated_decryption_test_case_192_3),
9892 /** AES CCM Authenticated Encryption 256 bits key */
9893 TEST_CASE_ST(ut_setup, ut_teardown,
9894 test_AES_CCM_authenticated_encryption_test_case_256_1),
9895 TEST_CASE_ST(ut_setup, ut_teardown,
9896 test_AES_CCM_authenticated_encryption_test_case_256_2),
9897 TEST_CASE_ST(ut_setup, ut_teardown,
9898 test_AES_CCM_authenticated_encryption_test_case_256_3),
9900 /** AES CCM Authenticated Decryption 256 bits key*/
9901 TEST_CASE_ST(ut_setup, ut_teardown,
9902 test_AES_CCM_authenticated_decryption_test_case_256_1),
9903 TEST_CASE_ST(ut_setup, ut_teardown,
9904 test_AES_CCM_authenticated_decryption_test_case_256_2),
9905 TEST_CASE_ST(ut_setup, ut_teardown,
9906 test_AES_CCM_authenticated_decryption_test_case_256_3),
9908 /** Scatter-Gather */
9909 TEST_CASE_ST(ut_setup, ut_teardown,
9910 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9912 /** Negative tests */
9913 TEST_CASE_ST(ut_setup, ut_teardown,
9914 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9915 TEST_CASE_ST(ut_setup, ut_teardown,
9916 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9917 TEST_CASE_ST(ut_setup, ut_teardown,
9918 authentication_verify_AES128_GMAC_fail_data_corrupt),
9919 TEST_CASE_ST(ut_setup, ut_teardown,
9920 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9921 TEST_CASE_ST(ut_setup, ut_teardown,
9922 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9923 TEST_CASE_ST(ut_setup, ut_teardown,
9924 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9926 TEST_CASES_END() /**< NULL terminate unit test array */
9930 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9931 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9932 .setup = testsuite_setup,
9933 .teardown = testsuite_teardown,
9934 .unit_test_cases = {
9935 /** AES GCM Authenticated Encryption */
9936 TEST_CASE_ST(ut_setup, ut_teardown,
9937 test_AES_GCM_authenticated_encryption_test_case_1),
9938 TEST_CASE_ST(ut_setup, ut_teardown,
9939 test_AES_GCM_authenticated_encryption_test_case_2),
9940 TEST_CASE_ST(ut_setup, ut_teardown,
9941 test_AES_GCM_authenticated_encryption_test_case_3),
9942 TEST_CASE_ST(ut_setup, ut_teardown,
9943 test_AES_GCM_authenticated_encryption_test_case_4),
9944 TEST_CASE_ST(ut_setup, ut_teardown,
9945 test_AES_GCM_authenticated_encryption_test_case_5),
9946 TEST_CASE_ST(ut_setup, ut_teardown,
9947 test_AES_GCM_authenticated_encryption_test_case_6),
9948 TEST_CASE_ST(ut_setup, ut_teardown,
9949 test_AES_GCM_authenticated_encryption_test_case_7),
9951 /** AES GCM Authenticated Decryption */
9952 TEST_CASE_ST(ut_setup, ut_teardown,
9953 test_AES_GCM_authenticated_decryption_test_case_1),
9954 TEST_CASE_ST(ut_setup, ut_teardown,
9955 test_AES_GCM_authenticated_decryption_test_case_2),
9956 TEST_CASE_ST(ut_setup, ut_teardown,
9957 test_AES_GCM_authenticated_decryption_test_case_3),
9958 TEST_CASE_ST(ut_setup, ut_teardown,
9959 test_AES_GCM_authenticated_decryption_test_case_4),
9960 TEST_CASE_ST(ut_setup, ut_teardown,
9961 test_AES_GCM_authenticated_decryption_test_case_5),
9962 TEST_CASE_ST(ut_setup, ut_teardown,
9963 test_AES_GCM_authenticated_decryption_test_case_6),
9964 TEST_CASE_ST(ut_setup, ut_teardown,
9965 test_AES_GCM_authenticated_decryption_test_case_7),
9967 /** AES GCM Authenticated Encryption 192 bits key */
9968 TEST_CASE_ST(ut_setup, ut_teardown,
9969 test_AES_GCM_auth_encryption_test_case_192_1),
9970 TEST_CASE_ST(ut_setup, ut_teardown,
9971 test_AES_GCM_auth_encryption_test_case_192_2),
9972 TEST_CASE_ST(ut_setup, ut_teardown,
9973 test_AES_GCM_auth_encryption_test_case_192_3),
9974 TEST_CASE_ST(ut_setup, ut_teardown,
9975 test_AES_GCM_auth_encryption_test_case_192_4),
9976 TEST_CASE_ST(ut_setup, ut_teardown,
9977 test_AES_GCM_auth_encryption_test_case_192_5),
9978 TEST_CASE_ST(ut_setup, ut_teardown,
9979 test_AES_GCM_auth_encryption_test_case_192_6),
9980 TEST_CASE_ST(ut_setup, ut_teardown,
9981 test_AES_GCM_auth_encryption_test_case_192_7),
9983 /** AES GCM Authenticated Decryption 192 bits key */
9984 TEST_CASE_ST(ut_setup, ut_teardown,
9985 test_AES_GCM_auth_decryption_test_case_192_1),
9986 TEST_CASE_ST(ut_setup, ut_teardown,
9987 test_AES_GCM_auth_decryption_test_case_192_2),
9988 TEST_CASE_ST(ut_setup, ut_teardown,
9989 test_AES_GCM_auth_decryption_test_case_192_3),
9990 TEST_CASE_ST(ut_setup, ut_teardown,
9991 test_AES_GCM_auth_decryption_test_case_192_4),
9992 TEST_CASE_ST(ut_setup, ut_teardown,
9993 test_AES_GCM_auth_decryption_test_case_192_5),
9994 TEST_CASE_ST(ut_setup, ut_teardown,
9995 test_AES_GCM_auth_decryption_test_case_192_6),
9996 TEST_CASE_ST(ut_setup, ut_teardown,
9997 test_AES_GCM_auth_decryption_test_case_192_7),
9999 /** AES GCM Authenticated Encryption 256 bits key */
10000 TEST_CASE_ST(ut_setup, ut_teardown,
10001 test_AES_GCM_auth_encryption_test_case_256_1),
10002 TEST_CASE_ST(ut_setup, ut_teardown,
10003 test_AES_GCM_auth_encryption_test_case_256_2),
10004 TEST_CASE_ST(ut_setup, ut_teardown,
10005 test_AES_GCM_auth_encryption_test_case_256_3),
10006 TEST_CASE_ST(ut_setup, ut_teardown,
10007 test_AES_GCM_auth_encryption_test_case_256_4),
10008 TEST_CASE_ST(ut_setup, ut_teardown,
10009 test_AES_GCM_auth_encryption_test_case_256_5),
10010 TEST_CASE_ST(ut_setup, ut_teardown,
10011 test_AES_GCM_auth_encryption_test_case_256_6),
10012 TEST_CASE_ST(ut_setup, ut_teardown,
10013 test_AES_GCM_auth_encryption_test_case_256_7),
10015 /** AES GCM Authenticated Decryption 256 bits key */
10016 TEST_CASE_ST(ut_setup, ut_teardown,
10017 test_AES_GCM_auth_decryption_test_case_256_1),
10018 TEST_CASE_ST(ut_setup, ut_teardown,
10019 test_AES_GCM_auth_decryption_test_case_256_2),
10020 TEST_CASE_ST(ut_setup, ut_teardown,
10021 test_AES_GCM_auth_decryption_test_case_256_3),
10022 TEST_CASE_ST(ut_setup, ut_teardown,
10023 test_AES_GCM_auth_decryption_test_case_256_4),
10024 TEST_CASE_ST(ut_setup, ut_teardown,
10025 test_AES_GCM_auth_decryption_test_case_256_5),
10026 TEST_CASE_ST(ut_setup, ut_teardown,
10027 test_AES_GCM_auth_decryption_test_case_256_6),
10028 TEST_CASE_ST(ut_setup, ut_teardown,
10029 test_AES_GCM_auth_decryption_test_case_256_7),
10031 /** AES GCM Authenticated Encryption big aad size */
10032 TEST_CASE_ST(ut_setup, ut_teardown,
10033 test_AES_GCM_auth_encryption_test_case_aad_1),
10034 TEST_CASE_ST(ut_setup, ut_teardown,
10035 test_AES_GCM_auth_encryption_test_case_aad_2),
10037 /** AES GCM Authenticated Decryption big aad size */
10038 TEST_CASE_ST(ut_setup, ut_teardown,
10039 test_AES_GCM_auth_decryption_test_case_aad_1),
10040 TEST_CASE_ST(ut_setup, ut_teardown,
10041 test_AES_GCM_auth_decryption_test_case_aad_2),
10043 /** AES GMAC Authentication */
10044 TEST_CASE_ST(ut_setup, ut_teardown,
10045 test_AES_GMAC_authentication_test_case_1),
10046 TEST_CASE_ST(ut_setup, ut_teardown,
10047 test_AES_GMAC_authentication_verify_test_case_1),
10048 TEST_CASE_ST(ut_setup, ut_teardown,
10049 test_AES_GMAC_authentication_test_case_3),
10050 TEST_CASE_ST(ut_setup, ut_teardown,
10051 test_AES_GMAC_authentication_verify_test_case_3),
10052 TEST_CASE_ST(ut_setup, ut_teardown,
10053 test_AES_GMAC_authentication_test_case_4),
10054 TEST_CASE_ST(ut_setup, ut_teardown,
10055 test_AES_GMAC_authentication_verify_test_case_4),
10057 /** Negative tests */
10058 TEST_CASE_ST(ut_setup, ut_teardown,
10059 authentication_verify_AES128_GMAC_fail_data_corrupt),
10060 TEST_CASE_ST(ut_setup, ut_teardown,
10061 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10063 /** Out of place tests */
10064 TEST_CASE_ST(ut_setup, ut_teardown,
10065 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10066 TEST_CASE_ST(ut_setup, ut_teardown,
10067 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10069 /** Session-less tests */
10070 TEST_CASE_ST(ut_setup, ut_teardown,
10071 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
10072 TEST_CASE_ST(ut_setup, ut_teardown,
10073 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
10075 /** Scatter-Gather */
10076 TEST_CASE_ST(ut_setup, ut_teardown,
10077 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10079 TEST_CASES_END() /**< NULL terminate unit test array */
10083 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
10084 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
10085 .setup = testsuite_setup,
10086 .teardown = testsuite_teardown,
10087 .unit_test_cases = {
10088 /** KASUMI encrypt only (UEA1) */
10089 TEST_CASE_ST(ut_setup, ut_teardown,
10090 test_kasumi_encryption_test_case_1),
10091 TEST_CASE_ST(ut_setup, ut_teardown,
10092 test_kasumi_encryption_test_case_1_sgl),
10093 TEST_CASE_ST(ut_setup, ut_teardown,
10094 test_kasumi_encryption_test_case_2),
10095 TEST_CASE_ST(ut_setup, ut_teardown,
10096 test_kasumi_encryption_test_case_3),
10097 TEST_CASE_ST(ut_setup, ut_teardown,
10098 test_kasumi_encryption_test_case_4),
10099 TEST_CASE_ST(ut_setup, ut_teardown,
10100 test_kasumi_encryption_test_case_5),
10101 /** KASUMI decrypt only (UEA1) */
10102 TEST_CASE_ST(ut_setup, ut_teardown,
10103 test_kasumi_decryption_test_case_1),
10104 TEST_CASE_ST(ut_setup, ut_teardown,
10105 test_kasumi_decryption_test_case_2),
10106 TEST_CASE_ST(ut_setup, ut_teardown,
10107 test_kasumi_decryption_test_case_3),
10108 TEST_CASE_ST(ut_setup, ut_teardown,
10109 test_kasumi_decryption_test_case_4),
10110 TEST_CASE_ST(ut_setup, ut_teardown,
10111 test_kasumi_decryption_test_case_5),
10113 TEST_CASE_ST(ut_setup, ut_teardown,
10114 test_kasumi_encryption_test_case_1_oop),
10115 TEST_CASE_ST(ut_setup, ut_teardown,
10116 test_kasumi_encryption_test_case_1_oop_sgl),
10119 TEST_CASE_ST(ut_setup, ut_teardown,
10120 test_kasumi_decryption_test_case_1_oop),
10122 /** KASUMI hash only (UIA1) */
10123 TEST_CASE_ST(ut_setup, ut_teardown,
10124 test_kasumi_hash_generate_test_case_1),
10125 TEST_CASE_ST(ut_setup, ut_teardown,
10126 test_kasumi_hash_generate_test_case_2),
10127 TEST_CASE_ST(ut_setup, ut_teardown,
10128 test_kasumi_hash_generate_test_case_3),
10129 TEST_CASE_ST(ut_setup, ut_teardown,
10130 test_kasumi_hash_generate_test_case_4),
10131 TEST_CASE_ST(ut_setup, ut_teardown,
10132 test_kasumi_hash_generate_test_case_5),
10133 TEST_CASE_ST(ut_setup, ut_teardown,
10134 test_kasumi_hash_generate_test_case_6),
10135 TEST_CASE_ST(ut_setup, ut_teardown,
10136 test_kasumi_hash_verify_test_case_1),
10137 TEST_CASE_ST(ut_setup, ut_teardown,
10138 test_kasumi_hash_verify_test_case_2),
10139 TEST_CASE_ST(ut_setup, ut_teardown,
10140 test_kasumi_hash_verify_test_case_3),
10141 TEST_CASE_ST(ut_setup, ut_teardown,
10142 test_kasumi_hash_verify_test_case_4),
10143 TEST_CASE_ST(ut_setup, ut_teardown,
10144 test_kasumi_hash_verify_test_case_5),
10145 TEST_CASE_ST(ut_setup, ut_teardown,
10146 test_kasumi_auth_cipher_test_case_1),
10147 TEST_CASE_ST(ut_setup, ut_teardown,
10148 test_kasumi_cipher_auth_test_case_1),
10149 TEST_CASES_END() /**< NULL terminate unit test array */
10152 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
10153 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
10154 .setup = testsuite_setup,
10155 .teardown = testsuite_teardown,
10156 .unit_test_cases = {
10157 /** SNOW 3G encrypt only (UEA2) */
10158 TEST_CASE_ST(ut_setup, ut_teardown,
10159 test_snow3g_encryption_test_case_1),
10160 TEST_CASE_ST(ut_setup, ut_teardown,
10161 test_snow3g_encryption_test_case_2),
10162 TEST_CASE_ST(ut_setup, ut_teardown,
10163 test_snow3g_encryption_test_case_3),
10164 TEST_CASE_ST(ut_setup, ut_teardown,
10165 test_snow3g_encryption_test_case_4),
10166 TEST_CASE_ST(ut_setup, ut_teardown,
10167 test_snow3g_encryption_test_case_5),
10168 TEST_CASE_ST(ut_setup, ut_teardown,
10169 test_snow3g_auth_cipher_with_digest_test_case_1),
10171 TEST_CASE_ST(ut_setup, ut_teardown,
10172 test_snow3g_encryption_test_case_1_oop),
10173 TEST_CASE_ST(ut_setup, ut_teardown,
10174 test_snow3g_encryption_test_case_1_oop_sgl),
10175 TEST_CASE_ST(ut_setup, ut_teardown,
10176 test_snow3g_decryption_test_case_1_oop),
10178 TEST_CASE_ST(ut_setup, ut_teardown,
10179 test_snow3g_encryption_test_case_1_offset_oop),
10181 /** SNOW 3G decrypt only (UEA2) */
10182 TEST_CASE_ST(ut_setup, ut_teardown,
10183 test_snow3g_decryption_test_case_1),
10184 TEST_CASE_ST(ut_setup, ut_teardown,
10185 test_snow3g_decryption_test_case_2),
10186 TEST_CASE_ST(ut_setup, ut_teardown,
10187 test_snow3g_decryption_test_case_3),
10188 TEST_CASE_ST(ut_setup, ut_teardown,
10189 test_snow3g_decryption_test_case_4),
10190 TEST_CASE_ST(ut_setup, ut_teardown,
10191 test_snow3g_decryption_test_case_5),
10192 TEST_CASE_ST(ut_setup, ut_teardown,
10193 test_snow3g_decryption_with_digest_test_case_1),
10194 TEST_CASE_ST(ut_setup, ut_teardown,
10195 test_snow3g_hash_generate_test_case_1),
10196 TEST_CASE_ST(ut_setup, ut_teardown,
10197 test_snow3g_hash_generate_test_case_2),
10198 TEST_CASE_ST(ut_setup, ut_teardown,
10199 test_snow3g_hash_generate_test_case_3),
10200 /* Tests with buffers which length is not byte-aligned */
10201 TEST_CASE_ST(ut_setup, ut_teardown,
10202 test_snow3g_hash_generate_test_case_4),
10203 TEST_CASE_ST(ut_setup, ut_teardown,
10204 test_snow3g_hash_generate_test_case_5),
10205 TEST_CASE_ST(ut_setup, ut_teardown,
10206 test_snow3g_hash_generate_test_case_6),
10207 TEST_CASE_ST(ut_setup, ut_teardown,
10208 test_snow3g_hash_verify_test_case_1),
10209 TEST_CASE_ST(ut_setup, ut_teardown,
10210 test_snow3g_hash_verify_test_case_2),
10211 TEST_CASE_ST(ut_setup, ut_teardown,
10212 test_snow3g_hash_verify_test_case_3),
10213 /* Tests with buffers which length is not byte-aligned */
10214 TEST_CASE_ST(ut_setup, ut_teardown,
10215 test_snow3g_hash_verify_test_case_4),
10216 TEST_CASE_ST(ut_setup, ut_teardown,
10217 test_snow3g_hash_verify_test_case_5),
10218 TEST_CASE_ST(ut_setup, ut_teardown,
10219 test_snow3g_hash_verify_test_case_6),
10220 TEST_CASE_ST(ut_setup, ut_teardown,
10221 test_snow3g_cipher_auth_test_case_1),
10223 /** SNOW 3G generate auth, then encrypt (UEA2) */
10224 TEST_CASE_ST(ut_setup, ut_teardown,
10225 test_snow3g_auth_cipher_test_case_1),
10226 TEST_CASE_ST(ut_setup, ut_teardown,
10227 test_snow3g_auth_cipher_test_case_2),
10228 TEST_CASE_ST(ut_setup, ut_teardown,
10229 test_snow3g_auth_cipher_test_case_2_oop),
10230 TEST_CASE_ST(ut_setup, ut_teardown,
10231 test_snow3g_auth_cipher_part_digest_enc),
10232 TEST_CASE_ST(ut_setup, ut_teardown,
10233 test_snow3g_auth_cipher_part_digest_enc_oop),
10235 /** SNOW 3G decrypt (UEA2), then verify auth */
10236 TEST_CASE_ST(ut_setup, ut_teardown,
10237 test_snow3g_auth_cipher_verify_test_case_1),
10238 TEST_CASE_ST(ut_setup, ut_teardown,
10239 test_snow3g_auth_cipher_verify_test_case_2),
10240 TEST_CASE_ST(ut_setup, ut_teardown,
10241 test_snow3g_auth_cipher_verify_test_case_2_oop),
10242 TEST_CASE_ST(ut_setup, ut_teardown,
10243 test_snow3g_auth_cipher_verify_part_digest_enc),
10244 TEST_CASE_ST(ut_setup, ut_teardown,
10245 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
10247 TEST_CASES_END() /**< NULL terminate unit test array */
10251 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
10252 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
10253 .setup = testsuite_setup,
10254 .teardown = testsuite_teardown,
10255 .unit_test_cases = {
10256 /** ZUC encrypt only (EEA3) */
10257 TEST_CASE_ST(ut_setup, ut_teardown,
10258 test_zuc_encryption_test_case_1),
10259 TEST_CASE_ST(ut_setup, ut_teardown,
10260 test_zuc_encryption_test_case_2),
10261 TEST_CASE_ST(ut_setup, ut_teardown,
10262 test_zuc_encryption_test_case_3),
10263 TEST_CASE_ST(ut_setup, ut_teardown,
10264 test_zuc_encryption_test_case_4),
10265 TEST_CASE_ST(ut_setup, ut_teardown,
10266 test_zuc_encryption_test_case_5),
10267 TEST_CASE_ST(ut_setup, ut_teardown,
10268 test_zuc_hash_generate_test_case_1),
10269 TEST_CASE_ST(ut_setup, ut_teardown,
10270 test_zuc_hash_generate_test_case_2),
10271 TEST_CASE_ST(ut_setup, ut_teardown,
10272 test_zuc_hash_generate_test_case_3),
10273 TEST_CASE_ST(ut_setup, ut_teardown,
10274 test_zuc_hash_generate_test_case_4),
10275 TEST_CASE_ST(ut_setup, ut_teardown,
10276 test_zuc_hash_generate_test_case_5),
10277 TEST_CASE_ST(ut_setup, ut_teardown,
10278 test_zuc_encryption_test_case_6_sgl),
10279 TEST_CASES_END() /**< NULL terminate unit test array */
10283 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
10284 .suite_name = "Crypto CAAM JR Unit Test Suite",
10285 .setup = testsuite_setup,
10286 .teardown = testsuite_teardown,
10287 .unit_test_cases = {
10288 TEST_CASE_ST(ut_setup, ut_teardown,
10289 test_device_configure_invalid_dev_id),
10290 TEST_CASE_ST(ut_setup, ut_teardown,
10291 test_multi_session),
10293 TEST_CASE_ST(ut_setup, ut_teardown,
10294 test_AES_chain_caam_jr_all),
10295 TEST_CASE_ST(ut_setup, ut_teardown,
10296 test_3DES_chain_caam_jr_all),
10297 TEST_CASE_ST(ut_setup, ut_teardown,
10298 test_AES_cipheronly_caam_jr_all),
10299 TEST_CASE_ST(ut_setup, ut_teardown,
10300 test_3DES_cipheronly_caam_jr_all),
10301 TEST_CASE_ST(ut_setup, ut_teardown,
10302 test_authonly_caam_jr_all),
10304 TEST_CASES_END() /**< NULL terminate unit test array */
10308 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
10309 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
10310 .setup = testsuite_setup,
10311 .teardown = testsuite_teardown,
10312 .unit_test_cases = {
10313 TEST_CASE_ST(ut_setup, ut_teardown,
10314 test_device_configure_invalid_dev_id),
10315 TEST_CASE_ST(ut_setup, ut_teardown,
10316 test_multi_session),
10318 TEST_CASE_ST(ut_setup, ut_teardown,
10319 test_AES_chain_dpaa_sec_all),
10320 TEST_CASE_ST(ut_setup, ut_teardown,
10321 test_3DES_chain_dpaa_sec_all),
10322 TEST_CASE_ST(ut_setup, ut_teardown,
10323 test_AES_cipheronly_dpaa_sec_all),
10324 TEST_CASE_ST(ut_setup, ut_teardown,
10325 test_3DES_cipheronly_dpaa_sec_all),
10326 TEST_CASE_ST(ut_setup, ut_teardown,
10327 test_authonly_dpaa_sec_all),
10329 /** AES GCM Authenticated Encryption */
10330 TEST_CASE_ST(ut_setup, ut_teardown,
10331 test_AES_GCM_authenticated_encryption_test_case_1),
10332 TEST_CASE_ST(ut_setup, ut_teardown,
10333 test_AES_GCM_authenticated_encryption_test_case_2),
10334 TEST_CASE_ST(ut_setup, ut_teardown,
10335 test_AES_GCM_authenticated_encryption_test_case_3),
10336 TEST_CASE_ST(ut_setup, ut_teardown,
10337 test_AES_GCM_authenticated_encryption_test_case_4),
10338 TEST_CASE_ST(ut_setup, ut_teardown,
10339 test_AES_GCM_authenticated_encryption_test_case_5),
10340 TEST_CASE_ST(ut_setup, ut_teardown,
10341 test_AES_GCM_authenticated_encryption_test_case_6),
10342 TEST_CASE_ST(ut_setup, ut_teardown,
10343 test_AES_GCM_authenticated_encryption_test_case_7),
10345 /** AES GCM Authenticated Decryption */
10346 TEST_CASE_ST(ut_setup, ut_teardown,
10347 test_AES_GCM_authenticated_decryption_test_case_1),
10348 TEST_CASE_ST(ut_setup, ut_teardown,
10349 test_AES_GCM_authenticated_decryption_test_case_2),
10350 TEST_CASE_ST(ut_setup, ut_teardown,
10351 test_AES_GCM_authenticated_decryption_test_case_3),
10352 TEST_CASE_ST(ut_setup, ut_teardown,
10353 test_AES_GCM_authenticated_decryption_test_case_4),
10354 TEST_CASE_ST(ut_setup, ut_teardown,
10355 test_AES_GCM_authenticated_decryption_test_case_5),
10356 TEST_CASE_ST(ut_setup, ut_teardown,
10357 test_AES_GCM_authenticated_decryption_test_case_6),
10358 TEST_CASE_ST(ut_setup, ut_teardown,
10359 test_AES_GCM_authenticated_decryption_test_case_7),
10361 /** AES GCM Authenticated Encryption 256 bits key */
10362 TEST_CASE_ST(ut_setup, ut_teardown,
10363 test_AES_GCM_auth_encryption_test_case_256_1),
10364 TEST_CASE_ST(ut_setup, ut_teardown,
10365 test_AES_GCM_auth_encryption_test_case_256_2),
10366 TEST_CASE_ST(ut_setup, ut_teardown,
10367 test_AES_GCM_auth_encryption_test_case_256_3),
10368 TEST_CASE_ST(ut_setup, ut_teardown,
10369 test_AES_GCM_auth_encryption_test_case_256_4),
10370 TEST_CASE_ST(ut_setup, ut_teardown,
10371 test_AES_GCM_auth_encryption_test_case_256_5),
10372 TEST_CASE_ST(ut_setup, ut_teardown,
10373 test_AES_GCM_auth_encryption_test_case_256_6),
10374 TEST_CASE_ST(ut_setup, ut_teardown,
10375 test_AES_GCM_auth_encryption_test_case_256_7),
10377 /** AES GCM Authenticated Decryption 256 bits key */
10378 TEST_CASE_ST(ut_setup, ut_teardown,
10379 test_AES_GCM_auth_decryption_test_case_256_1),
10380 TEST_CASE_ST(ut_setup, ut_teardown,
10381 test_AES_GCM_auth_decryption_test_case_256_2),
10382 TEST_CASE_ST(ut_setup, ut_teardown,
10383 test_AES_GCM_auth_decryption_test_case_256_3),
10384 TEST_CASE_ST(ut_setup, ut_teardown,
10385 test_AES_GCM_auth_decryption_test_case_256_4),
10386 TEST_CASE_ST(ut_setup, ut_teardown,
10387 test_AES_GCM_auth_decryption_test_case_256_5),
10388 TEST_CASE_ST(ut_setup, ut_teardown,
10389 test_AES_GCM_auth_decryption_test_case_256_6),
10390 TEST_CASE_ST(ut_setup, ut_teardown,
10391 test_AES_GCM_auth_decryption_test_case_256_7),
10393 /** Out of place tests */
10394 TEST_CASE_ST(ut_setup, ut_teardown,
10395 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10396 TEST_CASE_ST(ut_setup, ut_teardown,
10397 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10399 /** Scatter-Gather */
10400 TEST_CASE_ST(ut_setup, ut_teardown,
10401 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10402 TEST_CASE_ST(ut_setup, ut_teardown,
10403 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10404 TEST_CASE_ST(ut_setup, ut_teardown,
10405 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10406 TEST_CASE_ST(ut_setup, ut_teardown,
10407 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10409 TEST_CASES_END() /**< NULL terminate unit test array */
10413 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
10414 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10415 .setup = testsuite_setup,
10416 .teardown = testsuite_teardown,
10417 .unit_test_cases = {
10418 TEST_CASE_ST(ut_setup, ut_teardown,
10419 test_device_configure_invalid_dev_id),
10420 TEST_CASE_ST(ut_setup, ut_teardown,
10421 test_multi_session),
10423 TEST_CASE_ST(ut_setup, ut_teardown,
10424 test_AES_chain_dpaa2_sec_all),
10425 TEST_CASE_ST(ut_setup, ut_teardown,
10426 test_3DES_chain_dpaa2_sec_all),
10427 TEST_CASE_ST(ut_setup, ut_teardown,
10428 test_AES_cipheronly_dpaa2_sec_all),
10429 TEST_CASE_ST(ut_setup, ut_teardown,
10430 test_3DES_cipheronly_dpaa2_sec_all),
10431 TEST_CASE_ST(ut_setup, ut_teardown,
10432 test_authonly_dpaa2_sec_all),
10434 /** AES GCM Authenticated Encryption */
10435 TEST_CASE_ST(ut_setup, ut_teardown,
10436 test_AES_GCM_authenticated_encryption_test_case_1),
10437 TEST_CASE_ST(ut_setup, ut_teardown,
10438 test_AES_GCM_authenticated_encryption_test_case_2),
10439 TEST_CASE_ST(ut_setup, ut_teardown,
10440 test_AES_GCM_authenticated_encryption_test_case_3),
10441 TEST_CASE_ST(ut_setup, ut_teardown,
10442 test_AES_GCM_authenticated_encryption_test_case_4),
10443 TEST_CASE_ST(ut_setup, ut_teardown,
10444 test_AES_GCM_authenticated_encryption_test_case_5),
10445 TEST_CASE_ST(ut_setup, ut_teardown,
10446 test_AES_GCM_authenticated_encryption_test_case_6),
10447 TEST_CASE_ST(ut_setup, ut_teardown,
10448 test_AES_GCM_authenticated_encryption_test_case_7),
10450 /** AES GCM Authenticated Decryption */
10451 TEST_CASE_ST(ut_setup, ut_teardown,
10452 test_AES_GCM_authenticated_decryption_test_case_1),
10453 TEST_CASE_ST(ut_setup, ut_teardown,
10454 test_AES_GCM_authenticated_decryption_test_case_2),
10455 TEST_CASE_ST(ut_setup, ut_teardown,
10456 test_AES_GCM_authenticated_decryption_test_case_3),
10457 TEST_CASE_ST(ut_setup, ut_teardown,
10458 test_AES_GCM_authenticated_decryption_test_case_4),
10459 TEST_CASE_ST(ut_setup, ut_teardown,
10460 test_AES_GCM_authenticated_decryption_test_case_5),
10461 TEST_CASE_ST(ut_setup, ut_teardown,
10462 test_AES_GCM_authenticated_decryption_test_case_6),
10463 TEST_CASE_ST(ut_setup, ut_teardown,
10464 test_AES_GCM_authenticated_decryption_test_case_7),
10466 /** AES GCM Authenticated Encryption 192 bits key */
10467 TEST_CASE_ST(ut_setup, ut_teardown,
10468 test_AES_GCM_auth_encryption_test_case_192_1),
10469 TEST_CASE_ST(ut_setup, ut_teardown,
10470 test_AES_GCM_auth_encryption_test_case_192_2),
10471 TEST_CASE_ST(ut_setup, ut_teardown,
10472 test_AES_GCM_auth_encryption_test_case_192_3),
10473 TEST_CASE_ST(ut_setup, ut_teardown,
10474 test_AES_GCM_auth_encryption_test_case_192_4),
10475 TEST_CASE_ST(ut_setup, ut_teardown,
10476 test_AES_GCM_auth_encryption_test_case_192_5),
10477 TEST_CASE_ST(ut_setup, ut_teardown,
10478 test_AES_GCM_auth_encryption_test_case_192_6),
10479 TEST_CASE_ST(ut_setup, ut_teardown,
10480 test_AES_GCM_auth_encryption_test_case_192_7),
10482 /** AES GCM Authenticated Decryption 192 bits key */
10483 TEST_CASE_ST(ut_setup, ut_teardown,
10484 test_AES_GCM_auth_decryption_test_case_192_1),
10485 TEST_CASE_ST(ut_setup, ut_teardown,
10486 test_AES_GCM_auth_decryption_test_case_192_2),
10487 TEST_CASE_ST(ut_setup, ut_teardown,
10488 test_AES_GCM_auth_decryption_test_case_192_3),
10489 TEST_CASE_ST(ut_setup, ut_teardown,
10490 test_AES_GCM_auth_decryption_test_case_192_4),
10491 TEST_CASE_ST(ut_setup, ut_teardown,
10492 test_AES_GCM_auth_decryption_test_case_192_5),
10493 TEST_CASE_ST(ut_setup, ut_teardown,
10494 test_AES_GCM_auth_decryption_test_case_192_6),
10495 TEST_CASE_ST(ut_setup, ut_teardown,
10496 test_AES_GCM_auth_decryption_test_case_192_7),
10498 /** AES GCM Authenticated Encryption 256 bits key */
10499 TEST_CASE_ST(ut_setup, ut_teardown,
10500 test_AES_GCM_auth_encryption_test_case_256_1),
10501 TEST_CASE_ST(ut_setup, ut_teardown,
10502 test_AES_GCM_auth_encryption_test_case_256_2),
10503 TEST_CASE_ST(ut_setup, ut_teardown,
10504 test_AES_GCM_auth_encryption_test_case_256_3),
10505 TEST_CASE_ST(ut_setup, ut_teardown,
10506 test_AES_GCM_auth_encryption_test_case_256_4),
10507 TEST_CASE_ST(ut_setup, ut_teardown,
10508 test_AES_GCM_auth_encryption_test_case_256_5),
10509 TEST_CASE_ST(ut_setup, ut_teardown,
10510 test_AES_GCM_auth_encryption_test_case_256_6),
10511 TEST_CASE_ST(ut_setup, ut_teardown,
10512 test_AES_GCM_auth_encryption_test_case_256_7),
10514 /** AES GCM Authenticated Decryption 256 bits key */
10515 TEST_CASE_ST(ut_setup, ut_teardown,
10516 test_AES_GCM_auth_decryption_test_case_256_1),
10517 TEST_CASE_ST(ut_setup, ut_teardown,
10518 test_AES_GCM_auth_decryption_test_case_256_2),
10519 TEST_CASE_ST(ut_setup, ut_teardown,
10520 test_AES_GCM_auth_decryption_test_case_256_3),
10521 TEST_CASE_ST(ut_setup, ut_teardown,
10522 test_AES_GCM_auth_decryption_test_case_256_4),
10523 TEST_CASE_ST(ut_setup, ut_teardown,
10524 test_AES_GCM_auth_decryption_test_case_256_5),
10525 TEST_CASE_ST(ut_setup, ut_teardown,
10526 test_AES_GCM_auth_decryption_test_case_256_6),
10527 TEST_CASE_ST(ut_setup, ut_teardown,
10528 test_AES_GCM_auth_decryption_test_case_256_7),
10530 /** Out of place tests */
10531 TEST_CASE_ST(ut_setup, ut_teardown,
10532 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10533 TEST_CASE_ST(ut_setup, ut_teardown,
10534 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10536 /** Scatter-Gather */
10537 TEST_CASE_ST(ut_setup, ut_teardown,
10538 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10539 TEST_CASE_ST(ut_setup, ut_teardown,
10540 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10541 TEST_CASE_ST(ut_setup, ut_teardown,
10542 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10543 TEST_CASE_ST(ut_setup, ut_teardown,
10544 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10546 TEST_CASES_END() /**< NULL terminate unit test array */
10550 static struct unit_test_suite cryptodev_null_testsuite = {
10551 .suite_name = "Crypto Device NULL Unit Test Suite",
10552 .setup = testsuite_setup,
10553 .teardown = testsuite_teardown,
10554 .unit_test_cases = {
10555 TEST_CASE_ST(ut_setup, ut_teardown,
10556 test_null_invalid_operation),
10557 TEST_CASE_ST(ut_setup, ut_teardown,
10558 test_null_burst_operation),
10559 TEST_CASE_ST(ut_setup, ut_teardown,
10560 test_AES_chain_null_all),
10561 TEST_CASE_ST(ut_setup, ut_teardown,
10562 test_AES_cipheronly_null_all),
10563 TEST_CASE_ST(ut_setup, ut_teardown,
10564 test_authonly_null_all),
10566 TEST_CASES_END() /**< NULL terminate unit test array */
10570 static struct unit_test_suite cryptodev_armv8_testsuite = {
10571 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10572 .setup = testsuite_setup,
10573 .teardown = testsuite_teardown,
10574 .unit_test_cases = {
10575 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10577 /** Negative tests */
10578 TEST_CASE_ST(ut_setup, ut_teardown,
10579 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10580 TEST_CASE_ST(ut_setup, ut_teardown,
10581 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10583 TEST_CASES_END() /**< NULL terminate unit test array */
10587 static struct unit_test_suite cryptodev_mrvl_testsuite = {
10588 .suite_name = "Crypto Device Marvell Component Test Suite",
10589 .setup = testsuite_setup,
10590 .teardown = testsuite_teardown,
10591 .unit_test_cases = {
10592 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10593 TEST_CASE_ST(ut_setup, ut_teardown,
10594 test_multi_session_random_usage),
10595 TEST_CASE_ST(ut_setup, ut_teardown,
10596 test_AES_chain_mrvl_all),
10597 TEST_CASE_ST(ut_setup, ut_teardown,
10598 test_AES_cipheronly_mrvl_all),
10599 TEST_CASE_ST(ut_setup, ut_teardown,
10600 test_authonly_mrvl_all),
10601 TEST_CASE_ST(ut_setup, ut_teardown,
10602 test_3DES_chain_mrvl_all),
10603 TEST_CASE_ST(ut_setup, ut_teardown,
10604 test_3DES_cipheronly_mrvl_all),
10606 /** Negative tests */
10607 TEST_CASE_ST(ut_setup, ut_teardown,
10608 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10609 TEST_CASE_ST(ut_setup, ut_teardown,
10610 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10611 TEST_CASE_ST(ut_setup, ut_teardown,
10612 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10613 TEST_CASE_ST(ut_setup, ut_teardown,
10614 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10616 TEST_CASES_END() /**< NULL terminate unit test array */
10620 static struct unit_test_suite cryptodev_ccp_testsuite = {
10621 .suite_name = "Crypto Device CCP Unit Test Suite",
10622 .setup = testsuite_setup,
10623 .teardown = testsuite_teardown,
10624 .unit_test_cases = {
10625 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10626 TEST_CASE_ST(ut_setup, ut_teardown,
10627 test_multi_session_random_usage),
10628 TEST_CASE_ST(ut_setup, ut_teardown,
10629 test_AES_chain_ccp_all),
10630 TEST_CASE_ST(ut_setup, ut_teardown,
10631 test_AES_cipheronly_ccp_all),
10632 TEST_CASE_ST(ut_setup, ut_teardown,
10633 test_3DES_chain_ccp_all),
10634 TEST_CASE_ST(ut_setup, ut_teardown,
10635 test_3DES_cipheronly_ccp_all),
10636 TEST_CASE_ST(ut_setup, ut_teardown,
10637 test_authonly_ccp_all),
10639 /** Negative tests */
10640 TEST_CASE_ST(ut_setup, ut_teardown,
10641 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10642 TEST_CASE_ST(ut_setup, ut_teardown,
10643 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10644 TEST_CASE_ST(ut_setup, ut_teardown,
10645 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10646 TEST_CASE_ST(ut_setup, ut_teardown,
10647 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10649 TEST_CASES_END() /**< NULL terminate unit test array */
10653 static struct unit_test_suite cryptodev_octeontx_testsuite = {
10654 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
10655 .setup = testsuite_setup,
10656 .teardown = testsuite_teardown,
10657 .unit_test_cases = {
10658 TEST_CASE_ST(ut_setup, ut_teardown,
10659 test_AES_chain_octeontx_all),
10660 TEST_CASE_ST(ut_setup, ut_teardown,
10661 test_AES_cipheronly_octeontx_all),
10662 TEST_CASE_ST(ut_setup, ut_teardown,
10663 test_3DES_chain_octeontx_all),
10664 TEST_CASE_ST(ut_setup, ut_teardown,
10665 test_3DES_cipheronly_octeontx_all),
10666 TEST_CASE_ST(ut_setup, ut_teardown,
10667 test_authonly_octeontx_all),
10669 /** AES GCM Authenticated Encryption */
10670 TEST_CASE_ST(ut_setup, ut_teardown,
10671 test_AES_GCM_authenticated_encryption_test_case_1),
10672 TEST_CASE_ST(ut_setup, ut_teardown,
10673 test_AES_GCM_authenticated_encryption_test_case_2),
10674 TEST_CASE_ST(ut_setup, ut_teardown,
10675 test_AES_GCM_authenticated_encryption_test_case_3),
10676 TEST_CASE_ST(ut_setup, ut_teardown,
10677 test_AES_GCM_authenticated_encryption_test_case_4),
10678 TEST_CASE_ST(ut_setup, ut_teardown,
10679 test_AES_GCM_authenticated_encryption_test_case_5),
10680 TEST_CASE_ST(ut_setup, ut_teardown,
10681 test_AES_GCM_authenticated_encryption_test_case_6),
10682 TEST_CASE_ST(ut_setup, ut_teardown,
10683 test_AES_GCM_authenticated_encryption_test_case_7),
10685 /** AES GCM Authenticated Decryption */
10686 TEST_CASE_ST(ut_setup, ut_teardown,
10687 test_AES_GCM_authenticated_decryption_test_case_1),
10688 TEST_CASE_ST(ut_setup, ut_teardown,
10689 test_AES_GCM_authenticated_decryption_test_case_2),
10690 TEST_CASE_ST(ut_setup, ut_teardown,
10691 test_AES_GCM_authenticated_decryption_test_case_3),
10692 TEST_CASE_ST(ut_setup, ut_teardown,
10693 test_AES_GCM_authenticated_decryption_test_case_4),
10694 TEST_CASE_ST(ut_setup, ut_teardown,
10695 test_AES_GCM_authenticated_decryption_test_case_5),
10696 TEST_CASE_ST(ut_setup, ut_teardown,
10697 test_AES_GCM_authenticated_decryption_test_case_6),
10698 TEST_CASE_ST(ut_setup, ut_teardown,
10699 test_AES_GCM_authenticated_decryption_test_case_7),
10700 /** AES GMAC Authentication */
10701 TEST_CASE_ST(ut_setup, ut_teardown,
10702 test_AES_GMAC_authentication_test_case_1),
10703 TEST_CASE_ST(ut_setup, ut_teardown,
10704 test_AES_GMAC_authentication_verify_test_case_1),
10705 TEST_CASE_ST(ut_setup, ut_teardown,
10706 test_AES_GMAC_authentication_test_case_2),
10707 TEST_CASE_ST(ut_setup, ut_teardown,
10708 test_AES_GMAC_authentication_verify_test_case_2),
10709 TEST_CASE_ST(ut_setup, ut_teardown,
10710 test_AES_GMAC_authentication_test_case_3),
10711 TEST_CASE_ST(ut_setup, ut_teardown,
10712 test_AES_GMAC_authentication_verify_test_case_3),
10714 /** SNOW 3G encrypt only (UEA2) */
10715 TEST_CASE_ST(ut_setup, ut_teardown,
10716 test_snow3g_encryption_test_case_1),
10717 TEST_CASE_ST(ut_setup, ut_teardown,
10718 test_snow3g_encryption_test_case_2),
10719 TEST_CASE_ST(ut_setup, ut_teardown,
10720 test_snow3g_encryption_test_case_3),
10721 TEST_CASE_ST(ut_setup, ut_teardown,
10722 test_snow3g_encryption_test_case_4),
10723 TEST_CASE_ST(ut_setup, ut_teardown,
10724 test_snow3g_encryption_test_case_5),
10726 TEST_CASE_ST(ut_setup, ut_teardown,
10727 test_snow3g_encryption_test_case_1_oop),
10728 TEST_CASE_ST(ut_setup, ut_teardown,
10729 test_snow3g_decryption_test_case_1_oop),
10730 TEST_CASE_ST(ut_setup, ut_teardown,
10731 test_snow3g_encryption_test_case_1_oop_sgl),
10733 /** SNOW 3G decrypt only (UEA2) */
10734 TEST_CASE_ST(ut_setup, ut_teardown,
10735 test_snow3g_decryption_test_case_1),
10736 TEST_CASE_ST(ut_setup, ut_teardown,
10737 test_snow3g_decryption_test_case_2),
10738 TEST_CASE_ST(ut_setup, ut_teardown,
10739 test_snow3g_decryption_test_case_3),
10740 TEST_CASE_ST(ut_setup, ut_teardown,
10741 test_snow3g_decryption_test_case_4),
10742 TEST_CASE_ST(ut_setup, ut_teardown,
10743 test_snow3g_decryption_test_case_5),
10745 TEST_CASE_ST(ut_setup, ut_teardown,
10746 test_snow3g_hash_generate_test_case_1),
10747 TEST_CASE_ST(ut_setup, ut_teardown,
10748 test_snow3g_hash_generate_test_case_2),
10749 TEST_CASE_ST(ut_setup, ut_teardown,
10750 test_snow3g_hash_generate_test_case_3),
10751 TEST_CASE_ST(ut_setup, ut_teardown,
10752 test_snow3g_hash_verify_test_case_1),
10753 TEST_CASE_ST(ut_setup, ut_teardown,
10754 test_snow3g_hash_verify_test_case_2),
10755 TEST_CASE_ST(ut_setup, ut_teardown,
10756 test_snow3g_hash_verify_test_case_3),
10758 /** ZUC encrypt only (EEA3) */
10759 TEST_CASE_ST(ut_setup, ut_teardown,
10760 test_zuc_encryption_test_case_1),
10761 TEST_CASE_ST(ut_setup, ut_teardown,
10762 test_zuc_encryption_test_case_2),
10763 TEST_CASE_ST(ut_setup, ut_teardown,
10764 test_zuc_encryption_test_case_3),
10765 TEST_CASE_ST(ut_setup, ut_teardown,
10766 test_zuc_encryption_test_case_4),
10767 TEST_CASE_ST(ut_setup, ut_teardown,
10768 test_zuc_encryption_test_case_5),
10769 TEST_CASE_ST(ut_setup, ut_teardown,
10770 test_zuc_hash_generate_test_case_1),
10771 TEST_CASE_ST(ut_setup, ut_teardown,
10772 test_zuc_hash_generate_test_case_2),
10773 TEST_CASE_ST(ut_setup, ut_teardown,
10774 test_zuc_hash_generate_test_case_3),
10775 TEST_CASE_ST(ut_setup, ut_teardown,
10776 test_zuc_hash_generate_test_case_4),
10777 TEST_CASE_ST(ut_setup, ut_teardown,
10778 test_zuc_hash_generate_test_case_5),
10779 TEST_CASE_ST(ut_setup, ut_teardown,
10780 test_zuc_encryption_test_case_6_sgl),
10782 /** KASUMI encrypt only (UEA1) */
10783 TEST_CASE_ST(ut_setup, ut_teardown,
10784 test_kasumi_encryption_test_case_1),
10785 TEST_CASE_ST(ut_setup, ut_teardown,
10786 test_kasumi_encryption_test_case_2),
10787 TEST_CASE_ST(ut_setup, ut_teardown,
10788 test_kasumi_encryption_test_case_3),
10789 TEST_CASE_ST(ut_setup, ut_teardown,
10790 test_kasumi_encryption_test_case_4),
10791 TEST_CASE_ST(ut_setup, ut_teardown,
10792 test_kasumi_encryption_test_case_5),
10793 TEST_CASE_ST(ut_setup, ut_teardown,
10794 test_kasumi_encryption_test_case_1_sgl),
10795 TEST_CASE_ST(ut_setup, ut_teardown,
10796 test_kasumi_encryption_test_case_1_oop_sgl),
10797 /** KASUMI decrypt only (UEA1) */
10798 TEST_CASE_ST(ut_setup, ut_teardown,
10799 test_kasumi_decryption_test_case_1),
10800 TEST_CASE_ST(ut_setup, ut_teardown,
10801 test_kasumi_decryption_test_case_2),
10802 TEST_CASE_ST(ut_setup, ut_teardown,
10803 test_kasumi_decryption_test_case_3),
10804 TEST_CASE_ST(ut_setup, ut_teardown,
10805 test_kasumi_decryption_test_case_4),
10806 TEST_CASE_ST(ut_setup, ut_teardown,
10807 test_kasumi_decryption_test_case_5),
10809 TEST_CASE_ST(ut_setup, ut_teardown,
10810 test_kasumi_encryption_test_case_1_oop),
10811 TEST_CASE_ST(ut_setup, ut_teardown,
10812 test_kasumi_decryption_test_case_1_oop),
10814 /** KASUMI hash only (UIA1) */
10815 TEST_CASE_ST(ut_setup, ut_teardown,
10816 test_kasumi_hash_generate_test_case_1),
10817 TEST_CASE_ST(ut_setup, ut_teardown,
10818 test_kasumi_hash_generate_test_case_2),
10819 TEST_CASE_ST(ut_setup, ut_teardown,
10820 test_kasumi_hash_generate_test_case_3),
10821 TEST_CASE_ST(ut_setup, ut_teardown,
10822 test_kasumi_hash_generate_test_case_4),
10823 TEST_CASE_ST(ut_setup, ut_teardown,
10824 test_kasumi_hash_generate_test_case_5),
10825 TEST_CASE_ST(ut_setup, ut_teardown,
10826 test_kasumi_hash_generate_test_case_6),
10827 TEST_CASE_ST(ut_setup, ut_teardown,
10828 test_kasumi_hash_verify_test_case_1),
10829 TEST_CASE_ST(ut_setup, ut_teardown,
10830 test_kasumi_hash_verify_test_case_2),
10831 TEST_CASE_ST(ut_setup, ut_teardown,
10832 test_kasumi_hash_verify_test_case_3),
10833 TEST_CASE_ST(ut_setup, ut_teardown,
10834 test_kasumi_hash_verify_test_case_4),
10835 TEST_CASE_ST(ut_setup, ut_teardown,
10836 test_kasumi_hash_verify_test_case_5),
10839 TEST_CASE_ST(ut_setup, ut_teardown,
10840 test_null_cipher_only_operation),
10841 TEST_CASE_ST(ut_setup, ut_teardown,
10842 test_null_auth_only_operation),
10843 TEST_CASE_ST(ut_setup, ut_teardown,
10844 test_null_cipher_auth_operation),
10845 TEST_CASE_ST(ut_setup, ut_teardown,
10846 test_null_auth_cipher_operation),
10848 /** Negative tests */
10849 TEST_CASE_ST(ut_setup, ut_teardown,
10850 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10851 TEST_CASE_ST(ut_setup, ut_teardown,
10852 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10853 TEST_CASE_ST(ut_setup, ut_teardown,
10854 authentication_verify_AES128_GMAC_fail_data_corrupt),
10855 TEST_CASE_ST(ut_setup, ut_teardown,
10856 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10857 TEST_CASE_ST(ut_setup, ut_teardown,
10858 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10859 TEST_CASE_ST(ut_setup, ut_teardown,
10860 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10861 TEST_CASES_END() /**< NULL terminate unit test array */
10866 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
10868 gbl_driver_id = rte_cryptodev_driver_id_get(
10869 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
10871 if (gbl_driver_id == -1) {
10872 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
10873 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
10874 "are enabled in config file to run this testsuite.\n");
10875 return TEST_SKIPPED;
10878 return unit_test_suite_runner(&cryptodev_qat_testsuite);
10882 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
10884 gbl_driver_id = rte_cryptodev_driver_id_get(
10885 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
10887 if (gbl_driver_id == -1) {
10888 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
10889 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
10890 "in config file to run this testsuite.\n");
10891 return TEST_FAILED;
10894 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
10898 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
10900 gbl_driver_id = rte_cryptodev_driver_id_get(
10901 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10903 if (gbl_driver_id == -1) {
10904 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
10905 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
10906 "in config file to run this testsuite.\n");
10907 return TEST_SKIPPED;
10910 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10914 test_cryptodev_openssl(void)
10916 gbl_driver_id = rte_cryptodev_driver_id_get(
10917 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10919 if (gbl_driver_id == -1) {
10920 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10921 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10922 "in config file to run this testsuite.\n");
10923 return TEST_SKIPPED;
10926 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10930 test_cryptodev_aesni_gcm(void)
10932 gbl_driver_id = rte_cryptodev_driver_id_get(
10933 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10935 if (gbl_driver_id == -1) {
10936 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10937 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10938 "in config file to run this testsuite.\n");
10939 return TEST_SKIPPED;
10942 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10946 test_cryptodev_null(void)
10948 gbl_driver_id = rte_cryptodev_driver_id_get(
10949 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10951 if (gbl_driver_id == -1) {
10952 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10953 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10954 "in config file to run this testsuite.\n");
10955 return TEST_SKIPPED;
10958 return unit_test_suite_runner(&cryptodev_null_testsuite);
10962 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10964 gbl_driver_id = rte_cryptodev_driver_id_get(
10965 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10967 if (gbl_driver_id == -1) {
10968 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10969 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10970 "in config file to run this testsuite.\n");
10971 return TEST_SKIPPED;
10974 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10978 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10980 gbl_driver_id = rte_cryptodev_driver_id_get(
10981 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10983 if (gbl_driver_id == -1) {
10984 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10985 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10986 "in config file to run this testsuite.\n");
10987 return TEST_SKIPPED;
10990 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10994 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10996 gbl_driver_id = rte_cryptodev_driver_id_get(
10997 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10999 if (gbl_driver_id == -1) {
11000 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
11001 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
11002 "in config file to run this testsuite.\n");
11003 return TEST_SKIPPED;
11006 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
11010 test_cryptodev_armv8(void)
11012 gbl_driver_id = rte_cryptodev_driver_id_get(
11013 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
11015 if (gbl_driver_id == -1) {
11016 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
11017 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
11018 "in config file to run this testsuite.\n");
11019 return TEST_SKIPPED;
11022 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
11026 test_cryptodev_mrvl(void)
11028 gbl_driver_id = rte_cryptodev_driver_id_get(
11029 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
11031 if (gbl_driver_id == -1) {
11032 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
11033 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
11034 "in config file to run this testsuite.\n");
11035 return TEST_SKIPPED;
11038 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
11041 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11044 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
11046 gbl_driver_id = rte_cryptodev_driver_id_get(
11047 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
11049 if (gbl_driver_id == -1) {
11050 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
11051 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
11052 "in config file to run this testsuite.\n");
11053 return TEST_SKIPPED;
11056 if (rte_cryptodev_driver_id_get(
11057 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
11058 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
11059 " enabled in config file to run this testsuite.\n");
11060 return TEST_SKIPPED;
11062 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
11065 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
11070 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
11072 gbl_driver_id = rte_cryptodev_driver_id_get(
11073 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
11075 if (gbl_driver_id == -1) {
11076 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
11077 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
11078 "in config file to run this testsuite.\n");
11079 return TEST_SKIPPED;
11082 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
11086 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
11088 gbl_driver_id = rte_cryptodev_driver_id_get(
11089 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
11091 if (gbl_driver_id == -1) {
11092 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
11093 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
11094 "in config file to run this testsuite.\n");
11095 return TEST_SKIPPED;
11098 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
11102 test_cryptodev_ccp(void)
11104 gbl_driver_id = rte_cryptodev_driver_id_get(
11105 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
11107 if (gbl_driver_id == -1) {
11108 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
11109 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
11110 "in config file to run this testsuite.\n");
11111 return TEST_FAILED;
11114 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
11118 test_cryptodev_octeontx(void)
11120 gbl_driver_id = rte_cryptodev_driver_id_get(
11121 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
11122 if (gbl_driver_id == -1) {
11123 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
11124 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
11125 "enabled in config file to run this "
11127 return TEST_FAILED;
11129 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
11133 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
11135 gbl_driver_id = rte_cryptodev_driver_id_get(
11136 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
11138 if (gbl_driver_id == -1) {
11139 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
11140 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
11141 "in config file to run this testsuite.\n");
11142 return TEST_FAILED;
11145 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
11148 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
11149 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
11150 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
11151 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
11152 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
11153 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
11154 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
11155 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
11156 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
11157 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
11158 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
11159 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
11160 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
11161 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
11162 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
11163 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);