1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 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"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
51 #define OUT_OF_PLACE 1
53 static int gbl_driver_id;
55 static enum rte_security_session_action_type gbl_action_type =
56 RTE_SECURITY_ACTION_TYPE_NONE;
58 struct crypto_testsuite_params {
59 struct rte_mempool *mbuf_pool;
60 struct rte_mempool *large_mbuf_pool;
61 struct rte_mempool *op_mpool;
62 struct rte_mempool *session_mpool;
63 struct rte_mempool *session_priv_mpool;
64 struct rte_cryptodev_config conf;
65 struct rte_cryptodev_qp_conf qp_conf;
67 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
68 uint8_t valid_dev_count;
71 struct crypto_unittest_params {
72 struct rte_crypto_sym_xform cipher_xform;
73 struct rte_crypto_sym_xform auth_xform;
74 struct rte_crypto_sym_xform aead_xform;
77 struct rte_cryptodev_sym_session *sess;
78 #ifdef RTE_LIBRTE_SECURITY
79 struct rte_security_session *sec_session;
82 #ifdef RTE_LIBRTE_SECURITY
83 enum rte_security_session_action_type type;
85 struct rte_crypto_op *op;
87 struct rte_mbuf *obuf, *ibuf;
92 #define ALIGN_POW2_ROUNDUP(num, align) \
93 (((num) + (align) - 1) & ~((align) - 1))
96 * Forward declarations.
99 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
100 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
104 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
105 struct crypto_unittest_params *ut_params,
106 struct crypto_testsuite_params *ts_param,
107 const uint8_t *cipher,
108 const uint8_t *digest,
111 static struct rte_mbuf *
112 setup_test_string(struct rte_mempool *mpool,
113 const char *string, size_t len, uint8_t blocksize)
115 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
116 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
118 memset(m->buf_addr, 0, m->buf_len);
120 char *dst = rte_pktmbuf_append(m, t_len);
127 rte_memcpy(dst, string, t_len);
129 memset(dst, 0, t_len);
135 /* Get number of bytes in X bits (rounding up) */
137 ceil_byte_length(uint32_t num_bits)
140 return ((num_bits >> 3) + 1);
142 return (num_bits >> 3);
146 process_cpu_gmac_op(uint8_t dev_id, struct rte_crypto_op *op)
150 struct rte_crypto_sym_op *sop;
151 union rte_crypto_sym_ofs ofs;
152 struct rte_crypto_sgl sgl;
153 struct rte_crypto_sym_vec symvec;
154 struct rte_crypto_vec vec[UINT8_MAX];
158 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
159 sop->auth.data.length, vec, RTE_DIM(vec));
161 if (n < 0 || n != sop->m_src->nb_segs) {
162 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
169 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
172 symvec.digest = (void **)&sop->auth.digest.data;
178 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
182 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
184 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
189 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
193 struct rte_crypto_sym_op *sop;
194 union rte_crypto_sym_ofs ofs;
195 struct rte_crypto_sgl sgl;
196 struct rte_crypto_sym_vec symvec;
197 struct rte_crypto_vec vec[UINT8_MAX];
201 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
202 sop->aead.data.length, vec, RTE_DIM(vec));
204 if (n < 0 || n != sop->m_src->nb_segs) {
205 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
212 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
214 symvec.aad = (void **)&sop->aead.aad.data;
215 symvec.digest = (void **)&sop->aead.digest.data;
221 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
225 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
227 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
230 static struct rte_crypto_op *
231 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
234 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
236 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
237 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
243 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
246 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
247 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
254 static struct crypto_testsuite_params testsuite_params = { NULL };
255 static struct crypto_unittest_params unittest_params;
258 testsuite_setup(void)
260 struct crypto_testsuite_params *ts_params = &testsuite_params;
261 struct rte_cryptodev_info info;
262 uint32_t i = 0, nb_devs, dev_id;
266 memset(ts_params, 0, sizeof(*ts_params));
268 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
269 if (ts_params->mbuf_pool == NULL) {
270 /* Not already created so create */
271 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
273 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
275 if (ts_params->mbuf_pool == NULL) {
276 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
281 ts_params->large_mbuf_pool = rte_mempool_lookup(
282 "CRYPTO_LARGE_MBUFPOOL");
283 if (ts_params->large_mbuf_pool == NULL) {
284 /* Not already created so create */
285 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
286 "CRYPTO_LARGE_MBUFPOOL",
289 if (ts_params->large_mbuf_pool == NULL) {
291 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
296 ts_params->op_mpool = rte_crypto_op_pool_create(
297 "MBUF_CRYPTO_SYM_OP_POOL",
298 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
299 NUM_MBUFS, MBUF_CACHE_SIZE,
301 sizeof(struct rte_crypto_sym_xform) +
304 if (ts_params->op_mpool == NULL) {
305 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
309 /* Create an AESNI MB device if required */
310 if (gbl_driver_id == rte_cryptodev_driver_id_get(
311 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
312 nb_devs = rte_cryptodev_device_count_by_driver(
313 rte_cryptodev_driver_id_get(
314 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
317 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
319 TEST_ASSERT(ret == 0,
320 "Failed to create instance of"
322 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
326 /* Create an AESNI GCM device if required */
327 if (gbl_driver_id == rte_cryptodev_driver_id_get(
328 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
329 nb_devs = rte_cryptodev_device_count_by_driver(
330 rte_cryptodev_driver_id_get(
331 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
333 TEST_ASSERT_SUCCESS(rte_vdev_init(
334 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
335 "Failed to create instance of"
337 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
341 /* Create a SNOW 3G device if required */
342 if (gbl_driver_id == rte_cryptodev_driver_id_get(
343 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
344 nb_devs = rte_cryptodev_device_count_by_driver(
345 rte_cryptodev_driver_id_get(
346 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
348 TEST_ASSERT_SUCCESS(rte_vdev_init(
349 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
350 "Failed to create instance of"
352 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
356 /* Create a KASUMI device if required */
357 if (gbl_driver_id == rte_cryptodev_driver_id_get(
358 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
359 nb_devs = rte_cryptodev_device_count_by_driver(
360 rte_cryptodev_driver_id_get(
361 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
363 TEST_ASSERT_SUCCESS(rte_vdev_init(
364 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
365 "Failed to create instance of"
367 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
371 /* Create a ZUC device if required */
372 if (gbl_driver_id == rte_cryptodev_driver_id_get(
373 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
374 nb_devs = rte_cryptodev_device_count_by_driver(
375 rte_cryptodev_driver_id_get(
376 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
378 TEST_ASSERT_SUCCESS(rte_vdev_init(
379 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
380 "Failed to create instance of"
382 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
386 /* Create a NULL device if required */
387 if (gbl_driver_id == rte_cryptodev_driver_id_get(
388 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
389 nb_devs = rte_cryptodev_device_count_by_driver(
390 rte_cryptodev_driver_id_get(
391 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
394 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
396 TEST_ASSERT(ret == 0,
397 "Failed to create instance of"
399 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
403 /* Create an OPENSSL device if required */
404 if (gbl_driver_id == rte_cryptodev_driver_id_get(
405 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
406 nb_devs = rte_cryptodev_device_count_by_driver(
407 rte_cryptodev_driver_id_get(
408 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
411 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
414 TEST_ASSERT(ret == 0, "Failed to create "
415 "instance of pmd : %s",
416 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
420 /* Create a ARMv8 device if required */
421 if (gbl_driver_id == rte_cryptodev_driver_id_get(
422 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
423 nb_devs = rte_cryptodev_device_count_by_driver(
424 rte_cryptodev_driver_id_get(
425 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
428 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
431 TEST_ASSERT(ret == 0, "Failed to create "
432 "instance of pmd : %s",
433 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
437 /* Create a MVSAM device if required */
438 if (gbl_driver_id == rte_cryptodev_driver_id_get(
439 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
440 nb_devs = rte_cryptodev_device_count_by_driver(
441 rte_cryptodev_driver_id_get(
442 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
445 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
448 TEST_ASSERT(ret == 0, "Failed to create "
449 "instance of pmd : %s",
450 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
454 /* Create an CCP device if required */
455 if (gbl_driver_id == rte_cryptodev_driver_id_get(
456 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
457 nb_devs = rte_cryptodev_device_count_by_driver(
458 rte_cryptodev_driver_id_get(
459 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
462 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
465 TEST_ASSERT(ret == 0, "Failed to create "
466 "instance of pmd : %s",
467 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
471 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
472 char vdev_args[VDEV_ARGS_SIZE] = {""};
473 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
474 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
475 uint16_t slave_core_count = 0;
476 uint16_t socket_id = 0;
478 if (gbl_driver_id == rte_cryptodev_driver_id_get(
479 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
481 /* Identify the Slave Cores
482 * Use 2 slave cores for the device args
484 RTE_LCORE_FOREACH_SLAVE(i) {
485 if (slave_core_count > 1)
487 snprintf(vdev_args, sizeof(vdev_args),
488 "%s%d", temp_str, i);
489 strcpy(temp_str, vdev_args);
490 strlcat(temp_str, ";", sizeof(temp_str));
492 socket_id = rte_lcore_to_socket_id(i);
494 if (slave_core_count != 2) {
496 "Cryptodev scheduler test require at least "
497 "two slave cores to run. "
498 "Please use the correct coremask.\n");
501 strcpy(temp_str, vdev_args);
502 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
503 temp_str, socket_id);
504 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
505 nb_devs = rte_cryptodev_device_count_by_driver(
506 rte_cryptodev_driver_id_get(
507 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
510 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
512 TEST_ASSERT(ret == 0,
513 "Failed to create instance %u of"
515 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
518 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
520 nb_devs = rte_cryptodev_count();
522 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
526 /* Create list of valid crypto devs */
527 for (i = 0; i < nb_devs; i++) {
528 rte_cryptodev_info_get(i, &info);
529 if (info.driver_id == gbl_driver_id)
530 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
533 if (ts_params->valid_dev_count < 1)
536 /* Set up all the qps on the first of the valid devices found */
538 dev_id = ts_params->valid_devs[0];
540 rte_cryptodev_info_get(dev_id, &info);
542 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
543 ts_params->conf.socket_id = SOCKET_ID_ANY;
544 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
546 unsigned int session_size =
547 rte_cryptodev_sym_get_private_session_size(dev_id);
550 * Create mempool with maximum number of sessions * 2,
551 * to include the session headers
553 if (info.sym.max_nb_sessions != 0 &&
554 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
555 RTE_LOG(ERR, USER1, "Device does not support "
556 "at least %u sessions\n",
561 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
562 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
564 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
565 "session mempool allocation failed");
567 ts_params->session_priv_mpool = rte_mempool_create(
571 0, 0, NULL, NULL, NULL,
574 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
575 "session mempool allocation failed");
579 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
581 "Failed to configure cryptodev %u with %u qps",
582 dev_id, ts_params->conf.nb_queue_pairs);
584 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
585 ts_params->qp_conf.mp_session = ts_params->session_mpool;
586 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
588 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
589 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
590 dev_id, qp_id, &ts_params->qp_conf,
591 rte_cryptodev_socket_id(dev_id)),
592 "Failed to setup queue pair %u on cryptodev %u",
600 testsuite_teardown(void)
602 struct crypto_testsuite_params *ts_params = &testsuite_params;
604 if (ts_params->mbuf_pool != NULL) {
605 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
606 rte_mempool_avail_count(ts_params->mbuf_pool));
609 if (ts_params->op_mpool != NULL) {
610 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
611 rte_mempool_avail_count(ts_params->op_mpool));
614 /* Free session mempools */
615 if (ts_params->session_priv_mpool != NULL) {
616 rte_mempool_free(ts_params->session_priv_mpool);
617 ts_params->session_priv_mpool = NULL;
620 if (ts_params->session_mpool != NULL) {
621 rte_mempool_free(ts_params->session_mpool);
622 ts_params->session_mpool = NULL;
629 struct crypto_testsuite_params *ts_params = &testsuite_params;
630 struct crypto_unittest_params *ut_params = &unittest_params;
634 /* Clear unit test parameters before running test */
635 memset(ut_params, 0, sizeof(*ut_params));
637 /* Reconfigure device to default parameters */
638 ts_params->conf.socket_id = SOCKET_ID_ANY;
639 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
640 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
641 ts_params->qp_conf.mp_session = ts_params->session_mpool;
642 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
644 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
646 "Failed to configure cryptodev %u",
647 ts_params->valid_devs[0]);
649 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
650 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
651 ts_params->valid_devs[0], qp_id,
653 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
654 "Failed to setup queue pair %u on cryptodev %u",
655 qp_id, ts_params->valid_devs[0]);
659 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
661 /* Start the device */
662 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
663 "Failed to start cryptodev %u",
664 ts_params->valid_devs[0]);
672 struct crypto_testsuite_params *ts_params = &testsuite_params;
673 struct crypto_unittest_params *ut_params = &unittest_params;
674 struct rte_cryptodev_stats stats;
676 /* free crypto session structure */
677 #ifdef RTE_LIBRTE_SECURITY
678 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
679 if (ut_params->sec_session) {
680 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
681 (ts_params->valid_devs[0]),
682 ut_params->sec_session);
683 ut_params->sec_session = NULL;
688 if (ut_params->sess) {
689 rte_cryptodev_sym_session_clear(
690 ts_params->valid_devs[0],
692 rte_cryptodev_sym_session_free(ut_params->sess);
693 ut_params->sess = NULL;
697 /* free crypto operation structure */
699 rte_crypto_op_free(ut_params->op);
702 * free mbuf - both obuf and ibuf are usually the same,
703 * so check if they point at the same address is necessary,
704 * to avoid freeing the mbuf twice.
706 if (ut_params->obuf) {
707 rte_pktmbuf_free(ut_params->obuf);
708 if (ut_params->ibuf == ut_params->obuf)
712 if (ut_params->ibuf) {
713 rte_pktmbuf_free(ut_params->ibuf);
717 if (ts_params->mbuf_pool != NULL)
718 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
719 rte_mempool_avail_count(ts_params->mbuf_pool));
721 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
723 /* Stop the device */
724 rte_cryptodev_stop(ts_params->valid_devs[0]);
728 test_device_configure_invalid_dev_id(void)
730 struct crypto_testsuite_params *ts_params = &testsuite_params;
731 uint16_t dev_id, num_devs = 0;
733 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
734 "Need at least %d devices for test", 1);
736 /* valid dev_id values */
737 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
739 /* Stop the device in case it's started so it can be configured */
740 rte_cryptodev_stop(dev_id);
742 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
743 "Failed test for rte_cryptodev_configure: "
744 "invalid dev_num %u", dev_id);
746 /* invalid dev_id values */
749 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
750 "Failed test for rte_cryptodev_configure: "
751 "invalid dev_num %u", dev_id);
755 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
756 "Failed test for rte_cryptodev_configure:"
757 "invalid dev_num %u", dev_id);
763 test_device_configure_invalid_queue_pair_ids(void)
765 struct crypto_testsuite_params *ts_params = &testsuite_params;
766 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
768 /* This test is for QAT and NITROX PMDs only */
769 if (gbl_driver_id != rte_cryptodev_driver_id_get(
770 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)) &&
771 gbl_driver_id != rte_cryptodev_driver_id_get(
772 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)))
775 /* Stop the device in case it's started so it can be configured */
776 rte_cryptodev_stop(ts_params->valid_devs[0]);
778 /* valid - one queue pairs */
779 ts_params->conf.nb_queue_pairs = 1;
781 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
783 "Failed to configure cryptodev: dev_id %u, qp_id %u",
784 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
787 /* valid - max value queue pairs */
788 ts_params->conf.nb_queue_pairs = orig_nb_qps;
790 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
792 "Failed to configure cryptodev: dev_id %u, qp_id %u",
793 ts_params->valid_devs[0],
794 ts_params->conf.nb_queue_pairs);
797 /* invalid - zero queue pairs */
798 ts_params->conf.nb_queue_pairs = 0;
800 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
802 "Failed test for rte_cryptodev_configure, dev_id %u,"
804 ts_params->valid_devs[0],
805 ts_params->conf.nb_queue_pairs);
808 /* invalid - max value supported by field queue pairs */
809 ts_params->conf.nb_queue_pairs = UINT16_MAX;
811 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
813 "Failed test for rte_cryptodev_configure, dev_id %u,"
815 ts_params->valid_devs[0],
816 ts_params->conf.nb_queue_pairs);
819 /* invalid - max value + 1 queue pairs */
820 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
822 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
824 "Failed test for rte_cryptodev_configure, dev_id %u,"
826 ts_params->valid_devs[0],
827 ts_params->conf.nb_queue_pairs);
829 /* revert to original testsuite value */
830 ts_params->conf.nb_queue_pairs = orig_nb_qps;
836 test_queue_pair_descriptor_setup(void)
838 struct crypto_testsuite_params *ts_params = &testsuite_params;
839 struct rte_cryptodev_info dev_info;
840 struct rte_cryptodev_qp_conf qp_conf = {
841 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
846 /* This test is for QAT PMD only */
847 if (gbl_driver_id != rte_cryptodev_driver_id_get(
848 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
851 /* Stop the device in case it's started so it can be configured */
852 rte_cryptodev_stop(ts_params->valid_devs[0]);
855 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
857 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
859 "Failed to configure cryptodev %u",
860 ts_params->valid_devs[0]);
863 * Test various ring sizes on this device. memzones can't be
864 * freed so are re-used if ring is released and re-created.
866 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
867 qp_conf.mp_session = ts_params->session_mpool;
868 qp_conf.mp_session_private = ts_params->session_priv_mpool;
870 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
871 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
872 ts_params->valid_devs[0], qp_id, &qp_conf,
873 rte_cryptodev_socket_id(
874 ts_params->valid_devs[0])),
876 "rte_cryptodev_queue_pair_setup: num_inflights "
877 "%u on qp %u on cryptodev %u",
878 qp_conf.nb_descriptors, qp_id,
879 ts_params->valid_devs[0]);
882 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
884 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
885 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
886 ts_params->valid_devs[0], qp_id, &qp_conf,
887 rte_cryptodev_socket_id(
888 ts_params->valid_devs[0])),
890 " rte_cryptodev_queue_pair_setup: num_inflights"
891 " %u on qp %u on cryptodev %u",
892 qp_conf.nb_descriptors, qp_id,
893 ts_params->valid_devs[0]);
896 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
898 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
899 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
900 ts_params->valid_devs[0], qp_id, &qp_conf,
901 rte_cryptodev_socket_id(
902 ts_params->valid_devs[0])),
904 "rte_cryptodev_queue_pair_setup: num_inflights"
905 " %u on qp %u on cryptodev %u",
906 qp_conf.nb_descriptors, qp_id,
907 ts_params->valid_devs[0]);
910 /* invalid number of descriptors - max supported + 2 */
911 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
913 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
914 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
915 ts_params->valid_devs[0], qp_id, &qp_conf,
916 rte_cryptodev_socket_id(
917 ts_params->valid_devs[0])),
918 "Unexpectedly passed test for "
919 "rte_cryptodev_queue_pair_setup:"
920 "num_inflights %u on qp %u on cryptodev %u",
921 qp_conf.nb_descriptors, qp_id,
922 ts_params->valid_devs[0]);
925 /* invalid number of descriptors - max value of parameter */
926 qp_conf.nb_descriptors = UINT32_MAX-1;
928 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
929 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
930 ts_params->valid_devs[0], qp_id, &qp_conf,
931 rte_cryptodev_socket_id(
932 ts_params->valid_devs[0])),
933 "Unexpectedly passed test for "
934 "rte_cryptodev_queue_pair_setup:"
935 "num_inflights %u on qp %u on cryptodev %u",
936 qp_conf.nb_descriptors, qp_id,
937 ts_params->valid_devs[0]);
940 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
942 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
943 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
944 ts_params->valid_devs[0], qp_id, &qp_conf,
945 rte_cryptodev_socket_id(
946 ts_params->valid_devs[0])),
948 " rte_cryptodev_queue_pair_setup:"
949 "num_inflights %u on qp %u on cryptodev %u",
950 qp_conf.nb_descriptors, qp_id,
951 ts_params->valid_devs[0]);
954 /* invalid number of descriptors - max supported + 1 */
955 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
957 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
958 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
959 ts_params->valid_devs[0], qp_id, &qp_conf,
960 rte_cryptodev_socket_id(
961 ts_params->valid_devs[0])),
962 "Unexpectedly passed test for "
963 "rte_cryptodev_queue_pair_setup:"
964 "num_inflights %u on qp %u on cryptodev %u",
965 qp_conf.nb_descriptors, qp_id,
966 ts_params->valid_devs[0]);
969 /* test invalid queue pair id */
970 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
972 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
974 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
975 ts_params->valid_devs[0],
977 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
978 "Failed test for rte_cryptodev_queue_pair_setup:"
979 "invalid qp %u on cryptodev %u",
980 qp_id, ts_params->valid_devs[0]);
982 qp_id = 0xffff; /*invalid*/
984 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
985 ts_params->valid_devs[0],
987 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
988 "Failed test for rte_cryptodev_queue_pair_setup:"
989 "invalid qp %u on cryptodev %u",
990 qp_id, ts_params->valid_devs[0]);
995 /* ***** Plaintext data for tests ***** */
997 const char catch_22_quote_1[] =
998 "There was only one catch and that was Catch-22, which "
999 "specified that a concern for one's safety in the face of "
1000 "dangers that were real and immediate was the process of a "
1001 "rational mind. Orr was crazy and could be grounded. All he "
1002 "had to do was ask; and as soon as he did, he would no longer "
1003 "be crazy and would have to fly more missions. Orr would be "
1004 "crazy to fly more missions and sane if he didn't, but if he "
1005 "was sane he had to fly them. If he flew them he was crazy "
1006 "and didn't have to; but if he didn't want to he was sane and "
1007 "had to. Yossarian was moved very deeply by the absolute "
1008 "simplicity of this clause of Catch-22 and let out a "
1009 "respectful whistle. \"That's some catch, that Catch-22\", he "
1010 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1012 const char catch_22_quote[] =
1013 "What a lousy earth! He wondered how many people were "
1014 "destitute that same night even in his own prosperous country, "
1015 "how many homes were shanties, how many husbands were drunk "
1016 "and wives socked, and how many children were bullied, abused, "
1017 "or abandoned. How many families hungered for food they could "
1018 "not afford to buy? How many hearts were broken? How many "
1019 "suicides would take place that same night, how many people "
1020 "would go insane? How many cockroaches and landlords would "
1021 "triumph? How many winners were losers, successes failures, "
1022 "and rich men poor men? How many wise guys were stupid? How "
1023 "many happy endings were unhappy endings? How many honest men "
1024 "were liars, brave men cowards, loyal men traitors, how many "
1025 "sainted men were corrupt, how many people in positions of "
1026 "trust had sold their souls to bodyguards, how many had never "
1027 "had souls? How many straight-and-narrow paths were crooked "
1028 "paths? How many best families were worst families and how "
1029 "many good people were bad people? When you added them all up "
1030 "and then subtracted, you might be left with only the children, "
1031 "and perhaps with Albert Einstein and an old violinist or "
1032 "sculptor somewhere.";
1034 #define QUOTE_480_BYTES (480)
1035 #define QUOTE_512_BYTES (512)
1036 #define QUOTE_768_BYTES (768)
1037 #define QUOTE_1024_BYTES (1024)
1041 /* ***** SHA1 Hash Tests ***** */
1043 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1045 static uint8_t hmac_sha1_key[] = {
1046 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1047 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1048 0xDE, 0xF4, 0xDE, 0xAD };
1050 /* ***** SHA224 Hash Tests ***** */
1052 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1055 /* ***** AES-CBC Cipher Tests ***** */
1057 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1058 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1060 static uint8_t aes_cbc_key[] = {
1061 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1062 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1064 static uint8_t aes_cbc_iv[] = {
1065 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1066 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1069 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1071 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1072 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1073 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1074 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1075 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1076 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1077 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1078 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1079 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1080 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1081 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1082 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1083 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1084 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1085 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1086 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1087 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1088 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1089 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1090 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1091 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1092 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1093 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1094 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1095 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1096 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1097 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1098 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1099 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1100 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1101 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1102 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1103 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1104 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1105 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1106 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1107 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1108 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1109 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1110 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1111 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1112 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1113 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1114 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1115 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1116 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1117 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1118 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1119 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1120 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1121 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1122 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1123 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1124 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1125 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1126 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1127 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1128 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1129 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1130 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1131 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1132 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1133 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1134 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1135 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1138 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1139 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1140 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1141 0x18, 0x8c, 0x1d, 0x32
1145 /* Multisession Vector context Test */
1146 /*Begin Session 0 */
1147 static uint8_t ms_aes_cbc_key0[] = {
1148 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1149 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1152 static uint8_t ms_aes_cbc_iv0[] = {
1153 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1154 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1157 static const uint8_t ms_aes_cbc_cipher0[] = {
1158 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1159 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1160 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1161 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1162 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1163 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1164 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1165 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1166 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1167 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1168 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1169 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1170 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1171 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1172 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1173 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1174 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1175 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1176 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1177 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1178 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1179 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1180 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1181 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1182 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1183 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1184 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1185 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1186 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1187 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1188 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1189 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1190 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1191 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1192 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1193 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1194 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1195 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1196 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1197 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1198 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1199 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1200 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1201 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1202 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1203 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1204 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1205 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1206 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1207 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1208 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1209 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1210 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1211 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1212 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1213 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1214 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1215 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1216 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1217 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1218 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1219 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1220 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1221 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1225 static uint8_t ms_hmac_key0[] = {
1226 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1227 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1228 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1229 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1230 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1231 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1232 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1233 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1236 static const uint8_t ms_hmac_digest0[] = {
1237 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1238 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1239 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1240 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1241 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1242 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1243 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1244 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1248 /* Begin session 1 */
1250 static uint8_t ms_aes_cbc_key1[] = {
1251 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1252 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1255 static uint8_t ms_aes_cbc_iv1[] = {
1256 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1257 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1260 static const uint8_t ms_aes_cbc_cipher1[] = {
1261 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1262 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1263 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1264 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1265 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1266 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1267 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1268 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1269 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1270 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1271 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1272 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1273 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1274 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1275 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1276 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1277 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1278 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1279 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1280 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1281 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1282 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1283 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1284 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1285 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1286 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1287 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1288 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1289 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1290 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1291 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1292 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1293 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1294 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1295 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1296 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1297 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1298 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1299 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1300 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1301 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1302 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1303 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1304 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1305 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1306 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1307 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1308 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1309 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1310 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1311 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1312 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1313 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1314 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1315 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1316 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1317 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1318 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1319 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1320 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1321 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1322 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1323 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1324 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1328 static uint8_t ms_hmac_key1[] = {
1329 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1330 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1331 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1332 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1333 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1334 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1335 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1336 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1339 static const uint8_t ms_hmac_digest1[] = {
1340 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1341 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1342 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1343 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1344 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1345 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1346 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1347 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1350 /* Begin Session 2 */
1351 static uint8_t ms_aes_cbc_key2[] = {
1352 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1353 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1356 static uint8_t ms_aes_cbc_iv2[] = {
1357 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1358 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1361 static const uint8_t ms_aes_cbc_cipher2[] = {
1362 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1363 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1364 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1365 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1366 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1367 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1368 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1369 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1370 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1371 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1372 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1373 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1374 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1375 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1376 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1377 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1378 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1379 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1380 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1381 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1382 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1383 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1384 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1385 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1386 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1387 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1388 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1389 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1390 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1391 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1392 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1393 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1394 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1395 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1396 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1397 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1398 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1399 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1400 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1401 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1402 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1403 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1404 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1405 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1406 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1407 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1408 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1409 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1410 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1411 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1412 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1413 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1414 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1415 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1416 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1417 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1418 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1419 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1420 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1421 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1422 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1423 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1424 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1425 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1428 static uint8_t ms_hmac_key2[] = {
1429 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1430 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1431 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1432 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1433 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1434 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1435 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1436 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1439 static const uint8_t ms_hmac_digest2[] = {
1440 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1441 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1442 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1443 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1444 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1445 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1446 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1447 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1454 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1456 struct crypto_testsuite_params *ts_params = &testsuite_params;
1457 struct crypto_unittest_params *ut_params = &unittest_params;
1459 /* Verify the capabilities */
1460 struct rte_cryptodev_sym_capability_idx cap_idx;
1461 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1462 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1463 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1466 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1467 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1468 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1472 /* Generate test mbuf data and space for digest */
1473 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1474 catch_22_quote, QUOTE_512_BYTES, 0);
1476 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1477 DIGEST_BYTE_LENGTH_SHA1);
1478 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1480 /* Setup Cipher Parameters */
1481 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1482 ut_params->cipher_xform.next = &ut_params->auth_xform;
1484 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1485 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1486 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1487 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1488 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1489 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1491 /* Setup HMAC Parameters */
1492 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1494 ut_params->auth_xform.next = NULL;
1496 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1497 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1498 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1499 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1500 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1502 ut_params->sess = rte_cryptodev_sym_session_create(
1503 ts_params->session_mpool);
1505 /* Create crypto session*/
1506 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1507 ut_params->sess, &ut_params->cipher_xform,
1508 ts_params->session_priv_mpool);
1509 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1511 /* Generate crypto op data structure */
1512 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1513 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1514 TEST_ASSERT_NOT_NULL(ut_params->op,
1515 "Failed to allocate symmetric crypto operation struct");
1517 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1519 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1521 /* set crypto operation source mbuf */
1522 sym_op->m_src = ut_params->ibuf;
1524 /* Set crypto operation authentication parameters */
1525 sym_op->auth.digest.data = ut_params->digest;
1526 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1527 ut_params->ibuf, QUOTE_512_BYTES);
1529 sym_op->auth.data.offset = 0;
1530 sym_op->auth.data.length = QUOTE_512_BYTES;
1532 /* Copy IV at the end of the crypto operation */
1533 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1534 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1536 /* Set crypto operation cipher parameters */
1537 sym_op->cipher.data.offset = 0;
1538 sym_op->cipher.data.length = QUOTE_512_BYTES;
1540 /* Process crypto operation */
1541 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1542 ut_params->op), "failed to process sym crypto op");
1544 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1545 "crypto op processing failed");
1548 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1551 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1552 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1554 "ciphertext data not as expected");
1556 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1558 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1559 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1560 gbl_driver_id == rte_cryptodev_driver_id_get(
1561 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1562 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1563 DIGEST_BYTE_LENGTH_SHA1,
1564 "Generated digest data not as expected");
1566 return TEST_SUCCESS;
1569 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1571 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1573 static uint8_t hmac_sha512_key[] = {
1574 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1575 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1576 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1577 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1578 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1579 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1580 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1581 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1583 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1584 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1585 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1586 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1587 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1588 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1589 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1590 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1591 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1596 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1597 struct crypto_unittest_params *ut_params,
1598 uint8_t *cipher_key,
1602 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1603 struct crypto_unittest_params *ut_params,
1604 struct crypto_testsuite_params *ts_params,
1605 const uint8_t *cipher,
1606 const uint8_t *digest,
1611 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1612 struct crypto_unittest_params *ut_params,
1613 uint8_t *cipher_key,
1617 /* Setup Cipher Parameters */
1618 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1619 ut_params->cipher_xform.next = NULL;
1621 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1622 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1623 ut_params->cipher_xform.cipher.key.data = cipher_key;
1624 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1625 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1626 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1628 /* Setup HMAC Parameters */
1629 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1630 ut_params->auth_xform.next = &ut_params->cipher_xform;
1632 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1633 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1634 ut_params->auth_xform.auth.key.data = hmac_key;
1635 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1636 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1638 return TEST_SUCCESS;
1643 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1644 struct crypto_unittest_params *ut_params,
1645 struct crypto_testsuite_params *ts_params,
1646 const uint8_t *cipher,
1647 const uint8_t *digest,
1650 /* Generate test mbuf data and digest */
1651 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1654 QUOTE_512_BYTES, 0);
1656 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1657 DIGEST_BYTE_LENGTH_SHA512);
1658 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1660 rte_memcpy(ut_params->digest,
1662 DIGEST_BYTE_LENGTH_SHA512);
1664 /* Generate Crypto op data structure */
1665 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1666 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1667 TEST_ASSERT_NOT_NULL(ut_params->op,
1668 "Failed to allocate symmetric crypto operation struct");
1670 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1672 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1674 /* set crypto operation source mbuf */
1675 sym_op->m_src = ut_params->ibuf;
1677 sym_op->auth.digest.data = ut_params->digest;
1678 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1679 ut_params->ibuf, QUOTE_512_BYTES);
1681 sym_op->auth.data.offset = 0;
1682 sym_op->auth.data.length = QUOTE_512_BYTES;
1684 /* Copy IV at the end of the crypto operation */
1685 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1686 iv, CIPHER_IV_LENGTH_AES_CBC);
1688 sym_op->cipher.data.offset = 0;
1689 sym_op->cipher.data.length = QUOTE_512_BYTES;
1691 /* Process crypto operation */
1692 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1693 ut_params->op), "failed to process sym crypto op");
1695 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1696 "crypto op processing failed");
1698 ut_params->obuf = ut_params->op->sym->m_src;
1701 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1702 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1705 "Plaintext data not as expected");
1708 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1709 "Digest verification failed");
1711 return TEST_SUCCESS;
1715 test_blockcipher(enum blockcipher_test_type test_type)
1717 struct crypto_testsuite_params *ts_params = &testsuite_params;
1720 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1721 ts_params->op_mpool,
1722 ts_params->session_mpool, ts_params->session_priv_mpool,
1723 ts_params->valid_devs[0],
1727 if (status == -ENOTSUP)
1730 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1732 return TEST_SUCCESS;
1736 test_AES_cipheronly_all(void)
1738 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1742 test_AES_docsis_all(void)
1744 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1748 test_DES_docsis_all(void)
1750 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1754 test_DES_cipheronly_all(void)
1756 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1760 test_authonly_all(void)
1762 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1766 test_AES_chain_all(void)
1768 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1772 test_3DES_chain_all(void)
1774 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1778 test_3DES_cipheronly_all(void)
1780 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1783 /* ***** SNOW 3G Tests ***** */
1785 create_wireless_algo_hash_session(uint8_t dev_id,
1786 const uint8_t *key, const uint8_t key_len,
1787 const uint8_t iv_len, const uint8_t auth_len,
1788 enum rte_crypto_auth_operation op,
1789 enum rte_crypto_auth_algorithm algo)
1791 uint8_t hash_key[key_len];
1794 struct crypto_testsuite_params *ts_params = &testsuite_params;
1795 struct crypto_unittest_params *ut_params = &unittest_params;
1797 memcpy(hash_key, key, key_len);
1799 debug_hexdump(stdout, "key:", key, key_len);
1801 /* Setup Authentication Parameters */
1802 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1803 ut_params->auth_xform.next = NULL;
1805 ut_params->auth_xform.auth.op = op;
1806 ut_params->auth_xform.auth.algo = algo;
1807 ut_params->auth_xform.auth.key.length = key_len;
1808 ut_params->auth_xform.auth.key.data = hash_key;
1809 ut_params->auth_xform.auth.digest_length = auth_len;
1810 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1811 ut_params->auth_xform.auth.iv.length = iv_len;
1812 ut_params->sess = rte_cryptodev_sym_session_create(
1813 ts_params->session_mpool);
1815 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1816 &ut_params->auth_xform,
1817 ts_params->session_priv_mpool);
1818 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1819 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1824 create_wireless_algo_cipher_session(uint8_t dev_id,
1825 enum rte_crypto_cipher_operation op,
1826 enum rte_crypto_cipher_algorithm algo,
1827 const uint8_t *key, const uint8_t key_len,
1830 uint8_t cipher_key[key_len];
1832 struct crypto_testsuite_params *ts_params = &testsuite_params;
1833 struct crypto_unittest_params *ut_params = &unittest_params;
1835 memcpy(cipher_key, key, key_len);
1837 /* Setup Cipher Parameters */
1838 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1839 ut_params->cipher_xform.next = NULL;
1841 ut_params->cipher_xform.cipher.algo = algo;
1842 ut_params->cipher_xform.cipher.op = op;
1843 ut_params->cipher_xform.cipher.key.data = cipher_key;
1844 ut_params->cipher_xform.cipher.key.length = key_len;
1845 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1846 ut_params->cipher_xform.cipher.iv.length = iv_len;
1848 debug_hexdump(stdout, "key:", key, key_len);
1850 /* Create Crypto session */
1851 ut_params->sess = rte_cryptodev_sym_session_create(
1852 ts_params->session_mpool);
1854 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1855 &ut_params->cipher_xform,
1856 ts_params->session_priv_mpool);
1857 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1858 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1863 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1864 unsigned int cipher_len,
1865 unsigned int cipher_offset)
1867 struct crypto_testsuite_params *ts_params = &testsuite_params;
1868 struct crypto_unittest_params *ut_params = &unittest_params;
1870 /* Generate Crypto op data structure */
1871 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1872 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1873 TEST_ASSERT_NOT_NULL(ut_params->op,
1874 "Failed to allocate pktmbuf offload");
1876 /* Set crypto operation data parameters */
1877 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1879 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1881 /* set crypto operation source mbuf */
1882 sym_op->m_src = ut_params->ibuf;
1885 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1887 sym_op->cipher.data.length = cipher_len;
1888 sym_op->cipher.data.offset = cipher_offset;
1893 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1894 unsigned int cipher_len,
1895 unsigned int cipher_offset)
1897 struct crypto_testsuite_params *ts_params = &testsuite_params;
1898 struct crypto_unittest_params *ut_params = &unittest_params;
1900 /* Generate Crypto op data structure */
1901 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1902 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1903 TEST_ASSERT_NOT_NULL(ut_params->op,
1904 "Failed to allocate pktmbuf offload");
1906 /* Set crypto operation data parameters */
1907 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1909 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1911 /* set crypto operation source mbuf */
1912 sym_op->m_src = ut_params->ibuf;
1913 sym_op->m_dst = ut_params->obuf;
1916 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1918 sym_op->cipher.data.length = cipher_len;
1919 sym_op->cipher.data.offset = cipher_offset;
1924 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1925 enum rte_crypto_cipher_operation cipher_op,
1926 enum rte_crypto_auth_operation auth_op,
1927 enum rte_crypto_auth_algorithm auth_algo,
1928 enum rte_crypto_cipher_algorithm cipher_algo,
1929 const uint8_t *key, uint8_t key_len,
1930 uint8_t auth_iv_len, uint8_t auth_len,
1931 uint8_t cipher_iv_len)
1934 uint8_t cipher_auth_key[key_len];
1937 struct crypto_testsuite_params *ts_params = &testsuite_params;
1938 struct crypto_unittest_params *ut_params = &unittest_params;
1940 memcpy(cipher_auth_key, key, key_len);
1942 /* Setup Authentication Parameters */
1943 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1944 ut_params->auth_xform.next = NULL;
1946 ut_params->auth_xform.auth.op = auth_op;
1947 ut_params->auth_xform.auth.algo = auth_algo;
1948 ut_params->auth_xform.auth.key.length = key_len;
1949 /* Hash key = cipher key */
1950 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1951 ut_params->auth_xform.auth.digest_length = auth_len;
1952 /* Auth IV will be after cipher IV */
1953 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1954 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1956 /* Setup Cipher Parameters */
1957 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1958 ut_params->cipher_xform.next = &ut_params->auth_xform;
1960 ut_params->cipher_xform.cipher.algo = cipher_algo;
1961 ut_params->cipher_xform.cipher.op = cipher_op;
1962 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1963 ut_params->cipher_xform.cipher.key.length = key_len;
1964 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1965 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1967 debug_hexdump(stdout, "key:", key, key_len);
1969 /* Create Crypto session*/
1970 ut_params->sess = rte_cryptodev_sym_session_create(
1971 ts_params->session_mpool);
1972 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1974 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1975 &ut_params->cipher_xform,
1976 ts_params->session_priv_mpool);
1977 if (status == -ENOTSUP)
1980 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1985 create_wireless_cipher_auth_session(uint8_t dev_id,
1986 enum rte_crypto_cipher_operation cipher_op,
1987 enum rte_crypto_auth_operation auth_op,
1988 enum rte_crypto_auth_algorithm auth_algo,
1989 enum rte_crypto_cipher_algorithm cipher_algo,
1990 const struct wireless_test_data *tdata)
1992 const uint8_t key_len = tdata->key.len;
1993 uint8_t cipher_auth_key[key_len];
1996 struct crypto_testsuite_params *ts_params = &testsuite_params;
1997 struct crypto_unittest_params *ut_params = &unittest_params;
1998 const uint8_t *key = tdata->key.data;
1999 const uint8_t auth_len = tdata->digest.len;
2000 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2001 uint8_t auth_iv_len = tdata->auth_iv.len;
2003 memcpy(cipher_auth_key, key, key_len);
2005 /* Setup Authentication Parameters */
2006 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2007 ut_params->auth_xform.next = NULL;
2009 ut_params->auth_xform.auth.op = auth_op;
2010 ut_params->auth_xform.auth.algo = auth_algo;
2011 ut_params->auth_xform.auth.key.length = key_len;
2012 /* Hash key = cipher key */
2013 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2014 ut_params->auth_xform.auth.digest_length = auth_len;
2015 /* Auth IV will be after cipher IV */
2016 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2017 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2019 /* Setup Cipher Parameters */
2020 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2021 ut_params->cipher_xform.next = &ut_params->auth_xform;
2023 ut_params->cipher_xform.cipher.algo = cipher_algo;
2024 ut_params->cipher_xform.cipher.op = cipher_op;
2025 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2026 ut_params->cipher_xform.cipher.key.length = key_len;
2027 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2028 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2031 debug_hexdump(stdout, "key:", key, key_len);
2033 /* Create Crypto session*/
2034 ut_params->sess = rte_cryptodev_sym_session_create(
2035 ts_params->session_mpool);
2037 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2038 &ut_params->cipher_xform,
2039 ts_params->session_priv_mpool);
2041 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2042 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2047 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2048 const struct wireless_test_data *tdata)
2050 return create_wireless_cipher_auth_session(dev_id,
2051 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2052 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2053 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2057 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2058 enum rte_crypto_cipher_operation cipher_op,
2059 enum rte_crypto_auth_operation auth_op,
2060 enum rte_crypto_auth_algorithm auth_algo,
2061 enum rte_crypto_cipher_algorithm cipher_algo,
2062 const uint8_t *key, const uint8_t key_len,
2063 uint8_t auth_iv_len, uint8_t auth_len,
2064 uint8_t cipher_iv_len)
2066 uint8_t auth_cipher_key[key_len];
2068 struct crypto_testsuite_params *ts_params = &testsuite_params;
2069 struct crypto_unittest_params *ut_params = &unittest_params;
2071 memcpy(auth_cipher_key, key, key_len);
2073 /* Setup Authentication Parameters */
2074 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2075 ut_params->auth_xform.auth.op = auth_op;
2076 ut_params->auth_xform.next = &ut_params->cipher_xform;
2077 ut_params->auth_xform.auth.algo = auth_algo;
2078 ut_params->auth_xform.auth.key.length = key_len;
2079 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2080 ut_params->auth_xform.auth.digest_length = auth_len;
2081 /* Auth IV will be after cipher IV */
2082 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2083 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2085 /* Setup Cipher Parameters */
2086 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2087 ut_params->cipher_xform.next = NULL;
2088 ut_params->cipher_xform.cipher.algo = cipher_algo;
2089 ut_params->cipher_xform.cipher.op = cipher_op;
2090 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2091 ut_params->cipher_xform.cipher.key.length = key_len;
2092 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2093 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2095 debug_hexdump(stdout, "key:", key, key_len);
2097 /* Create Crypto session*/
2098 ut_params->sess = rte_cryptodev_sym_session_create(
2099 ts_params->session_mpool);
2100 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2102 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2103 ut_params->auth_xform.next = NULL;
2104 ut_params->cipher_xform.next = &ut_params->auth_xform;
2105 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2106 &ut_params->cipher_xform,
2107 ts_params->session_priv_mpool);
2110 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2111 &ut_params->auth_xform,
2112 ts_params->session_priv_mpool);
2114 if (status == -ENOTSUP)
2117 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2123 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2124 unsigned int auth_tag_len,
2125 const uint8_t *iv, unsigned int iv_len,
2126 unsigned int data_pad_len,
2127 enum rte_crypto_auth_operation op,
2128 unsigned int auth_len, unsigned int auth_offset)
2130 struct crypto_testsuite_params *ts_params = &testsuite_params;
2132 struct crypto_unittest_params *ut_params = &unittest_params;
2134 /* Generate Crypto op data structure */
2135 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2136 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2137 TEST_ASSERT_NOT_NULL(ut_params->op,
2138 "Failed to allocate pktmbuf offload");
2140 /* Set crypto operation data parameters */
2141 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2143 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2145 /* set crypto operation source mbuf */
2146 sym_op->m_src = ut_params->ibuf;
2149 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2152 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2153 ut_params->ibuf, auth_tag_len);
2155 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2156 "no room to append auth tag");
2157 ut_params->digest = sym_op->auth.digest.data;
2158 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2159 ut_params->ibuf, data_pad_len);
2160 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2161 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2163 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2165 debug_hexdump(stdout, "digest:",
2166 sym_op->auth.digest.data,
2169 sym_op->auth.data.length = auth_len;
2170 sym_op->auth.data.offset = auth_offset;
2176 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2177 enum rte_crypto_auth_operation op)
2179 struct crypto_testsuite_params *ts_params = &testsuite_params;
2180 struct crypto_unittest_params *ut_params = &unittest_params;
2182 const uint8_t *auth_tag = tdata->digest.data;
2183 const unsigned int auth_tag_len = tdata->digest.len;
2184 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2185 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2187 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2188 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2189 const uint8_t *auth_iv = tdata->auth_iv.data;
2190 const uint8_t auth_iv_len = tdata->auth_iv.len;
2191 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2192 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2194 /* Generate Crypto op data structure */
2195 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2196 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2197 TEST_ASSERT_NOT_NULL(ut_params->op,
2198 "Failed to allocate pktmbuf offload");
2199 /* Set crypto operation data parameters */
2200 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2202 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2204 /* set crypto operation source mbuf */
2205 sym_op->m_src = ut_params->ibuf;
2208 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2209 ut_params->ibuf, auth_tag_len);
2211 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2212 "no room to append auth tag");
2213 ut_params->digest = sym_op->auth.digest.data;
2214 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2215 ut_params->ibuf, data_pad_len);
2216 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2217 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2219 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2221 debug_hexdump(stdout, "digest:",
2222 sym_op->auth.digest.data,
2225 /* Copy cipher and auth IVs at the end of the crypto operation */
2226 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2228 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2229 iv_ptr += cipher_iv_len;
2230 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2232 sym_op->cipher.data.length = cipher_len;
2233 sym_op->cipher.data.offset = 0;
2234 sym_op->auth.data.length = auth_len;
2235 sym_op->auth.data.offset = 0;
2241 create_zuc_cipher_hash_generate_operation(
2242 const struct wireless_test_data *tdata)
2244 return create_wireless_cipher_hash_operation(tdata,
2245 RTE_CRYPTO_AUTH_OP_GENERATE);
2249 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2250 const unsigned auth_tag_len,
2251 const uint8_t *auth_iv, uint8_t auth_iv_len,
2252 unsigned data_pad_len,
2253 enum rte_crypto_auth_operation op,
2254 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2255 const unsigned cipher_len, const unsigned cipher_offset,
2256 const unsigned auth_len, const unsigned auth_offset)
2258 struct crypto_testsuite_params *ts_params = &testsuite_params;
2259 struct crypto_unittest_params *ut_params = &unittest_params;
2261 enum rte_crypto_cipher_algorithm cipher_algo =
2262 ut_params->cipher_xform.cipher.algo;
2263 enum rte_crypto_auth_algorithm auth_algo =
2264 ut_params->auth_xform.auth.algo;
2266 /* Generate Crypto op data structure */
2267 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2268 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2269 TEST_ASSERT_NOT_NULL(ut_params->op,
2270 "Failed to allocate pktmbuf offload");
2271 /* Set crypto operation data parameters */
2272 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2274 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2276 /* set crypto operation source mbuf */
2277 sym_op->m_src = ut_params->ibuf;
2280 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2281 ut_params->ibuf, auth_tag_len);
2283 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2284 "no room to append auth tag");
2285 ut_params->digest = sym_op->auth.digest.data;
2287 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2288 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2289 ut_params->ibuf, data_pad_len);
2291 struct rte_mbuf *m = ut_params->ibuf;
2292 unsigned int offset = data_pad_len;
2294 while (offset > m->data_len && m->next != NULL) {
2295 offset -= m->data_len;
2298 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2302 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2303 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2305 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2307 debug_hexdump(stdout, "digest:",
2308 sym_op->auth.digest.data,
2311 /* Copy cipher and auth IVs at the end of the crypto operation */
2312 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2314 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2315 iv_ptr += cipher_iv_len;
2316 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2318 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2319 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2320 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2321 sym_op->cipher.data.length = cipher_len;
2322 sym_op->cipher.data.offset = cipher_offset;
2324 sym_op->cipher.data.length = cipher_len >> 3;
2325 sym_op->cipher.data.offset = cipher_offset >> 3;
2328 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2329 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2330 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2331 sym_op->auth.data.length = auth_len;
2332 sym_op->auth.data.offset = auth_offset;
2334 sym_op->auth.data.length = auth_len >> 3;
2335 sym_op->auth.data.offset = auth_offset >> 3;
2342 create_wireless_algo_auth_cipher_operation(
2343 const uint8_t *auth_tag, unsigned int auth_tag_len,
2344 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2345 const uint8_t *auth_iv, uint8_t auth_iv_len,
2346 unsigned int data_pad_len,
2347 unsigned int cipher_len, unsigned int cipher_offset,
2348 unsigned int auth_len, unsigned int auth_offset,
2349 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2351 struct crypto_testsuite_params *ts_params = &testsuite_params;
2352 struct crypto_unittest_params *ut_params = &unittest_params;
2354 enum rte_crypto_cipher_algorithm cipher_algo =
2355 ut_params->cipher_xform.cipher.algo;
2356 enum rte_crypto_auth_algorithm auth_algo =
2357 ut_params->auth_xform.auth.algo;
2359 /* Generate Crypto op data structure */
2360 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2361 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2362 TEST_ASSERT_NOT_NULL(ut_params->op,
2363 "Failed to allocate pktmbuf offload");
2365 /* Set crypto operation data parameters */
2366 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2368 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2370 /* set crypto operation mbufs */
2371 sym_op->m_src = ut_params->ibuf;
2372 if (op_mode == OUT_OF_PLACE)
2373 sym_op->m_dst = ut_params->obuf;
2377 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2378 (op_mode == IN_PLACE ?
2379 ut_params->ibuf : ut_params->obuf),
2380 uint8_t *, data_pad_len);
2381 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2382 (op_mode == IN_PLACE ?
2383 ut_params->ibuf : ut_params->obuf),
2385 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2387 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2388 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2389 sym_op->m_src : sym_op->m_dst);
2390 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2391 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2392 sgl_buf = sgl_buf->next;
2394 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2395 uint8_t *, remaining_off);
2396 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2398 memset(sym_op->auth.digest.data, 0, remaining_off);
2399 while (sgl_buf->next != NULL) {
2400 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2401 0, rte_pktmbuf_data_len(sgl_buf));
2402 sgl_buf = sgl_buf->next;
2406 /* Copy digest for the verification */
2408 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2410 /* Copy cipher and auth IVs at the end of the crypto operation */
2411 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2412 ut_params->op, uint8_t *, IV_OFFSET);
2414 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2415 iv_ptr += cipher_iv_len;
2416 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2418 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2419 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2420 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2421 sym_op->cipher.data.length = cipher_len;
2422 sym_op->cipher.data.offset = cipher_offset;
2424 sym_op->cipher.data.length = cipher_len >> 3;
2425 sym_op->cipher.data.offset = cipher_offset >> 3;
2428 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2429 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2430 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2431 sym_op->auth.data.length = auth_len;
2432 sym_op->auth.data.offset = auth_offset;
2434 sym_op->auth.data.length = auth_len >> 3;
2435 sym_op->auth.data.offset = auth_offset >> 3;
2442 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2444 struct crypto_testsuite_params *ts_params = &testsuite_params;
2445 struct crypto_unittest_params *ut_params = &unittest_params;
2448 unsigned plaintext_pad_len;
2449 unsigned plaintext_len;
2452 /* QAT PMD supports byte-aligned data only */
2453 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
2454 (gbl_driver_id == rte_cryptodev_driver_id_get(
2455 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
2458 /* Verify the capabilities */
2459 struct rte_cryptodev_sym_capability_idx cap_idx;
2460 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2461 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2462 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2466 /* Create SNOW 3G session */
2467 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2468 tdata->key.data, tdata->key.len,
2469 tdata->auth_iv.len, tdata->digest.len,
2470 RTE_CRYPTO_AUTH_OP_GENERATE,
2471 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2475 /* alloc mbuf and set payload */
2476 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2478 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2479 rte_pktmbuf_tailroom(ut_params->ibuf));
2481 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2482 /* Append data which is padded to a multiple of */
2483 /* the algorithms block size */
2484 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2485 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2487 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2489 /* Create SNOW 3G operation */
2490 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2491 tdata->auth_iv.data, tdata->auth_iv.len,
2492 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2493 tdata->validAuthLenInBits.len,
2498 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2500 ut_params->obuf = ut_params->op->sym->m_src;
2501 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2502 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2503 + plaintext_pad_len;
2506 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2509 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2510 "SNOW 3G Generated auth tag not as expected");
2516 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2518 struct crypto_testsuite_params *ts_params = &testsuite_params;
2519 struct crypto_unittest_params *ut_params = &unittest_params;
2522 unsigned plaintext_pad_len;
2523 unsigned plaintext_len;
2526 /* QAT PMD supports byte-aligned data only */
2527 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
2528 (gbl_driver_id == rte_cryptodev_driver_id_get(
2529 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
2532 /* Verify the capabilities */
2533 struct rte_cryptodev_sym_capability_idx cap_idx;
2534 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2535 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2536 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2540 /* Create SNOW 3G session */
2541 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2542 tdata->key.data, tdata->key.len,
2543 tdata->auth_iv.len, tdata->digest.len,
2544 RTE_CRYPTO_AUTH_OP_VERIFY,
2545 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2548 /* alloc mbuf and set payload */
2549 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2551 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2552 rte_pktmbuf_tailroom(ut_params->ibuf));
2554 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2555 /* Append data which is padded to a multiple of */
2556 /* the algorithms block size */
2557 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2558 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2560 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2562 /* Create SNOW 3G operation */
2563 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2565 tdata->auth_iv.data, tdata->auth_iv.len,
2567 RTE_CRYPTO_AUTH_OP_VERIFY,
2568 tdata->validAuthLenInBits.len,
2573 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2575 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2576 ut_params->obuf = ut_params->op->sym->m_src;
2577 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2578 + plaintext_pad_len;
2581 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2590 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2592 struct crypto_testsuite_params *ts_params = &testsuite_params;
2593 struct crypto_unittest_params *ut_params = &unittest_params;
2596 unsigned plaintext_pad_len;
2597 unsigned plaintext_len;
2600 /* Verify the capabilities */
2601 struct rte_cryptodev_sym_capability_idx cap_idx;
2602 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2603 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2604 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2608 /* Create KASUMI session */
2609 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2610 tdata->key.data, tdata->key.len,
2611 0, tdata->digest.len,
2612 RTE_CRYPTO_AUTH_OP_GENERATE,
2613 RTE_CRYPTO_AUTH_KASUMI_F9);
2617 /* alloc mbuf and set payload */
2618 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2620 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2621 rte_pktmbuf_tailroom(ut_params->ibuf));
2623 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2624 /* Append data which is padded to a multiple of */
2625 /* the algorithms block size */
2626 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2627 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2629 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2631 /* Create KASUMI operation */
2632 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2634 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2635 tdata->plaintext.len,
2640 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2642 ut_params->obuf = ut_params->op->sym->m_src;
2643 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2644 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2645 + plaintext_pad_len;
2648 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2651 DIGEST_BYTE_LENGTH_KASUMI_F9,
2652 "KASUMI Generated auth tag not as expected");
2658 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2660 struct crypto_testsuite_params *ts_params = &testsuite_params;
2661 struct crypto_unittest_params *ut_params = &unittest_params;
2664 unsigned plaintext_pad_len;
2665 unsigned plaintext_len;
2668 /* Verify the capabilities */
2669 struct rte_cryptodev_sym_capability_idx cap_idx;
2670 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2671 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2672 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2676 /* Create KASUMI session */
2677 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2678 tdata->key.data, tdata->key.len,
2679 0, tdata->digest.len,
2680 RTE_CRYPTO_AUTH_OP_VERIFY,
2681 RTE_CRYPTO_AUTH_KASUMI_F9);
2684 /* alloc mbuf and set payload */
2685 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2687 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2688 rte_pktmbuf_tailroom(ut_params->ibuf));
2690 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2691 /* Append data which is padded to a multiple */
2692 /* of the algorithms block size */
2693 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2694 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2696 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2698 /* Create KASUMI operation */
2699 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2703 RTE_CRYPTO_AUTH_OP_VERIFY,
2704 tdata->plaintext.len,
2709 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2711 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2712 ut_params->obuf = ut_params->op->sym->m_src;
2713 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2714 + plaintext_pad_len;
2717 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2726 test_snow3g_hash_generate_test_case_1(void)
2728 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2732 test_snow3g_hash_generate_test_case_2(void)
2734 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2738 test_snow3g_hash_generate_test_case_3(void)
2740 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2744 test_snow3g_hash_generate_test_case_4(void)
2746 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2750 test_snow3g_hash_generate_test_case_5(void)
2752 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2756 test_snow3g_hash_generate_test_case_6(void)
2758 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2762 test_snow3g_hash_verify_test_case_1(void)
2764 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2769 test_snow3g_hash_verify_test_case_2(void)
2771 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2775 test_snow3g_hash_verify_test_case_3(void)
2777 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2781 test_snow3g_hash_verify_test_case_4(void)
2783 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2787 test_snow3g_hash_verify_test_case_5(void)
2789 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2793 test_snow3g_hash_verify_test_case_6(void)
2795 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2799 test_kasumi_hash_generate_test_case_1(void)
2801 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2805 test_kasumi_hash_generate_test_case_2(void)
2807 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2811 test_kasumi_hash_generate_test_case_3(void)
2813 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2817 test_kasumi_hash_generate_test_case_4(void)
2819 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2823 test_kasumi_hash_generate_test_case_5(void)
2825 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2829 test_kasumi_hash_generate_test_case_6(void)
2831 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2835 test_kasumi_hash_verify_test_case_1(void)
2837 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2841 test_kasumi_hash_verify_test_case_2(void)
2843 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2847 test_kasumi_hash_verify_test_case_3(void)
2849 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2853 test_kasumi_hash_verify_test_case_4(void)
2855 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2859 test_kasumi_hash_verify_test_case_5(void)
2861 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2865 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2867 struct crypto_testsuite_params *ts_params = &testsuite_params;
2868 struct crypto_unittest_params *ut_params = &unittest_params;
2871 uint8_t *plaintext, *ciphertext;
2872 unsigned plaintext_pad_len;
2873 unsigned plaintext_len;
2875 /* Verify the capabilities */
2876 struct rte_cryptodev_sym_capability_idx cap_idx;
2877 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2878 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2879 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2883 /* Create KASUMI session */
2884 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2885 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2886 RTE_CRYPTO_CIPHER_KASUMI_F8,
2887 tdata->key.data, tdata->key.len,
2888 tdata->cipher_iv.len);
2892 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2894 /* Clear mbuf payload */
2895 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2896 rte_pktmbuf_tailroom(ut_params->ibuf));
2898 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2899 /* Append data which is padded to a multiple */
2900 /* of the algorithms block size */
2901 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2902 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2904 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2906 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2908 /* Create KASUMI operation */
2909 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2910 tdata->cipher_iv.len,
2911 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2912 tdata->validCipherOffsetInBits.len);
2916 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2918 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2920 ut_params->obuf = ut_params->op->sym->m_dst;
2921 if (ut_params->obuf)
2922 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2924 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2926 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2928 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2929 (tdata->validCipherOffsetInBits.len >> 3);
2931 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2933 reference_ciphertext,
2934 tdata->validCipherLenInBits.len,
2935 "KASUMI Ciphertext data not as expected");
2940 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2942 struct crypto_testsuite_params *ts_params = &testsuite_params;
2943 struct crypto_unittest_params *ut_params = &unittest_params;
2947 unsigned int plaintext_pad_len;
2948 unsigned int plaintext_len;
2950 uint8_t buffer[10000];
2951 const uint8_t *ciphertext;
2953 struct rte_cryptodev_info dev_info;
2955 /* Verify the capabilities */
2956 struct rte_cryptodev_sym_capability_idx cap_idx;
2957 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2958 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2959 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2963 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2965 uint64_t feat_flags = dev_info.feature_flags;
2967 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2968 printf("Device doesn't support in-place scatter-gather. "
2973 /* Create KASUMI session */
2974 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2975 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2976 RTE_CRYPTO_CIPHER_KASUMI_F8,
2977 tdata->key.data, tdata->key.len,
2978 tdata->cipher_iv.len);
2982 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2985 /* Append data which is padded to a multiple */
2986 /* of the algorithms block size */
2987 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2989 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2990 plaintext_pad_len, 10, 0);
2992 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2994 /* Create KASUMI operation */
2995 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2996 tdata->cipher_iv.len,
2997 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2998 tdata->validCipherOffsetInBits.len);
3002 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3004 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3006 ut_params->obuf = ut_params->op->sym->m_dst;
3008 if (ut_params->obuf)
3009 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3010 plaintext_len, buffer);
3012 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3013 tdata->validCipherOffsetInBits.len >> 3,
3014 plaintext_len, buffer);
3017 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3019 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3020 (tdata->validCipherOffsetInBits.len >> 3);
3022 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3024 reference_ciphertext,
3025 tdata->validCipherLenInBits.len,
3026 "KASUMI Ciphertext data not as expected");
3031 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3033 struct crypto_testsuite_params *ts_params = &testsuite_params;
3034 struct crypto_unittest_params *ut_params = &unittest_params;
3037 uint8_t *plaintext, *ciphertext;
3038 unsigned plaintext_pad_len;
3039 unsigned plaintext_len;
3041 /* Verify the capabilities */
3042 struct rte_cryptodev_sym_capability_idx cap_idx;
3043 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3044 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3045 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3049 /* Create KASUMI session */
3050 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3051 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3052 RTE_CRYPTO_CIPHER_KASUMI_F8,
3053 tdata->key.data, tdata->key.len,
3054 tdata->cipher_iv.len);
3058 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3059 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3061 /* Clear mbuf payload */
3062 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3063 rte_pktmbuf_tailroom(ut_params->ibuf));
3065 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3066 /* Append data which is padded to a multiple */
3067 /* of the algorithms block size */
3068 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3069 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3071 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3072 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3074 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3076 /* Create KASUMI operation */
3077 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3078 tdata->cipher_iv.len,
3079 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3080 tdata->validCipherOffsetInBits.len);
3084 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3086 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3088 ut_params->obuf = ut_params->op->sym->m_dst;
3089 if (ut_params->obuf)
3090 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3092 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3094 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3096 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3097 (tdata->validCipherOffsetInBits.len >> 3);
3099 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3101 reference_ciphertext,
3102 tdata->validCipherLenInBits.len,
3103 "KASUMI Ciphertext data not as expected");
3108 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3110 struct crypto_testsuite_params *ts_params = &testsuite_params;
3111 struct crypto_unittest_params *ut_params = &unittest_params;
3114 unsigned int plaintext_pad_len;
3115 unsigned int plaintext_len;
3117 const uint8_t *ciphertext;
3118 uint8_t buffer[2048];
3120 struct rte_cryptodev_info dev_info;
3122 /* Verify the capabilities */
3123 struct rte_cryptodev_sym_capability_idx cap_idx;
3124 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3125 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3126 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3130 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3132 uint64_t feat_flags = dev_info.feature_flags;
3133 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3134 printf("Device doesn't support out-of-place scatter-gather "
3135 "in both input and output mbufs. "
3140 /* Create KASUMI session */
3141 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3142 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3143 RTE_CRYPTO_CIPHER_KASUMI_F8,
3144 tdata->key.data, tdata->key.len,
3145 tdata->cipher_iv.len);
3149 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3150 /* Append data which is padded to a multiple */
3151 /* of the algorithms block size */
3152 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3154 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3155 plaintext_pad_len, 10, 0);
3156 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3157 plaintext_pad_len, 3, 0);
3159 /* Append data which is padded to a multiple */
3160 /* of the algorithms block size */
3161 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3163 /* Create KASUMI operation */
3164 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3165 tdata->cipher_iv.len,
3166 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3167 tdata->validCipherOffsetInBits.len);
3171 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3173 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3175 ut_params->obuf = ut_params->op->sym->m_dst;
3176 if (ut_params->obuf)
3177 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3178 plaintext_pad_len, buffer);
3180 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3181 tdata->validCipherOffsetInBits.len >> 3,
3182 plaintext_pad_len, buffer);
3184 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3185 (tdata->validCipherOffsetInBits.len >> 3);
3187 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3189 reference_ciphertext,
3190 tdata->validCipherLenInBits.len,
3191 "KASUMI Ciphertext data not as expected");
3197 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3199 struct crypto_testsuite_params *ts_params = &testsuite_params;
3200 struct crypto_unittest_params *ut_params = &unittest_params;
3203 uint8_t *ciphertext, *plaintext;
3204 unsigned ciphertext_pad_len;
3205 unsigned ciphertext_len;
3207 /* Verify the capabilities */
3208 struct rte_cryptodev_sym_capability_idx cap_idx;
3209 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3210 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3211 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3215 /* Create KASUMI session */
3216 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3217 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3218 RTE_CRYPTO_CIPHER_KASUMI_F8,
3219 tdata->key.data, tdata->key.len,
3220 tdata->cipher_iv.len);
3224 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3225 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3227 /* Clear mbuf payload */
3228 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3229 rte_pktmbuf_tailroom(ut_params->ibuf));
3231 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3232 /* Append data which is padded to a multiple */
3233 /* of the algorithms block size */
3234 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3235 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3236 ciphertext_pad_len);
3237 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3238 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3240 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3242 /* Create KASUMI operation */
3243 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3244 tdata->cipher_iv.len,
3245 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3246 tdata->validCipherOffsetInBits.len);
3250 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3252 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3254 ut_params->obuf = ut_params->op->sym->m_dst;
3255 if (ut_params->obuf)
3256 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3258 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3260 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3262 const uint8_t *reference_plaintext = tdata->plaintext.data +
3263 (tdata->validCipherOffsetInBits.len >> 3);
3265 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3267 reference_plaintext,
3268 tdata->validCipherLenInBits.len,
3269 "KASUMI Plaintext data not as expected");
3274 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3276 struct crypto_testsuite_params *ts_params = &testsuite_params;
3277 struct crypto_unittest_params *ut_params = &unittest_params;
3280 uint8_t *ciphertext, *plaintext;
3281 unsigned ciphertext_pad_len;
3282 unsigned ciphertext_len;
3284 /* Verify the capabilities */
3285 struct rte_cryptodev_sym_capability_idx cap_idx;
3286 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3287 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3288 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3292 /* Create KASUMI session */
3293 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3294 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3295 RTE_CRYPTO_CIPHER_KASUMI_F8,
3296 tdata->key.data, tdata->key.len,
3297 tdata->cipher_iv.len);
3301 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3303 /* Clear mbuf payload */
3304 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3305 rte_pktmbuf_tailroom(ut_params->ibuf));
3307 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3308 /* Append data which is padded to a multiple */
3309 /* of the algorithms block size */
3310 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3311 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3312 ciphertext_pad_len);
3313 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3315 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3317 /* Create KASUMI operation */
3318 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3319 tdata->cipher_iv.len,
3320 tdata->ciphertext.len,
3321 tdata->validCipherOffsetInBits.len);
3325 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3327 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3329 ut_params->obuf = ut_params->op->sym->m_dst;
3330 if (ut_params->obuf)
3331 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3333 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3335 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3337 const uint8_t *reference_plaintext = tdata->plaintext.data +
3338 (tdata->validCipherOffsetInBits.len >> 3);
3340 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3342 reference_plaintext,
3343 tdata->validCipherLenInBits.len,
3344 "KASUMI Plaintext data not as expected");
3349 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3351 struct crypto_testsuite_params *ts_params = &testsuite_params;
3352 struct crypto_unittest_params *ut_params = &unittest_params;
3355 uint8_t *plaintext, *ciphertext;
3356 unsigned plaintext_pad_len;
3357 unsigned plaintext_len;
3359 /* Verify the capabilities */
3360 struct rte_cryptodev_sym_capability_idx cap_idx;
3361 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3362 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3363 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3367 /* Create SNOW 3G session */
3368 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3369 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3370 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3371 tdata->key.data, tdata->key.len,
3372 tdata->cipher_iv.len);
3376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3378 /* Clear mbuf payload */
3379 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3380 rte_pktmbuf_tailroom(ut_params->ibuf));
3382 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3383 /* Append data which is padded to a multiple of */
3384 /* the algorithms block size */
3385 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3386 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3388 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3390 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3392 /* Create SNOW 3G operation */
3393 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3394 tdata->cipher_iv.len,
3395 tdata->validCipherLenInBits.len,
3400 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3402 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3404 ut_params->obuf = ut_params->op->sym->m_dst;
3405 if (ut_params->obuf)
3406 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3408 ciphertext = plaintext;
3410 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3413 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3415 tdata->ciphertext.data,
3416 tdata->validDataLenInBits.len,
3417 "SNOW 3G Ciphertext data not as expected");
3423 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3425 struct crypto_testsuite_params *ts_params = &testsuite_params;
3426 struct crypto_unittest_params *ut_params = &unittest_params;
3427 uint8_t *plaintext, *ciphertext;
3430 unsigned plaintext_pad_len;
3431 unsigned plaintext_len;
3433 /* Verify the capabilities */
3434 struct rte_cryptodev_sym_capability_idx cap_idx;
3435 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3436 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3437 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3441 /* Create SNOW 3G session */
3442 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3443 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3444 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3445 tdata->key.data, tdata->key.len,
3446 tdata->cipher_iv.len);
3450 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3451 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3453 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3454 "Failed to allocate input buffer in mempool");
3455 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3456 "Failed to allocate output buffer in mempool");
3458 /* Clear mbuf payload */
3459 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3460 rte_pktmbuf_tailroom(ut_params->ibuf));
3462 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3463 /* Append data which is padded to a multiple of */
3464 /* the algorithms block size */
3465 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3466 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3468 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3469 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3471 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3473 /* Create SNOW 3G operation */
3474 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3475 tdata->cipher_iv.len,
3476 tdata->validCipherLenInBits.len,
3481 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3483 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3485 ut_params->obuf = ut_params->op->sym->m_dst;
3486 if (ut_params->obuf)
3487 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3489 ciphertext = plaintext;
3491 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3494 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3496 tdata->ciphertext.data,
3497 tdata->validDataLenInBits.len,
3498 "SNOW 3G Ciphertext data not as expected");
3503 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3505 struct crypto_testsuite_params *ts_params = &testsuite_params;
3506 struct crypto_unittest_params *ut_params = &unittest_params;
3509 unsigned int plaintext_pad_len;
3510 unsigned int plaintext_len;
3511 uint8_t buffer[10000];
3512 const uint8_t *ciphertext;
3514 struct rte_cryptodev_info dev_info;
3516 /* Verify the capabilities */
3517 struct rte_cryptodev_sym_capability_idx cap_idx;
3518 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3519 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3520 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3524 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3526 uint64_t feat_flags = dev_info.feature_flags;
3528 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3529 printf("Device doesn't support out-of-place scatter-gather "
3530 "in both input and output mbufs. "
3535 /* Create SNOW 3G session */
3536 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3537 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3538 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3539 tdata->key.data, tdata->key.len,
3540 tdata->cipher_iv.len);
3544 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3545 /* Append data which is padded to a multiple of */
3546 /* the algorithms block size */
3547 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3549 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3550 plaintext_pad_len, 10, 0);
3551 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3552 plaintext_pad_len, 3, 0);
3554 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3555 "Failed to allocate input buffer in mempool");
3556 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3557 "Failed to allocate output buffer in mempool");
3559 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3561 /* Create SNOW 3G operation */
3562 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3563 tdata->cipher_iv.len,
3564 tdata->validCipherLenInBits.len,
3569 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3571 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3573 ut_params->obuf = ut_params->op->sym->m_dst;
3574 if (ut_params->obuf)
3575 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3576 plaintext_len, buffer);
3578 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3579 plaintext_len, buffer);
3581 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3584 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3586 tdata->ciphertext.data,
3587 tdata->validDataLenInBits.len,
3588 "SNOW 3G Ciphertext data not as expected");
3593 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3595 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3597 uint8_t curr_byte, prev_byte;
3598 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3599 uint8_t lower_byte_mask = (1 << offset) - 1;
3602 prev_byte = buffer[0];
3603 buffer[0] >>= offset;
3605 for (i = 1; i < length_in_bytes; i++) {
3606 curr_byte = buffer[i];
3607 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3608 (curr_byte >> offset);
3609 prev_byte = curr_byte;
3614 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3616 struct crypto_testsuite_params *ts_params = &testsuite_params;
3617 struct crypto_unittest_params *ut_params = &unittest_params;
3618 uint8_t *plaintext, *ciphertext;
3620 uint32_t plaintext_len;
3621 uint32_t plaintext_pad_len;
3622 uint8_t extra_offset = 4;
3623 uint8_t *expected_ciphertext_shifted;
3625 /* QAT PMD supports byte-aligned data only */
3626 if (gbl_driver_id == rte_cryptodev_driver_id_get(
3627 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
3630 /* Verify the capabilities */
3631 struct rte_cryptodev_sym_capability_idx cap_idx;
3632 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3633 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3634 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3638 /* Create SNOW 3G session */
3639 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3640 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3641 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3642 tdata->key.data, tdata->key.len,
3643 tdata->cipher_iv.len);
3647 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3648 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3650 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3651 "Failed to allocate input buffer in mempool");
3652 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3653 "Failed to allocate output buffer in mempool");
3655 /* Clear mbuf payload */
3656 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3657 rte_pktmbuf_tailroom(ut_params->ibuf));
3659 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3661 * Append data which is padded to a
3662 * multiple of the algorithms block size
3664 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3666 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3669 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3671 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3672 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3674 #ifdef RTE_APP_TEST_DEBUG
3675 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3677 /* Create SNOW 3G operation */
3678 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3679 tdata->cipher_iv.len,
3680 tdata->validCipherLenInBits.len,
3685 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3687 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3689 ut_params->obuf = ut_params->op->sym->m_dst;
3690 if (ut_params->obuf)
3691 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3693 ciphertext = plaintext;
3695 #ifdef RTE_APP_TEST_DEBUG
3696 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3699 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3701 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3702 "failed to reserve memory for ciphertext shifted\n");
3704 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3705 ceil_byte_length(tdata->ciphertext.len));
3706 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3709 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3711 expected_ciphertext_shifted,
3712 tdata->validDataLenInBits.len,
3714 "SNOW 3G Ciphertext data not as expected");
3718 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3720 struct crypto_testsuite_params *ts_params = &testsuite_params;
3721 struct crypto_unittest_params *ut_params = &unittest_params;
3725 uint8_t *plaintext, *ciphertext;
3726 unsigned ciphertext_pad_len;
3727 unsigned ciphertext_len;
3729 /* Verify the capabilities */
3730 struct rte_cryptodev_sym_capability_idx cap_idx;
3731 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3732 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3733 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3737 /* Create SNOW 3G session */
3738 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3739 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3740 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3741 tdata->key.data, tdata->key.len,
3742 tdata->cipher_iv.len);
3746 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3748 /* Clear mbuf payload */
3749 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3750 rte_pktmbuf_tailroom(ut_params->ibuf));
3752 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3753 /* Append data which is padded to a multiple of */
3754 /* the algorithms block size */
3755 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3756 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3757 ciphertext_pad_len);
3758 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3760 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3762 /* Create SNOW 3G operation */
3763 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3764 tdata->cipher_iv.len,
3765 tdata->validCipherLenInBits.len,
3766 tdata->cipher.offset_bits);
3770 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3772 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3773 ut_params->obuf = ut_params->op->sym->m_dst;
3774 if (ut_params->obuf)
3775 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3777 plaintext = ciphertext;
3779 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3782 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3783 tdata->plaintext.data,
3784 tdata->validDataLenInBits.len,
3785 "SNOW 3G Plaintext data not as expected");
3789 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3791 struct crypto_testsuite_params *ts_params = &testsuite_params;
3792 struct crypto_unittest_params *ut_params = &unittest_params;
3796 uint8_t *plaintext, *ciphertext;
3797 unsigned ciphertext_pad_len;
3798 unsigned ciphertext_len;
3800 /* Verify the capabilities */
3801 struct rte_cryptodev_sym_capability_idx cap_idx;
3802 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3803 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3804 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3808 /* Create SNOW 3G session */
3809 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3810 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3811 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3812 tdata->key.data, tdata->key.len,
3813 tdata->cipher_iv.len);
3817 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3818 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3820 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3821 "Failed to allocate input buffer");
3822 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3823 "Failed to allocate output buffer");
3825 /* Clear mbuf payload */
3826 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3827 rte_pktmbuf_tailroom(ut_params->ibuf));
3829 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3830 rte_pktmbuf_tailroom(ut_params->obuf));
3832 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3833 /* Append data which is padded to a multiple of */
3834 /* the algorithms block size */
3835 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3836 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3837 ciphertext_pad_len);
3838 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3839 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3841 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3843 /* Create SNOW 3G operation */
3844 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3845 tdata->cipher_iv.len,
3846 tdata->validCipherLenInBits.len,
3851 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3853 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3854 ut_params->obuf = ut_params->op->sym->m_dst;
3855 if (ut_params->obuf)
3856 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3858 plaintext = ciphertext;
3860 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3863 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3864 tdata->plaintext.data,
3865 tdata->validDataLenInBits.len,
3866 "SNOW 3G Plaintext data not as expected");
3871 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3873 struct crypto_testsuite_params *ts_params = &testsuite_params;
3874 struct crypto_unittest_params *ut_params = &unittest_params;
3878 uint8_t *plaintext, *ciphertext;
3879 unsigned int plaintext_pad_len;
3880 unsigned int plaintext_len;
3882 struct rte_cryptodev_sym_capability_idx cap_idx;
3884 /* Check if device supports ZUC EEA3 */
3885 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3886 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3888 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3892 /* Check if device supports ZUC EIA3 */
3893 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3894 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3896 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3900 /* Create ZUC session */
3901 retval = create_zuc_cipher_auth_encrypt_generate_session(
3902 ts_params->valid_devs[0],
3906 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3908 /* clear mbuf payload */
3909 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3910 rte_pktmbuf_tailroom(ut_params->ibuf));
3912 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3913 /* Append data which is padded to a multiple of */
3914 /* the algorithms block size */
3915 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3916 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3918 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3920 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3922 /* Create ZUC operation */
3923 retval = create_zuc_cipher_hash_generate_operation(tdata);
3927 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3929 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3930 ut_params->obuf = ut_params->op->sym->m_src;
3931 if (ut_params->obuf)
3932 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3934 ciphertext = plaintext;
3936 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3938 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3940 tdata->ciphertext.data,
3941 tdata->validDataLenInBits.len,
3942 "ZUC Ciphertext data not as expected");
3944 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3945 + plaintext_pad_len;
3948 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3952 "ZUC Generated auth tag not as expected");
3957 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3959 struct crypto_testsuite_params *ts_params = &testsuite_params;
3960 struct crypto_unittest_params *ut_params = &unittest_params;
3964 uint8_t *plaintext, *ciphertext;
3965 unsigned plaintext_pad_len;
3966 unsigned plaintext_len;
3968 /* Verify the capabilities */
3969 struct rte_cryptodev_sym_capability_idx cap_idx;
3970 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3971 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3972 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3975 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3976 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3977 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3981 /* Create SNOW 3G session */
3982 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3983 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3984 RTE_CRYPTO_AUTH_OP_GENERATE,
3985 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3986 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3987 tdata->key.data, tdata->key.len,
3988 tdata->auth_iv.len, tdata->digest.len,
3989 tdata->cipher_iv.len);
3992 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3994 /* clear mbuf payload */
3995 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3996 rte_pktmbuf_tailroom(ut_params->ibuf));
3998 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3999 /* Append data which is padded to a multiple of */
4000 /* the algorithms block size */
4001 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4002 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4004 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4006 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4008 /* Create SNOW 3G operation */
4009 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4010 tdata->digest.len, tdata->auth_iv.data,
4012 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4013 tdata->cipher_iv.data, tdata->cipher_iv.len,
4014 tdata->validCipherLenInBits.len,
4016 tdata->validAuthLenInBits.len,
4022 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4024 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4025 ut_params->obuf = ut_params->op->sym->m_src;
4026 if (ut_params->obuf)
4027 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4029 ciphertext = plaintext;
4031 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4033 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4035 tdata->ciphertext.data,
4036 tdata->validDataLenInBits.len,
4037 "SNOW 3G Ciphertext data not as expected");
4039 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4040 + plaintext_pad_len;
4043 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4046 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4047 "SNOW 3G Generated auth tag not as expected");
4052 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4053 uint8_t op_mode, uint8_t verify)
4055 struct crypto_testsuite_params *ts_params = &testsuite_params;
4056 struct crypto_unittest_params *ut_params = &unittest_params;
4060 uint8_t *plaintext = NULL, *ciphertext = NULL;
4061 unsigned int plaintext_pad_len;
4062 unsigned int plaintext_len;
4063 unsigned int ciphertext_pad_len;
4064 unsigned int ciphertext_len;
4066 struct rte_cryptodev_info dev_info;
4068 /* Verify the capabilities */
4069 struct rte_cryptodev_sym_capability_idx cap_idx;
4070 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4071 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4072 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4075 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4076 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4077 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4081 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4083 uint64_t feat_flags = dev_info.feature_flags;
4085 if (op_mode == OUT_OF_PLACE) {
4086 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4087 printf("Device doesn't support digest encrypted.\n");
4092 /* Create SNOW 3G session */
4093 retval = create_wireless_algo_auth_cipher_session(
4094 ts_params->valid_devs[0],
4095 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4096 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4097 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4098 : RTE_CRYPTO_AUTH_OP_GENERATE),
4099 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4100 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4101 tdata->key.data, tdata->key.len,
4102 tdata->auth_iv.len, tdata->digest.len,
4103 tdata->cipher_iv.len);
4108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4109 if (op_mode == OUT_OF_PLACE)
4110 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4112 /* clear mbuf payload */
4113 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4114 rte_pktmbuf_tailroom(ut_params->ibuf));
4115 if (op_mode == OUT_OF_PLACE)
4116 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4117 rte_pktmbuf_tailroom(ut_params->obuf));
4119 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4120 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4121 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4122 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4125 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4126 ciphertext_pad_len);
4127 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4128 if (op_mode == OUT_OF_PLACE)
4129 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4130 debug_hexdump(stdout, "ciphertext:", ciphertext,
4133 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4135 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4136 if (op_mode == OUT_OF_PLACE)
4137 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4138 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4141 /* Create SNOW 3G operation */
4142 retval = create_wireless_algo_auth_cipher_operation(
4143 tdata->digest.data, tdata->digest.len,
4144 tdata->cipher_iv.data, tdata->cipher_iv.len,
4145 tdata->auth_iv.data, tdata->auth_iv.len,
4146 (tdata->digest.offset_bytes == 0 ?
4147 (verify ? ciphertext_pad_len : plaintext_pad_len)
4148 : tdata->digest.offset_bytes),
4149 tdata->validCipherLenInBits.len,
4150 tdata->cipher.offset_bits,
4151 tdata->validAuthLenInBits.len,
4152 tdata->auth.offset_bits,
4153 op_mode, 0, verify);
4158 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4161 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4163 ut_params->obuf = (op_mode == IN_PLACE ?
4164 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4167 if (ut_params->obuf)
4168 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4171 plaintext = ciphertext +
4172 (tdata->cipher.offset_bits >> 3);
4174 debug_hexdump(stdout, "plaintext:", plaintext,
4175 (tdata->plaintext.len >> 3) - tdata->digest.len);
4176 debug_hexdump(stdout, "plaintext expected:",
4177 tdata->plaintext.data,
4178 (tdata->plaintext.len >> 3) - tdata->digest.len);
4180 if (ut_params->obuf)
4181 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4184 ciphertext = plaintext;
4186 debug_hexdump(stdout, "ciphertext:", ciphertext,
4188 debug_hexdump(stdout, "ciphertext expected:",
4189 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4191 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4192 + (tdata->digest.offset_bytes == 0 ?
4193 plaintext_pad_len : tdata->digest.offset_bytes);
4195 debug_hexdump(stdout, "digest:", ut_params->digest,
4197 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4203 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4205 tdata->plaintext.data,
4206 tdata->plaintext.len >> 3,
4207 "SNOW 3G Plaintext data not as expected");
4209 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4211 tdata->ciphertext.data,
4212 tdata->validDataLenInBits.len,
4213 "SNOW 3G Ciphertext data not as expected");
4215 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4218 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4219 "SNOW 3G Generated auth tag not as expected");
4225 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4226 uint8_t op_mode, uint8_t verify)
4228 struct crypto_testsuite_params *ts_params = &testsuite_params;
4229 struct crypto_unittest_params *ut_params = &unittest_params;
4233 const uint8_t *plaintext = NULL;
4234 const uint8_t *ciphertext = NULL;
4235 const uint8_t *digest = NULL;
4236 unsigned int plaintext_pad_len;
4237 unsigned int plaintext_len;
4238 unsigned int ciphertext_pad_len;
4239 unsigned int ciphertext_len;
4240 uint8_t buffer[10000];
4241 uint8_t digest_buffer[10000];
4243 struct rte_cryptodev_info dev_info;
4245 /* Verify the capabilities */
4246 struct rte_cryptodev_sym_capability_idx cap_idx;
4247 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4248 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4249 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4252 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4253 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4254 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4258 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4260 uint64_t feat_flags = dev_info.feature_flags;
4262 if (op_mode == IN_PLACE) {
4263 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4264 printf("Device doesn't support in-place scatter-gather "
4265 "in both input and output mbufs.\n");
4269 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4270 printf("Device doesn't support out-of-place scatter-gather "
4271 "in both input and output mbufs.\n");
4274 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4275 printf("Device doesn't support digest encrypted.\n");
4280 /* Create SNOW 3G session */
4281 retval = create_wireless_algo_auth_cipher_session(
4282 ts_params->valid_devs[0],
4283 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4284 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4285 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4286 : RTE_CRYPTO_AUTH_OP_GENERATE),
4287 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4288 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4289 tdata->key.data, tdata->key.len,
4290 tdata->auth_iv.len, tdata->digest.len,
4291 tdata->cipher_iv.len);
4296 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4297 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4298 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4299 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4301 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4302 plaintext_pad_len, 15, 0);
4303 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4304 "Failed to allocate input buffer in mempool");
4306 if (op_mode == OUT_OF_PLACE) {
4307 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4308 plaintext_pad_len, 15, 0);
4309 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4310 "Failed to allocate output buffer in mempool");
4314 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4315 tdata->ciphertext.data);
4316 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4317 ciphertext_len, buffer);
4318 debug_hexdump(stdout, "ciphertext:", ciphertext,
4321 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4322 tdata->plaintext.data);
4323 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4324 plaintext_len, buffer);
4325 debug_hexdump(stdout, "plaintext:", plaintext,
4328 memset(buffer, 0, sizeof(buffer));
4330 /* Create SNOW 3G operation */
4331 retval = create_wireless_algo_auth_cipher_operation(
4332 tdata->digest.data, tdata->digest.len,
4333 tdata->cipher_iv.data, tdata->cipher_iv.len,
4334 tdata->auth_iv.data, tdata->auth_iv.len,
4335 (tdata->digest.offset_bytes == 0 ?
4336 (verify ? ciphertext_pad_len : plaintext_pad_len)
4337 : tdata->digest.offset_bytes),
4338 tdata->validCipherLenInBits.len,
4339 tdata->cipher.offset_bits,
4340 tdata->validAuthLenInBits.len,
4341 tdata->auth.offset_bits,
4342 op_mode, 1, verify);
4347 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4350 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4352 ut_params->obuf = (op_mode == IN_PLACE ?
4353 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4356 if (ut_params->obuf)
4357 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4358 plaintext_len, buffer);
4360 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4361 plaintext_len, buffer);
4363 debug_hexdump(stdout, "plaintext:", plaintext,
4364 (tdata->plaintext.len >> 3) - tdata->digest.len);
4365 debug_hexdump(stdout, "plaintext expected:",
4366 tdata->plaintext.data,
4367 (tdata->plaintext.len >> 3) - tdata->digest.len);
4369 if (ut_params->obuf)
4370 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4371 ciphertext_len, buffer);
4373 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4374 ciphertext_len, buffer);
4376 debug_hexdump(stdout, "ciphertext:", ciphertext,
4378 debug_hexdump(stdout, "ciphertext expected:",
4379 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4381 if (ut_params->obuf)
4382 digest = rte_pktmbuf_read(ut_params->obuf,
4383 (tdata->digest.offset_bytes == 0 ?
4384 plaintext_pad_len : tdata->digest.offset_bytes),
4385 tdata->digest.len, digest_buffer);
4387 digest = rte_pktmbuf_read(ut_params->ibuf,
4388 (tdata->digest.offset_bytes == 0 ?
4389 plaintext_pad_len : tdata->digest.offset_bytes),
4390 tdata->digest.len, digest_buffer);
4392 debug_hexdump(stdout, "digest:", digest,
4394 debug_hexdump(stdout, "digest expected:",
4395 tdata->digest.data, tdata->digest.len);
4400 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4402 tdata->plaintext.data,
4403 tdata->plaintext.len >> 3,
4404 "SNOW 3G Plaintext data not as expected");
4406 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4408 tdata->ciphertext.data,
4409 tdata->validDataLenInBits.len,
4410 "SNOW 3G Ciphertext data not as expected");
4412 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4415 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4416 "SNOW 3G Generated auth tag not as expected");
4422 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4423 uint8_t op_mode, uint8_t verify)
4425 struct crypto_testsuite_params *ts_params = &testsuite_params;
4426 struct crypto_unittest_params *ut_params = &unittest_params;
4430 uint8_t *plaintext = NULL, *ciphertext = NULL;
4431 unsigned int plaintext_pad_len;
4432 unsigned int plaintext_len;
4433 unsigned int ciphertext_pad_len;
4434 unsigned int ciphertext_len;
4436 struct rte_cryptodev_info dev_info;
4438 /* Verify the capabilities */
4439 struct rte_cryptodev_sym_capability_idx cap_idx;
4440 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4441 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4442 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4445 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4446 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4447 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4451 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4453 uint64_t feat_flags = dev_info.feature_flags;
4455 if (op_mode == OUT_OF_PLACE) {
4456 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4457 printf("Device doesn't support digest encrypted.\n");
4462 /* Create KASUMI session */
4463 retval = create_wireless_algo_auth_cipher_session(
4464 ts_params->valid_devs[0],
4465 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4466 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4467 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4468 : RTE_CRYPTO_AUTH_OP_GENERATE),
4469 RTE_CRYPTO_AUTH_KASUMI_F9,
4470 RTE_CRYPTO_CIPHER_KASUMI_F8,
4471 tdata->key.data, tdata->key.len,
4472 0, tdata->digest.len,
4473 tdata->cipher_iv.len);
4478 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4479 if (op_mode == OUT_OF_PLACE)
4480 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4482 /* clear mbuf payload */
4483 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4484 rte_pktmbuf_tailroom(ut_params->ibuf));
4485 if (op_mode == OUT_OF_PLACE)
4486 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4487 rte_pktmbuf_tailroom(ut_params->obuf));
4489 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4490 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4491 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4492 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4495 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4496 ciphertext_pad_len);
4497 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4498 if (op_mode == OUT_OF_PLACE)
4499 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4500 debug_hexdump(stdout, "ciphertext:", ciphertext,
4503 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4505 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4506 if (op_mode == OUT_OF_PLACE)
4507 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4508 debug_hexdump(stdout, "plaintext:", plaintext,
4512 /* Create KASUMI operation */
4513 retval = create_wireless_algo_auth_cipher_operation(
4514 tdata->digest.data, tdata->digest.len,
4515 tdata->cipher_iv.data, tdata->cipher_iv.len,
4517 (tdata->digest.offset_bytes == 0 ?
4518 (verify ? ciphertext_pad_len : plaintext_pad_len)
4519 : tdata->digest.offset_bytes),
4520 tdata->validCipherLenInBits.len,
4521 tdata->validCipherOffsetInBits.len,
4522 tdata->validAuthLenInBits.len,
4524 op_mode, 0, verify);
4529 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4532 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4534 ut_params->obuf = (op_mode == IN_PLACE ?
4535 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4539 if (ut_params->obuf)
4540 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4543 plaintext = ciphertext;
4545 debug_hexdump(stdout, "plaintext:", plaintext,
4546 (tdata->plaintext.len >> 3) - tdata->digest.len);
4547 debug_hexdump(stdout, "plaintext expected:",
4548 tdata->plaintext.data,
4549 (tdata->plaintext.len >> 3) - tdata->digest.len);
4551 if (ut_params->obuf)
4552 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4555 ciphertext = plaintext;
4557 debug_hexdump(stdout, "ciphertext:", ciphertext,
4559 debug_hexdump(stdout, "ciphertext expected:",
4560 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4562 ut_params->digest = rte_pktmbuf_mtod(
4563 ut_params->obuf, uint8_t *) +
4564 (tdata->digest.offset_bytes == 0 ?
4565 plaintext_pad_len : tdata->digest.offset_bytes);
4567 debug_hexdump(stdout, "digest:", ut_params->digest,
4569 debug_hexdump(stdout, "digest expected:",
4570 tdata->digest.data, tdata->digest.len);
4575 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4577 tdata->plaintext.data,
4578 tdata->plaintext.len >> 3,
4579 "KASUMI Plaintext data not as expected");
4581 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4583 tdata->ciphertext.data,
4584 tdata->ciphertext.len >> 3,
4585 "KASUMI Ciphertext data not as expected");
4587 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4590 DIGEST_BYTE_LENGTH_KASUMI_F9,
4591 "KASUMI Generated auth tag not as expected");
4597 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4598 uint8_t op_mode, uint8_t verify)
4600 struct crypto_testsuite_params *ts_params = &testsuite_params;
4601 struct crypto_unittest_params *ut_params = &unittest_params;
4605 const uint8_t *plaintext = NULL;
4606 const uint8_t *ciphertext = NULL;
4607 const uint8_t *digest = NULL;
4608 unsigned int plaintext_pad_len;
4609 unsigned int plaintext_len;
4610 unsigned int ciphertext_pad_len;
4611 unsigned int ciphertext_len;
4612 uint8_t buffer[10000];
4613 uint8_t digest_buffer[10000];
4615 struct rte_cryptodev_info dev_info;
4617 /* Verify the capabilities */
4618 struct rte_cryptodev_sym_capability_idx cap_idx;
4619 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4620 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4621 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4624 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4625 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4626 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4630 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4632 uint64_t feat_flags = dev_info.feature_flags;
4634 if (op_mode == IN_PLACE) {
4635 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4636 printf("Device doesn't support in-place scatter-gather "
4637 "in both input and output mbufs.\n");
4641 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4642 printf("Device doesn't support out-of-place scatter-gather "
4643 "in both input and output mbufs.\n");
4646 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4647 printf("Device doesn't support digest encrypted.\n");
4652 /* Create KASUMI session */
4653 retval = create_wireless_algo_auth_cipher_session(
4654 ts_params->valid_devs[0],
4655 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4656 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4657 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4658 : RTE_CRYPTO_AUTH_OP_GENERATE),
4659 RTE_CRYPTO_AUTH_KASUMI_F9,
4660 RTE_CRYPTO_CIPHER_KASUMI_F8,
4661 tdata->key.data, tdata->key.len,
4662 0, tdata->digest.len,
4663 tdata->cipher_iv.len);
4668 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4669 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4670 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4671 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4673 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4674 plaintext_pad_len, 15, 0);
4675 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4676 "Failed to allocate input buffer in mempool");
4678 if (op_mode == OUT_OF_PLACE) {
4679 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4680 plaintext_pad_len, 15, 0);
4681 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4682 "Failed to allocate output buffer in mempool");
4686 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4687 tdata->ciphertext.data);
4688 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4689 ciphertext_len, buffer);
4690 debug_hexdump(stdout, "ciphertext:", ciphertext,
4693 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4694 tdata->plaintext.data);
4695 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4696 plaintext_len, buffer);
4697 debug_hexdump(stdout, "plaintext:", plaintext,
4700 memset(buffer, 0, sizeof(buffer));
4702 /* Create KASUMI operation */
4703 retval = create_wireless_algo_auth_cipher_operation(
4704 tdata->digest.data, tdata->digest.len,
4705 tdata->cipher_iv.data, tdata->cipher_iv.len,
4707 (tdata->digest.offset_bytes == 0 ?
4708 (verify ? ciphertext_pad_len : plaintext_pad_len)
4709 : tdata->digest.offset_bytes),
4710 tdata->validCipherLenInBits.len,
4711 tdata->validCipherOffsetInBits.len,
4712 tdata->validAuthLenInBits.len,
4714 op_mode, 1, verify);
4719 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4722 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4724 ut_params->obuf = (op_mode == IN_PLACE ?
4725 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4728 if (ut_params->obuf)
4729 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4730 plaintext_len, buffer);
4732 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4733 plaintext_len, buffer);
4735 debug_hexdump(stdout, "plaintext:", plaintext,
4736 (tdata->plaintext.len >> 3) - tdata->digest.len);
4737 debug_hexdump(stdout, "plaintext expected:",
4738 tdata->plaintext.data,
4739 (tdata->plaintext.len >> 3) - tdata->digest.len);
4741 if (ut_params->obuf)
4742 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4743 ciphertext_len, buffer);
4745 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4746 ciphertext_len, buffer);
4748 debug_hexdump(stdout, "ciphertext:", ciphertext,
4750 debug_hexdump(stdout, "ciphertext expected:",
4751 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4753 if (ut_params->obuf)
4754 digest = rte_pktmbuf_read(ut_params->obuf,
4755 (tdata->digest.offset_bytes == 0 ?
4756 plaintext_pad_len : tdata->digest.offset_bytes),
4757 tdata->digest.len, digest_buffer);
4759 digest = rte_pktmbuf_read(ut_params->ibuf,
4760 (tdata->digest.offset_bytes == 0 ?
4761 plaintext_pad_len : tdata->digest.offset_bytes),
4762 tdata->digest.len, digest_buffer);
4764 debug_hexdump(stdout, "digest:", digest,
4766 debug_hexdump(stdout, "digest expected:",
4767 tdata->digest.data, tdata->digest.len);
4772 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4774 tdata->plaintext.data,
4775 tdata->plaintext.len >> 3,
4776 "KASUMI Plaintext data not as expected");
4778 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4780 tdata->ciphertext.data,
4781 tdata->validDataLenInBits.len,
4782 "KASUMI Ciphertext data not as expected");
4784 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4787 DIGEST_BYTE_LENGTH_KASUMI_F9,
4788 "KASUMI Generated auth tag not as expected");
4794 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4796 struct crypto_testsuite_params *ts_params = &testsuite_params;
4797 struct crypto_unittest_params *ut_params = &unittest_params;
4801 uint8_t *plaintext, *ciphertext;
4802 unsigned plaintext_pad_len;
4803 unsigned plaintext_len;
4805 /* Verify the capabilities */
4806 struct rte_cryptodev_sym_capability_idx cap_idx;
4807 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4808 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4809 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4812 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4813 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4814 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4818 /* Create KASUMI session */
4819 retval = create_wireless_algo_cipher_auth_session(
4820 ts_params->valid_devs[0],
4821 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4822 RTE_CRYPTO_AUTH_OP_GENERATE,
4823 RTE_CRYPTO_AUTH_KASUMI_F9,
4824 RTE_CRYPTO_CIPHER_KASUMI_F8,
4825 tdata->key.data, tdata->key.len,
4826 0, tdata->digest.len,
4827 tdata->cipher_iv.len);
4831 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4833 /* clear mbuf payload */
4834 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4835 rte_pktmbuf_tailroom(ut_params->ibuf));
4837 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4838 /* Append data which is padded to a multiple of */
4839 /* the algorithms block size */
4840 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4841 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4843 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4845 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4847 /* Create KASUMI operation */
4848 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4849 tdata->digest.len, NULL, 0,
4850 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4851 tdata->cipher_iv.data, tdata->cipher_iv.len,
4852 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4853 tdata->validCipherOffsetInBits.len,
4854 tdata->validAuthLenInBits.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 if (ut_params->op->sym->m_dst)
4865 ut_params->obuf = ut_params->op->sym->m_dst;
4867 ut_params->obuf = ut_params->op->sym->m_src;
4869 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4870 tdata->validCipherOffsetInBits.len >> 3);
4872 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4873 + plaintext_pad_len;
4875 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4876 (tdata->validCipherOffsetInBits.len >> 3);
4878 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4880 reference_ciphertext,
4881 tdata->validCipherLenInBits.len,
4882 "KASUMI Ciphertext data not as expected");
4885 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4888 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4889 "KASUMI Generated auth tag not as expected");
4894 test_zuc_encryption(const struct wireless_test_data *tdata)
4896 struct crypto_testsuite_params *ts_params = &testsuite_params;
4897 struct crypto_unittest_params *ut_params = &unittest_params;
4900 uint8_t *plaintext, *ciphertext;
4901 unsigned plaintext_pad_len;
4902 unsigned plaintext_len;
4904 struct rte_cryptodev_sym_capability_idx cap_idx;
4906 /* Check if device supports ZUC EEA3 */
4907 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4908 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4910 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4914 /* Create ZUC session */
4915 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4916 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4917 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4918 tdata->key.data, tdata->key.len,
4919 tdata->cipher_iv.len);
4923 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4925 /* Clear mbuf payload */
4926 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4927 rte_pktmbuf_tailroom(ut_params->ibuf));
4929 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4930 /* Append data which is padded to a multiple */
4931 /* of the algorithms block size */
4932 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4933 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4935 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4937 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4939 /* Create ZUC operation */
4940 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4941 tdata->cipher_iv.len,
4942 tdata->plaintext.len,
4947 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4949 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4951 ut_params->obuf = ut_params->op->sym->m_dst;
4952 if (ut_params->obuf)
4953 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4955 ciphertext = plaintext;
4957 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4960 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4962 tdata->ciphertext.data,
4963 tdata->validCipherLenInBits.len,
4964 "ZUC Ciphertext data not as expected");
4969 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4971 struct crypto_testsuite_params *ts_params = &testsuite_params;
4972 struct crypto_unittest_params *ut_params = &unittest_params;
4976 unsigned int plaintext_pad_len;
4977 unsigned int plaintext_len;
4978 const uint8_t *ciphertext;
4979 uint8_t ciphertext_buffer[2048];
4980 struct rte_cryptodev_info dev_info;
4982 struct rte_cryptodev_sym_capability_idx cap_idx;
4984 /* Check if device supports ZUC EEA3 */
4985 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4986 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4988 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4992 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4994 uint64_t feat_flags = dev_info.feature_flags;
4996 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4997 printf("Device doesn't support in-place scatter-gather. "
5002 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5004 /* Append data which is padded to a multiple */
5005 /* of the algorithms block size */
5006 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5008 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5009 plaintext_pad_len, 10, 0);
5011 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5012 tdata->plaintext.data);
5014 /* Create ZUC session */
5015 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5016 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5017 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5018 tdata->key.data, tdata->key.len,
5019 tdata->cipher_iv.len);
5023 /* Clear mbuf payload */
5025 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5027 /* Create ZUC operation */
5028 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5029 tdata->cipher_iv.len, tdata->plaintext.len,
5034 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5036 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5038 ut_params->obuf = ut_params->op->sym->m_dst;
5039 if (ut_params->obuf)
5040 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5041 0, plaintext_len, ciphertext_buffer);
5043 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5044 0, plaintext_len, ciphertext_buffer);
5047 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5050 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5052 tdata->ciphertext.data,
5053 tdata->validCipherLenInBits.len,
5054 "ZUC Ciphertext data not as expected");
5060 test_zuc_authentication(const struct wireless_test_data *tdata)
5062 struct crypto_testsuite_params *ts_params = &testsuite_params;
5063 struct crypto_unittest_params *ut_params = &unittest_params;
5066 unsigned plaintext_pad_len;
5067 unsigned plaintext_len;
5070 struct rte_cryptodev_sym_capability_idx cap_idx;
5072 /* QAT PMD supports byte-aligned data only */
5073 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
5074 (gbl_driver_id == rte_cryptodev_driver_id_get(
5075 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
5078 /* Check if device supports ZUC EIA3 */
5079 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5080 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5082 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5086 /* Create ZUC session */
5087 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5088 tdata->key.data, tdata->key.len,
5089 tdata->auth_iv.len, tdata->digest.len,
5090 RTE_CRYPTO_AUTH_OP_GENERATE,
5091 RTE_CRYPTO_AUTH_ZUC_EIA3);
5095 /* alloc mbuf and set payload */
5096 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5098 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5099 rte_pktmbuf_tailroom(ut_params->ibuf));
5101 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5102 /* Append data which is padded to a multiple of */
5103 /* the algorithms block size */
5104 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5105 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5107 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5109 /* Create ZUC operation */
5110 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5111 tdata->auth_iv.data, tdata->auth_iv.len,
5112 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5113 tdata->validAuthLenInBits.len,
5118 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5120 ut_params->obuf = ut_params->op->sym->m_src;
5121 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5122 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5123 + plaintext_pad_len;
5126 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5130 "ZUC Generated auth tag not as expected");
5136 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5137 uint8_t op_mode, uint8_t verify)
5139 struct crypto_testsuite_params *ts_params = &testsuite_params;
5140 struct crypto_unittest_params *ut_params = &unittest_params;
5144 uint8_t *plaintext = NULL, *ciphertext = NULL;
5145 unsigned int plaintext_pad_len;
5146 unsigned int plaintext_len;
5147 unsigned int ciphertext_pad_len;
5148 unsigned int ciphertext_len;
5150 struct rte_cryptodev_info dev_info;
5151 struct rte_cryptodev_sym_capability_idx cap_idx;
5153 /* Check if device supports ZUC EIA3 */
5154 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5155 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5157 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5161 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5163 uint64_t feat_flags = dev_info.feature_flags;
5165 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5166 printf("Device doesn't support digest encrypted.\n");
5170 /* Create ZUC session */
5171 retval = create_wireless_algo_auth_cipher_session(
5172 ts_params->valid_devs[0],
5173 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5174 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5175 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5176 : RTE_CRYPTO_AUTH_OP_GENERATE),
5177 RTE_CRYPTO_AUTH_ZUC_EIA3,
5178 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5179 tdata->key.data, tdata->key.len,
5180 tdata->auth_iv.len, tdata->digest.len,
5181 tdata->cipher_iv.len);
5186 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5187 if (op_mode == OUT_OF_PLACE)
5188 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5190 /* clear mbuf payload */
5191 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5192 rte_pktmbuf_tailroom(ut_params->ibuf));
5193 if (op_mode == OUT_OF_PLACE)
5194 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5195 rte_pktmbuf_tailroom(ut_params->obuf));
5197 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5198 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5199 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5200 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5203 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5204 ciphertext_pad_len);
5205 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5206 if (op_mode == OUT_OF_PLACE)
5207 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5208 debug_hexdump(stdout, "ciphertext:", ciphertext,
5211 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5213 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5214 if (op_mode == OUT_OF_PLACE)
5215 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5216 debug_hexdump(stdout, "plaintext:", plaintext,
5220 /* Create ZUC operation */
5221 retval = create_wireless_algo_auth_cipher_operation(
5222 tdata->digest.data, tdata->digest.len,
5223 tdata->cipher_iv.data, tdata->cipher_iv.len,
5224 tdata->auth_iv.data, tdata->auth_iv.len,
5225 (tdata->digest.offset_bytes == 0 ?
5226 (verify ? ciphertext_pad_len : plaintext_pad_len)
5227 : tdata->digest.offset_bytes),
5228 tdata->validCipherLenInBits.len,
5229 tdata->validCipherOffsetInBits.len,
5230 tdata->validAuthLenInBits.len,
5232 op_mode, 0, verify);
5237 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5240 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5242 ut_params->obuf = (op_mode == IN_PLACE ?
5243 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5247 if (ut_params->obuf)
5248 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5251 plaintext = ciphertext;
5253 debug_hexdump(stdout, "plaintext:", plaintext,
5254 (tdata->plaintext.len >> 3) - tdata->digest.len);
5255 debug_hexdump(stdout, "plaintext expected:",
5256 tdata->plaintext.data,
5257 (tdata->plaintext.len >> 3) - tdata->digest.len);
5259 if (ut_params->obuf)
5260 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5263 ciphertext = plaintext;
5265 debug_hexdump(stdout, "ciphertext:", ciphertext,
5267 debug_hexdump(stdout, "ciphertext expected:",
5268 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5270 ut_params->digest = rte_pktmbuf_mtod(
5271 ut_params->obuf, uint8_t *) +
5272 (tdata->digest.offset_bytes == 0 ?
5273 plaintext_pad_len : tdata->digest.offset_bytes);
5275 debug_hexdump(stdout, "digest:", ut_params->digest,
5277 debug_hexdump(stdout, "digest expected:",
5278 tdata->digest.data, tdata->digest.len);
5283 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5285 tdata->plaintext.data,
5286 tdata->plaintext.len >> 3,
5287 "ZUC Plaintext data not as expected");
5289 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5291 tdata->ciphertext.data,
5292 tdata->ciphertext.len >> 3,
5293 "ZUC Ciphertext data not as expected");
5295 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5298 DIGEST_BYTE_LENGTH_KASUMI_F9,
5299 "ZUC Generated auth tag not as expected");
5305 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5306 uint8_t op_mode, uint8_t verify)
5308 struct crypto_testsuite_params *ts_params = &testsuite_params;
5309 struct crypto_unittest_params *ut_params = &unittest_params;
5313 const uint8_t *plaintext = NULL;
5314 const uint8_t *ciphertext = NULL;
5315 const uint8_t *digest = NULL;
5316 unsigned int plaintext_pad_len;
5317 unsigned int plaintext_len;
5318 unsigned int ciphertext_pad_len;
5319 unsigned int ciphertext_len;
5320 uint8_t buffer[10000];
5321 uint8_t digest_buffer[10000];
5323 struct rte_cryptodev_info dev_info;
5324 struct rte_cryptodev_sym_capability_idx cap_idx;
5326 /* Check if device supports ZUC EIA3 */
5327 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5328 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5330 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5334 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5336 uint64_t feat_flags = dev_info.feature_flags;
5338 if (op_mode == IN_PLACE) {
5339 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5340 printf("Device doesn't support in-place scatter-gather "
5341 "in both input and output mbufs.\n");
5345 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5346 printf("Device doesn't support out-of-place scatter-gather "
5347 "in both input and output mbufs.\n");
5350 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5351 printf("Device doesn't support digest encrypted.\n");
5356 /* Create ZUC session */
5357 retval = create_wireless_algo_auth_cipher_session(
5358 ts_params->valid_devs[0],
5359 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5360 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5361 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5362 : RTE_CRYPTO_AUTH_OP_GENERATE),
5363 RTE_CRYPTO_AUTH_ZUC_EIA3,
5364 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5365 tdata->key.data, tdata->key.len,
5366 tdata->auth_iv.len, tdata->digest.len,
5367 tdata->cipher_iv.len);
5372 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5373 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5374 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5375 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5377 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5378 plaintext_pad_len, 15, 0);
5379 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5380 "Failed to allocate input buffer in mempool");
5382 if (op_mode == OUT_OF_PLACE) {
5383 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5384 plaintext_pad_len, 15, 0);
5385 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5386 "Failed to allocate output buffer in mempool");
5390 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5391 tdata->ciphertext.data);
5392 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5393 ciphertext_len, buffer);
5394 debug_hexdump(stdout, "ciphertext:", ciphertext,
5397 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5398 tdata->plaintext.data);
5399 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5400 plaintext_len, buffer);
5401 debug_hexdump(stdout, "plaintext:", plaintext,
5404 memset(buffer, 0, sizeof(buffer));
5406 /* Create ZUC operation */
5407 retval = create_wireless_algo_auth_cipher_operation(
5408 tdata->digest.data, tdata->digest.len,
5409 tdata->cipher_iv.data, tdata->cipher_iv.len,
5411 (tdata->digest.offset_bytes == 0 ?
5412 (verify ? ciphertext_pad_len : plaintext_pad_len)
5413 : tdata->digest.offset_bytes),
5414 tdata->validCipherLenInBits.len,
5415 tdata->validCipherOffsetInBits.len,
5416 tdata->validAuthLenInBits.len,
5418 op_mode, 1, verify);
5423 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5426 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5428 ut_params->obuf = (op_mode == IN_PLACE ?
5429 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5432 if (ut_params->obuf)
5433 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5434 plaintext_len, buffer);
5436 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5437 plaintext_len, buffer);
5439 debug_hexdump(stdout, "plaintext:", plaintext,
5440 (tdata->plaintext.len >> 3) - tdata->digest.len);
5441 debug_hexdump(stdout, "plaintext expected:",
5442 tdata->plaintext.data,
5443 (tdata->plaintext.len >> 3) - tdata->digest.len);
5445 if (ut_params->obuf)
5446 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5447 ciphertext_len, buffer);
5449 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5450 ciphertext_len, buffer);
5452 debug_hexdump(stdout, "ciphertext:", ciphertext,
5454 debug_hexdump(stdout, "ciphertext expected:",
5455 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5457 if (ut_params->obuf)
5458 digest = rte_pktmbuf_read(ut_params->obuf,
5459 (tdata->digest.offset_bytes == 0 ?
5460 plaintext_pad_len : tdata->digest.offset_bytes),
5461 tdata->digest.len, digest_buffer);
5463 digest = rte_pktmbuf_read(ut_params->ibuf,
5464 (tdata->digest.offset_bytes == 0 ?
5465 plaintext_pad_len : tdata->digest.offset_bytes),
5466 tdata->digest.len, digest_buffer);
5468 debug_hexdump(stdout, "digest:", digest,
5470 debug_hexdump(stdout, "digest expected:",
5471 tdata->digest.data, tdata->digest.len);
5476 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5478 tdata->plaintext.data,
5479 tdata->plaintext.len >> 3,
5480 "ZUC Plaintext data not as expected");
5482 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5484 tdata->ciphertext.data,
5485 tdata->validDataLenInBits.len,
5486 "ZUC Ciphertext data not as expected");
5488 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5491 DIGEST_BYTE_LENGTH_KASUMI_F9,
5492 "ZUC Generated auth tag not as expected");
5498 test_kasumi_encryption_test_case_1(void)
5500 return test_kasumi_encryption(&kasumi_test_case_1);
5504 test_kasumi_encryption_test_case_1_sgl(void)
5506 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5510 test_kasumi_encryption_test_case_1_oop(void)
5512 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5516 test_kasumi_encryption_test_case_1_oop_sgl(void)
5518 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5522 test_kasumi_encryption_test_case_2(void)
5524 return test_kasumi_encryption(&kasumi_test_case_2);
5528 test_kasumi_encryption_test_case_3(void)
5530 return test_kasumi_encryption(&kasumi_test_case_3);
5534 test_kasumi_encryption_test_case_4(void)
5536 return test_kasumi_encryption(&kasumi_test_case_4);
5540 test_kasumi_encryption_test_case_5(void)
5542 return test_kasumi_encryption(&kasumi_test_case_5);
5546 test_kasumi_decryption_test_case_1(void)
5548 return test_kasumi_decryption(&kasumi_test_case_1);
5552 test_kasumi_decryption_test_case_1_oop(void)
5554 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5558 test_kasumi_decryption_test_case_2(void)
5560 return test_kasumi_decryption(&kasumi_test_case_2);
5564 test_kasumi_decryption_test_case_3(void)
5566 return test_kasumi_decryption(&kasumi_test_case_3);
5570 test_kasumi_decryption_test_case_4(void)
5572 return test_kasumi_decryption(&kasumi_test_case_4);
5576 test_kasumi_decryption_test_case_5(void)
5578 return test_kasumi_decryption(&kasumi_test_case_5);
5581 test_snow3g_encryption_test_case_1(void)
5583 return test_snow3g_encryption(&snow3g_test_case_1);
5587 test_snow3g_encryption_test_case_1_oop(void)
5589 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5593 test_snow3g_encryption_test_case_1_oop_sgl(void)
5595 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5600 test_snow3g_encryption_test_case_1_offset_oop(void)
5602 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5606 test_snow3g_encryption_test_case_2(void)
5608 return test_snow3g_encryption(&snow3g_test_case_2);
5612 test_snow3g_encryption_test_case_3(void)
5614 return test_snow3g_encryption(&snow3g_test_case_3);
5618 test_snow3g_encryption_test_case_4(void)
5620 return test_snow3g_encryption(&snow3g_test_case_4);
5624 test_snow3g_encryption_test_case_5(void)
5626 return test_snow3g_encryption(&snow3g_test_case_5);
5630 test_snow3g_decryption_test_case_1(void)
5632 return test_snow3g_decryption(&snow3g_test_case_1);
5636 test_snow3g_decryption_test_case_1_oop(void)
5638 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5642 test_snow3g_decryption_test_case_2(void)
5644 return test_snow3g_decryption(&snow3g_test_case_2);
5648 test_snow3g_decryption_test_case_3(void)
5650 return test_snow3g_decryption(&snow3g_test_case_3);
5654 test_snow3g_decryption_test_case_4(void)
5656 return test_snow3g_decryption(&snow3g_test_case_4);
5660 test_snow3g_decryption_test_case_5(void)
5662 return test_snow3g_decryption(&snow3g_test_case_5);
5666 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5667 * Pattern digest from snow3g_test_data must be allocated as
5668 * 4 last bytes in plaintext.
5671 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5672 struct snow3g_hash_test_data *output)
5674 if ((pattern != NULL) && (output != NULL)) {
5675 output->key.len = pattern->key.len;
5677 memcpy(output->key.data,
5678 pattern->key.data, pattern->key.len);
5680 output->auth_iv.len = pattern->auth_iv.len;
5682 memcpy(output->auth_iv.data,
5683 pattern->auth_iv.data, pattern->auth_iv.len);
5685 output->plaintext.len = pattern->plaintext.len;
5687 memcpy(output->plaintext.data,
5688 pattern->plaintext.data, pattern->plaintext.len >> 3);
5690 output->digest.len = pattern->digest.len;
5692 memcpy(output->digest.data,
5693 &pattern->plaintext.data[pattern->digest.offset_bytes],
5694 pattern->digest.len);
5696 output->validAuthLenInBits.len =
5697 pattern->validAuthLenInBits.len;
5702 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5705 test_snow3g_decryption_with_digest_test_case_1(void)
5707 struct snow3g_hash_test_data snow3g_hash_data;
5710 * Function prepare data for hash veryfication test case.
5711 * Digest is allocated in 4 last bytes in plaintext, pattern.
5713 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5715 return test_snow3g_decryption(&snow3g_test_case_7) &
5716 test_snow3g_authentication_verify(&snow3g_hash_data);
5720 test_snow3g_cipher_auth_test_case_1(void)
5722 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5726 test_snow3g_auth_cipher_test_case_1(void)
5728 return test_snow3g_auth_cipher(
5729 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5733 test_snow3g_auth_cipher_test_case_2(void)
5735 return test_snow3g_auth_cipher(
5736 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5740 test_snow3g_auth_cipher_test_case_2_oop(void)
5742 return test_snow3g_auth_cipher(
5743 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5747 test_snow3g_auth_cipher_part_digest_enc(void)
5749 return test_snow3g_auth_cipher(
5750 &snow3g_auth_cipher_partial_digest_encryption,
5755 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5757 return test_snow3g_auth_cipher(
5758 &snow3g_auth_cipher_partial_digest_encryption,
5763 test_snow3g_auth_cipher_test_case_3_sgl(void)
5765 return test_snow3g_auth_cipher_sgl(
5766 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5770 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5772 return test_snow3g_auth_cipher_sgl(
5773 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5777 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5779 return test_snow3g_auth_cipher_sgl(
5780 &snow3g_auth_cipher_partial_digest_encryption,
5785 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5787 return test_snow3g_auth_cipher_sgl(
5788 &snow3g_auth_cipher_partial_digest_encryption,
5793 test_snow3g_auth_cipher_verify_test_case_1(void)
5795 return test_snow3g_auth_cipher(
5796 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5800 test_snow3g_auth_cipher_verify_test_case_2(void)
5802 return test_snow3g_auth_cipher(
5803 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5807 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5809 return test_snow3g_auth_cipher(
5810 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5814 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5816 return test_snow3g_auth_cipher(
5817 &snow3g_auth_cipher_partial_digest_encryption,
5822 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5824 return test_snow3g_auth_cipher(
5825 &snow3g_auth_cipher_partial_digest_encryption,
5830 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5832 return test_snow3g_auth_cipher_sgl(
5833 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5837 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5839 return test_snow3g_auth_cipher_sgl(
5840 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5844 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5846 return test_snow3g_auth_cipher_sgl(
5847 &snow3g_auth_cipher_partial_digest_encryption,
5852 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5854 return test_snow3g_auth_cipher_sgl(
5855 &snow3g_auth_cipher_partial_digest_encryption,
5860 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5862 return test_snow3g_auth_cipher(
5863 &snow3g_test_case_7, IN_PLACE, 0);
5867 test_kasumi_auth_cipher_test_case_1(void)
5869 return test_kasumi_auth_cipher(
5870 &kasumi_test_case_3, IN_PLACE, 0);
5874 test_kasumi_auth_cipher_test_case_2(void)
5876 return test_kasumi_auth_cipher(
5877 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5881 test_kasumi_auth_cipher_test_case_2_oop(void)
5883 return test_kasumi_auth_cipher(
5884 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5888 test_kasumi_auth_cipher_test_case_2_sgl(void)
5890 return test_kasumi_auth_cipher_sgl(
5891 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5895 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5897 return test_kasumi_auth_cipher_sgl(
5898 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5902 test_kasumi_auth_cipher_verify_test_case_1(void)
5904 return test_kasumi_auth_cipher(
5905 &kasumi_test_case_3, IN_PLACE, 1);
5909 test_kasumi_auth_cipher_verify_test_case_2(void)
5911 return test_kasumi_auth_cipher(
5912 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5916 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5918 return test_kasumi_auth_cipher(
5919 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5923 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5925 return test_kasumi_auth_cipher_sgl(
5926 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5930 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5932 return test_kasumi_auth_cipher_sgl(
5933 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5937 test_kasumi_cipher_auth_test_case_1(void)
5939 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5943 test_zuc_encryption_test_case_1(void)
5945 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5949 test_zuc_encryption_test_case_2(void)
5951 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5955 test_zuc_encryption_test_case_3(void)
5957 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5961 test_zuc_encryption_test_case_4(void)
5963 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5967 test_zuc_encryption_test_case_5(void)
5969 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5973 test_zuc_encryption_test_case_6_sgl(void)
5975 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5979 test_zuc_hash_generate_test_case_1(void)
5981 return test_zuc_authentication(&zuc_test_case_auth_1b);
5985 test_zuc_hash_generate_test_case_2(void)
5987 return test_zuc_authentication(&zuc_test_case_auth_90b);
5991 test_zuc_hash_generate_test_case_3(void)
5993 return test_zuc_authentication(&zuc_test_case_auth_577b);
5997 test_zuc_hash_generate_test_case_4(void)
5999 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6003 test_zuc_hash_generate_test_case_5(void)
6005 return test_zuc_authentication(&zuc_test_auth_5670b);
6009 test_zuc_hash_generate_test_case_6(void)
6011 return test_zuc_authentication(&zuc_test_case_auth_128b);
6015 test_zuc_hash_generate_test_case_7(void)
6017 /* This test is not for SW ZUC PMD */
6018 if (gbl_driver_id == rte_cryptodev_driver_id_get(
6019 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
6022 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6026 test_zuc_hash_generate_test_case_8(void)
6028 return test_zuc_authentication(&zuc_test_case_auth_584b);
6032 test_zuc_cipher_auth_test_case_1(void)
6034 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6038 test_zuc_cipher_auth_test_case_2(void)
6040 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6044 test_zuc_auth_cipher_test_case_1(void)
6046 /* This test is not for SW ZUC PMD */
6047 if (gbl_driver_id == rte_cryptodev_driver_id_get(
6048 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
6051 return test_zuc_auth_cipher(
6052 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6056 test_zuc_auth_cipher_test_case_1_oop(void)
6058 return test_zuc_auth_cipher(
6059 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6063 test_zuc_auth_cipher_test_case_1_sgl(void)
6065 return test_zuc_auth_cipher_sgl(
6066 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6070 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6072 return test_zuc_auth_cipher_sgl(
6073 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6077 test_zuc_auth_cipher_verify_test_case_1(void)
6079 return test_zuc_auth_cipher(
6080 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6084 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6086 return test_zuc_auth_cipher(
6087 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6091 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6093 return test_zuc_auth_cipher_sgl(
6094 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6098 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6100 return test_zuc_auth_cipher_sgl(
6101 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6105 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6107 uint8_t dev_id = testsuite_params.valid_devs[0];
6109 struct rte_cryptodev_sym_capability_idx cap_idx;
6111 /* Check if device supports particular cipher algorithm */
6112 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6113 cap_idx.algo.cipher = tdata->cipher_algo;
6114 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6117 /* Check if device supports particular hash algorithm */
6118 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6119 cap_idx.algo.auth = tdata->auth_algo;
6120 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6127 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6128 uint8_t op_mode, uint8_t verify)
6130 struct crypto_testsuite_params *ts_params = &testsuite_params;
6131 struct crypto_unittest_params *ut_params = &unittest_params;
6135 uint8_t *plaintext = NULL, *ciphertext = NULL;
6136 unsigned int plaintext_pad_len;
6137 unsigned int plaintext_len;
6138 unsigned int ciphertext_pad_len;
6139 unsigned int ciphertext_len;
6141 struct rte_cryptodev_info dev_info;
6142 struct rte_crypto_op *op;
6144 /* Check if device supports particular algorithms separately */
6145 if (test_mixed_check_if_unsupported(tdata))
6148 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6150 uint64_t feat_flags = dev_info.feature_flags;
6152 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6153 printf("Device doesn't support digest encrypted.\n");
6157 /* Create the session */
6159 retval = create_wireless_algo_cipher_auth_session(
6160 ts_params->valid_devs[0],
6161 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6162 RTE_CRYPTO_AUTH_OP_VERIFY,
6165 tdata->auth_key.data, tdata->auth_key.len,
6166 tdata->auth_iv.len, tdata->digest_enc.len,
6167 tdata->cipher_iv.len);
6169 retval = create_wireless_algo_auth_cipher_session(
6170 ts_params->valid_devs[0],
6171 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6172 RTE_CRYPTO_AUTH_OP_GENERATE,
6175 tdata->auth_key.data, tdata->auth_key.len,
6176 tdata->auth_iv.len, tdata->digest_enc.len,
6177 tdata->cipher_iv.len);
6181 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6182 if (op_mode == OUT_OF_PLACE)
6183 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6185 /* clear mbuf payload */
6186 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6187 rte_pktmbuf_tailroom(ut_params->ibuf));
6188 if (op_mode == OUT_OF_PLACE)
6189 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6190 rte_pktmbuf_tailroom(ut_params->obuf));
6192 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6193 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6194 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6195 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6198 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6199 ciphertext_pad_len);
6200 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6201 if (op_mode == OUT_OF_PLACE)
6202 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6203 debug_hexdump(stdout, "ciphertext:", ciphertext,
6206 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6208 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6209 if (op_mode == OUT_OF_PLACE)
6210 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6211 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6214 /* Create the operation */
6215 retval = create_wireless_algo_auth_cipher_operation(
6216 tdata->digest_enc.data, tdata->digest_enc.len,
6217 tdata->cipher_iv.data, tdata->cipher_iv.len,
6218 tdata->auth_iv.data, tdata->auth_iv.len,
6219 (tdata->digest_enc.offset == 0 ?
6221 : tdata->digest_enc.offset),
6222 tdata->validCipherLen.len_bits,
6223 tdata->cipher.offset_bits,
6224 tdata->validAuthLen.len_bits,
6225 tdata->auth.offset_bits,
6226 op_mode, 0, verify);
6231 op = process_crypto_request(ts_params->valid_devs[0],
6234 /* Check if the op failed because the device doesn't */
6235 /* support this particular combination of algorithms */
6236 if (op == NULL && ut_params->op->status ==
6237 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6238 printf("Device doesn't support this mixed combination. "
6244 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6246 ut_params->obuf = (op_mode == IN_PLACE ?
6247 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6250 if (ut_params->obuf)
6251 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6254 plaintext = ciphertext +
6255 (tdata->cipher.offset_bits >> 3);
6257 debug_hexdump(stdout, "plaintext:", plaintext,
6258 tdata->plaintext.len_bits >> 3);
6259 debug_hexdump(stdout, "plaintext expected:",
6260 tdata->plaintext.data,
6261 tdata->plaintext.len_bits >> 3);
6263 if (ut_params->obuf)
6264 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6267 ciphertext = plaintext;
6269 debug_hexdump(stdout, "ciphertext:", ciphertext,
6271 debug_hexdump(stdout, "ciphertext expected:",
6272 tdata->ciphertext.data,
6273 tdata->ciphertext.len_bits >> 3);
6275 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6276 + (tdata->digest_enc.offset == 0 ?
6277 plaintext_pad_len : tdata->digest_enc.offset);
6279 debug_hexdump(stdout, "digest:", ut_params->digest,
6280 tdata->digest_enc.len);
6281 debug_hexdump(stdout, "digest expected:",
6282 tdata->digest_enc.data,
6283 tdata->digest_enc.len);
6288 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6290 tdata->plaintext.data,
6291 tdata->plaintext.len_bits >> 3,
6292 "Plaintext data not as expected");
6294 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6296 tdata->ciphertext.data,
6297 tdata->validDataLen.len_bits,
6298 "Ciphertext data not as expected");
6300 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6302 tdata->digest_enc.data,
6303 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6304 "Generated auth tag not as expected");
6307 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6308 "crypto op processing failed");
6314 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6315 uint8_t op_mode, uint8_t verify)
6317 struct crypto_testsuite_params *ts_params = &testsuite_params;
6318 struct crypto_unittest_params *ut_params = &unittest_params;
6322 const uint8_t *plaintext = NULL;
6323 const uint8_t *ciphertext = NULL;
6324 const uint8_t *digest = NULL;
6325 unsigned int plaintext_pad_len;
6326 unsigned int plaintext_len;
6327 unsigned int ciphertext_pad_len;
6328 unsigned int ciphertext_len;
6329 uint8_t buffer[10000];
6330 uint8_t digest_buffer[10000];
6332 struct rte_cryptodev_info dev_info;
6333 struct rte_crypto_op *op;
6335 /* Check if device supports particular algorithms */
6336 if (test_mixed_check_if_unsupported(tdata))
6339 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6341 uint64_t feat_flags = dev_info.feature_flags;
6343 if (op_mode == IN_PLACE) {
6344 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6345 printf("Device doesn't support in-place scatter-gather "
6346 "in both input and output mbufs.\n");
6350 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6351 printf("Device doesn't support out-of-place scatter-gather "
6352 "in both input and output mbufs.\n");
6355 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6356 printf("Device doesn't support digest encrypted.\n");
6361 /* Create the session */
6363 retval = create_wireless_algo_cipher_auth_session(
6364 ts_params->valid_devs[0],
6365 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6366 RTE_CRYPTO_AUTH_OP_VERIFY,
6369 tdata->auth_key.data, tdata->auth_key.len,
6370 tdata->auth_iv.len, tdata->digest_enc.len,
6371 tdata->cipher_iv.len);
6373 retval = create_wireless_algo_auth_cipher_session(
6374 ts_params->valid_devs[0],
6375 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6376 RTE_CRYPTO_AUTH_OP_GENERATE,
6379 tdata->auth_key.data, tdata->auth_key.len,
6380 tdata->auth_iv.len, tdata->digest_enc.len,
6381 tdata->cipher_iv.len);
6385 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6386 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6387 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6388 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6390 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6391 ciphertext_pad_len, 15, 0);
6392 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6393 "Failed to allocate input buffer in mempool");
6395 if (op_mode == OUT_OF_PLACE) {
6396 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6397 plaintext_pad_len, 15, 0);
6398 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6399 "Failed to allocate output buffer in mempool");
6403 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6404 tdata->ciphertext.data);
6405 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6406 ciphertext_len, buffer);
6407 debug_hexdump(stdout, "ciphertext:", ciphertext,
6410 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6411 tdata->plaintext.data);
6412 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6413 plaintext_len, buffer);
6414 debug_hexdump(stdout, "plaintext:", plaintext,
6417 memset(buffer, 0, sizeof(buffer));
6419 /* Create the operation */
6420 retval = create_wireless_algo_auth_cipher_operation(
6421 tdata->digest_enc.data, tdata->digest_enc.len,
6422 tdata->cipher_iv.data, tdata->cipher_iv.len,
6423 tdata->auth_iv.data, tdata->auth_iv.len,
6424 (tdata->digest_enc.offset == 0 ?
6426 : tdata->digest_enc.offset),
6427 tdata->validCipherLen.len_bits,
6428 tdata->cipher.offset_bits,
6429 tdata->validAuthLen.len_bits,
6430 tdata->auth.offset_bits,
6431 op_mode, 1, verify);
6436 op = process_crypto_request(ts_params->valid_devs[0],
6439 /* Check if the op failed because the device doesn't */
6440 /* support this particular combination of algorithms */
6441 if (op == NULL && ut_params->op->status ==
6442 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6443 printf("Device doesn't support this mixed combination. "
6450 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6452 ut_params->obuf = (op_mode == IN_PLACE ?
6453 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6456 if (ut_params->obuf)
6457 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6458 plaintext_len, buffer);
6460 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6461 plaintext_len, buffer);
6463 debug_hexdump(stdout, "plaintext:", plaintext,
6464 (tdata->plaintext.len_bits >> 3) -
6465 tdata->digest_enc.len);
6466 debug_hexdump(stdout, "plaintext expected:",
6467 tdata->plaintext.data,
6468 (tdata->plaintext.len_bits >> 3) -
6469 tdata->digest_enc.len);
6471 if (ut_params->obuf)
6472 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6473 ciphertext_len, buffer);
6475 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6476 ciphertext_len, buffer);
6478 debug_hexdump(stdout, "ciphertext:", ciphertext,
6480 debug_hexdump(stdout, "ciphertext expected:",
6481 tdata->ciphertext.data,
6482 tdata->ciphertext.len_bits >> 3);
6484 if (ut_params->obuf)
6485 digest = rte_pktmbuf_read(ut_params->obuf,
6486 (tdata->digest_enc.offset == 0 ?
6488 tdata->digest_enc.offset),
6489 tdata->digest_enc.len, digest_buffer);
6491 digest = rte_pktmbuf_read(ut_params->ibuf,
6492 (tdata->digest_enc.offset == 0 ?
6494 tdata->digest_enc.offset),
6495 tdata->digest_enc.len, digest_buffer);
6497 debug_hexdump(stdout, "digest:", digest,
6498 tdata->digest_enc.len);
6499 debug_hexdump(stdout, "digest expected:",
6500 tdata->digest_enc.data, tdata->digest_enc.len);
6505 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6507 tdata->plaintext.data,
6508 tdata->plaintext.len_bits >> 3,
6509 "Plaintext data not as expected");
6511 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6513 tdata->ciphertext.data,
6514 tdata->validDataLen.len_bits,
6515 "Ciphertext data not as expected");
6516 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6518 tdata->digest_enc.data,
6519 tdata->digest_enc.len,
6520 "Generated auth tag not as expected");
6523 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6524 "crypto op processing failed");
6529 /** AUTH AES CMAC + CIPHER AES CTR */
6532 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6534 return test_mixed_auth_cipher(
6535 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6539 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6541 return test_mixed_auth_cipher(
6542 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6546 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6548 return test_mixed_auth_cipher_sgl(
6549 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6553 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6555 return test_mixed_auth_cipher_sgl(
6556 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6560 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6562 return test_mixed_auth_cipher(
6563 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6567 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6569 return test_mixed_auth_cipher(
6570 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6574 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6576 return test_mixed_auth_cipher_sgl(
6577 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6581 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6583 return test_mixed_auth_cipher_sgl(
6584 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6587 /** MIXED AUTH + CIPHER */
6590 test_auth_zuc_cipher_snow_test_case_1(void)
6592 return test_mixed_auth_cipher(
6593 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6597 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6599 return test_mixed_auth_cipher(
6600 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6604 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6606 return test_mixed_auth_cipher(
6607 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6611 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6613 return test_mixed_auth_cipher(
6614 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6618 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6620 return test_mixed_auth_cipher(
6621 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6625 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6627 return test_mixed_auth_cipher(
6628 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6632 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6634 return test_mixed_auth_cipher(
6635 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6639 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6641 return test_mixed_auth_cipher(
6642 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6646 test_auth_snow_cipher_zuc_test_case_1(void)
6648 return test_mixed_auth_cipher(
6649 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6653 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6655 return test_mixed_auth_cipher(
6656 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6660 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6662 return test_mixed_auth_cipher(
6663 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6667 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6669 return test_mixed_auth_cipher(
6670 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6674 test_auth_null_cipher_snow_test_case_1(void)
6676 return test_mixed_auth_cipher(
6677 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6681 test_verify_auth_null_cipher_snow_test_case_1(void)
6683 return test_mixed_auth_cipher(
6684 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6688 test_auth_null_cipher_zuc_test_case_1(void)
6690 return test_mixed_auth_cipher(
6691 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6695 test_verify_auth_null_cipher_zuc_test_case_1(void)
6697 return test_mixed_auth_cipher(
6698 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6702 test_auth_snow_cipher_null_test_case_1(void)
6704 return test_mixed_auth_cipher(
6705 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6709 test_verify_auth_snow_cipher_null_test_case_1(void)
6711 return test_mixed_auth_cipher(
6712 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6716 test_auth_zuc_cipher_null_test_case_1(void)
6718 return test_mixed_auth_cipher(
6719 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6723 test_verify_auth_zuc_cipher_null_test_case_1(void)
6725 return test_mixed_auth_cipher(
6726 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6730 test_auth_null_cipher_aes_ctr_test_case_1(void)
6732 return test_mixed_auth_cipher(
6733 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6737 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6739 return test_mixed_auth_cipher(
6740 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6744 test_auth_aes_cmac_cipher_null_test_case_1(void)
6746 return test_mixed_auth_cipher(
6747 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6751 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6753 return test_mixed_auth_cipher(
6754 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6757 /* ***** AEAD algorithm Tests ***** */
6760 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6761 enum rte_crypto_aead_operation op,
6762 const uint8_t *key, const uint8_t key_len,
6763 const uint16_t aad_len, const uint8_t auth_len,
6766 uint8_t aead_key[key_len];
6768 struct crypto_testsuite_params *ts_params = &testsuite_params;
6769 struct crypto_unittest_params *ut_params = &unittest_params;
6771 memcpy(aead_key, key, key_len);
6773 /* Setup AEAD Parameters */
6774 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6775 ut_params->aead_xform.next = NULL;
6776 ut_params->aead_xform.aead.algo = algo;
6777 ut_params->aead_xform.aead.op = op;
6778 ut_params->aead_xform.aead.key.data = aead_key;
6779 ut_params->aead_xform.aead.key.length = key_len;
6780 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6781 ut_params->aead_xform.aead.iv.length = iv_len;
6782 ut_params->aead_xform.aead.digest_length = auth_len;
6783 ut_params->aead_xform.aead.aad_length = aad_len;
6785 debug_hexdump(stdout, "key:", key, key_len);
6787 /* Create Crypto session*/
6788 ut_params->sess = rte_cryptodev_sym_session_create(
6789 ts_params->session_mpool);
6791 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6792 &ut_params->aead_xform,
6793 ts_params->session_priv_mpool);
6795 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6801 create_aead_xform(struct rte_crypto_op *op,
6802 enum rte_crypto_aead_algorithm algo,
6803 enum rte_crypto_aead_operation aead_op,
6804 uint8_t *key, const uint8_t key_len,
6805 const uint8_t aad_len, const uint8_t auth_len,
6808 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6809 "failed to allocate space for crypto transform");
6811 struct rte_crypto_sym_op *sym_op = op->sym;
6813 /* Setup AEAD Parameters */
6814 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6815 sym_op->xform->next = NULL;
6816 sym_op->xform->aead.algo = algo;
6817 sym_op->xform->aead.op = aead_op;
6818 sym_op->xform->aead.key.data = key;
6819 sym_op->xform->aead.key.length = key_len;
6820 sym_op->xform->aead.iv.offset = IV_OFFSET;
6821 sym_op->xform->aead.iv.length = iv_len;
6822 sym_op->xform->aead.digest_length = auth_len;
6823 sym_op->xform->aead.aad_length = aad_len;
6825 debug_hexdump(stdout, "key:", key, key_len);
6831 create_aead_operation(enum rte_crypto_aead_operation op,
6832 const struct aead_test_data *tdata)
6834 struct crypto_testsuite_params *ts_params = &testsuite_params;
6835 struct crypto_unittest_params *ut_params = &unittest_params;
6837 uint8_t *plaintext, *ciphertext;
6838 unsigned int aad_pad_len, plaintext_pad_len;
6840 /* Generate Crypto op data structure */
6841 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6842 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6843 TEST_ASSERT_NOT_NULL(ut_params->op,
6844 "Failed to allocate symmetric crypto operation struct");
6846 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6848 /* Append aad data */
6849 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6850 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6851 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6853 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6854 "no room to append aad");
6856 sym_op->aead.aad.phys_addr =
6857 rte_pktmbuf_iova(ut_params->ibuf);
6858 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6859 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6860 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6863 /* Append IV at the end of the crypto operation*/
6864 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6865 uint8_t *, IV_OFFSET);
6867 /* Copy IV 1 byte after the IV pointer, according to the API */
6868 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6869 debug_hexdump(stdout, "iv:", iv_ptr,
6872 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6873 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6875 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6876 "no room to append aad");
6878 sym_op->aead.aad.phys_addr =
6879 rte_pktmbuf_iova(ut_params->ibuf);
6880 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6881 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6884 /* Append IV at the end of the crypto operation*/
6885 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6886 uint8_t *, IV_OFFSET);
6888 if (tdata->iv.len == 0) {
6889 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6890 debug_hexdump(stdout, "iv:", iv_ptr,
6893 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6894 debug_hexdump(stdout, "iv:", iv_ptr,
6899 /* Append plaintext/ciphertext */
6900 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6901 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6902 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6904 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6906 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6907 debug_hexdump(stdout, "plaintext:", plaintext,
6908 tdata->plaintext.len);
6910 if (ut_params->obuf) {
6911 ciphertext = (uint8_t *)rte_pktmbuf_append(
6913 plaintext_pad_len + aad_pad_len);
6914 TEST_ASSERT_NOT_NULL(ciphertext,
6915 "no room to append ciphertext");
6917 memset(ciphertext + aad_pad_len, 0,
6918 tdata->ciphertext.len);
6921 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6922 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6924 TEST_ASSERT_NOT_NULL(ciphertext,
6925 "no room to append ciphertext");
6927 memcpy(ciphertext, tdata->ciphertext.data,
6928 tdata->ciphertext.len);
6929 debug_hexdump(stdout, "ciphertext:", ciphertext,
6930 tdata->ciphertext.len);
6932 if (ut_params->obuf) {
6933 plaintext = (uint8_t *)rte_pktmbuf_append(
6935 plaintext_pad_len + aad_pad_len);
6936 TEST_ASSERT_NOT_NULL(plaintext,
6937 "no room to append plaintext");
6939 memset(plaintext + aad_pad_len, 0,
6940 tdata->plaintext.len);
6944 /* Append digest data */
6945 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6946 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6947 ut_params->obuf ? ut_params->obuf :
6949 tdata->auth_tag.len);
6950 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6951 "no room to append digest");
6952 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6953 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6954 ut_params->obuf ? ut_params->obuf :
6959 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6960 ut_params->ibuf, tdata->auth_tag.len);
6961 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6962 "no room to append digest");
6963 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6965 plaintext_pad_len + aad_pad_len);
6967 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6968 tdata->auth_tag.len);
6969 debug_hexdump(stdout, "digest:",
6970 sym_op->aead.digest.data,
6971 tdata->auth_tag.len);
6974 sym_op->aead.data.length = tdata->plaintext.len;
6975 sym_op->aead.data.offset = aad_pad_len;
6981 test_authenticated_encryption(const struct aead_test_data *tdata)
6983 struct crypto_testsuite_params *ts_params = &testsuite_params;
6984 struct crypto_unittest_params *ut_params = &unittest_params;
6987 uint8_t *ciphertext, *auth_tag;
6988 uint16_t plaintext_pad_len;
6991 /* Verify the capabilities */
6992 struct rte_cryptodev_sym_capability_idx cap_idx;
6993 const struct rte_cryptodev_symmetric_capability *capability;
6994 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6995 cap_idx.algo.aead = tdata->algo;
6996 capability = rte_cryptodev_sym_capability_get(
6997 ts_params->valid_devs[0], &cap_idx);
6998 if (capability == NULL)
7000 if (rte_cryptodev_sym_capability_check_aead(
7001 capability, tdata->key.len, tdata->auth_tag.len,
7002 tdata->aad.len, tdata->iv.len))
7005 /* Create AEAD session */
7006 retval = create_aead_session(ts_params->valid_devs[0],
7008 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7009 tdata->key.data, tdata->key.len,
7010 tdata->aad.len, tdata->auth_tag.len,
7015 if (tdata->aad.len > MBUF_SIZE) {
7016 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7017 /* Populate full size of add data */
7018 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7019 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7021 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7023 /* clear mbuf payload */
7024 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7025 rte_pktmbuf_tailroom(ut_params->ibuf));
7027 /* Create AEAD operation */
7028 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7032 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7034 ut_params->op->sym->m_src = ut_params->ibuf;
7036 /* Process crypto operation */
7037 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7038 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7040 TEST_ASSERT_NOT_NULL(
7041 process_crypto_request(ts_params->valid_devs[0],
7042 ut_params->op), "failed to process sym crypto op");
7044 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7045 "crypto op processing failed");
7047 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7049 if (ut_params->op->sym->m_dst) {
7050 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7052 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7053 uint8_t *, plaintext_pad_len);
7055 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7057 ut_params->op->sym->cipher.data.offset);
7058 auth_tag = ciphertext + plaintext_pad_len;
7061 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7062 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7065 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7067 tdata->ciphertext.data,
7068 tdata->ciphertext.len,
7069 "Ciphertext data not as expected");
7071 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7073 tdata->auth_tag.data,
7074 tdata->auth_tag.len,
7075 "Generated auth tag not as expected");
7081 #ifdef RTE_LIBRTE_SECURITY
7082 /* Basic algorithm run function for async inplace mode.
7083 * Creates a session from input parameters and runs one operation
7084 * on input_vec. Checks the output of the crypto operation against
7088 test_pdcp_proto(int i, int oop,
7089 enum rte_crypto_cipher_operation opc,
7090 enum rte_crypto_auth_operation opa,
7092 unsigned int input_vec_len,
7093 uint8_t *output_vec,
7094 unsigned int output_vec_len)
7096 struct crypto_testsuite_params *ts_params = &testsuite_params;
7097 struct crypto_unittest_params *ut_params = &unittest_params;
7099 int ret = TEST_SUCCESS;
7100 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7101 rte_cryptodev_get_sec_ctx(
7102 ts_params->valid_devs[0]);
7104 /* Verify the capabilities */
7105 struct rte_security_capability_idx sec_cap_idx;
7107 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7108 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7109 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7110 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7113 /* Generate test mbuf data */
7114 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7116 /* clear mbuf payload */
7117 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7118 rte_pktmbuf_tailroom(ut_params->ibuf));
7120 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7122 memcpy(plaintext, input_vec, input_vec_len);
7124 /* Out of place support */
7127 * For out-op-place we need to alloc another mbuf
7129 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7130 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7133 /* Set crypto type as IPSEC */
7134 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7136 /* Setup Cipher Parameters */
7137 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7138 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7139 ut_params->cipher_xform.cipher.op = opc;
7140 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7141 ut_params->cipher_xform.cipher.key.length =
7142 pdcp_test_params[i].cipher_key_len;
7143 ut_params->cipher_xform.cipher.iv.length = 0;
7145 /* Setup HMAC Parameters if ICV header is required */
7146 if (pdcp_test_params[i].auth_alg != 0) {
7147 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7148 ut_params->auth_xform.next = NULL;
7149 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7150 ut_params->auth_xform.auth.op = opa;
7151 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7152 ut_params->auth_xform.auth.key.length =
7153 pdcp_test_params[i].auth_key_len;
7155 ut_params->cipher_xform.next = &ut_params->auth_xform;
7157 ut_params->cipher_xform.next = NULL;
7160 struct rte_security_session_conf sess_conf = {
7161 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7162 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7164 .bearer = pdcp_test_bearer[i],
7165 .domain = pdcp_test_params[i].domain,
7166 .pkt_dir = pdcp_test_packet_direction[i],
7167 .sn_size = pdcp_test_data_sn_size[i],
7168 .hfn = pdcp_test_hfn[i],
7169 .hfn_threshold = pdcp_test_hfn_threshold[i],
7171 .crypto_xform = &ut_params->cipher_xform
7174 /* Create security session */
7175 ut_params->sec_session = rte_security_session_create(ctx,
7176 &sess_conf, ts_params->session_priv_mpool);
7178 if (!ut_params->sec_session) {
7179 printf("TestCase %s()-%d line %d failed %s: ",
7180 __func__, i, __LINE__, "Failed to allocate session");
7185 /* Generate crypto op data structure */
7186 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7187 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7188 if (!ut_params->op) {
7189 printf("TestCase %s()-%d line %d failed %s: ",
7190 __func__, i, __LINE__,
7191 "Failed to allocate symmetric crypto operation struct");
7196 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7198 /* set crypto operation source mbuf */
7199 ut_params->op->sym->m_src = ut_params->ibuf;
7201 ut_params->op->sym->m_dst = ut_params->obuf;
7203 /* Process crypto operation */
7204 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7206 printf("TestCase %s()-%d line %d failed %s: ",
7207 __func__, i, __LINE__,
7208 "failed to process sym crypto op");
7213 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7214 printf("TestCase %s()-%d line %d failed %s: ",
7215 __func__, i, __LINE__, "crypto op processing failed");
7221 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7224 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7228 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7229 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7230 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7231 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7237 rte_crypto_op_free(ut_params->op);
7238 ut_params->op = NULL;
7240 if (ut_params->sec_session)
7241 rte_security_session_destroy(ctx, ut_params->sec_session);
7242 ut_params->sec_session = NULL;
7244 rte_pktmbuf_free(ut_params->ibuf);
7245 ut_params->ibuf = NULL;
7247 rte_pktmbuf_free(ut_params->obuf);
7248 ut_params->obuf = NULL;
7255 test_pdcp_proto_SGL(int i, int oop,
7256 enum rte_crypto_cipher_operation opc,
7257 enum rte_crypto_auth_operation opa,
7259 unsigned int input_vec_len,
7260 uint8_t *output_vec,
7261 unsigned int output_vec_len,
7263 uint32_t fragsz_oop)
7265 struct crypto_testsuite_params *ts_params = &testsuite_params;
7266 struct crypto_unittest_params *ut_params = &unittest_params;
7268 struct rte_mbuf *buf, *buf_oop = NULL;
7269 int ret = TEST_SUCCESS;
7273 unsigned int trn_data = 0;
7274 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7275 rte_cryptodev_get_sec_ctx(
7276 ts_params->valid_devs[0]);
7278 /* Verify the capabilities */
7279 struct rte_security_capability_idx sec_cap_idx;
7281 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7282 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7283 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7284 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7287 if (fragsz > input_vec_len)
7288 fragsz = input_vec_len;
7290 uint16_t plaintext_len = fragsz;
7291 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7293 if (fragsz_oop > output_vec_len)
7294 frag_size_oop = output_vec_len;
7297 if (input_vec_len % fragsz != 0) {
7298 if (input_vec_len / fragsz + 1 > 16)
7300 } else if (input_vec_len / fragsz > 16)
7303 /* Out of place support */
7306 * For out-op-place we need to alloc another mbuf
7308 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7309 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7310 buf_oop = ut_params->obuf;
7313 /* Generate test mbuf data */
7314 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7316 /* clear mbuf payload */
7317 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7318 rte_pktmbuf_tailroom(ut_params->ibuf));
7320 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7322 memcpy(plaintext, input_vec, plaintext_len);
7323 trn_data += plaintext_len;
7325 buf = ut_params->ibuf;
7328 * Loop until no more fragments
7331 while (trn_data < input_vec_len) {
7333 to_trn = (input_vec_len - trn_data < fragsz) ?
7334 (input_vec_len - trn_data) : fragsz;
7336 to_trn_tbl[ecx++] = to_trn;
7338 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7341 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7342 rte_pktmbuf_tailroom(buf));
7345 if (oop && !fragsz_oop) {
7347 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7348 buf_oop = buf_oop->next;
7349 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7350 0, rte_pktmbuf_tailroom(buf_oop));
7351 rte_pktmbuf_append(buf_oop, to_trn);
7354 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7357 memcpy(plaintext, input_vec + trn_data, to_trn);
7361 ut_params->ibuf->nb_segs = segs;
7364 if (fragsz_oop && oop) {
7368 trn_data = frag_size_oop;
7369 while (trn_data < output_vec_len) {
7372 (output_vec_len - trn_data <
7374 (output_vec_len - trn_data) :
7377 to_trn_tbl[ecx++] = to_trn;
7380 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7381 buf_oop = buf_oop->next;
7382 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7383 0, rte_pktmbuf_tailroom(buf_oop));
7384 rte_pktmbuf_append(buf_oop, to_trn);
7388 ut_params->obuf->nb_segs = segs;
7391 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7393 /* Setup Cipher Parameters */
7394 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7395 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7396 ut_params->cipher_xform.cipher.op = opc;
7397 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7398 ut_params->cipher_xform.cipher.key.length =
7399 pdcp_test_params[i].cipher_key_len;
7400 ut_params->cipher_xform.cipher.iv.length = 0;
7402 /* Setup HMAC Parameters if ICV header is required */
7403 if (pdcp_test_params[i].auth_alg != 0) {
7404 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7405 ut_params->auth_xform.next = NULL;
7406 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7407 ut_params->auth_xform.auth.op = opa;
7408 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7409 ut_params->auth_xform.auth.key.length =
7410 pdcp_test_params[i].auth_key_len;
7412 ut_params->cipher_xform.next = &ut_params->auth_xform;
7414 ut_params->cipher_xform.next = NULL;
7417 struct rte_security_session_conf sess_conf = {
7418 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7419 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7421 .bearer = pdcp_test_bearer[i],
7422 .domain = pdcp_test_params[i].domain,
7423 .pkt_dir = pdcp_test_packet_direction[i],
7424 .sn_size = pdcp_test_data_sn_size[i],
7425 .hfn = pdcp_test_hfn[i],
7426 .hfn_threshold = pdcp_test_hfn_threshold[i],
7428 .crypto_xform = &ut_params->cipher_xform
7431 /* Create security session */
7432 ut_params->sec_session = rte_security_session_create(ctx,
7433 &sess_conf, ts_params->session_priv_mpool);
7435 if (!ut_params->sec_session) {
7436 printf("TestCase %s()-%d line %d failed %s: ",
7437 __func__, i, __LINE__, "Failed to allocate session");
7442 /* Generate crypto op data structure */
7443 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7444 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7445 if (!ut_params->op) {
7446 printf("TestCase %s()-%d line %d failed %s: ",
7447 __func__, i, __LINE__,
7448 "Failed to allocate symmetric crypto operation struct");
7453 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7455 /* set crypto operation source mbuf */
7456 ut_params->op->sym->m_src = ut_params->ibuf;
7458 ut_params->op->sym->m_dst = ut_params->obuf;
7460 /* Process crypto operation */
7461 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7463 printf("TestCase %s()-%d line %d failed %s: ",
7464 __func__, i, __LINE__,
7465 "failed to process sym crypto op");
7470 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7471 printf("TestCase %s()-%d line %d failed %s: ",
7472 __func__, i, __LINE__, "crypto op processing failed");
7478 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7481 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7485 fragsz = frag_size_oop;
7486 if (memcmp(ciphertext, output_vec, fragsz)) {
7487 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7488 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7489 rte_hexdump(stdout, "reference", output_vec, fragsz);
7494 buf = ut_params->op->sym->m_src->next;
7496 buf = ut_params->op->sym->m_dst->next;
7498 unsigned int off = fragsz;
7502 ciphertext = rte_pktmbuf_mtod(buf,
7504 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7505 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7506 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7507 rte_hexdump(stdout, "reference", output_vec + off,
7512 off += to_trn_tbl[ecx++];
7516 rte_crypto_op_free(ut_params->op);
7517 ut_params->op = NULL;
7519 if (ut_params->sec_session)
7520 rte_security_session_destroy(ctx, ut_params->sec_session);
7521 ut_params->sec_session = NULL;
7523 rte_pktmbuf_free(ut_params->ibuf);
7524 ut_params->ibuf = NULL;
7526 rte_pktmbuf_free(ut_params->obuf);
7527 ut_params->obuf = NULL;
7534 test_pdcp_proto_cplane_encap(int i)
7536 return test_pdcp_proto(i, 0,
7537 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7538 RTE_CRYPTO_AUTH_OP_GENERATE,
7539 pdcp_test_data_in[i],
7540 pdcp_test_data_in_len[i],
7541 pdcp_test_data_out[i],
7542 pdcp_test_data_in_len[i]+4);
7546 test_pdcp_proto_uplane_encap(int i)
7548 return test_pdcp_proto(i, 0,
7549 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7550 RTE_CRYPTO_AUTH_OP_GENERATE,
7551 pdcp_test_data_in[i],
7552 pdcp_test_data_in_len[i],
7553 pdcp_test_data_out[i],
7554 pdcp_test_data_in_len[i]);
7559 test_pdcp_proto_uplane_encap_with_int(int i)
7561 return test_pdcp_proto(i, 0,
7562 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7563 RTE_CRYPTO_AUTH_OP_GENERATE,
7564 pdcp_test_data_in[i],
7565 pdcp_test_data_in_len[i],
7566 pdcp_test_data_out[i],
7567 pdcp_test_data_in_len[i] + 4);
7571 test_pdcp_proto_cplane_decap(int i)
7573 return test_pdcp_proto(i, 0,
7574 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7575 RTE_CRYPTO_AUTH_OP_VERIFY,
7576 pdcp_test_data_out[i],
7577 pdcp_test_data_in_len[i] + 4,
7578 pdcp_test_data_in[i],
7579 pdcp_test_data_in_len[i]);
7583 test_pdcp_proto_uplane_decap(int i)
7585 return test_pdcp_proto(i, 0,
7586 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7587 RTE_CRYPTO_AUTH_OP_VERIFY,
7588 pdcp_test_data_out[i],
7589 pdcp_test_data_in_len[i],
7590 pdcp_test_data_in[i],
7591 pdcp_test_data_in_len[i]);
7595 test_pdcp_proto_uplane_decap_with_int(int i)
7597 return test_pdcp_proto(i, 0,
7598 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7599 RTE_CRYPTO_AUTH_OP_VERIFY,
7600 pdcp_test_data_out[i],
7601 pdcp_test_data_in_len[i] + 4,
7602 pdcp_test_data_in[i],
7603 pdcp_test_data_in_len[i]);
7607 test_PDCP_PROTO_SGL_in_place_32B(void)
7609 /* i can be used for running any PDCP case
7610 * In this case it is uplane 12-bit AES-SNOW DL encap
7612 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7613 return test_pdcp_proto_SGL(i, IN_PLACE,
7614 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7615 RTE_CRYPTO_AUTH_OP_GENERATE,
7616 pdcp_test_data_in[i],
7617 pdcp_test_data_in_len[i],
7618 pdcp_test_data_out[i],
7619 pdcp_test_data_in_len[i]+4,
7623 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7625 /* i can be used for running any PDCP case
7626 * In this case it is uplane 18-bit NULL-NULL DL encap
7628 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7629 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7630 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7631 RTE_CRYPTO_AUTH_OP_GENERATE,
7632 pdcp_test_data_in[i],
7633 pdcp_test_data_in_len[i],
7634 pdcp_test_data_out[i],
7635 pdcp_test_data_in_len[i]+4,
7639 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7641 /* i can be used for running any PDCP case
7642 * In this case it is uplane 18-bit AES DL encap
7644 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7646 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7647 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7648 RTE_CRYPTO_AUTH_OP_GENERATE,
7649 pdcp_test_data_in[i],
7650 pdcp_test_data_in_len[i],
7651 pdcp_test_data_out[i],
7652 pdcp_test_data_in_len[i],
7656 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7658 /* i can be used for running any PDCP case
7659 * In this case it is cplane 12-bit AES-ZUC DL encap
7661 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7662 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7663 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7664 RTE_CRYPTO_AUTH_OP_GENERATE,
7665 pdcp_test_data_in[i],
7666 pdcp_test_data_in_len[i],
7667 pdcp_test_data_out[i],
7668 pdcp_test_data_in_len[i]+4,
7674 test_AES_GCM_authenticated_encryption_test_case_1(void)
7676 return test_authenticated_encryption(&gcm_test_case_1);
7680 test_AES_GCM_authenticated_encryption_test_case_2(void)
7682 return test_authenticated_encryption(&gcm_test_case_2);
7686 test_AES_GCM_authenticated_encryption_test_case_3(void)
7688 return test_authenticated_encryption(&gcm_test_case_3);
7692 test_AES_GCM_authenticated_encryption_test_case_4(void)
7694 return test_authenticated_encryption(&gcm_test_case_4);
7698 test_AES_GCM_authenticated_encryption_test_case_5(void)
7700 return test_authenticated_encryption(&gcm_test_case_5);
7704 test_AES_GCM_authenticated_encryption_test_case_6(void)
7706 return test_authenticated_encryption(&gcm_test_case_6);
7710 test_AES_GCM_authenticated_encryption_test_case_7(void)
7712 return test_authenticated_encryption(&gcm_test_case_7);
7716 test_AES_GCM_authenticated_encryption_test_case_8(void)
7718 return test_authenticated_encryption(&gcm_test_case_8);
7722 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7724 return test_authenticated_encryption(&gcm_J0_test_case_1);
7728 test_AES_GCM_auth_encryption_test_case_192_1(void)
7730 return test_authenticated_encryption(&gcm_test_case_192_1);
7734 test_AES_GCM_auth_encryption_test_case_192_2(void)
7736 return test_authenticated_encryption(&gcm_test_case_192_2);
7740 test_AES_GCM_auth_encryption_test_case_192_3(void)
7742 return test_authenticated_encryption(&gcm_test_case_192_3);
7746 test_AES_GCM_auth_encryption_test_case_192_4(void)
7748 return test_authenticated_encryption(&gcm_test_case_192_4);
7752 test_AES_GCM_auth_encryption_test_case_192_5(void)
7754 return test_authenticated_encryption(&gcm_test_case_192_5);
7758 test_AES_GCM_auth_encryption_test_case_192_6(void)
7760 return test_authenticated_encryption(&gcm_test_case_192_6);
7764 test_AES_GCM_auth_encryption_test_case_192_7(void)
7766 return test_authenticated_encryption(&gcm_test_case_192_7);
7770 test_AES_GCM_auth_encryption_test_case_256_1(void)
7772 return test_authenticated_encryption(&gcm_test_case_256_1);
7776 test_AES_GCM_auth_encryption_test_case_256_2(void)
7778 return test_authenticated_encryption(&gcm_test_case_256_2);
7782 test_AES_GCM_auth_encryption_test_case_256_3(void)
7784 return test_authenticated_encryption(&gcm_test_case_256_3);
7788 test_AES_GCM_auth_encryption_test_case_256_4(void)
7790 return test_authenticated_encryption(&gcm_test_case_256_4);
7794 test_AES_GCM_auth_encryption_test_case_256_5(void)
7796 return test_authenticated_encryption(&gcm_test_case_256_5);
7800 test_AES_GCM_auth_encryption_test_case_256_6(void)
7802 return test_authenticated_encryption(&gcm_test_case_256_6);
7806 test_AES_GCM_auth_encryption_test_case_256_7(void)
7808 return test_authenticated_encryption(&gcm_test_case_256_7);
7812 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7814 return test_authenticated_encryption(&gcm_test_case_aad_1);
7818 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7820 return test_authenticated_encryption(&gcm_test_case_aad_2);
7824 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7826 struct aead_test_data tdata;
7829 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7830 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7831 tdata.iv.data[0] += 1;
7832 res = test_authenticated_encryption(&tdata);
7833 if (res == -ENOTSUP)
7835 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7836 return TEST_SUCCESS;
7840 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7842 struct aead_test_data tdata;
7845 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7846 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7847 tdata.plaintext.data[0] += 1;
7848 res = test_authenticated_encryption(&tdata);
7849 if (res == -ENOTSUP)
7851 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7852 return TEST_SUCCESS;
7856 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7858 struct aead_test_data tdata;
7861 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7862 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7863 tdata.ciphertext.data[0] += 1;
7864 res = test_authenticated_encryption(&tdata);
7865 if (res == -ENOTSUP)
7867 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7868 return TEST_SUCCESS;
7872 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7874 struct aead_test_data tdata;
7877 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7878 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7880 res = test_authenticated_encryption(&tdata);
7881 if (res == -ENOTSUP)
7883 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7884 return TEST_SUCCESS;
7888 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7890 struct aead_test_data tdata;
7891 uint8_t aad[gcm_test_case_7.aad.len];
7894 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7895 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7896 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7898 tdata.aad.data = aad;
7899 res = test_authenticated_encryption(&tdata);
7900 if (res == -ENOTSUP)
7902 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7903 return TEST_SUCCESS;
7907 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7909 struct aead_test_data tdata;
7912 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7913 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7914 tdata.auth_tag.data[0] += 1;
7915 res = test_authenticated_encryption(&tdata);
7916 if (res == -ENOTSUP)
7918 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7919 return TEST_SUCCESS;
7923 test_authenticated_decryption(const struct aead_test_data *tdata)
7925 struct crypto_testsuite_params *ts_params = &testsuite_params;
7926 struct crypto_unittest_params *ut_params = &unittest_params;
7932 /* Verify the capabilities */
7933 struct rte_cryptodev_sym_capability_idx cap_idx;
7934 const struct rte_cryptodev_symmetric_capability *capability;
7935 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7936 cap_idx.algo.aead = tdata->algo;
7937 capability = rte_cryptodev_sym_capability_get(
7938 ts_params->valid_devs[0], &cap_idx);
7939 if (capability == NULL)
7941 if (rte_cryptodev_sym_capability_check_aead(
7942 capability, tdata->key.len, tdata->auth_tag.len,
7943 tdata->aad.len, tdata->iv.len))
7946 /* Create AEAD session */
7947 retval = create_aead_session(ts_params->valid_devs[0],
7949 RTE_CRYPTO_AEAD_OP_DECRYPT,
7950 tdata->key.data, tdata->key.len,
7951 tdata->aad.len, tdata->auth_tag.len,
7956 /* alloc mbuf and set payload */
7957 if (tdata->aad.len > MBUF_SIZE) {
7958 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7959 /* Populate full size of add data */
7960 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7961 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7963 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7965 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7966 rte_pktmbuf_tailroom(ut_params->ibuf));
7968 /* Create AEAD operation */
7969 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7973 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7975 ut_params->op->sym->m_src = ut_params->ibuf;
7977 /* Process crypto operation */
7978 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7979 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7981 TEST_ASSERT_NOT_NULL(
7982 process_crypto_request(ts_params->valid_devs[0],
7983 ut_params->op), "failed to process sym crypto op");
7985 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7986 "crypto op processing failed");
7988 if (ut_params->op->sym->m_dst)
7989 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7992 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7994 ut_params->op->sym->cipher.data.offset);
7996 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7999 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8001 tdata->plaintext.data,
8002 tdata->plaintext.len,
8003 "Plaintext data not as expected");
8005 TEST_ASSERT_EQUAL(ut_params->op->status,
8006 RTE_CRYPTO_OP_STATUS_SUCCESS,
8007 "Authentication failed");
8013 test_AES_GCM_authenticated_decryption_test_case_1(void)
8015 return test_authenticated_decryption(&gcm_test_case_1);
8019 test_AES_GCM_authenticated_decryption_test_case_2(void)
8021 return test_authenticated_decryption(&gcm_test_case_2);
8025 test_AES_GCM_authenticated_decryption_test_case_3(void)
8027 return test_authenticated_decryption(&gcm_test_case_3);
8031 test_AES_GCM_authenticated_decryption_test_case_4(void)
8033 return test_authenticated_decryption(&gcm_test_case_4);
8037 test_AES_GCM_authenticated_decryption_test_case_5(void)
8039 return test_authenticated_decryption(&gcm_test_case_5);
8043 test_AES_GCM_authenticated_decryption_test_case_6(void)
8045 return test_authenticated_decryption(&gcm_test_case_6);
8049 test_AES_GCM_authenticated_decryption_test_case_7(void)
8051 return test_authenticated_decryption(&gcm_test_case_7);
8055 test_AES_GCM_authenticated_decryption_test_case_8(void)
8057 return test_authenticated_decryption(&gcm_test_case_8);
8061 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8063 return test_authenticated_decryption(&gcm_J0_test_case_1);
8067 test_AES_GCM_auth_decryption_test_case_192_1(void)
8069 return test_authenticated_decryption(&gcm_test_case_192_1);
8073 test_AES_GCM_auth_decryption_test_case_192_2(void)
8075 return test_authenticated_decryption(&gcm_test_case_192_2);
8079 test_AES_GCM_auth_decryption_test_case_192_3(void)
8081 return test_authenticated_decryption(&gcm_test_case_192_3);
8085 test_AES_GCM_auth_decryption_test_case_192_4(void)
8087 return test_authenticated_decryption(&gcm_test_case_192_4);
8091 test_AES_GCM_auth_decryption_test_case_192_5(void)
8093 return test_authenticated_decryption(&gcm_test_case_192_5);
8097 test_AES_GCM_auth_decryption_test_case_192_6(void)
8099 return test_authenticated_decryption(&gcm_test_case_192_6);
8103 test_AES_GCM_auth_decryption_test_case_192_7(void)
8105 return test_authenticated_decryption(&gcm_test_case_192_7);
8109 test_AES_GCM_auth_decryption_test_case_256_1(void)
8111 return test_authenticated_decryption(&gcm_test_case_256_1);
8115 test_AES_GCM_auth_decryption_test_case_256_2(void)
8117 return test_authenticated_decryption(&gcm_test_case_256_2);
8121 test_AES_GCM_auth_decryption_test_case_256_3(void)
8123 return test_authenticated_decryption(&gcm_test_case_256_3);
8127 test_AES_GCM_auth_decryption_test_case_256_4(void)
8129 return test_authenticated_decryption(&gcm_test_case_256_4);
8133 test_AES_GCM_auth_decryption_test_case_256_5(void)
8135 return test_authenticated_decryption(&gcm_test_case_256_5);
8139 test_AES_GCM_auth_decryption_test_case_256_6(void)
8141 return test_authenticated_decryption(&gcm_test_case_256_6);
8145 test_AES_GCM_auth_decryption_test_case_256_7(void)
8147 return test_authenticated_decryption(&gcm_test_case_256_7);
8151 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8153 return test_authenticated_decryption(&gcm_test_case_aad_1);
8157 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8159 return test_authenticated_decryption(&gcm_test_case_aad_2);
8163 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8165 struct aead_test_data tdata;
8168 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8169 tdata.iv.data[0] += 1;
8170 res = test_authenticated_decryption(&tdata);
8171 if (res == -ENOTSUP)
8173 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8174 return TEST_SUCCESS;
8178 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8180 struct aead_test_data tdata;
8183 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8184 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8185 tdata.plaintext.data[0] += 1;
8186 res = test_authenticated_decryption(&tdata);
8187 if (res == -ENOTSUP)
8189 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8190 return TEST_SUCCESS;
8194 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8196 struct aead_test_data tdata;
8199 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8200 tdata.ciphertext.data[0] += 1;
8201 res = test_authenticated_decryption(&tdata);
8202 if (res == -ENOTSUP)
8204 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8205 return TEST_SUCCESS;
8209 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8211 struct aead_test_data tdata;
8214 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8216 res = test_authenticated_decryption(&tdata);
8217 if (res == -ENOTSUP)
8219 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8220 return TEST_SUCCESS;
8224 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8226 struct aead_test_data tdata;
8227 uint8_t aad[gcm_test_case_7.aad.len];
8230 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8231 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8233 tdata.aad.data = aad;
8234 res = test_authenticated_decryption(&tdata);
8235 if (res == -ENOTSUP)
8237 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8238 return TEST_SUCCESS;
8242 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8244 struct aead_test_data tdata;
8247 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8248 tdata.auth_tag.data[0] += 1;
8249 res = test_authenticated_decryption(&tdata);
8250 if (res == -ENOTSUP)
8252 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8253 return TEST_SUCCESS;
8257 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8259 struct crypto_testsuite_params *ts_params = &testsuite_params;
8260 struct crypto_unittest_params *ut_params = &unittest_params;
8263 uint8_t *ciphertext, *auth_tag;
8264 uint16_t plaintext_pad_len;
8266 /* Verify the capabilities */
8267 struct rte_cryptodev_sym_capability_idx cap_idx;
8268 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8269 cap_idx.algo.aead = tdata->algo;
8270 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8274 /* not supported with CPU crypto */
8275 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8278 /* Create AEAD session */
8279 retval = create_aead_session(ts_params->valid_devs[0],
8281 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8282 tdata->key.data, tdata->key.len,
8283 tdata->aad.len, tdata->auth_tag.len,
8288 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8289 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8291 /* clear mbuf payload */
8292 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8293 rte_pktmbuf_tailroom(ut_params->ibuf));
8294 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8295 rte_pktmbuf_tailroom(ut_params->obuf));
8297 /* Create AEAD operation */
8298 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8302 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8304 ut_params->op->sym->m_src = ut_params->ibuf;
8305 ut_params->op->sym->m_dst = ut_params->obuf;
8307 /* Process crypto operation */
8308 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8309 ut_params->op), "failed to process sym crypto op");
8311 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8312 "crypto op processing failed");
8314 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8316 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8317 ut_params->op->sym->cipher.data.offset);
8318 auth_tag = ciphertext + plaintext_pad_len;
8320 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8321 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8324 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8326 tdata->ciphertext.data,
8327 tdata->ciphertext.len,
8328 "Ciphertext data not as expected");
8330 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8332 tdata->auth_tag.data,
8333 tdata->auth_tag.len,
8334 "Generated auth tag not as expected");
8341 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8343 return test_authenticated_encryption_oop(&gcm_test_case_5);
8347 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8349 struct crypto_testsuite_params *ts_params = &testsuite_params;
8350 struct crypto_unittest_params *ut_params = &unittest_params;
8355 /* Verify the capabilities */
8356 struct rte_cryptodev_sym_capability_idx cap_idx;
8357 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8358 cap_idx.algo.aead = tdata->algo;
8359 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8363 /* not supported with CPU crypto */
8364 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8367 /* Create AEAD session */
8368 retval = create_aead_session(ts_params->valid_devs[0],
8370 RTE_CRYPTO_AEAD_OP_DECRYPT,
8371 tdata->key.data, tdata->key.len,
8372 tdata->aad.len, tdata->auth_tag.len,
8377 /* alloc mbuf and set payload */
8378 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8379 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8381 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8382 rte_pktmbuf_tailroom(ut_params->ibuf));
8383 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8384 rte_pktmbuf_tailroom(ut_params->obuf));
8386 /* Create AEAD operation */
8387 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8391 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8393 ut_params->op->sym->m_src = ut_params->ibuf;
8394 ut_params->op->sym->m_dst = ut_params->obuf;
8396 /* Process crypto operation */
8397 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8398 ut_params->op), "failed to process sym crypto op");
8400 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8401 "crypto op processing failed");
8403 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8404 ut_params->op->sym->cipher.data.offset);
8406 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8409 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8411 tdata->plaintext.data,
8412 tdata->plaintext.len,
8413 "Plaintext data not as expected");
8415 TEST_ASSERT_EQUAL(ut_params->op->status,
8416 RTE_CRYPTO_OP_STATUS_SUCCESS,
8417 "Authentication failed");
8422 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8424 return test_authenticated_decryption_oop(&gcm_test_case_5);
8428 test_authenticated_encryption_sessionless(
8429 const struct aead_test_data *tdata)
8431 struct crypto_testsuite_params *ts_params = &testsuite_params;
8432 struct crypto_unittest_params *ut_params = &unittest_params;
8435 uint8_t *ciphertext, *auth_tag;
8436 uint16_t plaintext_pad_len;
8437 uint8_t key[tdata->key.len + 1];
8439 /* This test is for AESNI MB and AESNI GCM PMDs only */
8440 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8441 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8442 (gbl_driver_id != rte_cryptodev_driver_id_get(
8443 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8446 /* not supported with CPU crypto */
8447 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8450 /* Verify the capabilities */
8451 struct rte_cryptodev_sym_capability_idx cap_idx;
8452 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8453 cap_idx.algo.aead = tdata->algo;
8454 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8458 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8460 /* clear mbuf payload */
8461 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8462 rte_pktmbuf_tailroom(ut_params->ibuf));
8464 /* Create AEAD operation */
8465 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8469 /* Create GCM xform */
8470 memcpy(key, tdata->key.data, tdata->key.len);
8471 retval = create_aead_xform(ut_params->op,
8473 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8474 key, tdata->key.len,
8475 tdata->aad.len, tdata->auth_tag.len,
8480 ut_params->op->sym->m_src = ut_params->ibuf;
8482 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8483 RTE_CRYPTO_OP_SESSIONLESS,
8484 "crypto op session type not sessionless");
8486 /* Process crypto operation */
8487 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8488 ut_params->op), "failed to process sym crypto op");
8490 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8492 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8493 "crypto op status not success");
8495 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8497 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8498 ut_params->op->sym->cipher.data.offset);
8499 auth_tag = ciphertext + plaintext_pad_len;
8501 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8502 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8505 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8507 tdata->ciphertext.data,
8508 tdata->ciphertext.len,
8509 "Ciphertext data not as expected");
8511 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8513 tdata->auth_tag.data,
8514 tdata->auth_tag.len,
8515 "Generated auth tag not as expected");
8522 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8524 return test_authenticated_encryption_sessionless(
8529 test_authenticated_decryption_sessionless(
8530 const struct aead_test_data *tdata)
8532 struct crypto_testsuite_params *ts_params = &testsuite_params;
8533 struct crypto_unittest_params *ut_params = &unittest_params;
8537 uint8_t key[tdata->key.len + 1];
8539 /* This test is for AESNI MB and AESNI GCM PMDs only */
8540 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8541 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8542 (gbl_driver_id != rte_cryptodev_driver_id_get(
8543 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8546 /* not supported with CPU crypto */
8547 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8550 /* Verify the capabilities */
8551 struct rte_cryptodev_sym_capability_idx cap_idx;
8552 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8553 cap_idx.algo.aead = tdata->algo;
8554 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8558 /* alloc mbuf and set payload */
8559 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8561 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8562 rte_pktmbuf_tailroom(ut_params->ibuf));
8564 /* Create AEAD operation */
8565 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8569 /* Create AEAD xform */
8570 memcpy(key, tdata->key.data, tdata->key.len);
8571 retval = create_aead_xform(ut_params->op,
8573 RTE_CRYPTO_AEAD_OP_DECRYPT,
8574 key, tdata->key.len,
8575 tdata->aad.len, tdata->auth_tag.len,
8580 ut_params->op->sym->m_src = ut_params->ibuf;
8582 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8583 RTE_CRYPTO_OP_SESSIONLESS,
8584 "crypto op session type not sessionless");
8586 /* Process crypto operation */
8587 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8588 ut_params->op), "failed to process sym crypto op");
8590 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8592 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8593 "crypto op status not success");
8595 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8596 ut_params->op->sym->cipher.data.offset);
8598 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8601 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8603 tdata->plaintext.data,
8604 tdata->plaintext.len,
8605 "Plaintext data not as expected");
8607 TEST_ASSERT_EQUAL(ut_params->op->status,
8608 RTE_CRYPTO_OP_STATUS_SUCCESS,
8609 "Authentication failed");
8614 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8616 return test_authenticated_decryption_sessionless(
8621 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8623 return test_authenticated_encryption(&ccm_test_case_128_1);
8627 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8629 return test_authenticated_encryption(&ccm_test_case_128_2);
8633 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8635 return test_authenticated_encryption(&ccm_test_case_128_3);
8639 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8641 return test_authenticated_decryption(&ccm_test_case_128_1);
8645 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8647 return test_authenticated_decryption(&ccm_test_case_128_2);
8651 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8653 return test_authenticated_decryption(&ccm_test_case_128_3);
8657 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8659 return test_authenticated_encryption(&ccm_test_case_192_1);
8663 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8665 return test_authenticated_encryption(&ccm_test_case_192_2);
8669 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8671 return test_authenticated_encryption(&ccm_test_case_192_3);
8675 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8677 return test_authenticated_decryption(&ccm_test_case_192_1);
8681 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8683 return test_authenticated_decryption(&ccm_test_case_192_2);
8687 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8689 return test_authenticated_decryption(&ccm_test_case_192_3);
8693 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8695 return test_authenticated_encryption(&ccm_test_case_256_1);
8699 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8701 return test_authenticated_encryption(&ccm_test_case_256_2);
8705 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8707 return test_authenticated_encryption(&ccm_test_case_256_3);
8711 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8713 return test_authenticated_decryption(&ccm_test_case_256_1);
8717 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8719 return test_authenticated_decryption(&ccm_test_case_256_2);
8723 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8725 return test_authenticated_decryption(&ccm_test_case_256_3);
8731 struct crypto_testsuite_params *ts_params = &testsuite_params;
8732 struct rte_cryptodev_stats stats;
8733 struct rte_cryptodev *dev;
8734 cryptodev_stats_get_t temp_pfn;
8736 /* Verify the capabilities */
8737 struct rte_cryptodev_sym_capability_idx cap_idx;
8738 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8739 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8740 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8743 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8744 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8745 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8749 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8750 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8751 &stats) == -ENODEV),
8752 "rte_cryptodev_stats_get invalid dev failed");
8753 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8754 "rte_cryptodev_stats_get invalid Param failed");
8755 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8756 temp_pfn = dev->dev_ops->stats_get;
8757 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8758 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8760 "rte_cryptodev_stats_get invalid Param failed");
8761 dev->dev_ops->stats_get = temp_pfn;
8763 /* Test expected values */
8765 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8767 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8769 "rte_cryptodev_stats_get failed");
8770 TEST_ASSERT((stats.enqueued_count == 1),
8771 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8772 TEST_ASSERT((stats.dequeued_count == 1),
8773 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8774 TEST_ASSERT((stats.enqueue_err_count == 0),
8775 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8776 TEST_ASSERT((stats.dequeue_err_count == 0),
8777 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8779 /* invalid device but should ignore and not reset device stats*/
8780 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8781 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8783 "rte_cryptodev_stats_get failed");
8784 TEST_ASSERT((stats.enqueued_count == 1),
8785 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8787 /* check that a valid reset clears stats */
8788 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8789 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8791 "rte_cryptodev_stats_get failed");
8792 TEST_ASSERT((stats.enqueued_count == 0),
8793 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8794 TEST_ASSERT((stats.dequeued_count == 0),
8795 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8797 return TEST_SUCCESS;
8800 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8801 struct crypto_unittest_params *ut_params,
8802 enum rte_crypto_auth_operation op,
8803 const struct HMAC_MD5_vector *test_case)
8807 memcpy(key, test_case->key.data, test_case->key.len);
8809 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8810 ut_params->auth_xform.next = NULL;
8811 ut_params->auth_xform.auth.op = op;
8813 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8815 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8816 ut_params->auth_xform.auth.key.length = test_case->key.len;
8817 ut_params->auth_xform.auth.key.data = key;
8819 ut_params->sess = rte_cryptodev_sym_session_create(
8820 ts_params->session_mpool);
8822 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8823 ut_params->sess, &ut_params->auth_xform,
8824 ts_params->session_priv_mpool);
8826 if (ut_params->sess == NULL)
8829 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8831 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8832 rte_pktmbuf_tailroom(ut_params->ibuf));
8837 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8838 const struct HMAC_MD5_vector *test_case,
8839 uint8_t **plaintext)
8841 uint16_t plaintext_pad_len;
8843 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8845 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8848 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8850 memcpy(*plaintext, test_case->plaintext.data,
8851 test_case->plaintext.len);
8853 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8854 ut_params->ibuf, MD5_DIGEST_LEN);
8855 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8856 "no room to append digest");
8857 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8858 ut_params->ibuf, plaintext_pad_len);
8860 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8861 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8862 test_case->auth_tag.len);
8865 sym_op->auth.data.offset = 0;
8866 sym_op->auth.data.length = test_case->plaintext.len;
8868 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8869 ut_params->op->sym->m_src = ut_params->ibuf;
8875 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8877 uint16_t plaintext_pad_len;
8878 uint8_t *plaintext, *auth_tag;
8880 struct crypto_testsuite_params *ts_params = &testsuite_params;
8881 struct crypto_unittest_params *ut_params = &unittest_params;
8883 /* Verify the capabilities */
8884 struct rte_cryptodev_sym_capability_idx cap_idx;
8885 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8886 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8887 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8891 if (MD5_HMAC_create_session(ts_params, ut_params,
8892 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8895 /* Generate Crypto op data structure */
8896 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8897 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8898 TEST_ASSERT_NOT_NULL(ut_params->op,
8899 "Failed to allocate symmetric crypto operation struct");
8901 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8904 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8907 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8908 ut_params->op), "failed to process sym crypto op");
8910 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8911 "crypto op processing failed");
8913 if (ut_params->op->sym->m_dst) {
8914 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8915 uint8_t *, plaintext_pad_len);
8917 auth_tag = plaintext + plaintext_pad_len;
8920 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8922 test_case->auth_tag.data,
8923 test_case->auth_tag.len,
8924 "HMAC_MD5 generated tag not as expected");
8926 return TEST_SUCCESS;
8930 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8934 struct crypto_testsuite_params *ts_params = &testsuite_params;
8935 struct crypto_unittest_params *ut_params = &unittest_params;
8937 /* Verify the capabilities */
8938 struct rte_cryptodev_sym_capability_idx cap_idx;
8939 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8940 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8941 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8945 if (MD5_HMAC_create_session(ts_params, ut_params,
8946 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8950 /* Generate Crypto op data structure */
8951 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8952 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8953 TEST_ASSERT_NOT_NULL(ut_params->op,
8954 "Failed to allocate symmetric crypto operation struct");
8956 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8959 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8960 ut_params->op), "failed to process sym crypto op");
8962 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8963 "HMAC_MD5 crypto op processing failed");
8965 return TEST_SUCCESS;
8969 test_MD5_HMAC_generate_case_1(void)
8971 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
8975 test_MD5_HMAC_verify_case_1(void)
8977 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
8981 test_MD5_HMAC_generate_case_2(void)
8983 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
8987 test_MD5_HMAC_verify_case_2(void)
8989 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
8993 test_multi_session(void)
8995 struct crypto_testsuite_params *ts_params = &testsuite_params;
8996 struct crypto_unittest_params *ut_params = &unittest_params;
8998 struct rte_cryptodev_info dev_info;
8999 struct rte_cryptodev_sym_session **sessions;
9003 /* Verify the capabilities */
9004 struct rte_cryptodev_sym_capability_idx cap_idx;
9005 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9006 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9007 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9010 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9011 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9012 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9016 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9017 aes_cbc_key, hmac_sha512_key);
9020 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9022 sessions = rte_malloc(NULL,
9023 (sizeof(struct rte_cryptodev_sym_session *) *
9024 MAX_NB_SESSIONS) + 1, 0);
9026 /* Create multiple crypto sessions*/
9027 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9029 sessions[i] = rte_cryptodev_sym_session_create(
9030 ts_params->session_mpool);
9032 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9033 sessions[i], &ut_params->auth_xform,
9034 ts_params->session_priv_mpool);
9035 TEST_ASSERT_NOT_NULL(sessions[i],
9036 "Session creation failed at session number %u",
9039 /* Attempt to send a request on each session */
9040 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9044 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9045 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9047 "Failed to perform decrypt on request number %u.", i);
9048 /* free crypto operation structure */
9050 rte_crypto_op_free(ut_params->op);
9053 * free mbuf - both obuf and ibuf are usually the same,
9054 * so check if they point at the same address is necessary,
9055 * to avoid freeing the mbuf twice.
9057 if (ut_params->obuf) {
9058 rte_pktmbuf_free(ut_params->obuf);
9059 if (ut_params->ibuf == ut_params->obuf)
9060 ut_params->ibuf = 0;
9061 ut_params->obuf = 0;
9063 if (ut_params->ibuf) {
9064 rte_pktmbuf_free(ut_params->ibuf);
9065 ut_params->ibuf = 0;
9069 /* Next session create should fail */
9070 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9071 sessions[i], &ut_params->auth_xform,
9072 ts_params->session_priv_mpool);
9073 TEST_ASSERT_NULL(sessions[i],
9074 "Session creation succeeded unexpectedly!");
9076 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9077 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9079 rte_cryptodev_sym_session_free(sessions[i]);
9084 return TEST_SUCCESS;
9087 struct multi_session_params {
9088 struct crypto_unittest_params ut_params;
9089 uint8_t *cipher_key;
9091 const uint8_t *cipher;
9092 const uint8_t *digest;
9096 #define MB_SESSION_NUMBER 3
9099 test_multi_session_random_usage(void)
9101 struct crypto_testsuite_params *ts_params = &testsuite_params;
9102 struct rte_cryptodev_info dev_info;
9103 struct rte_cryptodev_sym_session **sessions;
9105 struct multi_session_params ut_paramz[] = {
9108 .cipher_key = ms_aes_cbc_key0,
9109 .hmac_key = ms_hmac_key0,
9110 .cipher = ms_aes_cbc_cipher0,
9111 .digest = ms_hmac_digest0,
9112 .iv = ms_aes_cbc_iv0
9115 .cipher_key = ms_aes_cbc_key1,
9116 .hmac_key = ms_hmac_key1,
9117 .cipher = ms_aes_cbc_cipher1,
9118 .digest = ms_hmac_digest1,
9119 .iv = ms_aes_cbc_iv1
9122 .cipher_key = ms_aes_cbc_key2,
9123 .hmac_key = ms_hmac_key2,
9124 .cipher = ms_aes_cbc_cipher2,
9125 .digest = ms_hmac_digest2,
9126 .iv = ms_aes_cbc_iv2
9131 /* Verify the capabilities */
9132 struct rte_cryptodev_sym_capability_idx cap_idx;
9133 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9134 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9135 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9138 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9139 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9140 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9144 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9146 sessions = rte_malloc(NULL,
9147 (sizeof(struct rte_cryptodev_sym_session *)
9148 * MAX_NB_SESSIONS) + 1, 0);
9150 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9151 sessions[i] = rte_cryptodev_sym_session_create(
9152 ts_params->session_mpool);
9154 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9155 sizeof(struct crypto_unittest_params));
9157 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9158 &ut_paramz[i].ut_params,
9159 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9161 /* Create multiple crypto sessions*/
9162 rte_cryptodev_sym_session_init(
9163 ts_params->valid_devs[0],
9165 &ut_paramz[i].ut_params.auth_xform,
9166 ts_params->session_priv_mpool);
9168 TEST_ASSERT_NOT_NULL(sessions[i],
9169 "Session creation failed at session number %u",
9175 for (i = 0; i < 40000; i++) {
9177 j = rand() % MB_SESSION_NUMBER;
9179 TEST_ASSERT_SUCCESS(
9180 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9182 &ut_paramz[j].ut_params,
9183 ts_params, ut_paramz[j].cipher,
9184 ut_paramz[j].digest,
9186 "Failed to perform decrypt on request number %u.", i);
9188 if (ut_paramz[j].ut_params.op)
9189 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9192 * free mbuf - both obuf and ibuf are usually the same,
9193 * so check if they point at the same address is necessary,
9194 * to avoid freeing the mbuf twice.
9196 if (ut_paramz[j].ut_params.obuf) {
9197 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9198 if (ut_paramz[j].ut_params.ibuf
9199 == ut_paramz[j].ut_params.obuf)
9200 ut_paramz[j].ut_params.ibuf = 0;
9201 ut_paramz[j].ut_params.obuf = 0;
9203 if (ut_paramz[j].ut_params.ibuf) {
9204 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9205 ut_paramz[j].ut_params.ibuf = 0;
9209 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9210 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9212 rte_cryptodev_sym_session_free(sessions[i]);
9217 return TEST_SUCCESS;
9221 test_null_cipher_only_operation(void)
9223 struct crypto_testsuite_params *ts_params = &testsuite_params;
9224 struct crypto_unittest_params *ut_params = &unittest_params;
9226 /* Verify the capabilities */
9227 struct rte_cryptodev_sym_capability_idx cap_idx;
9228 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9229 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9230 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9234 /* Generate test mbuf data and space for digest */
9235 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9236 catch_22_quote, QUOTE_512_BYTES, 0);
9238 /* Setup Cipher Parameters */
9239 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9240 ut_params->cipher_xform.next = NULL;
9242 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9243 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9245 ut_params->sess = rte_cryptodev_sym_session_create(
9246 ts_params->session_mpool);
9248 /* Create Crypto session*/
9249 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9251 &ut_params->cipher_xform,
9252 ts_params->session_priv_mpool);
9253 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9255 /* Generate Crypto op data structure */
9256 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9257 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9258 TEST_ASSERT_NOT_NULL(ut_params->op,
9259 "Failed to allocate symmetric crypto operation struct");
9261 /* Set crypto operation data parameters */
9262 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9264 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9266 /* set crypto operation source mbuf */
9267 sym_op->m_src = ut_params->ibuf;
9269 sym_op->cipher.data.offset = 0;
9270 sym_op->cipher.data.length = QUOTE_512_BYTES;
9272 /* Process crypto operation */
9273 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9275 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9277 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9278 "crypto operation processing failed");
9281 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9282 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9285 "Ciphertext data not as expected");
9287 return TEST_SUCCESS;
9289 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9290 0xab, 0xab, 0xab, 0xab,
9291 0xab, 0xab, 0xab, 0xab,
9292 0xab, 0xab, 0xab, 0xab};
9294 test_null_auth_only_operation(void)
9296 struct crypto_testsuite_params *ts_params = &testsuite_params;
9297 struct crypto_unittest_params *ut_params = &unittest_params;
9300 /* Verify the capabilities */
9301 struct rte_cryptodev_sym_capability_idx cap_idx;
9302 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9303 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9304 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9308 /* Generate test mbuf data and space for digest */
9309 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9310 catch_22_quote, QUOTE_512_BYTES, 0);
9312 /* create a pointer for digest, but don't expect anything to be written
9313 * here in a NULL auth algo so no mbuf append done.
9315 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9317 /* prefill the memory pointed to by digest */
9318 memcpy(digest, orig_data, sizeof(orig_data));
9320 /* Setup HMAC Parameters */
9321 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9322 ut_params->auth_xform.next = NULL;
9324 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9325 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9327 ut_params->sess = rte_cryptodev_sym_session_create(
9328 ts_params->session_mpool);
9330 /* Create Crypto session*/
9331 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9332 ut_params->sess, &ut_params->auth_xform,
9333 ts_params->session_priv_mpool);
9334 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9336 /* Generate Crypto op data structure */
9337 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9338 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9339 TEST_ASSERT_NOT_NULL(ut_params->op,
9340 "Failed to allocate symmetric crypto operation struct");
9342 /* Set crypto operation data parameters */
9343 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9345 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9347 sym_op->m_src = ut_params->ibuf;
9349 sym_op->auth.data.offset = 0;
9350 sym_op->auth.data.length = QUOTE_512_BYTES;
9351 sym_op->auth.digest.data = digest;
9352 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9355 /* Process crypto operation */
9356 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9358 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9360 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9361 "crypto operation processing failed");
9362 /* Make sure memory pointed to by digest hasn't been overwritten */
9363 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9367 "Memory at digest ptr overwritten unexpectedly");
9369 return TEST_SUCCESS;
9374 test_null_cipher_auth_operation(void)
9376 struct crypto_testsuite_params *ts_params = &testsuite_params;
9377 struct crypto_unittest_params *ut_params = &unittest_params;
9380 /* Verify the capabilities */
9381 struct rte_cryptodev_sym_capability_idx cap_idx;
9382 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9383 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9384 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9387 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9388 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9389 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9393 /* Generate test mbuf data and space for digest */
9394 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9395 catch_22_quote, QUOTE_512_BYTES, 0);
9397 /* create a pointer for digest, but don't expect anything to be written
9398 * here in a NULL auth algo so no mbuf append done.
9400 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9402 /* prefill the memory pointed to by digest */
9403 memcpy(digest, orig_data, sizeof(orig_data));
9405 /* Setup Cipher Parameters */
9406 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9407 ut_params->cipher_xform.next = &ut_params->auth_xform;
9409 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9410 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9412 /* Setup HMAC Parameters */
9413 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9414 ut_params->auth_xform.next = NULL;
9416 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9417 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9419 ut_params->sess = rte_cryptodev_sym_session_create(
9420 ts_params->session_mpool);
9422 /* Create Crypto session*/
9423 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9424 ut_params->sess, &ut_params->cipher_xform,
9425 ts_params->session_priv_mpool);
9426 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9428 /* Generate Crypto op data structure */
9429 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9430 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9431 TEST_ASSERT_NOT_NULL(ut_params->op,
9432 "Failed to allocate symmetric crypto operation struct");
9434 /* Set crypto operation data parameters */
9435 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9437 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9439 sym_op->m_src = ut_params->ibuf;
9441 sym_op->cipher.data.offset = 0;
9442 sym_op->cipher.data.length = QUOTE_512_BYTES;
9444 sym_op->auth.data.offset = 0;
9445 sym_op->auth.data.length = QUOTE_512_BYTES;
9446 sym_op->auth.digest.data = digest;
9447 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9450 /* Process crypto operation */
9451 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9453 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9455 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9456 "crypto operation processing failed");
9459 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9460 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9463 "Ciphertext data not as expected");
9464 /* Make sure memory pointed to by digest hasn't been overwritten */
9465 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9469 "Memory at digest ptr overwritten unexpectedly");
9471 return TEST_SUCCESS;
9475 test_null_auth_cipher_operation(void)
9477 struct crypto_testsuite_params *ts_params = &testsuite_params;
9478 struct crypto_unittest_params *ut_params = &unittest_params;
9481 /* Verify the capabilities */
9482 struct rte_cryptodev_sym_capability_idx cap_idx;
9483 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9484 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9485 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9488 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9489 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9490 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9494 /* Generate test mbuf data */
9495 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9496 catch_22_quote, QUOTE_512_BYTES, 0);
9498 /* create a pointer for digest, but don't expect anything to be written
9499 * here in a NULL auth algo so no mbuf append done.
9501 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9503 /* prefill the memory pointed to by digest */
9504 memcpy(digest, orig_data, sizeof(orig_data));
9506 /* Setup Cipher Parameters */
9507 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9508 ut_params->cipher_xform.next = NULL;
9510 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9511 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9513 /* Setup HMAC Parameters */
9514 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9515 ut_params->auth_xform.next = &ut_params->cipher_xform;
9517 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9518 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9520 ut_params->sess = rte_cryptodev_sym_session_create(
9521 ts_params->session_mpool);
9523 /* Create Crypto session*/
9524 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9525 ut_params->sess, &ut_params->cipher_xform,
9526 ts_params->session_priv_mpool);
9527 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9529 /* Generate Crypto op data structure */
9530 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9531 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9532 TEST_ASSERT_NOT_NULL(ut_params->op,
9533 "Failed to allocate symmetric crypto operation struct");
9535 /* Set crypto operation data parameters */
9536 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9538 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9540 sym_op->m_src = ut_params->ibuf;
9542 sym_op->cipher.data.offset = 0;
9543 sym_op->cipher.data.length = QUOTE_512_BYTES;
9545 sym_op->auth.data.offset = 0;
9546 sym_op->auth.data.length = QUOTE_512_BYTES;
9547 sym_op->auth.digest.data = digest;
9548 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9551 /* Process crypto operation */
9552 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9554 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9556 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9557 "crypto operation processing failed");
9560 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9561 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9564 "Ciphertext data not as expected");
9565 /* Make sure memory pointed to by digest hasn't been overwritten */
9566 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9570 "Memory at digest ptr overwritten unexpectedly");
9572 return TEST_SUCCESS;
9577 test_null_invalid_operation(void)
9579 struct crypto_testsuite_params *ts_params = &testsuite_params;
9580 struct crypto_unittest_params *ut_params = &unittest_params;
9583 /* This test is for NULL PMD only */
9584 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9585 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9588 /* Setup Cipher Parameters */
9589 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9590 ut_params->cipher_xform.next = NULL;
9592 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9593 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9595 ut_params->sess = rte_cryptodev_sym_session_create(
9596 ts_params->session_mpool);
9598 /* Create Crypto session*/
9599 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9600 ut_params->sess, &ut_params->cipher_xform,
9601 ts_params->session_priv_mpool);
9602 TEST_ASSERT(ret < 0,
9603 "Session creation succeeded unexpectedly");
9606 /* Setup HMAC Parameters */
9607 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9608 ut_params->auth_xform.next = NULL;
9610 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9611 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9613 ut_params->sess = rte_cryptodev_sym_session_create(
9614 ts_params->session_mpool);
9616 /* Create Crypto session*/
9617 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9618 ut_params->sess, &ut_params->auth_xform,
9619 ts_params->session_priv_mpool);
9620 TEST_ASSERT(ret < 0,
9621 "Session creation succeeded unexpectedly");
9623 return TEST_SUCCESS;
9627 #define NULL_BURST_LENGTH (32)
9630 test_null_burst_operation(void)
9632 struct crypto_testsuite_params *ts_params = &testsuite_params;
9633 struct crypto_unittest_params *ut_params = &unittest_params;
9635 unsigned i, burst_len = NULL_BURST_LENGTH;
9637 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9638 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9640 /* This test is for NULL PMD only */
9641 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9642 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9645 /* Setup Cipher Parameters */
9646 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9647 ut_params->cipher_xform.next = &ut_params->auth_xform;
9649 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9650 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9652 /* Setup HMAC Parameters */
9653 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9654 ut_params->auth_xform.next = NULL;
9656 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9657 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9659 ut_params->sess = rte_cryptodev_sym_session_create(
9660 ts_params->session_mpool);
9662 /* Create Crypto session*/
9663 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9664 ut_params->sess, &ut_params->cipher_xform,
9665 ts_params->session_priv_mpool);
9666 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9668 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9669 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9670 burst_len, "failed to generate burst of crypto ops");
9672 /* Generate an operation for each mbuf in burst */
9673 for (i = 0; i < burst_len; i++) {
9674 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9676 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9678 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9682 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9684 burst[i]->sym->m_src = m;
9687 /* Process crypto operation */
9688 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9689 0, burst, burst_len),
9691 "Error enqueuing burst");
9693 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9694 0, burst_dequeued, burst_len),
9696 "Error dequeuing burst");
9699 for (i = 0; i < burst_len; i++) {
9701 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9702 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9704 "data not as expected");
9706 rte_pktmbuf_free(burst[i]->sym->m_src);
9707 rte_crypto_op_free(burst[i]);
9710 return TEST_SUCCESS;
9714 generate_gmac_large_plaintext(uint8_t *data)
9718 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9719 memcpy(&data[i], &data[0], 32);
9723 create_gmac_operation(enum rte_crypto_auth_operation op,
9724 const struct gmac_test_data *tdata)
9726 struct crypto_testsuite_params *ts_params = &testsuite_params;
9727 struct crypto_unittest_params *ut_params = &unittest_params;
9728 struct rte_crypto_sym_op *sym_op;
9730 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9732 /* Generate Crypto op data structure */
9733 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9734 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9735 TEST_ASSERT_NOT_NULL(ut_params->op,
9736 "Failed to allocate symmetric crypto operation struct");
9738 sym_op = ut_params->op->sym;
9740 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9741 ut_params->ibuf, tdata->gmac_tag.len);
9742 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9743 "no room to append digest");
9745 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9746 ut_params->ibuf, plaintext_pad_len);
9748 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9749 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9750 tdata->gmac_tag.len);
9751 debug_hexdump(stdout, "digest:",
9752 sym_op->auth.digest.data,
9753 tdata->gmac_tag.len);
9756 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9757 uint8_t *, IV_OFFSET);
9759 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9761 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9763 sym_op->cipher.data.length = 0;
9764 sym_op->cipher.data.offset = 0;
9766 sym_op->auth.data.offset = 0;
9767 sym_op->auth.data.length = tdata->plaintext.len;
9772 static int create_gmac_session(uint8_t dev_id,
9773 const struct gmac_test_data *tdata,
9774 enum rte_crypto_auth_operation auth_op)
9776 uint8_t auth_key[tdata->key.len];
9778 struct crypto_testsuite_params *ts_params = &testsuite_params;
9779 struct crypto_unittest_params *ut_params = &unittest_params;
9781 memcpy(auth_key, tdata->key.data, tdata->key.len);
9783 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9784 ut_params->auth_xform.next = NULL;
9786 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9787 ut_params->auth_xform.auth.op = auth_op;
9788 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9789 ut_params->auth_xform.auth.key.length = tdata->key.len;
9790 ut_params->auth_xform.auth.key.data = auth_key;
9791 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9792 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9795 ut_params->sess = rte_cryptodev_sym_session_create(
9796 ts_params->session_mpool);
9798 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9799 &ut_params->auth_xform,
9800 ts_params->session_priv_mpool);
9802 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9808 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9810 struct crypto_testsuite_params *ts_params = &testsuite_params;
9811 struct crypto_unittest_params *ut_params = &unittest_params;
9815 uint8_t *auth_tag, *plaintext;
9816 uint16_t plaintext_pad_len;
9818 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9819 "No GMAC length in the source data");
9821 /* Verify the capabilities */
9822 struct rte_cryptodev_sym_capability_idx cap_idx;
9823 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9824 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9825 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9829 retval = create_gmac_session(ts_params->valid_devs[0],
9830 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9835 if (tdata->plaintext.len > MBUF_SIZE)
9836 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9838 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9839 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9840 "Failed to allocate input buffer in mempool");
9842 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9843 rte_pktmbuf_tailroom(ut_params->ibuf));
9845 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9847 * Runtime generate the large plain text instead of use hard code
9848 * plain text vector. It is done to avoid create huge source file
9849 * with the test vector.
9851 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9852 generate_gmac_large_plaintext(tdata->plaintext.data);
9854 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9856 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9858 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9859 debug_hexdump(stdout, "plaintext:", plaintext,
9860 tdata->plaintext.len);
9862 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9868 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9870 ut_params->op->sym->m_src = ut_params->ibuf;
9872 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9873 process_cpu_gmac_op(ts_params->valid_devs[0], ut_params->op);
9875 TEST_ASSERT_NOT_NULL(
9876 process_crypto_request(ts_params->valid_devs[0],
9877 ut_params->op), "failed to process sym crypto op");
9879 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9880 "crypto op processing failed");
9882 if (ut_params->op->sym->m_dst) {
9883 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9884 uint8_t *, plaintext_pad_len);
9886 auth_tag = plaintext + plaintext_pad_len;
9889 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9891 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9893 tdata->gmac_tag.data,
9894 tdata->gmac_tag.len,
9895 "GMAC Generated auth tag not as expected");
9901 test_AES_GMAC_authentication_test_case_1(void)
9903 return test_AES_GMAC_authentication(&gmac_test_case_1);
9907 test_AES_GMAC_authentication_test_case_2(void)
9909 return test_AES_GMAC_authentication(&gmac_test_case_2);
9913 test_AES_GMAC_authentication_test_case_3(void)
9915 return test_AES_GMAC_authentication(&gmac_test_case_3);
9919 test_AES_GMAC_authentication_test_case_4(void)
9921 return test_AES_GMAC_authentication(&gmac_test_case_4);
9925 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9927 struct crypto_testsuite_params *ts_params = &testsuite_params;
9928 struct crypto_unittest_params *ut_params = &unittest_params;
9930 uint32_t plaintext_pad_len;
9933 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9934 "No GMAC length in the source data");
9936 /* Verify the capabilities */
9937 struct rte_cryptodev_sym_capability_idx cap_idx;
9938 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9939 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9940 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9944 retval = create_gmac_session(ts_params->valid_devs[0],
9945 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
9950 if (tdata->plaintext.len > MBUF_SIZE)
9951 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9953 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9954 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9955 "Failed to allocate input buffer in mempool");
9957 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9958 rte_pktmbuf_tailroom(ut_params->ibuf));
9960 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9963 * Runtime generate the large plain text instead of use hard code
9964 * plain text vector. It is done to avoid create huge source file
9965 * with the test vector.
9967 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9968 generate_gmac_large_plaintext(tdata->plaintext.data);
9970 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9972 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9974 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9975 debug_hexdump(stdout, "plaintext:", plaintext,
9976 tdata->plaintext.len);
9978 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
9984 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9986 ut_params->op->sym->m_src = ut_params->ibuf;
9988 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9989 process_cpu_gmac_op(ts_params->valid_devs[0], ut_params->op);
9991 TEST_ASSERT_NOT_NULL(
9992 process_crypto_request(ts_params->valid_devs[0],
9993 ut_params->op), "failed to process sym crypto op");
9995 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9996 "crypto op processing failed");
10003 test_AES_GMAC_authentication_verify_test_case_1(void)
10005 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10009 test_AES_GMAC_authentication_verify_test_case_2(void)
10011 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10015 test_AES_GMAC_authentication_verify_test_case_3(void)
10017 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10021 test_AES_GMAC_authentication_verify_test_case_4(void)
10023 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10026 struct test_crypto_vector {
10027 enum rte_crypto_cipher_algorithm crypto_algo;
10028 unsigned int cipher_offset;
10029 unsigned int cipher_len;
10042 const uint8_t *data;
10047 const uint8_t *data;
10051 enum rte_crypto_auth_algorithm auth_algo;
10052 unsigned int auth_offset;
10060 const uint8_t *data;
10070 static const struct test_crypto_vector
10071 hmac_sha1_test_crypto_vector = {
10072 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10074 .data = plaintext_hash,
10079 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10080 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10081 0xDE, 0xF4, 0xDE, 0xAD
10087 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10088 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10089 0x3F, 0x91, 0x64, 0x59
10095 static const struct test_crypto_vector
10096 aes128_gmac_test_vector = {
10097 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10099 .data = plaintext_hash,
10104 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10105 0x08, 0x09, 0x0A, 0x0B
10111 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10112 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10118 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10119 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10125 static const struct test_crypto_vector
10126 aes128cbc_hmac_sha1_test_vector = {
10127 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10128 .cipher_offset = 0,
10132 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10133 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10139 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10140 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10145 .data = plaintext_hash,
10149 .data = ciphertext512_aes128cbc,
10152 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10156 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10157 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10158 0xDE, 0xF4, 0xDE, 0xAD
10164 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10165 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10166 0x18, 0x8C, 0x1D, 0x32
10172 static const struct test_crypto_vector
10173 aes128cbc_hmac_sha1_aad_test_vector = {
10174 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10175 .cipher_offset = 12,
10179 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10180 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10186 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10187 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10192 .data = plaintext_hash,
10196 .data = ciphertext512_aes128cbc_aad,
10199 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10203 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10204 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10205 0xDE, 0xF4, 0xDE, 0xAD
10211 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10212 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10213 0x62, 0x8D, 0x62, 0x65
10220 data_corruption(uint8_t *data)
10226 tag_corruption(uint8_t *data, unsigned int tag_offset)
10228 data[tag_offset] += 1;
10232 create_auth_session(struct crypto_unittest_params *ut_params,
10234 const struct test_crypto_vector *reference,
10235 enum rte_crypto_auth_operation auth_op)
10237 struct crypto_testsuite_params *ts_params = &testsuite_params;
10238 uint8_t auth_key[reference->auth_key.len + 1];
10240 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10242 /* Setup Authentication Parameters */
10243 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10244 ut_params->auth_xform.auth.op = auth_op;
10245 ut_params->auth_xform.next = NULL;
10246 ut_params->auth_xform.auth.algo = reference->auth_algo;
10247 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10248 ut_params->auth_xform.auth.key.data = auth_key;
10249 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10251 /* Create Crypto session*/
10252 ut_params->sess = rte_cryptodev_sym_session_create(
10253 ts_params->session_mpool);
10255 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10256 &ut_params->auth_xform,
10257 ts_params->session_priv_mpool);
10259 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10265 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10267 const struct test_crypto_vector *reference,
10268 enum rte_crypto_auth_operation auth_op,
10269 enum rte_crypto_cipher_operation cipher_op)
10271 struct crypto_testsuite_params *ts_params = &testsuite_params;
10272 uint8_t cipher_key[reference->cipher_key.len + 1];
10273 uint8_t auth_key[reference->auth_key.len + 1];
10275 memcpy(cipher_key, reference->cipher_key.data,
10276 reference->cipher_key.len);
10277 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10279 /* Setup Authentication Parameters */
10280 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10281 ut_params->auth_xform.auth.op = auth_op;
10282 ut_params->auth_xform.auth.algo = reference->auth_algo;
10283 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10284 ut_params->auth_xform.auth.key.data = auth_key;
10285 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10287 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10288 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10289 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10291 ut_params->auth_xform.next = &ut_params->cipher_xform;
10293 /* Setup Cipher Parameters */
10294 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10295 ut_params->cipher_xform.next = NULL;
10296 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10297 ut_params->cipher_xform.cipher.op = cipher_op;
10298 ut_params->cipher_xform.cipher.key.data = cipher_key;
10299 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10300 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10301 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10304 /* Create Crypto session*/
10305 ut_params->sess = rte_cryptodev_sym_session_create(
10306 ts_params->session_mpool);
10308 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10309 &ut_params->auth_xform,
10310 ts_params->session_priv_mpool);
10312 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10318 create_auth_operation(struct crypto_testsuite_params *ts_params,
10319 struct crypto_unittest_params *ut_params,
10320 const struct test_crypto_vector *reference,
10321 unsigned int auth_generate)
10323 /* Generate Crypto op data structure */
10324 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10325 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10326 TEST_ASSERT_NOT_NULL(ut_params->op,
10327 "Failed to allocate pktmbuf offload");
10329 /* Set crypto operation data parameters */
10330 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10332 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10334 /* set crypto operation source mbuf */
10335 sym_op->m_src = ut_params->ibuf;
10338 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10339 ut_params->ibuf, reference->digest.len);
10341 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10342 "no room to append auth tag");
10344 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10345 ut_params->ibuf, reference->plaintext.len);
10348 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10350 memcpy(sym_op->auth.digest.data,
10351 reference->digest.data,
10352 reference->digest.len);
10354 debug_hexdump(stdout, "digest:",
10355 sym_op->auth.digest.data,
10356 reference->digest.len);
10358 sym_op->auth.data.length = reference->plaintext.len;
10359 sym_op->auth.data.offset = 0;
10365 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10366 struct crypto_unittest_params *ut_params,
10367 const struct test_crypto_vector *reference,
10368 unsigned int auth_generate)
10370 /* Generate Crypto op data structure */
10371 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10372 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10373 TEST_ASSERT_NOT_NULL(ut_params->op,
10374 "Failed to allocate pktmbuf offload");
10376 /* Set crypto operation data parameters */
10377 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10379 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10381 /* set crypto operation source mbuf */
10382 sym_op->m_src = ut_params->ibuf;
10385 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10386 ut_params->ibuf, reference->digest.len);
10388 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10389 "no room to append auth tag");
10391 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10392 ut_params->ibuf, reference->ciphertext.len);
10395 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10397 memcpy(sym_op->auth.digest.data,
10398 reference->digest.data,
10399 reference->digest.len);
10401 debug_hexdump(stdout, "digest:",
10402 sym_op->auth.digest.data,
10403 reference->digest.len);
10405 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10406 reference->iv.data, reference->iv.len);
10408 sym_op->cipher.data.length = 0;
10409 sym_op->cipher.data.offset = 0;
10411 sym_op->auth.data.length = reference->plaintext.len;
10412 sym_op->auth.data.offset = 0;
10418 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10419 struct crypto_unittest_params *ut_params,
10420 const struct test_crypto_vector *reference,
10421 unsigned int auth_generate)
10423 /* Generate Crypto op data structure */
10424 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10425 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10426 TEST_ASSERT_NOT_NULL(ut_params->op,
10427 "Failed to allocate pktmbuf offload");
10429 /* Set crypto operation data parameters */
10430 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10432 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10434 /* set crypto operation source mbuf */
10435 sym_op->m_src = ut_params->ibuf;
10438 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10439 ut_params->ibuf, reference->digest.len);
10441 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10442 "no room to append auth tag");
10444 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10445 ut_params->ibuf, reference->ciphertext.len);
10448 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10450 memcpy(sym_op->auth.digest.data,
10451 reference->digest.data,
10452 reference->digest.len);
10454 debug_hexdump(stdout, "digest:",
10455 sym_op->auth.digest.data,
10456 reference->digest.len);
10458 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10459 reference->iv.data, reference->iv.len);
10461 sym_op->cipher.data.length = reference->cipher_len;
10462 sym_op->cipher.data.offset = reference->cipher_offset;
10464 sym_op->auth.data.length = reference->plaintext.len;
10465 sym_op->auth.data.offset = reference->auth_offset;
10471 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10472 struct crypto_unittest_params *ut_params,
10473 const struct test_crypto_vector *reference)
10475 return create_auth_operation(ts_params, ut_params, reference, 0);
10479 create_auth_verify_GMAC_operation(
10480 struct crypto_testsuite_params *ts_params,
10481 struct crypto_unittest_params *ut_params,
10482 const struct test_crypto_vector *reference)
10484 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10488 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10489 struct crypto_unittest_params *ut_params,
10490 const struct test_crypto_vector *reference)
10492 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10496 test_authentication_verify_fail_when_data_corruption(
10497 struct crypto_testsuite_params *ts_params,
10498 struct crypto_unittest_params *ut_params,
10499 const struct test_crypto_vector *reference,
10500 unsigned int data_corrupted)
10504 uint8_t *plaintext;
10506 /* Verify the capabilities */
10507 struct rte_cryptodev_sym_capability_idx cap_idx;
10508 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10509 cap_idx.algo.auth = reference->auth_algo;
10510 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10514 /* Create session */
10515 retval = create_auth_session(ut_params,
10516 ts_params->valid_devs[0],
10518 RTE_CRYPTO_AUTH_OP_VERIFY);
10522 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10523 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10524 "Failed to allocate input buffer in mempool");
10526 /* clear mbuf payload */
10527 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10528 rte_pktmbuf_tailroom(ut_params->ibuf));
10530 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10531 reference->plaintext.len);
10532 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10533 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10535 debug_hexdump(stdout, "plaintext:", plaintext,
10536 reference->plaintext.len);
10538 /* Create operation */
10539 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10544 if (data_corrupted)
10545 data_corruption(plaintext);
10547 tag_corruption(plaintext, reference->plaintext.len);
10549 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10552 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10558 test_authentication_verify_GMAC_fail_when_corruption(
10559 struct crypto_testsuite_params *ts_params,
10560 struct crypto_unittest_params *ut_params,
10561 const struct test_crypto_vector *reference,
10562 unsigned int data_corrupted)
10565 uint8_t *plaintext;
10567 /* Verify the capabilities */
10568 struct rte_cryptodev_sym_capability_idx cap_idx;
10569 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10570 cap_idx.algo.auth = reference->auth_algo;
10571 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10575 /* Create session */
10576 retval = create_auth_cipher_session(ut_params,
10577 ts_params->valid_devs[0],
10579 RTE_CRYPTO_AUTH_OP_VERIFY,
10580 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10584 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10585 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10586 "Failed to allocate input buffer in mempool");
10588 /* clear mbuf payload */
10589 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10590 rte_pktmbuf_tailroom(ut_params->ibuf));
10592 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10593 reference->plaintext.len);
10594 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10595 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10597 debug_hexdump(stdout, "plaintext:", plaintext,
10598 reference->plaintext.len);
10600 /* Create operation */
10601 retval = create_auth_verify_GMAC_operation(ts_params,
10608 if (data_corrupted)
10609 data_corruption(plaintext);
10611 tag_corruption(plaintext, reference->aad.len);
10613 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10614 process_cpu_gmac_op(ts_params->valid_devs[0], ut_params->op);
10615 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10616 RTE_CRYPTO_OP_STATUS_SUCCESS,
10617 "authentication not failed");
10619 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10621 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10628 test_authenticated_decryption_fail_when_corruption(
10629 struct crypto_testsuite_params *ts_params,
10630 struct crypto_unittest_params *ut_params,
10631 const struct test_crypto_vector *reference,
10632 unsigned int data_corrupted)
10636 uint8_t *ciphertext;
10638 /* Verify the capabilities */
10639 struct rte_cryptodev_sym_capability_idx cap_idx;
10640 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10641 cap_idx.algo.auth = reference->auth_algo;
10642 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10645 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10646 cap_idx.algo.cipher = reference->crypto_algo;
10647 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10651 /* Create session */
10652 retval = create_auth_cipher_session(ut_params,
10653 ts_params->valid_devs[0],
10655 RTE_CRYPTO_AUTH_OP_VERIFY,
10656 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10660 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10661 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10662 "Failed to allocate input buffer in mempool");
10664 /* clear mbuf payload */
10665 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10666 rte_pktmbuf_tailroom(ut_params->ibuf));
10668 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10669 reference->ciphertext.len);
10670 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10671 memcpy(ciphertext, reference->ciphertext.data,
10672 reference->ciphertext.len);
10674 /* Create operation */
10675 retval = create_cipher_auth_verify_operation(ts_params,
10682 if (data_corrupted)
10683 data_corruption(ciphertext);
10685 tag_corruption(ciphertext, reference->ciphertext.len);
10687 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10690 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10696 test_authenticated_encryt_with_esn(
10697 struct crypto_testsuite_params *ts_params,
10698 struct crypto_unittest_params *ut_params,
10699 const struct test_crypto_vector *reference)
10703 uint8_t *authciphertext, *plaintext, *auth_tag;
10704 uint16_t plaintext_pad_len;
10705 uint8_t cipher_key[reference->cipher_key.len + 1];
10706 uint8_t auth_key[reference->auth_key.len + 1];
10708 /* Verify the capabilities */
10709 struct rte_cryptodev_sym_capability_idx cap_idx;
10710 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10711 cap_idx.algo.auth = reference->auth_algo;
10712 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10715 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10716 cap_idx.algo.cipher = reference->crypto_algo;
10717 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10721 /* Create session */
10722 memcpy(cipher_key, reference->cipher_key.data,
10723 reference->cipher_key.len);
10724 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10726 /* Setup Cipher Parameters */
10727 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10728 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10729 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10730 ut_params->cipher_xform.cipher.key.data = cipher_key;
10731 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10732 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10733 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10735 ut_params->cipher_xform.next = &ut_params->auth_xform;
10737 /* Setup Authentication Parameters */
10738 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10739 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10740 ut_params->auth_xform.auth.algo = reference->auth_algo;
10741 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10742 ut_params->auth_xform.auth.key.data = auth_key;
10743 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10744 ut_params->auth_xform.next = NULL;
10746 /* Create Crypto session*/
10747 ut_params->sess = rte_cryptodev_sym_session_create(
10748 ts_params->session_mpool);
10750 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10752 &ut_params->cipher_xform,
10753 ts_params->session_priv_mpool);
10755 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10757 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10758 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10759 "Failed to allocate input buffer in mempool");
10761 /* clear mbuf payload */
10762 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10763 rte_pktmbuf_tailroom(ut_params->ibuf));
10765 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10766 reference->plaintext.len);
10767 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10768 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10770 /* Create operation */
10771 retval = create_cipher_auth_operation(ts_params,
10778 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10781 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10783 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10784 "crypto op processing failed");
10786 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10788 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10789 ut_params->op->sym->auth.data.offset);
10790 auth_tag = authciphertext + plaintext_pad_len;
10791 debug_hexdump(stdout, "ciphertext:", authciphertext,
10792 reference->ciphertext.len);
10793 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10795 /* Validate obuf */
10796 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10798 reference->ciphertext.data,
10799 reference->ciphertext.len,
10800 "Ciphertext data not as expected");
10802 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10804 reference->digest.data,
10805 reference->digest.len,
10806 "Generated digest not as expected");
10808 return TEST_SUCCESS;
10813 test_authenticated_decrypt_with_esn(
10814 struct crypto_testsuite_params *ts_params,
10815 struct crypto_unittest_params *ut_params,
10816 const struct test_crypto_vector *reference)
10820 uint8_t *ciphertext;
10821 uint8_t cipher_key[reference->cipher_key.len + 1];
10822 uint8_t auth_key[reference->auth_key.len + 1];
10824 /* Verify the capabilities */
10825 struct rte_cryptodev_sym_capability_idx cap_idx;
10826 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10827 cap_idx.algo.auth = reference->auth_algo;
10828 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10831 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10832 cap_idx.algo.cipher = reference->crypto_algo;
10833 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10837 /* Create session */
10838 memcpy(cipher_key, reference->cipher_key.data,
10839 reference->cipher_key.len);
10840 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10842 /* Setup Authentication Parameters */
10843 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10844 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10845 ut_params->auth_xform.auth.algo = reference->auth_algo;
10846 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10847 ut_params->auth_xform.auth.key.data = auth_key;
10848 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10849 ut_params->auth_xform.next = &ut_params->cipher_xform;
10851 /* Setup Cipher Parameters */
10852 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10853 ut_params->cipher_xform.next = NULL;
10854 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10855 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10856 ut_params->cipher_xform.cipher.key.data = cipher_key;
10857 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10858 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10859 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10861 /* Create Crypto session*/
10862 ut_params->sess = rte_cryptodev_sym_session_create(
10863 ts_params->session_mpool);
10865 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10867 &ut_params->auth_xform,
10868 ts_params->session_priv_mpool);
10870 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10872 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10873 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10874 "Failed to allocate input buffer in mempool");
10876 /* clear mbuf payload */
10877 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10878 rte_pktmbuf_tailroom(ut_params->ibuf));
10880 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10881 reference->ciphertext.len);
10882 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10883 memcpy(ciphertext, reference->ciphertext.data,
10884 reference->ciphertext.len);
10886 /* Create operation */
10887 retval = create_cipher_auth_verify_operation(ts_params,
10894 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10897 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10898 TEST_ASSERT_EQUAL(ut_params->op->status,
10899 RTE_CRYPTO_OP_STATUS_SUCCESS,
10900 "crypto op processing passed");
10902 ut_params->obuf = ut_params->op->sym->m_src;
10903 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10909 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10910 const struct aead_test_data *tdata,
10911 void *digest_mem, uint64_t digest_phys)
10913 struct crypto_testsuite_params *ts_params = &testsuite_params;
10914 struct crypto_unittest_params *ut_params = &unittest_params;
10916 const unsigned int auth_tag_len = tdata->auth_tag.len;
10917 const unsigned int iv_len = tdata->iv.len;
10918 unsigned int aad_len = tdata->aad.len;
10919 unsigned int aad_len_pad = 0;
10921 /* Generate Crypto op data structure */
10922 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10923 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10924 TEST_ASSERT_NOT_NULL(ut_params->op,
10925 "Failed to allocate symmetric crypto operation struct");
10927 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10929 sym_op->aead.digest.data = digest_mem;
10931 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
10932 "no room to append digest");
10934 sym_op->aead.digest.phys_addr = digest_phys;
10936 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
10937 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
10939 debug_hexdump(stdout, "digest:",
10940 sym_op->aead.digest.data,
10944 /* Append aad data */
10945 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
10946 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10947 uint8_t *, IV_OFFSET);
10949 /* Copy IV 1 byte after the IV pointer, according to the API */
10950 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
10952 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
10954 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10955 ut_params->ibuf, aad_len);
10956 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10957 "no room to prepend aad");
10958 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10961 memset(sym_op->aead.aad.data, 0, aad_len);
10962 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
10963 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10965 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10966 debug_hexdump(stdout, "aad:",
10967 sym_op->aead.aad.data, aad_len);
10969 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10970 uint8_t *, IV_OFFSET);
10972 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
10974 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
10976 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10977 ut_params->ibuf, aad_len_pad);
10978 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10979 "no room to prepend aad");
10980 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10983 memset(sym_op->aead.aad.data, 0, aad_len);
10984 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10986 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10987 debug_hexdump(stdout, "aad:",
10988 sym_op->aead.aad.data, aad_len);
10991 sym_op->aead.data.length = tdata->plaintext.len;
10992 sym_op->aead.data.offset = aad_len_pad;
10997 #define SGL_MAX_NO 16
11000 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11001 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11003 struct crypto_testsuite_params *ts_params = &testsuite_params;
11004 struct crypto_unittest_params *ut_params = &unittest_params;
11005 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11008 int to_trn_tbl[SGL_MAX_NO];
11010 unsigned int trn_data = 0;
11011 uint8_t *plaintext, *ciphertext, *auth_tag;
11012 struct rte_cryptodev_info dev_info;
11014 /* Verify the capabilities */
11015 struct rte_cryptodev_sym_capability_idx cap_idx;
11016 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11017 cap_idx.algo.aead = tdata->algo;
11018 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11022 /* OOP not supported with CPU crypto */
11023 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11026 /* Detailed check for the particular SGL support flag */
11027 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11029 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11030 if (sgl_in && (!(dev_info.feature_flags &
11031 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11034 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11035 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11036 tdata->plaintext.len;
11037 if (sgl_in && !sgl_out) {
11038 if (!(dev_info.feature_flags &
11039 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11041 } else if (!sgl_in && sgl_out) {
11042 if (!(dev_info.feature_flags &
11043 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11045 } else if (sgl_in && sgl_out) {
11046 if (!(dev_info.feature_flags &
11047 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11052 if (fragsz > tdata->plaintext.len)
11053 fragsz = tdata->plaintext.len;
11055 uint16_t plaintext_len = fragsz;
11056 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11058 if (fragsz_oop > tdata->plaintext.len)
11059 frag_size_oop = tdata->plaintext.len;
11062 void *digest_mem = NULL;
11064 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11066 if (tdata->plaintext.len % fragsz != 0) {
11067 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11070 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11075 * For out-op-place we need to alloc another mbuf
11078 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11079 rte_pktmbuf_append(ut_params->obuf,
11080 frag_size_oop + prepend_len);
11081 buf_oop = ut_params->obuf;
11084 /* Create AEAD session */
11085 retval = create_aead_session(ts_params->valid_devs[0],
11087 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11088 tdata->key.data, tdata->key.len,
11089 tdata->aad.len, tdata->auth_tag.len,
11094 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11096 /* clear mbuf payload */
11097 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11098 rte_pktmbuf_tailroom(ut_params->ibuf));
11100 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11103 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11105 trn_data += plaintext_len;
11107 buf = ut_params->ibuf;
11110 * Loop until no more fragments
11113 while (trn_data < tdata->plaintext.len) {
11115 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11116 (tdata->plaintext.len - trn_data) : fragsz;
11118 to_trn_tbl[ecx++] = to_trn;
11120 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11123 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11124 rte_pktmbuf_tailroom(buf));
11127 if (oop && !fragsz_oop) {
11128 buf_last_oop = buf_oop->next =
11129 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11130 buf_oop = buf_oop->next;
11131 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11132 0, rte_pktmbuf_tailroom(buf_oop));
11133 rte_pktmbuf_append(buf_oop, to_trn);
11136 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11139 memcpy(plaintext, tdata->plaintext.data + trn_data,
11141 trn_data += to_trn;
11142 if (trn_data == tdata->plaintext.len) {
11145 digest_mem = rte_pktmbuf_append(buf_oop,
11146 tdata->auth_tag.len);
11148 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11149 tdata->auth_tag.len);
11153 uint64_t digest_phys = 0;
11155 ut_params->ibuf->nb_segs = segs;
11158 if (fragsz_oop && oop) {
11162 if (frag_size_oop == tdata->plaintext.len) {
11163 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11164 tdata->auth_tag.len);
11166 digest_phys = rte_pktmbuf_iova_offset(
11168 tdata->plaintext.len + prepend_len);
11171 trn_data = frag_size_oop;
11172 while (trn_data < tdata->plaintext.len) {
11175 (tdata->plaintext.len - trn_data <
11177 (tdata->plaintext.len - trn_data) :
11180 to_trn_tbl[ecx++] = to_trn;
11182 buf_last_oop = buf_oop->next =
11183 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11184 buf_oop = buf_oop->next;
11185 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11186 0, rte_pktmbuf_tailroom(buf_oop));
11187 rte_pktmbuf_append(buf_oop, to_trn);
11189 trn_data += to_trn;
11191 if (trn_data == tdata->plaintext.len) {
11192 digest_mem = rte_pktmbuf_append(buf_oop,
11193 tdata->auth_tag.len);
11197 ut_params->obuf->nb_segs = segs;
11201 * Place digest at the end of the last buffer
11204 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11205 if (oop && buf_last_oop)
11206 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11208 if (!digest_mem && !oop) {
11209 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11210 + tdata->auth_tag.len);
11211 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11212 tdata->plaintext.len);
11215 /* Create AEAD operation */
11216 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11217 tdata, digest_mem, digest_phys);
11222 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11224 ut_params->op->sym->m_src = ut_params->ibuf;
11226 ut_params->op->sym->m_dst = ut_params->obuf;
11228 /* Process crypto operation */
11229 if (oop == IN_PLACE &&
11230 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11231 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11233 TEST_ASSERT_NOT_NULL(
11234 process_crypto_request(ts_params->valid_devs[0],
11235 ut_params->op), "failed to process sym crypto op");
11237 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11238 "crypto op processing failed");
11241 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11242 uint8_t *, prepend_len);
11244 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11245 uint8_t *, prepend_len);
11249 fragsz = fragsz_oop;
11251 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11253 tdata->ciphertext.data,
11255 "Ciphertext data not as expected");
11257 buf = ut_params->op->sym->m_src->next;
11259 buf = ut_params->op->sym->m_dst->next;
11261 unsigned int off = fragsz;
11265 ciphertext = rte_pktmbuf_mtod(buf,
11268 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11270 tdata->ciphertext.data + off,
11272 "Ciphertext data not as expected");
11274 off += to_trn_tbl[ecx++];
11278 auth_tag = digest_mem;
11279 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11281 tdata->auth_tag.data,
11282 tdata->auth_tag.len,
11283 "Generated auth tag not as expected");
11289 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11291 return test_authenticated_encryption_SGL(
11292 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11296 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11298 return test_authenticated_encryption_SGL(
11299 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11303 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11305 return test_authenticated_encryption_SGL(
11306 &gcm_test_case_8, OUT_OF_PLACE, 400,
11307 gcm_test_case_8.plaintext.len);
11311 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11313 /* This test is not for OPENSSL PMD */
11314 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11315 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11318 return test_authenticated_encryption_SGL(
11319 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11323 test_authentication_verify_fail_when_data_corrupted(
11324 struct crypto_testsuite_params *ts_params,
11325 struct crypto_unittest_params *ut_params,
11326 const struct test_crypto_vector *reference)
11328 return test_authentication_verify_fail_when_data_corruption(
11329 ts_params, ut_params, reference, 1);
11333 test_authentication_verify_fail_when_tag_corrupted(
11334 struct crypto_testsuite_params *ts_params,
11335 struct crypto_unittest_params *ut_params,
11336 const struct test_crypto_vector *reference)
11338 return test_authentication_verify_fail_when_data_corruption(
11339 ts_params, ut_params, reference, 0);
11343 test_authentication_verify_GMAC_fail_when_data_corrupted(
11344 struct crypto_testsuite_params *ts_params,
11345 struct crypto_unittest_params *ut_params,
11346 const struct test_crypto_vector *reference)
11348 return test_authentication_verify_GMAC_fail_when_corruption(
11349 ts_params, ut_params, reference, 1);
11353 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11354 struct crypto_testsuite_params *ts_params,
11355 struct crypto_unittest_params *ut_params,
11356 const struct test_crypto_vector *reference)
11358 return test_authentication_verify_GMAC_fail_when_corruption(
11359 ts_params, ut_params, reference, 0);
11363 test_authenticated_decryption_fail_when_data_corrupted(
11364 struct crypto_testsuite_params *ts_params,
11365 struct crypto_unittest_params *ut_params,
11366 const struct test_crypto_vector *reference)
11368 return test_authenticated_decryption_fail_when_corruption(
11369 ts_params, ut_params, reference, 1);
11373 test_authenticated_decryption_fail_when_tag_corrupted(
11374 struct crypto_testsuite_params *ts_params,
11375 struct crypto_unittest_params *ut_params,
11376 const struct test_crypto_vector *reference)
11378 return test_authenticated_decryption_fail_when_corruption(
11379 ts_params, ut_params, reference, 0);
11383 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11385 return test_authentication_verify_fail_when_data_corrupted(
11386 &testsuite_params, &unittest_params,
11387 &hmac_sha1_test_crypto_vector);
11391 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11393 return test_authentication_verify_fail_when_tag_corrupted(
11394 &testsuite_params, &unittest_params,
11395 &hmac_sha1_test_crypto_vector);
11399 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11401 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11402 &testsuite_params, &unittest_params,
11403 &aes128_gmac_test_vector);
11407 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11409 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11410 &testsuite_params, &unittest_params,
11411 &aes128_gmac_test_vector);
11415 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11417 return test_authenticated_decryption_fail_when_data_corrupted(
11420 &aes128cbc_hmac_sha1_test_vector);
11424 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11426 return test_authenticated_decryption_fail_when_tag_corrupted(
11429 &aes128cbc_hmac_sha1_test_vector);
11433 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11435 return test_authenticated_encryt_with_esn(
11438 &aes128cbc_hmac_sha1_aad_test_vector);
11442 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11444 return test_authenticated_decrypt_with_esn(
11447 &aes128cbc_hmac_sha1_aad_test_vector);
11450 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11452 /* global AESNI slave IDs for the scheduler test */
11453 uint8_t aesni_ids[2];
11456 test_scheduler_attach_slave_op(void)
11458 struct crypto_testsuite_params *ts_params = &testsuite_params;
11459 uint8_t sched_id = ts_params->valid_devs[0];
11460 uint32_t nb_devs, i, nb_devs_attached = 0;
11462 char vdev_name[32];
11464 /* create 2 AESNI_MB if necessary */
11465 nb_devs = rte_cryptodev_device_count_by_driver(
11466 rte_cryptodev_driver_id_get(
11467 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11469 for (i = nb_devs; i < 2; i++) {
11470 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11471 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11473 ret = rte_vdev_init(vdev_name, NULL);
11475 TEST_ASSERT(ret == 0,
11476 "Failed to create instance %u of"
11478 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11482 /* attach 2 AESNI_MB cdevs */
11483 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11485 struct rte_cryptodev_info info;
11486 unsigned int session_size;
11488 rte_cryptodev_info_get(i, &info);
11489 if (info.driver_id != rte_cryptodev_driver_id_get(
11490 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11493 session_size = rte_cryptodev_sym_get_private_session_size(i);
11495 * Create the session mempool again, since now there are new devices
11496 * to use the mempool.
11498 if (ts_params->session_mpool) {
11499 rte_mempool_free(ts_params->session_mpool);
11500 ts_params->session_mpool = NULL;
11502 if (ts_params->session_priv_mpool) {
11503 rte_mempool_free(ts_params->session_priv_mpool);
11504 ts_params->session_priv_mpool = NULL;
11507 if (info.sym.max_nb_sessions != 0 &&
11508 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11509 RTE_LOG(ERR, USER1,
11510 "Device does not support "
11511 "at least %u sessions\n",
11513 return TEST_FAILED;
11516 * Create mempool with maximum number of sessions,
11517 * to include the session headers
11519 if (ts_params->session_mpool == NULL) {
11520 ts_params->session_mpool =
11521 rte_cryptodev_sym_session_pool_create(
11523 MAX_NB_SESSIONS, 0, 0, 0,
11525 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11526 "session mempool allocation failed");
11530 * Create mempool with maximum number of sessions,
11531 * to include device specific session private data
11533 if (ts_params->session_priv_mpool == NULL) {
11534 ts_params->session_priv_mpool = rte_mempool_create(
11535 "test_sess_mp_priv",
11538 0, 0, NULL, NULL, NULL,
11539 NULL, SOCKET_ID_ANY,
11542 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11543 "session mempool allocation failed");
11546 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11547 ts_params->qp_conf.mp_session_private =
11548 ts_params->session_priv_mpool;
11550 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11553 TEST_ASSERT(ret == 0,
11554 "Failed to attach device %u of pmd : %s", i,
11555 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11557 aesni_ids[nb_devs_attached] = (uint8_t)i;
11559 nb_devs_attached++;
11566 test_scheduler_detach_slave_op(void)
11568 struct crypto_testsuite_params *ts_params = &testsuite_params;
11569 uint8_t sched_id = ts_params->valid_devs[0];
11573 for (i = 0; i < 2; i++) {
11574 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11576 TEST_ASSERT(ret == 0,
11577 "Failed to detach device %u", aesni_ids[i]);
11584 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11586 struct crypto_testsuite_params *ts_params = &testsuite_params;
11587 uint8_t sched_id = ts_params->valid_devs[0];
11589 return rte_cryptodev_scheduler_mode_set(sched_id,
11594 test_scheduler_mode_roundrobin_op(void)
11596 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11597 0, "Failed to set roundrobin mode");
11603 test_scheduler_mode_multicore_op(void)
11605 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11606 0, "Failed to set multicore mode");
11612 test_scheduler_mode_failover_op(void)
11614 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11615 0, "Failed to set failover mode");
11621 test_scheduler_mode_pkt_size_distr_op(void)
11623 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11624 0, "Failed to set pktsize mode");
11629 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11630 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11631 .setup = testsuite_setup,
11632 .teardown = testsuite_teardown,
11633 .unit_test_cases = {
11635 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11636 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11637 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11638 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11639 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11640 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11643 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11644 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11645 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11646 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11647 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11648 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11651 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11652 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11653 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11654 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11655 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11656 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11659 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11660 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11661 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11662 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11663 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11664 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11666 TEST_CASES_END() /**< NULL terminate unit test array */
11670 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11672 static struct unit_test_suite cryptodev_testsuite = {
11673 .suite_name = "Crypto Unit Test Suite",
11674 .setup = testsuite_setup,
11675 .teardown = testsuite_teardown,
11676 .unit_test_cases = {
11677 TEST_CASE_ST(ut_setup, ut_teardown,
11678 test_device_configure_invalid_dev_id),
11679 TEST_CASE_ST(ut_setup, ut_teardown,
11680 test_device_configure_invalid_queue_pair_ids),
11681 TEST_CASE_ST(ut_setup, ut_teardown,
11682 test_queue_pair_descriptor_setup),
11684 TEST_CASE_ST(ut_setup, ut_teardown,
11685 test_multi_session),
11686 TEST_CASE_ST(ut_setup, ut_teardown,
11687 test_multi_session_random_usage),
11689 TEST_CASE_ST(ut_setup, ut_teardown,
11690 test_null_invalid_operation),
11691 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11693 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11694 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11695 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11696 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11697 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11698 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11699 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11700 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11701 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11703 /** AES CCM Authenticated Encryption 128 bits key */
11704 TEST_CASE_ST(ut_setup, ut_teardown,
11705 test_AES_CCM_authenticated_encryption_test_case_128_1),
11706 TEST_CASE_ST(ut_setup, ut_teardown,
11707 test_AES_CCM_authenticated_encryption_test_case_128_2),
11708 TEST_CASE_ST(ut_setup, ut_teardown,
11709 test_AES_CCM_authenticated_encryption_test_case_128_3),
11711 /** AES CCM Authenticated Decryption 128 bits key*/
11712 TEST_CASE_ST(ut_setup, ut_teardown,
11713 test_AES_CCM_authenticated_decryption_test_case_128_1),
11714 TEST_CASE_ST(ut_setup, ut_teardown,
11715 test_AES_CCM_authenticated_decryption_test_case_128_2),
11716 TEST_CASE_ST(ut_setup, ut_teardown,
11717 test_AES_CCM_authenticated_decryption_test_case_128_3),
11719 /** AES CCM Authenticated Encryption 192 bits key */
11720 TEST_CASE_ST(ut_setup, ut_teardown,
11721 test_AES_CCM_authenticated_encryption_test_case_192_1),
11722 TEST_CASE_ST(ut_setup, ut_teardown,
11723 test_AES_CCM_authenticated_encryption_test_case_192_2),
11724 TEST_CASE_ST(ut_setup, ut_teardown,
11725 test_AES_CCM_authenticated_encryption_test_case_192_3),
11727 /** AES CCM Authenticated Decryption 192 bits key*/
11728 TEST_CASE_ST(ut_setup, ut_teardown,
11729 test_AES_CCM_authenticated_decryption_test_case_192_1),
11730 TEST_CASE_ST(ut_setup, ut_teardown,
11731 test_AES_CCM_authenticated_decryption_test_case_192_2),
11732 TEST_CASE_ST(ut_setup, ut_teardown,
11733 test_AES_CCM_authenticated_decryption_test_case_192_3),
11735 /** AES CCM Authenticated Encryption 256 bits key */
11736 TEST_CASE_ST(ut_setup, ut_teardown,
11737 test_AES_CCM_authenticated_encryption_test_case_256_1),
11738 TEST_CASE_ST(ut_setup, ut_teardown,
11739 test_AES_CCM_authenticated_encryption_test_case_256_2),
11740 TEST_CASE_ST(ut_setup, ut_teardown,
11741 test_AES_CCM_authenticated_encryption_test_case_256_3),
11743 /** AES CCM Authenticated Decryption 256 bits key*/
11744 TEST_CASE_ST(ut_setup, ut_teardown,
11745 test_AES_CCM_authenticated_decryption_test_case_256_1),
11746 TEST_CASE_ST(ut_setup, ut_teardown,
11747 test_AES_CCM_authenticated_decryption_test_case_256_2),
11748 TEST_CASE_ST(ut_setup, ut_teardown,
11749 test_AES_CCM_authenticated_decryption_test_case_256_3),
11751 /** AES GCM Authenticated Encryption */
11752 TEST_CASE_ST(ut_setup, ut_teardown,
11753 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11754 TEST_CASE_ST(ut_setup, ut_teardown,
11755 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11756 TEST_CASE_ST(ut_setup, ut_teardown,
11757 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11758 TEST_CASE_ST(ut_setup, ut_teardown,
11759 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11760 TEST_CASE_ST(ut_setup, ut_teardown,
11761 test_AES_GCM_authenticated_encryption_test_case_1),
11762 TEST_CASE_ST(ut_setup, ut_teardown,
11763 test_AES_GCM_authenticated_encryption_test_case_2),
11764 TEST_CASE_ST(ut_setup, ut_teardown,
11765 test_AES_GCM_authenticated_encryption_test_case_3),
11766 TEST_CASE_ST(ut_setup, ut_teardown,
11767 test_AES_GCM_authenticated_encryption_test_case_4),
11768 TEST_CASE_ST(ut_setup, ut_teardown,
11769 test_AES_GCM_authenticated_encryption_test_case_5),
11770 TEST_CASE_ST(ut_setup, ut_teardown,
11771 test_AES_GCM_authenticated_encryption_test_case_6),
11772 TEST_CASE_ST(ut_setup, ut_teardown,
11773 test_AES_GCM_authenticated_encryption_test_case_7),
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_AES_GCM_authenticated_encryption_test_case_8),
11776 TEST_CASE_ST(ut_setup, ut_teardown,
11777 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11779 /** AES GCM Authenticated Decryption */
11780 TEST_CASE_ST(ut_setup, ut_teardown,
11781 test_AES_GCM_authenticated_decryption_test_case_1),
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_AES_GCM_authenticated_decryption_test_case_2),
11784 TEST_CASE_ST(ut_setup, ut_teardown,
11785 test_AES_GCM_authenticated_decryption_test_case_3),
11786 TEST_CASE_ST(ut_setup, ut_teardown,
11787 test_AES_GCM_authenticated_decryption_test_case_4),
11788 TEST_CASE_ST(ut_setup, ut_teardown,
11789 test_AES_GCM_authenticated_decryption_test_case_5),
11790 TEST_CASE_ST(ut_setup, ut_teardown,
11791 test_AES_GCM_authenticated_decryption_test_case_6),
11792 TEST_CASE_ST(ut_setup, ut_teardown,
11793 test_AES_GCM_authenticated_decryption_test_case_7),
11794 TEST_CASE_ST(ut_setup, ut_teardown,
11795 test_AES_GCM_authenticated_decryption_test_case_8),
11796 TEST_CASE_ST(ut_setup, ut_teardown,
11797 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11799 /** AES GCM Authenticated Encryption 192 bits key */
11800 TEST_CASE_ST(ut_setup, ut_teardown,
11801 test_AES_GCM_auth_encryption_test_case_192_1),
11802 TEST_CASE_ST(ut_setup, ut_teardown,
11803 test_AES_GCM_auth_encryption_test_case_192_2),
11804 TEST_CASE_ST(ut_setup, ut_teardown,
11805 test_AES_GCM_auth_encryption_test_case_192_3),
11806 TEST_CASE_ST(ut_setup, ut_teardown,
11807 test_AES_GCM_auth_encryption_test_case_192_4),
11808 TEST_CASE_ST(ut_setup, ut_teardown,
11809 test_AES_GCM_auth_encryption_test_case_192_5),
11810 TEST_CASE_ST(ut_setup, ut_teardown,
11811 test_AES_GCM_auth_encryption_test_case_192_6),
11812 TEST_CASE_ST(ut_setup, ut_teardown,
11813 test_AES_GCM_auth_encryption_test_case_192_7),
11815 /** AES GCM Authenticated Decryption 192 bits key */
11816 TEST_CASE_ST(ut_setup, ut_teardown,
11817 test_AES_GCM_auth_decryption_test_case_192_1),
11818 TEST_CASE_ST(ut_setup, ut_teardown,
11819 test_AES_GCM_auth_decryption_test_case_192_2),
11820 TEST_CASE_ST(ut_setup, ut_teardown,
11821 test_AES_GCM_auth_decryption_test_case_192_3),
11822 TEST_CASE_ST(ut_setup, ut_teardown,
11823 test_AES_GCM_auth_decryption_test_case_192_4),
11824 TEST_CASE_ST(ut_setup, ut_teardown,
11825 test_AES_GCM_auth_decryption_test_case_192_5),
11826 TEST_CASE_ST(ut_setup, ut_teardown,
11827 test_AES_GCM_auth_decryption_test_case_192_6),
11828 TEST_CASE_ST(ut_setup, ut_teardown,
11829 test_AES_GCM_auth_decryption_test_case_192_7),
11831 /** AES GCM Authenticated Encryption 256 bits key */
11832 TEST_CASE_ST(ut_setup, ut_teardown,
11833 test_AES_GCM_auth_encryption_test_case_256_1),
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_AES_GCM_auth_encryption_test_case_256_2),
11836 TEST_CASE_ST(ut_setup, ut_teardown,
11837 test_AES_GCM_auth_encryption_test_case_256_3),
11838 TEST_CASE_ST(ut_setup, ut_teardown,
11839 test_AES_GCM_auth_encryption_test_case_256_4),
11840 TEST_CASE_ST(ut_setup, ut_teardown,
11841 test_AES_GCM_auth_encryption_test_case_256_5),
11842 TEST_CASE_ST(ut_setup, ut_teardown,
11843 test_AES_GCM_auth_encryption_test_case_256_6),
11844 TEST_CASE_ST(ut_setup, ut_teardown,
11845 test_AES_GCM_auth_encryption_test_case_256_7),
11847 /** AES GCM Authenticated Decryption 256 bits key */
11848 TEST_CASE_ST(ut_setup, ut_teardown,
11849 test_AES_GCM_auth_decryption_test_case_256_1),
11850 TEST_CASE_ST(ut_setup, ut_teardown,
11851 test_AES_GCM_auth_decryption_test_case_256_2),
11852 TEST_CASE_ST(ut_setup, ut_teardown,
11853 test_AES_GCM_auth_decryption_test_case_256_3),
11854 TEST_CASE_ST(ut_setup, ut_teardown,
11855 test_AES_GCM_auth_decryption_test_case_256_4),
11856 TEST_CASE_ST(ut_setup, ut_teardown,
11857 test_AES_GCM_auth_decryption_test_case_256_5),
11858 TEST_CASE_ST(ut_setup, ut_teardown,
11859 test_AES_GCM_auth_decryption_test_case_256_6),
11860 TEST_CASE_ST(ut_setup, ut_teardown,
11861 test_AES_GCM_auth_decryption_test_case_256_7),
11863 /** AES GCM Authenticated Encryption big aad size */
11864 TEST_CASE_ST(ut_setup, ut_teardown,
11865 test_AES_GCM_auth_encryption_test_case_aad_1),
11866 TEST_CASE_ST(ut_setup, ut_teardown,
11867 test_AES_GCM_auth_encryption_test_case_aad_2),
11869 /** AES GCM Authenticated Decryption big aad size */
11870 TEST_CASE_ST(ut_setup, ut_teardown,
11871 test_AES_GCM_auth_decryption_test_case_aad_1),
11872 TEST_CASE_ST(ut_setup, ut_teardown,
11873 test_AES_GCM_auth_decryption_test_case_aad_2),
11875 /** Out of place tests */
11876 TEST_CASE_ST(ut_setup, ut_teardown,
11877 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11878 TEST_CASE_ST(ut_setup, ut_teardown,
11879 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11881 /** Session-less tests */
11882 TEST_CASE_ST(ut_setup, ut_teardown,
11883 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11884 TEST_CASE_ST(ut_setup, ut_teardown,
11885 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11887 /** AES GMAC Authentication */
11888 TEST_CASE_ST(ut_setup, ut_teardown,
11889 test_AES_GMAC_authentication_test_case_1),
11890 TEST_CASE_ST(ut_setup, ut_teardown,
11891 test_AES_GMAC_authentication_verify_test_case_1),
11892 TEST_CASE_ST(ut_setup, ut_teardown,
11893 test_AES_GMAC_authentication_test_case_2),
11894 TEST_CASE_ST(ut_setup, ut_teardown,
11895 test_AES_GMAC_authentication_verify_test_case_2),
11896 TEST_CASE_ST(ut_setup, ut_teardown,
11897 test_AES_GMAC_authentication_test_case_3),
11898 TEST_CASE_ST(ut_setup, ut_teardown,
11899 test_AES_GMAC_authentication_verify_test_case_3),
11900 TEST_CASE_ST(ut_setup, ut_teardown,
11901 test_AES_GMAC_authentication_test_case_4),
11902 TEST_CASE_ST(ut_setup, ut_teardown,
11903 test_AES_GMAC_authentication_verify_test_case_4),
11905 /** SNOW 3G encrypt only (UEA2) */
11906 TEST_CASE_ST(ut_setup, ut_teardown,
11907 test_snow3g_encryption_test_case_1),
11908 TEST_CASE_ST(ut_setup, ut_teardown,
11909 test_snow3g_encryption_test_case_2),
11910 TEST_CASE_ST(ut_setup, ut_teardown,
11911 test_snow3g_encryption_test_case_3),
11912 TEST_CASE_ST(ut_setup, ut_teardown,
11913 test_snow3g_encryption_test_case_4),
11914 TEST_CASE_ST(ut_setup, ut_teardown,
11915 test_snow3g_encryption_test_case_5),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_snow3g_encryption_test_case_1_oop),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_snow3g_encryption_test_case_1_oop_sgl),
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_snow3g_encryption_test_case_1_offset_oop),
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_snow3g_decryption_test_case_1_oop),
11926 /** SNOW 3G generate auth, then encrypt (UEA2) */
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_snow3g_auth_cipher_test_case_1),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_snow3g_auth_cipher_test_case_2),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_snow3g_auth_cipher_test_case_2_oop),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_snow3g_auth_cipher_part_digest_enc),
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_snow3g_auth_cipher_part_digest_enc_oop),
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_snow3g_auth_cipher_test_case_3_sgl),
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 test_snow3g_auth_cipher_test_case_3_oop_sgl),
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_snow3g_auth_cipher_part_digest_enc_sgl),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11946 /** SNOW 3G decrypt (UEA2), then verify auth */
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_snow3g_auth_cipher_verify_test_case_1),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_snow3g_auth_cipher_verify_test_case_2),
11951 TEST_CASE_ST(ut_setup, ut_teardown,
11952 test_snow3g_auth_cipher_verify_test_case_2_oop),
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 test_snow3g_auth_cipher_verify_part_digest_enc),
11955 TEST_CASE_ST(ut_setup, ut_teardown,
11956 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11957 TEST_CASE_ST(ut_setup, ut_teardown,
11958 test_snow3g_auth_cipher_verify_test_case_3_sgl),
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11961 TEST_CASE_ST(ut_setup, ut_teardown,
11962 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11963 TEST_CASE_ST(ut_setup, ut_teardown,
11964 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11966 /** SNOW 3G decrypt only (UEA2) */
11967 TEST_CASE_ST(ut_setup, ut_teardown,
11968 test_snow3g_decryption_test_case_1),
11969 TEST_CASE_ST(ut_setup, ut_teardown,
11970 test_snow3g_decryption_test_case_2),
11971 TEST_CASE_ST(ut_setup, ut_teardown,
11972 test_snow3g_decryption_test_case_3),
11973 TEST_CASE_ST(ut_setup, ut_teardown,
11974 test_snow3g_decryption_test_case_4),
11975 TEST_CASE_ST(ut_setup, ut_teardown,
11976 test_snow3g_decryption_test_case_5),
11977 TEST_CASE_ST(ut_setup, ut_teardown,
11978 test_snow3g_decryption_with_digest_test_case_1),
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_snow3g_hash_generate_test_case_1),
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_snow3g_hash_generate_test_case_2),
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_snow3g_hash_generate_test_case_3),
11985 /* Tests with buffers which length is not byte-aligned */
11986 TEST_CASE_ST(ut_setup, ut_teardown,
11987 test_snow3g_hash_generate_test_case_4),
11988 TEST_CASE_ST(ut_setup, ut_teardown,
11989 test_snow3g_hash_generate_test_case_5),
11990 TEST_CASE_ST(ut_setup, ut_teardown,
11991 test_snow3g_hash_generate_test_case_6),
11992 TEST_CASE_ST(ut_setup, ut_teardown,
11993 test_snow3g_hash_verify_test_case_1),
11994 TEST_CASE_ST(ut_setup, ut_teardown,
11995 test_snow3g_hash_verify_test_case_2),
11996 TEST_CASE_ST(ut_setup, ut_teardown,
11997 test_snow3g_hash_verify_test_case_3),
11998 /* Tests with buffers which length is not byte-aligned */
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_snow3g_hash_verify_test_case_4),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_snow3g_hash_verify_test_case_5),
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 test_snow3g_hash_verify_test_case_6),
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_snow3g_cipher_auth_test_case_1),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_snow3g_auth_cipher_with_digest_test_case_1),
12010 /** ZUC encrypt only (EEA3) */
12011 TEST_CASE_ST(ut_setup, ut_teardown,
12012 test_zuc_encryption_test_case_1),
12013 TEST_CASE_ST(ut_setup, ut_teardown,
12014 test_zuc_encryption_test_case_2),
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_zuc_encryption_test_case_3),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_zuc_encryption_test_case_4),
12019 TEST_CASE_ST(ut_setup, ut_teardown,
12020 test_zuc_encryption_test_case_5),
12021 TEST_CASE_ST(ut_setup, ut_teardown,
12022 test_zuc_encryption_test_case_6_sgl),
12024 /** ZUC authenticate (EIA3) */
12025 TEST_CASE_ST(ut_setup, ut_teardown,
12026 test_zuc_hash_generate_test_case_1),
12027 TEST_CASE_ST(ut_setup, ut_teardown,
12028 test_zuc_hash_generate_test_case_2),
12029 TEST_CASE_ST(ut_setup, ut_teardown,
12030 test_zuc_hash_generate_test_case_3),
12031 TEST_CASE_ST(ut_setup, ut_teardown,
12032 test_zuc_hash_generate_test_case_4),
12033 TEST_CASE_ST(ut_setup, ut_teardown,
12034 test_zuc_hash_generate_test_case_5),
12035 TEST_CASE_ST(ut_setup, ut_teardown,
12036 test_zuc_hash_generate_test_case_6),
12037 TEST_CASE_ST(ut_setup, ut_teardown,
12038 test_zuc_hash_generate_test_case_7),
12039 TEST_CASE_ST(ut_setup, ut_teardown,
12040 test_zuc_hash_generate_test_case_8),
12042 /** ZUC alg-chain (EEA3/EIA3) */
12043 TEST_CASE_ST(ut_setup, ut_teardown,
12044 test_zuc_cipher_auth_test_case_1),
12045 TEST_CASE_ST(ut_setup, ut_teardown,
12046 test_zuc_cipher_auth_test_case_2),
12048 /** ZUC generate auth, then encrypt (EEA3) */
12049 TEST_CASE_ST(ut_setup, ut_teardown,
12050 test_zuc_auth_cipher_test_case_1),
12051 TEST_CASE_ST(ut_setup, ut_teardown,
12052 test_zuc_auth_cipher_test_case_1_oop),
12053 TEST_CASE_ST(ut_setup, ut_teardown,
12054 test_zuc_auth_cipher_test_case_1_sgl),
12055 TEST_CASE_ST(ut_setup, ut_teardown,
12056 test_zuc_auth_cipher_test_case_1_oop_sgl),
12058 /** ZUC decrypt (EEA3), then verify auth */
12059 TEST_CASE_ST(ut_setup, ut_teardown,
12060 test_zuc_auth_cipher_verify_test_case_1),
12061 TEST_CASE_ST(ut_setup, ut_teardown,
12062 test_zuc_auth_cipher_verify_test_case_1_oop),
12063 TEST_CASE_ST(ut_setup, ut_teardown,
12064 test_zuc_auth_cipher_verify_test_case_1_sgl),
12065 TEST_CASE_ST(ut_setup, ut_teardown,
12066 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12068 /** HMAC_MD5 Authentication */
12069 TEST_CASE_ST(ut_setup, ut_teardown,
12070 test_MD5_HMAC_generate_case_1),
12071 TEST_CASE_ST(ut_setup, ut_teardown,
12072 test_MD5_HMAC_verify_case_1),
12073 TEST_CASE_ST(ut_setup, ut_teardown,
12074 test_MD5_HMAC_generate_case_2),
12075 TEST_CASE_ST(ut_setup, ut_teardown,
12076 test_MD5_HMAC_verify_case_2),
12078 /** KASUMI hash only (UIA1) */
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_kasumi_hash_generate_test_case_1),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_kasumi_hash_generate_test_case_2),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_kasumi_hash_generate_test_case_3),
12085 TEST_CASE_ST(ut_setup, ut_teardown,
12086 test_kasumi_hash_generate_test_case_4),
12087 TEST_CASE_ST(ut_setup, ut_teardown,
12088 test_kasumi_hash_generate_test_case_5),
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_kasumi_hash_generate_test_case_6),
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 test_kasumi_hash_verify_test_case_1),
12094 TEST_CASE_ST(ut_setup, ut_teardown,
12095 test_kasumi_hash_verify_test_case_2),
12096 TEST_CASE_ST(ut_setup, ut_teardown,
12097 test_kasumi_hash_verify_test_case_3),
12098 TEST_CASE_ST(ut_setup, ut_teardown,
12099 test_kasumi_hash_verify_test_case_4),
12100 TEST_CASE_ST(ut_setup, ut_teardown,
12101 test_kasumi_hash_verify_test_case_5),
12103 /** KASUMI encrypt only (UEA1) */
12104 TEST_CASE_ST(ut_setup, ut_teardown,
12105 test_kasumi_encryption_test_case_1),
12106 TEST_CASE_ST(ut_setup, ut_teardown,
12107 test_kasumi_encryption_test_case_1_sgl),
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_kasumi_encryption_test_case_1_oop),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_kasumi_encryption_test_case_1_oop_sgl),
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_kasumi_encryption_test_case_2),
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_kasumi_encryption_test_case_3),
12116 TEST_CASE_ST(ut_setup, ut_teardown,
12117 test_kasumi_encryption_test_case_4),
12118 TEST_CASE_ST(ut_setup, ut_teardown,
12119 test_kasumi_encryption_test_case_5),
12121 /** KASUMI decrypt only (UEA1) */
12122 TEST_CASE_ST(ut_setup, ut_teardown,
12123 test_kasumi_decryption_test_case_1),
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_kasumi_decryption_test_case_2),
12126 TEST_CASE_ST(ut_setup, ut_teardown,
12127 test_kasumi_decryption_test_case_3),
12128 TEST_CASE_ST(ut_setup, ut_teardown,
12129 test_kasumi_decryption_test_case_4),
12130 TEST_CASE_ST(ut_setup, ut_teardown,
12131 test_kasumi_decryption_test_case_5),
12132 TEST_CASE_ST(ut_setup, ut_teardown,
12133 test_kasumi_decryption_test_case_1_oop),
12135 TEST_CASE_ST(ut_setup, ut_teardown,
12136 test_kasumi_cipher_auth_test_case_1),
12138 /** KASUMI generate auth, then encrypt (F8) */
12139 TEST_CASE_ST(ut_setup, ut_teardown,
12140 test_kasumi_auth_cipher_test_case_1),
12141 TEST_CASE_ST(ut_setup, ut_teardown,
12142 test_kasumi_auth_cipher_test_case_2),
12143 TEST_CASE_ST(ut_setup, ut_teardown,
12144 test_kasumi_auth_cipher_test_case_2_oop),
12145 TEST_CASE_ST(ut_setup, ut_teardown,
12146 test_kasumi_auth_cipher_test_case_2_sgl),
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12150 /** KASUMI decrypt (F8), then verify auth */
12151 TEST_CASE_ST(ut_setup, ut_teardown,
12152 test_kasumi_auth_cipher_verify_test_case_1),
12153 TEST_CASE_ST(ut_setup, ut_teardown,
12154 test_kasumi_auth_cipher_verify_test_case_2),
12155 TEST_CASE_ST(ut_setup, ut_teardown,
12156 test_kasumi_auth_cipher_verify_test_case_2_oop),
12157 TEST_CASE_ST(ut_setup, ut_teardown,
12158 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12159 TEST_CASE_ST(ut_setup, ut_teardown,
12160 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12162 /** ESN Testcase */
12163 TEST_CASE_ST(ut_setup, ut_teardown,
12164 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12165 TEST_CASE_ST(ut_setup, ut_teardown,
12166 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12168 /** Negative tests */
12169 TEST_CASE_ST(ut_setup, ut_teardown,
12170 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12171 TEST_CASE_ST(ut_setup, ut_teardown,
12172 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12173 TEST_CASE_ST(ut_setup, ut_teardown,
12174 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12175 TEST_CASE_ST(ut_setup, ut_teardown,
12176 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12177 TEST_CASE_ST(ut_setup, ut_teardown,
12178 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12179 TEST_CASE_ST(ut_setup, ut_teardown,
12180 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12181 TEST_CASE_ST(ut_setup, ut_teardown,
12182 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12183 TEST_CASE_ST(ut_setup, ut_teardown,
12184 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12185 TEST_CASE_ST(ut_setup, ut_teardown,
12186 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12191 TEST_CASE_ST(ut_setup, ut_teardown,
12192 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12193 TEST_CASE_ST(ut_setup, ut_teardown,
12194 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12195 TEST_CASE_ST(ut_setup, ut_teardown,
12196 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12197 TEST_CASE_ST(ut_setup, ut_teardown,
12198 authentication_verify_AES128_GMAC_fail_data_corrupt),
12199 TEST_CASE_ST(ut_setup, ut_teardown,
12200 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12206 /** Mixed CIPHER + HASH algorithms */
12207 /** AUTH AES CMAC + CIPHER AES CTR */
12208 TEST_CASE_ST(ut_setup, ut_teardown,
12209 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12210 TEST_CASE_ST(ut_setup, ut_teardown,
12211 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12212 TEST_CASE_ST(ut_setup, ut_teardown,
12213 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12214 TEST_CASE_ST(ut_setup, ut_teardown,
12215 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12216 TEST_CASE_ST(ut_setup, ut_teardown,
12217 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12218 TEST_CASE_ST(ut_setup, ut_teardown,
12219 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12220 TEST_CASE_ST(ut_setup, ut_teardown,
12221 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12222 TEST_CASE_ST(ut_setup, ut_teardown,
12223 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12225 /** AUTH ZUC + CIPHER SNOW3G */
12226 TEST_CASE_ST(ut_setup, ut_teardown,
12227 test_auth_zuc_cipher_snow_test_case_1),
12228 TEST_CASE_ST(ut_setup, ut_teardown,
12229 test_verify_auth_zuc_cipher_snow_test_case_1),
12230 /** AUTH AES CMAC + CIPHER SNOW3G */
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_auth_aes_cmac_cipher_snow_test_case_1),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12235 /** AUTH ZUC + CIPHER AES CTR */
12236 TEST_CASE_ST(ut_setup, ut_teardown,
12237 test_auth_zuc_cipher_aes_ctr_test_case_1),
12238 TEST_CASE_ST(ut_setup, ut_teardown,
12239 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12240 /** AUTH SNOW3G + CIPHER AES CTR */
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 test_auth_snow_cipher_aes_ctr_test_case_1),
12243 TEST_CASE_ST(ut_setup, ut_teardown,
12244 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12245 /** AUTH SNOW3G + CIPHER ZUC */
12246 TEST_CASE_ST(ut_setup, ut_teardown,
12247 test_auth_snow_cipher_zuc_test_case_1),
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_verify_auth_snow_cipher_zuc_test_case_1),
12250 /** AUTH AES CMAC + CIPHER ZUC */
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_auth_aes_cmac_cipher_zuc_test_case_1),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12256 /** AUTH NULL + CIPHER SNOW3G */
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 test_auth_null_cipher_snow_test_case_1),
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 test_verify_auth_null_cipher_snow_test_case_1),
12261 /** AUTH NULL + CIPHER ZUC */
12262 TEST_CASE_ST(ut_setup, ut_teardown,
12263 test_auth_null_cipher_zuc_test_case_1),
12264 TEST_CASE_ST(ut_setup, ut_teardown,
12265 test_verify_auth_null_cipher_zuc_test_case_1),
12266 /** AUTH SNOW3G + CIPHER NULL */
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_auth_snow_cipher_null_test_case_1),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_verify_auth_snow_cipher_null_test_case_1),
12271 /** AUTH ZUC + CIPHER NULL */
12272 TEST_CASE_ST(ut_setup, ut_teardown,
12273 test_auth_zuc_cipher_null_test_case_1),
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 test_verify_auth_zuc_cipher_null_test_case_1),
12276 /** AUTH NULL + CIPHER AES CTR */
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 test_auth_null_cipher_aes_ctr_test_case_1),
12279 TEST_CASE_ST(ut_setup, ut_teardown,
12280 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12281 /** AUTH AES CMAC + CIPHER NULL */
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_auth_aes_cmac_cipher_null_test_case_1),
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12287 TEST_CASES_END() /**< NULL terminate unit test array */
12291 static struct unit_test_suite cryptodev_virtio_testsuite = {
12292 .suite_name = "Crypto VIRTIO Unit Test Suite",
12293 .setup = testsuite_setup,
12294 .teardown = testsuite_teardown,
12295 .unit_test_cases = {
12296 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12298 TEST_CASES_END() /**< NULL terminate unit test array */
12302 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12303 .suite_name = "Crypto CAAM JR Unit Test Suite",
12304 .setup = testsuite_setup,
12305 .teardown = testsuite_teardown,
12306 .unit_test_cases = {
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_device_configure_invalid_dev_id),
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_multi_session),
12312 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12313 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12314 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12315 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12316 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12318 TEST_CASES_END() /**< NULL terminate unit test array */
12322 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12323 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12324 .setup = testsuite_setup,
12325 .teardown = testsuite_teardown,
12326 .unit_test_cases = {
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_device_configure_invalid_dev_id),
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_multi_session),
12332 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12333 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12334 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12335 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12336 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12338 #ifdef RTE_LIBRTE_SECURITY
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_PDCP_PROTO_cplane_encap_all),
12342 TEST_CASE_ST(ut_setup, ut_teardown,
12343 test_PDCP_PROTO_cplane_decap_all),
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_PDCP_PROTO_uplane_encap_all),
12348 TEST_CASE_ST(ut_setup, ut_teardown,
12349 test_PDCP_PROTO_uplane_decap_all),
12351 TEST_CASE_ST(ut_setup, ut_teardown,
12352 test_PDCP_PROTO_SGL_in_place_32B),
12353 TEST_CASE_ST(ut_setup, ut_teardown,
12354 test_PDCP_PROTO_SGL_oop_32B_128B),
12355 TEST_CASE_ST(ut_setup, ut_teardown,
12356 test_PDCP_PROTO_SGL_oop_32B_40B),
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_PDCP_PROTO_SGL_oop_128B_32B),
12360 /** AES GCM Authenticated Encryption */
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12363 TEST_CASE_ST(ut_setup, ut_teardown,
12364 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_AES_GCM_authenticated_encryption_test_case_1),
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_AES_GCM_authenticated_encryption_test_case_2),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_AES_GCM_authenticated_encryption_test_case_3),
12375 TEST_CASE_ST(ut_setup, ut_teardown,
12376 test_AES_GCM_authenticated_encryption_test_case_4),
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_AES_GCM_authenticated_encryption_test_case_5),
12379 TEST_CASE_ST(ut_setup, ut_teardown,
12380 test_AES_GCM_authenticated_encryption_test_case_6),
12381 TEST_CASE_ST(ut_setup, ut_teardown,
12382 test_AES_GCM_authenticated_encryption_test_case_7),
12383 TEST_CASE_ST(ut_setup, ut_teardown,
12384 test_AES_GCM_authenticated_encryption_test_case_8),
12386 /** AES GCM Authenticated Decryption */
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_AES_GCM_authenticated_decryption_test_case_1),
12389 TEST_CASE_ST(ut_setup, ut_teardown,
12390 test_AES_GCM_authenticated_decryption_test_case_2),
12391 TEST_CASE_ST(ut_setup, ut_teardown,
12392 test_AES_GCM_authenticated_decryption_test_case_3),
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_AES_GCM_authenticated_decryption_test_case_4),
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_AES_GCM_authenticated_decryption_test_case_5),
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_AES_GCM_authenticated_decryption_test_case_6),
12399 TEST_CASE_ST(ut_setup, ut_teardown,
12400 test_AES_GCM_authenticated_decryption_test_case_7),
12401 TEST_CASE_ST(ut_setup, ut_teardown,
12402 test_AES_GCM_authenticated_decryption_test_case_8),
12404 /** AES GCM Authenticated Encryption 192 bits key */
12405 TEST_CASE_ST(ut_setup, ut_teardown,
12406 test_AES_GCM_auth_encryption_test_case_192_1),
12407 TEST_CASE_ST(ut_setup, ut_teardown,
12408 test_AES_GCM_auth_encryption_test_case_192_2),
12409 TEST_CASE_ST(ut_setup, ut_teardown,
12410 test_AES_GCM_auth_encryption_test_case_192_3),
12411 TEST_CASE_ST(ut_setup, ut_teardown,
12412 test_AES_GCM_auth_encryption_test_case_192_4),
12413 TEST_CASE_ST(ut_setup, ut_teardown,
12414 test_AES_GCM_auth_encryption_test_case_192_5),
12415 TEST_CASE_ST(ut_setup, ut_teardown,
12416 test_AES_GCM_auth_encryption_test_case_192_6),
12417 TEST_CASE_ST(ut_setup, ut_teardown,
12418 test_AES_GCM_auth_encryption_test_case_192_7),
12420 /** AES GCM Authenticated Decryption 192 bits key */
12421 TEST_CASE_ST(ut_setup, ut_teardown,
12422 test_AES_GCM_auth_decryption_test_case_192_1),
12423 TEST_CASE_ST(ut_setup, ut_teardown,
12424 test_AES_GCM_auth_decryption_test_case_192_2),
12425 TEST_CASE_ST(ut_setup, ut_teardown,
12426 test_AES_GCM_auth_decryption_test_case_192_3),
12427 TEST_CASE_ST(ut_setup, ut_teardown,
12428 test_AES_GCM_auth_decryption_test_case_192_4),
12429 TEST_CASE_ST(ut_setup, ut_teardown,
12430 test_AES_GCM_auth_decryption_test_case_192_5),
12431 TEST_CASE_ST(ut_setup, ut_teardown,
12432 test_AES_GCM_auth_decryption_test_case_192_6),
12433 TEST_CASE_ST(ut_setup, ut_teardown,
12434 test_AES_GCM_auth_decryption_test_case_192_7),
12436 /** AES GCM Authenticated Encryption 256 bits key */
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_AES_GCM_auth_encryption_test_case_256_1),
12439 TEST_CASE_ST(ut_setup, ut_teardown,
12440 test_AES_GCM_auth_encryption_test_case_256_2),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_AES_GCM_auth_encryption_test_case_256_3),
12443 TEST_CASE_ST(ut_setup, ut_teardown,
12444 test_AES_GCM_auth_encryption_test_case_256_4),
12445 TEST_CASE_ST(ut_setup, ut_teardown,
12446 test_AES_GCM_auth_encryption_test_case_256_5),
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 test_AES_GCM_auth_encryption_test_case_256_6),
12449 TEST_CASE_ST(ut_setup, ut_teardown,
12450 test_AES_GCM_auth_encryption_test_case_256_7),
12452 /** AES GCM Authenticated Decryption 256 bits key */
12453 TEST_CASE_ST(ut_setup, ut_teardown,
12454 test_AES_GCM_auth_decryption_test_case_256_1),
12455 TEST_CASE_ST(ut_setup, ut_teardown,
12456 test_AES_GCM_auth_decryption_test_case_256_2),
12457 TEST_CASE_ST(ut_setup, ut_teardown,
12458 test_AES_GCM_auth_decryption_test_case_256_3),
12459 TEST_CASE_ST(ut_setup, ut_teardown,
12460 test_AES_GCM_auth_decryption_test_case_256_4),
12461 TEST_CASE_ST(ut_setup, ut_teardown,
12462 test_AES_GCM_auth_decryption_test_case_256_5),
12463 TEST_CASE_ST(ut_setup, ut_teardown,
12464 test_AES_GCM_auth_decryption_test_case_256_6),
12465 TEST_CASE_ST(ut_setup, ut_teardown,
12466 test_AES_GCM_auth_decryption_test_case_256_7),
12468 /** Out of place tests */
12469 TEST_CASE_ST(ut_setup, ut_teardown,
12470 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12471 TEST_CASE_ST(ut_setup, ut_teardown,
12472 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12474 /** SNOW 3G encrypt only (UEA2) */
12475 TEST_CASE_ST(ut_setup, ut_teardown,
12476 test_snow3g_encryption_test_case_1),
12477 TEST_CASE_ST(ut_setup, ut_teardown,
12478 test_snow3g_encryption_test_case_2),
12479 TEST_CASE_ST(ut_setup, ut_teardown,
12480 test_snow3g_encryption_test_case_3),
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_snow3g_encryption_test_case_4),
12483 TEST_CASE_ST(ut_setup, ut_teardown,
12484 test_snow3g_encryption_test_case_5),
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_snow3g_encryption_test_case_1_oop),
12488 TEST_CASE_ST(ut_setup, ut_teardown,
12489 test_snow3g_encryption_test_case_1_oop_sgl),
12490 TEST_CASE_ST(ut_setup, ut_teardown,
12491 test_snow3g_decryption_test_case_1_oop),
12493 /** SNOW 3G decrypt only (UEA2) */
12494 TEST_CASE_ST(ut_setup, ut_teardown,
12495 test_snow3g_decryption_test_case_1),
12496 TEST_CASE_ST(ut_setup, ut_teardown,
12497 test_snow3g_decryption_test_case_2),
12498 TEST_CASE_ST(ut_setup, ut_teardown,
12499 test_snow3g_decryption_test_case_3),
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_snow3g_decryption_test_case_4),
12502 TEST_CASE_ST(ut_setup, ut_teardown,
12503 test_snow3g_decryption_test_case_5),
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_snow3g_hash_generate_test_case_1),
12507 TEST_CASE_ST(ut_setup, ut_teardown,
12508 test_snow3g_hash_generate_test_case_2),
12509 TEST_CASE_ST(ut_setup, ut_teardown,
12510 test_snow3g_hash_generate_test_case_3),
12511 TEST_CASE_ST(ut_setup, ut_teardown,
12512 test_snow3g_hash_verify_test_case_1),
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 test_snow3g_hash_verify_test_case_2),
12515 TEST_CASE_ST(ut_setup, ut_teardown,
12516 test_snow3g_hash_verify_test_case_3),
12518 /** ZUC encrypt only (EEA3) */
12519 TEST_CASE_ST(ut_setup, ut_teardown,
12520 test_zuc_encryption_test_case_1),
12521 TEST_CASE_ST(ut_setup, ut_teardown,
12522 test_zuc_encryption_test_case_2),
12523 TEST_CASE_ST(ut_setup, ut_teardown,
12524 test_zuc_encryption_test_case_3),
12525 TEST_CASE_ST(ut_setup, ut_teardown,
12526 test_zuc_encryption_test_case_4),
12527 TEST_CASE_ST(ut_setup, ut_teardown,
12528 test_zuc_encryption_test_case_5),
12530 /** ZUC authenticate (EIA3) */
12531 TEST_CASE_ST(ut_setup, ut_teardown,
12532 test_zuc_hash_generate_test_case_6),
12533 TEST_CASE_ST(ut_setup, ut_teardown,
12534 test_zuc_hash_generate_test_case_7),
12535 TEST_CASE_ST(ut_setup, ut_teardown,
12536 test_zuc_hash_generate_test_case_8),
12538 /** Negative tests */
12539 TEST_CASE_ST(ut_setup, ut_teardown,
12540 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12541 TEST_CASE_ST(ut_setup, ut_teardown,
12542 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12543 TEST_CASE_ST(ut_setup, ut_teardown,
12544 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12545 TEST_CASE_ST(ut_setup, ut_teardown,
12546 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12547 TEST_CASE_ST(ut_setup, ut_teardown,
12548 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12549 TEST_CASE_ST(ut_setup, ut_teardown,
12550 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12551 TEST_CASE_ST(ut_setup, ut_teardown,
12552 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12553 TEST_CASE_ST(ut_setup, ut_teardown,
12554 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12555 TEST_CASE_ST(ut_setup, ut_teardown,
12556 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12557 TEST_CASE_ST(ut_setup, ut_teardown,
12558 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12559 TEST_CASE_ST(ut_setup, ut_teardown,
12560 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12561 TEST_CASE_ST(ut_setup, ut_teardown,
12562 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12563 TEST_CASE_ST(ut_setup, ut_teardown,
12564 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12565 TEST_CASE_ST(ut_setup, ut_teardown,
12566 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12567 TEST_CASE_ST(ut_setup, ut_teardown,
12568 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12569 TEST_CASE_ST(ut_setup, ut_teardown,
12570 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12573 TEST_CASE_ST(ut_setup, ut_teardown,
12574 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12575 TEST_CASE_ST(ut_setup, ut_teardown,
12576 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12578 TEST_CASES_END() /**< NULL terminate unit test array */
12582 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12583 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12584 .setup = testsuite_setup,
12585 .teardown = testsuite_teardown,
12586 .unit_test_cases = {
12587 TEST_CASE_ST(ut_setup, ut_teardown,
12588 test_device_configure_invalid_dev_id),
12589 TEST_CASE_ST(ut_setup, ut_teardown,
12590 test_multi_session),
12591 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12592 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12593 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12594 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12595 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12597 #ifdef RTE_LIBRTE_SECURITY
12598 TEST_CASE_ST(ut_setup, ut_teardown,
12599 test_PDCP_PROTO_cplane_encap_all),
12601 TEST_CASE_ST(ut_setup, ut_teardown,
12602 test_PDCP_PROTO_cplane_decap_all),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_PDCP_PROTO_uplane_encap_all),
12607 TEST_CASE_ST(ut_setup, ut_teardown,
12608 test_PDCP_PROTO_uplane_decap_all),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_PDCP_PROTO_SGL_in_place_32B),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_PDCP_PROTO_SGL_oop_32B_128B),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_PDCP_PROTO_SGL_oop_32B_40B),
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_PDCP_PROTO_SGL_oop_128B_32B),
12619 /** AES GCM Authenticated Encryption */
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12622 TEST_CASE_ST(ut_setup, ut_teardown,
12623 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12626 TEST_CASE_ST(ut_setup, ut_teardown,
12627 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12628 TEST_CASE_ST(ut_setup, ut_teardown,
12629 test_AES_GCM_authenticated_encryption_test_case_1),
12630 TEST_CASE_ST(ut_setup, ut_teardown,
12631 test_AES_GCM_authenticated_encryption_test_case_2),
12632 TEST_CASE_ST(ut_setup, ut_teardown,
12633 test_AES_GCM_authenticated_encryption_test_case_3),
12634 TEST_CASE_ST(ut_setup, ut_teardown,
12635 test_AES_GCM_authenticated_encryption_test_case_4),
12636 TEST_CASE_ST(ut_setup, ut_teardown,
12637 test_AES_GCM_authenticated_encryption_test_case_5),
12638 TEST_CASE_ST(ut_setup, ut_teardown,
12639 test_AES_GCM_authenticated_encryption_test_case_6),
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 test_AES_GCM_authenticated_encryption_test_case_7),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 test_AES_GCM_authenticated_encryption_test_case_8),
12645 /** AES GCM Authenticated Decryption */
12646 TEST_CASE_ST(ut_setup, ut_teardown,
12647 test_AES_GCM_authenticated_decryption_test_case_1),
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_AES_GCM_authenticated_decryption_test_case_2),
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 test_AES_GCM_authenticated_decryption_test_case_3),
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 test_AES_GCM_authenticated_decryption_test_case_4),
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 test_AES_GCM_authenticated_decryption_test_case_5),
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 test_AES_GCM_authenticated_decryption_test_case_6),
12658 TEST_CASE_ST(ut_setup, ut_teardown,
12659 test_AES_GCM_authenticated_decryption_test_case_7),
12660 TEST_CASE_ST(ut_setup, ut_teardown,
12661 test_AES_GCM_authenticated_decryption_test_case_8),
12663 /** AES GCM Authenticated Encryption 192 bits key */
12664 TEST_CASE_ST(ut_setup, ut_teardown,
12665 test_AES_GCM_auth_encryption_test_case_192_1),
12666 TEST_CASE_ST(ut_setup, ut_teardown,
12667 test_AES_GCM_auth_encryption_test_case_192_2),
12668 TEST_CASE_ST(ut_setup, ut_teardown,
12669 test_AES_GCM_auth_encryption_test_case_192_3),
12670 TEST_CASE_ST(ut_setup, ut_teardown,
12671 test_AES_GCM_auth_encryption_test_case_192_4),
12672 TEST_CASE_ST(ut_setup, ut_teardown,
12673 test_AES_GCM_auth_encryption_test_case_192_5),
12674 TEST_CASE_ST(ut_setup, ut_teardown,
12675 test_AES_GCM_auth_encryption_test_case_192_6),
12676 TEST_CASE_ST(ut_setup, ut_teardown,
12677 test_AES_GCM_auth_encryption_test_case_192_7),
12679 /** AES GCM Authenticated Decryption 192 bits key */
12680 TEST_CASE_ST(ut_setup, ut_teardown,
12681 test_AES_GCM_auth_decryption_test_case_192_1),
12682 TEST_CASE_ST(ut_setup, ut_teardown,
12683 test_AES_GCM_auth_decryption_test_case_192_2),
12684 TEST_CASE_ST(ut_setup, ut_teardown,
12685 test_AES_GCM_auth_decryption_test_case_192_3),
12686 TEST_CASE_ST(ut_setup, ut_teardown,
12687 test_AES_GCM_auth_decryption_test_case_192_4),
12688 TEST_CASE_ST(ut_setup, ut_teardown,
12689 test_AES_GCM_auth_decryption_test_case_192_5),
12690 TEST_CASE_ST(ut_setup, ut_teardown,
12691 test_AES_GCM_auth_decryption_test_case_192_6),
12692 TEST_CASE_ST(ut_setup, ut_teardown,
12693 test_AES_GCM_auth_decryption_test_case_192_7),
12695 /** AES GCM Authenticated Encryption 256 bits key */
12696 TEST_CASE_ST(ut_setup, ut_teardown,
12697 test_AES_GCM_auth_encryption_test_case_256_1),
12698 TEST_CASE_ST(ut_setup, ut_teardown,
12699 test_AES_GCM_auth_encryption_test_case_256_2),
12700 TEST_CASE_ST(ut_setup, ut_teardown,
12701 test_AES_GCM_auth_encryption_test_case_256_3),
12702 TEST_CASE_ST(ut_setup, ut_teardown,
12703 test_AES_GCM_auth_encryption_test_case_256_4),
12704 TEST_CASE_ST(ut_setup, ut_teardown,
12705 test_AES_GCM_auth_encryption_test_case_256_5),
12706 TEST_CASE_ST(ut_setup, ut_teardown,
12707 test_AES_GCM_auth_encryption_test_case_256_6),
12708 TEST_CASE_ST(ut_setup, ut_teardown,
12709 test_AES_GCM_auth_encryption_test_case_256_7),
12711 /** AES GCM Authenticated Decryption 256 bits key */
12712 TEST_CASE_ST(ut_setup, ut_teardown,
12713 test_AES_GCM_auth_decryption_test_case_256_1),
12714 TEST_CASE_ST(ut_setup, ut_teardown,
12715 test_AES_GCM_auth_decryption_test_case_256_2),
12716 TEST_CASE_ST(ut_setup, ut_teardown,
12717 test_AES_GCM_auth_decryption_test_case_256_3),
12718 TEST_CASE_ST(ut_setup, ut_teardown,
12719 test_AES_GCM_auth_decryption_test_case_256_4),
12720 TEST_CASE_ST(ut_setup, ut_teardown,
12721 test_AES_GCM_auth_decryption_test_case_256_5),
12722 TEST_CASE_ST(ut_setup, ut_teardown,
12723 test_AES_GCM_auth_decryption_test_case_256_6),
12724 TEST_CASE_ST(ut_setup, ut_teardown,
12725 test_AES_GCM_auth_decryption_test_case_256_7),
12727 /** Out of place tests */
12728 TEST_CASE_ST(ut_setup, ut_teardown,
12729 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12730 TEST_CASE_ST(ut_setup, ut_teardown,
12731 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12733 /** SNOW 3G encrypt only (UEA2) */
12734 TEST_CASE_ST(ut_setup, ut_teardown,
12735 test_snow3g_encryption_test_case_1),
12736 TEST_CASE_ST(ut_setup, ut_teardown,
12737 test_snow3g_encryption_test_case_2),
12738 TEST_CASE_ST(ut_setup, ut_teardown,
12739 test_snow3g_encryption_test_case_3),
12740 TEST_CASE_ST(ut_setup, ut_teardown,
12741 test_snow3g_encryption_test_case_4),
12742 TEST_CASE_ST(ut_setup, ut_teardown,
12743 test_snow3g_encryption_test_case_5),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_snow3g_encryption_test_case_1_oop),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_snow3g_encryption_test_case_1_oop_sgl),
12749 TEST_CASE_ST(ut_setup, ut_teardown,
12750 test_snow3g_decryption_test_case_1_oop),
12752 /** SNOW 3G decrypt only (UEA2) */
12753 TEST_CASE_ST(ut_setup, ut_teardown,
12754 test_snow3g_decryption_test_case_1),
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_snow3g_decryption_test_case_2),
12757 TEST_CASE_ST(ut_setup, ut_teardown,
12758 test_snow3g_decryption_test_case_3),
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_snow3g_decryption_test_case_4),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_snow3g_decryption_test_case_5),
12764 TEST_CASE_ST(ut_setup, ut_teardown,
12765 test_snow3g_hash_generate_test_case_1),
12766 TEST_CASE_ST(ut_setup, ut_teardown,
12767 test_snow3g_hash_generate_test_case_2),
12768 TEST_CASE_ST(ut_setup, ut_teardown,
12769 test_snow3g_hash_generate_test_case_3),
12770 TEST_CASE_ST(ut_setup, ut_teardown,
12771 test_snow3g_hash_verify_test_case_1),
12772 TEST_CASE_ST(ut_setup, ut_teardown,
12773 test_snow3g_hash_verify_test_case_2),
12774 TEST_CASE_ST(ut_setup, ut_teardown,
12775 test_snow3g_hash_verify_test_case_3),
12777 /** ZUC encrypt only (EEA3) */
12778 TEST_CASE_ST(ut_setup, ut_teardown,
12779 test_zuc_encryption_test_case_1),
12780 TEST_CASE_ST(ut_setup, ut_teardown,
12781 test_zuc_encryption_test_case_2),
12782 TEST_CASE_ST(ut_setup, ut_teardown,
12783 test_zuc_encryption_test_case_3),
12784 TEST_CASE_ST(ut_setup, ut_teardown,
12785 test_zuc_encryption_test_case_4),
12786 TEST_CASE_ST(ut_setup, ut_teardown,
12787 test_zuc_encryption_test_case_5),
12789 /** ZUC authenticate (EIA3) */
12790 TEST_CASE_ST(ut_setup, ut_teardown,
12791 test_zuc_hash_generate_test_case_6),
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_zuc_hash_generate_test_case_7),
12794 TEST_CASE_ST(ut_setup, ut_teardown,
12795 test_zuc_hash_generate_test_case_8),
12797 /** HMAC_MD5 Authentication */
12798 TEST_CASE_ST(ut_setup, ut_teardown,
12799 test_MD5_HMAC_generate_case_1),
12800 TEST_CASE_ST(ut_setup, ut_teardown,
12801 test_MD5_HMAC_verify_case_1),
12802 TEST_CASE_ST(ut_setup, ut_teardown,
12803 test_MD5_HMAC_generate_case_2),
12804 TEST_CASE_ST(ut_setup, ut_teardown,
12805 test_MD5_HMAC_verify_case_2),
12807 /** Negative tests */
12808 TEST_CASE_ST(ut_setup, ut_teardown,
12809 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12810 TEST_CASE_ST(ut_setup, ut_teardown,
12811 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12812 TEST_CASE_ST(ut_setup, ut_teardown,
12813 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12814 TEST_CASE_ST(ut_setup, ut_teardown,
12815 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12816 TEST_CASE_ST(ut_setup, ut_teardown,
12817 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12820 TEST_CASE_ST(ut_setup, ut_teardown,
12821 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12822 TEST_CASE_ST(ut_setup, ut_teardown,
12823 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12824 TEST_CASE_ST(ut_setup, ut_teardown,
12825 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12826 TEST_CASE_ST(ut_setup, ut_teardown,
12827 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12828 TEST_CASE_ST(ut_setup, ut_teardown,
12829 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12830 TEST_CASE_ST(ut_setup, ut_teardown,
12831 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12832 TEST_CASE_ST(ut_setup, ut_teardown,
12833 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12834 TEST_CASE_ST(ut_setup, ut_teardown,
12835 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12836 TEST_CASE_ST(ut_setup, ut_teardown,
12837 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12838 TEST_CASE_ST(ut_setup, ut_teardown,
12839 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12845 TEST_CASE_ST(ut_setup, ut_teardown,
12846 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12848 TEST_CASES_END() /**< NULL terminate unit test array */
12852 static struct unit_test_suite cryptodev_armv8_testsuite = {
12853 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12854 .setup = testsuite_setup,
12855 .teardown = testsuite_teardown,
12856 .unit_test_cases = {
12857 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12859 /** Negative tests */
12860 TEST_CASE_ST(ut_setup, ut_teardown,
12861 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12862 TEST_CASE_ST(ut_setup, ut_teardown,
12863 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12865 TEST_CASES_END() /**< NULL terminate unit test array */
12869 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12870 .suite_name = "Crypto Device Marvell Component Test Suite",
12871 .setup = testsuite_setup,
12872 .teardown = testsuite_teardown,
12873 .unit_test_cases = {
12874 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_multi_session_random_usage),
12877 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12878 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12879 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12880 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12881 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12883 /** Negative tests */
12884 TEST_CASE_ST(ut_setup, ut_teardown,
12885 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12886 TEST_CASE_ST(ut_setup, ut_teardown,
12887 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12888 TEST_CASE_ST(ut_setup, ut_teardown,
12889 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12893 TEST_CASES_END() /**< NULL terminate unit test array */
12897 static struct unit_test_suite cryptodev_ccp_testsuite = {
12898 .suite_name = "Crypto Device CCP Unit Test Suite",
12899 .setup = testsuite_setup,
12900 .teardown = testsuite_teardown,
12901 .unit_test_cases = {
12902 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12903 TEST_CASE_ST(ut_setup, ut_teardown,
12904 test_multi_session_random_usage),
12905 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12906 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12907 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12908 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12909 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12911 /** Negative tests */
12912 TEST_CASE_ST(ut_setup, ut_teardown,
12913 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12914 TEST_CASE_ST(ut_setup, ut_teardown,
12915 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12916 TEST_CASE_ST(ut_setup, ut_teardown,
12917 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12921 TEST_CASES_END() /**< NULL terminate unit test array */
12925 static struct unit_test_suite cryptodev_octeontx_testsuite = {
12926 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
12927 .setup = testsuite_setup,
12928 .teardown = testsuite_teardown,
12929 .unit_test_cases = {
12930 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12931 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12932 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12933 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12934 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12936 /** AES GCM Authenticated Encryption */
12937 TEST_CASE_ST(ut_setup, ut_teardown,
12938 test_AES_GCM_authenticated_encryption_test_case_1),
12939 TEST_CASE_ST(ut_setup, ut_teardown,
12940 test_AES_GCM_authenticated_encryption_test_case_2),
12941 TEST_CASE_ST(ut_setup, ut_teardown,
12942 test_AES_GCM_authenticated_encryption_test_case_3),
12943 TEST_CASE_ST(ut_setup, ut_teardown,
12944 test_AES_GCM_authenticated_encryption_test_case_4),
12945 TEST_CASE_ST(ut_setup, ut_teardown,
12946 test_AES_GCM_authenticated_encryption_test_case_5),
12947 TEST_CASE_ST(ut_setup, ut_teardown,
12948 test_AES_GCM_authenticated_encryption_test_case_6),
12949 TEST_CASE_ST(ut_setup, ut_teardown,
12950 test_AES_GCM_authenticated_encryption_test_case_7),
12952 /** AES GCM Authenticated Decryption */
12953 TEST_CASE_ST(ut_setup, ut_teardown,
12954 test_AES_GCM_authenticated_decryption_test_case_1),
12955 TEST_CASE_ST(ut_setup, ut_teardown,
12956 test_AES_GCM_authenticated_decryption_test_case_2),
12957 TEST_CASE_ST(ut_setup, ut_teardown,
12958 test_AES_GCM_authenticated_decryption_test_case_3),
12959 TEST_CASE_ST(ut_setup, ut_teardown,
12960 test_AES_GCM_authenticated_decryption_test_case_4),
12961 TEST_CASE_ST(ut_setup, ut_teardown,
12962 test_AES_GCM_authenticated_decryption_test_case_5),
12963 TEST_CASE_ST(ut_setup, ut_teardown,
12964 test_AES_GCM_authenticated_decryption_test_case_6),
12965 TEST_CASE_ST(ut_setup, ut_teardown,
12966 test_AES_GCM_authenticated_decryption_test_case_7),
12967 /** AES GMAC Authentication */
12968 TEST_CASE_ST(ut_setup, ut_teardown,
12969 test_AES_GMAC_authentication_test_case_1),
12970 TEST_CASE_ST(ut_setup, ut_teardown,
12971 test_AES_GMAC_authentication_verify_test_case_1),
12972 TEST_CASE_ST(ut_setup, ut_teardown,
12973 test_AES_GMAC_authentication_test_case_2),
12974 TEST_CASE_ST(ut_setup, ut_teardown,
12975 test_AES_GMAC_authentication_verify_test_case_2),
12976 TEST_CASE_ST(ut_setup, ut_teardown,
12977 test_AES_GMAC_authentication_test_case_3),
12978 TEST_CASE_ST(ut_setup, ut_teardown,
12979 test_AES_GMAC_authentication_verify_test_case_3),
12981 /** SNOW 3G encrypt only (UEA2) */
12982 TEST_CASE_ST(ut_setup, ut_teardown,
12983 test_snow3g_encryption_test_case_1),
12984 TEST_CASE_ST(ut_setup, ut_teardown,
12985 test_snow3g_encryption_test_case_2),
12986 TEST_CASE_ST(ut_setup, ut_teardown,
12987 test_snow3g_encryption_test_case_3),
12988 TEST_CASE_ST(ut_setup, ut_teardown,
12989 test_snow3g_encryption_test_case_4),
12990 TEST_CASE_ST(ut_setup, ut_teardown,
12991 test_snow3g_encryption_test_case_5),
12993 TEST_CASE_ST(ut_setup, ut_teardown,
12994 test_snow3g_encryption_test_case_1_oop),
12995 TEST_CASE_ST(ut_setup, ut_teardown,
12996 test_snow3g_decryption_test_case_1_oop),
12997 TEST_CASE_ST(ut_setup, ut_teardown,
12998 test_snow3g_encryption_test_case_1_oop_sgl),
13000 /** SNOW 3G decrypt only (UEA2) */
13001 TEST_CASE_ST(ut_setup, ut_teardown,
13002 test_snow3g_decryption_test_case_1),
13003 TEST_CASE_ST(ut_setup, ut_teardown,
13004 test_snow3g_decryption_test_case_2),
13005 TEST_CASE_ST(ut_setup, ut_teardown,
13006 test_snow3g_decryption_test_case_3),
13007 TEST_CASE_ST(ut_setup, ut_teardown,
13008 test_snow3g_decryption_test_case_4),
13009 TEST_CASE_ST(ut_setup, ut_teardown,
13010 test_snow3g_decryption_test_case_5),
13012 TEST_CASE_ST(ut_setup, ut_teardown,
13013 test_snow3g_hash_generate_test_case_1),
13014 TEST_CASE_ST(ut_setup, ut_teardown,
13015 test_snow3g_hash_generate_test_case_2),
13016 TEST_CASE_ST(ut_setup, ut_teardown,
13017 test_snow3g_hash_generate_test_case_3),
13018 TEST_CASE_ST(ut_setup, ut_teardown,
13019 test_snow3g_hash_verify_test_case_1),
13020 TEST_CASE_ST(ut_setup, ut_teardown,
13021 test_snow3g_hash_verify_test_case_2),
13022 TEST_CASE_ST(ut_setup, ut_teardown,
13023 test_snow3g_hash_verify_test_case_3),
13025 /** ZUC encrypt only (EEA3) */
13026 TEST_CASE_ST(ut_setup, ut_teardown,
13027 test_zuc_encryption_test_case_1),
13028 TEST_CASE_ST(ut_setup, ut_teardown,
13029 test_zuc_encryption_test_case_2),
13030 TEST_CASE_ST(ut_setup, ut_teardown,
13031 test_zuc_encryption_test_case_3),
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 test_zuc_encryption_test_case_4),
13034 TEST_CASE_ST(ut_setup, ut_teardown,
13035 test_zuc_encryption_test_case_5),
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_zuc_hash_generate_test_case_1),
13038 TEST_CASE_ST(ut_setup, ut_teardown,
13039 test_zuc_hash_generate_test_case_2),
13040 TEST_CASE_ST(ut_setup, ut_teardown,
13041 test_zuc_hash_generate_test_case_3),
13042 TEST_CASE_ST(ut_setup, ut_teardown,
13043 test_zuc_hash_generate_test_case_4),
13044 TEST_CASE_ST(ut_setup, ut_teardown,
13045 test_zuc_hash_generate_test_case_5),
13046 TEST_CASE_ST(ut_setup, ut_teardown,
13047 test_zuc_encryption_test_case_6_sgl),
13049 /** KASUMI encrypt only (UEA1) */
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_kasumi_encryption_test_case_1),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_kasumi_encryption_test_case_2),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_kasumi_encryption_test_case_3),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_kasumi_encryption_test_case_4),
13058 TEST_CASE_ST(ut_setup, ut_teardown,
13059 test_kasumi_encryption_test_case_5),
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_kasumi_encryption_test_case_1_sgl),
13062 TEST_CASE_ST(ut_setup, ut_teardown,
13063 test_kasumi_encryption_test_case_1_oop_sgl),
13064 /** KASUMI decrypt only (UEA1) */
13065 TEST_CASE_ST(ut_setup, ut_teardown,
13066 test_kasumi_decryption_test_case_1),
13067 TEST_CASE_ST(ut_setup, ut_teardown,
13068 test_kasumi_decryption_test_case_2),
13069 TEST_CASE_ST(ut_setup, ut_teardown,
13070 test_kasumi_decryption_test_case_3),
13071 TEST_CASE_ST(ut_setup, ut_teardown,
13072 test_kasumi_decryption_test_case_4),
13073 TEST_CASE_ST(ut_setup, ut_teardown,
13074 test_kasumi_decryption_test_case_5),
13076 TEST_CASE_ST(ut_setup, ut_teardown,
13077 test_kasumi_encryption_test_case_1_oop),
13078 TEST_CASE_ST(ut_setup, ut_teardown,
13079 test_kasumi_decryption_test_case_1_oop),
13081 /** KASUMI hash only (UIA1) */
13082 TEST_CASE_ST(ut_setup, ut_teardown,
13083 test_kasumi_hash_generate_test_case_1),
13084 TEST_CASE_ST(ut_setup, ut_teardown,
13085 test_kasumi_hash_generate_test_case_2),
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 test_kasumi_hash_generate_test_case_3),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_kasumi_hash_generate_test_case_4),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_kasumi_hash_generate_test_case_5),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_kasumi_hash_generate_test_case_6),
13094 TEST_CASE_ST(ut_setup, ut_teardown,
13095 test_kasumi_hash_verify_test_case_1),
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_kasumi_hash_verify_test_case_2),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_kasumi_hash_verify_test_case_3),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_kasumi_hash_verify_test_case_4),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_kasumi_hash_verify_test_case_5),
13106 TEST_CASE_ST(ut_setup, ut_teardown,
13107 test_null_cipher_only_operation),
13108 TEST_CASE_ST(ut_setup, ut_teardown,
13109 test_null_auth_only_operation),
13110 TEST_CASE_ST(ut_setup, ut_teardown,
13111 test_null_cipher_auth_operation),
13112 TEST_CASE_ST(ut_setup, ut_teardown,
13113 test_null_auth_cipher_operation),
13115 /** Negative tests */
13116 TEST_CASE_ST(ut_setup, ut_teardown,
13117 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13118 TEST_CASE_ST(ut_setup, ut_teardown,
13119 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13120 TEST_CASE_ST(ut_setup, ut_teardown,
13121 authentication_verify_AES128_GMAC_fail_data_corrupt),
13122 TEST_CASE_ST(ut_setup, ut_teardown,
13123 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13124 TEST_CASE_ST(ut_setup, ut_teardown,
13125 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13126 TEST_CASE_ST(ut_setup, ut_teardown,
13127 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13128 TEST_CASES_END() /**< NULL terminate unit test array */
13132 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13133 .suite_name = "Crypto NITROX Unit Test Suite",
13134 .setup = testsuite_setup,
13135 .teardown = testsuite_teardown,
13136 .unit_test_cases = {
13137 TEST_CASE_ST(ut_setup, ut_teardown,
13138 test_device_configure_invalid_dev_id),
13139 TEST_CASE_ST(ut_setup, ut_teardown,
13140 test_device_configure_invalid_queue_pair_ids),
13141 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13142 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13144 TEST_CASES_END() /**< NULL terminate unit test array */
13148 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13149 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13150 .setup = testsuite_setup,
13151 .teardown = testsuite_teardown,
13152 .unit_test_cases = {
13153 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13154 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13155 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13156 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13157 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13159 /** AES GCM Authenticated Encryption */
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_AES_GCM_authenticated_encryption_test_case_1),
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_AES_GCM_authenticated_encryption_test_case_2),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_AES_GCM_authenticated_encryption_test_case_3),
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_AES_GCM_authenticated_encryption_test_case_4),
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_AES_GCM_authenticated_encryption_test_case_5),
13170 TEST_CASE_ST(ut_setup, ut_teardown,
13171 test_AES_GCM_authenticated_encryption_test_case_6),
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_AES_GCM_authenticated_encryption_test_case_7),
13175 /** AES GCM Authenticated Decryption */
13176 TEST_CASE_ST(ut_setup, ut_teardown,
13177 test_AES_GCM_authenticated_decryption_test_case_1),
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 test_AES_GCM_authenticated_decryption_test_case_2),
13180 TEST_CASE_ST(ut_setup, ut_teardown,
13181 test_AES_GCM_authenticated_decryption_test_case_3),
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 test_AES_GCM_authenticated_decryption_test_case_4),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 test_AES_GCM_authenticated_decryption_test_case_5),
13186 TEST_CASE_ST(ut_setup, ut_teardown,
13187 test_AES_GCM_authenticated_decryption_test_case_6),
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 test_AES_GCM_authenticated_decryption_test_case_7),
13190 /** AES GMAC Authentication */
13191 TEST_CASE_ST(ut_setup, ut_teardown,
13192 test_AES_GMAC_authentication_test_case_1),
13193 TEST_CASE_ST(ut_setup, ut_teardown,
13194 test_AES_GMAC_authentication_verify_test_case_1),
13195 TEST_CASE_ST(ut_setup, ut_teardown,
13196 test_AES_GMAC_authentication_test_case_2),
13197 TEST_CASE_ST(ut_setup, ut_teardown,
13198 test_AES_GMAC_authentication_verify_test_case_2),
13199 TEST_CASE_ST(ut_setup, ut_teardown,
13200 test_AES_GMAC_authentication_test_case_3),
13201 TEST_CASE_ST(ut_setup, ut_teardown,
13202 test_AES_GMAC_authentication_verify_test_case_3),
13204 /** SNOW 3G encrypt only (UEA2) */
13205 TEST_CASE_ST(ut_setup, ut_teardown,
13206 test_snow3g_encryption_test_case_1),
13207 TEST_CASE_ST(ut_setup, ut_teardown,
13208 test_snow3g_encryption_test_case_2),
13209 TEST_CASE_ST(ut_setup, ut_teardown,
13210 test_snow3g_encryption_test_case_3),
13211 TEST_CASE_ST(ut_setup, ut_teardown,
13212 test_snow3g_encryption_test_case_4),
13213 TEST_CASE_ST(ut_setup, ut_teardown,
13214 test_snow3g_encryption_test_case_5),
13216 TEST_CASE_ST(ut_setup, ut_teardown,
13217 test_snow3g_encryption_test_case_1_oop),
13218 TEST_CASE_ST(ut_setup, ut_teardown,
13219 test_snow3g_decryption_test_case_1_oop),
13220 TEST_CASE_ST(ut_setup, ut_teardown,
13221 test_snow3g_encryption_test_case_1_oop_sgl),
13223 /** SNOW 3G decrypt only (UEA2) */
13224 TEST_CASE_ST(ut_setup, ut_teardown,
13225 test_snow3g_decryption_test_case_1),
13226 TEST_CASE_ST(ut_setup, ut_teardown,
13227 test_snow3g_decryption_test_case_2),
13228 TEST_CASE_ST(ut_setup, ut_teardown,
13229 test_snow3g_decryption_test_case_3),
13230 TEST_CASE_ST(ut_setup, ut_teardown,
13231 test_snow3g_decryption_test_case_4),
13232 TEST_CASE_ST(ut_setup, ut_teardown,
13233 test_snow3g_decryption_test_case_5),
13235 TEST_CASE_ST(ut_setup, ut_teardown,
13236 test_snow3g_hash_generate_test_case_1),
13237 TEST_CASE_ST(ut_setup, ut_teardown,
13238 test_snow3g_hash_generate_test_case_2),
13239 TEST_CASE_ST(ut_setup, ut_teardown,
13240 test_snow3g_hash_generate_test_case_3),
13241 TEST_CASE_ST(ut_setup, ut_teardown,
13242 test_snow3g_hash_verify_test_case_1),
13243 TEST_CASE_ST(ut_setup, ut_teardown,
13244 test_snow3g_hash_verify_test_case_2),
13245 TEST_CASE_ST(ut_setup, ut_teardown,
13246 test_snow3g_hash_verify_test_case_3),
13248 /** ZUC encrypt only (EEA3) */
13249 TEST_CASE_ST(ut_setup, ut_teardown,
13250 test_zuc_encryption_test_case_1),
13251 TEST_CASE_ST(ut_setup, ut_teardown,
13252 test_zuc_encryption_test_case_2),
13253 TEST_CASE_ST(ut_setup, ut_teardown,
13254 test_zuc_encryption_test_case_3),
13255 TEST_CASE_ST(ut_setup, ut_teardown,
13256 test_zuc_encryption_test_case_4),
13257 TEST_CASE_ST(ut_setup, ut_teardown,
13258 test_zuc_encryption_test_case_5),
13259 TEST_CASE_ST(ut_setup, ut_teardown,
13260 test_zuc_hash_generate_test_case_1),
13261 TEST_CASE_ST(ut_setup, ut_teardown,
13262 test_zuc_hash_generate_test_case_2),
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_zuc_hash_generate_test_case_3),
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_zuc_hash_generate_test_case_4),
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_zuc_hash_generate_test_case_5),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_zuc_encryption_test_case_6_sgl),
13272 /** KASUMI encrypt only (UEA1) */
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_kasumi_encryption_test_case_1),
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_kasumi_encryption_test_case_2),
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_kasumi_encryption_test_case_3),
13279 TEST_CASE_ST(ut_setup, ut_teardown,
13280 test_kasumi_encryption_test_case_4),
13281 TEST_CASE_ST(ut_setup, ut_teardown,
13282 test_kasumi_encryption_test_case_5),
13283 TEST_CASE_ST(ut_setup, ut_teardown,
13284 test_kasumi_encryption_test_case_1_sgl),
13285 TEST_CASE_ST(ut_setup, ut_teardown,
13286 test_kasumi_encryption_test_case_1_oop_sgl),
13287 /** KASUMI decrypt only (UEA1) */
13288 TEST_CASE_ST(ut_setup, ut_teardown,
13289 test_kasumi_decryption_test_case_1),
13290 TEST_CASE_ST(ut_setup, ut_teardown,
13291 test_kasumi_decryption_test_case_2),
13292 TEST_CASE_ST(ut_setup, ut_teardown,
13293 test_kasumi_decryption_test_case_3),
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_kasumi_decryption_test_case_4),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_kasumi_decryption_test_case_5),
13299 TEST_CASE_ST(ut_setup, ut_teardown,
13300 test_kasumi_encryption_test_case_1_oop),
13301 TEST_CASE_ST(ut_setup, ut_teardown,
13302 test_kasumi_decryption_test_case_1_oop),
13304 /** KASUMI hash only (UIA1) */
13305 TEST_CASE_ST(ut_setup, ut_teardown,
13306 test_kasumi_hash_generate_test_case_1),
13307 TEST_CASE_ST(ut_setup, ut_teardown,
13308 test_kasumi_hash_generate_test_case_2),
13309 TEST_CASE_ST(ut_setup, ut_teardown,
13310 test_kasumi_hash_generate_test_case_3),
13311 TEST_CASE_ST(ut_setup, ut_teardown,
13312 test_kasumi_hash_generate_test_case_4),
13313 TEST_CASE_ST(ut_setup, ut_teardown,
13314 test_kasumi_hash_generate_test_case_5),
13315 TEST_CASE_ST(ut_setup, ut_teardown,
13316 test_kasumi_hash_generate_test_case_6),
13317 TEST_CASE_ST(ut_setup, ut_teardown,
13318 test_kasumi_hash_verify_test_case_1),
13319 TEST_CASE_ST(ut_setup, ut_teardown,
13320 test_kasumi_hash_verify_test_case_2),
13321 TEST_CASE_ST(ut_setup, ut_teardown,
13322 test_kasumi_hash_verify_test_case_3),
13323 TEST_CASE_ST(ut_setup, ut_teardown,
13324 test_kasumi_hash_verify_test_case_4),
13325 TEST_CASE_ST(ut_setup, ut_teardown,
13326 test_kasumi_hash_verify_test_case_5),
13329 TEST_CASE_ST(ut_setup, ut_teardown,
13330 test_null_cipher_only_operation),
13331 TEST_CASE_ST(ut_setup, ut_teardown,
13332 test_null_auth_only_operation),
13333 TEST_CASE_ST(ut_setup, ut_teardown,
13334 test_null_cipher_auth_operation),
13335 TEST_CASE_ST(ut_setup, ut_teardown,
13336 test_null_auth_cipher_operation),
13338 /** Negative tests */
13339 TEST_CASE_ST(ut_setup, ut_teardown,
13340 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13341 TEST_CASE_ST(ut_setup, ut_teardown,
13342 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13343 TEST_CASE_ST(ut_setup, ut_teardown,
13344 authentication_verify_AES128_GMAC_fail_data_corrupt),
13345 TEST_CASE_ST(ut_setup, ut_teardown,
13346 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13347 TEST_CASE_ST(ut_setup, ut_teardown,
13348 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13349 TEST_CASE_ST(ut_setup, ut_teardown,
13350 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13351 TEST_CASES_END() /**< NULL terminate unit test array */
13356 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13358 gbl_driver_id = rte_cryptodev_driver_id_get(
13359 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13361 if (gbl_driver_id == -1) {
13362 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13363 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13364 "are enabled in config file to run this testsuite.\n");
13365 return TEST_SKIPPED;
13368 return unit_test_suite_runner(&cryptodev_testsuite);
13372 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13374 gbl_driver_id = rte_cryptodev_driver_id_get(
13375 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13377 if (gbl_driver_id == -1) {
13378 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13379 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13380 "in config file to run this testsuite.\n");
13381 return TEST_FAILED;
13384 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13388 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13390 gbl_driver_id = rte_cryptodev_driver_id_get(
13391 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13393 if (gbl_driver_id == -1) {
13394 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13395 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13396 "in config file to run this testsuite.\n");
13397 return TEST_SKIPPED;
13400 return unit_test_suite_runner(&cryptodev_testsuite);
13404 test_cryptodev_openssl(void)
13406 gbl_driver_id = rte_cryptodev_driver_id_get(
13407 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13409 if (gbl_driver_id == -1) {
13410 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13411 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13412 "in config file to run this testsuite.\n");
13413 return TEST_SKIPPED;
13416 return unit_test_suite_runner(&cryptodev_testsuite);
13420 test_cryptodev_aesni_gcm(void)
13422 gbl_driver_id = rte_cryptodev_driver_id_get(
13423 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13425 if (gbl_driver_id == -1) {
13426 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13427 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13428 "in config file to run this testsuite.\n");
13429 return TEST_SKIPPED;
13432 return unit_test_suite_runner(&cryptodev_testsuite);
13436 test_cryptodev_cpu_aesni_gcm(void)
13439 enum rte_security_session_action_type at;
13441 gbl_driver_id = rte_cryptodev_driver_id_get(
13442 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13444 if (gbl_driver_id == -1) {
13445 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13446 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13447 "in config file to run this testsuite.\n");
13448 return TEST_SKIPPED;
13451 at = gbl_action_type;
13452 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13453 rc = unit_test_suite_runner(&cryptodev_testsuite);
13454 gbl_action_type = at;
13459 test_cryptodev_null(void)
13461 gbl_driver_id = rte_cryptodev_driver_id_get(
13462 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13464 if (gbl_driver_id == -1) {
13465 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13466 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13467 "in config file to run this testsuite.\n");
13468 return TEST_SKIPPED;
13471 return unit_test_suite_runner(&cryptodev_testsuite);
13475 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13477 gbl_driver_id = rte_cryptodev_driver_id_get(
13478 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13480 if (gbl_driver_id == -1) {
13481 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13482 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13483 "in config file to run this testsuite.\n");
13484 return TEST_SKIPPED;
13487 return unit_test_suite_runner(&cryptodev_testsuite);
13491 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13493 gbl_driver_id = rte_cryptodev_driver_id_get(
13494 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13496 if (gbl_driver_id == -1) {
13497 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13498 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13499 "in config file to run this testsuite.\n");
13500 return TEST_SKIPPED;
13503 return unit_test_suite_runner(&cryptodev_testsuite);
13507 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13509 gbl_driver_id = rte_cryptodev_driver_id_get(
13510 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13512 if (gbl_driver_id == -1) {
13513 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13514 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13515 "in config file to run this testsuite.\n");
13516 return TEST_SKIPPED;
13519 return unit_test_suite_runner(&cryptodev_testsuite);
13523 test_cryptodev_armv8(void)
13525 gbl_driver_id = rte_cryptodev_driver_id_get(
13526 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13528 if (gbl_driver_id == -1) {
13529 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13530 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13531 "in config file to run this testsuite.\n");
13532 return TEST_SKIPPED;
13535 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13539 test_cryptodev_mrvl(void)
13541 gbl_driver_id = rte_cryptodev_driver_id_get(
13542 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13544 if (gbl_driver_id == -1) {
13545 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13546 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13547 "in config file to run this testsuite.\n");
13548 return TEST_SKIPPED;
13551 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13554 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13557 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13559 gbl_driver_id = rte_cryptodev_driver_id_get(
13560 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13562 if (gbl_driver_id == -1) {
13563 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13564 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13565 "in config file to run this testsuite.\n");
13566 return TEST_SKIPPED;
13569 if (rte_cryptodev_driver_id_get(
13570 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13571 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13572 " enabled in config file to run this testsuite.\n");
13573 return TEST_SKIPPED;
13575 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13578 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13583 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13585 gbl_driver_id = rte_cryptodev_driver_id_get(
13586 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13588 if (gbl_driver_id == -1) {
13589 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13590 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13591 "in config file to run this testsuite.\n");
13592 return TEST_SKIPPED;
13595 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13599 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13601 gbl_driver_id = rte_cryptodev_driver_id_get(
13602 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13604 if (gbl_driver_id == -1) {
13605 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13606 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13607 "in config file to run this testsuite.\n");
13608 return TEST_SKIPPED;
13611 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13615 test_cryptodev_ccp(void)
13617 gbl_driver_id = rte_cryptodev_driver_id_get(
13618 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13620 if (gbl_driver_id == -1) {
13621 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13622 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13623 "in config file to run this testsuite.\n");
13624 return TEST_FAILED;
13627 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13631 test_cryptodev_octeontx(void)
13633 gbl_driver_id = rte_cryptodev_driver_id_get(
13634 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13635 if (gbl_driver_id == -1) {
13636 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13637 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13638 "enabled in config file to run this "
13640 return TEST_FAILED;
13642 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13646 test_cryptodev_octeontx2(void)
13648 gbl_driver_id = rte_cryptodev_driver_id_get(
13649 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13650 if (gbl_driver_id == -1) {
13651 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13652 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13653 "enabled in config file to run this "
13655 return TEST_FAILED;
13657 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13661 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13663 gbl_driver_id = rte_cryptodev_driver_id_get(
13664 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13666 if (gbl_driver_id == -1) {
13667 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13668 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13669 "in config file to run this testsuite.\n");
13670 return TEST_FAILED;
13673 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13677 test_cryptodev_nitrox(void)
13679 gbl_driver_id = rte_cryptodev_driver_id_get(
13680 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13682 if (gbl_driver_id == -1) {
13683 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13684 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13685 "in config file to run this testsuite.\n");
13686 return TEST_FAILED;
13689 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13692 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13693 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13694 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13695 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13696 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13697 test_cryptodev_cpu_aesni_gcm);
13698 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13699 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13700 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13701 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13702 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13703 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13704 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13705 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13706 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13707 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13708 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13709 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13710 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13711 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);