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>
14 #include <rte_ether.h>
16 #include <rte_crypto.h>
17 #include <rte_cryptodev.h>
18 #include <rte_cryptodev_pmd.h>
19 #include <rte_string_fns.h>
21 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
22 #include <rte_cryptodev_scheduler.h>
23 #include <rte_cryptodev_scheduler_operations.h>
26 #include <rte_lcore.h>
29 #include "test_cryptodev.h"
31 #include "test_cryptodev_blockcipher.h"
32 #include "test_cryptodev_aes_test_vectors.h"
33 #include "test_cryptodev_des_test_vectors.h"
34 #include "test_cryptodev_hash_test_vectors.h"
35 #include "test_cryptodev_kasumi_test_vectors.h"
36 #include "test_cryptodev_kasumi_hash_test_vectors.h"
37 #include "test_cryptodev_snow3g_test_vectors.h"
38 #include "test_cryptodev_snow3g_hash_test_vectors.h"
39 #include "test_cryptodev_zuc_test_vectors.h"
40 #include "test_cryptodev_aead_test_vectors.h"
41 #include "test_cryptodev_hmac_test_vectors.h"
42 #include "test_cryptodev_mixed_test_vectors.h"
43 #ifdef RTE_LIBRTE_SECURITY
44 #include "test_cryptodev_security_pdcp_test_vectors.h"
45 #include "test_cryptodev_security_pdcp_test_func.h"
46 #include "test_cryptodev_security_docsis_test_vectors.h"
49 #define VDEV_ARGS_SIZE 100
50 #define MAX_NB_SESSIONS 4
53 #define OUT_OF_PLACE 1
55 static int gbl_driver_id;
57 static enum rte_security_session_action_type gbl_action_type =
58 RTE_SECURITY_ACTION_TYPE_NONE;
60 struct crypto_testsuite_params {
61 struct rte_mempool *mbuf_pool;
62 struct rte_mempool *large_mbuf_pool;
63 struct rte_mempool *op_mpool;
64 struct rte_mempool *session_mpool;
65 struct rte_mempool *session_priv_mpool;
66 struct rte_cryptodev_config conf;
67 struct rte_cryptodev_qp_conf qp_conf;
69 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
70 uint8_t valid_dev_count;
73 struct crypto_unittest_params {
74 struct rte_crypto_sym_xform cipher_xform;
75 struct rte_crypto_sym_xform auth_xform;
76 struct rte_crypto_sym_xform aead_xform;
77 #ifdef RTE_LIBRTE_SECURITY
78 struct rte_security_docsis_xform docsis_xform;
82 struct rte_cryptodev_sym_session *sess;
83 #ifdef RTE_LIBRTE_SECURITY
84 struct rte_security_session *sec_session;
87 #ifdef RTE_LIBRTE_SECURITY
88 enum rte_security_session_action_type type;
90 struct rte_crypto_op *op;
92 struct rte_mbuf *obuf, *ibuf;
97 #define ALIGN_POW2_ROUNDUP(num, align) \
98 (((num) + (align) - 1) & ~((align) - 1))
101 * Forward declarations.
104 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
105 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
109 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
110 struct crypto_unittest_params *ut_params,
111 struct crypto_testsuite_params *ts_param,
112 const uint8_t *cipher,
113 const uint8_t *digest,
116 static struct rte_mbuf *
117 setup_test_string(struct rte_mempool *mpool,
118 const char *string, size_t len, uint8_t blocksize)
120 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
121 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
123 memset(m->buf_addr, 0, m->buf_len);
125 char *dst = rte_pktmbuf_append(m, t_len);
132 rte_memcpy(dst, string, t_len);
134 memset(dst, 0, t_len);
140 /* Get number of bytes in X bits (rounding up) */
142 ceil_byte_length(uint32_t num_bits)
145 return ((num_bits >> 3) + 1);
147 return (num_bits >> 3);
151 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
155 struct rte_crypto_sym_op *sop;
156 union rte_crypto_sym_ofs ofs;
157 struct rte_crypto_sgl sgl;
158 struct rte_crypto_sym_vec symvec;
159 struct rte_crypto_vec vec[UINT8_MAX];
163 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
164 sop->aead.data.length, vec, RTE_DIM(vec));
166 if (n < 0 || n != sop->m_src->nb_segs) {
167 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
174 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
176 symvec.aad = (void **)&sop->aead.aad.data;
177 symvec.digest = (void **)&sop->aead.digest.data;
183 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
187 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
189 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
193 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
197 struct rte_crypto_sym_op *sop;
198 union rte_crypto_sym_ofs ofs;
199 struct rte_crypto_sgl sgl;
200 struct rte_crypto_sym_vec symvec;
201 struct rte_crypto_vec vec[UINT8_MAX];
205 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
206 sop->auth.data.length, vec, RTE_DIM(vec));
208 if (n < 0 || n != sop->m_src->nb_segs) {
209 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
216 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
218 symvec.aad = (void **)&sop->aead.aad.data;
219 symvec.digest = (void **)&sop->auth.digest.data;
224 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
225 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
226 (sop->cipher.data.offset + sop->cipher.data.length);
228 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
232 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
234 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
237 static struct rte_crypto_op *
238 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
241 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
243 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
244 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
250 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
253 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
254 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
261 static struct crypto_testsuite_params testsuite_params = { NULL };
262 static struct crypto_unittest_params unittest_params;
265 testsuite_setup(void)
267 struct crypto_testsuite_params *ts_params = &testsuite_params;
268 struct rte_cryptodev_info info;
269 uint32_t i = 0, nb_devs, dev_id;
273 memset(ts_params, 0, sizeof(*ts_params));
275 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
276 if (ts_params->mbuf_pool == NULL) {
277 /* Not already created so create */
278 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
280 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
282 if (ts_params->mbuf_pool == NULL) {
283 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
288 ts_params->large_mbuf_pool = rte_mempool_lookup(
289 "CRYPTO_LARGE_MBUFPOOL");
290 if (ts_params->large_mbuf_pool == NULL) {
291 /* Not already created so create */
292 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
293 "CRYPTO_LARGE_MBUFPOOL",
296 if (ts_params->large_mbuf_pool == NULL) {
298 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
303 ts_params->op_mpool = rte_crypto_op_pool_create(
304 "MBUF_CRYPTO_SYM_OP_POOL",
305 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
306 NUM_MBUFS, MBUF_CACHE_SIZE,
308 sizeof(struct rte_crypto_sym_xform) +
311 if (ts_params->op_mpool == NULL) {
312 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
316 /* Create an AESNI MB device if required */
317 if (gbl_driver_id == rte_cryptodev_driver_id_get(
318 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
319 nb_devs = rte_cryptodev_device_count_by_driver(
320 rte_cryptodev_driver_id_get(
321 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
324 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
326 TEST_ASSERT(ret == 0,
327 "Failed to create instance of"
329 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
333 /* Create an AESNI GCM device if required */
334 if (gbl_driver_id == rte_cryptodev_driver_id_get(
335 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
336 nb_devs = rte_cryptodev_device_count_by_driver(
337 rte_cryptodev_driver_id_get(
338 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
340 TEST_ASSERT_SUCCESS(rte_vdev_init(
341 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
342 "Failed to create instance of"
344 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
348 /* Create a SNOW 3G device if required */
349 if (gbl_driver_id == rte_cryptodev_driver_id_get(
350 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
351 nb_devs = rte_cryptodev_device_count_by_driver(
352 rte_cryptodev_driver_id_get(
353 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
355 TEST_ASSERT_SUCCESS(rte_vdev_init(
356 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
357 "Failed to create instance of"
359 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
363 /* Create a KASUMI device if required */
364 if (gbl_driver_id == rte_cryptodev_driver_id_get(
365 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
366 nb_devs = rte_cryptodev_device_count_by_driver(
367 rte_cryptodev_driver_id_get(
368 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
370 TEST_ASSERT_SUCCESS(rte_vdev_init(
371 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
372 "Failed to create instance of"
374 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
378 /* Create a ZUC device if required */
379 if (gbl_driver_id == rte_cryptodev_driver_id_get(
380 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
381 nb_devs = rte_cryptodev_device_count_by_driver(
382 rte_cryptodev_driver_id_get(
383 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
385 TEST_ASSERT_SUCCESS(rte_vdev_init(
386 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
387 "Failed to create instance of"
389 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
393 /* Create a NULL device if required */
394 if (gbl_driver_id == rte_cryptodev_driver_id_get(
395 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
396 nb_devs = rte_cryptodev_device_count_by_driver(
397 rte_cryptodev_driver_id_get(
398 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
401 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
403 TEST_ASSERT(ret == 0,
404 "Failed to create instance of"
406 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
410 /* Create an OPENSSL device if required */
411 if (gbl_driver_id == rte_cryptodev_driver_id_get(
412 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
413 nb_devs = rte_cryptodev_device_count_by_driver(
414 rte_cryptodev_driver_id_get(
415 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
418 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
421 TEST_ASSERT(ret == 0, "Failed to create "
422 "instance of pmd : %s",
423 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
427 /* Create a ARMv8 device if required */
428 if (gbl_driver_id == rte_cryptodev_driver_id_get(
429 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
430 nb_devs = rte_cryptodev_device_count_by_driver(
431 rte_cryptodev_driver_id_get(
432 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
435 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
438 TEST_ASSERT(ret == 0, "Failed to create "
439 "instance of pmd : %s",
440 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
444 /* Create a MVSAM device if required */
445 if (gbl_driver_id == rte_cryptodev_driver_id_get(
446 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
447 nb_devs = rte_cryptodev_device_count_by_driver(
448 rte_cryptodev_driver_id_get(
449 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
452 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
455 TEST_ASSERT(ret == 0, "Failed to create "
456 "instance of pmd : %s",
457 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
461 /* Create an CCP device if required */
462 if (gbl_driver_id == rte_cryptodev_driver_id_get(
463 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
464 nb_devs = rte_cryptodev_device_count_by_driver(
465 rte_cryptodev_driver_id_get(
466 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
469 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
472 TEST_ASSERT(ret == 0, "Failed to create "
473 "instance of pmd : %s",
474 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
478 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
479 char vdev_args[VDEV_ARGS_SIZE] = {""};
480 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
481 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
482 uint16_t slave_core_count = 0;
483 uint16_t socket_id = 0;
485 if (gbl_driver_id == rte_cryptodev_driver_id_get(
486 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
488 /* Identify the Slave Cores
489 * Use 2 slave cores for the device args
491 RTE_LCORE_FOREACH_SLAVE(i) {
492 if (slave_core_count > 1)
494 snprintf(vdev_args, sizeof(vdev_args),
495 "%s%d", temp_str, i);
496 strcpy(temp_str, vdev_args);
497 strlcat(temp_str, ";", sizeof(temp_str));
499 socket_id = rte_lcore_to_socket_id(i);
501 if (slave_core_count != 2) {
503 "Cryptodev scheduler test require at least "
504 "two slave cores to run. "
505 "Please use the correct coremask.\n");
508 strcpy(temp_str, vdev_args);
509 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
510 temp_str, socket_id);
511 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
512 nb_devs = rte_cryptodev_device_count_by_driver(
513 rte_cryptodev_driver_id_get(
514 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
517 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
519 TEST_ASSERT(ret == 0,
520 "Failed to create instance %u of"
522 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
525 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
527 nb_devs = rte_cryptodev_count();
529 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
533 /* Create list of valid crypto devs */
534 for (i = 0; i < nb_devs; i++) {
535 rte_cryptodev_info_get(i, &info);
536 if (info.driver_id == gbl_driver_id)
537 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
540 if (ts_params->valid_dev_count < 1)
543 /* Set up all the qps on the first of the valid devices found */
545 dev_id = ts_params->valid_devs[0];
547 rte_cryptodev_info_get(dev_id, &info);
549 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
550 ts_params->conf.socket_id = SOCKET_ID_ANY;
551 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
553 unsigned int session_size =
554 rte_cryptodev_sym_get_private_session_size(dev_id);
557 * Create mempool with maximum number of sessions * 2,
558 * to include the session headers
560 if (info.sym.max_nb_sessions != 0 &&
561 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
562 RTE_LOG(ERR, USER1, "Device does not support "
563 "at least %u sessions\n",
568 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
569 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
571 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
572 "session mempool allocation failed");
574 ts_params->session_priv_mpool = rte_mempool_create(
578 0, 0, NULL, NULL, NULL,
581 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
582 "session mempool allocation failed");
586 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
588 "Failed to configure cryptodev %u with %u qps",
589 dev_id, ts_params->conf.nb_queue_pairs);
591 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
592 ts_params->qp_conf.mp_session = ts_params->session_mpool;
593 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
595 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
596 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
597 dev_id, qp_id, &ts_params->qp_conf,
598 rte_cryptodev_socket_id(dev_id)),
599 "Failed to setup queue pair %u on cryptodev %u",
607 testsuite_teardown(void)
609 struct crypto_testsuite_params *ts_params = &testsuite_params;
611 if (ts_params->mbuf_pool != NULL) {
612 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
613 rte_mempool_avail_count(ts_params->mbuf_pool));
616 if (ts_params->op_mpool != NULL) {
617 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
618 rte_mempool_avail_count(ts_params->op_mpool));
621 /* Free session mempools */
622 if (ts_params->session_priv_mpool != NULL) {
623 rte_mempool_free(ts_params->session_priv_mpool);
624 ts_params->session_priv_mpool = NULL;
627 if (ts_params->session_mpool != NULL) {
628 rte_mempool_free(ts_params->session_mpool);
629 ts_params->session_mpool = NULL;
636 struct crypto_testsuite_params *ts_params = &testsuite_params;
637 struct crypto_unittest_params *ut_params = &unittest_params;
641 /* Clear unit test parameters before running test */
642 memset(ut_params, 0, sizeof(*ut_params));
644 /* Reconfigure device to default parameters */
645 ts_params->conf.socket_id = SOCKET_ID_ANY;
646 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
647 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
648 ts_params->qp_conf.mp_session = ts_params->session_mpool;
649 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
651 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
653 "Failed to configure cryptodev %u",
654 ts_params->valid_devs[0]);
656 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
657 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
658 ts_params->valid_devs[0], qp_id,
660 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
661 "Failed to setup queue pair %u on cryptodev %u",
662 qp_id, ts_params->valid_devs[0]);
666 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
668 /* Start the device */
669 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
670 "Failed to start cryptodev %u",
671 ts_params->valid_devs[0]);
679 struct crypto_testsuite_params *ts_params = &testsuite_params;
680 struct crypto_unittest_params *ut_params = &unittest_params;
681 struct rte_cryptodev_stats stats;
683 /* free crypto session structure */
684 #ifdef RTE_LIBRTE_SECURITY
685 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
686 if (ut_params->sec_session) {
687 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
688 (ts_params->valid_devs[0]),
689 ut_params->sec_session);
690 ut_params->sec_session = NULL;
695 if (ut_params->sess) {
696 rte_cryptodev_sym_session_clear(
697 ts_params->valid_devs[0],
699 rte_cryptodev_sym_session_free(ut_params->sess);
700 ut_params->sess = NULL;
704 /* free crypto operation structure */
706 rte_crypto_op_free(ut_params->op);
709 * free mbuf - both obuf and ibuf are usually the same,
710 * so check if they point at the same address is necessary,
711 * to avoid freeing the mbuf twice.
713 if (ut_params->obuf) {
714 rte_pktmbuf_free(ut_params->obuf);
715 if (ut_params->ibuf == ut_params->obuf)
719 if (ut_params->ibuf) {
720 rte_pktmbuf_free(ut_params->ibuf);
724 if (ts_params->mbuf_pool != NULL)
725 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
726 rte_mempool_avail_count(ts_params->mbuf_pool));
728 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
730 /* Stop the device */
731 rte_cryptodev_stop(ts_params->valid_devs[0]);
735 test_device_configure_invalid_dev_id(void)
737 struct crypto_testsuite_params *ts_params = &testsuite_params;
738 uint16_t dev_id, num_devs = 0;
740 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
741 "Need at least %d devices for test", 1);
743 /* valid dev_id values */
744 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
746 /* Stop the device in case it's started so it can be configured */
747 rte_cryptodev_stop(dev_id);
749 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
750 "Failed test for rte_cryptodev_configure: "
751 "invalid dev_num %u", dev_id);
753 /* invalid dev_id values */
756 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
757 "Failed test for rte_cryptodev_configure: "
758 "invalid dev_num %u", dev_id);
762 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
763 "Failed test for rte_cryptodev_configure:"
764 "invalid dev_num %u", dev_id);
770 test_device_configure_invalid_queue_pair_ids(void)
772 struct crypto_testsuite_params *ts_params = &testsuite_params;
773 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
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 - max value queue pairs */
779 ts_params->conf.nb_queue_pairs = orig_nb_qps;
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);
786 /* valid - one queue pairs */
787 ts_params->conf.nb_queue_pairs = 1;
789 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
791 "Failed to configure cryptodev: dev_id %u, qp_id %u",
792 ts_params->valid_devs[0],
793 ts_params->conf.nb_queue_pairs);
796 /* invalid - zero queue pairs */
797 ts_params->conf.nb_queue_pairs = 0;
799 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
801 "Failed test for rte_cryptodev_configure, dev_id %u,"
803 ts_params->valid_devs[0],
804 ts_params->conf.nb_queue_pairs);
807 /* invalid - max value supported by field queue pairs */
808 ts_params->conf.nb_queue_pairs = UINT16_MAX;
810 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
812 "Failed test for rte_cryptodev_configure, dev_id %u,"
814 ts_params->valid_devs[0],
815 ts_params->conf.nb_queue_pairs);
818 /* invalid - max value + 1 queue pairs */
819 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
821 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
823 "Failed test for rte_cryptodev_configure, dev_id %u,"
825 ts_params->valid_devs[0],
826 ts_params->conf.nb_queue_pairs);
828 /* revert to original testsuite value */
829 ts_params->conf.nb_queue_pairs = orig_nb_qps;
835 test_queue_pair_descriptor_setup(void)
837 struct crypto_testsuite_params *ts_params = &testsuite_params;
838 struct rte_cryptodev_qp_conf qp_conf = {
839 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
843 /* Stop the device in case it's started so it can be configured */
844 rte_cryptodev_stop(ts_params->valid_devs[0]);
846 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
848 "Failed to configure cryptodev %u",
849 ts_params->valid_devs[0]);
852 * Test various ring sizes on this device. memzones can't be
853 * freed so are re-used if ring is released and re-created.
855 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
856 qp_conf.mp_session = ts_params->session_mpool;
857 qp_conf.mp_session_private = ts_params->session_priv_mpool;
859 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
860 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
861 ts_params->valid_devs[0], qp_id, &qp_conf,
862 rte_cryptodev_socket_id(
863 ts_params->valid_devs[0])),
865 "rte_cryptodev_queue_pair_setup: num_inflights "
866 "%u on qp %u on cryptodev %u",
867 qp_conf.nb_descriptors, qp_id,
868 ts_params->valid_devs[0]);
871 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
873 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
874 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
875 ts_params->valid_devs[0], qp_id, &qp_conf,
876 rte_cryptodev_socket_id(
877 ts_params->valid_devs[0])),
879 " rte_cryptodev_queue_pair_setup: num_inflights"
880 " %u on qp %u on cryptodev %u",
881 qp_conf.nb_descriptors, qp_id,
882 ts_params->valid_devs[0]);
885 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
887 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
888 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
889 ts_params->valid_devs[0], qp_id, &qp_conf,
890 rte_cryptodev_socket_id(
891 ts_params->valid_devs[0])),
893 "rte_cryptodev_queue_pair_setup: num_inflights"
894 " %u on qp %u on cryptodev %u",
895 qp_conf.nb_descriptors, qp_id,
896 ts_params->valid_devs[0]);
899 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
901 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
902 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
903 ts_params->valid_devs[0], qp_id, &qp_conf,
904 rte_cryptodev_socket_id(
905 ts_params->valid_devs[0])),
907 " rte_cryptodev_queue_pair_setup:"
908 "num_inflights %u on qp %u on cryptodev %u",
909 qp_conf.nb_descriptors, qp_id,
910 ts_params->valid_devs[0]);
913 /* test invalid queue pair id */
914 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
916 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
918 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
919 ts_params->valid_devs[0],
921 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
922 "Failed test for rte_cryptodev_queue_pair_setup:"
923 "invalid qp %u on cryptodev %u",
924 qp_id, ts_params->valid_devs[0]);
926 qp_id = 0xffff; /*invalid*/
928 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
929 ts_params->valid_devs[0],
931 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
932 "Failed test for rte_cryptodev_queue_pair_setup:"
933 "invalid qp %u on cryptodev %u",
934 qp_id, ts_params->valid_devs[0]);
939 /* ***** Plaintext data for tests ***** */
941 const char catch_22_quote_1[] =
942 "There was only one catch and that was Catch-22, which "
943 "specified that a concern for one's safety in the face of "
944 "dangers that were real and immediate was the process of a "
945 "rational mind. Orr was crazy and could be grounded. All he "
946 "had to do was ask; and as soon as he did, he would no longer "
947 "be crazy and would have to fly more missions. Orr would be "
948 "crazy to fly more missions and sane if he didn't, but if he "
949 "was sane he had to fly them. If he flew them he was crazy "
950 "and didn't have to; but if he didn't want to he was sane and "
951 "had to. Yossarian was moved very deeply by the absolute "
952 "simplicity of this clause of Catch-22 and let out a "
953 "respectful whistle. \"That's some catch, that Catch-22\", he "
954 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
956 const char catch_22_quote[] =
957 "What a lousy earth! He wondered how many people were "
958 "destitute that same night even in his own prosperous country, "
959 "how many homes were shanties, how many husbands were drunk "
960 "and wives socked, and how many children were bullied, abused, "
961 "or abandoned. How many families hungered for food they could "
962 "not afford to buy? How many hearts were broken? How many "
963 "suicides would take place that same night, how many people "
964 "would go insane? How many cockroaches and landlords would "
965 "triumph? How many winners were losers, successes failures, "
966 "and rich men poor men? How many wise guys were stupid? How "
967 "many happy endings were unhappy endings? How many honest men "
968 "were liars, brave men cowards, loyal men traitors, how many "
969 "sainted men were corrupt, how many people in positions of "
970 "trust had sold their souls to bodyguards, how many had never "
971 "had souls? How many straight-and-narrow paths were crooked "
972 "paths? How many best families were worst families and how "
973 "many good people were bad people? When you added them all up "
974 "and then subtracted, you might be left with only the children, "
975 "and perhaps with Albert Einstein and an old violinist or "
976 "sculptor somewhere.";
978 #define QUOTE_480_BYTES (480)
979 #define QUOTE_512_BYTES (512)
980 #define QUOTE_768_BYTES (768)
981 #define QUOTE_1024_BYTES (1024)
985 /* ***** SHA1 Hash Tests ***** */
987 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
989 static uint8_t hmac_sha1_key[] = {
990 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
991 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
992 0xDE, 0xF4, 0xDE, 0xAD };
994 /* ***** SHA224 Hash Tests ***** */
996 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
999 /* ***** AES-CBC Cipher Tests ***** */
1001 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1002 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1004 static uint8_t aes_cbc_key[] = {
1005 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1006 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1008 static uint8_t aes_cbc_iv[] = {
1009 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1010 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1013 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1015 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1016 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1017 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1018 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1019 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1020 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1021 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1022 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1023 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1024 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1025 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1026 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1027 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1028 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1029 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1030 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1031 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1032 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1033 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1034 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1035 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1036 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1037 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1038 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1039 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1040 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1041 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1042 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1043 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1044 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1045 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1046 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1047 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1048 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1049 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1050 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1051 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1052 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1053 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1054 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1055 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1056 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1057 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1058 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1059 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1060 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1061 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1062 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1063 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1064 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1065 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1066 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1067 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1068 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1069 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1070 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1071 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1072 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1073 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1074 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1075 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1076 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1077 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1078 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1079 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1082 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1083 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1084 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1085 0x18, 0x8c, 0x1d, 0x32
1089 /* Multisession Vector context Test */
1090 /*Begin Session 0 */
1091 static uint8_t ms_aes_cbc_key0[] = {
1092 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1093 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1096 static uint8_t ms_aes_cbc_iv0[] = {
1097 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1098 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1101 static const uint8_t ms_aes_cbc_cipher0[] = {
1102 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1103 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1104 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1105 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1106 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1107 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1108 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1109 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1110 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1111 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1112 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1113 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1114 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1115 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1116 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1117 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1118 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1119 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1120 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1121 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1122 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1123 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1124 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1125 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1126 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1127 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1128 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1129 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1130 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1131 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1132 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1133 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1134 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1135 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1136 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1137 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1138 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1139 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1140 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1141 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1142 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1143 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1144 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1145 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1146 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1147 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1148 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1149 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1150 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1151 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1152 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1153 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1154 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1155 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1156 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1157 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1158 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1159 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1160 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1161 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1162 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1163 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1164 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1165 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1169 static uint8_t ms_hmac_key0[] = {
1170 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1171 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1172 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1173 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1174 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1175 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1176 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1177 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1180 static const uint8_t ms_hmac_digest0[] = {
1181 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1182 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1183 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1184 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1185 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1186 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1187 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1188 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1192 /* Begin session 1 */
1194 static uint8_t ms_aes_cbc_key1[] = {
1195 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1196 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1199 static uint8_t ms_aes_cbc_iv1[] = {
1200 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1201 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1204 static const uint8_t ms_aes_cbc_cipher1[] = {
1205 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1206 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1207 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1208 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1209 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1210 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1211 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1212 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1213 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1214 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1215 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1216 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1217 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1218 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1219 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1220 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1221 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1222 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1223 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1224 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1225 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1226 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1227 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1228 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1229 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1230 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1231 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1232 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1233 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1234 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1235 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1236 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1237 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1238 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1239 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1240 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1241 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1242 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1243 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1244 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1245 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1246 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1247 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1248 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1249 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1250 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1251 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1252 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1253 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1254 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1255 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1256 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1257 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1258 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1259 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1260 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1261 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1262 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1263 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1264 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1265 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1266 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1267 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1268 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1272 static uint8_t ms_hmac_key1[] = {
1273 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1274 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1275 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1276 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1277 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1278 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1279 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1280 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1283 static const uint8_t ms_hmac_digest1[] = {
1284 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1285 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1286 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1287 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1288 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1289 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1290 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1291 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1294 /* Begin Session 2 */
1295 static uint8_t ms_aes_cbc_key2[] = {
1296 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1297 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1300 static uint8_t ms_aes_cbc_iv2[] = {
1301 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1302 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1305 static const uint8_t ms_aes_cbc_cipher2[] = {
1306 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1307 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1308 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1309 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1310 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1311 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1312 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1313 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1314 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1315 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1316 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1317 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1318 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1319 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1320 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1321 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1322 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1323 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1324 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1325 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1326 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1327 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1328 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1329 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1330 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1331 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1332 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1333 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1334 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1335 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1336 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1337 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1338 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1339 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1340 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1341 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1342 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1343 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1344 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1345 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1346 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1347 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1348 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1349 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1350 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1351 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1352 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1353 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1354 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1355 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1356 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1357 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1358 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1359 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1360 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1361 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1362 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1363 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1364 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1365 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1366 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1367 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1368 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1369 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1372 static uint8_t ms_hmac_key2[] = {
1373 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1374 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1375 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1376 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1377 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1378 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1379 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1380 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1383 static const uint8_t ms_hmac_digest2[] = {
1384 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1385 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1386 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1387 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1388 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1389 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1390 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1391 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1398 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1400 struct crypto_testsuite_params *ts_params = &testsuite_params;
1401 struct crypto_unittest_params *ut_params = &unittest_params;
1403 /* Verify the capabilities */
1404 struct rte_cryptodev_sym_capability_idx cap_idx;
1405 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1406 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1407 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1410 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1411 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1412 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1416 /* Generate test mbuf data and space for digest */
1417 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1418 catch_22_quote, QUOTE_512_BYTES, 0);
1420 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1421 DIGEST_BYTE_LENGTH_SHA1);
1422 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1424 /* Setup Cipher Parameters */
1425 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1426 ut_params->cipher_xform.next = &ut_params->auth_xform;
1428 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1429 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1430 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1431 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1432 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1433 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1435 /* Setup HMAC Parameters */
1436 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1438 ut_params->auth_xform.next = NULL;
1440 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1441 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1442 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1443 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1444 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1446 ut_params->sess = rte_cryptodev_sym_session_create(
1447 ts_params->session_mpool);
1449 /* Create crypto session*/
1450 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1451 ut_params->sess, &ut_params->cipher_xform,
1452 ts_params->session_priv_mpool);
1453 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1455 /* Generate crypto op data structure */
1456 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1457 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1458 TEST_ASSERT_NOT_NULL(ut_params->op,
1459 "Failed to allocate symmetric crypto operation struct");
1461 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1463 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1465 /* set crypto operation source mbuf */
1466 sym_op->m_src = ut_params->ibuf;
1468 /* Set crypto operation authentication parameters */
1469 sym_op->auth.digest.data = ut_params->digest;
1470 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1471 ut_params->ibuf, QUOTE_512_BYTES);
1473 sym_op->auth.data.offset = 0;
1474 sym_op->auth.data.length = QUOTE_512_BYTES;
1476 /* Copy IV at the end of the crypto operation */
1477 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1478 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1480 /* Set crypto operation cipher parameters */
1481 sym_op->cipher.data.offset = 0;
1482 sym_op->cipher.data.length = QUOTE_512_BYTES;
1484 /* Process crypto operation */
1485 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1486 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1489 TEST_ASSERT_NOT_NULL(
1490 process_crypto_request(ts_params->valid_devs[0],
1492 "failed to process sym crypto op");
1494 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1495 "crypto op processing failed");
1498 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1501 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1502 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1504 "ciphertext data not as expected");
1506 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1508 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1509 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1510 gbl_driver_id == rte_cryptodev_driver_id_get(
1511 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1512 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1513 DIGEST_BYTE_LENGTH_SHA1,
1514 "Generated digest data not as expected");
1516 return TEST_SUCCESS;
1519 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1521 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1523 static uint8_t hmac_sha512_key[] = {
1524 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1525 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1526 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1527 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1528 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1529 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1530 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1531 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1533 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1534 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1535 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1536 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1537 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1538 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1539 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1540 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1541 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1546 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1547 struct crypto_unittest_params *ut_params,
1548 uint8_t *cipher_key,
1552 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1553 struct crypto_unittest_params *ut_params,
1554 struct crypto_testsuite_params *ts_params,
1555 const uint8_t *cipher,
1556 const uint8_t *digest,
1561 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1562 struct crypto_unittest_params *ut_params,
1563 uint8_t *cipher_key,
1567 /* Setup Cipher Parameters */
1568 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1569 ut_params->cipher_xform.next = NULL;
1571 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1572 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1573 ut_params->cipher_xform.cipher.key.data = cipher_key;
1574 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1575 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1576 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1578 /* Setup HMAC Parameters */
1579 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1580 ut_params->auth_xform.next = &ut_params->cipher_xform;
1582 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1583 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1584 ut_params->auth_xform.auth.key.data = hmac_key;
1585 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1586 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1588 return TEST_SUCCESS;
1593 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1594 struct crypto_unittest_params *ut_params,
1595 struct crypto_testsuite_params *ts_params,
1596 const uint8_t *cipher,
1597 const uint8_t *digest,
1600 /* Generate test mbuf data and digest */
1601 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1604 QUOTE_512_BYTES, 0);
1606 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1607 DIGEST_BYTE_LENGTH_SHA512);
1608 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1610 rte_memcpy(ut_params->digest,
1612 DIGEST_BYTE_LENGTH_SHA512);
1614 /* Generate Crypto op data structure */
1615 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1616 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1617 TEST_ASSERT_NOT_NULL(ut_params->op,
1618 "Failed to allocate symmetric crypto operation struct");
1620 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1622 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1624 /* set crypto operation source mbuf */
1625 sym_op->m_src = ut_params->ibuf;
1627 sym_op->auth.digest.data = ut_params->digest;
1628 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1629 ut_params->ibuf, QUOTE_512_BYTES);
1631 sym_op->auth.data.offset = 0;
1632 sym_op->auth.data.length = QUOTE_512_BYTES;
1634 /* Copy IV at the end of the crypto operation */
1635 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1636 iv, CIPHER_IV_LENGTH_AES_CBC);
1638 sym_op->cipher.data.offset = 0;
1639 sym_op->cipher.data.length = QUOTE_512_BYTES;
1641 /* Process crypto operation */
1642 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1643 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1646 TEST_ASSERT_NOT_NULL(
1647 process_crypto_request(ts_params->valid_devs[0],
1649 "failed to process sym crypto op");
1651 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1652 "crypto op processing failed");
1654 ut_params->obuf = ut_params->op->sym->m_src;
1657 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1658 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1661 "Plaintext data not as expected");
1664 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1665 "Digest verification failed");
1667 return TEST_SUCCESS;
1671 test_blockcipher(enum blockcipher_test_type test_type)
1673 struct crypto_testsuite_params *ts_params = &testsuite_params;
1676 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1677 ts_params->op_mpool,
1678 ts_params->session_mpool, ts_params->session_priv_mpool,
1679 ts_params->valid_devs[0],
1682 if (status == -ENOTSUP)
1685 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1687 return TEST_SUCCESS;
1691 test_AES_cipheronly_all(void)
1693 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1697 test_AES_docsis_all(void)
1699 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1703 test_DES_docsis_all(void)
1705 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1709 test_DES_cipheronly_all(void)
1711 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1715 test_authonly_all(void)
1717 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1721 test_AES_chain_all(void)
1723 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1727 test_3DES_chain_all(void)
1729 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1733 test_3DES_cipheronly_all(void)
1735 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1738 /* ***** SNOW 3G Tests ***** */
1740 create_wireless_algo_hash_session(uint8_t dev_id,
1741 const uint8_t *key, const uint8_t key_len,
1742 const uint8_t iv_len, const uint8_t auth_len,
1743 enum rte_crypto_auth_operation op,
1744 enum rte_crypto_auth_algorithm algo)
1746 uint8_t hash_key[key_len];
1749 struct crypto_testsuite_params *ts_params = &testsuite_params;
1750 struct crypto_unittest_params *ut_params = &unittest_params;
1752 memcpy(hash_key, key, key_len);
1754 debug_hexdump(stdout, "key:", key, key_len);
1756 /* Setup Authentication Parameters */
1757 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1758 ut_params->auth_xform.next = NULL;
1760 ut_params->auth_xform.auth.op = op;
1761 ut_params->auth_xform.auth.algo = algo;
1762 ut_params->auth_xform.auth.key.length = key_len;
1763 ut_params->auth_xform.auth.key.data = hash_key;
1764 ut_params->auth_xform.auth.digest_length = auth_len;
1765 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1766 ut_params->auth_xform.auth.iv.length = iv_len;
1767 ut_params->sess = rte_cryptodev_sym_session_create(
1768 ts_params->session_mpool);
1770 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1771 &ut_params->auth_xform,
1772 ts_params->session_priv_mpool);
1773 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1774 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1779 create_wireless_algo_cipher_session(uint8_t dev_id,
1780 enum rte_crypto_cipher_operation op,
1781 enum rte_crypto_cipher_algorithm algo,
1782 const uint8_t *key, const uint8_t key_len,
1785 uint8_t cipher_key[key_len];
1787 struct crypto_testsuite_params *ts_params = &testsuite_params;
1788 struct crypto_unittest_params *ut_params = &unittest_params;
1790 memcpy(cipher_key, key, key_len);
1792 /* Setup Cipher Parameters */
1793 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1794 ut_params->cipher_xform.next = NULL;
1796 ut_params->cipher_xform.cipher.algo = algo;
1797 ut_params->cipher_xform.cipher.op = op;
1798 ut_params->cipher_xform.cipher.key.data = cipher_key;
1799 ut_params->cipher_xform.cipher.key.length = key_len;
1800 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1801 ut_params->cipher_xform.cipher.iv.length = iv_len;
1803 debug_hexdump(stdout, "key:", key, key_len);
1805 /* Create Crypto session */
1806 ut_params->sess = rte_cryptodev_sym_session_create(
1807 ts_params->session_mpool);
1809 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1810 &ut_params->cipher_xform,
1811 ts_params->session_priv_mpool);
1812 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1813 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1818 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1819 unsigned int cipher_len,
1820 unsigned int cipher_offset)
1822 struct crypto_testsuite_params *ts_params = &testsuite_params;
1823 struct crypto_unittest_params *ut_params = &unittest_params;
1825 /* Generate Crypto op data structure */
1826 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1827 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1828 TEST_ASSERT_NOT_NULL(ut_params->op,
1829 "Failed to allocate pktmbuf offload");
1831 /* Set crypto operation data parameters */
1832 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1834 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1836 /* set crypto operation source mbuf */
1837 sym_op->m_src = ut_params->ibuf;
1840 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1842 sym_op->cipher.data.length = cipher_len;
1843 sym_op->cipher.data.offset = cipher_offset;
1848 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1849 unsigned int cipher_len,
1850 unsigned int cipher_offset)
1852 struct crypto_testsuite_params *ts_params = &testsuite_params;
1853 struct crypto_unittest_params *ut_params = &unittest_params;
1855 /* Generate Crypto op data structure */
1856 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1857 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1858 TEST_ASSERT_NOT_NULL(ut_params->op,
1859 "Failed to allocate pktmbuf offload");
1861 /* Set crypto operation data parameters */
1862 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1864 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1866 /* set crypto operation source mbuf */
1867 sym_op->m_src = ut_params->ibuf;
1868 sym_op->m_dst = ut_params->obuf;
1871 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1873 sym_op->cipher.data.length = cipher_len;
1874 sym_op->cipher.data.offset = cipher_offset;
1879 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1880 enum rte_crypto_cipher_operation cipher_op,
1881 enum rte_crypto_auth_operation auth_op,
1882 enum rte_crypto_auth_algorithm auth_algo,
1883 enum rte_crypto_cipher_algorithm cipher_algo,
1884 const uint8_t *key, uint8_t key_len,
1885 uint8_t auth_iv_len, uint8_t auth_len,
1886 uint8_t cipher_iv_len)
1889 uint8_t cipher_auth_key[key_len];
1892 struct crypto_testsuite_params *ts_params = &testsuite_params;
1893 struct crypto_unittest_params *ut_params = &unittest_params;
1895 memcpy(cipher_auth_key, key, key_len);
1897 /* Setup Authentication Parameters */
1898 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1899 ut_params->auth_xform.next = NULL;
1901 ut_params->auth_xform.auth.op = auth_op;
1902 ut_params->auth_xform.auth.algo = auth_algo;
1903 ut_params->auth_xform.auth.key.length = key_len;
1904 /* Hash key = cipher key */
1905 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1906 ut_params->auth_xform.auth.digest_length = auth_len;
1907 /* Auth IV will be after cipher IV */
1908 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1909 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1911 /* Setup Cipher Parameters */
1912 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1913 ut_params->cipher_xform.next = &ut_params->auth_xform;
1915 ut_params->cipher_xform.cipher.algo = cipher_algo;
1916 ut_params->cipher_xform.cipher.op = cipher_op;
1917 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1918 ut_params->cipher_xform.cipher.key.length = key_len;
1919 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1920 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1922 debug_hexdump(stdout, "key:", key, key_len);
1924 /* Create Crypto session*/
1925 ut_params->sess = rte_cryptodev_sym_session_create(
1926 ts_params->session_mpool);
1927 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1929 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1930 &ut_params->cipher_xform,
1931 ts_params->session_priv_mpool);
1932 if (status == -ENOTSUP)
1935 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1940 create_wireless_cipher_auth_session(uint8_t dev_id,
1941 enum rte_crypto_cipher_operation cipher_op,
1942 enum rte_crypto_auth_operation auth_op,
1943 enum rte_crypto_auth_algorithm auth_algo,
1944 enum rte_crypto_cipher_algorithm cipher_algo,
1945 const struct wireless_test_data *tdata)
1947 const uint8_t key_len = tdata->key.len;
1948 uint8_t cipher_auth_key[key_len];
1951 struct crypto_testsuite_params *ts_params = &testsuite_params;
1952 struct crypto_unittest_params *ut_params = &unittest_params;
1953 const uint8_t *key = tdata->key.data;
1954 const uint8_t auth_len = tdata->digest.len;
1955 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1956 uint8_t auth_iv_len = tdata->auth_iv.len;
1958 memcpy(cipher_auth_key, key, key_len);
1960 /* Setup Authentication Parameters */
1961 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1962 ut_params->auth_xform.next = NULL;
1964 ut_params->auth_xform.auth.op = auth_op;
1965 ut_params->auth_xform.auth.algo = auth_algo;
1966 ut_params->auth_xform.auth.key.length = key_len;
1967 /* Hash key = cipher key */
1968 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1969 ut_params->auth_xform.auth.digest_length = auth_len;
1970 /* Auth IV will be after cipher IV */
1971 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1972 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1974 /* Setup Cipher Parameters */
1975 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1976 ut_params->cipher_xform.next = &ut_params->auth_xform;
1978 ut_params->cipher_xform.cipher.algo = cipher_algo;
1979 ut_params->cipher_xform.cipher.op = cipher_op;
1980 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1981 ut_params->cipher_xform.cipher.key.length = key_len;
1982 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1983 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1986 debug_hexdump(stdout, "key:", key, key_len);
1988 /* Create Crypto session*/
1989 ut_params->sess = rte_cryptodev_sym_session_create(
1990 ts_params->session_mpool);
1992 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1993 &ut_params->cipher_xform,
1994 ts_params->session_priv_mpool);
1995 if (status == -ENOTSUP)
1998 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1999 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2004 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2005 const struct wireless_test_data *tdata)
2007 return create_wireless_cipher_auth_session(dev_id,
2008 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2009 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2010 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2014 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2015 enum rte_crypto_cipher_operation cipher_op,
2016 enum rte_crypto_auth_operation auth_op,
2017 enum rte_crypto_auth_algorithm auth_algo,
2018 enum rte_crypto_cipher_algorithm cipher_algo,
2019 const uint8_t *key, const uint8_t key_len,
2020 uint8_t auth_iv_len, uint8_t auth_len,
2021 uint8_t cipher_iv_len)
2023 uint8_t auth_cipher_key[key_len];
2025 struct crypto_testsuite_params *ts_params = &testsuite_params;
2026 struct crypto_unittest_params *ut_params = &unittest_params;
2028 memcpy(auth_cipher_key, key, key_len);
2030 /* Setup Authentication Parameters */
2031 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2032 ut_params->auth_xform.auth.op = auth_op;
2033 ut_params->auth_xform.next = &ut_params->cipher_xform;
2034 ut_params->auth_xform.auth.algo = auth_algo;
2035 ut_params->auth_xform.auth.key.length = key_len;
2036 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2037 ut_params->auth_xform.auth.digest_length = auth_len;
2038 /* Auth IV will be after cipher IV */
2039 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2040 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2042 /* Setup Cipher Parameters */
2043 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2044 ut_params->cipher_xform.next = NULL;
2045 ut_params->cipher_xform.cipher.algo = cipher_algo;
2046 ut_params->cipher_xform.cipher.op = cipher_op;
2047 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2048 ut_params->cipher_xform.cipher.key.length = key_len;
2049 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2050 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2052 debug_hexdump(stdout, "key:", key, key_len);
2054 /* Create Crypto session*/
2055 ut_params->sess = rte_cryptodev_sym_session_create(
2056 ts_params->session_mpool);
2057 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2059 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2060 ut_params->auth_xform.next = NULL;
2061 ut_params->cipher_xform.next = &ut_params->auth_xform;
2062 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2063 &ut_params->cipher_xform,
2064 ts_params->session_priv_mpool);
2067 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2068 &ut_params->auth_xform,
2069 ts_params->session_priv_mpool);
2071 if (status == -ENOTSUP)
2074 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2080 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2081 unsigned int auth_tag_len,
2082 const uint8_t *iv, unsigned int iv_len,
2083 unsigned int data_pad_len,
2084 enum rte_crypto_auth_operation op,
2085 unsigned int auth_len, unsigned int auth_offset)
2087 struct crypto_testsuite_params *ts_params = &testsuite_params;
2089 struct crypto_unittest_params *ut_params = &unittest_params;
2091 /* Generate Crypto op data structure */
2092 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2093 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2094 TEST_ASSERT_NOT_NULL(ut_params->op,
2095 "Failed to allocate pktmbuf offload");
2097 /* Set crypto operation data parameters */
2098 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2100 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2102 /* set crypto operation source mbuf */
2103 sym_op->m_src = ut_params->ibuf;
2106 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2109 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2110 ut_params->ibuf, auth_tag_len);
2112 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2113 "no room to append auth tag");
2114 ut_params->digest = sym_op->auth.digest.data;
2115 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2116 ut_params->ibuf, data_pad_len);
2117 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2118 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2120 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2122 debug_hexdump(stdout, "digest:",
2123 sym_op->auth.digest.data,
2126 sym_op->auth.data.length = auth_len;
2127 sym_op->auth.data.offset = auth_offset;
2133 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2134 enum rte_crypto_auth_operation op)
2136 struct crypto_testsuite_params *ts_params = &testsuite_params;
2137 struct crypto_unittest_params *ut_params = &unittest_params;
2139 const uint8_t *auth_tag = tdata->digest.data;
2140 const unsigned int auth_tag_len = tdata->digest.len;
2141 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2142 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2144 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2145 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2146 const uint8_t *auth_iv = tdata->auth_iv.data;
2147 const uint8_t auth_iv_len = tdata->auth_iv.len;
2148 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2149 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2151 /* Generate Crypto op data structure */
2152 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2153 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2154 TEST_ASSERT_NOT_NULL(ut_params->op,
2155 "Failed to allocate pktmbuf offload");
2156 /* Set crypto operation data parameters */
2157 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2159 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2161 /* set crypto operation source mbuf */
2162 sym_op->m_src = ut_params->ibuf;
2165 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2166 ut_params->ibuf, auth_tag_len);
2168 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2169 "no room to append auth tag");
2170 ut_params->digest = sym_op->auth.digest.data;
2171 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2172 ut_params->ibuf, data_pad_len);
2173 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2174 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2176 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2178 debug_hexdump(stdout, "digest:",
2179 sym_op->auth.digest.data,
2182 /* Copy cipher and auth IVs at the end of the crypto operation */
2183 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2185 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2186 iv_ptr += cipher_iv_len;
2187 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2189 sym_op->cipher.data.length = cipher_len;
2190 sym_op->cipher.data.offset = 0;
2191 sym_op->auth.data.length = auth_len;
2192 sym_op->auth.data.offset = 0;
2198 create_zuc_cipher_hash_generate_operation(
2199 const struct wireless_test_data *tdata)
2201 return create_wireless_cipher_hash_operation(tdata,
2202 RTE_CRYPTO_AUTH_OP_GENERATE);
2206 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2207 const unsigned auth_tag_len,
2208 const uint8_t *auth_iv, uint8_t auth_iv_len,
2209 unsigned data_pad_len,
2210 enum rte_crypto_auth_operation op,
2211 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2212 const unsigned cipher_len, const unsigned cipher_offset,
2213 const unsigned auth_len, const unsigned auth_offset)
2215 struct crypto_testsuite_params *ts_params = &testsuite_params;
2216 struct crypto_unittest_params *ut_params = &unittest_params;
2218 enum rte_crypto_cipher_algorithm cipher_algo =
2219 ut_params->cipher_xform.cipher.algo;
2220 enum rte_crypto_auth_algorithm auth_algo =
2221 ut_params->auth_xform.auth.algo;
2223 /* Generate Crypto op data structure */
2224 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2225 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2226 TEST_ASSERT_NOT_NULL(ut_params->op,
2227 "Failed to allocate pktmbuf offload");
2228 /* Set crypto operation data parameters */
2229 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2231 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2233 /* set crypto operation source mbuf */
2234 sym_op->m_src = ut_params->ibuf;
2237 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2238 ut_params->ibuf, auth_tag_len);
2240 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2241 "no room to append auth tag");
2242 ut_params->digest = sym_op->auth.digest.data;
2244 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2245 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2246 ut_params->ibuf, data_pad_len);
2248 struct rte_mbuf *m = ut_params->ibuf;
2249 unsigned int offset = data_pad_len;
2251 while (offset > m->data_len && m->next != NULL) {
2252 offset -= m->data_len;
2255 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2259 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2260 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2262 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2264 debug_hexdump(stdout, "digest:",
2265 sym_op->auth.digest.data,
2268 /* Copy cipher and auth IVs at the end of the crypto operation */
2269 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2271 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2272 iv_ptr += cipher_iv_len;
2273 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2275 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2276 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2277 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2278 sym_op->cipher.data.length = cipher_len;
2279 sym_op->cipher.data.offset = cipher_offset;
2281 sym_op->cipher.data.length = cipher_len >> 3;
2282 sym_op->cipher.data.offset = cipher_offset >> 3;
2285 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2286 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2287 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2288 sym_op->auth.data.length = auth_len;
2289 sym_op->auth.data.offset = auth_offset;
2291 sym_op->auth.data.length = auth_len >> 3;
2292 sym_op->auth.data.offset = auth_offset >> 3;
2299 create_wireless_algo_auth_cipher_operation(
2300 const uint8_t *auth_tag, unsigned int auth_tag_len,
2301 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2302 const uint8_t *auth_iv, uint8_t auth_iv_len,
2303 unsigned int data_pad_len,
2304 unsigned int cipher_len, unsigned int cipher_offset,
2305 unsigned int auth_len, unsigned int auth_offset,
2306 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2308 struct crypto_testsuite_params *ts_params = &testsuite_params;
2309 struct crypto_unittest_params *ut_params = &unittest_params;
2311 enum rte_crypto_cipher_algorithm cipher_algo =
2312 ut_params->cipher_xform.cipher.algo;
2313 enum rte_crypto_auth_algorithm auth_algo =
2314 ut_params->auth_xform.auth.algo;
2316 /* Generate Crypto op data structure */
2317 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2318 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2319 TEST_ASSERT_NOT_NULL(ut_params->op,
2320 "Failed to allocate pktmbuf offload");
2322 /* Set crypto operation data parameters */
2323 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2325 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2327 /* set crypto operation mbufs */
2328 sym_op->m_src = ut_params->ibuf;
2329 if (op_mode == OUT_OF_PLACE)
2330 sym_op->m_dst = ut_params->obuf;
2334 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2335 (op_mode == IN_PLACE ?
2336 ut_params->ibuf : ut_params->obuf),
2337 uint8_t *, data_pad_len);
2338 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2339 (op_mode == IN_PLACE ?
2340 ut_params->ibuf : ut_params->obuf),
2342 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2344 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2345 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2346 sym_op->m_src : sym_op->m_dst);
2347 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2348 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2349 sgl_buf = sgl_buf->next;
2351 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2352 uint8_t *, remaining_off);
2353 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2355 memset(sym_op->auth.digest.data, 0, remaining_off);
2356 while (sgl_buf->next != NULL) {
2357 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2358 0, rte_pktmbuf_data_len(sgl_buf));
2359 sgl_buf = sgl_buf->next;
2363 /* Copy digest for the verification */
2365 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2367 /* Copy cipher and auth IVs at the end of the crypto operation */
2368 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2369 ut_params->op, uint8_t *, IV_OFFSET);
2371 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2372 iv_ptr += cipher_iv_len;
2373 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2375 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2376 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2377 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2378 sym_op->cipher.data.length = cipher_len;
2379 sym_op->cipher.data.offset = cipher_offset;
2381 sym_op->cipher.data.length = cipher_len >> 3;
2382 sym_op->cipher.data.offset = cipher_offset >> 3;
2385 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2386 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2387 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2388 sym_op->auth.data.length = auth_len;
2389 sym_op->auth.data.offset = auth_offset;
2391 sym_op->auth.data.length = auth_len >> 3;
2392 sym_op->auth.data.offset = auth_offset >> 3;
2399 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2401 struct crypto_testsuite_params *ts_params = &testsuite_params;
2402 struct crypto_unittest_params *ut_params = &unittest_params;
2405 unsigned plaintext_pad_len;
2406 unsigned plaintext_len;
2408 struct rte_cryptodev_info dev_info;
2410 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2411 uint64_t feat_flags = dev_info.feature_flags;
2413 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2414 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2415 printf("Device doesn't support NON-Byte Aligned Data.\n");
2419 /* Verify the capabilities */
2420 struct rte_cryptodev_sym_capability_idx cap_idx;
2421 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2422 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2423 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2427 /* Create SNOW 3G session */
2428 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2429 tdata->key.data, tdata->key.len,
2430 tdata->auth_iv.len, tdata->digest.len,
2431 RTE_CRYPTO_AUTH_OP_GENERATE,
2432 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2436 /* alloc mbuf and set payload */
2437 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2439 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2440 rte_pktmbuf_tailroom(ut_params->ibuf));
2442 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2443 /* Append data which is padded to a multiple of */
2444 /* the algorithms block size */
2445 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2446 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2448 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2450 /* Create SNOW 3G operation */
2451 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2452 tdata->auth_iv.data, tdata->auth_iv.len,
2453 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2454 tdata->validAuthLenInBits.len,
2459 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2461 ut_params->obuf = ut_params->op->sym->m_src;
2462 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2463 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2464 + plaintext_pad_len;
2467 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2470 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2471 "SNOW 3G Generated auth tag not as expected");
2477 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2479 struct crypto_testsuite_params *ts_params = &testsuite_params;
2480 struct crypto_unittest_params *ut_params = &unittest_params;
2483 unsigned plaintext_pad_len;
2484 unsigned plaintext_len;
2486 struct rte_cryptodev_info dev_info;
2488 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2489 uint64_t feat_flags = dev_info.feature_flags;
2491 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2492 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2493 printf("Device doesn't support NON-Byte Aligned Data.\n");
2497 /* Verify the capabilities */
2498 struct rte_cryptodev_sym_capability_idx cap_idx;
2499 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2500 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2501 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2505 /* Create SNOW 3G session */
2506 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2507 tdata->key.data, tdata->key.len,
2508 tdata->auth_iv.len, tdata->digest.len,
2509 RTE_CRYPTO_AUTH_OP_VERIFY,
2510 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2513 /* alloc mbuf and set payload */
2514 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2516 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2517 rte_pktmbuf_tailroom(ut_params->ibuf));
2519 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2520 /* Append data which is padded to a multiple of */
2521 /* the algorithms block size */
2522 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2523 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2525 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2527 /* Create SNOW 3G operation */
2528 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2530 tdata->auth_iv.data, tdata->auth_iv.len,
2532 RTE_CRYPTO_AUTH_OP_VERIFY,
2533 tdata->validAuthLenInBits.len,
2538 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2540 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2541 ut_params->obuf = ut_params->op->sym->m_src;
2542 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2543 + plaintext_pad_len;
2546 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2555 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2557 struct crypto_testsuite_params *ts_params = &testsuite_params;
2558 struct crypto_unittest_params *ut_params = &unittest_params;
2561 unsigned plaintext_pad_len;
2562 unsigned plaintext_len;
2565 /* Verify the capabilities */
2566 struct rte_cryptodev_sym_capability_idx cap_idx;
2567 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2568 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2569 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2573 /* Create KASUMI session */
2574 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2575 tdata->key.data, tdata->key.len,
2576 0, tdata->digest.len,
2577 RTE_CRYPTO_AUTH_OP_GENERATE,
2578 RTE_CRYPTO_AUTH_KASUMI_F9);
2582 /* alloc mbuf and set payload */
2583 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2585 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2586 rte_pktmbuf_tailroom(ut_params->ibuf));
2588 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2589 /* Append data which is padded to a multiple of */
2590 /* the algorithms block size */
2591 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2592 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2594 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2596 /* Create KASUMI operation */
2597 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2599 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2600 tdata->plaintext.len,
2605 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2606 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2609 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2612 ut_params->obuf = ut_params->op->sym->m_src;
2613 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2614 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2615 + plaintext_pad_len;
2618 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2621 DIGEST_BYTE_LENGTH_KASUMI_F9,
2622 "KASUMI Generated auth tag not as expected");
2628 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2630 struct crypto_testsuite_params *ts_params = &testsuite_params;
2631 struct crypto_unittest_params *ut_params = &unittest_params;
2634 unsigned plaintext_pad_len;
2635 unsigned plaintext_len;
2638 /* Verify the capabilities */
2639 struct rte_cryptodev_sym_capability_idx cap_idx;
2640 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2641 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2642 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2646 /* Create KASUMI session */
2647 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2648 tdata->key.data, tdata->key.len,
2649 0, tdata->digest.len,
2650 RTE_CRYPTO_AUTH_OP_VERIFY,
2651 RTE_CRYPTO_AUTH_KASUMI_F9);
2654 /* alloc mbuf and set payload */
2655 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2657 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2658 rte_pktmbuf_tailroom(ut_params->ibuf));
2660 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2661 /* Append data which is padded to a multiple */
2662 /* of the algorithms block size */
2663 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2664 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2666 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2668 /* Create KASUMI operation */
2669 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2673 RTE_CRYPTO_AUTH_OP_VERIFY,
2674 tdata->plaintext.len,
2679 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2681 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2682 ut_params->obuf = ut_params->op->sym->m_src;
2683 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2684 + plaintext_pad_len;
2687 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2696 test_snow3g_hash_generate_test_case_1(void)
2698 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2702 test_snow3g_hash_generate_test_case_2(void)
2704 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2708 test_snow3g_hash_generate_test_case_3(void)
2710 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2714 test_snow3g_hash_generate_test_case_4(void)
2716 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2720 test_snow3g_hash_generate_test_case_5(void)
2722 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2726 test_snow3g_hash_generate_test_case_6(void)
2728 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2732 test_snow3g_hash_verify_test_case_1(void)
2734 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2739 test_snow3g_hash_verify_test_case_2(void)
2741 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2745 test_snow3g_hash_verify_test_case_3(void)
2747 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2751 test_snow3g_hash_verify_test_case_4(void)
2753 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2757 test_snow3g_hash_verify_test_case_5(void)
2759 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2763 test_snow3g_hash_verify_test_case_6(void)
2765 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2769 test_kasumi_hash_generate_test_case_1(void)
2771 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2775 test_kasumi_hash_generate_test_case_2(void)
2777 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2781 test_kasumi_hash_generate_test_case_3(void)
2783 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2787 test_kasumi_hash_generate_test_case_4(void)
2789 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2793 test_kasumi_hash_generate_test_case_5(void)
2795 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2799 test_kasumi_hash_generate_test_case_6(void)
2801 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2805 test_kasumi_hash_verify_test_case_1(void)
2807 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2811 test_kasumi_hash_verify_test_case_2(void)
2813 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2817 test_kasumi_hash_verify_test_case_3(void)
2819 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2823 test_kasumi_hash_verify_test_case_4(void)
2825 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2829 test_kasumi_hash_verify_test_case_5(void)
2831 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2835 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2837 struct crypto_testsuite_params *ts_params = &testsuite_params;
2838 struct crypto_unittest_params *ut_params = &unittest_params;
2841 uint8_t *plaintext, *ciphertext;
2842 unsigned plaintext_pad_len;
2843 unsigned plaintext_len;
2845 /* Verify the capabilities */
2846 struct rte_cryptodev_sym_capability_idx cap_idx;
2847 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2848 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2849 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2853 /* Create KASUMI session */
2854 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2855 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2856 RTE_CRYPTO_CIPHER_KASUMI_F8,
2857 tdata->key.data, tdata->key.len,
2858 tdata->cipher_iv.len);
2862 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2864 /* Clear mbuf payload */
2865 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2866 rte_pktmbuf_tailroom(ut_params->ibuf));
2868 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2869 /* Append data which is padded to a multiple */
2870 /* of the algorithms block size */
2871 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2872 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2874 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2876 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2878 /* Create KASUMI operation */
2879 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2880 tdata->cipher_iv.len,
2881 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2882 tdata->validCipherOffsetInBits.len);
2886 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2888 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2890 ut_params->obuf = ut_params->op->sym->m_dst;
2891 if (ut_params->obuf)
2892 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2894 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2896 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2898 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2899 (tdata->validCipherOffsetInBits.len >> 3);
2901 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2903 reference_ciphertext,
2904 tdata->validCipherLenInBits.len,
2905 "KASUMI Ciphertext data not as expected");
2910 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2912 struct crypto_testsuite_params *ts_params = &testsuite_params;
2913 struct crypto_unittest_params *ut_params = &unittest_params;
2917 unsigned int plaintext_pad_len;
2918 unsigned int plaintext_len;
2920 uint8_t buffer[10000];
2921 const uint8_t *ciphertext;
2923 struct rte_cryptodev_info dev_info;
2925 /* Verify the capabilities */
2926 struct rte_cryptodev_sym_capability_idx cap_idx;
2927 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2928 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2929 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2933 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2935 uint64_t feat_flags = dev_info.feature_flags;
2937 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2938 printf("Device doesn't support in-place scatter-gather. "
2943 /* Create KASUMI session */
2944 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2945 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2946 RTE_CRYPTO_CIPHER_KASUMI_F8,
2947 tdata->key.data, tdata->key.len,
2948 tdata->cipher_iv.len);
2952 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2955 /* Append data which is padded to a multiple */
2956 /* of the algorithms block size */
2957 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2959 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2960 plaintext_pad_len, 10, 0);
2962 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2964 /* Create KASUMI operation */
2965 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2966 tdata->cipher_iv.len,
2967 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2968 tdata->validCipherOffsetInBits.len);
2972 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2974 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2976 ut_params->obuf = ut_params->op->sym->m_dst;
2978 if (ut_params->obuf)
2979 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2980 plaintext_len, buffer);
2982 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
2983 tdata->validCipherOffsetInBits.len >> 3,
2984 plaintext_len, buffer);
2987 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2989 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2990 (tdata->validCipherOffsetInBits.len >> 3);
2992 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2994 reference_ciphertext,
2995 tdata->validCipherLenInBits.len,
2996 "KASUMI Ciphertext data not as expected");
3001 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3003 struct crypto_testsuite_params *ts_params = &testsuite_params;
3004 struct crypto_unittest_params *ut_params = &unittest_params;
3007 uint8_t *plaintext, *ciphertext;
3008 unsigned plaintext_pad_len;
3009 unsigned plaintext_len;
3011 /* Verify the capabilities */
3012 struct rte_cryptodev_sym_capability_idx cap_idx;
3013 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3014 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3015 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3019 /* Create KASUMI session */
3020 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3021 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3022 RTE_CRYPTO_CIPHER_KASUMI_F8,
3023 tdata->key.data, tdata->key.len,
3024 tdata->cipher_iv.len);
3028 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3029 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3031 /* Clear mbuf payload */
3032 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3033 rte_pktmbuf_tailroom(ut_params->ibuf));
3035 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3036 /* Append data which is padded to a multiple */
3037 /* of the algorithms block size */
3038 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3039 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3041 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3042 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3044 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3046 /* Create KASUMI operation */
3047 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3048 tdata->cipher_iv.len,
3049 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3050 tdata->validCipherOffsetInBits.len);
3054 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3056 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3058 ut_params->obuf = ut_params->op->sym->m_dst;
3059 if (ut_params->obuf)
3060 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3062 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3064 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3066 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3067 (tdata->validCipherOffsetInBits.len >> 3);
3069 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3071 reference_ciphertext,
3072 tdata->validCipherLenInBits.len,
3073 "KASUMI Ciphertext data not as expected");
3078 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3080 struct crypto_testsuite_params *ts_params = &testsuite_params;
3081 struct crypto_unittest_params *ut_params = &unittest_params;
3084 unsigned int plaintext_pad_len;
3085 unsigned int plaintext_len;
3087 const uint8_t *ciphertext;
3088 uint8_t buffer[2048];
3090 struct rte_cryptodev_info dev_info;
3092 /* Verify the capabilities */
3093 struct rte_cryptodev_sym_capability_idx cap_idx;
3094 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3095 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3096 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3100 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3102 uint64_t feat_flags = dev_info.feature_flags;
3103 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3104 printf("Device doesn't support out-of-place scatter-gather "
3105 "in both input and output mbufs. "
3110 /* Create KASUMI session */
3111 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3112 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3113 RTE_CRYPTO_CIPHER_KASUMI_F8,
3114 tdata->key.data, tdata->key.len,
3115 tdata->cipher_iv.len);
3119 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3120 /* Append data which is padded to a multiple */
3121 /* of the algorithms block size */
3122 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3124 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3125 plaintext_pad_len, 10, 0);
3126 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3127 plaintext_pad_len, 3, 0);
3129 /* Append data which is padded to a multiple */
3130 /* of the algorithms block size */
3131 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3133 /* Create KASUMI operation */
3134 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3135 tdata->cipher_iv.len,
3136 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3137 tdata->validCipherOffsetInBits.len);
3141 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3143 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3145 ut_params->obuf = ut_params->op->sym->m_dst;
3146 if (ut_params->obuf)
3147 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3148 plaintext_pad_len, buffer);
3150 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3151 tdata->validCipherOffsetInBits.len >> 3,
3152 plaintext_pad_len, buffer);
3154 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3155 (tdata->validCipherOffsetInBits.len >> 3);
3157 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3159 reference_ciphertext,
3160 tdata->validCipherLenInBits.len,
3161 "KASUMI Ciphertext data not as expected");
3167 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3169 struct crypto_testsuite_params *ts_params = &testsuite_params;
3170 struct crypto_unittest_params *ut_params = &unittest_params;
3173 uint8_t *ciphertext, *plaintext;
3174 unsigned ciphertext_pad_len;
3175 unsigned ciphertext_len;
3177 /* Verify the capabilities */
3178 struct rte_cryptodev_sym_capability_idx cap_idx;
3179 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3180 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3181 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3185 /* Create KASUMI session */
3186 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3187 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3188 RTE_CRYPTO_CIPHER_KASUMI_F8,
3189 tdata->key.data, tdata->key.len,
3190 tdata->cipher_iv.len);
3194 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3195 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3197 /* Clear mbuf payload */
3198 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3199 rte_pktmbuf_tailroom(ut_params->ibuf));
3201 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3202 /* Append data which is padded to a multiple */
3203 /* of the algorithms block size */
3204 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3205 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3206 ciphertext_pad_len);
3207 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3208 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3210 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3212 /* Create KASUMI operation */
3213 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3214 tdata->cipher_iv.len,
3215 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3216 tdata->validCipherOffsetInBits.len);
3220 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3222 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3224 ut_params->obuf = ut_params->op->sym->m_dst;
3225 if (ut_params->obuf)
3226 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3228 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3230 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3232 const uint8_t *reference_plaintext = tdata->plaintext.data +
3233 (tdata->validCipherOffsetInBits.len >> 3);
3235 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3237 reference_plaintext,
3238 tdata->validCipherLenInBits.len,
3239 "KASUMI Plaintext data not as expected");
3244 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3246 struct crypto_testsuite_params *ts_params = &testsuite_params;
3247 struct crypto_unittest_params *ut_params = &unittest_params;
3250 uint8_t *ciphertext, *plaintext;
3251 unsigned ciphertext_pad_len;
3252 unsigned ciphertext_len;
3254 /* Verify the capabilities */
3255 struct rte_cryptodev_sym_capability_idx cap_idx;
3256 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3257 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3258 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3262 /* Create KASUMI session */
3263 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3264 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3265 RTE_CRYPTO_CIPHER_KASUMI_F8,
3266 tdata->key.data, tdata->key.len,
3267 tdata->cipher_iv.len);
3271 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3273 /* Clear mbuf payload */
3274 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3275 rte_pktmbuf_tailroom(ut_params->ibuf));
3277 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3278 /* Append data which is padded to a multiple */
3279 /* of the algorithms block size */
3280 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3281 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3282 ciphertext_pad_len);
3283 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3285 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3287 /* Create KASUMI operation */
3288 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3289 tdata->cipher_iv.len,
3290 tdata->ciphertext.len,
3291 tdata->validCipherOffsetInBits.len);
3295 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3297 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3299 ut_params->obuf = ut_params->op->sym->m_dst;
3300 if (ut_params->obuf)
3301 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3303 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3305 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3307 const uint8_t *reference_plaintext = tdata->plaintext.data +
3308 (tdata->validCipherOffsetInBits.len >> 3);
3310 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3312 reference_plaintext,
3313 tdata->validCipherLenInBits.len,
3314 "KASUMI Plaintext data not as expected");
3319 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3321 struct crypto_testsuite_params *ts_params = &testsuite_params;
3322 struct crypto_unittest_params *ut_params = &unittest_params;
3325 uint8_t *plaintext, *ciphertext;
3326 unsigned plaintext_pad_len;
3327 unsigned plaintext_len;
3329 /* Verify the capabilities */
3330 struct rte_cryptodev_sym_capability_idx cap_idx;
3331 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3332 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3333 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3337 /* Create SNOW 3G session */
3338 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3339 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3340 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3341 tdata->key.data, tdata->key.len,
3342 tdata->cipher_iv.len);
3346 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3348 /* Clear mbuf payload */
3349 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3350 rte_pktmbuf_tailroom(ut_params->ibuf));
3352 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3353 /* Append data which is padded to a multiple of */
3354 /* the algorithms block size */
3355 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3356 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3358 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3360 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3362 /* Create SNOW 3G operation */
3363 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3364 tdata->cipher_iv.len,
3365 tdata->validCipherLenInBits.len,
3370 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3372 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3374 ut_params->obuf = ut_params->op->sym->m_dst;
3375 if (ut_params->obuf)
3376 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3378 ciphertext = plaintext;
3380 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3383 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3385 tdata->ciphertext.data,
3386 tdata->validDataLenInBits.len,
3387 "SNOW 3G Ciphertext data not as expected");
3393 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3395 struct crypto_testsuite_params *ts_params = &testsuite_params;
3396 struct crypto_unittest_params *ut_params = &unittest_params;
3397 uint8_t *plaintext, *ciphertext;
3400 unsigned plaintext_pad_len;
3401 unsigned plaintext_len;
3403 /* Verify the capabilities */
3404 struct rte_cryptodev_sym_capability_idx cap_idx;
3405 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3406 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3407 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3411 /* Create SNOW 3G session */
3412 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3413 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3414 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3415 tdata->key.data, tdata->key.len,
3416 tdata->cipher_iv.len);
3420 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3421 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3423 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3424 "Failed to allocate input buffer in mempool");
3425 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3426 "Failed to allocate output buffer in mempool");
3428 /* Clear mbuf payload */
3429 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3430 rte_pktmbuf_tailroom(ut_params->ibuf));
3432 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3433 /* Append data which is padded to a multiple of */
3434 /* the algorithms block size */
3435 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3436 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3438 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3439 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3441 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3443 /* Create SNOW 3G operation */
3444 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3445 tdata->cipher_iv.len,
3446 tdata->validCipherLenInBits.len,
3451 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3453 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3455 ut_params->obuf = ut_params->op->sym->m_dst;
3456 if (ut_params->obuf)
3457 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3459 ciphertext = plaintext;
3461 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3464 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3466 tdata->ciphertext.data,
3467 tdata->validDataLenInBits.len,
3468 "SNOW 3G Ciphertext data not as expected");
3473 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3475 struct crypto_testsuite_params *ts_params = &testsuite_params;
3476 struct crypto_unittest_params *ut_params = &unittest_params;
3479 unsigned int plaintext_pad_len;
3480 unsigned int plaintext_len;
3481 uint8_t buffer[10000];
3482 const uint8_t *ciphertext;
3484 struct rte_cryptodev_info dev_info;
3486 /* Verify the capabilities */
3487 struct rte_cryptodev_sym_capability_idx cap_idx;
3488 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3489 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3490 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3494 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3496 uint64_t feat_flags = dev_info.feature_flags;
3498 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3499 printf("Device doesn't support out-of-place scatter-gather "
3500 "in both input and output mbufs. "
3505 /* Create SNOW 3G session */
3506 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3507 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3508 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3509 tdata->key.data, tdata->key.len,
3510 tdata->cipher_iv.len);
3514 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3515 /* Append data which is padded to a multiple of */
3516 /* the algorithms block size */
3517 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3519 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3520 plaintext_pad_len, 10, 0);
3521 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3522 plaintext_pad_len, 3, 0);
3524 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3525 "Failed to allocate input buffer in mempool");
3526 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3527 "Failed to allocate output buffer in mempool");
3529 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3531 /* Create SNOW 3G operation */
3532 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3533 tdata->cipher_iv.len,
3534 tdata->validCipherLenInBits.len,
3539 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3541 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3543 ut_params->obuf = ut_params->op->sym->m_dst;
3544 if (ut_params->obuf)
3545 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3546 plaintext_len, buffer);
3548 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3549 plaintext_len, buffer);
3551 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3554 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3556 tdata->ciphertext.data,
3557 tdata->validDataLenInBits.len,
3558 "SNOW 3G Ciphertext data not as expected");
3563 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3565 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3567 uint8_t curr_byte, prev_byte;
3568 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3569 uint8_t lower_byte_mask = (1 << offset) - 1;
3572 prev_byte = buffer[0];
3573 buffer[0] >>= offset;
3575 for (i = 1; i < length_in_bytes; i++) {
3576 curr_byte = buffer[i];
3577 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3578 (curr_byte >> offset);
3579 prev_byte = curr_byte;
3584 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3586 struct crypto_testsuite_params *ts_params = &testsuite_params;
3587 struct crypto_unittest_params *ut_params = &unittest_params;
3588 uint8_t *plaintext, *ciphertext;
3590 uint32_t plaintext_len;
3591 uint32_t plaintext_pad_len;
3592 uint8_t extra_offset = 4;
3593 uint8_t *expected_ciphertext_shifted;
3594 struct rte_cryptodev_info dev_info;
3596 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3597 uint64_t feat_flags = dev_info.feature_flags;
3599 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3600 ((tdata->validDataLenInBits.len % 8) != 0)) {
3601 printf("Device doesn't support NON-Byte Aligned Data.\n");
3605 /* Verify the capabilities */
3606 struct rte_cryptodev_sym_capability_idx cap_idx;
3607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3608 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3609 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3613 /* Create SNOW 3G session */
3614 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3615 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3616 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3617 tdata->key.data, tdata->key.len,
3618 tdata->cipher_iv.len);
3622 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3623 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3625 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3626 "Failed to allocate input buffer in mempool");
3627 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3628 "Failed to allocate output buffer in mempool");
3630 /* Clear mbuf payload */
3631 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3632 rte_pktmbuf_tailroom(ut_params->ibuf));
3634 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3636 * Append data which is padded to a
3637 * multiple of the algorithms block size
3639 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3641 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3644 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3646 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3647 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3649 #ifdef RTE_APP_TEST_DEBUG
3650 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3652 /* Create SNOW 3G operation */
3653 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3654 tdata->cipher_iv.len,
3655 tdata->validCipherLenInBits.len,
3660 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3662 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3664 ut_params->obuf = ut_params->op->sym->m_dst;
3665 if (ut_params->obuf)
3666 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3668 ciphertext = plaintext;
3670 #ifdef RTE_APP_TEST_DEBUG
3671 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3674 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3676 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3677 "failed to reserve memory for ciphertext shifted\n");
3679 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3680 ceil_byte_length(tdata->ciphertext.len));
3681 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3684 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3686 expected_ciphertext_shifted,
3687 tdata->validDataLenInBits.len,
3689 "SNOW 3G Ciphertext data not as expected");
3693 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3695 struct crypto_testsuite_params *ts_params = &testsuite_params;
3696 struct crypto_unittest_params *ut_params = &unittest_params;
3700 uint8_t *plaintext, *ciphertext;
3701 unsigned ciphertext_pad_len;
3702 unsigned ciphertext_len;
3704 /* Verify the capabilities */
3705 struct rte_cryptodev_sym_capability_idx cap_idx;
3706 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3707 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3708 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3712 /* Create SNOW 3G session */
3713 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3714 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3715 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3716 tdata->key.data, tdata->key.len,
3717 tdata->cipher_iv.len);
3721 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3723 /* Clear mbuf payload */
3724 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3725 rte_pktmbuf_tailroom(ut_params->ibuf));
3727 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3728 /* Append data which is padded to a multiple of */
3729 /* the algorithms block size */
3730 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3731 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3732 ciphertext_pad_len);
3733 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3735 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3737 /* Create SNOW 3G operation */
3738 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3739 tdata->cipher_iv.len,
3740 tdata->validCipherLenInBits.len,
3741 tdata->cipher.offset_bits);
3745 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3747 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3748 ut_params->obuf = ut_params->op->sym->m_dst;
3749 if (ut_params->obuf)
3750 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3752 plaintext = ciphertext;
3754 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3757 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3758 tdata->plaintext.data,
3759 tdata->validDataLenInBits.len,
3760 "SNOW 3G Plaintext data not as expected");
3764 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3766 struct crypto_testsuite_params *ts_params = &testsuite_params;
3767 struct crypto_unittest_params *ut_params = &unittest_params;
3771 uint8_t *plaintext, *ciphertext;
3772 unsigned ciphertext_pad_len;
3773 unsigned ciphertext_len;
3775 /* Verify the capabilities */
3776 struct rte_cryptodev_sym_capability_idx cap_idx;
3777 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3778 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3779 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3783 /* Create SNOW 3G session */
3784 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3785 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3786 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3787 tdata->key.data, tdata->key.len,
3788 tdata->cipher_iv.len);
3792 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3793 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3795 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3796 "Failed to allocate input buffer");
3797 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3798 "Failed to allocate output buffer");
3800 /* Clear mbuf payload */
3801 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3802 rte_pktmbuf_tailroom(ut_params->ibuf));
3804 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3805 rte_pktmbuf_tailroom(ut_params->obuf));
3807 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3808 /* Append data which is padded to a multiple of */
3809 /* the algorithms block size */
3810 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3811 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3812 ciphertext_pad_len);
3813 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3814 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3816 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3818 /* Create SNOW 3G operation */
3819 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3820 tdata->cipher_iv.len,
3821 tdata->validCipherLenInBits.len,
3826 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3828 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3829 ut_params->obuf = ut_params->op->sym->m_dst;
3830 if (ut_params->obuf)
3831 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3833 plaintext = ciphertext;
3835 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3838 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3839 tdata->plaintext.data,
3840 tdata->validDataLenInBits.len,
3841 "SNOW 3G Plaintext data not as expected");
3846 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3848 struct crypto_testsuite_params *ts_params = &testsuite_params;
3849 struct crypto_unittest_params *ut_params = &unittest_params;
3853 uint8_t *plaintext, *ciphertext;
3854 unsigned int plaintext_pad_len;
3855 unsigned int plaintext_len;
3857 struct rte_cryptodev_info dev_info;
3858 struct rte_cryptodev_sym_capability_idx cap_idx;
3860 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3861 uint64_t feat_flags = dev_info.feature_flags;
3863 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3864 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3865 (tdata->validDataLenInBits.len % 8 != 0))) {
3866 printf("Device doesn't support NON-Byte Aligned Data.\n");
3870 /* Check if device supports ZUC EEA3 */
3871 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3872 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3874 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3878 /* Check if device supports ZUC EIA3 */
3879 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3880 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3882 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3886 /* Create ZUC session */
3887 retval = create_zuc_cipher_auth_encrypt_generate_session(
3888 ts_params->valid_devs[0],
3892 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3894 /* clear mbuf payload */
3895 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3896 rte_pktmbuf_tailroom(ut_params->ibuf));
3898 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3899 /* Append data which is padded to a multiple of */
3900 /* the algorithms block size */
3901 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3902 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3904 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3906 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3908 /* Create ZUC operation */
3909 retval = create_zuc_cipher_hash_generate_operation(tdata);
3913 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3915 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3916 ut_params->obuf = ut_params->op->sym->m_src;
3917 if (ut_params->obuf)
3918 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3920 ciphertext = plaintext;
3922 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3924 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3926 tdata->ciphertext.data,
3927 tdata->validDataLenInBits.len,
3928 "ZUC Ciphertext data not as expected");
3930 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3931 + plaintext_pad_len;
3934 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3938 "ZUC Generated auth tag not as expected");
3943 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3945 struct crypto_testsuite_params *ts_params = &testsuite_params;
3946 struct crypto_unittest_params *ut_params = &unittest_params;
3950 uint8_t *plaintext, *ciphertext;
3951 unsigned plaintext_pad_len;
3952 unsigned plaintext_len;
3954 /* Verify the capabilities */
3955 struct rte_cryptodev_sym_capability_idx cap_idx;
3956 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3957 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3958 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3961 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3962 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3963 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3967 /* Create SNOW 3G session */
3968 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3969 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3970 RTE_CRYPTO_AUTH_OP_GENERATE,
3971 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3972 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3973 tdata->key.data, tdata->key.len,
3974 tdata->auth_iv.len, tdata->digest.len,
3975 tdata->cipher_iv.len);
3978 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3980 /* clear mbuf payload */
3981 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3982 rte_pktmbuf_tailroom(ut_params->ibuf));
3984 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3985 /* Append data which is padded to a multiple of */
3986 /* the algorithms block size */
3987 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3988 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3990 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3992 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3994 /* Create SNOW 3G operation */
3995 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3996 tdata->digest.len, tdata->auth_iv.data,
3998 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3999 tdata->cipher_iv.data, tdata->cipher_iv.len,
4000 tdata->validCipherLenInBits.len,
4002 tdata->validAuthLenInBits.len,
4008 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4010 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4011 ut_params->obuf = ut_params->op->sym->m_src;
4012 if (ut_params->obuf)
4013 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4015 ciphertext = plaintext;
4017 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4019 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4021 tdata->ciphertext.data,
4022 tdata->validDataLenInBits.len,
4023 "SNOW 3G Ciphertext data not as expected");
4025 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4026 + plaintext_pad_len;
4029 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4032 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4033 "SNOW 3G Generated auth tag not as expected");
4038 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4039 uint8_t op_mode, uint8_t verify)
4041 struct crypto_testsuite_params *ts_params = &testsuite_params;
4042 struct crypto_unittest_params *ut_params = &unittest_params;
4046 uint8_t *plaintext = NULL, *ciphertext = NULL;
4047 unsigned int plaintext_pad_len;
4048 unsigned int plaintext_len;
4049 unsigned int ciphertext_pad_len;
4050 unsigned int ciphertext_len;
4052 struct rte_cryptodev_info dev_info;
4054 /* Verify the capabilities */
4055 struct rte_cryptodev_sym_capability_idx cap_idx;
4056 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4057 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4058 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4061 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4062 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4063 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4067 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4069 uint64_t feat_flags = dev_info.feature_flags;
4071 if (op_mode == OUT_OF_PLACE) {
4072 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4073 printf("Device doesn't support digest encrypted.\n");
4078 /* Create SNOW 3G session */
4079 retval = create_wireless_algo_auth_cipher_session(
4080 ts_params->valid_devs[0],
4081 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4082 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4083 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4084 : RTE_CRYPTO_AUTH_OP_GENERATE),
4085 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4086 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4087 tdata->key.data, tdata->key.len,
4088 tdata->auth_iv.len, tdata->digest.len,
4089 tdata->cipher_iv.len);
4094 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4095 if (op_mode == OUT_OF_PLACE)
4096 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4098 /* clear mbuf payload */
4099 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4100 rte_pktmbuf_tailroom(ut_params->ibuf));
4101 if (op_mode == OUT_OF_PLACE)
4102 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4103 rte_pktmbuf_tailroom(ut_params->obuf));
4105 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4106 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4107 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4108 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4111 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4112 ciphertext_pad_len);
4113 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4114 if (op_mode == OUT_OF_PLACE)
4115 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4116 debug_hexdump(stdout, "ciphertext:", ciphertext,
4119 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4121 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4122 if (op_mode == OUT_OF_PLACE)
4123 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4124 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4127 /* Create SNOW 3G operation */
4128 retval = create_wireless_algo_auth_cipher_operation(
4129 tdata->digest.data, tdata->digest.len,
4130 tdata->cipher_iv.data, tdata->cipher_iv.len,
4131 tdata->auth_iv.data, tdata->auth_iv.len,
4132 (tdata->digest.offset_bytes == 0 ?
4133 (verify ? ciphertext_pad_len : plaintext_pad_len)
4134 : tdata->digest.offset_bytes),
4135 tdata->validCipherLenInBits.len,
4136 tdata->cipher.offset_bits,
4137 tdata->validAuthLenInBits.len,
4138 tdata->auth.offset_bits,
4139 op_mode, 0, verify);
4144 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4147 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4149 ut_params->obuf = (op_mode == IN_PLACE ?
4150 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4153 if (ut_params->obuf)
4154 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4157 plaintext = ciphertext +
4158 (tdata->cipher.offset_bits >> 3);
4160 debug_hexdump(stdout, "plaintext:", plaintext,
4161 (tdata->plaintext.len >> 3) - tdata->digest.len);
4162 debug_hexdump(stdout, "plaintext expected:",
4163 tdata->plaintext.data,
4164 (tdata->plaintext.len >> 3) - tdata->digest.len);
4166 if (ut_params->obuf)
4167 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4170 ciphertext = plaintext;
4172 debug_hexdump(stdout, "ciphertext:", ciphertext,
4174 debug_hexdump(stdout, "ciphertext expected:",
4175 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4177 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4178 + (tdata->digest.offset_bytes == 0 ?
4179 plaintext_pad_len : tdata->digest.offset_bytes);
4181 debug_hexdump(stdout, "digest:", ut_params->digest,
4183 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4189 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4191 tdata->plaintext.data,
4192 tdata->plaintext.len >> 3,
4193 "SNOW 3G Plaintext data not as expected");
4195 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4197 tdata->ciphertext.data,
4198 tdata->validDataLenInBits.len,
4199 "SNOW 3G Ciphertext data not as expected");
4201 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4204 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4205 "SNOW 3G Generated auth tag not as expected");
4211 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4212 uint8_t op_mode, uint8_t verify)
4214 struct crypto_testsuite_params *ts_params = &testsuite_params;
4215 struct crypto_unittest_params *ut_params = &unittest_params;
4219 const uint8_t *plaintext = NULL;
4220 const uint8_t *ciphertext = NULL;
4221 const uint8_t *digest = NULL;
4222 unsigned int plaintext_pad_len;
4223 unsigned int plaintext_len;
4224 unsigned int ciphertext_pad_len;
4225 unsigned int ciphertext_len;
4226 uint8_t buffer[10000];
4227 uint8_t digest_buffer[10000];
4229 struct rte_cryptodev_info dev_info;
4231 /* Verify the capabilities */
4232 struct rte_cryptodev_sym_capability_idx cap_idx;
4233 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4234 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4235 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4238 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4239 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4240 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4244 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4246 uint64_t feat_flags = dev_info.feature_flags;
4248 if (op_mode == IN_PLACE) {
4249 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4250 printf("Device doesn't support in-place scatter-gather "
4251 "in both input and output mbufs.\n");
4255 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4256 printf("Device doesn't support out-of-place scatter-gather "
4257 "in both input and output mbufs.\n");
4260 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4261 printf("Device doesn't support digest encrypted.\n");
4266 /* Create SNOW 3G session */
4267 retval = create_wireless_algo_auth_cipher_session(
4268 ts_params->valid_devs[0],
4269 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4270 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4271 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4272 : RTE_CRYPTO_AUTH_OP_GENERATE),
4273 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4274 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4275 tdata->key.data, tdata->key.len,
4276 tdata->auth_iv.len, tdata->digest.len,
4277 tdata->cipher_iv.len);
4282 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4283 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4284 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4285 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4287 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4288 plaintext_pad_len, 15, 0);
4289 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4290 "Failed to allocate input buffer in mempool");
4292 if (op_mode == OUT_OF_PLACE) {
4293 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4294 plaintext_pad_len, 15, 0);
4295 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4296 "Failed to allocate output buffer in mempool");
4300 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4301 tdata->ciphertext.data);
4302 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4303 ciphertext_len, buffer);
4304 debug_hexdump(stdout, "ciphertext:", ciphertext,
4307 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4308 tdata->plaintext.data);
4309 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4310 plaintext_len, buffer);
4311 debug_hexdump(stdout, "plaintext:", plaintext,
4314 memset(buffer, 0, sizeof(buffer));
4316 /* Create SNOW 3G operation */
4317 retval = create_wireless_algo_auth_cipher_operation(
4318 tdata->digest.data, tdata->digest.len,
4319 tdata->cipher_iv.data, tdata->cipher_iv.len,
4320 tdata->auth_iv.data, tdata->auth_iv.len,
4321 (tdata->digest.offset_bytes == 0 ?
4322 (verify ? ciphertext_pad_len : plaintext_pad_len)
4323 : tdata->digest.offset_bytes),
4324 tdata->validCipherLenInBits.len,
4325 tdata->cipher.offset_bits,
4326 tdata->validAuthLenInBits.len,
4327 tdata->auth.offset_bits,
4328 op_mode, 1, verify);
4333 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4336 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4338 ut_params->obuf = (op_mode == IN_PLACE ?
4339 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4342 if (ut_params->obuf)
4343 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4344 plaintext_len, buffer);
4346 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4347 plaintext_len, buffer);
4349 debug_hexdump(stdout, "plaintext:", plaintext,
4350 (tdata->plaintext.len >> 3) - tdata->digest.len);
4351 debug_hexdump(stdout, "plaintext expected:",
4352 tdata->plaintext.data,
4353 (tdata->plaintext.len >> 3) - tdata->digest.len);
4355 if (ut_params->obuf)
4356 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4357 ciphertext_len, buffer);
4359 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4360 ciphertext_len, buffer);
4362 debug_hexdump(stdout, "ciphertext:", ciphertext,
4364 debug_hexdump(stdout, "ciphertext expected:",
4365 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4367 if (ut_params->obuf)
4368 digest = rte_pktmbuf_read(ut_params->obuf,
4369 (tdata->digest.offset_bytes == 0 ?
4370 plaintext_pad_len : tdata->digest.offset_bytes),
4371 tdata->digest.len, digest_buffer);
4373 digest = rte_pktmbuf_read(ut_params->ibuf,
4374 (tdata->digest.offset_bytes == 0 ?
4375 plaintext_pad_len : tdata->digest.offset_bytes),
4376 tdata->digest.len, digest_buffer);
4378 debug_hexdump(stdout, "digest:", digest,
4380 debug_hexdump(stdout, "digest expected:",
4381 tdata->digest.data, tdata->digest.len);
4386 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4388 tdata->plaintext.data,
4389 tdata->plaintext.len >> 3,
4390 "SNOW 3G Plaintext data not as expected");
4392 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4394 tdata->ciphertext.data,
4395 tdata->validDataLenInBits.len,
4396 "SNOW 3G Ciphertext data not as expected");
4398 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4401 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4402 "SNOW 3G Generated auth tag not as expected");
4408 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4409 uint8_t op_mode, uint8_t verify)
4411 struct crypto_testsuite_params *ts_params = &testsuite_params;
4412 struct crypto_unittest_params *ut_params = &unittest_params;
4416 uint8_t *plaintext = NULL, *ciphertext = NULL;
4417 unsigned int plaintext_pad_len;
4418 unsigned int plaintext_len;
4419 unsigned int ciphertext_pad_len;
4420 unsigned int ciphertext_len;
4422 struct rte_cryptodev_info dev_info;
4424 /* Verify the capabilities */
4425 struct rte_cryptodev_sym_capability_idx cap_idx;
4426 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4427 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4428 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4431 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4432 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4433 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4437 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4439 uint64_t feat_flags = dev_info.feature_flags;
4441 if (op_mode == OUT_OF_PLACE) {
4442 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4443 printf("Device doesn't support digest encrypted.\n");
4448 /* Create KASUMI session */
4449 retval = create_wireless_algo_auth_cipher_session(
4450 ts_params->valid_devs[0],
4451 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4452 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4453 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4454 : RTE_CRYPTO_AUTH_OP_GENERATE),
4455 RTE_CRYPTO_AUTH_KASUMI_F9,
4456 RTE_CRYPTO_CIPHER_KASUMI_F8,
4457 tdata->key.data, tdata->key.len,
4458 0, tdata->digest.len,
4459 tdata->cipher_iv.len);
4464 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4465 if (op_mode == OUT_OF_PLACE)
4466 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4468 /* clear mbuf payload */
4469 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4470 rte_pktmbuf_tailroom(ut_params->ibuf));
4471 if (op_mode == OUT_OF_PLACE)
4472 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4473 rte_pktmbuf_tailroom(ut_params->obuf));
4475 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4476 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4477 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4478 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4481 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4482 ciphertext_pad_len);
4483 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4484 if (op_mode == OUT_OF_PLACE)
4485 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4486 debug_hexdump(stdout, "ciphertext:", ciphertext,
4489 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4491 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4492 if (op_mode == OUT_OF_PLACE)
4493 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4494 debug_hexdump(stdout, "plaintext:", plaintext,
4498 /* Create KASUMI operation */
4499 retval = create_wireless_algo_auth_cipher_operation(
4500 tdata->digest.data, tdata->digest.len,
4501 tdata->cipher_iv.data, tdata->cipher_iv.len,
4503 (tdata->digest.offset_bytes == 0 ?
4504 (verify ? ciphertext_pad_len : plaintext_pad_len)
4505 : tdata->digest.offset_bytes),
4506 tdata->validCipherLenInBits.len,
4507 tdata->validCipherOffsetInBits.len,
4508 tdata->validAuthLenInBits.len,
4510 op_mode, 0, verify);
4515 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4518 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4520 ut_params->obuf = (op_mode == IN_PLACE ?
4521 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4525 if (ut_params->obuf)
4526 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4529 plaintext = ciphertext;
4531 debug_hexdump(stdout, "plaintext:", plaintext,
4532 (tdata->plaintext.len >> 3) - tdata->digest.len);
4533 debug_hexdump(stdout, "plaintext expected:",
4534 tdata->plaintext.data,
4535 (tdata->plaintext.len >> 3) - tdata->digest.len);
4537 if (ut_params->obuf)
4538 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4541 ciphertext = plaintext;
4543 debug_hexdump(stdout, "ciphertext:", ciphertext,
4545 debug_hexdump(stdout, "ciphertext expected:",
4546 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4548 ut_params->digest = rte_pktmbuf_mtod(
4549 ut_params->obuf, uint8_t *) +
4550 (tdata->digest.offset_bytes == 0 ?
4551 plaintext_pad_len : tdata->digest.offset_bytes);
4553 debug_hexdump(stdout, "digest:", ut_params->digest,
4555 debug_hexdump(stdout, "digest expected:",
4556 tdata->digest.data, tdata->digest.len);
4561 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4563 tdata->plaintext.data,
4564 tdata->plaintext.len >> 3,
4565 "KASUMI Plaintext data not as expected");
4567 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4569 tdata->ciphertext.data,
4570 tdata->ciphertext.len >> 3,
4571 "KASUMI Ciphertext data not as expected");
4573 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4576 DIGEST_BYTE_LENGTH_KASUMI_F9,
4577 "KASUMI Generated auth tag not as expected");
4583 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4584 uint8_t op_mode, uint8_t verify)
4586 struct crypto_testsuite_params *ts_params = &testsuite_params;
4587 struct crypto_unittest_params *ut_params = &unittest_params;
4591 const uint8_t *plaintext = NULL;
4592 const uint8_t *ciphertext = NULL;
4593 const uint8_t *digest = NULL;
4594 unsigned int plaintext_pad_len;
4595 unsigned int plaintext_len;
4596 unsigned int ciphertext_pad_len;
4597 unsigned int ciphertext_len;
4598 uint8_t buffer[10000];
4599 uint8_t digest_buffer[10000];
4601 struct rte_cryptodev_info dev_info;
4603 /* Verify the capabilities */
4604 struct rte_cryptodev_sym_capability_idx cap_idx;
4605 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4606 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4607 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4610 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4611 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4612 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4616 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4618 uint64_t feat_flags = dev_info.feature_flags;
4620 if (op_mode == IN_PLACE) {
4621 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4622 printf("Device doesn't support in-place scatter-gather "
4623 "in both input and output mbufs.\n");
4627 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4628 printf("Device doesn't support out-of-place scatter-gather "
4629 "in both input and output mbufs.\n");
4632 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4633 printf("Device doesn't support digest encrypted.\n");
4638 /* Create KASUMI session */
4639 retval = create_wireless_algo_auth_cipher_session(
4640 ts_params->valid_devs[0],
4641 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4642 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4643 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4644 : RTE_CRYPTO_AUTH_OP_GENERATE),
4645 RTE_CRYPTO_AUTH_KASUMI_F9,
4646 RTE_CRYPTO_CIPHER_KASUMI_F8,
4647 tdata->key.data, tdata->key.len,
4648 0, tdata->digest.len,
4649 tdata->cipher_iv.len);
4654 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4655 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4656 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4657 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4659 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4660 plaintext_pad_len, 15, 0);
4661 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4662 "Failed to allocate input buffer in mempool");
4664 if (op_mode == OUT_OF_PLACE) {
4665 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4666 plaintext_pad_len, 15, 0);
4667 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4668 "Failed to allocate output buffer in mempool");
4672 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4673 tdata->ciphertext.data);
4674 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4675 ciphertext_len, buffer);
4676 debug_hexdump(stdout, "ciphertext:", ciphertext,
4679 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4680 tdata->plaintext.data);
4681 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4682 plaintext_len, buffer);
4683 debug_hexdump(stdout, "plaintext:", plaintext,
4686 memset(buffer, 0, sizeof(buffer));
4688 /* Create KASUMI operation */
4689 retval = create_wireless_algo_auth_cipher_operation(
4690 tdata->digest.data, tdata->digest.len,
4691 tdata->cipher_iv.data, tdata->cipher_iv.len,
4693 (tdata->digest.offset_bytes == 0 ?
4694 (verify ? ciphertext_pad_len : plaintext_pad_len)
4695 : tdata->digest.offset_bytes),
4696 tdata->validCipherLenInBits.len,
4697 tdata->validCipherOffsetInBits.len,
4698 tdata->validAuthLenInBits.len,
4700 op_mode, 1, verify);
4705 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4708 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4710 ut_params->obuf = (op_mode == IN_PLACE ?
4711 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4714 if (ut_params->obuf)
4715 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4716 plaintext_len, buffer);
4718 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4719 plaintext_len, buffer);
4721 debug_hexdump(stdout, "plaintext:", plaintext,
4722 (tdata->plaintext.len >> 3) - tdata->digest.len);
4723 debug_hexdump(stdout, "plaintext expected:",
4724 tdata->plaintext.data,
4725 (tdata->plaintext.len >> 3) - tdata->digest.len);
4727 if (ut_params->obuf)
4728 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4729 ciphertext_len, buffer);
4731 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4732 ciphertext_len, buffer);
4734 debug_hexdump(stdout, "ciphertext:", ciphertext,
4736 debug_hexdump(stdout, "ciphertext expected:",
4737 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4739 if (ut_params->obuf)
4740 digest = rte_pktmbuf_read(ut_params->obuf,
4741 (tdata->digest.offset_bytes == 0 ?
4742 plaintext_pad_len : tdata->digest.offset_bytes),
4743 tdata->digest.len, digest_buffer);
4745 digest = rte_pktmbuf_read(ut_params->ibuf,
4746 (tdata->digest.offset_bytes == 0 ?
4747 plaintext_pad_len : tdata->digest.offset_bytes),
4748 tdata->digest.len, digest_buffer);
4750 debug_hexdump(stdout, "digest:", digest,
4752 debug_hexdump(stdout, "digest expected:",
4753 tdata->digest.data, tdata->digest.len);
4758 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4760 tdata->plaintext.data,
4761 tdata->plaintext.len >> 3,
4762 "KASUMI Plaintext data not as expected");
4764 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4766 tdata->ciphertext.data,
4767 tdata->validDataLenInBits.len,
4768 "KASUMI Ciphertext data not as expected");
4770 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4773 DIGEST_BYTE_LENGTH_KASUMI_F9,
4774 "KASUMI Generated auth tag not as expected");
4780 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4782 struct crypto_testsuite_params *ts_params = &testsuite_params;
4783 struct crypto_unittest_params *ut_params = &unittest_params;
4787 uint8_t *plaintext, *ciphertext;
4788 unsigned plaintext_pad_len;
4789 unsigned plaintext_len;
4791 /* Verify the capabilities */
4792 struct rte_cryptodev_sym_capability_idx cap_idx;
4793 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4794 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4795 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4798 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4799 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4800 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4804 /* Create KASUMI session */
4805 retval = create_wireless_algo_cipher_auth_session(
4806 ts_params->valid_devs[0],
4807 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4808 RTE_CRYPTO_AUTH_OP_GENERATE,
4809 RTE_CRYPTO_AUTH_KASUMI_F9,
4810 RTE_CRYPTO_CIPHER_KASUMI_F8,
4811 tdata->key.data, tdata->key.len,
4812 0, tdata->digest.len,
4813 tdata->cipher_iv.len);
4817 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4819 /* clear mbuf payload */
4820 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4821 rte_pktmbuf_tailroom(ut_params->ibuf));
4823 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4824 /* Append data which is padded to a multiple of */
4825 /* the algorithms block size */
4826 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4827 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4829 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4831 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4833 /* Create KASUMI operation */
4834 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4835 tdata->digest.len, NULL, 0,
4836 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4837 tdata->cipher_iv.data, tdata->cipher_iv.len,
4838 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4839 tdata->validCipherOffsetInBits.len,
4840 tdata->validAuthLenInBits.len,
4846 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4848 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4850 if (ut_params->op->sym->m_dst)
4851 ut_params->obuf = ut_params->op->sym->m_dst;
4853 ut_params->obuf = ut_params->op->sym->m_src;
4855 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4856 tdata->validCipherOffsetInBits.len >> 3);
4858 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4859 + plaintext_pad_len;
4861 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4862 (tdata->validCipherOffsetInBits.len >> 3);
4864 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4866 reference_ciphertext,
4867 tdata->validCipherLenInBits.len,
4868 "KASUMI Ciphertext data not as expected");
4871 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4874 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4875 "KASUMI Generated auth tag not as expected");
4880 test_zuc_encryption(const struct wireless_test_data *tdata)
4882 struct crypto_testsuite_params *ts_params = &testsuite_params;
4883 struct crypto_unittest_params *ut_params = &unittest_params;
4886 uint8_t *plaintext, *ciphertext;
4887 unsigned plaintext_pad_len;
4888 unsigned plaintext_len;
4890 struct rte_cryptodev_sym_capability_idx cap_idx;
4892 /* Check if device supports ZUC EEA3 */
4893 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4894 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4896 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4900 /* Create ZUC session */
4901 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4902 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4903 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4904 tdata->key.data, tdata->key.len,
4905 tdata->cipher_iv.len);
4909 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4911 /* Clear mbuf payload */
4912 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4913 rte_pktmbuf_tailroom(ut_params->ibuf));
4915 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4916 /* Append data which is padded to a multiple */
4917 /* of the algorithms block size */
4918 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4919 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4921 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4923 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4925 /* Create ZUC operation */
4926 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4927 tdata->cipher_iv.len,
4928 tdata->plaintext.len,
4933 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4935 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4937 ut_params->obuf = ut_params->op->sym->m_dst;
4938 if (ut_params->obuf)
4939 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4941 ciphertext = plaintext;
4943 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4946 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4948 tdata->ciphertext.data,
4949 tdata->validCipherLenInBits.len,
4950 "ZUC Ciphertext data not as expected");
4955 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4957 struct crypto_testsuite_params *ts_params = &testsuite_params;
4958 struct crypto_unittest_params *ut_params = &unittest_params;
4962 unsigned int plaintext_pad_len;
4963 unsigned int plaintext_len;
4964 const uint8_t *ciphertext;
4965 uint8_t ciphertext_buffer[2048];
4966 struct rte_cryptodev_info dev_info;
4968 struct rte_cryptodev_sym_capability_idx cap_idx;
4970 /* Check if device supports ZUC EEA3 */
4971 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4972 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4974 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4978 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4980 uint64_t feat_flags = dev_info.feature_flags;
4982 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4983 printf("Device doesn't support in-place scatter-gather. "
4988 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4990 /* Append data which is padded to a multiple */
4991 /* of the algorithms block size */
4992 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4994 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4995 plaintext_pad_len, 10, 0);
4997 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4998 tdata->plaintext.data);
5000 /* Create ZUC session */
5001 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5002 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5003 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5004 tdata->key.data, tdata->key.len,
5005 tdata->cipher_iv.len);
5009 /* Clear mbuf payload */
5011 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5013 /* Create ZUC operation */
5014 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5015 tdata->cipher_iv.len, tdata->plaintext.len,
5020 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5022 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5024 ut_params->obuf = ut_params->op->sym->m_dst;
5025 if (ut_params->obuf)
5026 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5027 0, plaintext_len, ciphertext_buffer);
5029 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5030 0, plaintext_len, ciphertext_buffer);
5033 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5036 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5038 tdata->ciphertext.data,
5039 tdata->validCipherLenInBits.len,
5040 "ZUC Ciphertext data not as expected");
5046 test_zuc_authentication(const struct wireless_test_data *tdata)
5048 struct crypto_testsuite_params *ts_params = &testsuite_params;
5049 struct crypto_unittest_params *ut_params = &unittest_params;
5052 unsigned plaintext_pad_len;
5053 unsigned plaintext_len;
5056 struct rte_cryptodev_sym_capability_idx cap_idx;
5057 struct rte_cryptodev_info dev_info;
5059 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5060 uint64_t feat_flags = dev_info.feature_flags;
5062 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5063 (tdata->validAuthLenInBits.len % 8 != 0)) {
5064 printf("Device doesn't support NON-Byte Aligned Data.\n");
5068 /* Check if device supports ZUC EIA3 */
5069 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5070 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5072 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5076 /* Create ZUC session */
5077 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5078 tdata->key.data, tdata->key.len,
5079 tdata->auth_iv.len, tdata->digest.len,
5080 RTE_CRYPTO_AUTH_OP_GENERATE,
5081 RTE_CRYPTO_AUTH_ZUC_EIA3);
5085 /* alloc mbuf and set payload */
5086 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5088 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5089 rte_pktmbuf_tailroom(ut_params->ibuf));
5091 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5092 /* Append data which is padded to a multiple of */
5093 /* the algorithms block size */
5094 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5095 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5097 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5099 /* Create ZUC operation */
5100 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5101 tdata->auth_iv.data, tdata->auth_iv.len,
5102 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5103 tdata->validAuthLenInBits.len,
5108 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5110 ut_params->obuf = ut_params->op->sym->m_src;
5111 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5112 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5113 + plaintext_pad_len;
5116 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5120 "ZUC Generated auth tag not as expected");
5126 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5127 uint8_t op_mode, uint8_t verify)
5129 struct crypto_testsuite_params *ts_params = &testsuite_params;
5130 struct crypto_unittest_params *ut_params = &unittest_params;
5134 uint8_t *plaintext = NULL, *ciphertext = NULL;
5135 unsigned int plaintext_pad_len;
5136 unsigned int plaintext_len;
5137 unsigned int ciphertext_pad_len;
5138 unsigned int ciphertext_len;
5140 struct rte_cryptodev_info dev_info;
5141 struct rte_cryptodev_sym_capability_idx cap_idx;
5143 /* Check if device supports ZUC EIA3 */
5144 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5145 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5147 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5151 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5153 uint64_t feat_flags = dev_info.feature_flags;
5155 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5156 printf("Device doesn't support digest encrypted.\n");
5159 if (op_mode == IN_PLACE) {
5160 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5161 printf("Device doesn't support in-place scatter-gather "
5162 "in both input and output mbufs.\n");
5166 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5167 printf("Device doesn't support out-of-place scatter-gather "
5168 "in both input and output mbufs.\n");
5173 /* Create ZUC session */
5174 retval = create_wireless_algo_auth_cipher_session(
5175 ts_params->valid_devs[0],
5176 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5177 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5178 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5179 : RTE_CRYPTO_AUTH_OP_GENERATE),
5180 RTE_CRYPTO_AUTH_ZUC_EIA3,
5181 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5182 tdata->key.data, tdata->key.len,
5183 tdata->auth_iv.len, tdata->digest.len,
5184 tdata->cipher_iv.len);
5189 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5190 if (op_mode == OUT_OF_PLACE)
5191 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5193 /* clear mbuf payload */
5194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5195 rte_pktmbuf_tailroom(ut_params->ibuf));
5196 if (op_mode == OUT_OF_PLACE)
5197 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5198 rte_pktmbuf_tailroom(ut_params->obuf));
5200 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5201 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5202 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5203 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5206 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5207 ciphertext_pad_len);
5208 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5209 if (op_mode == OUT_OF_PLACE)
5210 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5211 debug_hexdump(stdout, "ciphertext:", ciphertext,
5214 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5216 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5217 if (op_mode == OUT_OF_PLACE)
5218 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5219 debug_hexdump(stdout, "plaintext:", plaintext,
5223 /* Create ZUC operation */
5224 retval = create_wireless_algo_auth_cipher_operation(
5225 tdata->digest.data, tdata->digest.len,
5226 tdata->cipher_iv.data, tdata->cipher_iv.len,
5227 tdata->auth_iv.data, tdata->auth_iv.len,
5228 (tdata->digest.offset_bytes == 0 ?
5229 (verify ? ciphertext_pad_len : plaintext_pad_len)
5230 : tdata->digest.offset_bytes),
5231 tdata->validCipherLenInBits.len,
5232 tdata->validCipherOffsetInBits.len,
5233 tdata->validAuthLenInBits.len,
5235 op_mode, 0, verify);
5240 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5243 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5245 ut_params->obuf = (op_mode == IN_PLACE ?
5246 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5250 if (ut_params->obuf)
5251 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5254 plaintext = ciphertext;
5256 debug_hexdump(stdout, "plaintext:", plaintext,
5257 (tdata->plaintext.len >> 3) - tdata->digest.len);
5258 debug_hexdump(stdout, "plaintext expected:",
5259 tdata->plaintext.data,
5260 (tdata->plaintext.len >> 3) - tdata->digest.len);
5262 if (ut_params->obuf)
5263 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5266 ciphertext = plaintext;
5268 debug_hexdump(stdout, "ciphertext:", ciphertext,
5270 debug_hexdump(stdout, "ciphertext expected:",
5271 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5273 ut_params->digest = rte_pktmbuf_mtod(
5274 ut_params->obuf, uint8_t *) +
5275 (tdata->digest.offset_bytes == 0 ?
5276 plaintext_pad_len : tdata->digest.offset_bytes);
5278 debug_hexdump(stdout, "digest:", ut_params->digest,
5280 debug_hexdump(stdout, "digest expected:",
5281 tdata->digest.data, tdata->digest.len);
5286 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5288 tdata->plaintext.data,
5289 tdata->plaintext.len >> 3,
5290 "ZUC Plaintext data not as expected");
5292 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5294 tdata->ciphertext.data,
5295 tdata->ciphertext.len >> 3,
5296 "ZUC Ciphertext data not as expected");
5298 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5301 DIGEST_BYTE_LENGTH_KASUMI_F9,
5302 "ZUC Generated auth tag not as expected");
5308 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5309 uint8_t op_mode, uint8_t verify)
5311 struct crypto_testsuite_params *ts_params = &testsuite_params;
5312 struct crypto_unittest_params *ut_params = &unittest_params;
5316 const uint8_t *plaintext = NULL;
5317 const uint8_t *ciphertext = NULL;
5318 const uint8_t *digest = NULL;
5319 unsigned int plaintext_pad_len;
5320 unsigned int plaintext_len;
5321 unsigned int ciphertext_pad_len;
5322 unsigned int ciphertext_len;
5323 uint8_t buffer[10000];
5324 uint8_t digest_buffer[10000];
5326 struct rte_cryptodev_info dev_info;
5327 struct rte_cryptodev_sym_capability_idx cap_idx;
5329 /* Check if device supports ZUC EIA3 */
5330 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5331 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5333 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5337 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5339 uint64_t feat_flags = dev_info.feature_flags;
5341 if (op_mode == IN_PLACE) {
5342 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5343 printf("Device doesn't support in-place scatter-gather "
5344 "in both input and output mbufs.\n");
5348 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5349 printf("Device doesn't support out-of-place scatter-gather "
5350 "in both input and output mbufs.\n");
5353 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5354 printf("Device doesn't support digest encrypted.\n");
5359 /* Create ZUC session */
5360 retval = create_wireless_algo_auth_cipher_session(
5361 ts_params->valid_devs[0],
5362 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5363 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5364 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5365 : RTE_CRYPTO_AUTH_OP_GENERATE),
5366 RTE_CRYPTO_AUTH_ZUC_EIA3,
5367 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5368 tdata->key.data, tdata->key.len,
5369 tdata->auth_iv.len, tdata->digest.len,
5370 tdata->cipher_iv.len);
5375 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5376 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5377 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5378 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5380 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5381 plaintext_pad_len, 15, 0);
5382 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5383 "Failed to allocate input buffer in mempool");
5385 if (op_mode == OUT_OF_PLACE) {
5386 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5387 plaintext_pad_len, 15, 0);
5388 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5389 "Failed to allocate output buffer in mempool");
5393 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5394 tdata->ciphertext.data);
5395 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5396 ciphertext_len, buffer);
5397 debug_hexdump(stdout, "ciphertext:", ciphertext,
5400 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5401 tdata->plaintext.data);
5402 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5403 plaintext_len, buffer);
5404 debug_hexdump(stdout, "plaintext:", plaintext,
5407 memset(buffer, 0, sizeof(buffer));
5409 /* Create ZUC operation */
5410 retval = create_wireless_algo_auth_cipher_operation(
5411 tdata->digest.data, tdata->digest.len,
5412 tdata->cipher_iv.data, tdata->cipher_iv.len,
5414 (tdata->digest.offset_bytes == 0 ?
5415 (verify ? ciphertext_pad_len : plaintext_pad_len)
5416 : tdata->digest.offset_bytes),
5417 tdata->validCipherLenInBits.len,
5418 tdata->validCipherOffsetInBits.len,
5419 tdata->validAuthLenInBits.len,
5421 op_mode, 1, verify);
5426 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5429 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5431 ut_params->obuf = (op_mode == IN_PLACE ?
5432 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5435 if (ut_params->obuf)
5436 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5437 plaintext_len, buffer);
5439 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5440 plaintext_len, buffer);
5442 debug_hexdump(stdout, "plaintext:", plaintext,
5443 (tdata->plaintext.len >> 3) - tdata->digest.len);
5444 debug_hexdump(stdout, "plaintext expected:",
5445 tdata->plaintext.data,
5446 (tdata->plaintext.len >> 3) - tdata->digest.len);
5448 if (ut_params->obuf)
5449 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5450 ciphertext_len, buffer);
5452 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5453 ciphertext_len, buffer);
5455 debug_hexdump(stdout, "ciphertext:", ciphertext,
5457 debug_hexdump(stdout, "ciphertext expected:",
5458 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5460 if (ut_params->obuf)
5461 digest = rte_pktmbuf_read(ut_params->obuf,
5462 (tdata->digest.offset_bytes == 0 ?
5463 plaintext_pad_len : tdata->digest.offset_bytes),
5464 tdata->digest.len, digest_buffer);
5466 digest = rte_pktmbuf_read(ut_params->ibuf,
5467 (tdata->digest.offset_bytes == 0 ?
5468 plaintext_pad_len : tdata->digest.offset_bytes),
5469 tdata->digest.len, digest_buffer);
5471 debug_hexdump(stdout, "digest:", digest,
5473 debug_hexdump(stdout, "digest expected:",
5474 tdata->digest.data, tdata->digest.len);
5479 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5481 tdata->plaintext.data,
5482 tdata->plaintext.len >> 3,
5483 "ZUC Plaintext data not as expected");
5485 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5487 tdata->ciphertext.data,
5488 tdata->validDataLenInBits.len,
5489 "ZUC Ciphertext data not as expected");
5491 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5494 DIGEST_BYTE_LENGTH_KASUMI_F9,
5495 "ZUC Generated auth tag not as expected");
5501 test_kasumi_encryption_test_case_1(void)
5503 return test_kasumi_encryption(&kasumi_test_case_1);
5507 test_kasumi_encryption_test_case_1_sgl(void)
5509 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5513 test_kasumi_encryption_test_case_1_oop(void)
5515 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5519 test_kasumi_encryption_test_case_1_oop_sgl(void)
5521 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5525 test_kasumi_encryption_test_case_2(void)
5527 return test_kasumi_encryption(&kasumi_test_case_2);
5531 test_kasumi_encryption_test_case_3(void)
5533 return test_kasumi_encryption(&kasumi_test_case_3);
5537 test_kasumi_encryption_test_case_4(void)
5539 return test_kasumi_encryption(&kasumi_test_case_4);
5543 test_kasumi_encryption_test_case_5(void)
5545 return test_kasumi_encryption(&kasumi_test_case_5);
5549 test_kasumi_decryption_test_case_1(void)
5551 return test_kasumi_decryption(&kasumi_test_case_1);
5555 test_kasumi_decryption_test_case_1_oop(void)
5557 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5561 test_kasumi_decryption_test_case_2(void)
5563 return test_kasumi_decryption(&kasumi_test_case_2);
5567 test_kasumi_decryption_test_case_3(void)
5569 return test_kasumi_decryption(&kasumi_test_case_3);
5573 test_kasumi_decryption_test_case_4(void)
5575 return test_kasumi_decryption(&kasumi_test_case_4);
5579 test_kasumi_decryption_test_case_5(void)
5581 return test_kasumi_decryption(&kasumi_test_case_5);
5584 test_snow3g_encryption_test_case_1(void)
5586 return test_snow3g_encryption(&snow3g_test_case_1);
5590 test_snow3g_encryption_test_case_1_oop(void)
5592 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5596 test_snow3g_encryption_test_case_1_oop_sgl(void)
5598 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5603 test_snow3g_encryption_test_case_1_offset_oop(void)
5605 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5609 test_snow3g_encryption_test_case_2(void)
5611 return test_snow3g_encryption(&snow3g_test_case_2);
5615 test_snow3g_encryption_test_case_3(void)
5617 return test_snow3g_encryption(&snow3g_test_case_3);
5621 test_snow3g_encryption_test_case_4(void)
5623 return test_snow3g_encryption(&snow3g_test_case_4);
5627 test_snow3g_encryption_test_case_5(void)
5629 return test_snow3g_encryption(&snow3g_test_case_5);
5633 test_snow3g_decryption_test_case_1(void)
5635 return test_snow3g_decryption(&snow3g_test_case_1);
5639 test_snow3g_decryption_test_case_1_oop(void)
5641 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5645 test_snow3g_decryption_test_case_2(void)
5647 return test_snow3g_decryption(&snow3g_test_case_2);
5651 test_snow3g_decryption_test_case_3(void)
5653 return test_snow3g_decryption(&snow3g_test_case_3);
5657 test_snow3g_decryption_test_case_4(void)
5659 return test_snow3g_decryption(&snow3g_test_case_4);
5663 test_snow3g_decryption_test_case_5(void)
5665 return test_snow3g_decryption(&snow3g_test_case_5);
5669 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5670 * Pattern digest from snow3g_test_data must be allocated as
5671 * 4 last bytes in plaintext.
5674 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5675 struct snow3g_hash_test_data *output)
5677 if ((pattern != NULL) && (output != NULL)) {
5678 output->key.len = pattern->key.len;
5680 memcpy(output->key.data,
5681 pattern->key.data, pattern->key.len);
5683 output->auth_iv.len = pattern->auth_iv.len;
5685 memcpy(output->auth_iv.data,
5686 pattern->auth_iv.data, pattern->auth_iv.len);
5688 output->plaintext.len = pattern->plaintext.len;
5690 memcpy(output->plaintext.data,
5691 pattern->plaintext.data, pattern->plaintext.len >> 3);
5693 output->digest.len = pattern->digest.len;
5695 memcpy(output->digest.data,
5696 &pattern->plaintext.data[pattern->digest.offset_bytes],
5697 pattern->digest.len);
5699 output->validAuthLenInBits.len =
5700 pattern->validAuthLenInBits.len;
5705 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5708 test_snow3g_decryption_with_digest_test_case_1(void)
5710 struct snow3g_hash_test_data snow3g_hash_data;
5713 * Function prepare data for hash veryfication test case.
5714 * Digest is allocated in 4 last bytes in plaintext, pattern.
5716 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5718 return test_snow3g_decryption(&snow3g_test_case_7) &
5719 test_snow3g_authentication_verify(&snow3g_hash_data);
5723 test_snow3g_cipher_auth_test_case_1(void)
5725 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5729 test_snow3g_auth_cipher_test_case_1(void)
5731 return test_snow3g_auth_cipher(
5732 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5736 test_snow3g_auth_cipher_test_case_2(void)
5738 return test_snow3g_auth_cipher(
5739 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5743 test_snow3g_auth_cipher_test_case_2_oop(void)
5745 return test_snow3g_auth_cipher(
5746 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5750 test_snow3g_auth_cipher_part_digest_enc(void)
5752 return test_snow3g_auth_cipher(
5753 &snow3g_auth_cipher_partial_digest_encryption,
5758 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5760 return test_snow3g_auth_cipher(
5761 &snow3g_auth_cipher_partial_digest_encryption,
5766 test_snow3g_auth_cipher_test_case_3_sgl(void)
5768 return test_snow3g_auth_cipher_sgl(
5769 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5773 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5775 return test_snow3g_auth_cipher_sgl(
5776 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5780 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5782 return test_snow3g_auth_cipher_sgl(
5783 &snow3g_auth_cipher_partial_digest_encryption,
5788 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5790 return test_snow3g_auth_cipher_sgl(
5791 &snow3g_auth_cipher_partial_digest_encryption,
5796 test_snow3g_auth_cipher_verify_test_case_1(void)
5798 return test_snow3g_auth_cipher(
5799 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5803 test_snow3g_auth_cipher_verify_test_case_2(void)
5805 return test_snow3g_auth_cipher(
5806 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5810 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5812 return test_snow3g_auth_cipher(
5813 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5817 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5819 return test_snow3g_auth_cipher(
5820 &snow3g_auth_cipher_partial_digest_encryption,
5825 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5827 return test_snow3g_auth_cipher(
5828 &snow3g_auth_cipher_partial_digest_encryption,
5833 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5835 return test_snow3g_auth_cipher_sgl(
5836 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5840 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5842 return test_snow3g_auth_cipher_sgl(
5843 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5847 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5849 return test_snow3g_auth_cipher_sgl(
5850 &snow3g_auth_cipher_partial_digest_encryption,
5855 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5857 return test_snow3g_auth_cipher_sgl(
5858 &snow3g_auth_cipher_partial_digest_encryption,
5863 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5865 return test_snow3g_auth_cipher(
5866 &snow3g_test_case_7, IN_PLACE, 0);
5870 test_kasumi_auth_cipher_test_case_1(void)
5872 return test_kasumi_auth_cipher(
5873 &kasumi_test_case_3, IN_PLACE, 0);
5877 test_kasumi_auth_cipher_test_case_2(void)
5879 return test_kasumi_auth_cipher(
5880 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5884 test_kasumi_auth_cipher_test_case_2_oop(void)
5886 return test_kasumi_auth_cipher(
5887 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5891 test_kasumi_auth_cipher_test_case_2_sgl(void)
5893 return test_kasumi_auth_cipher_sgl(
5894 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5898 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5900 return test_kasumi_auth_cipher_sgl(
5901 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5905 test_kasumi_auth_cipher_verify_test_case_1(void)
5907 return test_kasumi_auth_cipher(
5908 &kasumi_test_case_3, IN_PLACE, 1);
5912 test_kasumi_auth_cipher_verify_test_case_2(void)
5914 return test_kasumi_auth_cipher(
5915 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5919 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5921 return test_kasumi_auth_cipher(
5922 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5926 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5928 return test_kasumi_auth_cipher_sgl(
5929 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5933 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5935 return test_kasumi_auth_cipher_sgl(
5936 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5940 test_kasumi_cipher_auth_test_case_1(void)
5942 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5946 test_zuc_encryption_test_case_1(void)
5948 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5952 test_zuc_encryption_test_case_2(void)
5954 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5958 test_zuc_encryption_test_case_3(void)
5960 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5964 test_zuc_encryption_test_case_4(void)
5966 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5970 test_zuc_encryption_test_case_5(void)
5972 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5976 test_zuc_encryption_test_case_6_sgl(void)
5978 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5982 test_zuc_hash_generate_test_case_1(void)
5984 return test_zuc_authentication(&zuc_test_case_auth_1b);
5988 test_zuc_hash_generate_test_case_2(void)
5990 return test_zuc_authentication(&zuc_test_case_auth_90b);
5994 test_zuc_hash_generate_test_case_3(void)
5996 return test_zuc_authentication(&zuc_test_case_auth_577b);
6000 test_zuc_hash_generate_test_case_4(void)
6002 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6006 test_zuc_hash_generate_test_case_5(void)
6008 return test_zuc_authentication(&zuc_test_auth_5670b);
6012 test_zuc_hash_generate_test_case_6(void)
6014 return test_zuc_authentication(&zuc_test_case_auth_128b);
6018 test_zuc_hash_generate_test_case_7(void)
6020 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6024 test_zuc_hash_generate_test_case_8(void)
6026 return test_zuc_authentication(&zuc_test_case_auth_584b);
6030 test_zuc_cipher_auth_test_case_1(void)
6032 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6036 test_zuc_cipher_auth_test_case_2(void)
6038 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6042 test_zuc_auth_cipher_test_case_1(void)
6044 return test_zuc_auth_cipher(
6045 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6049 test_zuc_auth_cipher_test_case_1_oop(void)
6051 return test_zuc_auth_cipher(
6052 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6056 test_zuc_auth_cipher_test_case_1_sgl(void)
6058 return test_zuc_auth_cipher_sgl(
6059 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6063 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6065 return test_zuc_auth_cipher_sgl(
6066 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6070 test_zuc_auth_cipher_verify_test_case_1(void)
6072 return test_zuc_auth_cipher(
6073 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6077 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6079 return test_zuc_auth_cipher(
6080 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6084 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6086 return test_zuc_auth_cipher_sgl(
6087 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6091 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6093 return test_zuc_auth_cipher_sgl(
6094 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6098 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6100 uint8_t dev_id = testsuite_params.valid_devs[0];
6102 struct rte_cryptodev_sym_capability_idx cap_idx;
6104 /* Check if device supports particular cipher algorithm */
6105 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6106 cap_idx.algo.cipher = tdata->cipher_algo;
6107 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6110 /* Check if device supports particular hash algorithm */
6111 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6112 cap_idx.algo.auth = tdata->auth_algo;
6113 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6120 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6121 uint8_t op_mode, uint8_t verify)
6123 struct crypto_testsuite_params *ts_params = &testsuite_params;
6124 struct crypto_unittest_params *ut_params = &unittest_params;
6128 uint8_t *plaintext = NULL, *ciphertext = NULL;
6129 unsigned int plaintext_pad_len;
6130 unsigned int plaintext_len;
6131 unsigned int ciphertext_pad_len;
6132 unsigned int ciphertext_len;
6134 struct rte_cryptodev_info dev_info;
6135 struct rte_crypto_op *op;
6137 /* Check if device supports particular algorithms separately */
6138 if (test_mixed_check_if_unsupported(tdata))
6141 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6143 uint64_t feat_flags = dev_info.feature_flags;
6145 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6146 printf("Device doesn't support digest encrypted.\n");
6150 /* Create the session */
6152 retval = create_wireless_algo_cipher_auth_session(
6153 ts_params->valid_devs[0],
6154 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6155 RTE_CRYPTO_AUTH_OP_VERIFY,
6158 tdata->auth_key.data, tdata->auth_key.len,
6159 tdata->auth_iv.len, tdata->digest_enc.len,
6160 tdata->cipher_iv.len);
6162 retval = create_wireless_algo_auth_cipher_session(
6163 ts_params->valid_devs[0],
6164 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6165 RTE_CRYPTO_AUTH_OP_GENERATE,
6168 tdata->auth_key.data, tdata->auth_key.len,
6169 tdata->auth_iv.len, tdata->digest_enc.len,
6170 tdata->cipher_iv.len);
6174 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6175 if (op_mode == OUT_OF_PLACE)
6176 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6178 /* clear mbuf payload */
6179 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6180 rte_pktmbuf_tailroom(ut_params->ibuf));
6181 if (op_mode == OUT_OF_PLACE)
6182 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6183 rte_pktmbuf_tailroom(ut_params->obuf));
6185 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6186 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6187 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6188 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6191 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6192 ciphertext_pad_len);
6193 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6194 if (op_mode == OUT_OF_PLACE)
6195 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6196 debug_hexdump(stdout, "ciphertext:", ciphertext,
6199 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6201 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6202 if (op_mode == OUT_OF_PLACE)
6203 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6204 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6207 /* Create the operation */
6208 retval = create_wireless_algo_auth_cipher_operation(
6209 tdata->digest_enc.data, tdata->digest_enc.len,
6210 tdata->cipher_iv.data, tdata->cipher_iv.len,
6211 tdata->auth_iv.data, tdata->auth_iv.len,
6212 (tdata->digest_enc.offset == 0 ?
6214 : tdata->digest_enc.offset),
6215 tdata->validCipherLen.len_bits,
6216 tdata->cipher.offset_bits,
6217 tdata->validAuthLen.len_bits,
6218 tdata->auth.offset_bits,
6219 op_mode, 0, verify);
6224 op = process_crypto_request(ts_params->valid_devs[0],
6227 /* Check if the op failed because the device doesn't */
6228 /* support this particular combination of algorithms */
6229 if (op == NULL && ut_params->op->status ==
6230 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6231 printf("Device doesn't support this mixed combination. "
6237 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6239 ut_params->obuf = (op_mode == IN_PLACE ?
6240 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6243 if (ut_params->obuf)
6244 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6247 plaintext = ciphertext +
6248 (tdata->cipher.offset_bits >> 3);
6250 debug_hexdump(stdout, "plaintext:", plaintext,
6251 tdata->plaintext.len_bits >> 3);
6252 debug_hexdump(stdout, "plaintext expected:",
6253 tdata->plaintext.data,
6254 tdata->plaintext.len_bits >> 3);
6256 if (ut_params->obuf)
6257 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6260 ciphertext = plaintext;
6262 debug_hexdump(stdout, "ciphertext:", ciphertext,
6264 debug_hexdump(stdout, "ciphertext expected:",
6265 tdata->ciphertext.data,
6266 tdata->ciphertext.len_bits >> 3);
6268 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6269 + (tdata->digest_enc.offset == 0 ?
6270 plaintext_pad_len : tdata->digest_enc.offset);
6272 debug_hexdump(stdout, "digest:", ut_params->digest,
6273 tdata->digest_enc.len);
6274 debug_hexdump(stdout, "digest expected:",
6275 tdata->digest_enc.data,
6276 tdata->digest_enc.len);
6281 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6283 tdata->plaintext.data,
6284 tdata->plaintext.len_bits >> 3,
6285 "Plaintext data not as expected");
6287 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6289 tdata->ciphertext.data,
6290 tdata->validDataLen.len_bits,
6291 "Ciphertext data not as expected");
6293 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6295 tdata->digest_enc.data,
6296 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6297 "Generated auth tag not as expected");
6300 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6301 "crypto op processing failed");
6307 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6308 uint8_t op_mode, uint8_t verify)
6310 struct crypto_testsuite_params *ts_params = &testsuite_params;
6311 struct crypto_unittest_params *ut_params = &unittest_params;
6315 const uint8_t *plaintext = NULL;
6316 const uint8_t *ciphertext = NULL;
6317 const uint8_t *digest = NULL;
6318 unsigned int plaintext_pad_len;
6319 unsigned int plaintext_len;
6320 unsigned int ciphertext_pad_len;
6321 unsigned int ciphertext_len;
6322 uint8_t buffer[10000];
6323 uint8_t digest_buffer[10000];
6325 struct rte_cryptodev_info dev_info;
6326 struct rte_crypto_op *op;
6328 /* Check if device supports particular algorithms */
6329 if (test_mixed_check_if_unsupported(tdata))
6332 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6334 uint64_t feat_flags = dev_info.feature_flags;
6336 if (op_mode == IN_PLACE) {
6337 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6338 printf("Device doesn't support in-place scatter-gather "
6339 "in both input and output mbufs.\n");
6343 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6344 printf("Device doesn't support out-of-place scatter-gather "
6345 "in both input and output mbufs.\n");
6348 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6349 printf("Device doesn't support digest encrypted.\n");
6354 /* Create the session */
6356 retval = create_wireless_algo_cipher_auth_session(
6357 ts_params->valid_devs[0],
6358 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6359 RTE_CRYPTO_AUTH_OP_VERIFY,
6362 tdata->auth_key.data, tdata->auth_key.len,
6363 tdata->auth_iv.len, tdata->digest_enc.len,
6364 tdata->cipher_iv.len);
6366 retval = create_wireless_algo_auth_cipher_session(
6367 ts_params->valid_devs[0],
6368 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6369 RTE_CRYPTO_AUTH_OP_GENERATE,
6372 tdata->auth_key.data, tdata->auth_key.len,
6373 tdata->auth_iv.len, tdata->digest_enc.len,
6374 tdata->cipher_iv.len);
6378 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6379 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6380 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6381 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6383 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6384 ciphertext_pad_len, 15, 0);
6385 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6386 "Failed to allocate input buffer in mempool");
6388 if (op_mode == OUT_OF_PLACE) {
6389 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6390 plaintext_pad_len, 15, 0);
6391 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6392 "Failed to allocate output buffer in mempool");
6396 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6397 tdata->ciphertext.data);
6398 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6399 ciphertext_len, buffer);
6400 debug_hexdump(stdout, "ciphertext:", ciphertext,
6403 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6404 tdata->plaintext.data);
6405 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6406 plaintext_len, buffer);
6407 debug_hexdump(stdout, "plaintext:", plaintext,
6410 memset(buffer, 0, sizeof(buffer));
6412 /* Create the operation */
6413 retval = create_wireless_algo_auth_cipher_operation(
6414 tdata->digest_enc.data, tdata->digest_enc.len,
6415 tdata->cipher_iv.data, tdata->cipher_iv.len,
6416 tdata->auth_iv.data, tdata->auth_iv.len,
6417 (tdata->digest_enc.offset == 0 ?
6419 : tdata->digest_enc.offset),
6420 tdata->validCipherLen.len_bits,
6421 tdata->cipher.offset_bits,
6422 tdata->validAuthLen.len_bits,
6423 tdata->auth.offset_bits,
6424 op_mode, 1, verify);
6429 op = process_crypto_request(ts_params->valid_devs[0],
6432 /* Check if the op failed because the device doesn't */
6433 /* support this particular combination of algorithms */
6434 if (op == NULL && ut_params->op->status ==
6435 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6436 printf("Device doesn't support this mixed combination. "
6443 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6445 ut_params->obuf = (op_mode == IN_PLACE ?
6446 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6449 if (ut_params->obuf)
6450 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6451 plaintext_len, buffer);
6453 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6454 plaintext_len, buffer);
6456 debug_hexdump(stdout, "plaintext:", plaintext,
6457 (tdata->plaintext.len_bits >> 3) -
6458 tdata->digest_enc.len);
6459 debug_hexdump(stdout, "plaintext expected:",
6460 tdata->plaintext.data,
6461 (tdata->plaintext.len_bits >> 3) -
6462 tdata->digest_enc.len);
6464 if (ut_params->obuf)
6465 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6466 ciphertext_len, buffer);
6468 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6469 ciphertext_len, buffer);
6471 debug_hexdump(stdout, "ciphertext:", ciphertext,
6473 debug_hexdump(stdout, "ciphertext expected:",
6474 tdata->ciphertext.data,
6475 tdata->ciphertext.len_bits >> 3);
6477 if (ut_params->obuf)
6478 digest = rte_pktmbuf_read(ut_params->obuf,
6479 (tdata->digest_enc.offset == 0 ?
6481 tdata->digest_enc.offset),
6482 tdata->digest_enc.len, digest_buffer);
6484 digest = rte_pktmbuf_read(ut_params->ibuf,
6485 (tdata->digest_enc.offset == 0 ?
6487 tdata->digest_enc.offset),
6488 tdata->digest_enc.len, digest_buffer);
6490 debug_hexdump(stdout, "digest:", digest,
6491 tdata->digest_enc.len);
6492 debug_hexdump(stdout, "digest expected:",
6493 tdata->digest_enc.data, tdata->digest_enc.len);
6498 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6500 tdata->plaintext.data,
6501 tdata->plaintext.len_bits >> 3,
6502 "Plaintext data not as expected");
6504 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6506 tdata->ciphertext.data,
6507 tdata->validDataLen.len_bits,
6508 "Ciphertext data not as expected");
6509 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6511 tdata->digest_enc.data,
6512 tdata->digest_enc.len,
6513 "Generated auth tag not as expected");
6516 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6517 "crypto op processing failed");
6522 /** AUTH AES CMAC + CIPHER AES CTR */
6525 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6527 return test_mixed_auth_cipher(
6528 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6532 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6534 return test_mixed_auth_cipher(
6535 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6539 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6541 return test_mixed_auth_cipher_sgl(
6542 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6546 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6548 return test_mixed_auth_cipher_sgl(
6549 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6553 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6555 return test_mixed_auth_cipher(
6556 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6560 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6562 return test_mixed_auth_cipher(
6563 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6567 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6569 return test_mixed_auth_cipher_sgl(
6570 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6574 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6576 return test_mixed_auth_cipher_sgl(
6577 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6580 /** MIXED AUTH + CIPHER */
6583 test_auth_zuc_cipher_snow_test_case_1(void)
6585 return test_mixed_auth_cipher(
6586 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6590 test_verify_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, 1);
6597 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6599 return test_mixed_auth_cipher(
6600 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6604 test_verify_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, 1);
6611 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6613 return test_mixed_auth_cipher(
6614 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6618 test_verify_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, 1);
6625 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6627 return test_mixed_auth_cipher(
6628 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6632 test_verify_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, 1);
6639 test_auth_snow_cipher_zuc_test_case_1(void)
6641 return test_mixed_auth_cipher(
6642 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6646 test_verify_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, 1);
6653 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6655 return test_mixed_auth_cipher(
6656 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6660 test_verify_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, 1);
6667 test_auth_null_cipher_snow_test_case_1(void)
6669 return test_mixed_auth_cipher(
6670 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6674 test_verify_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, 1);
6681 test_auth_null_cipher_zuc_test_case_1(void)
6683 return test_mixed_auth_cipher(
6684 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6688 test_verify_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, 1);
6695 test_auth_snow_cipher_null_test_case_1(void)
6697 return test_mixed_auth_cipher(
6698 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6702 test_verify_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, 1);
6709 test_auth_zuc_cipher_null_test_case_1(void)
6711 return test_mixed_auth_cipher(
6712 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6716 test_verify_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, 1);
6723 test_auth_null_cipher_aes_ctr_test_case_1(void)
6725 return test_mixed_auth_cipher(
6726 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6730 test_verify_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, 1);
6737 test_auth_aes_cmac_cipher_null_test_case_1(void)
6739 return test_mixed_auth_cipher(
6740 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6744 test_verify_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, 1);
6750 /* ***** AEAD algorithm Tests ***** */
6753 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6754 enum rte_crypto_aead_operation op,
6755 const uint8_t *key, const uint8_t key_len,
6756 const uint16_t aad_len, const uint8_t auth_len,
6759 uint8_t aead_key[key_len];
6761 struct crypto_testsuite_params *ts_params = &testsuite_params;
6762 struct crypto_unittest_params *ut_params = &unittest_params;
6764 memcpy(aead_key, key, key_len);
6766 /* Setup AEAD Parameters */
6767 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6768 ut_params->aead_xform.next = NULL;
6769 ut_params->aead_xform.aead.algo = algo;
6770 ut_params->aead_xform.aead.op = op;
6771 ut_params->aead_xform.aead.key.data = aead_key;
6772 ut_params->aead_xform.aead.key.length = key_len;
6773 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6774 ut_params->aead_xform.aead.iv.length = iv_len;
6775 ut_params->aead_xform.aead.digest_length = auth_len;
6776 ut_params->aead_xform.aead.aad_length = aad_len;
6778 debug_hexdump(stdout, "key:", key, key_len);
6780 /* Create Crypto session*/
6781 ut_params->sess = rte_cryptodev_sym_session_create(
6782 ts_params->session_mpool);
6784 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6785 &ut_params->aead_xform,
6786 ts_params->session_priv_mpool);
6788 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6794 create_aead_xform(struct rte_crypto_op *op,
6795 enum rte_crypto_aead_algorithm algo,
6796 enum rte_crypto_aead_operation aead_op,
6797 uint8_t *key, const uint8_t key_len,
6798 const uint8_t aad_len, const uint8_t auth_len,
6801 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6802 "failed to allocate space for crypto transform");
6804 struct rte_crypto_sym_op *sym_op = op->sym;
6806 /* Setup AEAD Parameters */
6807 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6808 sym_op->xform->next = NULL;
6809 sym_op->xform->aead.algo = algo;
6810 sym_op->xform->aead.op = aead_op;
6811 sym_op->xform->aead.key.data = key;
6812 sym_op->xform->aead.key.length = key_len;
6813 sym_op->xform->aead.iv.offset = IV_OFFSET;
6814 sym_op->xform->aead.iv.length = iv_len;
6815 sym_op->xform->aead.digest_length = auth_len;
6816 sym_op->xform->aead.aad_length = aad_len;
6818 debug_hexdump(stdout, "key:", key, key_len);
6824 create_aead_operation(enum rte_crypto_aead_operation op,
6825 const struct aead_test_data *tdata)
6827 struct crypto_testsuite_params *ts_params = &testsuite_params;
6828 struct crypto_unittest_params *ut_params = &unittest_params;
6830 uint8_t *plaintext, *ciphertext;
6831 unsigned int aad_pad_len, plaintext_pad_len;
6833 /* Generate Crypto op data structure */
6834 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6835 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6836 TEST_ASSERT_NOT_NULL(ut_params->op,
6837 "Failed to allocate symmetric crypto operation struct");
6839 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6841 /* Append aad data */
6842 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6843 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6844 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6846 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6847 "no room to append aad");
6849 sym_op->aead.aad.phys_addr =
6850 rte_pktmbuf_iova(ut_params->ibuf);
6851 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6852 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6853 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6856 /* Append IV at the end of the crypto operation*/
6857 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6858 uint8_t *, IV_OFFSET);
6860 /* Copy IV 1 byte after the IV pointer, according to the API */
6861 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6862 debug_hexdump(stdout, "iv:", iv_ptr,
6865 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6866 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6868 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6869 "no room to append aad");
6871 sym_op->aead.aad.phys_addr =
6872 rte_pktmbuf_iova(ut_params->ibuf);
6873 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6874 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6877 /* Append IV at the end of the crypto operation*/
6878 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6879 uint8_t *, IV_OFFSET);
6881 if (tdata->iv.len == 0) {
6882 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6883 debug_hexdump(stdout, "iv:", iv_ptr,
6886 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6887 debug_hexdump(stdout, "iv:", iv_ptr,
6892 /* Append plaintext/ciphertext */
6893 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6894 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6895 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6897 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6899 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6900 debug_hexdump(stdout, "plaintext:", plaintext,
6901 tdata->plaintext.len);
6903 if (ut_params->obuf) {
6904 ciphertext = (uint8_t *)rte_pktmbuf_append(
6906 plaintext_pad_len + aad_pad_len);
6907 TEST_ASSERT_NOT_NULL(ciphertext,
6908 "no room to append ciphertext");
6910 memset(ciphertext + aad_pad_len, 0,
6911 tdata->ciphertext.len);
6914 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6915 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6917 TEST_ASSERT_NOT_NULL(ciphertext,
6918 "no room to append ciphertext");
6920 memcpy(ciphertext, tdata->ciphertext.data,
6921 tdata->ciphertext.len);
6922 debug_hexdump(stdout, "ciphertext:", ciphertext,
6923 tdata->ciphertext.len);
6925 if (ut_params->obuf) {
6926 plaintext = (uint8_t *)rte_pktmbuf_append(
6928 plaintext_pad_len + aad_pad_len);
6929 TEST_ASSERT_NOT_NULL(plaintext,
6930 "no room to append plaintext");
6932 memset(plaintext + aad_pad_len, 0,
6933 tdata->plaintext.len);
6937 /* Append digest data */
6938 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6939 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6940 ut_params->obuf ? ut_params->obuf :
6942 tdata->auth_tag.len);
6943 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6944 "no room to append digest");
6945 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6946 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6947 ut_params->obuf ? ut_params->obuf :
6952 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6953 ut_params->ibuf, tdata->auth_tag.len);
6954 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6955 "no room to append digest");
6956 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6958 plaintext_pad_len + aad_pad_len);
6960 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6961 tdata->auth_tag.len);
6962 debug_hexdump(stdout, "digest:",
6963 sym_op->aead.digest.data,
6964 tdata->auth_tag.len);
6967 sym_op->aead.data.length = tdata->plaintext.len;
6968 sym_op->aead.data.offset = aad_pad_len;
6974 test_authenticated_encryption(const struct aead_test_data *tdata)
6976 struct crypto_testsuite_params *ts_params = &testsuite_params;
6977 struct crypto_unittest_params *ut_params = &unittest_params;
6980 uint8_t *ciphertext, *auth_tag;
6981 uint16_t plaintext_pad_len;
6984 /* Verify the capabilities */
6985 struct rte_cryptodev_sym_capability_idx cap_idx;
6986 const struct rte_cryptodev_symmetric_capability *capability;
6987 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6988 cap_idx.algo.aead = tdata->algo;
6989 capability = rte_cryptodev_sym_capability_get(
6990 ts_params->valid_devs[0], &cap_idx);
6991 if (capability == NULL)
6993 if (rte_cryptodev_sym_capability_check_aead(
6994 capability, tdata->key.len, tdata->auth_tag.len,
6995 tdata->aad.len, tdata->iv.len))
6998 /* Create AEAD session */
6999 retval = create_aead_session(ts_params->valid_devs[0],
7001 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7002 tdata->key.data, tdata->key.len,
7003 tdata->aad.len, tdata->auth_tag.len,
7008 if (tdata->aad.len > MBUF_SIZE) {
7009 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7010 /* Populate full size of add data */
7011 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7012 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7014 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7016 /* clear mbuf payload */
7017 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7018 rte_pktmbuf_tailroom(ut_params->ibuf));
7020 /* Create AEAD operation */
7021 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7025 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7027 ut_params->op->sym->m_src = ut_params->ibuf;
7029 /* Process crypto operation */
7030 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7031 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7033 TEST_ASSERT_NOT_NULL(
7034 process_crypto_request(ts_params->valid_devs[0],
7035 ut_params->op), "failed to process sym crypto op");
7037 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7038 "crypto op processing failed");
7040 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7042 if (ut_params->op->sym->m_dst) {
7043 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7045 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7046 uint8_t *, plaintext_pad_len);
7048 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7050 ut_params->op->sym->cipher.data.offset);
7051 auth_tag = ciphertext + plaintext_pad_len;
7054 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7055 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7058 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7060 tdata->ciphertext.data,
7061 tdata->ciphertext.len,
7062 "Ciphertext data not as expected");
7064 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7066 tdata->auth_tag.data,
7067 tdata->auth_tag.len,
7068 "Generated auth tag not as expected");
7074 #ifdef RTE_LIBRTE_SECURITY
7076 security_proto_supported(enum rte_security_session_protocol proto)
7078 struct crypto_testsuite_params *ts_params = &testsuite_params;
7080 const struct rte_security_capability *capabilities;
7081 const struct rte_security_capability *capability;
7084 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7085 rte_cryptodev_get_sec_ctx(
7086 ts_params->valid_devs[0]);
7089 capabilities = rte_security_capabilities_get(ctx);
7091 if (capabilities == NULL)
7094 while ((capability = &capabilities[i++])->action !=
7095 RTE_SECURITY_ACTION_TYPE_NONE) {
7096 if (capability->protocol == proto)
7103 /* Basic algorithm run function for async inplace mode.
7104 * Creates a session from input parameters and runs one operation
7105 * on input_vec. Checks the output of the crypto operation against
7109 test_pdcp_proto(int i, int oop,
7110 enum rte_crypto_cipher_operation opc,
7111 enum rte_crypto_auth_operation opa,
7113 unsigned int input_vec_len,
7114 uint8_t *output_vec,
7115 unsigned int output_vec_len)
7117 struct crypto_testsuite_params *ts_params = &testsuite_params;
7118 struct crypto_unittest_params *ut_params = &unittest_params;
7120 int ret = TEST_SUCCESS;
7121 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7122 rte_cryptodev_get_sec_ctx(
7123 ts_params->valid_devs[0]);
7125 /* Verify the capabilities */
7126 struct rte_security_capability_idx sec_cap_idx;
7128 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7129 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7130 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7131 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7134 /* Generate test mbuf data */
7135 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7137 /* clear mbuf payload */
7138 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7139 rte_pktmbuf_tailroom(ut_params->ibuf));
7141 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7143 memcpy(plaintext, input_vec, input_vec_len);
7145 /* Out of place support */
7148 * For out-op-place we need to alloc another mbuf
7150 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7151 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7154 /* Set crypto type as IPSEC */
7155 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7157 /* Setup Cipher Parameters */
7158 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7159 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7160 ut_params->cipher_xform.cipher.op = opc;
7161 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7162 ut_params->cipher_xform.cipher.key.length =
7163 pdcp_test_params[i].cipher_key_len;
7164 ut_params->cipher_xform.cipher.iv.length =
7165 pdcp_test_packet_direction[i] ? 4 : 0;
7166 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7168 /* Setup HMAC Parameters if ICV header is required */
7169 if (pdcp_test_params[i].auth_alg != 0) {
7170 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7171 ut_params->auth_xform.next = NULL;
7172 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7173 ut_params->auth_xform.auth.op = opa;
7174 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7175 ut_params->auth_xform.auth.key.length =
7176 pdcp_test_params[i].auth_key_len;
7178 ut_params->cipher_xform.next = &ut_params->auth_xform;
7180 ut_params->cipher_xform.next = NULL;
7183 struct rte_security_session_conf sess_conf = {
7184 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7185 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7187 .bearer = pdcp_test_bearer[i],
7188 .domain = pdcp_test_params[i].domain,
7189 .pkt_dir = pdcp_test_packet_direction[i],
7190 .sn_size = pdcp_test_data_sn_size[i],
7191 .hfn = pdcp_test_packet_direction[i] ?
7192 0 : pdcp_test_hfn[i],
7194 * hfn can be set as pdcp_test_hfn[i]
7195 * if hfn_ovrd is not set. Here, PDCP
7196 * packet direction is just used to
7197 * run half of the cases with session
7198 * HFN and other half with per packet
7201 .hfn_threshold = pdcp_test_hfn_threshold[i],
7202 .hfn_ovrd = pdcp_test_packet_direction[i] ? 1 : 0,
7204 .crypto_xform = &ut_params->cipher_xform
7207 /* Create security session */
7208 ut_params->sec_session = rte_security_session_create(ctx,
7209 &sess_conf, ts_params->session_priv_mpool);
7211 if (!ut_params->sec_session) {
7212 printf("TestCase %s()-%d line %d failed %s: ",
7213 __func__, i, __LINE__, "Failed to allocate session");
7218 /* Generate crypto op data structure */
7219 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7220 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7221 if (!ut_params->op) {
7222 printf("TestCase %s()-%d line %d failed %s: ",
7223 __func__, i, __LINE__,
7224 "Failed to allocate symmetric crypto operation struct");
7229 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7230 uint32_t *, IV_OFFSET);
7231 *per_pkt_hfn = pdcp_test_packet_direction[i] ? pdcp_test_hfn[i] : 0;
7233 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7235 /* set crypto operation source mbuf */
7236 ut_params->op->sym->m_src = ut_params->ibuf;
7238 ut_params->op->sym->m_dst = ut_params->obuf;
7240 /* Process crypto operation */
7241 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7243 printf("TestCase %s()-%d line %d failed %s: ",
7244 __func__, i, __LINE__,
7245 "failed to process sym crypto op");
7250 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7251 printf("TestCase %s()-%d line %d failed %s: ",
7252 __func__, i, __LINE__, "crypto op processing failed");
7258 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7261 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7265 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7266 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7267 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7268 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7274 rte_crypto_op_free(ut_params->op);
7275 ut_params->op = NULL;
7277 if (ut_params->sec_session)
7278 rte_security_session_destroy(ctx, ut_params->sec_session);
7279 ut_params->sec_session = NULL;
7281 rte_pktmbuf_free(ut_params->ibuf);
7282 ut_params->ibuf = NULL;
7284 rte_pktmbuf_free(ut_params->obuf);
7285 ut_params->obuf = NULL;
7292 test_pdcp_proto_SGL(int i, int oop,
7293 enum rte_crypto_cipher_operation opc,
7294 enum rte_crypto_auth_operation opa,
7296 unsigned int input_vec_len,
7297 uint8_t *output_vec,
7298 unsigned int output_vec_len,
7300 uint32_t fragsz_oop)
7302 struct crypto_testsuite_params *ts_params = &testsuite_params;
7303 struct crypto_unittest_params *ut_params = &unittest_params;
7305 struct rte_mbuf *buf, *buf_oop = NULL;
7306 int ret = TEST_SUCCESS;
7310 unsigned int trn_data = 0;
7311 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7312 rte_cryptodev_get_sec_ctx(
7313 ts_params->valid_devs[0]);
7315 /* Verify the capabilities */
7316 struct rte_security_capability_idx sec_cap_idx;
7318 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7319 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7320 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7321 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7324 if (fragsz > input_vec_len)
7325 fragsz = input_vec_len;
7327 uint16_t plaintext_len = fragsz;
7328 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7330 if (fragsz_oop > output_vec_len)
7331 frag_size_oop = output_vec_len;
7334 if (input_vec_len % fragsz != 0) {
7335 if (input_vec_len / fragsz + 1 > 16)
7337 } else if (input_vec_len / fragsz > 16)
7340 /* Out of place support */
7343 * For out-op-place we need to alloc another mbuf
7345 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7346 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7347 buf_oop = ut_params->obuf;
7350 /* Generate test mbuf data */
7351 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7353 /* clear mbuf payload */
7354 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7355 rte_pktmbuf_tailroom(ut_params->ibuf));
7357 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7359 memcpy(plaintext, input_vec, plaintext_len);
7360 trn_data += plaintext_len;
7362 buf = ut_params->ibuf;
7365 * Loop until no more fragments
7368 while (trn_data < input_vec_len) {
7370 to_trn = (input_vec_len - trn_data < fragsz) ?
7371 (input_vec_len - trn_data) : fragsz;
7373 to_trn_tbl[ecx++] = to_trn;
7375 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7378 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7379 rte_pktmbuf_tailroom(buf));
7382 if (oop && !fragsz_oop) {
7384 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7385 buf_oop = buf_oop->next;
7386 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7387 0, rte_pktmbuf_tailroom(buf_oop));
7388 rte_pktmbuf_append(buf_oop, to_trn);
7391 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7394 memcpy(plaintext, input_vec + trn_data, to_trn);
7398 ut_params->ibuf->nb_segs = segs;
7401 if (fragsz_oop && oop) {
7405 trn_data = frag_size_oop;
7406 while (trn_data < output_vec_len) {
7409 (output_vec_len - trn_data <
7411 (output_vec_len - trn_data) :
7414 to_trn_tbl[ecx++] = to_trn;
7417 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7418 buf_oop = buf_oop->next;
7419 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7420 0, rte_pktmbuf_tailroom(buf_oop));
7421 rte_pktmbuf_append(buf_oop, to_trn);
7425 ut_params->obuf->nb_segs = segs;
7428 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7430 /* Setup Cipher Parameters */
7431 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7432 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7433 ut_params->cipher_xform.cipher.op = opc;
7434 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7435 ut_params->cipher_xform.cipher.key.length =
7436 pdcp_test_params[i].cipher_key_len;
7437 ut_params->cipher_xform.cipher.iv.length = 0;
7439 /* Setup HMAC Parameters if ICV header is required */
7440 if (pdcp_test_params[i].auth_alg != 0) {
7441 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7442 ut_params->auth_xform.next = NULL;
7443 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7444 ut_params->auth_xform.auth.op = opa;
7445 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7446 ut_params->auth_xform.auth.key.length =
7447 pdcp_test_params[i].auth_key_len;
7449 ut_params->cipher_xform.next = &ut_params->auth_xform;
7451 ut_params->cipher_xform.next = NULL;
7454 struct rte_security_session_conf sess_conf = {
7455 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7456 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7458 .bearer = pdcp_test_bearer[i],
7459 .domain = pdcp_test_params[i].domain,
7460 .pkt_dir = pdcp_test_packet_direction[i],
7461 .sn_size = pdcp_test_data_sn_size[i],
7462 .hfn = pdcp_test_hfn[i],
7463 .hfn_threshold = pdcp_test_hfn_threshold[i],
7466 .crypto_xform = &ut_params->cipher_xform
7469 /* Create security session */
7470 ut_params->sec_session = rte_security_session_create(ctx,
7471 &sess_conf, ts_params->session_priv_mpool);
7473 if (!ut_params->sec_session) {
7474 printf("TestCase %s()-%d line %d failed %s: ",
7475 __func__, i, __LINE__, "Failed to allocate session");
7480 /* Generate crypto op data structure */
7481 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7482 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7483 if (!ut_params->op) {
7484 printf("TestCase %s()-%d line %d failed %s: ",
7485 __func__, i, __LINE__,
7486 "Failed to allocate symmetric crypto operation struct");
7491 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7493 /* set crypto operation source mbuf */
7494 ut_params->op->sym->m_src = ut_params->ibuf;
7496 ut_params->op->sym->m_dst = ut_params->obuf;
7498 /* Process crypto operation */
7499 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7501 printf("TestCase %s()-%d line %d failed %s: ",
7502 __func__, i, __LINE__,
7503 "failed to process sym crypto op");
7508 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7509 printf("TestCase %s()-%d line %d failed %s: ",
7510 __func__, i, __LINE__, "crypto op processing failed");
7516 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7519 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7523 fragsz = frag_size_oop;
7524 if (memcmp(ciphertext, output_vec, fragsz)) {
7525 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7526 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7527 rte_hexdump(stdout, "reference", output_vec, fragsz);
7532 buf = ut_params->op->sym->m_src->next;
7534 buf = ut_params->op->sym->m_dst->next;
7536 unsigned int off = fragsz;
7540 ciphertext = rte_pktmbuf_mtod(buf,
7542 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7543 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7544 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7545 rte_hexdump(stdout, "reference", output_vec + off,
7550 off += to_trn_tbl[ecx++];
7554 rte_crypto_op_free(ut_params->op);
7555 ut_params->op = NULL;
7557 if (ut_params->sec_session)
7558 rte_security_session_destroy(ctx, ut_params->sec_session);
7559 ut_params->sec_session = NULL;
7561 rte_pktmbuf_free(ut_params->ibuf);
7562 ut_params->ibuf = NULL;
7564 rte_pktmbuf_free(ut_params->obuf);
7565 ut_params->obuf = NULL;
7572 test_pdcp_proto_cplane_encap(int i)
7574 return test_pdcp_proto(i, 0,
7575 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7576 RTE_CRYPTO_AUTH_OP_GENERATE,
7577 pdcp_test_data_in[i],
7578 pdcp_test_data_in_len[i],
7579 pdcp_test_data_out[i],
7580 pdcp_test_data_in_len[i]+4);
7584 test_pdcp_proto_uplane_encap(int i)
7586 return test_pdcp_proto(i, 0,
7587 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7588 RTE_CRYPTO_AUTH_OP_GENERATE,
7589 pdcp_test_data_in[i],
7590 pdcp_test_data_in_len[i],
7591 pdcp_test_data_out[i],
7592 pdcp_test_data_in_len[i]);
7597 test_pdcp_proto_uplane_encap_with_int(int i)
7599 return test_pdcp_proto(i, 0,
7600 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7601 RTE_CRYPTO_AUTH_OP_GENERATE,
7602 pdcp_test_data_in[i],
7603 pdcp_test_data_in_len[i],
7604 pdcp_test_data_out[i],
7605 pdcp_test_data_in_len[i] + 4);
7609 test_pdcp_proto_cplane_decap(int i)
7611 return test_pdcp_proto(i, 0,
7612 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7613 RTE_CRYPTO_AUTH_OP_VERIFY,
7614 pdcp_test_data_out[i],
7615 pdcp_test_data_in_len[i] + 4,
7616 pdcp_test_data_in[i],
7617 pdcp_test_data_in_len[i]);
7621 test_pdcp_proto_uplane_decap(int i)
7623 return test_pdcp_proto(i, 0,
7624 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7625 RTE_CRYPTO_AUTH_OP_VERIFY,
7626 pdcp_test_data_out[i],
7627 pdcp_test_data_in_len[i],
7628 pdcp_test_data_in[i],
7629 pdcp_test_data_in_len[i]);
7633 test_pdcp_proto_uplane_decap_with_int(int i)
7635 return test_pdcp_proto(i, 0,
7636 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7637 RTE_CRYPTO_AUTH_OP_VERIFY,
7638 pdcp_test_data_out[i],
7639 pdcp_test_data_in_len[i] + 4,
7640 pdcp_test_data_in[i],
7641 pdcp_test_data_in_len[i]);
7645 test_PDCP_PROTO_SGL_in_place_32B(void)
7647 /* i can be used for running any PDCP case
7648 * In this case it is uplane 12-bit AES-SNOW DL encap
7650 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7651 return test_pdcp_proto_SGL(i, IN_PLACE,
7652 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7653 RTE_CRYPTO_AUTH_OP_GENERATE,
7654 pdcp_test_data_in[i],
7655 pdcp_test_data_in_len[i],
7656 pdcp_test_data_out[i],
7657 pdcp_test_data_in_len[i]+4,
7661 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7663 /* i can be used for running any PDCP case
7664 * In this case it is uplane 18-bit NULL-NULL DL encap
7666 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7667 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7668 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7669 RTE_CRYPTO_AUTH_OP_GENERATE,
7670 pdcp_test_data_in[i],
7671 pdcp_test_data_in_len[i],
7672 pdcp_test_data_out[i],
7673 pdcp_test_data_in_len[i]+4,
7677 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7679 /* i can be used for running any PDCP case
7680 * In this case it is uplane 18-bit AES DL encap
7682 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7684 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7685 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7686 RTE_CRYPTO_AUTH_OP_GENERATE,
7687 pdcp_test_data_in[i],
7688 pdcp_test_data_in_len[i],
7689 pdcp_test_data_out[i],
7690 pdcp_test_data_in_len[i],
7694 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7696 /* i can be used for running any PDCP case
7697 * In this case it is cplane 12-bit AES-ZUC DL encap
7699 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7700 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7701 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7702 RTE_CRYPTO_AUTH_OP_GENERATE,
7703 pdcp_test_data_in[i],
7704 pdcp_test_data_in_len[i],
7705 pdcp_test_data_out[i],
7706 pdcp_test_data_in_len[i]+4,
7711 test_PDCP_PROTO_all(void)
7713 struct crypto_testsuite_params *ts_params = &testsuite_params;
7714 struct rte_cryptodev_info dev_info;
7717 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7718 uint64_t feat_flags = dev_info.feature_flags;
7720 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
7723 if (security_proto_supported(RTE_SECURITY_PROTOCOL_PDCP) < 0)
7726 status = test_PDCP_PROTO_cplane_encap_all();
7727 status += test_PDCP_PROTO_cplane_decap_all();
7728 status += test_PDCP_PROTO_uplane_encap_all();
7729 status += test_PDCP_PROTO_uplane_decap_all();
7730 status += test_PDCP_PROTO_SGL_in_place_32B();
7731 status += test_PDCP_PROTO_SGL_oop_32B_128B();
7732 status += test_PDCP_PROTO_SGL_oop_32B_40B();
7733 status += test_PDCP_PROTO_SGL_oop_128B_32B();
7738 return TEST_SUCCESS;
7742 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
7744 struct crypto_testsuite_params *ts_params = &testsuite_params;
7745 struct crypto_unittest_params *ut_params = &unittest_params;
7746 uint8_t *plaintext, *ciphertext;
7748 int32_t cipher_len, crc_len;
7749 uint32_t crc_data_len;
7750 int ret = TEST_SUCCESS;
7752 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7753 rte_cryptodev_get_sec_ctx(
7754 ts_params->valid_devs[0]);
7756 /* Verify the capabilities */
7757 struct rte_security_capability_idx sec_cap_idx;
7758 const struct rte_security_capability *sec_cap;
7759 const struct rte_cryptodev_capabilities *crypto_cap;
7760 const struct rte_cryptodev_symmetric_capability *sym_cap;
7763 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7764 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
7765 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
7767 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
7768 if (sec_cap == NULL)
7771 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
7772 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
7773 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
7774 crypto_cap->sym.xform_type ==
7775 RTE_CRYPTO_SYM_XFORM_CIPHER &&
7776 crypto_cap->sym.cipher.algo ==
7777 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
7778 sym_cap = &crypto_cap->sym;
7779 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
7786 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
7789 /* Setup source mbuf payload */
7790 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7791 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7792 rte_pktmbuf_tailroom(ut_params->ibuf));
7794 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7795 d_td->ciphertext.len);
7797 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
7799 /* Set session action type */
7800 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7802 /* Setup cipher session parameters */
7803 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7804 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
7805 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
7806 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
7807 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
7808 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
7809 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7810 ut_params->cipher_xform.next = NULL;
7812 /* Setup DOCSIS session parameters */
7813 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
7815 struct rte_security_session_conf sess_conf = {
7816 .action_type = ut_params->type,
7817 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
7818 .docsis = ut_params->docsis_xform,
7819 .crypto_xform = &ut_params->cipher_xform,
7822 /* Create security session */
7823 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
7824 ts_params->session_priv_mpool);
7826 if (!ut_params->sec_session) {
7827 printf("TestCase %s(%d) line %d: %s\n",
7828 __func__, i, __LINE__, "failed to allocate session");
7833 /* Generate crypto op data structure */
7834 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7835 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7836 if (!ut_params->op) {
7837 printf("TestCase %s(%d) line %d: %s\n",
7838 __func__, i, __LINE__,
7839 "failed to allocate symmetric crypto operation");
7844 /* Setup CRC operation parameters */
7845 crc_len = d_td->ciphertext.no_crc == false ?
7846 (d_td->ciphertext.len -
7847 d_td->ciphertext.crc_offset -
7848 RTE_ETHER_CRC_LEN) :
7850 crc_len = crc_len > 0 ? crc_len : 0;
7851 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
7852 ut_params->op->sym->auth.data.length = crc_len;
7853 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
7855 /* Setup cipher operation parameters */
7856 cipher_len = d_td->ciphertext.no_cipher == false ?
7857 (d_td->ciphertext.len -
7858 d_td->ciphertext.cipher_offset) :
7860 cipher_len = cipher_len > 0 ? cipher_len : 0;
7861 ut_params->op->sym->cipher.data.length = cipher_len;
7862 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
7864 /* Setup cipher IV */
7865 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
7866 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
7868 /* Attach session to operation */
7869 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7871 /* Set crypto operation mbufs */
7872 ut_params->op->sym->m_src = ut_params->ibuf;
7873 ut_params->op->sym->m_dst = NULL;
7875 /* Process crypto operation */
7876 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
7878 printf("TestCase %s(%d) line %d: %s\n",
7879 __func__, i, __LINE__,
7880 "failed to process security crypto op");
7885 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7886 printf("TestCase %s(%d) line %d: %s\n",
7887 __func__, i, __LINE__, "crypto op processing failed");
7892 /* Validate plaintext */
7893 plaintext = ciphertext;
7895 if (memcmp(plaintext, d_td->plaintext.data,
7896 d_td->plaintext.len - crc_data_len)) {
7897 printf("TestCase %s(%d) line %d: %s\n",
7898 __func__, i, __LINE__, "plaintext not as expected\n");
7899 rte_hexdump(stdout, "expected", d_td->plaintext.data,
7900 d_td->plaintext.len);
7901 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
7907 rte_crypto_op_free(ut_params->op);
7908 ut_params->op = NULL;
7910 if (ut_params->sec_session)
7911 rte_security_session_destroy(ctx, ut_params->sec_session);
7912 ut_params->sec_session = NULL;
7914 rte_pktmbuf_free(ut_params->ibuf);
7915 ut_params->ibuf = NULL;
7921 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
7923 struct crypto_testsuite_params *ts_params = &testsuite_params;
7924 struct crypto_unittest_params *ut_params = &unittest_params;
7925 uint8_t *plaintext, *ciphertext;
7927 int32_t cipher_len, crc_len;
7928 int ret = TEST_SUCCESS;
7930 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7931 rte_cryptodev_get_sec_ctx(
7932 ts_params->valid_devs[0]);
7934 /* Verify the capabilities */
7935 struct rte_security_capability_idx sec_cap_idx;
7936 const struct rte_security_capability *sec_cap;
7937 const struct rte_cryptodev_capabilities *crypto_cap;
7938 const struct rte_cryptodev_symmetric_capability *sym_cap;
7941 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7942 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
7943 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
7945 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
7946 if (sec_cap == NULL)
7949 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
7950 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
7951 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
7952 crypto_cap->sym.xform_type ==
7953 RTE_CRYPTO_SYM_XFORM_CIPHER &&
7954 crypto_cap->sym.cipher.algo ==
7955 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
7956 sym_cap = &crypto_cap->sym;
7957 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
7964 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
7967 /* Setup source mbuf payload */
7968 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7969 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7970 rte_pktmbuf_tailroom(ut_params->ibuf));
7972 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7973 d_td->plaintext.len);
7975 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
7977 /* Set session action type */
7978 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7980 /* Setup cipher session parameters */
7981 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7982 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
7983 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7984 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
7985 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
7986 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
7987 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7988 ut_params->cipher_xform.next = NULL;
7990 /* Setup DOCSIS session parameters */
7991 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
7993 struct rte_security_session_conf sess_conf = {
7994 .action_type = ut_params->type,
7995 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
7996 .docsis = ut_params->docsis_xform,
7997 .crypto_xform = &ut_params->cipher_xform,
8000 /* Create security session */
8001 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8002 ts_params->session_priv_mpool);
8004 if (!ut_params->sec_session) {
8005 printf("TestCase %s(%d) line %d: %s\n",
8006 __func__, i, __LINE__, "failed to allocate session");
8011 /* Generate crypto op data structure */
8012 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8013 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8014 if (!ut_params->op) {
8015 printf("TestCase %s(%d) line %d: %s\n",
8016 __func__, i, __LINE__,
8017 "failed to allocate security crypto operation");
8022 /* Setup CRC operation parameters */
8023 crc_len = d_td->plaintext.no_crc == false ?
8024 (d_td->plaintext.len -
8025 d_td->plaintext.crc_offset -
8026 RTE_ETHER_CRC_LEN) :
8028 crc_len = crc_len > 0 ? crc_len : 0;
8029 ut_params->op->sym->auth.data.length = crc_len;
8030 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8032 /* Setup cipher operation parameters */
8033 cipher_len = d_td->plaintext.no_cipher == false ?
8034 (d_td->plaintext.len -
8035 d_td->plaintext.cipher_offset) :
8037 cipher_len = cipher_len > 0 ? cipher_len : 0;
8038 ut_params->op->sym->cipher.data.length = cipher_len;
8039 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8041 /* Setup cipher IV */
8042 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8043 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8045 /* Attach session to operation */
8046 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8048 /* Set crypto operation mbufs */
8049 ut_params->op->sym->m_src = ut_params->ibuf;
8050 ut_params->op->sym->m_dst = NULL;
8052 /* Process crypto operation */
8053 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8055 printf("TestCase %s(%d) line %d: %s\n",
8056 __func__, i, __LINE__,
8057 "failed to process security crypto op");
8062 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8063 printf("TestCase %s(%d) line %d: %s\n",
8064 __func__, i, __LINE__, "crypto op processing failed");
8069 /* Validate ciphertext */
8070 ciphertext = plaintext;
8072 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8073 printf("TestCase %s(%d) line %d: %s\n",
8074 __func__, i, __LINE__, "ciphertext not as expected\n");
8075 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8076 d_td->ciphertext.len);
8077 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8083 rte_crypto_op_free(ut_params->op);
8084 ut_params->op = NULL;
8086 if (ut_params->sec_session)
8087 rte_security_session_destroy(ctx, ut_params->sec_session);
8088 ut_params->sec_session = NULL;
8090 rte_pktmbuf_free(ut_params->ibuf);
8091 ut_params->ibuf = NULL;
8096 #define TEST_DOCSIS_COUNT(func) do { \
8098 if (ret == TEST_SUCCESS) { \
8099 printf("\t%2d)", n++); \
8100 printf("+++++ PASSED:" #func"\n"); \
8102 } else if (ret == -ENOTSUP) { \
8103 printf("\t%2d)", n++); \
8104 printf("~~~~~ UNSUPP:" #func"\n"); \
8107 printf("\t%2d)", n++); \
8108 printf("----- FAILED:" #func"\n"); \
8114 test_DOCSIS_PROTO_uplink_all(void)
8116 int p = 0, u = 0, f = 0, n = 0;
8118 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8119 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8120 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8121 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8122 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8123 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8124 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8125 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8126 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8127 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8128 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8129 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8130 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8131 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8132 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8133 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8134 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8135 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8136 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8137 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8138 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8139 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8140 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8141 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8142 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8143 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8146 printf("## %s: %d passed out of %d (%d unsupported)\n",
8153 test_DOCSIS_PROTO_downlink_all(void)
8155 int p = 0, u = 0, f = 0, n = 0;
8157 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8158 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8159 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8160 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8161 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8162 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8163 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8164 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8165 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8166 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8167 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8168 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8169 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8170 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8171 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8172 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8173 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8174 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8175 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8176 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8177 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8178 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8179 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8180 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8181 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8182 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8185 printf("## %s: %d passed out of %d (%d unsupported)\n",
8192 test_DOCSIS_PROTO_all(void)
8194 struct crypto_testsuite_params *ts_params = &testsuite_params;
8195 struct rte_cryptodev_info dev_info;
8198 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8199 uint64_t feat_flags = dev_info.feature_flags;
8201 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8204 if (security_proto_supported(RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8207 status = test_DOCSIS_PROTO_uplink_all();
8208 status += test_DOCSIS_PROTO_downlink_all();
8213 return TEST_SUCCESS;
8218 test_AES_GCM_authenticated_encryption_test_case_1(void)
8220 return test_authenticated_encryption(&gcm_test_case_1);
8224 test_AES_GCM_authenticated_encryption_test_case_2(void)
8226 return test_authenticated_encryption(&gcm_test_case_2);
8230 test_AES_GCM_authenticated_encryption_test_case_3(void)
8232 return test_authenticated_encryption(&gcm_test_case_3);
8236 test_AES_GCM_authenticated_encryption_test_case_4(void)
8238 return test_authenticated_encryption(&gcm_test_case_4);
8242 test_AES_GCM_authenticated_encryption_test_case_5(void)
8244 return test_authenticated_encryption(&gcm_test_case_5);
8248 test_AES_GCM_authenticated_encryption_test_case_6(void)
8250 return test_authenticated_encryption(&gcm_test_case_6);
8254 test_AES_GCM_authenticated_encryption_test_case_7(void)
8256 return test_authenticated_encryption(&gcm_test_case_7);
8260 test_AES_GCM_authenticated_encryption_test_case_8(void)
8262 return test_authenticated_encryption(&gcm_test_case_8);
8266 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
8268 return test_authenticated_encryption(&gcm_J0_test_case_1);
8272 test_AES_GCM_auth_encryption_test_case_192_1(void)
8274 return test_authenticated_encryption(&gcm_test_case_192_1);
8278 test_AES_GCM_auth_encryption_test_case_192_2(void)
8280 return test_authenticated_encryption(&gcm_test_case_192_2);
8284 test_AES_GCM_auth_encryption_test_case_192_3(void)
8286 return test_authenticated_encryption(&gcm_test_case_192_3);
8290 test_AES_GCM_auth_encryption_test_case_192_4(void)
8292 return test_authenticated_encryption(&gcm_test_case_192_4);
8296 test_AES_GCM_auth_encryption_test_case_192_5(void)
8298 return test_authenticated_encryption(&gcm_test_case_192_5);
8302 test_AES_GCM_auth_encryption_test_case_192_6(void)
8304 return test_authenticated_encryption(&gcm_test_case_192_6);
8308 test_AES_GCM_auth_encryption_test_case_192_7(void)
8310 return test_authenticated_encryption(&gcm_test_case_192_7);
8314 test_AES_GCM_auth_encryption_test_case_256_1(void)
8316 return test_authenticated_encryption(&gcm_test_case_256_1);
8320 test_AES_GCM_auth_encryption_test_case_256_2(void)
8322 return test_authenticated_encryption(&gcm_test_case_256_2);
8326 test_AES_GCM_auth_encryption_test_case_256_3(void)
8328 return test_authenticated_encryption(&gcm_test_case_256_3);
8332 test_AES_GCM_auth_encryption_test_case_256_4(void)
8334 return test_authenticated_encryption(&gcm_test_case_256_4);
8338 test_AES_GCM_auth_encryption_test_case_256_5(void)
8340 return test_authenticated_encryption(&gcm_test_case_256_5);
8344 test_AES_GCM_auth_encryption_test_case_256_6(void)
8346 return test_authenticated_encryption(&gcm_test_case_256_6);
8350 test_AES_GCM_auth_encryption_test_case_256_7(void)
8352 return test_authenticated_encryption(&gcm_test_case_256_7);
8356 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8358 return test_authenticated_encryption(&gcm_test_case_aad_1);
8362 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8364 return test_authenticated_encryption(&gcm_test_case_aad_2);
8368 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8370 struct aead_test_data tdata;
8373 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8374 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8375 tdata.iv.data[0] += 1;
8376 res = test_authenticated_encryption(&tdata);
8377 if (res == -ENOTSUP)
8379 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8380 return TEST_SUCCESS;
8384 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8386 struct aead_test_data tdata;
8389 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8390 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8391 tdata.plaintext.data[0] += 1;
8392 res = test_authenticated_encryption(&tdata);
8393 if (res == -ENOTSUP)
8395 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8396 return TEST_SUCCESS;
8400 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8402 struct aead_test_data tdata;
8405 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8406 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8407 tdata.ciphertext.data[0] += 1;
8408 res = test_authenticated_encryption(&tdata);
8409 if (res == -ENOTSUP)
8411 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8412 return TEST_SUCCESS;
8416 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8418 struct aead_test_data tdata;
8421 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8422 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8424 res = test_authenticated_encryption(&tdata);
8425 if (res == -ENOTSUP)
8427 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8428 return TEST_SUCCESS;
8432 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8434 struct aead_test_data tdata;
8435 uint8_t aad[gcm_test_case_7.aad.len];
8438 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8439 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8440 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8442 tdata.aad.data = aad;
8443 res = test_authenticated_encryption(&tdata);
8444 if (res == -ENOTSUP)
8446 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8447 return TEST_SUCCESS;
8451 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8453 struct aead_test_data tdata;
8456 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8457 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8458 tdata.auth_tag.data[0] += 1;
8459 res = test_authenticated_encryption(&tdata);
8460 if (res == -ENOTSUP)
8462 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8463 return TEST_SUCCESS;
8467 test_authenticated_decryption(const struct aead_test_data *tdata)
8469 struct crypto_testsuite_params *ts_params = &testsuite_params;
8470 struct crypto_unittest_params *ut_params = &unittest_params;
8476 /* Verify the capabilities */
8477 struct rte_cryptodev_sym_capability_idx cap_idx;
8478 const struct rte_cryptodev_symmetric_capability *capability;
8479 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8480 cap_idx.algo.aead = tdata->algo;
8481 capability = rte_cryptodev_sym_capability_get(
8482 ts_params->valid_devs[0], &cap_idx);
8483 if (capability == NULL)
8485 if (rte_cryptodev_sym_capability_check_aead(
8486 capability, tdata->key.len, tdata->auth_tag.len,
8487 tdata->aad.len, tdata->iv.len))
8490 /* Create AEAD session */
8491 retval = create_aead_session(ts_params->valid_devs[0],
8493 RTE_CRYPTO_AEAD_OP_DECRYPT,
8494 tdata->key.data, tdata->key.len,
8495 tdata->aad.len, tdata->auth_tag.len,
8500 /* alloc mbuf and set payload */
8501 if (tdata->aad.len > MBUF_SIZE) {
8502 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8503 /* Populate full size of add data */
8504 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8505 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8507 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8509 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8510 rte_pktmbuf_tailroom(ut_params->ibuf));
8512 /* Create AEAD operation */
8513 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8517 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8519 ut_params->op->sym->m_src = ut_params->ibuf;
8521 /* Process crypto operation */
8522 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8523 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8525 TEST_ASSERT_NOT_NULL(
8526 process_crypto_request(ts_params->valid_devs[0],
8527 ut_params->op), "failed to process sym crypto op");
8529 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8530 "crypto op processing failed");
8532 if (ut_params->op->sym->m_dst)
8533 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8536 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8538 ut_params->op->sym->cipher.data.offset);
8540 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8543 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8545 tdata->plaintext.data,
8546 tdata->plaintext.len,
8547 "Plaintext data not as expected");
8549 TEST_ASSERT_EQUAL(ut_params->op->status,
8550 RTE_CRYPTO_OP_STATUS_SUCCESS,
8551 "Authentication failed");
8557 test_AES_GCM_authenticated_decryption_test_case_1(void)
8559 return test_authenticated_decryption(&gcm_test_case_1);
8563 test_AES_GCM_authenticated_decryption_test_case_2(void)
8565 return test_authenticated_decryption(&gcm_test_case_2);
8569 test_AES_GCM_authenticated_decryption_test_case_3(void)
8571 return test_authenticated_decryption(&gcm_test_case_3);
8575 test_AES_GCM_authenticated_decryption_test_case_4(void)
8577 return test_authenticated_decryption(&gcm_test_case_4);
8581 test_AES_GCM_authenticated_decryption_test_case_5(void)
8583 return test_authenticated_decryption(&gcm_test_case_5);
8587 test_AES_GCM_authenticated_decryption_test_case_6(void)
8589 return test_authenticated_decryption(&gcm_test_case_6);
8593 test_AES_GCM_authenticated_decryption_test_case_7(void)
8595 return test_authenticated_decryption(&gcm_test_case_7);
8599 test_AES_GCM_authenticated_decryption_test_case_8(void)
8601 return test_authenticated_decryption(&gcm_test_case_8);
8605 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8607 return test_authenticated_decryption(&gcm_J0_test_case_1);
8611 test_AES_GCM_auth_decryption_test_case_192_1(void)
8613 return test_authenticated_decryption(&gcm_test_case_192_1);
8617 test_AES_GCM_auth_decryption_test_case_192_2(void)
8619 return test_authenticated_decryption(&gcm_test_case_192_2);
8623 test_AES_GCM_auth_decryption_test_case_192_3(void)
8625 return test_authenticated_decryption(&gcm_test_case_192_3);
8629 test_AES_GCM_auth_decryption_test_case_192_4(void)
8631 return test_authenticated_decryption(&gcm_test_case_192_4);
8635 test_AES_GCM_auth_decryption_test_case_192_5(void)
8637 return test_authenticated_decryption(&gcm_test_case_192_5);
8641 test_AES_GCM_auth_decryption_test_case_192_6(void)
8643 return test_authenticated_decryption(&gcm_test_case_192_6);
8647 test_AES_GCM_auth_decryption_test_case_192_7(void)
8649 return test_authenticated_decryption(&gcm_test_case_192_7);
8653 test_AES_GCM_auth_decryption_test_case_256_1(void)
8655 return test_authenticated_decryption(&gcm_test_case_256_1);
8659 test_AES_GCM_auth_decryption_test_case_256_2(void)
8661 return test_authenticated_decryption(&gcm_test_case_256_2);
8665 test_AES_GCM_auth_decryption_test_case_256_3(void)
8667 return test_authenticated_decryption(&gcm_test_case_256_3);
8671 test_AES_GCM_auth_decryption_test_case_256_4(void)
8673 return test_authenticated_decryption(&gcm_test_case_256_4);
8677 test_AES_GCM_auth_decryption_test_case_256_5(void)
8679 return test_authenticated_decryption(&gcm_test_case_256_5);
8683 test_AES_GCM_auth_decryption_test_case_256_6(void)
8685 return test_authenticated_decryption(&gcm_test_case_256_6);
8689 test_AES_GCM_auth_decryption_test_case_256_7(void)
8691 return test_authenticated_decryption(&gcm_test_case_256_7);
8695 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8697 return test_authenticated_decryption(&gcm_test_case_aad_1);
8701 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8703 return test_authenticated_decryption(&gcm_test_case_aad_2);
8707 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8709 struct aead_test_data tdata;
8712 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8713 tdata.iv.data[0] += 1;
8714 res = test_authenticated_decryption(&tdata);
8715 if (res == -ENOTSUP)
8717 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8718 return TEST_SUCCESS;
8722 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8724 struct aead_test_data tdata;
8727 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8728 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8729 tdata.plaintext.data[0] += 1;
8730 res = test_authenticated_decryption(&tdata);
8731 if (res == -ENOTSUP)
8733 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8734 return TEST_SUCCESS;
8738 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8740 struct aead_test_data tdata;
8743 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8744 tdata.ciphertext.data[0] += 1;
8745 res = test_authenticated_decryption(&tdata);
8746 if (res == -ENOTSUP)
8748 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8749 return TEST_SUCCESS;
8753 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8755 struct aead_test_data tdata;
8758 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8760 res = test_authenticated_decryption(&tdata);
8761 if (res == -ENOTSUP)
8763 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8764 return TEST_SUCCESS;
8768 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8770 struct aead_test_data tdata;
8771 uint8_t aad[gcm_test_case_7.aad.len];
8774 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8775 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8777 tdata.aad.data = aad;
8778 res = test_authenticated_decryption(&tdata);
8779 if (res == -ENOTSUP)
8781 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8782 return TEST_SUCCESS;
8786 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8788 struct aead_test_data tdata;
8791 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8792 tdata.auth_tag.data[0] += 1;
8793 res = test_authenticated_decryption(&tdata);
8794 if (res == -ENOTSUP)
8796 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8797 return TEST_SUCCESS;
8801 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8803 struct crypto_testsuite_params *ts_params = &testsuite_params;
8804 struct crypto_unittest_params *ut_params = &unittest_params;
8807 uint8_t *ciphertext, *auth_tag;
8808 uint16_t plaintext_pad_len;
8810 /* Verify the capabilities */
8811 struct rte_cryptodev_sym_capability_idx cap_idx;
8812 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8813 cap_idx.algo.aead = tdata->algo;
8814 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8818 /* not supported with CPU crypto */
8819 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8822 /* Create AEAD session */
8823 retval = create_aead_session(ts_params->valid_devs[0],
8825 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8826 tdata->key.data, tdata->key.len,
8827 tdata->aad.len, tdata->auth_tag.len,
8832 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8833 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8835 /* clear mbuf payload */
8836 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8837 rte_pktmbuf_tailroom(ut_params->ibuf));
8838 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8839 rte_pktmbuf_tailroom(ut_params->obuf));
8841 /* Create AEAD operation */
8842 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8846 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8848 ut_params->op->sym->m_src = ut_params->ibuf;
8849 ut_params->op->sym->m_dst = ut_params->obuf;
8851 /* Process crypto operation */
8852 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8853 ut_params->op), "failed to process sym crypto op");
8855 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8856 "crypto op processing failed");
8858 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8860 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8861 ut_params->op->sym->cipher.data.offset);
8862 auth_tag = ciphertext + plaintext_pad_len;
8864 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8865 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8868 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8870 tdata->ciphertext.data,
8871 tdata->ciphertext.len,
8872 "Ciphertext data not as expected");
8874 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8876 tdata->auth_tag.data,
8877 tdata->auth_tag.len,
8878 "Generated auth tag not as expected");
8885 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8887 return test_authenticated_encryption_oop(&gcm_test_case_5);
8891 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8893 struct crypto_testsuite_params *ts_params = &testsuite_params;
8894 struct crypto_unittest_params *ut_params = &unittest_params;
8899 /* Verify the capabilities */
8900 struct rte_cryptodev_sym_capability_idx cap_idx;
8901 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8902 cap_idx.algo.aead = tdata->algo;
8903 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8907 /* not supported with CPU crypto */
8908 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8911 /* Create AEAD session */
8912 retval = create_aead_session(ts_params->valid_devs[0],
8914 RTE_CRYPTO_AEAD_OP_DECRYPT,
8915 tdata->key.data, tdata->key.len,
8916 tdata->aad.len, tdata->auth_tag.len,
8921 /* alloc mbuf and set payload */
8922 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8923 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8925 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8926 rte_pktmbuf_tailroom(ut_params->ibuf));
8927 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8928 rte_pktmbuf_tailroom(ut_params->obuf));
8930 /* Create AEAD operation */
8931 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8935 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8937 ut_params->op->sym->m_src = ut_params->ibuf;
8938 ut_params->op->sym->m_dst = ut_params->obuf;
8940 /* Process crypto operation */
8941 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8942 ut_params->op), "failed to process sym crypto op");
8944 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8945 "crypto op processing failed");
8947 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8948 ut_params->op->sym->cipher.data.offset);
8950 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8953 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8955 tdata->plaintext.data,
8956 tdata->plaintext.len,
8957 "Plaintext data not as expected");
8959 TEST_ASSERT_EQUAL(ut_params->op->status,
8960 RTE_CRYPTO_OP_STATUS_SUCCESS,
8961 "Authentication failed");
8966 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8968 return test_authenticated_decryption_oop(&gcm_test_case_5);
8972 test_authenticated_encryption_sessionless(
8973 const struct aead_test_data *tdata)
8975 struct crypto_testsuite_params *ts_params = &testsuite_params;
8976 struct crypto_unittest_params *ut_params = &unittest_params;
8979 uint8_t *ciphertext, *auth_tag;
8980 uint16_t plaintext_pad_len;
8981 uint8_t key[tdata->key.len + 1];
8982 struct rte_cryptodev_info dev_info;
8984 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8985 uint64_t feat_flags = dev_info.feature_flags;
8987 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8988 printf("Device doesn't support Sessionless ops.\n");
8992 /* not supported with CPU crypto */
8993 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8996 /* Verify the capabilities */
8997 struct rte_cryptodev_sym_capability_idx cap_idx;
8998 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8999 cap_idx.algo.aead = tdata->algo;
9000 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9004 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9006 /* clear mbuf payload */
9007 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9008 rte_pktmbuf_tailroom(ut_params->ibuf));
9010 /* Create AEAD operation */
9011 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9015 /* Create GCM xform */
9016 memcpy(key, tdata->key.data, tdata->key.len);
9017 retval = create_aead_xform(ut_params->op,
9019 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9020 key, tdata->key.len,
9021 tdata->aad.len, tdata->auth_tag.len,
9026 ut_params->op->sym->m_src = ut_params->ibuf;
9028 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9029 RTE_CRYPTO_OP_SESSIONLESS,
9030 "crypto op session type not sessionless");
9032 /* Process crypto operation */
9033 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9034 ut_params->op), "failed to process sym crypto op");
9036 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9038 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9039 "crypto op status not success");
9041 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9043 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9044 ut_params->op->sym->cipher.data.offset);
9045 auth_tag = ciphertext + plaintext_pad_len;
9047 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9048 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9051 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9053 tdata->ciphertext.data,
9054 tdata->ciphertext.len,
9055 "Ciphertext data not as expected");
9057 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9059 tdata->auth_tag.data,
9060 tdata->auth_tag.len,
9061 "Generated auth tag not as expected");
9068 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9070 return test_authenticated_encryption_sessionless(
9075 test_authenticated_decryption_sessionless(
9076 const struct aead_test_data *tdata)
9078 struct crypto_testsuite_params *ts_params = &testsuite_params;
9079 struct crypto_unittest_params *ut_params = &unittest_params;
9083 uint8_t key[tdata->key.len + 1];
9084 struct rte_cryptodev_info dev_info;
9086 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9087 uint64_t feat_flags = dev_info.feature_flags;
9089 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9090 printf("Device doesn't support Sessionless ops.\n");
9094 /* not supported with CPU crypto */
9095 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9098 /* Verify the capabilities */
9099 struct rte_cryptodev_sym_capability_idx cap_idx;
9100 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9101 cap_idx.algo.aead = tdata->algo;
9102 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9106 /* alloc mbuf and set payload */
9107 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9109 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9110 rte_pktmbuf_tailroom(ut_params->ibuf));
9112 /* Create AEAD operation */
9113 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9117 /* Create AEAD xform */
9118 memcpy(key, tdata->key.data, tdata->key.len);
9119 retval = create_aead_xform(ut_params->op,
9121 RTE_CRYPTO_AEAD_OP_DECRYPT,
9122 key, tdata->key.len,
9123 tdata->aad.len, tdata->auth_tag.len,
9128 ut_params->op->sym->m_src = ut_params->ibuf;
9130 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9131 RTE_CRYPTO_OP_SESSIONLESS,
9132 "crypto op session type not sessionless");
9134 /* Process crypto operation */
9135 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9136 ut_params->op), "failed to process sym crypto op");
9138 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9140 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9141 "crypto op status not success");
9143 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9144 ut_params->op->sym->cipher.data.offset);
9146 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9149 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9151 tdata->plaintext.data,
9152 tdata->plaintext.len,
9153 "Plaintext data not as expected");
9155 TEST_ASSERT_EQUAL(ut_params->op->status,
9156 RTE_CRYPTO_OP_STATUS_SUCCESS,
9157 "Authentication failed");
9162 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9164 return test_authenticated_decryption_sessionless(
9169 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9171 return test_authenticated_encryption(&ccm_test_case_128_1);
9175 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9177 return test_authenticated_encryption(&ccm_test_case_128_2);
9181 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9183 return test_authenticated_encryption(&ccm_test_case_128_3);
9187 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9189 return test_authenticated_decryption(&ccm_test_case_128_1);
9193 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9195 return test_authenticated_decryption(&ccm_test_case_128_2);
9199 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9201 return test_authenticated_decryption(&ccm_test_case_128_3);
9205 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9207 return test_authenticated_encryption(&ccm_test_case_192_1);
9211 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9213 return test_authenticated_encryption(&ccm_test_case_192_2);
9217 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9219 return test_authenticated_encryption(&ccm_test_case_192_3);
9223 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9225 return test_authenticated_decryption(&ccm_test_case_192_1);
9229 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9231 return test_authenticated_decryption(&ccm_test_case_192_2);
9235 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9237 return test_authenticated_decryption(&ccm_test_case_192_3);
9241 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9243 return test_authenticated_encryption(&ccm_test_case_256_1);
9247 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9249 return test_authenticated_encryption(&ccm_test_case_256_2);
9253 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9255 return test_authenticated_encryption(&ccm_test_case_256_3);
9259 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9261 return test_authenticated_decryption(&ccm_test_case_256_1);
9265 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9267 return test_authenticated_decryption(&ccm_test_case_256_2);
9271 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9273 return test_authenticated_decryption(&ccm_test_case_256_3);
9279 struct crypto_testsuite_params *ts_params = &testsuite_params;
9280 struct rte_cryptodev_stats stats;
9282 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9285 /* Verify the capabilities */
9286 struct rte_cryptodev_sym_capability_idx cap_idx;
9287 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9288 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
9289 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9292 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9293 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9294 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9298 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9302 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9303 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9304 &stats) == -ENODEV),
9305 "rte_cryptodev_stats_get invalid dev failed");
9306 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9307 "rte_cryptodev_stats_get invalid Param failed");
9309 /* Test expected values */
9311 test_AES_CBC_HMAC_SHA1_encrypt_digest();
9313 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9315 "rte_cryptodev_stats_get failed");
9316 TEST_ASSERT((stats.enqueued_count == 1),
9317 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9318 TEST_ASSERT((stats.dequeued_count == 1),
9319 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9320 TEST_ASSERT((stats.enqueue_err_count == 0),
9321 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9322 TEST_ASSERT((stats.dequeue_err_count == 0),
9323 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9325 /* invalid device but should ignore and not reset device stats*/
9326 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9327 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9329 "rte_cryptodev_stats_get failed");
9330 TEST_ASSERT((stats.enqueued_count == 1),
9331 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9333 /* check that a valid reset clears stats */
9334 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9335 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9337 "rte_cryptodev_stats_get failed");
9338 TEST_ASSERT((stats.enqueued_count == 0),
9339 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9340 TEST_ASSERT((stats.dequeued_count == 0),
9341 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9343 return TEST_SUCCESS;
9346 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9347 struct crypto_unittest_params *ut_params,
9348 enum rte_crypto_auth_operation op,
9349 const struct HMAC_MD5_vector *test_case)
9353 memcpy(key, test_case->key.data, test_case->key.len);
9355 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9356 ut_params->auth_xform.next = NULL;
9357 ut_params->auth_xform.auth.op = op;
9359 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9361 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9362 ut_params->auth_xform.auth.key.length = test_case->key.len;
9363 ut_params->auth_xform.auth.key.data = key;
9365 ut_params->sess = rte_cryptodev_sym_session_create(
9366 ts_params->session_mpool);
9368 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9369 ut_params->sess, &ut_params->auth_xform,
9370 ts_params->session_priv_mpool);
9372 if (ut_params->sess == NULL)
9375 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9377 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9378 rte_pktmbuf_tailroom(ut_params->ibuf));
9383 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9384 const struct HMAC_MD5_vector *test_case,
9385 uint8_t **plaintext)
9387 uint16_t plaintext_pad_len;
9389 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9391 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9394 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9396 memcpy(*plaintext, test_case->plaintext.data,
9397 test_case->plaintext.len);
9399 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9400 ut_params->ibuf, MD5_DIGEST_LEN);
9401 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9402 "no room to append digest");
9403 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9404 ut_params->ibuf, plaintext_pad_len);
9406 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9407 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9408 test_case->auth_tag.len);
9411 sym_op->auth.data.offset = 0;
9412 sym_op->auth.data.length = test_case->plaintext.len;
9414 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9415 ut_params->op->sym->m_src = ut_params->ibuf;
9421 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9423 uint16_t plaintext_pad_len;
9424 uint8_t *plaintext, *auth_tag;
9426 struct crypto_testsuite_params *ts_params = &testsuite_params;
9427 struct crypto_unittest_params *ut_params = &unittest_params;
9429 /* Verify the capabilities */
9430 struct rte_cryptodev_sym_capability_idx cap_idx;
9431 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9432 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9433 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9437 if (MD5_HMAC_create_session(ts_params, ut_params,
9438 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9441 /* Generate Crypto op data structure */
9442 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9443 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9444 TEST_ASSERT_NOT_NULL(ut_params->op,
9445 "Failed to allocate symmetric crypto operation struct");
9447 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9450 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9453 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9454 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9457 TEST_ASSERT_NOT_NULL(
9458 process_crypto_request(ts_params->valid_devs[0],
9460 "failed to process sym crypto op");
9462 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9463 "crypto op processing failed");
9465 if (ut_params->op->sym->m_dst) {
9466 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9467 uint8_t *, plaintext_pad_len);
9469 auth_tag = plaintext + plaintext_pad_len;
9472 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9474 test_case->auth_tag.data,
9475 test_case->auth_tag.len,
9476 "HMAC_MD5 generated tag not as expected");
9478 return TEST_SUCCESS;
9482 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9486 struct crypto_testsuite_params *ts_params = &testsuite_params;
9487 struct crypto_unittest_params *ut_params = &unittest_params;
9489 /* Verify the capabilities */
9490 struct rte_cryptodev_sym_capability_idx cap_idx;
9491 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9492 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9493 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9497 if (MD5_HMAC_create_session(ts_params, ut_params,
9498 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9502 /* Generate Crypto op data structure */
9503 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9504 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9505 TEST_ASSERT_NOT_NULL(ut_params->op,
9506 "Failed to allocate symmetric crypto operation struct");
9508 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9511 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9512 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9515 TEST_ASSERT_NOT_NULL(
9516 process_crypto_request(ts_params->valid_devs[0],
9518 "failed to process sym crypto op");
9520 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9521 "HMAC_MD5 crypto op processing failed");
9523 return TEST_SUCCESS;
9527 test_MD5_HMAC_generate_case_1(void)
9529 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9533 test_MD5_HMAC_verify_case_1(void)
9535 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9539 test_MD5_HMAC_generate_case_2(void)
9541 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9545 test_MD5_HMAC_verify_case_2(void)
9547 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9551 test_multi_session(void)
9553 struct crypto_testsuite_params *ts_params = &testsuite_params;
9554 struct crypto_unittest_params *ut_params = &unittest_params;
9556 struct rte_cryptodev_info dev_info;
9557 struct rte_cryptodev_sym_session **sessions;
9561 /* Verify the capabilities */
9562 struct rte_cryptodev_sym_capability_idx cap_idx;
9563 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9564 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9565 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9568 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9569 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9570 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9574 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9575 aes_cbc_key, hmac_sha512_key);
9578 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9580 sessions = rte_malloc(NULL,
9581 (sizeof(struct rte_cryptodev_sym_session *) *
9582 MAX_NB_SESSIONS) + 1, 0);
9584 /* Create multiple crypto sessions*/
9585 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9587 sessions[i] = rte_cryptodev_sym_session_create(
9588 ts_params->session_mpool);
9590 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9591 sessions[i], &ut_params->auth_xform,
9592 ts_params->session_priv_mpool);
9593 TEST_ASSERT_NOT_NULL(sessions[i],
9594 "Session creation failed at session number %u",
9597 /* Attempt to send a request on each session */
9598 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9602 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9603 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9605 "Failed to perform decrypt on request number %u.", i);
9606 /* free crypto operation structure */
9608 rte_crypto_op_free(ut_params->op);
9611 * free mbuf - both obuf and ibuf are usually the same,
9612 * so check if they point at the same address is necessary,
9613 * to avoid freeing the mbuf twice.
9615 if (ut_params->obuf) {
9616 rte_pktmbuf_free(ut_params->obuf);
9617 if (ut_params->ibuf == ut_params->obuf)
9618 ut_params->ibuf = 0;
9619 ut_params->obuf = 0;
9621 if (ut_params->ibuf) {
9622 rte_pktmbuf_free(ut_params->ibuf);
9623 ut_params->ibuf = 0;
9627 /* Next session create should fail */
9628 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9629 sessions[i], &ut_params->auth_xform,
9630 ts_params->session_priv_mpool);
9631 TEST_ASSERT_NULL(sessions[i],
9632 "Session creation succeeded unexpectedly!");
9634 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9635 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9637 rte_cryptodev_sym_session_free(sessions[i]);
9642 return TEST_SUCCESS;
9645 struct multi_session_params {
9646 struct crypto_unittest_params ut_params;
9647 uint8_t *cipher_key;
9649 const uint8_t *cipher;
9650 const uint8_t *digest;
9654 #define MB_SESSION_NUMBER 3
9657 test_multi_session_random_usage(void)
9659 struct crypto_testsuite_params *ts_params = &testsuite_params;
9660 struct rte_cryptodev_info dev_info;
9661 struct rte_cryptodev_sym_session **sessions;
9663 struct multi_session_params ut_paramz[] = {
9666 .cipher_key = ms_aes_cbc_key0,
9667 .hmac_key = ms_hmac_key0,
9668 .cipher = ms_aes_cbc_cipher0,
9669 .digest = ms_hmac_digest0,
9670 .iv = ms_aes_cbc_iv0
9673 .cipher_key = ms_aes_cbc_key1,
9674 .hmac_key = ms_hmac_key1,
9675 .cipher = ms_aes_cbc_cipher1,
9676 .digest = ms_hmac_digest1,
9677 .iv = ms_aes_cbc_iv1
9680 .cipher_key = ms_aes_cbc_key2,
9681 .hmac_key = ms_hmac_key2,
9682 .cipher = ms_aes_cbc_cipher2,
9683 .digest = ms_hmac_digest2,
9684 .iv = ms_aes_cbc_iv2
9689 /* Verify the capabilities */
9690 struct rte_cryptodev_sym_capability_idx cap_idx;
9691 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9692 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9693 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9696 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9697 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9698 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9702 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9704 sessions = rte_malloc(NULL,
9705 (sizeof(struct rte_cryptodev_sym_session *)
9706 * MAX_NB_SESSIONS) + 1, 0);
9708 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9709 sessions[i] = rte_cryptodev_sym_session_create(
9710 ts_params->session_mpool);
9712 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9713 sizeof(struct crypto_unittest_params));
9715 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9716 &ut_paramz[i].ut_params,
9717 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9719 /* Create multiple crypto sessions*/
9720 rte_cryptodev_sym_session_init(
9721 ts_params->valid_devs[0],
9723 &ut_paramz[i].ut_params.auth_xform,
9724 ts_params->session_priv_mpool);
9726 TEST_ASSERT_NOT_NULL(sessions[i],
9727 "Session creation failed at session number %u",
9733 for (i = 0; i < 40000; i++) {
9735 j = rand() % MB_SESSION_NUMBER;
9737 TEST_ASSERT_SUCCESS(
9738 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9740 &ut_paramz[j].ut_params,
9741 ts_params, ut_paramz[j].cipher,
9742 ut_paramz[j].digest,
9744 "Failed to perform decrypt on request number %u.", i);
9746 if (ut_paramz[j].ut_params.op)
9747 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9750 * free mbuf - both obuf and ibuf are usually the same,
9751 * so check if they point at the same address is necessary,
9752 * to avoid freeing the mbuf twice.
9754 if (ut_paramz[j].ut_params.obuf) {
9755 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9756 if (ut_paramz[j].ut_params.ibuf
9757 == ut_paramz[j].ut_params.obuf)
9758 ut_paramz[j].ut_params.ibuf = 0;
9759 ut_paramz[j].ut_params.obuf = 0;
9761 if (ut_paramz[j].ut_params.ibuf) {
9762 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9763 ut_paramz[j].ut_params.ibuf = 0;
9767 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9768 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9770 rte_cryptodev_sym_session_free(sessions[i]);
9775 return TEST_SUCCESS;
9778 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9779 0xab, 0xab, 0xab, 0xab,
9780 0xab, 0xab, 0xab, 0xab,
9781 0xab, 0xab, 0xab, 0xab};
9784 test_null_invalid_operation(void)
9786 struct crypto_testsuite_params *ts_params = &testsuite_params;
9787 struct crypto_unittest_params *ut_params = &unittest_params;
9790 /* This test is for NULL PMD only */
9791 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9792 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9795 /* Setup Cipher Parameters */
9796 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9797 ut_params->cipher_xform.next = NULL;
9799 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9800 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9802 ut_params->sess = rte_cryptodev_sym_session_create(
9803 ts_params->session_mpool);
9805 /* Create Crypto session*/
9806 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9807 ut_params->sess, &ut_params->cipher_xform,
9808 ts_params->session_priv_mpool);
9809 TEST_ASSERT(ret < 0,
9810 "Session creation succeeded unexpectedly");
9813 /* Setup HMAC Parameters */
9814 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9815 ut_params->auth_xform.next = NULL;
9817 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9818 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9820 ut_params->sess = rte_cryptodev_sym_session_create(
9821 ts_params->session_mpool);
9823 /* Create Crypto session*/
9824 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9825 ut_params->sess, &ut_params->auth_xform,
9826 ts_params->session_priv_mpool);
9827 TEST_ASSERT(ret < 0,
9828 "Session creation succeeded unexpectedly");
9830 return TEST_SUCCESS;
9834 #define NULL_BURST_LENGTH (32)
9837 test_null_burst_operation(void)
9839 struct crypto_testsuite_params *ts_params = &testsuite_params;
9840 struct crypto_unittest_params *ut_params = &unittest_params;
9842 unsigned i, burst_len = NULL_BURST_LENGTH;
9844 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9845 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9847 /* This test is for NULL PMD only */
9848 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9849 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9852 /* Setup Cipher Parameters */
9853 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9854 ut_params->cipher_xform.next = &ut_params->auth_xform;
9856 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9857 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9859 /* Setup HMAC Parameters */
9860 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9861 ut_params->auth_xform.next = NULL;
9863 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9864 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9866 ut_params->sess = rte_cryptodev_sym_session_create(
9867 ts_params->session_mpool);
9869 /* Create Crypto session*/
9870 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9871 ut_params->sess, &ut_params->cipher_xform,
9872 ts_params->session_priv_mpool);
9873 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9875 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9876 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9877 burst_len, "failed to generate burst of crypto ops");
9879 /* Generate an operation for each mbuf in burst */
9880 for (i = 0; i < burst_len; i++) {
9881 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9883 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9885 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9889 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9891 burst[i]->sym->m_src = m;
9894 /* Process crypto operation */
9895 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9896 0, burst, burst_len),
9898 "Error enqueuing burst");
9900 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9901 0, burst_dequeued, burst_len),
9903 "Error dequeuing burst");
9906 for (i = 0; i < burst_len; i++) {
9908 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9909 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9911 "data not as expected");
9913 rte_pktmbuf_free(burst[i]->sym->m_src);
9914 rte_crypto_op_free(burst[i]);
9917 return TEST_SUCCESS;
9921 generate_gmac_large_plaintext(uint8_t *data)
9925 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9926 memcpy(&data[i], &data[0], 32);
9930 create_gmac_operation(enum rte_crypto_auth_operation op,
9931 const struct gmac_test_data *tdata)
9933 struct crypto_testsuite_params *ts_params = &testsuite_params;
9934 struct crypto_unittest_params *ut_params = &unittest_params;
9935 struct rte_crypto_sym_op *sym_op;
9937 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9939 /* Generate Crypto op data structure */
9940 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9941 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9942 TEST_ASSERT_NOT_NULL(ut_params->op,
9943 "Failed to allocate symmetric crypto operation struct");
9945 sym_op = ut_params->op->sym;
9947 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9948 ut_params->ibuf, tdata->gmac_tag.len);
9949 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9950 "no room to append digest");
9952 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9953 ut_params->ibuf, plaintext_pad_len);
9955 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9956 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9957 tdata->gmac_tag.len);
9958 debug_hexdump(stdout, "digest:",
9959 sym_op->auth.digest.data,
9960 tdata->gmac_tag.len);
9963 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9964 uint8_t *, IV_OFFSET);
9966 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9968 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9970 sym_op->cipher.data.length = 0;
9971 sym_op->cipher.data.offset = 0;
9973 sym_op->auth.data.offset = 0;
9974 sym_op->auth.data.length = tdata->plaintext.len;
9979 static int create_gmac_session(uint8_t dev_id,
9980 const struct gmac_test_data *tdata,
9981 enum rte_crypto_auth_operation auth_op)
9983 uint8_t auth_key[tdata->key.len];
9985 struct crypto_testsuite_params *ts_params = &testsuite_params;
9986 struct crypto_unittest_params *ut_params = &unittest_params;
9988 memcpy(auth_key, tdata->key.data, tdata->key.len);
9990 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9991 ut_params->auth_xform.next = NULL;
9993 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9994 ut_params->auth_xform.auth.op = auth_op;
9995 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9996 ut_params->auth_xform.auth.key.length = tdata->key.len;
9997 ut_params->auth_xform.auth.key.data = auth_key;
9998 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9999 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10002 ut_params->sess = rte_cryptodev_sym_session_create(
10003 ts_params->session_mpool);
10005 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10006 &ut_params->auth_xform,
10007 ts_params->session_priv_mpool);
10009 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10015 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10017 struct crypto_testsuite_params *ts_params = &testsuite_params;
10018 struct crypto_unittest_params *ut_params = &unittest_params;
10022 uint8_t *auth_tag, *plaintext;
10023 uint16_t plaintext_pad_len;
10025 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10026 "No GMAC length in the source data");
10028 /* Verify the capabilities */
10029 struct rte_cryptodev_sym_capability_idx cap_idx;
10030 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10031 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10032 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10036 retval = create_gmac_session(ts_params->valid_devs[0],
10037 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10042 if (tdata->plaintext.len > MBUF_SIZE)
10043 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10045 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10046 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10047 "Failed to allocate input buffer in mempool");
10049 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10050 rte_pktmbuf_tailroom(ut_params->ibuf));
10052 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10054 * Runtime generate the large plain text instead of use hard code
10055 * plain text vector. It is done to avoid create huge source file
10056 * with the test vector.
10058 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10059 generate_gmac_large_plaintext(tdata->plaintext.data);
10061 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10062 plaintext_pad_len);
10063 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10065 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10066 debug_hexdump(stdout, "plaintext:", plaintext,
10067 tdata->plaintext.len);
10069 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10075 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10077 ut_params->op->sym->m_src = ut_params->ibuf;
10079 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10080 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10083 TEST_ASSERT_NOT_NULL(
10084 process_crypto_request(ts_params->valid_devs[0],
10085 ut_params->op), "failed to process sym crypto op");
10087 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10088 "crypto op processing failed");
10090 if (ut_params->op->sym->m_dst) {
10091 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10092 uint8_t *, plaintext_pad_len);
10094 auth_tag = plaintext + plaintext_pad_len;
10097 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10099 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10101 tdata->gmac_tag.data,
10102 tdata->gmac_tag.len,
10103 "GMAC Generated auth tag not as expected");
10109 test_AES_GMAC_authentication_test_case_1(void)
10111 return test_AES_GMAC_authentication(&gmac_test_case_1);
10115 test_AES_GMAC_authentication_test_case_2(void)
10117 return test_AES_GMAC_authentication(&gmac_test_case_2);
10121 test_AES_GMAC_authentication_test_case_3(void)
10123 return test_AES_GMAC_authentication(&gmac_test_case_3);
10127 test_AES_GMAC_authentication_test_case_4(void)
10129 return test_AES_GMAC_authentication(&gmac_test_case_4);
10133 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10135 struct crypto_testsuite_params *ts_params = &testsuite_params;
10136 struct crypto_unittest_params *ut_params = &unittest_params;
10138 uint32_t plaintext_pad_len;
10139 uint8_t *plaintext;
10141 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10142 "No GMAC length in the source data");
10144 /* Verify the capabilities */
10145 struct rte_cryptodev_sym_capability_idx cap_idx;
10146 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10147 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10148 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10152 retval = create_gmac_session(ts_params->valid_devs[0],
10153 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10158 if (tdata->plaintext.len > MBUF_SIZE)
10159 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10161 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10162 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10163 "Failed to allocate input buffer in mempool");
10165 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10166 rte_pktmbuf_tailroom(ut_params->ibuf));
10168 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10171 * Runtime generate the large plain text instead of use hard code
10172 * plain text vector. It is done to avoid create huge source file
10173 * with the test vector.
10175 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10176 generate_gmac_large_plaintext(tdata->plaintext.data);
10178 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10179 plaintext_pad_len);
10180 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10182 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10183 debug_hexdump(stdout, "plaintext:", plaintext,
10184 tdata->plaintext.len);
10186 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10192 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10194 ut_params->op->sym->m_src = ut_params->ibuf;
10196 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10197 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10200 TEST_ASSERT_NOT_NULL(
10201 process_crypto_request(ts_params->valid_devs[0],
10202 ut_params->op), "failed to process sym crypto op");
10204 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10205 "crypto op processing failed");
10212 test_AES_GMAC_authentication_verify_test_case_1(void)
10214 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10218 test_AES_GMAC_authentication_verify_test_case_2(void)
10220 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10224 test_AES_GMAC_authentication_verify_test_case_3(void)
10226 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10230 test_AES_GMAC_authentication_verify_test_case_4(void)
10232 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10235 struct test_crypto_vector {
10236 enum rte_crypto_cipher_algorithm crypto_algo;
10237 unsigned int cipher_offset;
10238 unsigned int cipher_len;
10251 const uint8_t *data;
10256 const uint8_t *data;
10260 enum rte_crypto_auth_algorithm auth_algo;
10261 unsigned int auth_offset;
10269 const uint8_t *data;
10279 static const struct test_crypto_vector
10280 hmac_sha1_test_crypto_vector = {
10281 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10283 .data = plaintext_hash,
10288 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10289 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10290 0xDE, 0xF4, 0xDE, 0xAD
10296 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10297 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10298 0x3F, 0x91, 0x64, 0x59
10304 static const struct test_crypto_vector
10305 aes128_gmac_test_vector = {
10306 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10308 .data = plaintext_hash,
10313 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10314 0x08, 0x09, 0x0A, 0x0B
10320 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10321 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10327 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10328 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10334 static const struct test_crypto_vector
10335 aes128cbc_hmac_sha1_test_vector = {
10336 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10337 .cipher_offset = 0,
10341 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10342 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10348 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10349 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10354 .data = plaintext_hash,
10358 .data = ciphertext512_aes128cbc,
10361 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10365 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10366 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10367 0xDE, 0xF4, 0xDE, 0xAD
10373 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10374 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10375 0x18, 0x8C, 0x1D, 0x32
10381 static const struct test_crypto_vector
10382 aes128cbc_hmac_sha1_aad_test_vector = {
10383 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10384 .cipher_offset = 12,
10388 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10389 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10395 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10396 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10401 .data = plaintext_hash,
10405 .data = ciphertext512_aes128cbc_aad,
10408 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10412 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10413 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10414 0xDE, 0xF4, 0xDE, 0xAD
10420 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10421 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10422 0x62, 0x8D, 0x62, 0x65
10429 data_corruption(uint8_t *data)
10435 tag_corruption(uint8_t *data, unsigned int tag_offset)
10437 data[tag_offset] += 1;
10441 create_auth_session(struct crypto_unittest_params *ut_params,
10443 const struct test_crypto_vector *reference,
10444 enum rte_crypto_auth_operation auth_op)
10446 struct crypto_testsuite_params *ts_params = &testsuite_params;
10447 uint8_t auth_key[reference->auth_key.len + 1];
10449 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10451 /* Setup Authentication Parameters */
10452 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10453 ut_params->auth_xform.auth.op = auth_op;
10454 ut_params->auth_xform.next = NULL;
10455 ut_params->auth_xform.auth.algo = reference->auth_algo;
10456 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10457 ut_params->auth_xform.auth.key.data = auth_key;
10458 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10460 /* Create Crypto session*/
10461 ut_params->sess = rte_cryptodev_sym_session_create(
10462 ts_params->session_mpool);
10464 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10465 &ut_params->auth_xform,
10466 ts_params->session_priv_mpool);
10468 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10474 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10476 const struct test_crypto_vector *reference,
10477 enum rte_crypto_auth_operation auth_op,
10478 enum rte_crypto_cipher_operation cipher_op)
10480 struct crypto_testsuite_params *ts_params = &testsuite_params;
10481 uint8_t cipher_key[reference->cipher_key.len + 1];
10482 uint8_t auth_key[reference->auth_key.len + 1];
10484 memcpy(cipher_key, reference->cipher_key.data,
10485 reference->cipher_key.len);
10486 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10488 /* Setup Authentication Parameters */
10489 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10490 ut_params->auth_xform.auth.op = auth_op;
10491 ut_params->auth_xform.auth.algo = reference->auth_algo;
10492 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10493 ut_params->auth_xform.auth.key.data = auth_key;
10494 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10496 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10497 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10498 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10500 ut_params->auth_xform.next = &ut_params->cipher_xform;
10502 /* Setup Cipher Parameters */
10503 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10504 ut_params->cipher_xform.next = NULL;
10505 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10506 ut_params->cipher_xform.cipher.op = cipher_op;
10507 ut_params->cipher_xform.cipher.key.data = cipher_key;
10508 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10509 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10510 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10513 /* Create Crypto session*/
10514 ut_params->sess = rte_cryptodev_sym_session_create(
10515 ts_params->session_mpool);
10517 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10518 &ut_params->auth_xform,
10519 ts_params->session_priv_mpool);
10521 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10527 create_auth_operation(struct crypto_testsuite_params *ts_params,
10528 struct crypto_unittest_params *ut_params,
10529 const struct test_crypto_vector *reference,
10530 unsigned int auth_generate)
10532 /* Generate Crypto op data structure */
10533 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10534 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10535 TEST_ASSERT_NOT_NULL(ut_params->op,
10536 "Failed to allocate pktmbuf offload");
10538 /* Set crypto operation data parameters */
10539 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10541 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10543 /* set crypto operation source mbuf */
10544 sym_op->m_src = ut_params->ibuf;
10547 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10548 ut_params->ibuf, reference->digest.len);
10550 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10551 "no room to append auth tag");
10553 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10554 ut_params->ibuf, reference->plaintext.len);
10557 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10559 memcpy(sym_op->auth.digest.data,
10560 reference->digest.data,
10561 reference->digest.len);
10563 debug_hexdump(stdout, "digest:",
10564 sym_op->auth.digest.data,
10565 reference->digest.len);
10567 sym_op->auth.data.length = reference->plaintext.len;
10568 sym_op->auth.data.offset = 0;
10574 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10575 struct crypto_unittest_params *ut_params,
10576 const struct test_crypto_vector *reference,
10577 unsigned int auth_generate)
10579 /* Generate Crypto op data structure */
10580 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10581 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10582 TEST_ASSERT_NOT_NULL(ut_params->op,
10583 "Failed to allocate pktmbuf offload");
10585 /* Set crypto operation data parameters */
10586 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10588 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10590 /* set crypto operation source mbuf */
10591 sym_op->m_src = ut_params->ibuf;
10594 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10595 ut_params->ibuf, reference->digest.len);
10597 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10598 "no room to append auth tag");
10600 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10601 ut_params->ibuf, reference->ciphertext.len);
10604 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10606 memcpy(sym_op->auth.digest.data,
10607 reference->digest.data,
10608 reference->digest.len);
10610 debug_hexdump(stdout, "digest:",
10611 sym_op->auth.digest.data,
10612 reference->digest.len);
10614 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10615 reference->iv.data, reference->iv.len);
10617 sym_op->cipher.data.length = 0;
10618 sym_op->cipher.data.offset = 0;
10620 sym_op->auth.data.length = reference->plaintext.len;
10621 sym_op->auth.data.offset = 0;
10627 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10628 struct crypto_unittest_params *ut_params,
10629 const struct test_crypto_vector *reference,
10630 unsigned int auth_generate)
10632 /* Generate Crypto op data structure */
10633 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10634 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10635 TEST_ASSERT_NOT_NULL(ut_params->op,
10636 "Failed to allocate pktmbuf offload");
10638 /* Set crypto operation data parameters */
10639 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10641 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10643 /* set crypto operation source mbuf */
10644 sym_op->m_src = ut_params->ibuf;
10647 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10648 ut_params->ibuf, reference->digest.len);
10650 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10651 "no room to append auth tag");
10653 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10654 ut_params->ibuf, reference->ciphertext.len);
10657 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10659 memcpy(sym_op->auth.digest.data,
10660 reference->digest.data,
10661 reference->digest.len);
10663 debug_hexdump(stdout, "digest:",
10664 sym_op->auth.digest.data,
10665 reference->digest.len);
10667 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10668 reference->iv.data, reference->iv.len);
10670 sym_op->cipher.data.length = reference->cipher_len;
10671 sym_op->cipher.data.offset = reference->cipher_offset;
10673 sym_op->auth.data.length = reference->plaintext.len;
10674 sym_op->auth.data.offset = reference->auth_offset;
10680 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10681 struct crypto_unittest_params *ut_params,
10682 const struct test_crypto_vector *reference)
10684 return create_auth_operation(ts_params, ut_params, reference, 0);
10688 create_auth_verify_GMAC_operation(
10689 struct crypto_testsuite_params *ts_params,
10690 struct crypto_unittest_params *ut_params,
10691 const struct test_crypto_vector *reference)
10693 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10697 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10698 struct crypto_unittest_params *ut_params,
10699 const struct test_crypto_vector *reference)
10701 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10705 test_authentication_verify_fail_when_data_corruption(
10706 struct crypto_testsuite_params *ts_params,
10707 struct crypto_unittest_params *ut_params,
10708 const struct test_crypto_vector *reference,
10709 unsigned int data_corrupted)
10713 uint8_t *plaintext;
10715 /* Verify the capabilities */
10716 struct rte_cryptodev_sym_capability_idx cap_idx;
10717 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10718 cap_idx.algo.auth = reference->auth_algo;
10719 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10723 /* Create session */
10724 retval = create_auth_session(ut_params,
10725 ts_params->valid_devs[0],
10727 RTE_CRYPTO_AUTH_OP_VERIFY);
10731 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10732 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10733 "Failed to allocate input buffer in mempool");
10735 /* clear mbuf payload */
10736 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10737 rte_pktmbuf_tailroom(ut_params->ibuf));
10739 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10740 reference->plaintext.len);
10741 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10742 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10744 debug_hexdump(stdout, "plaintext:", plaintext,
10745 reference->plaintext.len);
10747 /* Create operation */
10748 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10753 if (data_corrupted)
10754 data_corruption(plaintext);
10756 tag_corruption(plaintext, reference->plaintext.len);
10758 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10759 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10761 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10762 RTE_CRYPTO_OP_STATUS_SUCCESS,
10763 "authentication not failed");
10765 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10767 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10774 test_authentication_verify_GMAC_fail_when_corruption(
10775 struct crypto_testsuite_params *ts_params,
10776 struct crypto_unittest_params *ut_params,
10777 const struct test_crypto_vector *reference,
10778 unsigned int data_corrupted)
10781 uint8_t *plaintext;
10783 /* Verify the capabilities */
10784 struct rte_cryptodev_sym_capability_idx cap_idx;
10785 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10786 cap_idx.algo.auth = reference->auth_algo;
10787 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10791 /* Create session */
10792 retval = create_auth_cipher_session(ut_params,
10793 ts_params->valid_devs[0],
10795 RTE_CRYPTO_AUTH_OP_VERIFY,
10796 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10800 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10801 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10802 "Failed to allocate input buffer in mempool");
10804 /* clear mbuf payload */
10805 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10806 rte_pktmbuf_tailroom(ut_params->ibuf));
10808 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10809 reference->plaintext.len);
10810 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10811 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10813 debug_hexdump(stdout, "plaintext:", plaintext,
10814 reference->plaintext.len);
10816 /* Create operation */
10817 retval = create_auth_verify_GMAC_operation(ts_params,
10824 if (data_corrupted)
10825 data_corruption(plaintext);
10827 tag_corruption(plaintext, reference->aad.len);
10829 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10830 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10832 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10833 RTE_CRYPTO_OP_STATUS_SUCCESS,
10834 "authentication not failed");
10836 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10838 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10845 test_authenticated_decryption_fail_when_corruption(
10846 struct crypto_testsuite_params *ts_params,
10847 struct crypto_unittest_params *ut_params,
10848 const struct test_crypto_vector *reference,
10849 unsigned int data_corrupted)
10853 uint8_t *ciphertext;
10855 /* Verify the capabilities */
10856 struct rte_cryptodev_sym_capability_idx cap_idx;
10857 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10858 cap_idx.algo.auth = reference->auth_algo;
10859 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10862 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10863 cap_idx.algo.cipher = reference->crypto_algo;
10864 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10868 /* Create session */
10869 retval = create_auth_cipher_session(ut_params,
10870 ts_params->valid_devs[0],
10872 RTE_CRYPTO_AUTH_OP_VERIFY,
10873 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10877 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10878 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10879 "Failed to allocate input buffer in mempool");
10881 /* clear mbuf payload */
10882 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10883 rte_pktmbuf_tailroom(ut_params->ibuf));
10885 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10886 reference->ciphertext.len);
10887 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10888 memcpy(ciphertext, reference->ciphertext.data,
10889 reference->ciphertext.len);
10891 /* Create operation */
10892 retval = create_cipher_auth_verify_operation(ts_params,
10899 if (data_corrupted)
10900 data_corruption(ciphertext);
10902 tag_corruption(ciphertext, reference->ciphertext.len);
10904 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10905 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10907 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10908 RTE_CRYPTO_OP_STATUS_SUCCESS,
10909 "authentication not failed");
10911 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10913 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10920 test_authenticated_encryt_with_esn(
10921 struct crypto_testsuite_params *ts_params,
10922 struct crypto_unittest_params *ut_params,
10923 const struct test_crypto_vector *reference)
10927 uint8_t *authciphertext, *plaintext, *auth_tag;
10928 uint16_t plaintext_pad_len;
10929 uint8_t cipher_key[reference->cipher_key.len + 1];
10930 uint8_t auth_key[reference->auth_key.len + 1];
10932 /* Verify the capabilities */
10933 struct rte_cryptodev_sym_capability_idx cap_idx;
10934 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10935 cap_idx.algo.auth = reference->auth_algo;
10936 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10939 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10940 cap_idx.algo.cipher = reference->crypto_algo;
10941 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10945 /* Create session */
10946 memcpy(cipher_key, reference->cipher_key.data,
10947 reference->cipher_key.len);
10948 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10950 /* Setup Cipher Parameters */
10951 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10952 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10953 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10954 ut_params->cipher_xform.cipher.key.data = cipher_key;
10955 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10956 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10957 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10959 ut_params->cipher_xform.next = &ut_params->auth_xform;
10961 /* Setup Authentication Parameters */
10962 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10963 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10964 ut_params->auth_xform.auth.algo = reference->auth_algo;
10965 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10966 ut_params->auth_xform.auth.key.data = auth_key;
10967 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10968 ut_params->auth_xform.next = NULL;
10970 /* Create Crypto session*/
10971 ut_params->sess = rte_cryptodev_sym_session_create(
10972 ts_params->session_mpool);
10974 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10976 &ut_params->cipher_xform,
10977 ts_params->session_priv_mpool);
10979 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10981 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10982 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10983 "Failed to allocate input buffer in mempool");
10985 /* clear mbuf payload */
10986 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10987 rte_pktmbuf_tailroom(ut_params->ibuf));
10989 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10990 reference->plaintext.len);
10991 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10992 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10994 /* Create operation */
10995 retval = create_cipher_auth_operation(ts_params,
11002 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11003 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11006 ut_params->op = process_crypto_request(
11007 ts_params->valid_devs[0], ut_params->op);
11009 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11011 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11012 "crypto op processing failed");
11014 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11016 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11017 ut_params->op->sym->auth.data.offset);
11018 auth_tag = authciphertext + plaintext_pad_len;
11019 debug_hexdump(stdout, "ciphertext:", authciphertext,
11020 reference->ciphertext.len);
11021 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11023 /* Validate obuf */
11024 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11026 reference->ciphertext.data,
11027 reference->ciphertext.len,
11028 "Ciphertext data not as expected");
11030 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11032 reference->digest.data,
11033 reference->digest.len,
11034 "Generated digest not as expected");
11036 return TEST_SUCCESS;
11041 test_authenticated_decrypt_with_esn(
11042 struct crypto_testsuite_params *ts_params,
11043 struct crypto_unittest_params *ut_params,
11044 const struct test_crypto_vector *reference)
11048 uint8_t *ciphertext;
11049 uint8_t cipher_key[reference->cipher_key.len + 1];
11050 uint8_t auth_key[reference->auth_key.len + 1];
11052 /* Verify the capabilities */
11053 struct rte_cryptodev_sym_capability_idx cap_idx;
11054 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11055 cap_idx.algo.auth = reference->auth_algo;
11056 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11059 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11060 cap_idx.algo.cipher = reference->crypto_algo;
11061 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11065 /* Create session */
11066 memcpy(cipher_key, reference->cipher_key.data,
11067 reference->cipher_key.len);
11068 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11070 /* Setup Authentication Parameters */
11071 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11072 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11073 ut_params->auth_xform.auth.algo = reference->auth_algo;
11074 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11075 ut_params->auth_xform.auth.key.data = auth_key;
11076 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11077 ut_params->auth_xform.next = &ut_params->cipher_xform;
11079 /* Setup Cipher Parameters */
11080 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11081 ut_params->cipher_xform.next = NULL;
11082 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11083 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11084 ut_params->cipher_xform.cipher.key.data = cipher_key;
11085 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11086 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11087 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11089 /* Create Crypto session*/
11090 ut_params->sess = rte_cryptodev_sym_session_create(
11091 ts_params->session_mpool);
11093 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11095 &ut_params->auth_xform,
11096 ts_params->session_priv_mpool);
11098 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11100 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11101 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11102 "Failed to allocate input buffer in mempool");
11104 /* clear mbuf payload */
11105 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11106 rte_pktmbuf_tailroom(ut_params->ibuf));
11108 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11109 reference->ciphertext.len);
11110 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11111 memcpy(ciphertext, reference->ciphertext.data,
11112 reference->ciphertext.len);
11114 /* Create operation */
11115 retval = create_cipher_auth_verify_operation(ts_params,
11122 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11123 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11126 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11129 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11130 TEST_ASSERT_EQUAL(ut_params->op->status,
11131 RTE_CRYPTO_OP_STATUS_SUCCESS,
11132 "crypto op processing passed");
11134 ut_params->obuf = ut_params->op->sym->m_src;
11135 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11141 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11142 const struct aead_test_data *tdata,
11143 void *digest_mem, uint64_t digest_phys)
11145 struct crypto_testsuite_params *ts_params = &testsuite_params;
11146 struct crypto_unittest_params *ut_params = &unittest_params;
11148 const unsigned int auth_tag_len = tdata->auth_tag.len;
11149 const unsigned int iv_len = tdata->iv.len;
11150 unsigned int aad_len = tdata->aad.len;
11151 unsigned int aad_len_pad = 0;
11153 /* Generate Crypto op data structure */
11154 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11155 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11156 TEST_ASSERT_NOT_NULL(ut_params->op,
11157 "Failed to allocate symmetric crypto operation struct");
11159 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11161 sym_op->aead.digest.data = digest_mem;
11163 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11164 "no room to append digest");
11166 sym_op->aead.digest.phys_addr = digest_phys;
11168 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11169 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11171 debug_hexdump(stdout, "digest:",
11172 sym_op->aead.digest.data,
11176 /* Append aad data */
11177 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11178 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11179 uint8_t *, IV_OFFSET);
11181 /* Copy IV 1 byte after the IV pointer, according to the API */
11182 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11184 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11186 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11187 ut_params->ibuf, aad_len);
11188 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11189 "no room to prepend aad");
11190 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11193 memset(sym_op->aead.aad.data, 0, aad_len);
11194 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11195 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11197 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11198 debug_hexdump(stdout, "aad:",
11199 sym_op->aead.aad.data, aad_len);
11201 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11202 uint8_t *, IV_OFFSET);
11204 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11206 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11208 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11209 ut_params->ibuf, aad_len_pad);
11210 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11211 "no room to prepend aad");
11212 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11215 memset(sym_op->aead.aad.data, 0, aad_len);
11216 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11218 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11219 debug_hexdump(stdout, "aad:",
11220 sym_op->aead.aad.data, aad_len);
11223 sym_op->aead.data.length = tdata->plaintext.len;
11224 sym_op->aead.data.offset = aad_len_pad;
11229 #define SGL_MAX_NO 16
11232 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11233 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11235 struct crypto_testsuite_params *ts_params = &testsuite_params;
11236 struct crypto_unittest_params *ut_params = &unittest_params;
11237 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11240 int to_trn_tbl[SGL_MAX_NO];
11242 unsigned int trn_data = 0;
11243 uint8_t *plaintext, *ciphertext, *auth_tag;
11244 struct rte_cryptodev_info dev_info;
11246 /* Verify the capabilities */
11247 struct rte_cryptodev_sym_capability_idx cap_idx;
11248 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11249 cap_idx.algo.aead = tdata->algo;
11250 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11254 /* OOP not supported with CPU crypto */
11255 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11258 /* Detailed check for the particular SGL support flag */
11259 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11261 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11262 if (sgl_in && (!(dev_info.feature_flags &
11263 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11266 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11267 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11268 tdata->plaintext.len;
11269 if (sgl_in && !sgl_out) {
11270 if (!(dev_info.feature_flags &
11271 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11273 } else if (!sgl_in && sgl_out) {
11274 if (!(dev_info.feature_flags &
11275 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11277 } else if (sgl_in && sgl_out) {
11278 if (!(dev_info.feature_flags &
11279 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11284 if (fragsz > tdata->plaintext.len)
11285 fragsz = tdata->plaintext.len;
11287 uint16_t plaintext_len = fragsz;
11288 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11290 if (fragsz_oop > tdata->plaintext.len)
11291 frag_size_oop = tdata->plaintext.len;
11294 void *digest_mem = NULL;
11296 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11298 if (tdata->plaintext.len % fragsz != 0) {
11299 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11302 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11307 * For out-op-place we need to alloc another mbuf
11310 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11311 rte_pktmbuf_append(ut_params->obuf,
11312 frag_size_oop + prepend_len);
11313 buf_oop = ut_params->obuf;
11316 /* Create AEAD session */
11317 retval = create_aead_session(ts_params->valid_devs[0],
11319 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11320 tdata->key.data, tdata->key.len,
11321 tdata->aad.len, tdata->auth_tag.len,
11326 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11328 /* clear mbuf payload */
11329 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11330 rte_pktmbuf_tailroom(ut_params->ibuf));
11332 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11335 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11337 trn_data += plaintext_len;
11339 buf = ut_params->ibuf;
11342 * Loop until no more fragments
11345 while (trn_data < tdata->plaintext.len) {
11347 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11348 (tdata->plaintext.len - trn_data) : fragsz;
11350 to_trn_tbl[ecx++] = to_trn;
11352 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11355 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11356 rte_pktmbuf_tailroom(buf));
11359 if (oop && !fragsz_oop) {
11360 buf_last_oop = buf_oop->next =
11361 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11362 buf_oop = buf_oop->next;
11363 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11364 0, rte_pktmbuf_tailroom(buf_oop));
11365 rte_pktmbuf_append(buf_oop, to_trn);
11368 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11371 memcpy(plaintext, tdata->plaintext.data + trn_data,
11373 trn_data += to_trn;
11374 if (trn_data == tdata->plaintext.len) {
11377 digest_mem = rte_pktmbuf_append(buf_oop,
11378 tdata->auth_tag.len);
11380 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11381 tdata->auth_tag.len);
11385 uint64_t digest_phys = 0;
11387 ut_params->ibuf->nb_segs = segs;
11390 if (fragsz_oop && oop) {
11394 if (frag_size_oop == tdata->plaintext.len) {
11395 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11396 tdata->auth_tag.len);
11398 digest_phys = rte_pktmbuf_iova_offset(
11400 tdata->plaintext.len + prepend_len);
11403 trn_data = frag_size_oop;
11404 while (trn_data < tdata->plaintext.len) {
11407 (tdata->plaintext.len - trn_data <
11409 (tdata->plaintext.len - trn_data) :
11412 to_trn_tbl[ecx++] = to_trn;
11414 buf_last_oop = buf_oop->next =
11415 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11416 buf_oop = buf_oop->next;
11417 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11418 0, rte_pktmbuf_tailroom(buf_oop));
11419 rte_pktmbuf_append(buf_oop, to_trn);
11421 trn_data += to_trn;
11423 if (trn_data == tdata->plaintext.len) {
11424 digest_mem = rte_pktmbuf_append(buf_oop,
11425 tdata->auth_tag.len);
11429 ut_params->obuf->nb_segs = segs;
11433 * Place digest at the end of the last buffer
11436 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11437 if (oop && buf_last_oop)
11438 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11440 if (!digest_mem && !oop) {
11441 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11442 + tdata->auth_tag.len);
11443 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11444 tdata->plaintext.len);
11447 /* Create AEAD operation */
11448 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11449 tdata, digest_mem, digest_phys);
11454 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11456 ut_params->op->sym->m_src = ut_params->ibuf;
11458 ut_params->op->sym->m_dst = ut_params->obuf;
11460 /* Process crypto operation */
11461 if (oop == IN_PLACE &&
11462 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11463 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11465 TEST_ASSERT_NOT_NULL(
11466 process_crypto_request(ts_params->valid_devs[0],
11467 ut_params->op), "failed to process sym crypto op");
11469 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11470 "crypto op processing failed");
11473 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11474 uint8_t *, prepend_len);
11476 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11477 uint8_t *, prepend_len);
11481 fragsz = fragsz_oop;
11483 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11485 tdata->ciphertext.data,
11487 "Ciphertext data not as expected");
11489 buf = ut_params->op->sym->m_src->next;
11491 buf = ut_params->op->sym->m_dst->next;
11493 unsigned int off = fragsz;
11497 ciphertext = rte_pktmbuf_mtod(buf,
11500 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11502 tdata->ciphertext.data + off,
11504 "Ciphertext data not as expected");
11506 off += to_trn_tbl[ecx++];
11510 auth_tag = digest_mem;
11511 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11513 tdata->auth_tag.data,
11514 tdata->auth_tag.len,
11515 "Generated auth tag not as expected");
11521 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11523 return test_authenticated_encryption_SGL(
11524 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11528 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11530 return test_authenticated_encryption_SGL(
11531 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11535 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11537 return test_authenticated_encryption_SGL(
11538 &gcm_test_case_8, OUT_OF_PLACE, 400,
11539 gcm_test_case_8.plaintext.len);
11543 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11545 /* This test is not for OPENSSL PMD */
11546 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11547 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11550 return test_authenticated_encryption_SGL(
11551 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11555 test_authentication_verify_fail_when_data_corrupted(
11556 struct crypto_testsuite_params *ts_params,
11557 struct crypto_unittest_params *ut_params,
11558 const struct test_crypto_vector *reference)
11560 return test_authentication_verify_fail_when_data_corruption(
11561 ts_params, ut_params, reference, 1);
11565 test_authentication_verify_fail_when_tag_corrupted(
11566 struct crypto_testsuite_params *ts_params,
11567 struct crypto_unittest_params *ut_params,
11568 const struct test_crypto_vector *reference)
11570 return test_authentication_verify_fail_when_data_corruption(
11571 ts_params, ut_params, reference, 0);
11575 test_authentication_verify_GMAC_fail_when_data_corrupted(
11576 struct crypto_testsuite_params *ts_params,
11577 struct crypto_unittest_params *ut_params,
11578 const struct test_crypto_vector *reference)
11580 return test_authentication_verify_GMAC_fail_when_corruption(
11581 ts_params, ut_params, reference, 1);
11585 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11586 struct crypto_testsuite_params *ts_params,
11587 struct crypto_unittest_params *ut_params,
11588 const struct test_crypto_vector *reference)
11590 return test_authentication_verify_GMAC_fail_when_corruption(
11591 ts_params, ut_params, reference, 0);
11595 test_authenticated_decryption_fail_when_data_corrupted(
11596 struct crypto_testsuite_params *ts_params,
11597 struct crypto_unittest_params *ut_params,
11598 const struct test_crypto_vector *reference)
11600 return test_authenticated_decryption_fail_when_corruption(
11601 ts_params, ut_params, reference, 1);
11605 test_authenticated_decryption_fail_when_tag_corrupted(
11606 struct crypto_testsuite_params *ts_params,
11607 struct crypto_unittest_params *ut_params,
11608 const struct test_crypto_vector *reference)
11610 return test_authenticated_decryption_fail_when_corruption(
11611 ts_params, ut_params, reference, 0);
11615 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11617 return test_authentication_verify_fail_when_data_corrupted(
11618 &testsuite_params, &unittest_params,
11619 &hmac_sha1_test_crypto_vector);
11623 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11625 return test_authentication_verify_fail_when_tag_corrupted(
11626 &testsuite_params, &unittest_params,
11627 &hmac_sha1_test_crypto_vector);
11631 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11633 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11634 &testsuite_params, &unittest_params,
11635 &aes128_gmac_test_vector);
11639 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11641 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11642 &testsuite_params, &unittest_params,
11643 &aes128_gmac_test_vector);
11647 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11649 return test_authenticated_decryption_fail_when_data_corrupted(
11652 &aes128cbc_hmac_sha1_test_vector);
11656 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11658 return test_authenticated_decryption_fail_when_tag_corrupted(
11661 &aes128cbc_hmac_sha1_test_vector);
11665 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11667 return test_authenticated_encryt_with_esn(
11670 &aes128cbc_hmac_sha1_aad_test_vector);
11674 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11676 return test_authenticated_decrypt_with_esn(
11679 &aes128cbc_hmac_sha1_aad_test_vector);
11683 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
11685 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
11689 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
11691 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
11694 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11696 /* global AESNI slave IDs for the scheduler test */
11697 uint8_t aesni_ids[2];
11700 test_scheduler_attach_slave_op(void)
11702 struct crypto_testsuite_params *ts_params = &testsuite_params;
11703 uint8_t sched_id = ts_params->valid_devs[0];
11704 uint32_t nb_devs, i, nb_devs_attached = 0;
11706 char vdev_name[32];
11708 /* create 2 AESNI_MB if necessary */
11709 nb_devs = rte_cryptodev_device_count_by_driver(
11710 rte_cryptodev_driver_id_get(
11711 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11713 for (i = nb_devs; i < 2; i++) {
11714 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11715 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11717 ret = rte_vdev_init(vdev_name, NULL);
11719 TEST_ASSERT(ret == 0,
11720 "Failed to create instance %u of"
11722 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11726 /* attach 2 AESNI_MB cdevs */
11727 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11729 struct rte_cryptodev_info info;
11730 unsigned int session_size;
11732 rte_cryptodev_info_get(i, &info);
11733 if (info.driver_id != rte_cryptodev_driver_id_get(
11734 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11737 session_size = rte_cryptodev_sym_get_private_session_size(i);
11739 * Create the session mempool again, since now there are new devices
11740 * to use the mempool.
11742 if (ts_params->session_mpool) {
11743 rte_mempool_free(ts_params->session_mpool);
11744 ts_params->session_mpool = NULL;
11746 if (ts_params->session_priv_mpool) {
11747 rte_mempool_free(ts_params->session_priv_mpool);
11748 ts_params->session_priv_mpool = NULL;
11751 if (info.sym.max_nb_sessions != 0 &&
11752 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11753 RTE_LOG(ERR, USER1,
11754 "Device does not support "
11755 "at least %u sessions\n",
11757 return TEST_FAILED;
11760 * Create mempool with maximum number of sessions,
11761 * to include the session headers
11763 if (ts_params->session_mpool == NULL) {
11764 ts_params->session_mpool =
11765 rte_cryptodev_sym_session_pool_create(
11767 MAX_NB_SESSIONS, 0, 0, 0,
11769 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11770 "session mempool allocation failed");
11774 * Create mempool with maximum number of sessions,
11775 * to include device specific session private data
11777 if (ts_params->session_priv_mpool == NULL) {
11778 ts_params->session_priv_mpool = rte_mempool_create(
11779 "test_sess_mp_priv",
11782 0, 0, NULL, NULL, NULL,
11783 NULL, SOCKET_ID_ANY,
11786 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11787 "session mempool allocation failed");
11790 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11791 ts_params->qp_conf.mp_session_private =
11792 ts_params->session_priv_mpool;
11794 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11797 TEST_ASSERT(ret == 0,
11798 "Failed to attach device %u of pmd : %s", i,
11799 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11801 aesni_ids[nb_devs_attached] = (uint8_t)i;
11803 nb_devs_attached++;
11810 test_scheduler_detach_slave_op(void)
11812 struct crypto_testsuite_params *ts_params = &testsuite_params;
11813 uint8_t sched_id = ts_params->valid_devs[0];
11817 for (i = 0; i < 2; i++) {
11818 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11820 TEST_ASSERT(ret == 0,
11821 "Failed to detach device %u", aesni_ids[i]);
11828 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11830 struct crypto_testsuite_params *ts_params = &testsuite_params;
11831 uint8_t sched_id = ts_params->valid_devs[0];
11833 return rte_cryptodev_scheduler_mode_set(sched_id,
11838 test_scheduler_mode_roundrobin_op(void)
11840 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11841 0, "Failed to set roundrobin mode");
11847 test_scheduler_mode_multicore_op(void)
11849 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11850 0, "Failed to set multicore mode");
11856 test_scheduler_mode_failover_op(void)
11858 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11859 0, "Failed to set failover mode");
11865 test_scheduler_mode_pkt_size_distr_op(void)
11867 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11868 0, "Failed to set pktsize mode");
11873 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11874 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11875 .setup = testsuite_setup,
11876 .teardown = testsuite_teardown,
11877 .unit_test_cases = {
11879 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11880 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11881 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11882 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11883 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11884 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11887 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11888 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11889 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11890 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11891 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11892 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11895 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11896 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11897 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11898 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11899 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11900 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11903 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11904 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11905 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11906 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11907 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11908 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11910 TEST_CASES_END() /**< NULL terminate unit test array */
11914 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11916 static struct unit_test_suite cryptodev_testsuite = {
11917 .suite_name = "Crypto Unit Test Suite",
11918 .setup = testsuite_setup,
11919 .teardown = testsuite_teardown,
11920 .unit_test_cases = {
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_device_configure_invalid_dev_id),
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_queue_pair_descriptor_setup),
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_device_configure_invalid_queue_pair_ids),
11928 TEST_CASE_ST(ut_setup, ut_teardown,
11929 test_multi_session),
11930 TEST_CASE_ST(ut_setup, ut_teardown,
11931 test_multi_session_random_usage),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_null_invalid_operation),
11935 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11937 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11938 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11939 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11940 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11941 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11942 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11943 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11944 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11945 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11947 /** AES CCM Authenticated Encryption 128 bits key */
11948 TEST_CASE_ST(ut_setup, ut_teardown,
11949 test_AES_CCM_authenticated_encryption_test_case_128_1),
11950 TEST_CASE_ST(ut_setup, ut_teardown,
11951 test_AES_CCM_authenticated_encryption_test_case_128_2),
11952 TEST_CASE_ST(ut_setup, ut_teardown,
11953 test_AES_CCM_authenticated_encryption_test_case_128_3),
11955 /** AES CCM Authenticated Decryption 128 bits key*/
11956 TEST_CASE_ST(ut_setup, ut_teardown,
11957 test_AES_CCM_authenticated_decryption_test_case_128_1),
11958 TEST_CASE_ST(ut_setup, ut_teardown,
11959 test_AES_CCM_authenticated_decryption_test_case_128_2),
11960 TEST_CASE_ST(ut_setup, ut_teardown,
11961 test_AES_CCM_authenticated_decryption_test_case_128_3),
11963 /** AES CCM Authenticated Encryption 192 bits key */
11964 TEST_CASE_ST(ut_setup, ut_teardown,
11965 test_AES_CCM_authenticated_encryption_test_case_192_1),
11966 TEST_CASE_ST(ut_setup, ut_teardown,
11967 test_AES_CCM_authenticated_encryption_test_case_192_2),
11968 TEST_CASE_ST(ut_setup, ut_teardown,
11969 test_AES_CCM_authenticated_encryption_test_case_192_3),
11971 /** AES CCM Authenticated Decryption 192 bits key*/
11972 TEST_CASE_ST(ut_setup, ut_teardown,
11973 test_AES_CCM_authenticated_decryption_test_case_192_1),
11974 TEST_CASE_ST(ut_setup, ut_teardown,
11975 test_AES_CCM_authenticated_decryption_test_case_192_2),
11976 TEST_CASE_ST(ut_setup, ut_teardown,
11977 test_AES_CCM_authenticated_decryption_test_case_192_3),
11979 /** AES CCM Authenticated Encryption 256 bits key */
11980 TEST_CASE_ST(ut_setup, ut_teardown,
11981 test_AES_CCM_authenticated_encryption_test_case_256_1),
11982 TEST_CASE_ST(ut_setup, ut_teardown,
11983 test_AES_CCM_authenticated_encryption_test_case_256_2),
11984 TEST_CASE_ST(ut_setup, ut_teardown,
11985 test_AES_CCM_authenticated_encryption_test_case_256_3),
11987 /** AES CCM Authenticated Decryption 256 bits key*/
11988 TEST_CASE_ST(ut_setup, ut_teardown,
11989 test_AES_CCM_authenticated_decryption_test_case_256_1),
11990 TEST_CASE_ST(ut_setup, ut_teardown,
11991 test_AES_CCM_authenticated_decryption_test_case_256_2),
11992 TEST_CASE_ST(ut_setup, ut_teardown,
11993 test_AES_CCM_authenticated_decryption_test_case_256_3),
11995 /** AES GCM Authenticated Encryption */
11996 TEST_CASE_ST(ut_setup, ut_teardown,
11997 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11998 TEST_CASE_ST(ut_setup, ut_teardown,
11999 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12000 TEST_CASE_ST(ut_setup, ut_teardown,
12001 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12002 TEST_CASE_ST(ut_setup, ut_teardown,
12003 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12004 TEST_CASE_ST(ut_setup, ut_teardown,
12005 test_AES_GCM_authenticated_encryption_test_case_1),
12006 TEST_CASE_ST(ut_setup, ut_teardown,
12007 test_AES_GCM_authenticated_encryption_test_case_2),
12008 TEST_CASE_ST(ut_setup, ut_teardown,
12009 test_AES_GCM_authenticated_encryption_test_case_3),
12010 TEST_CASE_ST(ut_setup, ut_teardown,
12011 test_AES_GCM_authenticated_encryption_test_case_4),
12012 TEST_CASE_ST(ut_setup, ut_teardown,
12013 test_AES_GCM_authenticated_encryption_test_case_5),
12014 TEST_CASE_ST(ut_setup, ut_teardown,
12015 test_AES_GCM_authenticated_encryption_test_case_6),
12016 TEST_CASE_ST(ut_setup, ut_teardown,
12017 test_AES_GCM_authenticated_encryption_test_case_7),
12018 TEST_CASE_ST(ut_setup, ut_teardown,
12019 test_AES_GCM_authenticated_encryption_test_case_8),
12020 TEST_CASE_ST(ut_setup, ut_teardown,
12021 test_AES_GCM_J0_authenticated_encryption_test_case_1),
12023 /** AES GCM Authenticated Decryption */
12024 TEST_CASE_ST(ut_setup, ut_teardown,
12025 test_AES_GCM_authenticated_decryption_test_case_1),
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_AES_GCM_authenticated_decryption_test_case_2),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_AES_GCM_authenticated_decryption_test_case_3),
12030 TEST_CASE_ST(ut_setup, ut_teardown,
12031 test_AES_GCM_authenticated_decryption_test_case_4),
12032 TEST_CASE_ST(ut_setup, ut_teardown,
12033 test_AES_GCM_authenticated_decryption_test_case_5),
12034 TEST_CASE_ST(ut_setup, ut_teardown,
12035 test_AES_GCM_authenticated_decryption_test_case_6),
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_AES_GCM_authenticated_decryption_test_case_7),
12038 TEST_CASE_ST(ut_setup, ut_teardown,
12039 test_AES_GCM_authenticated_decryption_test_case_8),
12040 TEST_CASE_ST(ut_setup, ut_teardown,
12041 test_AES_GCM_J0_authenticated_decryption_test_case_1),
12043 /** AES GCM Authenticated Encryption 192 bits key */
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_AES_GCM_auth_encryption_test_case_192_1),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_AES_GCM_auth_encryption_test_case_192_2),
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_AES_GCM_auth_encryption_test_case_192_3),
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_AES_GCM_auth_encryption_test_case_192_4),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_AES_GCM_auth_encryption_test_case_192_5),
12054 TEST_CASE_ST(ut_setup, ut_teardown,
12055 test_AES_GCM_auth_encryption_test_case_192_6),
12056 TEST_CASE_ST(ut_setup, ut_teardown,
12057 test_AES_GCM_auth_encryption_test_case_192_7),
12059 /** AES GCM Authenticated Decryption 192 bits key */
12060 TEST_CASE_ST(ut_setup, ut_teardown,
12061 test_AES_GCM_auth_decryption_test_case_192_1),
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_AES_GCM_auth_decryption_test_case_192_2),
12064 TEST_CASE_ST(ut_setup, ut_teardown,
12065 test_AES_GCM_auth_decryption_test_case_192_3),
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_AES_GCM_auth_decryption_test_case_192_4),
12068 TEST_CASE_ST(ut_setup, ut_teardown,
12069 test_AES_GCM_auth_decryption_test_case_192_5),
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_AES_GCM_auth_decryption_test_case_192_6),
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_AES_GCM_auth_decryption_test_case_192_7),
12075 /** AES GCM Authenticated Encryption 256 bits key */
12076 TEST_CASE_ST(ut_setup, ut_teardown,
12077 test_AES_GCM_auth_encryption_test_case_256_1),
12078 TEST_CASE_ST(ut_setup, ut_teardown,
12079 test_AES_GCM_auth_encryption_test_case_256_2),
12080 TEST_CASE_ST(ut_setup, ut_teardown,
12081 test_AES_GCM_auth_encryption_test_case_256_3),
12082 TEST_CASE_ST(ut_setup, ut_teardown,
12083 test_AES_GCM_auth_encryption_test_case_256_4),
12084 TEST_CASE_ST(ut_setup, ut_teardown,
12085 test_AES_GCM_auth_encryption_test_case_256_5),
12086 TEST_CASE_ST(ut_setup, ut_teardown,
12087 test_AES_GCM_auth_encryption_test_case_256_6),
12088 TEST_CASE_ST(ut_setup, ut_teardown,
12089 test_AES_GCM_auth_encryption_test_case_256_7),
12091 /** AES GCM Authenticated Decryption 256 bits key */
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 test_AES_GCM_auth_decryption_test_case_256_1),
12094 TEST_CASE_ST(ut_setup, ut_teardown,
12095 test_AES_GCM_auth_decryption_test_case_256_2),
12096 TEST_CASE_ST(ut_setup, ut_teardown,
12097 test_AES_GCM_auth_decryption_test_case_256_3),
12098 TEST_CASE_ST(ut_setup, ut_teardown,
12099 test_AES_GCM_auth_decryption_test_case_256_4),
12100 TEST_CASE_ST(ut_setup, ut_teardown,
12101 test_AES_GCM_auth_decryption_test_case_256_5),
12102 TEST_CASE_ST(ut_setup, ut_teardown,
12103 test_AES_GCM_auth_decryption_test_case_256_6),
12104 TEST_CASE_ST(ut_setup, ut_teardown,
12105 test_AES_GCM_auth_decryption_test_case_256_7),
12107 /** AES GCM Authenticated Encryption big aad size */
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_AES_GCM_auth_encryption_test_case_aad_1),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_AES_GCM_auth_encryption_test_case_aad_2),
12113 /** AES GCM Authenticated Decryption big aad size */
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_AES_GCM_auth_decryption_test_case_aad_1),
12116 TEST_CASE_ST(ut_setup, ut_teardown,
12117 test_AES_GCM_auth_decryption_test_case_aad_2),
12119 /** Out of place tests */
12120 TEST_CASE_ST(ut_setup, ut_teardown,
12121 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12122 TEST_CASE_ST(ut_setup, ut_teardown,
12123 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12125 /** Session-less tests */
12126 TEST_CASE_ST(ut_setup, ut_teardown,
12127 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12128 TEST_CASE_ST(ut_setup, ut_teardown,
12129 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12131 /** AES GMAC Authentication */
12132 TEST_CASE_ST(ut_setup, ut_teardown,
12133 test_AES_GMAC_authentication_test_case_1),
12134 TEST_CASE_ST(ut_setup, ut_teardown,
12135 test_AES_GMAC_authentication_verify_test_case_1),
12136 TEST_CASE_ST(ut_setup, ut_teardown,
12137 test_AES_GMAC_authentication_test_case_2),
12138 TEST_CASE_ST(ut_setup, ut_teardown,
12139 test_AES_GMAC_authentication_verify_test_case_2),
12140 TEST_CASE_ST(ut_setup, ut_teardown,
12141 test_AES_GMAC_authentication_test_case_3),
12142 TEST_CASE_ST(ut_setup, ut_teardown,
12143 test_AES_GMAC_authentication_verify_test_case_3),
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_AES_GMAC_authentication_test_case_4),
12146 TEST_CASE_ST(ut_setup, ut_teardown,
12147 test_AES_GMAC_authentication_verify_test_case_4),
12148 /** Chacha20-Poly1305 */
12149 TEST_CASE_ST(ut_setup, ut_teardown,
12150 test_chacha20_poly1305_encrypt_test_case_rfc8439),
12151 TEST_CASE_ST(ut_setup, ut_teardown,
12152 test_chacha20_poly1305_decrypt_test_case_rfc8439),
12153 /** SNOW 3G encrypt only (UEA2) */
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_snow3g_encryption_test_case_1),
12156 TEST_CASE_ST(ut_setup, ut_teardown,
12157 test_snow3g_encryption_test_case_2),
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_snow3g_encryption_test_case_3),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_snow3g_encryption_test_case_4),
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_snow3g_encryption_test_case_5),
12165 TEST_CASE_ST(ut_setup, ut_teardown,
12166 test_snow3g_encryption_test_case_1_oop),
12167 TEST_CASE_ST(ut_setup, ut_teardown,
12168 test_snow3g_encryption_test_case_1_oop_sgl),
12169 TEST_CASE_ST(ut_setup, ut_teardown,
12170 test_snow3g_encryption_test_case_1_offset_oop),
12171 TEST_CASE_ST(ut_setup, ut_teardown,
12172 test_snow3g_decryption_test_case_1_oop),
12174 /** SNOW 3G generate auth, then encrypt (UEA2) */
12175 TEST_CASE_ST(ut_setup, ut_teardown,
12176 test_snow3g_auth_cipher_test_case_1),
12177 TEST_CASE_ST(ut_setup, ut_teardown,
12178 test_snow3g_auth_cipher_test_case_2),
12179 TEST_CASE_ST(ut_setup, ut_teardown,
12180 test_snow3g_auth_cipher_test_case_2_oop),
12181 TEST_CASE_ST(ut_setup, ut_teardown,
12182 test_snow3g_auth_cipher_part_digest_enc),
12183 TEST_CASE_ST(ut_setup, ut_teardown,
12184 test_snow3g_auth_cipher_part_digest_enc_oop),
12185 TEST_CASE_ST(ut_setup, ut_teardown,
12186 test_snow3g_auth_cipher_test_case_3_sgl),
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_snow3g_auth_cipher_part_digest_enc_sgl),
12191 TEST_CASE_ST(ut_setup, ut_teardown,
12192 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12194 /** SNOW 3G decrypt (UEA2), then verify auth */
12195 TEST_CASE_ST(ut_setup, ut_teardown,
12196 test_snow3g_auth_cipher_verify_test_case_1),
12197 TEST_CASE_ST(ut_setup, ut_teardown,
12198 test_snow3g_auth_cipher_verify_test_case_2),
12199 TEST_CASE_ST(ut_setup, ut_teardown,
12200 test_snow3g_auth_cipher_verify_test_case_2_oop),
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 test_snow3g_auth_cipher_verify_part_digest_enc),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12207 TEST_CASE_ST(ut_setup, ut_teardown,
12208 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12214 /** SNOW 3G decrypt only (UEA2) */
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_snow3g_decryption_test_case_1),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_snow3g_decryption_test_case_2),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_snow3g_decryption_test_case_3),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_snow3g_decryption_test_case_4),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_snow3g_decryption_test_case_5),
12225 TEST_CASE_ST(ut_setup, ut_teardown,
12226 test_snow3g_decryption_with_digest_test_case_1),
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_snow3g_hash_generate_test_case_1),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_snow3g_hash_generate_test_case_2),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_snow3g_hash_generate_test_case_3),
12233 /* Tests with buffers which length is not byte-aligned */
12234 TEST_CASE_ST(ut_setup, ut_teardown,
12235 test_snow3g_hash_generate_test_case_4),
12236 TEST_CASE_ST(ut_setup, ut_teardown,
12237 test_snow3g_hash_generate_test_case_5),
12238 TEST_CASE_ST(ut_setup, ut_teardown,
12239 test_snow3g_hash_generate_test_case_6),
12240 TEST_CASE_ST(ut_setup, ut_teardown,
12241 test_snow3g_hash_verify_test_case_1),
12242 TEST_CASE_ST(ut_setup, ut_teardown,
12243 test_snow3g_hash_verify_test_case_2),
12244 TEST_CASE_ST(ut_setup, ut_teardown,
12245 test_snow3g_hash_verify_test_case_3),
12246 /* Tests with buffers which length is not byte-aligned */
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_snow3g_hash_verify_test_case_4),
12249 TEST_CASE_ST(ut_setup, ut_teardown,
12250 test_snow3g_hash_verify_test_case_5),
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_snow3g_hash_verify_test_case_6),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_snow3g_cipher_auth_test_case_1),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_snow3g_auth_cipher_with_digest_test_case_1),
12258 /** ZUC encrypt only (EEA3) */
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 test_zuc_encryption_test_case_1),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_zuc_encryption_test_case_2),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 test_zuc_encryption_test_case_3),
12265 TEST_CASE_ST(ut_setup, ut_teardown,
12266 test_zuc_encryption_test_case_4),
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_zuc_encryption_test_case_5),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_zuc_encryption_test_case_6_sgl),
12272 /** ZUC authenticate (EIA3) */
12273 TEST_CASE_ST(ut_setup, ut_teardown,
12274 test_zuc_hash_generate_test_case_1),
12275 TEST_CASE_ST(ut_setup, ut_teardown,
12276 test_zuc_hash_generate_test_case_2),
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 test_zuc_hash_generate_test_case_3),
12279 TEST_CASE_ST(ut_setup, ut_teardown,
12280 test_zuc_hash_generate_test_case_4),
12281 TEST_CASE_ST(ut_setup, ut_teardown,
12282 test_zuc_hash_generate_test_case_5),
12283 TEST_CASE_ST(ut_setup, ut_teardown,
12284 test_zuc_hash_generate_test_case_6),
12285 TEST_CASE_ST(ut_setup, ut_teardown,
12286 test_zuc_hash_generate_test_case_7),
12287 TEST_CASE_ST(ut_setup, ut_teardown,
12288 test_zuc_hash_generate_test_case_8),
12290 /** ZUC alg-chain (EEA3/EIA3) */
12291 TEST_CASE_ST(ut_setup, ut_teardown,
12292 test_zuc_cipher_auth_test_case_1),
12293 TEST_CASE_ST(ut_setup, ut_teardown,
12294 test_zuc_cipher_auth_test_case_2),
12296 /** ZUC generate auth, then encrypt (EEA3) */
12297 TEST_CASE_ST(ut_setup, ut_teardown,
12298 test_zuc_auth_cipher_test_case_1),
12299 TEST_CASE_ST(ut_setup, ut_teardown,
12300 test_zuc_auth_cipher_test_case_1_oop),
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_zuc_auth_cipher_test_case_1_sgl),
12303 TEST_CASE_ST(ut_setup, ut_teardown,
12304 test_zuc_auth_cipher_test_case_1_oop_sgl),
12306 /** ZUC decrypt (EEA3), then verify auth */
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_zuc_auth_cipher_verify_test_case_1),
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_zuc_auth_cipher_verify_test_case_1_oop),
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_zuc_auth_cipher_verify_test_case_1_sgl),
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12316 /** HMAC_MD5 Authentication */
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_MD5_HMAC_generate_case_1),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_MD5_HMAC_verify_case_1),
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_MD5_HMAC_generate_case_2),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_MD5_HMAC_verify_case_2),
12326 /** KASUMI hash only (UIA1) */
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_kasumi_hash_generate_test_case_1),
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_kasumi_hash_generate_test_case_2),
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_kasumi_hash_generate_test_case_3),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_kasumi_hash_generate_test_case_4),
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_kasumi_hash_generate_test_case_5),
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_kasumi_hash_generate_test_case_6),
12340 TEST_CASE_ST(ut_setup, ut_teardown,
12341 test_kasumi_hash_verify_test_case_1),
12342 TEST_CASE_ST(ut_setup, ut_teardown,
12343 test_kasumi_hash_verify_test_case_2),
12344 TEST_CASE_ST(ut_setup, ut_teardown,
12345 test_kasumi_hash_verify_test_case_3),
12346 TEST_CASE_ST(ut_setup, ut_teardown,
12347 test_kasumi_hash_verify_test_case_4),
12348 TEST_CASE_ST(ut_setup, ut_teardown,
12349 test_kasumi_hash_verify_test_case_5),
12351 /** KASUMI encrypt only (UEA1) */
12352 TEST_CASE_ST(ut_setup, ut_teardown,
12353 test_kasumi_encryption_test_case_1),
12354 TEST_CASE_ST(ut_setup, ut_teardown,
12355 test_kasumi_encryption_test_case_1_sgl),
12356 TEST_CASE_ST(ut_setup, ut_teardown,
12357 test_kasumi_encryption_test_case_1_oop),
12358 TEST_CASE_ST(ut_setup, ut_teardown,
12359 test_kasumi_encryption_test_case_1_oop_sgl),
12360 TEST_CASE_ST(ut_setup, ut_teardown,
12361 test_kasumi_encryption_test_case_2),
12362 TEST_CASE_ST(ut_setup, ut_teardown,
12363 test_kasumi_encryption_test_case_3),
12364 TEST_CASE_ST(ut_setup, ut_teardown,
12365 test_kasumi_encryption_test_case_4),
12366 TEST_CASE_ST(ut_setup, ut_teardown,
12367 test_kasumi_encryption_test_case_5),
12369 /** KASUMI decrypt only (UEA1) */
12370 TEST_CASE_ST(ut_setup, ut_teardown,
12371 test_kasumi_decryption_test_case_1),
12372 TEST_CASE_ST(ut_setup, ut_teardown,
12373 test_kasumi_decryption_test_case_2),
12374 TEST_CASE_ST(ut_setup, ut_teardown,
12375 test_kasumi_decryption_test_case_3),
12376 TEST_CASE_ST(ut_setup, ut_teardown,
12377 test_kasumi_decryption_test_case_4),
12378 TEST_CASE_ST(ut_setup, ut_teardown,
12379 test_kasumi_decryption_test_case_5),
12380 TEST_CASE_ST(ut_setup, ut_teardown,
12381 test_kasumi_decryption_test_case_1_oop),
12383 TEST_CASE_ST(ut_setup, ut_teardown,
12384 test_kasumi_cipher_auth_test_case_1),
12386 /** KASUMI generate auth, then encrypt (F8) */
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_kasumi_auth_cipher_test_case_1),
12389 TEST_CASE_ST(ut_setup, ut_teardown,
12390 test_kasumi_auth_cipher_test_case_2),
12391 TEST_CASE_ST(ut_setup, ut_teardown,
12392 test_kasumi_auth_cipher_test_case_2_oop),
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_kasumi_auth_cipher_test_case_2_sgl),
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12398 /** KASUMI decrypt (F8), then verify auth */
12399 TEST_CASE_ST(ut_setup, ut_teardown,
12400 test_kasumi_auth_cipher_verify_test_case_1),
12401 TEST_CASE_ST(ut_setup, ut_teardown,
12402 test_kasumi_auth_cipher_verify_test_case_2),
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 test_kasumi_auth_cipher_verify_test_case_2_oop),
12405 TEST_CASE_ST(ut_setup, ut_teardown,
12406 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12407 TEST_CASE_ST(ut_setup, ut_teardown,
12408 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12410 /** ESN Testcase */
12411 TEST_CASE_ST(ut_setup, ut_teardown,
12412 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12413 TEST_CASE_ST(ut_setup, ut_teardown,
12414 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12416 /** Negative tests */
12417 TEST_CASE_ST(ut_setup, ut_teardown,
12418 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12419 TEST_CASE_ST(ut_setup, ut_teardown,
12420 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12421 TEST_CASE_ST(ut_setup, ut_teardown,
12422 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12423 TEST_CASE_ST(ut_setup, ut_teardown,
12424 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12425 TEST_CASE_ST(ut_setup, ut_teardown,
12426 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12427 TEST_CASE_ST(ut_setup, ut_teardown,
12428 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12429 TEST_CASE_ST(ut_setup, ut_teardown,
12430 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12431 TEST_CASE_ST(ut_setup, ut_teardown,
12432 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12433 TEST_CASE_ST(ut_setup, ut_teardown,
12434 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12435 TEST_CASE_ST(ut_setup, ut_teardown,
12436 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12439 TEST_CASE_ST(ut_setup, ut_teardown,
12440 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12443 TEST_CASE_ST(ut_setup, ut_teardown,
12444 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12445 TEST_CASE_ST(ut_setup, ut_teardown,
12446 authentication_verify_AES128_GMAC_fail_data_corrupt),
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12449 TEST_CASE_ST(ut_setup, ut_teardown,
12450 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12451 TEST_CASE_ST(ut_setup, ut_teardown,
12452 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12454 /** Mixed CIPHER + HASH algorithms */
12455 /** AUTH AES CMAC + CIPHER AES CTR */
12456 TEST_CASE_ST(ut_setup, ut_teardown,
12457 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12458 TEST_CASE_ST(ut_setup, ut_teardown,
12459 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12460 TEST_CASE_ST(ut_setup, ut_teardown,
12461 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12462 TEST_CASE_ST(ut_setup, ut_teardown,
12463 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12464 TEST_CASE_ST(ut_setup, ut_teardown,
12465 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12466 TEST_CASE_ST(ut_setup, ut_teardown,
12467 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12468 TEST_CASE_ST(ut_setup, ut_teardown,
12469 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12470 TEST_CASE_ST(ut_setup, ut_teardown,
12471 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12473 /** AUTH ZUC + CIPHER SNOW3G */
12474 TEST_CASE_ST(ut_setup, ut_teardown,
12475 test_auth_zuc_cipher_snow_test_case_1),
12476 TEST_CASE_ST(ut_setup, ut_teardown,
12477 test_verify_auth_zuc_cipher_snow_test_case_1),
12478 /** AUTH AES CMAC + CIPHER SNOW3G */
12479 TEST_CASE_ST(ut_setup, ut_teardown,
12480 test_auth_aes_cmac_cipher_snow_test_case_1),
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12483 /** AUTH ZUC + CIPHER AES CTR */
12484 TEST_CASE_ST(ut_setup, ut_teardown,
12485 test_auth_zuc_cipher_aes_ctr_test_case_1),
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12488 /** AUTH SNOW3G + CIPHER AES CTR */
12489 TEST_CASE_ST(ut_setup, ut_teardown,
12490 test_auth_snow_cipher_aes_ctr_test_case_1),
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12493 /** AUTH SNOW3G + CIPHER ZUC */
12494 TEST_CASE_ST(ut_setup, ut_teardown,
12495 test_auth_snow_cipher_zuc_test_case_1),
12496 TEST_CASE_ST(ut_setup, ut_teardown,
12497 test_verify_auth_snow_cipher_zuc_test_case_1),
12498 /** AUTH AES CMAC + CIPHER ZUC */
12499 TEST_CASE_ST(ut_setup, ut_teardown,
12500 test_auth_aes_cmac_cipher_zuc_test_case_1),
12501 TEST_CASE_ST(ut_setup, ut_teardown,
12502 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12504 /** AUTH NULL + CIPHER SNOW3G */
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_auth_null_cipher_snow_test_case_1),
12507 TEST_CASE_ST(ut_setup, ut_teardown,
12508 test_verify_auth_null_cipher_snow_test_case_1),
12509 /** AUTH NULL + CIPHER ZUC */
12510 TEST_CASE_ST(ut_setup, ut_teardown,
12511 test_auth_null_cipher_zuc_test_case_1),
12512 TEST_CASE_ST(ut_setup, ut_teardown,
12513 test_verify_auth_null_cipher_zuc_test_case_1),
12514 /** AUTH SNOW3G + CIPHER NULL */
12515 TEST_CASE_ST(ut_setup, ut_teardown,
12516 test_auth_snow_cipher_null_test_case_1),
12517 TEST_CASE_ST(ut_setup, ut_teardown,
12518 test_verify_auth_snow_cipher_null_test_case_1),
12519 /** AUTH ZUC + CIPHER NULL */
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_auth_zuc_cipher_null_test_case_1),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_verify_auth_zuc_cipher_null_test_case_1),
12524 /** AUTH NULL + CIPHER AES CTR */
12525 TEST_CASE_ST(ut_setup, ut_teardown,
12526 test_auth_null_cipher_aes_ctr_test_case_1),
12527 TEST_CASE_ST(ut_setup, ut_teardown,
12528 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12529 /** AUTH AES CMAC + CIPHER NULL */
12530 TEST_CASE_ST(ut_setup, ut_teardown,
12531 test_auth_aes_cmac_cipher_null_test_case_1),
12532 TEST_CASE_ST(ut_setup, ut_teardown,
12533 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12535 #ifdef RTE_LIBRTE_SECURITY
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_PDCP_PROTO_all),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_DOCSIS_PROTO_all),
12541 TEST_CASES_END() /**< NULL terminate unit test array */
12545 static struct unit_test_suite cryptodev_virtio_testsuite = {
12546 .suite_name = "Crypto VIRTIO Unit Test Suite",
12547 .setup = testsuite_setup,
12548 .teardown = testsuite_teardown,
12549 .unit_test_cases = {
12550 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12552 TEST_CASES_END() /**< NULL terminate unit test array */
12556 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12557 .suite_name = "Crypto CAAM JR Unit Test Suite",
12558 .setup = testsuite_setup,
12559 .teardown = testsuite_teardown,
12560 .unit_test_cases = {
12561 TEST_CASE_ST(ut_setup, ut_teardown,
12562 test_device_configure_invalid_dev_id),
12563 TEST_CASE_ST(ut_setup, ut_teardown,
12564 test_multi_session),
12566 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12567 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12568 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12569 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12570 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12572 TEST_CASES_END() /**< NULL terminate unit test array */
12576 static struct unit_test_suite cryptodev_armv8_testsuite = {
12577 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12578 .setup = testsuite_setup,
12579 .teardown = testsuite_teardown,
12580 .unit_test_cases = {
12581 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12583 /** Negative tests */
12584 TEST_CASE_ST(ut_setup, ut_teardown,
12585 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12586 TEST_CASE_ST(ut_setup, ut_teardown,
12587 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12589 TEST_CASES_END() /**< NULL terminate unit test array */
12593 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12594 .suite_name = "Crypto Device Marvell Component Test Suite",
12595 .setup = testsuite_setup,
12596 .teardown = testsuite_teardown,
12597 .unit_test_cases = {
12598 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_multi_session_random_usage),
12601 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12602 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12603 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12604 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12605 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12607 /** Negative tests */
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12617 TEST_CASES_END() /**< NULL terminate unit test array */
12621 static struct unit_test_suite cryptodev_ccp_testsuite = {
12622 .suite_name = "Crypto Device CCP Unit Test Suite",
12623 .setup = testsuite_setup,
12624 .teardown = testsuite_teardown,
12625 .unit_test_cases = {
12626 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 test_multi_session_random_usage),
12629 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12630 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12631 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12632 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12633 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12635 /** Negative tests */
12636 TEST_CASE_ST(ut_setup, ut_teardown,
12637 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12638 TEST_CASE_ST(ut_setup, ut_teardown,
12639 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12645 TEST_CASES_END() /**< NULL terminate unit test array */
12649 static struct unit_test_suite cryptodev_nitrox_testsuite = {
12650 .suite_name = "Crypto NITROX Unit Test Suite",
12651 .setup = testsuite_setup,
12652 .teardown = testsuite_teardown,
12653 .unit_test_cases = {
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 test_device_configure_invalid_dev_id),
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 test_device_configure_invalid_queue_pair_ids),
12658 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12659 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12661 TEST_CASES_END() /**< NULL terminate unit test array */
12666 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
12668 gbl_driver_id = rte_cryptodev_driver_id_get(
12669 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
12671 if (gbl_driver_id == -1) {
12672 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
12673 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
12674 "are enabled in config file to run this testsuite.\n");
12675 return TEST_SKIPPED;
12678 return unit_test_suite_runner(&cryptodev_testsuite);
12682 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
12684 gbl_driver_id = rte_cryptodev_driver_id_get(
12685 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
12687 if (gbl_driver_id == -1) {
12688 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
12689 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
12690 "in config file to run this testsuite.\n");
12691 return TEST_FAILED;
12694 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
12698 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
12700 gbl_driver_id = rte_cryptodev_driver_id_get(
12701 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12703 if (gbl_driver_id == -1) {
12704 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12705 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12706 "in config file to run this testsuite.\n");
12707 return TEST_SKIPPED;
12710 return unit_test_suite_runner(&cryptodev_testsuite);
12714 test_cryptodev_cpu_aesni_mb(void)
12717 enum rte_security_session_action_type at;
12719 gbl_driver_id = rte_cryptodev_driver_id_get(
12720 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12722 if (gbl_driver_id == -1) {
12723 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12724 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12725 "in config file to run this testsuite.\n");
12726 return TEST_SKIPPED;
12729 at = gbl_action_type;
12730 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
12731 rc = unit_test_suite_runner(&cryptodev_testsuite);
12732 gbl_action_type = at;
12737 test_cryptodev_openssl(void)
12739 gbl_driver_id = rte_cryptodev_driver_id_get(
12740 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
12742 if (gbl_driver_id == -1) {
12743 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
12744 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
12745 "in config file to run this testsuite.\n");
12746 return TEST_SKIPPED;
12749 return unit_test_suite_runner(&cryptodev_testsuite);
12753 test_cryptodev_aesni_gcm(void)
12755 gbl_driver_id = rte_cryptodev_driver_id_get(
12756 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12758 if (gbl_driver_id == -1) {
12759 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
12760 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
12761 "in config file to run this testsuite.\n");
12762 return TEST_SKIPPED;
12765 return unit_test_suite_runner(&cryptodev_testsuite);
12769 test_cryptodev_cpu_aesni_gcm(void)
12772 enum rte_security_session_action_type at;
12774 gbl_driver_id = rte_cryptodev_driver_id_get(
12775 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12777 if (gbl_driver_id == -1) {
12778 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
12779 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
12780 "in config file to run this testsuite.\n");
12781 return TEST_SKIPPED;
12784 at = gbl_action_type;
12785 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
12786 rc = unit_test_suite_runner(&cryptodev_testsuite);
12787 gbl_action_type = at;
12792 test_cryptodev_null(void)
12794 gbl_driver_id = rte_cryptodev_driver_id_get(
12795 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
12797 if (gbl_driver_id == -1) {
12798 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
12799 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
12800 "in config file to run this testsuite.\n");
12801 return TEST_SKIPPED;
12804 return unit_test_suite_runner(&cryptodev_testsuite);
12808 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
12810 gbl_driver_id = rte_cryptodev_driver_id_get(
12811 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
12813 if (gbl_driver_id == -1) {
12814 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
12815 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
12816 "in config file to run this testsuite.\n");
12817 return TEST_SKIPPED;
12820 return unit_test_suite_runner(&cryptodev_testsuite);
12824 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
12826 gbl_driver_id = rte_cryptodev_driver_id_get(
12827 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
12829 if (gbl_driver_id == -1) {
12830 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
12831 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
12832 "in config file to run this testsuite.\n");
12833 return TEST_SKIPPED;
12836 return unit_test_suite_runner(&cryptodev_testsuite);
12840 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
12842 gbl_driver_id = rte_cryptodev_driver_id_get(
12843 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
12845 if (gbl_driver_id == -1) {
12846 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
12847 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
12848 "in config file to run this testsuite.\n");
12849 return TEST_SKIPPED;
12852 return unit_test_suite_runner(&cryptodev_testsuite);
12856 test_cryptodev_armv8(void)
12858 gbl_driver_id = rte_cryptodev_driver_id_get(
12859 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
12861 if (gbl_driver_id == -1) {
12862 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
12863 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
12864 "in config file to run this testsuite.\n");
12865 return TEST_SKIPPED;
12868 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
12872 test_cryptodev_mrvl(void)
12874 gbl_driver_id = rte_cryptodev_driver_id_get(
12875 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
12877 if (gbl_driver_id == -1) {
12878 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
12879 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
12880 "in config file to run this testsuite.\n");
12881 return TEST_SKIPPED;
12884 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
12887 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
12890 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
12892 gbl_driver_id = rte_cryptodev_driver_id_get(
12893 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
12895 if (gbl_driver_id == -1) {
12896 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
12897 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
12898 "in config file to run this testsuite.\n");
12899 return TEST_SKIPPED;
12902 if (rte_cryptodev_driver_id_get(
12903 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
12904 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
12905 " enabled in config file to run this testsuite.\n");
12906 return TEST_SKIPPED;
12908 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
12911 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
12916 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12918 gbl_driver_id = rte_cryptodev_driver_id_get(
12919 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
12921 if (gbl_driver_id == -1) {
12922 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
12923 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
12924 "in config file to run this testsuite.\n");
12925 return TEST_SKIPPED;
12928 return unit_test_suite_runner(&cryptodev_testsuite);
12932 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12934 gbl_driver_id = rte_cryptodev_driver_id_get(
12935 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
12937 if (gbl_driver_id == -1) {
12938 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
12939 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
12940 "in config file to run this testsuite.\n");
12941 return TEST_SKIPPED;
12944 return unit_test_suite_runner(&cryptodev_testsuite);
12948 test_cryptodev_ccp(void)
12950 gbl_driver_id = rte_cryptodev_driver_id_get(
12951 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
12953 if (gbl_driver_id == -1) {
12954 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
12955 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
12956 "in config file to run this testsuite.\n");
12957 return TEST_FAILED;
12960 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
12964 test_cryptodev_octeontx(void)
12966 gbl_driver_id = rte_cryptodev_driver_id_get(
12967 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
12968 if (gbl_driver_id == -1) {
12969 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
12970 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
12971 "enabled in config file to run this "
12973 return TEST_FAILED;
12975 return unit_test_suite_runner(&cryptodev_testsuite);
12979 test_cryptodev_octeontx2(void)
12981 gbl_driver_id = rte_cryptodev_driver_id_get(
12982 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
12983 if (gbl_driver_id == -1) {
12984 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
12985 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
12986 "enabled in config file to run this "
12988 return TEST_FAILED;
12990 return unit_test_suite_runner(&cryptodev_testsuite);
12994 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
12996 gbl_driver_id = rte_cryptodev_driver_id_get(
12997 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
12999 if (gbl_driver_id == -1) {
13000 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13001 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13002 "in config file to run this testsuite.\n");
13003 return TEST_FAILED;
13006 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13010 test_cryptodev_nitrox(void)
13012 gbl_driver_id = rte_cryptodev_driver_id_get(
13013 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13015 if (gbl_driver_id == -1) {
13016 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13017 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13018 "in config file to run this testsuite.\n");
13019 return TEST_FAILED;
13022 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13025 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13026 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13027 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13028 test_cryptodev_cpu_aesni_mb);
13029 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13030 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13031 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13032 test_cryptodev_cpu_aesni_gcm);
13033 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13034 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13035 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13036 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13037 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13038 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13039 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13040 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13041 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13042 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13043 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13044 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13045 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13046 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);