1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
20 #include <rte_string_fns.h>
24 #ifdef RTE_CRYPTO_SCHEDULER
25 #include <rte_cryptodev_scheduler.h>
26 #include <rte_cryptodev_scheduler_operations.h>
29 #include <rte_lcore.h>
32 #include "test_cryptodev.h"
34 #include "test_cryptodev_blockcipher.h"
35 #include "test_cryptodev_aes_test_vectors.h"
36 #include "test_cryptodev_des_test_vectors.h"
37 #include "test_cryptodev_hash_test_vectors.h"
38 #include "test_cryptodev_kasumi_test_vectors.h"
39 #include "test_cryptodev_kasumi_hash_test_vectors.h"
40 #include "test_cryptodev_snow3g_test_vectors.h"
41 #include "test_cryptodev_snow3g_hash_test_vectors.h"
42 #include "test_cryptodev_zuc_test_vectors.h"
43 #include "test_cryptodev_aead_test_vectors.h"
44 #include "test_cryptodev_hmac_test_vectors.h"
45 #include "test_cryptodev_mixed_test_vectors.h"
46 #ifdef RTE_LIB_SECURITY
47 #include "test_cryptodev_security_ipsec.h"
48 #include "test_cryptodev_security_ipsec_test_vectors.h"
49 #include "test_cryptodev_security_pdcp_test_vectors.h"
50 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
51 #include "test_cryptodev_security_pdcp_test_func.h"
52 #include "test_cryptodev_security_docsis_test_vectors.h"
54 #define SDAP_DISABLED 0
55 #define SDAP_ENABLED 1
58 #define VDEV_ARGS_SIZE 100
59 #define MAX_NB_SESSIONS 4
61 #define MAX_DRV_SERVICE_CTX_SIZE 256
63 #define MAX_RAW_DEQUEUE_COUNT 65535
66 #define OUT_OF_PLACE 1
68 static int gbl_driver_id;
70 static enum rte_security_session_action_type gbl_action_type =
71 RTE_SECURITY_ACTION_TYPE_NONE;
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 struct crypto_unittest_params {
76 struct rte_crypto_sym_xform cipher_xform;
77 struct rte_crypto_sym_xform auth_xform;
78 struct rte_crypto_sym_xform aead_xform;
79 #ifdef RTE_LIB_SECURITY
80 struct rte_security_docsis_xform docsis_xform;
84 struct rte_cryptodev_sym_session *sess;
85 #ifdef RTE_LIB_SECURITY
86 struct rte_security_session *sec_session;
89 #ifdef RTE_LIB_SECURITY
90 enum rte_security_session_action_type type;
92 struct rte_crypto_op *op;
94 struct rte_mbuf *obuf, *ibuf;
99 #define ALIGN_POW2_ROUNDUP(num, align) \
100 (((num) + (align) - 1) & ~((align) - 1))
102 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
103 for (j = 0; j < num_child_ts; index++, j++) \
104 parent_ts.unit_test_suites[index] = child_ts[j]
106 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
107 for (j = 0; j < num_blk_types; index++, j++) \
108 parent_ts.unit_test_suites[index] = \
109 build_blockcipher_test_suite(blk_types[j])
111 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
112 for (j = index; j < index + num_blk_types; j++) \
113 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
116 * Forward declarations.
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 struct crypto_unittest_params *ut_params,
126 struct crypto_testsuite_params *ts_param,
127 const uint8_t *cipher,
128 const uint8_t *digest,
132 security_proto_supported(enum rte_security_session_action_type action,
133 enum rte_security_session_protocol proto);
136 dev_configure_and_start(uint64_t ff_disable);
138 static struct rte_mbuf *
139 setup_test_string(struct rte_mempool *mpool,
140 const char *string, size_t len, uint8_t blocksize)
142 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
143 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
148 memset(m->buf_addr, 0, m->buf_len);
149 dst = rte_pktmbuf_append(m, t_len);
155 rte_memcpy(dst, string, t_len);
157 memset(dst, 0, t_len);
163 /* Get number of bytes in X bits (rounding up) */
165 ceil_byte_length(uint32_t num_bits)
168 return ((num_bits >> 3) + 1);
170 return (num_bits >> 3);
174 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
175 uint8_t is_op_success)
177 struct rte_crypto_op *op = user_data;
178 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
179 RTE_CRYPTO_OP_STATUS_ERROR;
183 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
184 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
185 uint8_t len_in_bits, uint8_t cipher_iv_len)
187 struct rte_crypto_sym_op *sop = op->sym;
188 struct rte_crypto_op *ret_op = NULL;
189 struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
190 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
191 union rte_crypto_sym_ofs ofs;
192 struct rte_crypto_sym_vec vec;
193 struct rte_crypto_sgl sgl, dest_sgl;
195 union rte_cryptodev_session_ctx sess;
197 struct rte_crypto_raw_dp_ctx *ctx;
198 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
202 int ctx_service_size;
204 int enqueue_status, dequeue_status;
206 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
207 if (ctx_service_size < 0) {
208 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
212 ctx = malloc(ctx_service_size);
214 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
218 /* Both are enums, setting crypto_sess will suit any session type */
219 sess.crypto_sess = op->sym->session;
221 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
222 op->sess_type, sess, 0) < 0) {
223 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
229 aad_auth_iv.iova = 0;
230 aad_auth_iv.va = NULL;
237 vec.digest = &digest;
238 vec.aad = &aad_auth_iv;
239 vec.status = &status;
243 if (is_cipher && is_auth) {
244 cipher_offset = sop->cipher.data.offset;
245 cipher_len = sop->cipher.data.length;
246 auth_offset = sop->auth.data.offset;
247 auth_len = sop->auth.data.length;
248 max_len = RTE_MAX(cipher_offset + cipher_len,
249 auth_offset + auth_len);
251 max_len = max_len >> 3;
252 cipher_offset = cipher_offset >> 3;
253 auth_offset = auth_offset >> 3;
254 cipher_len = cipher_len >> 3;
255 auth_len = auth_len >> 3;
257 ofs.ofs.cipher.head = cipher_offset;
258 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
259 ofs.ofs.auth.head = auth_offset;
260 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
261 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
262 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
263 aad_auth_iv.va = rte_crypto_op_ctod_offset(
264 op, void *, IV_OFFSET + cipher_iv_len);
265 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
267 digest.va = (void *)sop->auth.digest.data;
268 digest.iova = sop->auth.digest.phys_addr;
270 } else if (is_cipher) {
271 cipher_offset = sop->cipher.data.offset;
272 cipher_len = sop->cipher.data.length;
273 max_len = cipher_len + cipher_offset;
275 max_len = max_len >> 3;
276 cipher_offset = cipher_offset >> 3;
277 cipher_len = cipher_len >> 3;
279 ofs.ofs.cipher.head = cipher_offset;
280 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
281 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
282 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
284 } else if (is_auth) {
285 auth_offset = sop->auth.data.offset;
286 auth_len = sop->auth.data.length;
287 max_len = auth_len + auth_offset;
289 max_len = max_len >> 3;
290 auth_offset = auth_offset >> 3;
291 auth_len = auth_len >> 3;
293 ofs.ofs.auth.head = auth_offset;
294 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
295 aad_auth_iv.va = rte_crypto_op_ctod_offset(
296 op, void *, IV_OFFSET + cipher_iv_len);
297 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
299 digest.va = (void *)sop->auth.digest.data;
300 digest.iova = sop->auth.digest.phys_addr;
303 cipher_offset = sop->aead.data.offset;
304 cipher_len = sop->aead.data.length;
305 max_len = cipher_len + cipher_offset;
307 max_len = max_len >> 3;
308 cipher_offset = cipher_offset >> 3;
309 cipher_len = cipher_len >> 3;
311 ofs.ofs.cipher.head = cipher_offset;
312 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
313 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
314 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
315 aad_auth_iv.va = (void *)sop->aead.aad.data;
316 aad_auth_iv.iova = sop->aead.aad.phys_addr;
317 digest.va = (void *)sop->aead.digest.data;
318 digest.iova = sop->aead.digest.phys_addr;
321 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
322 data_vec, RTE_DIM(data_vec));
323 if (n < 0 || n > sop->m_src->nb_segs) {
324 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
330 if (sop->m_dst != NULL) {
331 dest_sgl.vec = dest_data_vec;
332 vec.dest_sgl = &dest_sgl;
333 n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
334 dest_data_vec, RTE_DIM(dest_data_vec));
335 if (n < 0 || n > sop->m_dst->nb_segs) {
336 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
343 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
344 &enqueue_status) < 1) {
345 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
349 if (enqueue_status == 0) {
350 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
352 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
355 } else if (enqueue_status < 0) {
356 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
361 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
362 n = rte_cryptodev_raw_dequeue_burst(ctx,
363 NULL, 1, post_process_raw_dp_op,
364 (void **)&ret_op, 0, &n_success,
366 if (dequeue_status < 0) {
367 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
374 if (n == 1 && dequeue_status == 0) {
375 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
376 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
381 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
382 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
383 RTE_CRYPTO_OP_STATUS_SUCCESS;
390 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
393 struct rte_crypto_sym_op *sop;
394 union rte_crypto_sym_ofs ofs;
395 struct rte_crypto_sgl sgl;
396 struct rte_crypto_sym_vec symvec;
397 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
398 struct rte_crypto_vec vec[UINT8_MAX];
402 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
403 sop->aead.data.length, vec, RTE_DIM(vec));
405 if (n < 0 || n != sop->m_src->nb_segs) {
406 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
412 symvec.src_sgl = &sgl;
414 symvec.digest = &digest_ptr;
415 symvec.aad = &aad_ptr;
419 /* for CPU crypto the IOVA address is not required */
420 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
421 digest_ptr.va = (void *)sop->aead.digest.data;
422 aad_ptr.va = (void *)sop->aead.aad.data;
426 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
430 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
432 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
436 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
439 struct rte_crypto_sym_op *sop;
440 union rte_crypto_sym_ofs ofs;
441 struct rte_crypto_sgl sgl;
442 struct rte_crypto_sym_vec symvec;
443 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
444 struct rte_crypto_vec vec[UINT8_MAX];
448 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
449 sop->auth.data.length, vec, RTE_DIM(vec));
451 if (n < 0 || n != sop->m_src->nb_segs) {
452 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
458 symvec.src_sgl = &sgl;
460 symvec.digest = &digest_ptr;
464 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
465 digest_ptr.va = (void *)sop->auth.digest.data;
468 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
469 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
470 (sop->cipher.data.offset + sop->cipher.data.length);
472 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
476 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
478 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
481 static struct rte_crypto_op *
482 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
485 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
487 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
488 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
494 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
497 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
498 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
505 static struct crypto_testsuite_params testsuite_params = { NULL };
506 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
507 static struct crypto_unittest_params unittest_params;
510 testsuite_setup(void)
512 struct crypto_testsuite_params *ts_params = &testsuite_params;
513 struct rte_cryptodev_info info;
514 uint32_t i = 0, nb_devs, dev_id;
517 memset(ts_params, 0, sizeof(*ts_params));
519 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
520 if (ts_params->mbuf_pool == NULL) {
521 /* Not already created so create */
522 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
524 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
526 if (ts_params->mbuf_pool == NULL) {
527 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
532 ts_params->large_mbuf_pool = rte_mempool_lookup(
533 "CRYPTO_LARGE_MBUFPOOL");
534 if (ts_params->large_mbuf_pool == NULL) {
535 /* Not already created so create */
536 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
537 "CRYPTO_LARGE_MBUFPOOL",
540 if (ts_params->large_mbuf_pool == NULL) {
542 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
547 ts_params->op_mpool = rte_crypto_op_pool_create(
548 "MBUF_CRYPTO_SYM_OP_POOL",
549 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
550 NUM_MBUFS, MBUF_CACHE_SIZE,
552 sizeof(struct rte_crypto_sym_xform) +
555 if (ts_params->op_mpool == NULL) {
556 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
560 nb_devs = rte_cryptodev_count();
562 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
566 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
567 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
568 rte_cryptodev_driver_name_get(gbl_driver_id));
572 /* Create list of valid crypto devs */
573 for (i = 0; i < nb_devs; i++) {
574 rte_cryptodev_info_get(i, &info);
575 if (info.driver_id == gbl_driver_id)
576 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
579 if (ts_params->valid_dev_count < 1)
582 /* Set up all the qps on the first of the valid devices found */
584 dev_id = ts_params->valid_devs[0];
586 rte_cryptodev_info_get(dev_id, &info);
588 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
589 ts_params->conf.socket_id = SOCKET_ID_ANY;
590 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
592 unsigned int session_size =
593 rte_cryptodev_sym_get_private_session_size(dev_id);
595 #ifdef RTE_LIB_SECURITY
596 unsigned int security_session_size = rte_security_session_get_size(
597 rte_cryptodev_get_sec_ctx(dev_id));
599 if (session_size < security_session_size)
600 session_size = security_session_size;
603 * Create mempool with maximum number of sessions.
605 if (info.sym.max_nb_sessions != 0 &&
606 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
607 RTE_LOG(ERR, USER1, "Device does not support "
608 "at least %u sessions\n",
613 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
614 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
616 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
617 "session mempool allocation failed");
619 ts_params->session_priv_mpool = rte_mempool_create(
623 0, 0, NULL, NULL, NULL,
626 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
627 "session mempool allocation failed");
631 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
633 "Failed to configure cryptodev %u with %u qps",
634 dev_id, ts_params->conf.nb_queue_pairs);
636 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
637 ts_params->qp_conf.mp_session = ts_params->session_mpool;
638 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
640 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
641 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
642 dev_id, qp_id, &ts_params->qp_conf,
643 rte_cryptodev_socket_id(dev_id)),
644 "Failed to setup queue pair %u on cryptodev %u",
652 testsuite_teardown(void)
654 struct crypto_testsuite_params *ts_params = &testsuite_params;
657 if (ts_params->mbuf_pool != NULL) {
658 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
659 rte_mempool_avail_count(ts_params->mbuf_pool));
662 if (ts_params->op_mpool != NULL) {
663 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
664 rte_mempool_avail_count(ts_params->op_mpool));
667 /* Free session mempools */
668 if (ts_params->session_priv_mpool != NULL) {
669 rte_mempool_free(ts_params->session_priv_mpool);
670 ts_params->session_priv_mpool = NULL;
673 if (ts_params->session_mpool != NULL) {
674 rte_mempool_free(ts_params->session_mpool);
675 ts_params->session_mpool = NULL;
678 res = rte_cryptodev_close(ts_params->valid_devs[0]);
680 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
684 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
685 const int *algs, uint16_t num_algs)
687 uint8_t dev_id = testsuite_params.valid_devs[0];
688 bool some_alg_supported = FALSE;
691 for (i = 0; i < num_algs && !some_alg_supported; i++) {
692 struct rte_cryptodev_sym_capability_idx alg = {
695 if (rte_cryptodev_sym_capability_get(dev_id,
697 some_alg_supported = TRUE;
699 if (!some_alg_supported)
706 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
707 uint16_t num_ciphers)
709 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
710 (const int *) ciphers, num_ciphers);
714 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
717 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
718 (const int *) auths, num_auths);
722 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
725 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
726 (const int *) aeads, num_aeads);
730 null_testsuite_setup(void)
732 struct crypto_testsuite_params *ts_params = &testsuite_params;
733 uint8_t dev_id = ts_params->valid_devs[0];
734 struct rte_cryptodev_info dev_info;
735 const enum rte_crypto_cipher_algorithm ciphers[] = {
736 RTE_CRYPTO_CIPHER_NULL
738 const enum rte_crypto_auth_algorithm auths[] = {
742 rte_cryptodev_info_get(dev_id, &dev_info);
744 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
745 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
746 "testsuite not met\n");
750 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
751 && check_auth_capabilities_supported(auths,
752 RTE_DIM(auths)) != 0) {
753 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
754 "testsuite not met\n");
762 crypto_gen_testsuite_setup(void)
764 struct crypto_testsuite_params *ts_params = &testsuite_params;
765 uint8_t dev_id = ts_params->valid_devs[0];
766 struct rte_cryptodev_info dev_info;
768 rte_cryptodev_info_get(dev_id, &dev_info);
770 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
771 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
772 "testsuite not met\n");
779 #ifdef RTE_LIB_SECURITY
781 ipsec_proto_testsuite_setup(void)
783 struct crypto_testsuite_params *ts_params = &testsuite_params;
784 struct crypto_unittest_params *ut_params = &unittest_params;
785 struct rte_cryptodev_info dev_info;
788 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
790 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
791 RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
792 "testsuite not met\n");
796 /* Reconfigure to enable security */
797 ret = dev_configure_and_start(0);
798 if (ret != TEST_SUCCESS)
801 /* Set action type */
802 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
804 if (security_proto_supported(
805 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
806 RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
807 RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
813 * Stop the device. Device would be started again by individual test
814 * case setup routine.
816 rte_cryptodev_stop(ts_params->valid_devs[0]);
822 pdcp_proto_testsuite_setup(void)
824 struct crypto_testsuite_params *ts_params = &testsuite_params;
825 uint8_t dev_id = ts_params->valid_devs[0];
826 struct rte_cryptodev_info dev_info;
827 const enum rte_crypto_cipher_algorithm ciphers[] = {
828 RTE_CRYPTO_CIPHER_NULL,
829 RTE_CRYPTO_CIPHER_AES_CTR,
830 RTE_CRYPTO_CIPHER_ZUC_EEA3,
831 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
833 const enum rte_crypto_auth_algorithm auths[] = {
834 RTE_CRYPTO_AUTH_NULL,
835 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
836 RTE_CRYPTO_AUTH_AES_CMAC,
837 RTE_CRYPTO_AUTH_ZUC_EIA3
840 rte_cryptodev_info_get(dev_id, &dev_info);
842 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
843 !(dev_info.feature_flags &
844 RTE_CRYPTODEV_FF_SECURITY)) {
845 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
846 "testsuite not met\n");
850 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
851 && check_auth_capabilities_supported(auths,
852 RTE_DIM(auths)) != 0) {
853 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
854 "testsuite not met\n");
862 docsis_proto_testsuite_setup(void)
864 struct crypto_testsuite_params *ts_params = &testsuite_params;
865 uint8_t dev_id = ts_params->valid_devs[0];
866 struct rte_cryptodev_info dev_info;
867 const enum rte_crypto_cipher_algorithm ciphers[] = {
868 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
871 rte_cryptodev_info_get(dev_id, &dev_info);
873 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
874 !(dev_info.feature_flags &
875 RTE_CRYPTODEV_FF_SECURITY)) {
876 RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
877 "Proto testsuite not met\n");
881 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
882 RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
883 "testsuite not met\n");
892 aes_ccm_auth_testsuite_setup(void)
894 struct crypto_testsuite_params *ts_params = &testsuite_params;
895 uint8_t dev_id = ts_params->valid_devs[0];
896 struct rte_cryptodev_info dev_info;
897 const enum rte_crypto_aead_algorithm aeads[] = {
898 RTE_CRYPTO_AEAD_AES_CCM
901 rte_cryptodev_info_get(dev_id, &dev_info);
903 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
904 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
905 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
906 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
907 "testsuite not met\n");
911 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
912 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
913 "testsuite not met\n");
921 aes_gcm_auth_testsuite_setup(void)
923 struct crypto_testsuite_params *ts_params = &testsuite_params;
924 uint8_t dev_id = ts_params->valid_devs[0];
925 struct rte_cryptodev_info dev_info;
926 const enum rte_crypto_aead_algorithm aeads[] = {
927 RTE_CRYPTO_AEAD_AES_GCM
930 rte_cryptodev_info_get(dev_id, &dev_info);
932 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
933 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
934 "testsuite not met\n");
938 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
939 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
940 "testsuite not met\n");
948 aes_gmac_auth_testsuite_setup(void)
950 struct crypto_testsuite_params *ts_params = &testsuite_params;
951 uint8_t dev_id = ts_params->valid_devs[0];
952 struct rte_cryptodev_info dev_info;
953 const enum rte_crypto_auth_algorithm auths[] = {
954 RTE_CRYPTO_AUTH_AES_GMAC
957 rte_cryptodev_info_get(dev_id, &dev_info);
959 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
960 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
961 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
962 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
963 "testsuite not met\n");
967 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
968 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
969 "testsuite not met\n");
977 chacha20_poly1305_testsuite_setup(void)
979 struct crypto_testsuite_params *ts_params = &testsuite_params;
980 uint8_t dev_id = ts_params->valid_devs[0];
981 struct rte_cryptodev_info dev_info;
982 const enum rte_crypto_aead_algorithm aeads[] = {
983 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
986 rte_cryptodev_info_get(dev_id, &dev_info);
988 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
989 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
990 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
991 RTE_LOG(INFO, USER1, "Feature flag requirements for "
992 "Chacha20-Poly1305 testsuite not met\n");
996 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
997 RTE_LOG(INFO, USER1, "Capability requirements for "
998 "Chacha20-Poly1305 testsuite not met\n");
1006 snow3g_testsuite_setup(void)
1008 struct crypto_testsuite_params *ts_params = &testsuite_params;
1009 uint8_t dev_id = ts_params->valid_devs[0];
1010 struct rte_cryptodev_info dev_info;
1011 const enum rte_crypto_cipher_algorithm ciphers[] = {
1012 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1015 const enum rte_crypto_auth_algorithm auths[] = {
1016 RTE_CRYPTO_AUTH_SNOW3G_UIA2
1019 rte_cryptodev_info_get(dev_id, &dev_info);
1021 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1022 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1023 "testsuite not met\n");
1024 return TEST_SKIPPED;
1027 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1028 && check_auth_capabilities_supported(auths,
1029 RTE_DIM(auths)) != 0) {
1030 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1031 "testsuite not met\n");
1032 return TEST_SKIPPED;
1039 zuc_testsuite_setup(void)
1041 struct crypto_testsuite_params *ts_params = &testsuite_params;
1042 uint8_t dev_id = ts_params->valid_devs[0];
1043 struct rte_cryptodev_info dev_info;
1044 const enum rte_crypto_cipher_algorithm ciphers[] = {
1045 RTE_CRYPTO_CIPHER_ZUC_EEA3
1047 const enum rte_crypto_auth_algorithm auths[] = {
1048 RTE_CRYPTO_AUTH_ZUC_EIA3
1051 rte_cryptodev_info_get(dev_id, &dev_info);
1053 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1054 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1055 "testsuite not met\n");
1056 return TEST_SKIPPED;
1059 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1060 && check_auth_capabilities_supported(auths,
1061 RTE_DIM(auths)) != 0) {
1062 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1063 "testsuite not met\n");
1064 return TEST_SKIPPED;
1071 hmac_md5_auth_testsuite_setup(void)
1073 struct crypto_testsuite_params *ts_params = &testsuite_params;
1074 uint8_t dev_id = ts_params->valid_devs[0];
1075 struct rte_cryptodev_info dev_info;
1076 const enum rte_crypto_auth_algorithm auths[] = {
1077 RTE_CRYPTO_AUTH_MD5_HMAC
1080 rte_cryptodev_info_get(dev_id, &dev_info);
1082 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1083 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1084 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1085 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1086 "Auth testsuite not met\n");
1087 return TEST_SKIPPED;
1090 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1091 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1092 "testsuite not met\n");
1093 return TEST_SKIPPED;
1100 kasumi_testsuite_setup(void)
1102 struct crypto_testsuite_params *ts_params = &testsuite_params;
1103 uint8_t dev_id = ts_params->valid_devs[0];
1104 struct rte_cryptodev_info dev_info;
1105 const enum rte_crypto_cipher_algorithm ciphers[] = {
1106 RTE_CRYPTO_CIPHER_KASUMI_F8
1108 const enum rte_crypto_auth_algorithm auths[] = {
1109 RTE_CRYPTO_AUTH_KASUMI_F9
1112 rte_cryptodev_info_get(dev_id, &dev_info);
1114 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1115 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1116 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1117 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1118 "testsuite not met\n");
1119 return TEST_SKIPPED;
1122 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1123 && check_auth_capabilities_supported(auths,
1124 RTE_DIM(auths)) != 0) {
1125 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1126 "testsuite not met\n");
1127 return TEST_SKIPPED;
1134 negative_aes_gcm_testsuite_setup(void)
1136 struct crypto_testsuite_params *ts_params = &testsuite_params;
1137 uint8_t dev_id = ts_params->valid_devs[0];
1138 struct rte_cryptodev_info dev_info;
1139 const enum rte_crypto_aead_algorithm aeads[] = {
1140 RTE_CRYPTO_AEAD_AES_GCM
1143 rte_cryptodev_info_get(dev_id, &dev_info);
1145 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1146 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1147 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1148 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1149 "AES GCM testsuite not met\n");
1150 return TEST_SKIPPED;
1153 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1154 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1155 "AES GCM testsuite not met\n");
1156 return TEST_SKIPPED;
1163 negative_aes_gmac_testsuite_setup(void)
1165 struct crypto_testsuite_params *ts_params = &testsuite_params;
1166 uint8_t dev_id = ts_params->valid_devs[0];
1167 struct rte_cryptodev_info dev_info;
1168 const enum rte_crypto_auth_algorithm auths[] = {
1169 RTE_CRYPTO_AUTH_AES_GMAC
1172 rte_cryptodev_info_get(dev_id, &dev_info);
1174 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1175 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1176 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1177 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1178 "AES GMAC testsuite not met\n");
1179 return TEST_SKIPPED;
1182 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1183 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1184 "AES GMAC testsuite not met\n");
1185 return TEST_SKIPPED;
1192 mixed_cipher_hash_testsuite_setup(void)
1194 struct crypto_testsuite_params *ts_params = &testsuite_params;
1195 uint8_t dev_id = ts_params->valid_devs[0];
1196 struct rte_cryptodev_info dev_info;
1197 uint64_t feat_flags;
1198 const enum rte_crypto_cipher_algorithm ciphers[] = {
1199 RTE_CRYPTO_CIPHER_NULL,
1200 RTE_CRYPTO_CIPHER_AES_CTR,
1201 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1202 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1204 const enum rte_crypto_auth_algorithm auths[] = {
1205 RTE_CRYPTO_AUTH_NULL,
1206 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1207 RTE_CRYPTO_AUTH_AES_CMAC,
1208 RTE_CRYPTO_AUTH_ZUC_EIA3
1211 rte_cryptodev_info_get(dev_id, &dev_info);
1212 feat_flags = dev_info.feature_flags;
1214 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1215 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1216 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1217 "Cipher Hash testsuite not met\n");
1218 return TEST_SKIPPED;
1221 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1222 && check_auth_capabilities_supported(auths,
1223 RTE_DIM(auths)) != 0) {
1224 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1225 "Cipher Hash testsuite not met\n");
1226 return TEST_SKIPPED;
1233 esn_testsuite_setup(void)
1235 struct crypto_testsuite_params *ts_params = &testsuite_params;
1236 uint8_t dev_id = ts_params->valid_devs[0];
1237 struct rte_cryptodev_info dev_info;
1238 const enum rte_crypto_cipher_algorithm ciphers[] = {
1239 RTE_CRYPTO_CIPHER_AES_CBC
1241 const enum rte_crypto_auth_algorithm auths[] = {
1242 RTE_CRYPTO_AUTH_SHA1_HMAC
1245 rte_cryptodev_info_get(dev_id, &dev_info);
1247 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1248 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1249 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1250 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1251 "testsuite not met\n");
1252 return TEST_SKIPPED;
1255 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1256 && check_auth_capabilities_supported(auths,
1257 RTE_DIM(auths)) != 0) {
1258 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1259 "testsuite not met\n");
1260 return TEST_SKIPPED;
1267 multi_session_testsuite_setup(void)
1269 struct crypto_testsuite_params *ts_params = &testsuite_params;
1270 uint8_t dev_id = ts_params->valid_devs[0];
1271 struct rte_cryptodev_info dev_info;
1272 const enum rte_crypto_cipher_algorithm ciphers[] = {
1273 RTE_CRYPTO_CIPHER_AES_CBC
1275 const enum rte_crypto_auth_algorithm auths[] = {
1276 RTE_CRYPTO_AUTH_SHA512_HMAC
1279 rte_cryptodev_info_get(dev_id, &dev_info);
1281 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1282 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1283 "Session testsuite not met\n");
1284 return TEST_SKIPPED;
1287 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1288 && check_auth_capabilities_supported(auths,
1289 RTE_DIM(auths)) != 0) {
1290 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1291 "Session testsuite not met\n");
1292 return TEST_SKIPPED;
1299 negative_hmac_sha1_testsuite_setup(void)
1301 struct crypto_testsuite_params *ts_params = &testsuite_params;
1302 uint8_t dev_id = ts_params->valid_devs[0];
1303 struct rte_cryptodev_info dev_info;
1304 const enum rte_crypto_cipher_algorithm ciphers[] = {
1305 RTE_CRYPTO_CIPHER_AES_CBC
1307 const enum rte_crypto_auth_algorithm auths[] = {
1308 RTE_CRYPTO_AUTH_SHA1_HMAC
1311 rte_cryptodev_info_get(dev_id, &dev_info);
1313 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1314 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1315 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1316 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1317 "HMAC SHA1 testsuite not met\n");
1318 return TEST_SKIPPED;
1321 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1322 && check_auth_capabilities_supported(auths,
1323 RTE_DIM(auths)) != 0) {
1324 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1325 "HMAC SHA1 testsuite not met\n");
1326 return TEST_SKIPPED;
1333 dev_configure_and_start(uint64_t ff_disable)
1335 struct crypto_testsuite_params *ts_params = &testsuite_params;
1336 struct crypto_unittest_params *ut_params = &unittest_params;
1340 /* Clear unit test parameters before running test */
1341 memset(ut_params, 0, sizeof(*ut_params));
1343 /* Reconfigure device to default parameters */
1344 ts_params->conf.socket_id = SOCKET_ID_ANY;
1345 ts_params->conf.ff_disable = ff_disable;
1346 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1347 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1348 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1350 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1352 "Failed to configure cryptodev %u",
1353 ts_params->valid_devs[0]);
1355 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1356 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1357 ts_params->valid_devs[0], qp_id,
1358 &ts_params->qp_conf,
1359 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1360 "Failed to setup queue pair %u on cryptodev %u",
1361 qp_id, ts_params->valid_devs[0]);
1365 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1367 /* Start the device */
1368 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1369 "Failed to start cryptodev %u",
1370 ts_params->valid_devs[0]);
1372 return TEST_SUCCESS;
1378 /* Configure and start the device with security feature disabled */
1379 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1383 ut_setup_security(void)
1385 /* Configure and start the device with no features disabled */
1386 return dev_configure_and_start(0);
1392 struct crypto_testsuite_params *ts_params = &testsuite_params;
1393 struct crypto_unittest_params *ut_params = &unittest_params;
1394 struct rte_cryptodev_stats stats;
1396 /* free crypto session structure */
1397 #ifdef RTE_LIB_SECURITY
1398 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1399 if (ut_params->sec_session) {
1400 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1401 (ts_params->valid_devs[0]),
1402 ut_params->sec_session);
1403 ut_params->sec_session = NULL;
1408 if (ut_params->sess) {
1409 rte_cryptodev_sym_session_clear(
1410 ts_params->valid_devs[0],
1412 rte_cryptodev_sym_session_free(ut_params->sess);
1413 ut_params->sess = NULL;
1417 /* free crypto operation structure */
1419 rte_crypto_op_free(ut_params->op);
1422 * free mbuf - both obuf and ibuf are usually the same,
1423 * so check if they point at the same address is necessary,
1424 * to avoid freeing the mbuf twice.
1426 if (ut_params->obuf) {
1427 rte_pktmbuf_free(ut_params->obuf);
1428 if (ut_params->ibuf == ut_params->obuf)
1429 ut_params->ibuf = 0;
1430 ut_params->obuf = 0;
1432 if (ut_params->ibuf) {
1433 rte_pktmbuf_free(ut_params->ibuf);
1434 ut_params->ibuf = 0;
1437 if (ts_params->mbuf_pool != NULL)
1438 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1439 rte_mempool_avail_count(ts_params->mbuf_pool));
1441 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1443 /* Stop the device */
1444 rte_cryptodev_stop(ts_params->valid_devs[0]);
1448 test_device_configure_invalid_dev_id(void)
1450 struct crypto_testsuite_params *ts_params = &testsuite_params;
1451 uint16_t dev_id, num_devs = 0;
1453 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1454 "Need at least %d devices for test", 1);
1456 /* valid dev_id values */
1457 dev_id = ts_params->valid_devs[0];
1459 /* Stop the device in case it's started so it can be configured */
1460 rte_cryptodev_stop(dev_id);
1462 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1463 "Failed test for rte_cryptodev_configure: "
1464 "invalid dev_num %u", dev_id);
1466 /* invalid dev_id values */
1469 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1470 "Failed test for rte_cryptodev_configure: "
1471 "invalid dev_num %u", dev_id);
1475 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1476 "Failed test for rte_cryptodev_configure:"
1477 "invalid dev_num %u", dev_id);
1479 return TEST_SUCCESS;
1483 test_device_configure_invalid_queue_pair_ids(void)
1485 struct crypto_testsuite_params *ts_params = &testsuite_params;
1486 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1488 /* Stop the device in case it's started so it can be configured */
1489 rte_cryptodev_stop(ts_params->valid_devs[0]);
1491 /* valid - max value queue pairs */
1492 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1494 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1496 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1497 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1499 /* valid - one queue pairs */
1500 ts_params->conf.nb_queue_pairs = 1;
1502 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1504 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1505 ts_params->valid_devs[0],
1506 ts_params->conf.nb_queue_pairs);
1509 /* invalid - zero queue pairs */
1510 ts_params->conf.nb_queue_pairs = 0;
1512 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1514 "Failed test for rte_cryptodev_configure, dev_id %u,"
1516 ts_params->valid_devs[0],
1517 ts_params->conf.nb_queue_pairs);
1520 /* invalid - max value supported by field queue pairs */
1521 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1523 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1525 "Failed test for rte_cryptodev_configure, dev_id %u,"
1527 ts_params->valid_devs[0],
1528 ts_params->conf.nb_queue_pairs);
1531 /* invalid - max value + 1 queue pairs */
1532 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1534 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1536 "Failed test for rte_cryptodev_configure, dev_id %u,"
1538 ts_params->valid_devs[0],
1539 ts_params->conf.nb_queue_pairs);
1541 /* revert to original testsuite value */
1542 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1544 return TEST_SUCCESS;
1548 test_queue_pair_descriptor_setup(void)
1550 struct crypto_testsuite_params *ts_params = &testsuite_params;
1551 struct rte_cryptodev_qp_conf qp_conf = {
1552 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1556 /* Stop the device in case it's started so it can be configured */
1557 rte_cryptodev_stop(ts_params->valid_devs[0]);
1559 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1561 "Failed to configure cryptodev %u",
1562 ts_params->valid_devs[0]);
1565 * Test various ring sizes on this device. memzones can't be
1566 * freed so are re-used if ring is released and re-created.
1568 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1569 qp_conf.mp_session = ts_params->session_mpool;
1570 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1572 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1573 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1574 ts_params->valid_devs[0], qp_id, &qp_conf,
1575 rte_cryptodev_socket_id(
1576 ts_params->valid_devs[0])),
1578 "rte_cryptodev_queue_pair_setup: num_inflights "
1579 "%u on qp %u on cryptodev %u",
1580 qp_conf.nb_descriptors, qp_id,
1581 ts_params->valid_devs[0]);
1584 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1586 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1587 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1588 ts_params->valid_devs[0], qp_id, &qp_conf,
1589 rte_cryptodev_socket_id(
1590 ts_params->valid_devs[0])),
1592 " rte_cryptodev_queue_pair_setup: num_inflights"
1593 " %u on qp %u on cryptodev %u",
1594 qp_conf.nb_descriptors, qp_id,
1595 ts_params->valid_devs[0]);
1598 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1600 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1601 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1602 ts_params->valid_devs[0], qp_id, &qp_conf,
1603 rte_cryptodev_socket_id(
1604 ts_params->valid_devs[0])),
1606 "rte_cryptodev_queue_pair_setup: num_inflights"
1607 " %u on qp %u on cryptodev %u",
1608 qp_conf.nb_descriptors, qp_id,
1609 ts_params->valid_devs[0]);
1612 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1614 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1615 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1616 ts_params->valid_devs[0], qp_id, &qp_conf,
1617 rte_cryptodev_socket_id(
1618 ts_params->valid_devs[0])),
1620 " rte_cryptodev_queue_pair_setup:"
1621 "num_inflights %u on qp %u on cryptodev %u",
1622 qp_conf.nb_descriptors, qp_id,
1623 ts_params->valid_devs[0]);
1626 /* test invalid queue pair id */
1627 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1629 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1631 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1632 ts_params->valid_devs[0],
1634 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1635 "Failed test for rte_cryptodev_queue_pair_setup:"
1636 "invalid qp %u on cryptodev %u",
1637 qp_id, ts_params->valid_devs[0]);
1639 qp_id = 0xffff; /*invalid*/
1641 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1642 ts_params->valid_devs[0],
1644 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1645 "Failed test for rte_cryptodev_queue_pair_setup:"
1646 "invalid qp %u on cryptodev %u",
1647 qp_id, ts_params->valid_devs[0]);
1649 return TEST_SUCCESS;
1652 /* ***** Plaintext data for tests ***** */
1654 const char catch_22_quote_1[] =
1655 "There was only one catch and that was Catch-22, which "
1656 "specified that a concern for one's safety in the face of "
1657 "dangers that were real and immediate was the process of a "
1658 "rational mind. Orr was crazy and could be grounded. All he "
1659 "had to do was ask; and as soon as he did, he would no longer "
1660 "be crazy and would have to fly more missions. Orr would be "
1661 "crazy to fly more missions and sane if he didn't, but if he "
1662 "was sane he had to fly them. If he flew them he was crazy "
1663 "and didn't have to; but if he didn't want to he was sane and "
1664 "had to. Yossarian was moved very deeply by the absolute "
1665 "simplicity of this clause of Catch-22 and let out a "
1666 "respectful whistle. \"That's some catch, that Catch-22\", he "
1667 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1669 const char catch_22_quote[] =
1670 "What a lousy earth! He wondered how many people were "
1671 "destitute that same night even in his own prosperous country, "
1672 "how many homes were shanties, how many husbands were drunk "
1673 "and wives socked, and how many children were bullied, abused, "
1674 "or abandoned. How many families hungered for food they could "
1675 "not afford to buy? How many hearts were broken? How many "
1676 "suicides would take place that same night, how many people "
1677 "would go insane? How many cockroaches and landlords would "
1678 "triumph? How many winners were losers, successes failures, "
1679 "and rich men poor men? How many wise guys were stupid? How "
1680 "many happy endings were unhappy endings? How many honest men "
1681 "were liars, brave men cowards, loyal men traitors, how many "
1682 "sainted men were corrupt, how many people in positions of "
1683 "trust had sold their souls to bodyguards, how many had never "
1684 "had souls? How many straight-and-narrow paths were crooked "
1685 "paths? How many best families were worst families and how "
1686 "many good people were bad people? When you added them all up "
1687 "and then subtracted, you might be left with only the children, "
1688 "and perhaps with Albert Einstein and an old violinist or "
1689 "sculptor somewhere.";
1691 #define QUOTE_480_BYTES (480)
1692 #define QUOTE_512_BYTES (512)
1693 #define QUOTE_768_BYTES (768)
1694 #define QUOTE_1024_BYTES (1024)
1698 /* ***** SHA1 Hash Tests ***** */
1700 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1702 static uint8_t hmac_sha1_key[] = {
1703 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1704 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1705 0xDE, 0xF4, 0xDE, 0xAD };
1707 /* ***** SHA224 Hash Tests ***** */
1709 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1712 /* ***** AES-CBC Cipher Tests ***** */
1714 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1715 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1717 static uint8_t aes_cbc_key[] = {
1718 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1719 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1721 static uint8_t aes_cbc_iv[] = {
1722 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1723 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1726 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1728 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1729 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1730 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1731 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1732 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1733 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1734 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1735 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1736 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1737 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1738 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1739 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1740 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1741 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1742 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1743 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1744 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1745 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1746 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1747 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1748 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1749 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1750 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1751 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1752 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1753 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1754 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1755 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1756 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1757 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1758 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1759 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1760 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1761 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1762 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1763 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1764 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1765 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1766 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1767 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1768 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1769 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1770 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1771 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1772 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1773 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1774 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1775 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1776 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1777 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1778 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1779 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1780 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1781 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1782 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1783 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1784 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1785 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1786 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1787 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1788 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1789 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1790 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1791 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1792 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1795 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1796 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1797 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1798 0x18, 0x8c, 0x1d, 0x32
1802 /* Multisession Vector context Test */
1803 /*Begin Session 0 */
1804 static uint8_t ms_aes_cbc_key0[] = {
1805 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1806 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1809 static uint8_t ms_aes_cbc_iv0[] = {
1810 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1811 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1814 static const uint8_t ms_aes_cbc_cipher0[] = {
1815 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1816 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1817 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1818 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1819 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1820 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1821 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1822 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1823 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1824 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1825 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1826 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1827 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1828 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1829 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1830 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1831 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1832 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1833 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1834 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1835 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1836 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1837 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1838 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1839 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1840 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1841 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1842 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1843 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1844 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1845 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1846 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1847 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1848 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1849 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1850 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1851 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1852 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1853 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1854 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1855 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1856 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1857 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1858 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1859 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1860 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1861 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1862 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1863 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1864 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1865 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1866 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1867 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1868 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1869 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1870 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1871 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1872 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1873 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1874 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1875 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1876 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1877 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1878 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1882 static uint8_t ms_hmac_key0[] = {
1883 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1884 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1885 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1886 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1887 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1888 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1889 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1890 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1893 static const uint8_t ms_hmac_digest0[] = {
1894 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1895 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1896 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1897 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1898 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1899 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1900 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1901 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1905 /* Begin session 1 */
1907 static uint8_t ms_aes_cbc_key1[] = {
1908 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1909 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1912 static uint8_t ms_aes_cbc_iv1[] = {
1913 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1914 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1917 static const uint8_t ms_aes_cbc_cipher1[] = {
1918 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1919 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1920 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1921 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1922 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1923 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1924 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1925 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1926 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1927 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1928 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1929 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1930 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1931 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1932 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1933 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1934 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1935 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1936 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1937 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1938 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1939 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1940 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1941 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1942 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1943 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1944 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1945 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1946 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1947 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1948 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1949 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1950 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1951 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1952 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1953 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1954 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1955 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1956 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1957 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1958 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1959 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1960 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1961 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1962 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1963 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1964 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1965 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1966 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1967 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1968 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1969 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1970 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1971 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1972 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1973 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1974 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1975 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1976 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1977 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1978 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1979 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1980 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1981 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1985 static uint8_t ms_hmac_key1[] = {
1986 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1987 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1988 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1989 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1990 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1991 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1992 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1993 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1996 static const uint8_t ms_hmac_digest1[] = {
1997 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1998 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1999 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2000 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2001 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2002 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2003 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2004 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2007 /* Begin Session 2 */
2008 static uint8_t ms_aes_cbc_key2[] = {
2009 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2010 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2013 static uint8_t ms_aes_cbc_iv2[] = {
2014 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2015 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2018 static const uint8_t ms_aes_cbc_cipher2[] = {
2019 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2020 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2021 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2022 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2023 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2024 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2025 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2026 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2027 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2028 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2029 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2030 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2031 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2032 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2033 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2034 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2035 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2036 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2037 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2038 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2039 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2040 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2041 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2042 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2043 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2044 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2045 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2046 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2047 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2048 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2049 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2050 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2051 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2052 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2053 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2054 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2055 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2056 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2057 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2058 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2059 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2060 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2061 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2062 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2063 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2064 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2065 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2066 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2067 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2068 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2069 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2070 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2071 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2072 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2073 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2074 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2075 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2076 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2077 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2078 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2079 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2080 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2081 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2082 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2085 static uint8_t ms_hmac_key2[] = {
2086 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2087 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2088 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2089 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2090 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2091 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2092 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2093 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2096 static const uint8_t ms_hmac_digest2[] = {
2097 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2098 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2099 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2100 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2101 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2102 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2103 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2104 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2111 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2113 struct crypto_testsuite_params *ts_params = &testsuite_params;
2114 struct crypto_unittest_params *ut_params = &unittest_params;
2116 /* Verify the capabilities */
2117 struct rte_cryptodev_sym_capability_idx cap_idx;
2118 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2119 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2120 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2122 return TEST_SKIPPED;
2123 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2124 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2125 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2127 return TEST_SKIPPED;
2129 /* Generate test mbuf data and space for digest */
2130 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2131 catch_22_quote, QUOTE_512_BYTES, 0);
2133 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2134 DIGEST_BYTE_LENGTH_SHA1);
2135 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2137 /* Setup Cipher Parameters */
2138 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2139 ut_params->cipher_xform.next = &ut_params->auth_xform;
2141 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2142 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2143 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2144 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2145 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2146 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2148 /* Setup HMAC Parameters */
2149 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2151 ut_params->auth_xform.next = NULL;
2153 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2154 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2155 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2156 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2157 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2159 ut_params->sess = rte_cryptodev_sym_session_create(
2160 ts_params->session_mpool);
2162 /* Create crypto session*/
2163 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2164 ut_params->sess, &ut_params->cipher_xform,
2165 ts_params->session_priv_mpool);
2166 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2168 /* Generate crypto op data structure */
2169 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2170 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2171 TEST_ASSERT_NOT_NULL(ut_params->op,
2172 "Failed to allocate symmetric crypto operation struct");
2174 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2176 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2178 /* set crypto operation source mbuf */
2179 sym_op->m_src = ut_params->ibuf;
2181 /* Set crypto operation authentication parameters */
2182 sym_op->auth.digest.data = ut_params->digest;
2183 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2184 ut_params->ibuf, QUOTE_512_BYTES);
2186 sym_op->auth.data.offset = 0;
2187 sym_op->auth.data.length = QUOTE_512_BYTES;
2189 /* Copy IV at the end of the crypto operation */
2190 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2191 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2193 /* Set crypto operation cipher parameters */
2194 sym_op->cipher.data.offset = 0;
2195 sym_op->cipher.data.length = QUOTE_512_BYTES;
2197 /* Process crypto operation */
2198 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2199 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2202 TEST_ASSERT_NOT_NULL(
2203 process_crypto_request(ts_params->valid_devs[0],
2205 "failed to process sym crypto op");
2207 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2208 "crypto op processing failed");
2211 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2214 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2215 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2217 "ciphertext data not as expected");
2219 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2221 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2222 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2223 gbl_driver_id == rte_cryptodev_driver_id_get(
2224 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2225 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2226 DIGEST_BYTE_LENGTH_SHA1,
2227 "Generated digest data not as expected");
2229 return TEST_SUCCESS;
2232 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2234 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2236 static uint8_t hmac_sha512_key[] = {
2237 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2238 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2239 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2240 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2241 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2242 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2243 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2244 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2246 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2247 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2248 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2249 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2250 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2251 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2252 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2253 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2254 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2259 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2260 struct crypto_unittest_params *ut_params,
2261 uint8_t *cipher_key,
2265 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2266 struct crypto_unittest_params *ut_params,
2267 struct crypto_testsuite_params *ts_params,
2268 const uint8_t *cipher,
2269 const uint8_t *digest,
2274 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2275 struct crypto_unittest_params *ut_params,
2276 uint8_t *cipher_key,
2280 /* Setup Cipher Parameters */
2281 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2282 ut_params->cipher_xform.next = NULL;
2284 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2285 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2286 ut_params->cipher_xform.cipher.key.data = cipher_key;
2287 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2288 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2289 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2291 /* Setup HMAC Parameters */
2292 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2293 ut_params->auth_xform.next = &ut_params->cipher_xform;
2295 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2296 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2297 ut_params->auth_xform.auth.key.data = hmac_key;
2298 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2299 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2301 return TEST_SUCCESS;
2306 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2307 struct crypto_unittest_params *ut_params,
2308 struct crypto_testsuite_params *ts_params,
2309 const uint8_t *cipher,
2310 const uint8_t *digest,
2313 /* Generate test mbuf data and digest */
2314 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2317 QUOTE_512_BYTES, 0);
2319 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2320 DIGEST_BYTE_LENGTH_SHA512);
2321 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2323 rte_memcpy(ut_params->digest,
2325 DIGEST_BYTE_LENGTH_SHA512);
2327 /* Generate Crypto op data structure */
2328 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2329 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2330 TEST_ASSERT_NOT_NULL(ut_params->op,
2331 "Failed to allocate symmetric crypto operation struct");
2333 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2335 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2337 /* set crypto operation source mbuf */
2338 sym_op->m_src = ut_params->ibuf;
2340 sym_op->auth.digest.data = ut_params->digest;
2341 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2342 ut_params->ibuf, QUOTE_512_BYTES);
2344 sym_op->auth.data.offset = 0;
2345 sym_op->auth.data.length = QUOTE_512_BYTES;
2347 /* Copy IV at the end of the crypto operation */
2348 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2349 iv, CIPHER_IV_LENGTH_AES_CBC);
2351 sym_op->cipher.data.offset = 0;
2352 sym_op->cipher.data.length = QUOTE_512_BYTES;
2354 /* Process crypto operation */
2355 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2356 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2358 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2359 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2360 ut_params->op, 1, 1, 0, 0);
2362 TEST_ASSERT_NOT_NULL(
2363 process_crypto_request(ts_params->valid_devs[0],
2365 "failed to process sym crypto op");
2367 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2368 "crypto op processing failed");
2370 ut_params->obuf = ut_params->op->sym->m_src;
2373 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2374 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2377 "Plaintext data not as expected");
2380 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2381 "Digest verification failed");
2383 return TEST_SUCCESS;
2386 /* ***** SNOW 3G Tests ***** */
2388 create_wireless_algo_hash_session(uint8_t dev_id,
2389 const uint8_t *key, const uint8_t key_len,
2390 const uint8_t iv_len, const uint8_t auth_len,
2391 enum rte_crypto_auth_operation op,
2392 enum rte_crypto_auth_algorithm algo)
2394 uint8_t hash_key[key_len];
2397 struct crypto_testsuite_params *ts_params = &testsuite_params;
2398 struct crypto_unittest_params *ut_params = &unittest_params;
2400 memcpy(hash_key, key, key_len);
2402 debug_hexdump(stdout, "key:", key, key_len);
2404 /* Setup Authentication Parameters */
2405 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2406 ut_params->auth_xform.next = NULL;
2408 ut_params->auth_xform.auth.op = op;
2409 ut_params->auth_xform.auth.algo = algo;
2410 ut_params->auth_xform.auth.key.length = key_len;
2411 ut_params->auth_xform.auth.key.data = hash_key;
2412 ut_params->auth_xform.auth.digest_length = auth_len;
2413 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2414 ut_params->auth_xform.auth.iv.length = iv_len;
2415 ut_params->sess = rte_cryptodev_sym_session_create(
2416 ts_params->session_mpool);
2418 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2419 &ut_params->auth_xform,
2420 ts_params->session_priv_mpool);
2421 if (status == -ENOTSUP)
2422 return TEST_SKIPPED;
2424 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2425 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2430 create_wireless_algo_cipher_session(uint8_t dev_id,
2431 enum rte_crypto_cipher_operation op,
2432 enum rte_crypto_cipher_algorithm algo,
2433 const uint8_t *key, const uint8_t key_len,
2436 uint8_t cipher_key[key_len];
2438 struct crypto_testsuite_params *ts_params = &testsuite_params;
2439 struct crypto_unittest_params *ut_params = &unittest_params;
2441 memcpy(cipher_key, key, key_len);
2443 /* Setup Cipher Parameters */
2444 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2445 ut_params->cipher_xform.next = NULL;
2447 ut_params->cipher_xform.cipher.algo = algo;
2448 ut_params->cipher_xform.cipher.op = op;
2449 ut_params->cipher_xform.cipher.key.data = cipher_key;
2450 ut_params->cipher_xform.cipher.key.length = key_len;
2451 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2452 ut_params->cipher_xform.cipher.iv.length = iv_len;
2454 debug_hexdump(stdout, "key:", key, key_len);
2456 /* Create Crypto session */
2457 ut_params->sess = rte_cryptodev_sym_session_create(
2458 ts_params->session_mpool);
2460 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2461 &ut_params->cipher_xform,
2462 ts_params->session_priv_mpool);
2463 if (status == -ENOTSUP)
2464 return TEST_SKIPPED;
2466 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2467 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2472 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2473 unsigned int cipher_len,
2474 unsigned int cipher_offset)
2476 struct crypto_testsuite_params *ts_params = &testsuite_params;
2477 struct crypto_unittest_params *ut_params = &unittest_params;
2479 /* Generate Crypto op data structure */
2480 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2481 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2482 TEST_ASSERT_NOT_NULL(ut_params->op,
2483 "Failed to allocate pktmbuf offload");
2485 /* Set crypto operation data parameters */
2486 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2488 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2490 /* set crypto operation source mbuf */
2491 sym_op->m_src = ut_params->ibuf;
2494 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2496 sym_op->cipher.data.length = cipher_len;
2497 sym_op->cipher.data.offset = cipher_offset;
2502 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2503 unsigned int cipher_len,
2504 unsigned int cipher_offset)
2506 struct crypto_testsuite_params *ts_params = &testsuite_params;
2507 struct crypto_unittest_params *ut_params = &unittest_params;
2509 /* Generate Crypto op data structure */
2510 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2511 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2512 TEST_ASSERT_NOT_NULL(ut_params->op,
2513 "Failed to allocate pktmbuf offload");
2515 /* Set crypto operation data parameters */
2516 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2518 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2520 /* set crypto operation source mbuf */
2521 sym_op->m_src = ut_params->ibuf;
2522 sym_op->m_dst = ut_params->obuf;
2525 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2527 sym_op->cipher.data.length = cipher_len;
2528 sym_op->cipher.data.offset = cipher_offset;
2533 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2534 enum rte_crypto_cipher_operation cipher_op,
2535 enum rte_crypto_auth_operation auth_op,
2536 enum rte_crypto_auth_algorithm auth_algo,
2537 enum rte_crypto_cipher_algorithm cipher_algo,
2538 const uint8_t *key, uint8_t key_len,
2539 uint8_t auth_iv_len, uint8_t auth_len,
2540 uint8_t cipher_iv_len)
2543 uint8_t cipher_auth_key[key_len];
2546 struct crypto_testsuite_params *ts_params = &testsuite_params;
2547 struct crypto_unittest_params *ut_params = &unittest_params;
2549 memcpy(cipher_auth_key, key, key_len);
2551 /* Setup Authentication Parameters */
2552 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2553 ut_params->auth_xform.next = NULL;
2555 ut_params->auth_xform.auth.op = auth_op;
2556 ut_params->auth_xform.auth.algo = auth_algo;
2557 ut_params->auth_xform.auth.key.length = key_len;
2558 /* Hash key = cipher key */
2559 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2560 ut_params->auth_xform.auth.digest_length = auth_len;
2561 /* Auth IV will be after cipher IV */
2562 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2563 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2565 /* Setup Cipher Parameters */
2566 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2567 ut_params->cipher_xform.next = &ut_params->auth_xform;
2569 ut_params->cipher_xform.cipher.algo = cipher_algo;
2570 ut_params->cipher_xform.cipher.op = cipher_op;
2571 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2572 ut_params->cipher_xform.cipher.key.length = key_len;
2573 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2574 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2576 debug_hexdump(stdout, "key:", key, key_len);
2578 /* Create Crypto session*/
2579 ut_params->sess = rte_cryptodev_sym_session_create(
2580 ts_params->session_mpool);
2581 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2583 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2584 &ut_params->cipher_xform,
2585 ts_params->session_priv_mpool);
2586 if (status == -ENOTSUP)
2587 return TEST_SKIPPED;
2589 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2594 create_wireless_cipher_auth_session(uint8_t dev_id,
2595 enum rte_crypto_cipher_operation cipher_op,
2596 enum rte_crypto_auth_operation auth_op,
2597 enum rte_crypto_auth_algorithm auth_algo,
2598 enum rte_crypto_cipher_algorithm cipher_algo,
2599 const struct wireless_test_data *tdata)
2601 const uint8_t key_len = tdata->key.len;
2602 uint8_t cipher_auth_key[key_len];
2605 struct crypto_testsuite_params *ts_params = &testsuite_params;
2606 struct crypto_unittest_params *ut_params = &unittest_params;
2607 const uint8_t *key = tdata->key.data;
2608 const uint8_t auth_len = tdata->digest.len;
2609 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2610 uint8_t auth_iv_len = tdata->auth_iv.len;
2612 memcpy(cipher_auth_key, key, key_len);
2614 /* Setup Authentication Parameters */
2615 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2616 ut_params->auth_xform.next = NULL;
2618 ut_params->auth_xform.auth.op = auth_op;
2619 ut_params->auth_xform.auth.algo = auth_algo;
2620 ut_params->auth_xform.auth.key.length = key_len;
2621 /* Hash key = cipher key */
2622 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2623 ut_params->auth_xform.auth.digest_length = auth_len;
2624 /* Auth IV will be after cipher IV */
2625 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2626 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2628 /* Setup Cipher Parameters */
2629 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2630 ut_params->cipher_xform.next = &ut_params->auth_xform;
2632 ut_params->cipher_xform.cipher.algo = cipher_algo;
2633 ut_params->cipher_xform.cipher.op = cipher_op;
2634 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2635 ut_params->cipher_xform.cipher.key.length = key_len;
2636 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2637 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2640 debug_hexdump(stdout, "key:", key, key_len);
2642 /* Create Crypto session*/
2643 ut_params->sess = rte_cryptodev_sym_session_create(
2644 ts_params->session_mpool);
2646 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2647 &ut_params->cipher_xform,
2648 ts_params->session_priv_mpool);
2649 if (status == -ENOTSUP)
2650 return TEST_SKIPPED;
2652 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2653 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2658 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2659 const struct wireless_test_data *tdata)
2661 return create_wireless_cipher_auth_session(dev_id,
2662 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2663 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2664 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2668 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2669 enum rte_crypto_cipher_operation cipher_op,
2670 enum rte_crypto_auth_operation auth_op,
2671 enum rte_crypto_auth_algorithm auth_algo,
2672 enum rte_crypto_cipher_algorithm cipher_algo,
2673 const uint8_t *key, const uint8_t key_len,
2674 uint8_t auth_iv_len, uint8_t auth_len,
2675 uint8_t cipher_iv_len)
2677 uint8_t auth_cipher_key[key_len];
2679 struct crypto_testsuite_params *ts_params = &testsuite_params;
2680 struct crypto_unittest_params *ut_params = &unittest_params;
2682 memcpy(auth_cipher_key, key, key_len);
2684 /* Setup Authentication Parameters */
2685 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2686 ut_params->auth_xform.auth.op = auth_op;
2687 ut_params->auth_xform.next = &ut_params->cipher_xform;
2688 ut_params->auth_xform.auth.algo = auth_algo;
2689 ut_params->auth_xform.auth.key.length = key_len;
2690 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2691 ut_params->auth_xform.auth.digest_length = auth_len;
2692 /* Auth IV will be after cipher IV */
2693 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2694 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2696 /* Setup Cipher Parameters */
2697 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2698 ut_params->cipher_xform.next = NULL;
2699 ut_params->cipher_xform.cipher.algo = cipher_algo;
2700 ut_params->cipher_xform.cipher.op = cipher_op;
2701 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2702 ut_params->cipher_xform.cipher.key.length = key_len;
2703 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2704 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2706 debug_hexdump(stdout, "key:", key, key_len);
2708 /* Create Crypto session*/
2709 ut_params->sess = rte_cryptodev_sym_session_create(
2710 ts_params->session_mpool);
2711 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2713 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2714 ut_params->auth_xform.next = NULL;
2715 ut_params->cipher_xform.next = &ut_params->auth_xform;
2716 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2717 &ut_params->cipher_xform,
2718 ts_params->session_priv_mpool);
2721 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2722 &ut_params->auth_xform,
2723 ts_params->session_priv_mpool);
2725 if (status == -ENOTSUP)
2726 return TEST_SKIPPED;
2728 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2734 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2735 unsigned int auth_tag_len,
2736 const uint8_t *iv, unsigned int iv_len,
2737 unsigned int data_pad_len,
2738 enum rte_crypto_auth_operation op,
2739 unsigned int auth_len, unsigned int auth_offset)
2741 struct crypto_testsuite_params *ts_params = &testsuite_params;
2743 struct crypto_unittest_params *ut_params = &unittest_params;
2745 /* Generate Crypto op data structure */
2746 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2747 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2748 TEST_ASSERT_NOT_NULL(ut_params->op,
2749 "Failed to allocate pktmbuf offload");
2751 /* Set crypto operation data parameters */
2752 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2754 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2756 /* set crypto operation source mbuf */
2757 sym_op->m_src = ut_params->ibuf;
2760 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2763 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2764 ut_params->ibuf, auth_tag_len);
2766 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2767 "no room to append auth tag");
2768 ut_params->digest = sym_op->auth.digest.data;
2769 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2770 ut_params->ibuf, data_pad_len);
2771 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2772 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2774 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2776 debug_hexdump(stdout, "digest:",
2777 sym_op->auth.digest.data,
2780 sym_op->auth.data.length = auth_len;
2781 sym_op->auth.data.offset = auth_offset;
2787 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2788 enum rte_crypto_auth_operation op)
2790 struct crypto_testsuite_params *ts_params = &testsuite_params;
2791 struct crypto_unittest_params *ut_params = &unittest_params;
2793 const uint8_t *auth_tag = tdata->digest.data;
2794 const unsigned int auth_tag_len = tdata->digest.len;
2795 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2796 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2798 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2799 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2800 const uint8_t *auth_iv = tdata->auth_iv.data;
2801 const uint8_t auth_iv_len = tdata->auth_iv.len;
2802 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2803 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2805 /* Generate Crypto op data structure */
2806 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2807 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2808 TEST_ASSERT_NOT_NULL(ut_params->op,
2809 "Failed to allocate pktmbuf offload");
2810 /* Set crypto operation data parameters */
2811 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2813 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2815 /* set crypto operation source mbuf */
2816 sym_op->m_src = ut_params->ibuf;
2819 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2820 ut_params->ibuf, auth_tag_len);
2822 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2823 "no room to append auth tag");
2824 ut_params->digest = sym_op->auth.digest.data;
2825 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2826 ut_params->ibuf, data_pad_len);
2827 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2828 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2830 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2832 debug_hexdump(stdout, "digest:",
2833 sym_op->auth.digest.data,
2836 /* Copy cipher and auth IVs at the end of the crypto operation */
2837 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2839 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2840 iv_ptr += cipher_iv_len;
2841 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2843 sym_op->cipher.data.length = cipher_len;
2844 sym_op->cipher.data.offset = 0;
2845 sym_op->auth.data.length = auth_len;
2846 sym_op->auth.data.offset = 0;
2852 create_zuc_cipher_hash_generate_operation(
2853 const struct wireless_test_data *tdata)
2855 return create_wireless_cipher_hash_operation(tdata,
2856 RTE_CRYPTO_AUTH_OP_GENERATE);
2860 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2861 const unsigned auth_tag_len,
2862 const uint8_t *auth_iv, uint8_t auth_iv_len,
2863 unsigned data_pad_len,
2864 enum rte_crypto_auth_operation op,
2865 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2866 const unsigned cipher_len, const unsigned cipher_offset,
2867 const unsigned auth_len, const unsigned auth_offset)
2869 struct crypto_testsuite_params *ts_params = &testsuite_params;
2870 struct crypto_unittest_params *ut_params = &unittest_params;
2872 enum rte_crypto_cipher_algorithm cipher_algo =
2873 ut_params->cipher_xform.cipher.algo;
2874 enum rte_crypto_auth_algorithm auth_algo =
2875 ut_params->auth_xform.auth.algo;
2877 /* Generate Crypto op data structure */
2878 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2879 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2880 TEST_ASSERT_NOT_NULL(ut_params->op,
2881 "Failed to allocate pktmbuf offload");
2882 /* Set crypto operation data parameters */
2883 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2885 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2887 /* set crypto operation source mbuf */
2888 sym_op->m_src = ut_params->ibuf;
2891 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2892 ut_params->ibuf, auth_tag_len);
2894 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2895 "no room to append auth tag");
2896 ut_params->digest = sym_op->auth.digest.data;
2898 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2899 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2900 ut_params->ibuf, data_pad_len);
2902 struct rte_mbuf *m = ut_params->ibuf;
2903 unsigned int offset = data_pad_len;
2905 while (offset > m->data_len && m->next != NULL) {
2906 offset -= m->data_len;
2909 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2913 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2914 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2916 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2918 debug_hexdump(stdout, "digest:",
2919 sym_op->auth.digest.data,
2922 /* Copy cipher and auth IVs at the end of the crypto operation */
2923 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2925 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2926 iv_ptr += cipher_iv_len;
2927 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2929 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2930 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2931 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2932 sym_op->cipher.data.length = cipher_len;
2933 sym_op->cipher.data.offset = cipher_offset;
2935 sym_op->cipher.data.length = cipher_len >> 3;
2936 sym_op->cipher.data.offset = cipher_offset >> 3;
2939 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2940 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2941 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2942 sym_op->auth.data.length = auth_len;
2943 sym_op->auth.data.offset = auth_offset;
2945 sym_op->auth.data.length = auth_len >> 3;
2946 sym_op->auth.data.offset = auth_offset >> 3;
2953 create_wireless_algo_auth_cipher_operation(
2954 const uint8_t *auth_tag, unsigned int auth_tag_len,
2955 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2956 const uint8_t *auth_iv, uint8_t auth_iv_len,
2957 unsigned int data_pad_len,
2958 unsigned int cipher_len, unsigned int cipher_offset,
2959 unsigned int auth_len, unsigned int auth_offset,
2960 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2962 struct crypto_testsuite_params *ts_params = &testsuite_params;
2963 struct crypto_unittest_params *ut_params = &unittest_params;
2965 enum rte_crypto_cipher_algorithm cipher_algo =
2966 ut_params->cipher_xform.cipher.algo;
2967 enum rte_crypto_auth_algorithm auth_algo =
2968 ut_params->auth_xform.auth.algo;
2970 /* Generate Crypto op data structure */
2971 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2972 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2973 TEST_ASSERT_NOT_NULL(ut_params->op,
2974 "Failed to allocate pktmbuf offload");
2976 /* Set crypto operation data parameters */
2977 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2979 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2981 /* set crypto operation mbufs */
2982 sym_op->m_src = ut_params->ibuf;
2983 if (op_mode == OUT_OF_PLACE)
2984 sym_op->m_dst = ut_params->obuf;
2988 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2989 (op_mode == IN_PLACE ?
2990 ut_params->ibuf : ut_params->obuf),
2991 uint8_t *, data_pad_len);
2992 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2993 (op_mode == IN_PLACE ?
2994 ut_params->ibuf : ut_params->obuf),
2996 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2998 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2999 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3000 sym_op->m_src : sym_op->m_dst);
3001 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3002 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3003 sgl_buf = sgl_buf->next;
3005 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3006 uint8_t *, remaining_off);
3007 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3009 memset(sym_op->auth.digest.data, 0, remaining_off);
3010 while (sgl_buf->next != NULL) {
3011 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3012 0, rte_pktmbuf_data_len(sgl_buf));
3013 sgl_buf = sgl_buf->next;
3017 /* Copy digest for the verification */
3019 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3021 /* Copy cipher and auth IVs at the end of the crypto operation */
3022 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3023 ut_params->op, uint8_t *, IV_OFFSET);
3025 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3026 iv_ptr += cipher_iv_len;
3027 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3029 /* Only copy over the offset data needed from src to dst in OOP,
3030 * if the auth and cipher offsets are not aligned
3032 if (op_mode == OUT_OF_PLACE) {
3033 if (cipher_offset > auth_offset)
3035 rte_pktmbuf_mtod_offset(
3037 uint8_t *, auth_offset >> 3),
3038 rte_pktmbuf_mtod_offset(
3040 uint8_t *, auth_offset >> 3),
3041 ((cipher_offset >> 3) - (auth_offset >> 3)));
3044 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3045 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3046 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3047 sym_op->cipher.data.length = cipher_len;
3048 sym_op->cipher.data.offset = cipher_offset;
3050 sym_op->cipher.data.length = cipher_len >> 3;
3051 sym_op->cipher.data.offset = cipher_offset >> 3;
3054 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3055 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3056 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3057 sym_op->auth.data.length = auth_len;
3058 sym_op->auth.data.offset = auth_offset;
3060 sym_op->auth.data.length = auth_len >> 3;
3061 sym_op->auth.data.offset = auth_offset >> 3;
3068 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3070 struct crypto_testsuite_params *ts_params = &testsuite_params;
3071 struct crypto_unittest_params *ut_params = &unittest_params;
3074 unsigned plaintext_pad_len;
3075 unsigned plaintext_len;
3077 struct rte_cryptodev_info dev_info;
3079 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3080 uint64_t feat_flags = dev_info.feature_flags;
3082 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3083 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3084 printf("Device doesn't support NON-Byte Aligned Data.\n");
3085 return TEST_SKIPPED;
3088 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3089 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3090 printf("Device doesn't support RAW data-path APIs.\n");
3091 return TEST_SKIPPED;
3094 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3095 return TEST_SKIPPED;
3097 /* Verify the capabilities */
3098 struct rte_cryptodev_sym_capability_idx cap_idx;
3099 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3100 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3101 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3103 return TEST_SKIPPED;
3105 /* Create SNOW 3G session */
3106 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3107 tdata->key.data, tdata->key.len,
3108 tdata->auth_iv.len, tdata->digest.len,
3109 RTE_CRYPTO_AUTH_OP_GENERATE,
3110 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3114 /* alloc mbuf and set payload */
3115 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3117 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3118 rte_pktmbuf_tailroom(ut_params->ibuf));
3120 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3121 /* Append data which is padded to a multiple of */
3122 /* the algorithms block size */
3123 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3124 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3126 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3128 /* Create SNOW 3G operation */
3129 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3130 tdata->auth_iv.data, tdata->auth_iv.len,
3131 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3132 tdata->validAuthLenInBits.len,
3137 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3138 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3139 ut_params->op, 0, 1, 1, 0);
3141 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3143 ut_params->obuf = ut_params->op->sym->m_src;
3144 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3145 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3146 + plaintext_pad_len;
3149 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3152 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3153 "SNOW 3G Generated auth tag not as expected");
3159 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3161 struct crypto_testsuite_params *ts_params = &testsuite_params;
3162 struct crypto_unittest_params *ut_params = &unittest_params;
3165 unsigned plaintext_pad_len;
3166 unsigned plaintext_len;
3168 struct rte_cryptodev_info dev_info;
3170 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3171 uint64_t feat_flags = dev_info.feature_flags;
3173 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3174 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3175 printf("Device doesn't support NON-Byte Aligned Data.\n");
3176 return TEST_SKIPPED;
3179 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3180 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3181 printf("Device doesn't support RAW data-path APIs.\n");
3182 return TEST_SKIPPED;
3185 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3186 return TEST_SKIPPED;
3188 /* Verify the capabilities */
3189 struct rte_cryptodev_sym_capability_idx cap_idx;
3190 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3191 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3192 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3194 return TEST_SKIPPED;
3196 /* Create SNOW 3G session */
3197 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3198 tdata->key.data, tdata->key.len,
3199 tdata->auth_iv.len, tdata->digest.len,
3200 RTE_CRYPTO_AUTH_OP_VERIFY,
3201 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3204 /* alloc mbuf and set payload */
3205 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3207 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3208 rte_pktmbuf_tailroom(ut_params->ibuf));
3210 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3211 /* Append data which is padded to a multiple of */
3212 /* the algorithms block size */
3213 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3214 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3216 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3218 /* Create SNOW 3G operation */
3219 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3221 tdata->auth_iv.data, tdata->auth_iv.len,
3223 RTE_CRYPTO_AUTH_OP_VERIFY,
3224 tdata->validAuthLenInBits.len,
3229 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3230 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3231 ut_params->op, 0, 1, 1, 0);
3233 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3235 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3236 ut_params->obuf = ut_params->op->sym->m_src;
3237 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3238 + plaintext_pad_len;
3241 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3250 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3252 struct crypto_testsuite_params *ts_params = &testsuite_params;
3253 struct crypto_unittest_params *ut_params = &unittest_params;
3256 unsigned plaintext_pad_len;
3257 unsigned plaintext_len;
3259 struct rte_cryptodev_info dev_info;
3261 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3262 uint64_t feat_flags = dev_info.feature_flags;
3264 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3265 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3266 printf("Device doesn't support RAW data-path APIs.\n");
3267 return TEST_SKIPPED;
3270 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3271 return TEST_SKIPPED;
3273 /* Verify the capabilities */
3274 struct rte_cryptodev_sym_capability_idx cap_idx;
3275 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3276 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3277 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3279 return TEST_SKIPPED;
3281 /* Create KASUMI session */
3282 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3283 tdata->key.data, tdata->key.len,
3284 0, tdata->digest.len,
3285 RTE_CRYPTO_AUTH_OP_GENERATE,
3286 RTE_CRYPTO_AUTH_KASUMI_F9);
3290 /* alloc mbuf and set payload */
3291 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3293 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3294 rte_pktmbuf_tailroom(ut_params->ibuf));
3296 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3297 /* Append data which is padded to a multiple of */
3298 /* the algorithms block size */
3299 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3300 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3302 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3304 /* Create KASUMI operation */
3305 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3307 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3308 tdata->plaintext.len,
3313 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3314 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3316 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3317 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3318 ut_params->op, 0, 1, 1, 0);
3320 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3323 ut_params->obuf = ut_params->op->sym->m_src;
3324 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3325 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3326 + plaintext_pad_len;
3329 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3332 DIGEST_BYTE_LENGTH_KASUMI_F9,
3333 "KASUMI Generated auth tag not as expected");
3339 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3341 struct crypto_testsuite_params *ts_params = &testsuite_params;
3342 struct crypto_unittest_params *ut_params = &unittest_params;
3345 unsigned plaintext_pad_len;
3346 unsigned plaintext_len;
3348 struct rte_cryptodev_info dev_info;
3350 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3351 uint64_t feat_flags = dev_info.feature_flags;
3353 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3354 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3355 printf("Device doesn't support RAW data-path APIs.\n");
3356 return TEST_SKIPPED;
3359 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3360 return TEST_SKIPPED;
3362 /* Verify the capabilities */
3363 struct rte_cryptodev_sym_capability_idx cap_idx;
3364 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3365 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3366 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3368 return TEST_SKIPPED;
3370 /* Create KASUMI session */
3371 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3372 tdata->key.data, tdata->key.len,
3373 0, tdata->digest.len,
3374 RTE_CRYPTO_AUTH_OP_VERIFY,
3375 RTE_CRYPTO_AUTH_KASUMI_F9);
3378 /* alloc mbuf and set payload */
3379 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3381 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3382 rte_pktmbuf_tailroom(ut_params->ibuf));
3384 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3385 /* Append data which is padded to a multiple */
3386 /* of the algorithms block size */
3387 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3388 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3390 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3392 /* Create KASUMI operation */
3393 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3397 RTE_CRYPTO_AUTH_OP_VERIFY,
3398 tdata->plaintext.len,
3403 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3404 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3405 ut_params->op, 0, 1, 1, 0);
3407 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3409 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3410 ut_params->obuf = ut_params->op->sym->m_src;
3411 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3412 + plaintext_pad_len;
3415 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3424 test_snow3g_hash_generate_test_case_1(void)
3426 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3430 test_snow3g_hash_generate_test_case_2(void)
3432 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3436 test_snow3g_hash_generate_test_case_3(void)
3438 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3442 test_snow3g_hash_generate_test_case_4(void)
3444 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3448 test_snow3g_hash_generate_test_case_5(void)
3450 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3454 test_snow3g_hash_generate_test_case_6(void)
3456 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3460 test_snow3g_hash_verify_test_case_1(void)
3462 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3467 test_snow3g_hash_verify_test_case_2(void)
3469 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3473 test_snow3g_hash_verify_test_case_3(void)
3475 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3479 test_snow3g_hash_verify_test_case_4(void)
3481 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3485 test_snow3g_hash_verify_test_case_5(void)
3487 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3491 test_snow3g_hash_verify_test_case_6(void)
3493 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3497 test_kasumi_hash_generate_test_case_1(void)
3499 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3503 test_kasumi_hash_generate_test_case_2(void)
3505 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3509 test_kasumi_hash_generate_test_case_3(void)
3511 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3515 test_kasumi_hash_generate_test_case_4(void)
3517 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3521 test_kasumi_hash_generate_test_case_5(void)
3523 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3527 test_kasumi_hash_generate_test_case_6(void)
3529 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3533 test_kasumi_hash_verify_test_case_1(void)
3535 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3539 test_kasumi_hash_verify_test_case_2(void)
3541 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3545 test_kasumi_hash_verify_test_case_3(void)
3547 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3551 test_kasumi_hash_verify_test_case_4(void)
3553 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3557 test_kasumi_hash_verify_test_case_5(void)
3559 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3563 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3565 struct crypto_testsuite_params *ts_params = &testsuite_params;
3566 struct crypto_unittest_params *ut_params = &unittest_params;
3569 uint8_t *plaintext, *ciphertext;
3570 unsigned plaintext_pad_len;
3571 unsigned plaintext_len;
3572 struct rte_cryptodev_info dev_info;
3574 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3575 uint64_t feat_flags = dev_info.feature_flags;
3577 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3578 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3579 printf("Device doesn't support RAW data-path APIs.\n");
3580 return TEST_SKIPPED;
3583 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3584 return TEST_SKIPPED;
3586 /* Verify the capabilities */
3587 struct rte_cryptodev_sym_capability_idx cap_idx;
3588 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3589 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3590 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3592 return TEST_SKIPPED;
3594 /* Create KASUMI session */
3595 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3596 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3597 RTE_CRYPTO_CIPHER_KASUMI_F8,
3598 tdata->key.data, tdata->key.len,
3599 tdata->cipher_iv.len);
3603 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3605 /* Clear mbuf payload */
3606 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3607 rte_pktmbuf_tailroom(ut_params->ibuf));
3609 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3610 /* Append data which is padded to a multiple */
3611 /* of the algorithms block size */
3612 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3613 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3615 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3617 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3619 /* Create KASUMI operation */
3620 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3621 tdata->cipher_iv.len,
3622 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3623 tdata->validCipherOffsetInBits.len);
3627 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3628 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3629 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3631 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3633 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3635 ut_params->obuf = ut_params->op->sym->m_dst;
3636 if (ut_params->obuf)
3637 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3639 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3641 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3643 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3644 (tdata->validCipherOffsetInBits.len >> 3);
3646 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3648 reference_ciphertext,
3649 tdata->validCipherLenInBits.len,
3650 "KASUMI Ciphertext data not as expected");
3655 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3657 struct crypto_testsuite_params *ts_params = &testsuite_params;
3658 struct crypto_unittest_params *ut_params = &unittest_params;
3662 unsigned int plaintext_pad_len;
3663 unsigned int plaintext_len;
3665 uint8_t buffer[10000];
3666 const uint8_t *ciphertext;
3668 struct rte_cryptodev_info dev_info;
3670 /* Verify the capabilities */
3671 struct rte_cryptodev_sym_capability_idx cap_idx;
3672 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3673 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3674 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3676 return TEST_SKIPPED;
3678 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3680 uint64_t feat_flags = dev_info.feature_flags;
3682 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3683 printf("Device doesn't support in-place scatter-gather. "
3685 return TEST_SKIPPED;
3688 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3689 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3690 printf("Device doesn't support RAW data-path APIs.\n");
3691 return TEST_SKIPPED;
3694 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3695 return TEST_SKIPPED;
3697 /* Create KASUMI session */
3698 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3699 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3700 RTE_CRYPTO_CIPHER_KASUMI_F8,
3701 tdata->key.data, tdata->key.len,
3702 tdata->cipher_iv.len);
3706 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3709 /* Append data which is padded to a multiple */
3710 /* of the algorithms block size */
3711 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3713 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3714 plaintext_pad_len, 10, 0);
3716 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3718 /* Create KASUMI operation */
3719 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3720 tdata->cipher_iv.len,
3721 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3722 tdata->validCipherOffsetInBits.len);
3726 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3727 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3728 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3730 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3732 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3734 ut_params->obuf = ut_params->op->sym->m_dst;
3736 if (ut_params->obuf)
3737 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3738 plaintext_len, buffer);
3740 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3741 tdata->validCipherOffsetInBits.len >> 3,
3742 plaintext_len, buffer);
3745 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3747 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3748 (tdata->validCipherOffsetInBits.len >> 3);
3750 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3752 reference_ciphertext,
3753 tdata->validCipherLenInBits.len,
3754 "KASUMI Ciphertext data not as expected");
3759 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3761 struct crypto_testsuite_params *ts_params = &testsuite_params;
3762 struct crypto_unittest_params *ut_params = &unittest_params;
3765 uint8_t *plaintext, *ciphertext;
3766 unsigned plaintext_pad_len;
3767 unsigned plaintext_len;
3769 /* Verify the capabilities */
3770 struct rte_cryptodev_sym_capability_idx cap_idx;
3771 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3772 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3773 /* Data-path service does not support OOP */
3774 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3776 return TEST_SKIPPED;
3778 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3779 return TEST_SKIPPED;
3781 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3782 return TEST_SKIPPED;
3784 /* Create KASUMI session */
3785 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3786 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3787 RTE_CRYPTO_CIPHER_KASUMI_F8,
3788 tdata->key.data, tdata->key.len,
3789 tdata->cipher_iv.len);
3793 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3794 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3796 /* Clear mbuf payload */
3797 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3798 rte_pktmbuf_tailroom(ut_params->ibuf));
3800 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3801 /* Append data which is padded to a multiple */
3802 /* of the algorithms block size */
3803 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3804 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3806 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3807 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3809 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3811 /* Create KASUMI operation */
3812 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3813 tdata->cipher_iv.len,
3814 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3815 tdata->validCipherOffsetInBits.len);
3819 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3821 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3823 ut_params->obuf = ut_params->op->sym->m_dst;
3824 if (ut_params->obuf)
3825 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3827 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3829 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3831 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3832 (tdata->validCipherOffsetInBits.len >> 3);
3834 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3836 reference_ciphertext,
3837 tdata->validCipherLenInBits.len,
3838 "KASUMI Ciphertext data not as expected");
3843 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3845 struct crypto_testsuite_params *ts_params = &testsuite_params;
3846 struct crypto_unittest_params *ut_params = &unittest_params;
3849 unsigned int plaintext_pad_len;
3850 unsigned int plaintext_len;
3852 const uint8_t *ciphertext;
3853 uint8_t buffer[2048];
3855 struct rte_cryptodev_info dev_info;
3857 /* Verify the capabilities */
3858 struct rte_cryptodev_sym_capability_idx cap_idx;
3859 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3860 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3861 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3863 return TEST_SKIPPED;
3865 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3866 return TEST_SKIPPED;
3868 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3869 return TEST_SKIPPED;
3871 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3873 uint64_t feat_flags = dev_info.feature_flags;
3874 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3875 printf("Device doesn't support out-of-place scatter-gather "
3876 "in both input and output mbufs. "
3878 return TEST_SKIPPED;
3881 /* Create KASUMI session */
3882 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3883 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3884 RTE_CRYPTO_CIPHER_KASUMI_F8,
3885 tdata->key.data, tdata->key.len,
3886 tdata->cipher_iv.len);
3890 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3891 /* Append data which is padded to a multiple */
3892 /* of the algorithms block size */
3893 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3895 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3896 plaintext_pad_len, 10, 0);
3897 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3898 plaintext_pad_len, 3, 0);
3900 /* Append data which is padded to a multiple */
3901 /* of the algorithms block size */
3902 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3904 /* Create KASUMI operation */
3905 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3906 tdata->cipher_iv.len,
3907 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3908 tdata->validCipherOffsetInBits.len);
3912 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3914 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3916 ut_params->obuf = ut_params->op->sym->m_dst;
3917 if (ut_params->obuf)
3918 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3919 plaintext_pad_len, buffer);
3921 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3922 tdata->validCipherOffsetInBits.len >> 3,
3923 plaintext_pad_len, buffer);
3925 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3926 (tdata->validCipherOffsetInBits.len >> 3);
3928 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3930 reference_ciphertext,
3931 tdata->validCipherLenInBits.len,
3932 "KASUMI Ciphertext data not as expected");
3938 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3940 struct crypto_testsuite_params *ts_params = &testsuite_params;
3941 struct crypto_unittest_params *ut_params = &unittest_params;
3944 uint8_t *ciphertext, *plaintext;
3945 unsigned ciphertext_pad_len;
3946 unsigned ciphertext_len;
3948 /* Verify the capabilities */
3949 struct rte_cryptodev_sym_capability_idx cap_idx;
3950 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3951 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3952 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3954 return TEST_SKIPPED;
3956 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3957 return TEST_SKIPPED;
3959 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3960 return TEST_SKIPPED;
3962 /* Create KASUMI session */
3963 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3964 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3965 RTE_CRYPTO_CIPHER_KASUMI_F8,
3966 tdata->key.data, tdata->key.len,
3967 tdata->cipher_iv.len);
3971 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3972 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3974 /* Clear mbuf payload */
3975 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3976 rte_pktmbuf_tailroom(ut_params->ibuf));
3978 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3979 /* Append data which is padded to a multiple */
3980 /* of the algorithms block size */
3981 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3982 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3983 ciphertext_pad_len);
3984 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3985 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3987 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3989 /* Create KASUMI operation */
3990 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3991 tdata->cipher_iv.len,
3992 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3993 tdata->validCipherOffsetInBits.len);
3997 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3999 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4001 ut_params->obuf = ut_params->op->sym->m_dst;
4002 if (ut_params->obuf)
4003 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4005 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4007 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4009 const uint8_t *reference_plaintext = tdata->plaintext.data +
4010 (tdata->validCipherOffsetInBits.len >> 3);
4012 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4014 reference_plaintext,
4015 tdata->validCipherLenInBits.len,
4016 "KASUMI Plaintext data not as expected");
4021 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4023 struct crypto_testsuite_params *ts_params = &testsuite_params;
4024 struct crypto_unittest_params *ut_params = &unittest_params;
4027 uint8_t *ciphertext, *plaintext;
4028 unsigned ciphertext_pad_len;
4029 unsigned ciphertext_len;
4030 struct rte_cryptodev_info dev_info;
4032 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4033 uint64_t feat_flags = dev_info.feature_flags;
4035 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4036 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4037 printf("Device doesn't support RAW data-path APIs.\n");
4038 return TEST_SKIPPED;
4041 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4042 return TEST_SKIPPED;
4044 /* Verify the capabilities */
4045 struct rte_cryptodev_sym_capability_idx cap_idx;
4046 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4047 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4048 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4050 return TEST_SKIPPED;
4052 /* Create KASUMI session */
4053 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4054 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4055 RTE_CRYPTO_CIPHER_KASUMI_F8,
4056 tdata->key.data, tdata->key.len,
4057 tdata->cipher_iv.len);
4061 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4063 /* Clear mbuf payload */
4064 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4065 rte_pktmbuf_tailroom(ut_params->ibuf));
4067 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4068 /* Append data which is padded to a multiple */
4069 /* of the algorithms block size */
4070 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4071 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4072 ciphertext_pad_len);
4073 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4075 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4077 /* Create KASUMI operation */
4078 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4079 tdata->cipher_iv.len,
4080 tdata->ciphertext.len,
4081 tdata->validCipherOffsetInBits.len);
4085 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4086 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4087 ut_params->op, 1, 0, 1, 0);
4089 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4091 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4093 ut_params->obuf = ut_params->op->sym->m_dst;
4094 if (ut_params->obuf)
4095 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4097 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4099 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4101 const uint8_t *reference_plaintext = tdata->plaintext.data +
4102 (tdata->validCipherOffsetInBits.len >> 3);
4104 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4106 reference_plaintext,
4107 tdata->validCipherLenInBits.len,
4108 "KASUMI Plaintext data not as expected");
4113 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4115 struct crypto_testsuite_params *ts_params = &testsuite_params;
4116 struct crypto_unittest_params *ut_params = &unittest_params;
4119 uint8_t *plaintext, *ciphertext;
4120 unsigned plaintext_pad_len;
4121 unsigned plaintext_len;
4122 struct rte_cryptodev_info dev_info;
4124 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4125 uint64_t feat_flags = dev_info.feature_flags;
4127 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4128 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4129 printf("Device doesn't support RAW data-path APIs.\n");
4130 return TEST_SKIPPED;
4133 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4134 return TEST_SKIPPED;
4136 /* Verify the capabilities */
4137 struct rte_cryptodev_sym_capability_idx cap_idx;
4138 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4139 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4140 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4142 return TEST_SKIPPED;
4144 /* Create SNOW 3G session */
4145 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4146 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4147 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4148 tdata->key.data, tdata->key.len,
4149 tdata->cipher_iv.len);
4153 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4155 /* Clear mbuf payload */
4156 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4157 rte_pktmbuf_tailroom(ut_params->ibuf));
4159 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4160 /* Append data which is padded to a multiple of */
4161 /* the algorithms block size */
4162 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4163 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4165 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4167 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4169 /* Create SNOW 3G operation */
4170 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4171 tdata->cipher_iv.len,
4172 tdata->validCipherLenInBits.len,
4177 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4178 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4179 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4181 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4183 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4185 ut_params->obuf = ut_params->op->sym->m_dst;
4186 if (ut_params->obuf)
4187 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4189 ciphertext = plaintext;
4191 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4194 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4196 tdata->ciphertext.data,
4197 tdata->validDataLenInBits.len,
4198 "SNOW 3G Ciphertext data not as expected");
4204 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4206 struct crypto_testsuite_params *ts_params = &testsuite_params;
4207 struct crypto_unittest_params *ut_params = &unittest_params;
4208 uint8_t *plaintext, *ciphertext;
4211 unsigned plaintext_pad_len;
4212 unsigned plaintext_len;
4214 /* Verify the capabilities */
4215 struct rte_cryptodev_sym_capability_idx cap_idx;
4216 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4217 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4218 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4220 return TEST_SKIPPED;
4222 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4223 return TEST_SKIPPED;
4225 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4226 return TEST_SKIPPED;
4228 /* Create SNOW 3G session */
4229 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4230 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4231 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4232 tdata->key.data, tdata->key.len,
4233 tdata->cipher_iv.len);
4237 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4238 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4240 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4241 "Failed to allocate input buffer in mempool");
4242 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4243 "Failed to allocate output buffer in mempool");
4245 /* Clear mbuf payload */
4246 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4247 rte_pktmbuf_tailroom(ut_params->ibuf));
4249 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4250 /* Append data which is padded to a multiple of */
4251 /* the algorithms block size */
4252 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4253 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4255 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4256 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4258 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4260 /* Create SNOW 3G operation */
4261 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4262 tdata->cipher_iv.len,
4263 tdata->validCipherLenInBits.len,
4268 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4270 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4272 ut_params->obuf = ut_params->op->sym->m_dst;
4273 if (ut_params->obuf)
4274 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4276 ciphertext = plaintext;
4278 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4281 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4283 tdata->ciphertext.data,
4284 tdata->validDataLenInBits.len,
4285 "SNOW 3G Ciphertext data not as expected");
4290 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4292 struct crypto_testsuite_params *ts_params = &testsuite_params;
4293 struct crypto_unittest_params *ut_params = &unittest_params;
4296 unsigned int plaintext_pad_len;
4297 unsigned int plaintext_len;
4298 uint8_t buffer[10000];
4299 const uint8_t *ciphertext;
4301 struct rte_cryptodev_info dev_info;
4303 /* Verify the capabilities */
4304 struct rte_cryptodev_sym_capability_idx cap_idx;
4305 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4306 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4307 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4309 return TEST_SKIPPED;
4311 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4312 return TEST_SKIPPED;
4314 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4315 return TEST_SKIPPED;
4317 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4319 uint64_t feat_flags = dev_info.feature_flags;
4321 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4322 printf("Device doesn't support out-of-place scatter-gather "
4323 "in both input and output mbufs. "
4325 return TEST_SKIPPED;
4328 /* Create SNOW 3G session */
4329 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4330 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4331 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4332 tdata->key.data, tdata->key.len,
4333 tdata->cipher_iv.len);
4337 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4338 /* Append data which is padded to a multiple of */
4339 /* the algorithms block size */
4340 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4342 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4343 plaintext_pad_len, 10, 0);
4344 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4345 plaintext_pad_len, 3, 0);
4347 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4348 "Failed to allocate input buffer in mempool");
4349 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4350 "Failed to allocate output buffer in mempool");
4352 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4354 /* Create SNOW 3G operation */
4355 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4356 tdata->cipher_iv.len,
4357 tdata->validCipherLenInBits.len,
4362 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4364 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4366 ut_params->obuf = ut_params->op->sym->m_dst;
4367 if (ut_params->obuf)
4368 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4369 plaintext_len, buffer);
4371 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4372 plaintext_len, buffer);
4374 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4377 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4379 tdata->ciphertext.data,
4380 tdata->validDataLenInBits.len,
4381 "SNOW 3G Ciphertext data not as expected");
4386 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4388 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4390 uint8_t curr_byte, prev_byte;
4391 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4392 uint8_t lower_byte_mask = (1 << offset) - 1;
4395 prev_byte = buffer[0];
4396 buffer[0] >>= offset;
4398 for (i = 1; i < length_in_bytes; i++) {
4399 curr_byte = buffer[i];
4400 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4401 (curr_byte >> offset);
4402 prev_byte = curr_byte;
4407 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4409 struct crypto_testsuite_params *ts_params = &testsuite_params;
4410 struct crypto_unittest_params *ut_params = &unittest_params;
4411 uint8_t *plaintext, *ciphertext;
4413 uint32_t plaintext_len;
4414 uint32_t plaintext_pad_len;
4415 uint8_t extra_offset = 4;
4416 uint8_t *expected_ciphertext_shifted;
4417 struct rte_cryptodev_info dev_info;
4419 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4420 uint64_t feat_flags = dev_info.feature_flags;
4422 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4423 ((tdata->validDataLenInBits.len % 8) != 0)) {
4424 printf("Device doesn't support NON-Byte Aligned Data.\n");
4425 return TEST_SKIPPED;
4428 /* Verify the capabilities */
4429 struct rte_cryptodev_sym_capability_idx cap_idx;
4430 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4431 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4432 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4434 return TEST_SKIPPED;
4436 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4437 return TEST_SKIPPED;
4439 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4440 return TEST_SKIPPED;
4442 /* Create SNOW 3G session */
4443 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4444 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4445 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4446 tdata->key.data, tdata->key.len,
4447 tdata->cipher_iv.len);
4451 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4452 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4454 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4455 "Failed to allocate input buffer in mempool");
4456 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4457 "Failed to allocate output buffer in mempool");
4459 /* Clear mbuf payload */
4460 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4461 rte_pktmbuf_tailroom(ut_params->ibuf));
4463 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4465 * Append data which is padded to a
4466 * multiple of the algorithms block size
4468 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4470 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4473 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4475 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4476 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4478 #ifdef RTE_APP_TEST_DEBUG
4479 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4481 /* Create SNOW 3G operation */
4482 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4483 tdata->cipher_iv.len,
4484 tdata->validCipherLenInBits.len,
4489 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4491 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4493 ut_params->obuf = ut_params->op->sym->m_dst;
4494 if (ut_params->obuf)
4495 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4497 ciphertext = plaintext;
4499 #ifdef RTE_APP_TEST_DEBUG
4500 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4503 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4505 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4506 "failed to reserve memory for ciphertext shifted\n");
4508 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4509 ceil_byte_length(tdata->ciphertext.len));
4510 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4513 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4515 expected_ciphertext_shifted,
4516 tdata->validDataLenInBits.len,
4518 "SNOW 3G Ciphertext data not as expected");
4522 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4524 struct crypto_testsuite_params *ts_params = &testsuite_params;
4525 struct crypto_unittest_params *ut_params = &unittest_params;
4529 uint8_t *plaintext, *ciphertext;
4530 unsigned ciphertext_pad_len;
4531 unsigned ciphertext_len;
4532 struct rte_cryptodev_info dev_info;
4534 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4535 uint64_t feat_flags = dev_info.feature_flags;
4537 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4538 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4539 printf("Device doesn't support RAW data-path APIs.\n");
4540 return TEST_SKIPPED;
4543 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4544 return TEST_SKIPPED;
4546 /* Verify the capabilities */
4547 struct rte_cryptodev_sym_capability_idx cap_idx;
4548 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4549 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4550 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4552 return TEST_SKIPPED;
4554 /* Create SNOW 3G session */
4555 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4556 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4557 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4558 tdata->key.data, tdata->key.len,
4559 tdata->cipher_iv.len);
4563 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4565 /* Clear mbuf payload */
4566 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4567 rte_pktmbuf_tailroom(ut_params->ibuf));
4569 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4570 /* Append data which is padded to a multiple of */
4571 /* the algorithms block size */
4572 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4573 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4574 ciphertext_pad_len);
4575 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4577 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4579 /* Create SNOW 3G operation */
4580 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4581 tdata->cipher_iv.len,
4582 tdata->validCipherLenInBits.len,
4583 tdata->cipher.offset_bits);
4587 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4588 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4589 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4591 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4593 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4594 ut_params->obuf = ut_params->op->sym->m_dst;
4595 if (ut_params->obuf)
4596 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4598 plaintext = ciphertext;
4600 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4603 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4604 tdata->plaintext.data,
4605 tdata->validDataLenInBits.len,
4606 "SNOW 3G Plaintext data not as expected");
4610 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4612 struct crypto_testsuite_params *ts_params = &testsuite_params;
4613 struct crypto_unittest_params *ut_params = &unittest_params;
4617 uint8_t *plaintext, *ciphertext;
4618 unsigned ciphertext_pad_len;
4619 unsigned ciphertext_len;
4621 /* Verify the capabilities */
4622 struct rte_cryptodev_sym_capability_idx cap_idx;
4623 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4624 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4625 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4627 return TEST_SKIPPED;
4629 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4630 return TEST_SKIPPED;
4632 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4633 return TEST_SKIPPED;
4635 /* Create SNOW 3G session */
4636 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4637 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4638 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4639 tdata->key.data, tdata->key.len,
4640 tdata->cipher_iv.len);
4644 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4645 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4647 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4648 "Failed to allocate input buffer");
4649 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4650 "Failed to allocate output buffer");
4652 /* Clear mbuf payload */
4653 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4654 rte_pktmbuf_tailroom(ut_params->ibuf));
4656 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4657 rte_pktmbuf_tailroom(ut_params->obuf));
4659 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4660 /* Append data which is padded to a multiple of */
4661 /* the algorithms block size */
4662 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4663 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4664 ciphertext_pad_len);
4665 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4666 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4668 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4670 /* Create SNOW 3G operation */
4671 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4672 tdata->cipher_iv.len,
4673 tdata->validCipherLenInBits.len,
4678 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4680 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4681 ut_params->obuf = ut_params->op->sym->m_dst;
4682 if (ut_params->obuf)
4683 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4685 plaintext = ciphertext;
4687 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4690 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4691 tdata->plaintext.data,
4692 tdata->validDataLenInBits.len,
4693 "SNOW 3G Plaintext data not as expected");
4698 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4700 struct crypto_testsuite_params *ts_params = &testsuite_params;
4701 struct crypto_unittest_params *ut_params = &unittest_params;
4705 uint8_t *plaintext, *ciphertext;
4706 unsigned int plaintext_pad_len;
4707 unsigned int plaintext_len;
4709 struct rte_cryptodev_info dev_info;
4710 struct rte_cryptodev_sym_capability_idx cap_idx;
4712 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4713 uint64_t feat_flags = dev_info.feature_flags;
4715 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4716 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4717 (tdata->validDataLenInBits.len % 8 != 0))) {
4718 printf("Device doesn't support NON-Byte Aligned Data.\n");
4719 return TEST_SKIPPED;
4722 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4723 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4724 printf("Device doesn't support RAW data-path APIs.\n");
4725 return TEST_SKIPPED;
4728 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4729 return TEST_SKIPPED;
4731 /* Check if device supports ZUC EEA3 */
4732 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4733 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4735 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4737 return TEST_SKIPPED;
4739 /* Check if device supports ZUC EIA3 */
4740 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4741 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4743 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4745 return TEST_SKIPPED;
4747 /* Create ZUC session */
4748 retval = create_zuc_cipher_auth_encrypt_generate_session(
4749 ts_params->valid_devs[0],
4753 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4755 /* clear mbuf payload */
4756 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4757 rte_pktmbuf_tailroom(ut_params->ibuf));
4759 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4760 /* Append data which is padded to a multiple of */
4761 /* the algorithms block size */
4762 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4763 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4765 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4767 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4769 /* Create ZUC operation */
4770 retval = create_zuc_cipher_hash_generate_operation(tdata);
4774 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4775 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4776 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4778 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4780 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4781 ut_params->obuf = ut_params->op->sym->m_src;
4782 if (ut_params->obuf)
4783 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4785 ciphertext = plaintext;
4787 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4789 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4791 tdata->ciphertext.data,
4792 tdata->validDataLenInBits.len,
4793 "ZUC Ciphertext data not as expected");
4795 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4796 + plaintext_pad_len;
4799 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4803 "ZUC Generated auth tag not as expected");
4808 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4810 struct crypto_testsuite_params *ts_params = &testsuite_params;
4811 struct crypto_unittest_params *ut_params = &unittest_params;
4815 uint8_t *plaintext, *ciphertext;
4816 unsigned plaintext_pad_len;
4817 unsigned plaintext_len;
4818 struct rte_cryptodev_info dev_info;
4820 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4821 uint64_t feat_flags = dev_info.feature_flags;
4823 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4824 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4825 printf("Device doesn't support RAW data-path APIs.\n");
4826 return TEST_SKIPPED;
4829 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4830 return TEST_SKIPPED;
4832 /* Verify the capabilities */
4833 struct rte_cryptodev_sym_capability_idx cap_idx;
4834 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4835 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4836 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4838 return TEST_SKIPPED;
4839 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4840 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4841 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4843 return TEST_SKIPPED;
4845 /* Create SNOW 3G session */
4846 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4847 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4848 RTE_CRYPTO_AUTH_OP_GENERATE,
4849 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4850 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4851 tdata->key.data, tdata->key.len,
4852 tdata->auth_iv.len, tdata->digest.len,
4853 tdata->cipher_iv.len);
4856 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4858 /* clear mbuf payload */
4859 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4860 rte_pktmbuf_tailroom(ut_params->ibuf));
4862 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4863 /* Append data which is padded to a multiple of */
4864 /* the algorithms block size */
4865 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4866 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4868 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4870 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4872 /* Create SNOW 3G operation */
4873 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4874 tdata->digest.len, tdata->auth_iv.data,
4876 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4877 tdata->cipher_iv.data, tdata->cipher_iv.len,
4878 tdata->validCipherLenInBits.len,
4880 tdata->validAuthLenInBits.len,
4886 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4887 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4888 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4890 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4892 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4893 ut_params->obuf = ut_params->op->sym->m_src;
4894 if (ut_params->obuf)
4895 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4897 ciphertext = plaintext;
4899 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4901 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4903 tdata->ciphertext.data,
4904 tdata->validDataLenInBits.len,
4905 "SNOW 3G Ciphertext data not as expected");
4907 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4908 + plaintext_pad_len;
4911 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4914 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4915 "SNOW 3G Generated auth tag not as expected");
4920 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4921 uint8_t op_mode, uint8_t verify)
4923 struct crypto_testsuite_params *ts_params = &testsuite_params;
4924 struct crypto_unittest_params *ut_params = &unittest_params;
4928 uint8_t *plaintext = NULL, *ciphertext = NULL;
4929 unsigned int plaintext_pad_len;
4930 unsigned int plaintext_len;
4931 unsigned int ciphertext_pad_len;
4932 unsigned int ciphertext_len;
4934 struct rte_cryptodev_info dev_info;
4936 /* Verify the capabilities */
4937 struct rte_cryptodev_sym_capability_idx cap_idx;
4938 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4939 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4940 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4942 return TEST_SKIPPED;
4943 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4944 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4945 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4947 return TEST_SKIPPED;
4949 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4950 return TEST_SKIPPED;
4952 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4954 uint64_t feat_flags = dev_info.feature_flags;
4956 if (op_mode == OUT_OF_PLACE) {
4957 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4958 printf("Device doesn't support digest encrypted.\n");
4959 return TEST_SKIPPED;
4961 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4962 return TEST_SKIPPED;
4965 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4966 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4967 printf("Device doesn't support RAW data-path APIs.\n");
4968 return TEST_SKIPPED;
4971 /* Create SNOW 3G session */
4972 retval = create_wireless_algo_auth_cipher_session(
4973 ts_params->valid_devs[0],
4974 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4975 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4976 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4977 : RTE_CRYPTO_AUTH_OP_GENERATE),
4978 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4979 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4980 tdata->key.data, tdata->key.len,
4981 tdata->auth_iv.len, tdata->digest.len,
4982 tdata->cipher_iv.len);
4986 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4987 if (op_mode == OUT_OF_PLACE)
4988 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4990 /* clear mbuf payload */
4991 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4992 rte_pktmbuf_tailroom(ut_params->ibuf));
4993 if (op_mode == OUT_OF_PLACE)
4994 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4995 rte_pktmbuf_tailroom(ut_params->obuf));
4997 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4998 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4999 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5000 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5003 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5004 ciphertext_pad_len);
5005 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5006 if (op_mode == OUT_OF_PLACE)
5007 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5008 debug_hexdump(stdout, "ciphertext:", ciphertext,
5011 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5013 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5014 if (op_mode == OUT_OF_PLACE)
5015 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5016 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5019 /* Create SNOW 3G operation */
5020 retval = create_wireless_algo_auth_cipher_operation(
5021 tdata->digest.data, tdata->digest.len,
5022 tdata->cipher_iv.data, tdata->cipher_iv.len,
5023 tdata->auth_iv.data, tdata->auth_iv.len,
5024 (tdata->digest.offset_bytes == 0 ?
5025 (verify ? ciphertext_pad_len : plaintext_pad_len)
5026 : tdata->digest.offset_bytes),
5027 tdata->validCipherLenInBits.len,
5028 tdata->cipher.offset_bits,
5029 tdata->validAuthLenInBits.len,
5030 tdata->auth.offset_bits,
5031 op_mode, 0, verify);
5036 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5037 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5038 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5040 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5043 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5045 ut_params->obuf = (op_mode == IN_PLACE ?
5046 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5049 if (ut_params->obuf)
5050 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5053 plaintext = ciphertext +
5054 (tdata->cipher.offset_bits >> 3);
5056 debug_hexdump(stdout, "plaintext:", plaintext,
5057 (tdata->plaintext.len >> 3) - tdata->digest.len);
5058 debug_hexdump(stdout, "plaintext expected:",
5059 tdata->plaintext.data,
5060 (tdata->plaintext.len >> 3) - tdata->digest.len);
5062 if (ut_params->obuf)
5063 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5066 ciphertext = plaintext;
5068 debug_hexdump(stdout, "ciphertext:", ciphertext,
5070 debug_hexdump(stdout, "ciphertext expected:",
5071 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5073 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5074 + (tdata->digest.offset_bytes == 0 ?
5075 plaintext_pad_len : tdata->digest.offset_bytes);
5077 debug_hexdump(stdout, "digest:", ut_params->digest,
5079 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5085 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5087 tdata->plaintext.data,
5088 (tdata->plaintext.len - tdata->cipher.offset_bits -
5089 (tdata->digest.len << 3)),
5090 tdata->cipher.offset_bits,
5091 "SNOW 3G Plaintext data not as expected");
5093 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5095 tdata->ciphertext.data,
5096 (tdata->validDataLenInBits.len -
5097 tdata->cipher.offset_bits),
5098 tdata->cipher.offset_bits,
5099 "SNOW 3G Ciphertext data not as expected");
5101 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5104 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5105 "SNOW 3G Generated auth tag not as expected");
5111 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5112 uint8_t op_mode, uint8_t verify)
5114 struct crypto_testsuite_params *ts_params = &testsuite_params;
5115 struct crypto_unittest_params *ut_params = &unittest_params;
5119 const uint8_t *plaintext = NULL;
5120 const uint8_t *ciphertext = NULL;
5121 const uint8_t *digest = NULL;
5122 unsigned int plaintext_pad_len;
5123 unsigned int plaintext_len;
5124 unsigned int ciphertext_pad_len;
5125 unsigned int ciphertext_len;
5126 uint8_t buffer[10000];
5127 uint8_t digest_buffer[10000];
5129 struct rte_cryptodev_info dev_info;
5131 /* Verify the capabilities */
5132 struct rte_cryptodev_sym_capability_idx cap_idx;
5133 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5134 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5135 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5137 return TEST_SKIPPED;
5138 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5139 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5140 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5142 return TEST_SKIPPED;
5144 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5145 return TEST_SKIPPED;
5147 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5149 uint64_t feat_flags = dev_info.feature_flags;
5151 if (op_mode == IN_PLACE) {
5152 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5153 printf("Device doesn't support in-place scatter-gather "
5154 "in both input and output mbufs.\n");
5155 return TEST_SKIPPED;
5157 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5158 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5159 printf("Device doesn't support RAW data-path APIs.\n");
5160 return TEST_SKIPPED;
5163 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5164 return TEST_SKIPPED;
5165 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5166 printf("Device doesn't support out-of-place scatter-gather "
5167 "in both input and output mbufs.\n");
5168 return TEST_SKIPPED;
5170 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5171 printf("Device doesn't support digest encrypted.\n");
5172 return TEST_SKIPPED;
5176 /* Create SNOW 3G session */
5177 retval = create_wireless_algo_auth_cipher_session(
5178 ts_params->valid_devs[0],
5179 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5180 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5181 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5182 : RTE_CRYPTO_AUTH_OP_GENERATE),
5183 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5184 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5185 tdata->key.data, tdata->key.len,
5186 tdata->auth_iv.len, tdata->digest.len,
5187 tdata->cipher_iv.len);
5192 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5193 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5194 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5195 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5197 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5198 plaintext_pad_len, 15, 0);
5199 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5200 "Failed to allocate input buffer in mempool");
5202 if (op_mode == OUT_OF_PLACE) {
5203 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5204 plaintext_pad_len, 15, 0);
5205 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5206 "Failed to allocate output buffer in mempool");
5210 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5211 tdata->ciphertext.data);
5212 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5213 ciphertext_len, buffer);
5214 debug_hexdump(stdout, "ciphertext:", ciphertext,
5217 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5218 tdata->plaintext.data);
5219 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5220 plaintext_len, buffer);
5221 debug_hexdump(stdout, "plaintext:", plaintext,
5224 memset(buffer, 0, sizeof(buffer));
5226 /* Create SNOW 3G operation */
5227 retval = create_wireless_algo_auth_cipher_operation(
5228 tdata->digest.data, tdata->digest.len,
5229 tdata->cipher_iv.data, tdata->cipher_iv.len,
5230 tdata->auth_iv.data, tdata->auth_iv.len,
5231 (tdata->digest.offset_bytes == 0 ?
5232 (verify ? ciphertext_pad_len : plaintext_pad_len)
5233 : tdata->digest.offset_bytes),
5234 tdata->validCipherLenInBits.len,
5235 tdata->cipher.offset_bits,
5236 tdata->validAuthLenInBits.len,
5237 tdata->auth.offset_bits,
5238 op_mode, 1, verify);
5243 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5244 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5245 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5247 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5250 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5252 ut_params->obuf = (op_mode == IN_PLACE ?
5253 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5256 if (ut_params->obuf)
5257 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5258 plaintext_len, buffer);
5260 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5261 plaintext_len, buffer);
5263 debug_hexdump(stdout, "plaintext:", plaintext,
5264 (tdata->plaintext.len >> 3) - tdata->digest.len);
5265 debug_hexdump(stdout, "plaintext expected:",
5266 tdata->plaintext.data,
5267 (tdata->plaintext.len >> 3) - tdata->digest.len);
5269 if (ut_params->obuf)
5270 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5271 ciphertext_len, buffer);
5273 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5274 ciphertext_len, buffer);
5276 debug_hexdump(stdout, "ciphertext:", ciphertext,
5278 debug_hexdump(stdout, "ciphertext expected:",
5279 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5281 if (ut_params->obuf)
5282 digest = rte_pktmbuf_read(ut_params->obuf,
5283 (tdata->digest.offset_bytes == 0 ?
5284 plaintext_pad_len : tdata->digest.offset_bytes),
5285 tdata->digest.len, digest_buffer);
5287 digest = rte_pktmbuf_read(ut_params->ibuf,
5288 (tdata->digest.offset_bytes == 0 ?
5289 plaintext_pad_len : tdata->digest.offset_bytes),
5290 tdata->digest.len, digest_buffer);
5292 debug_hexdump(stdout, "digest:", digest,
5294 debug_hexdump(stdout, "digest expected:",
5295 tdata->digest.data, tdata->digest.len);
5300 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5302 tdata->plaintext.data,
5303 (tdata->plaintext.len - tdata->cipher.offset_bits -
5304 (tdata->digest.len << 3)),
5305 tdata->cipher.offset_bits,
5306 "SNOW 3G Plaintext data not as expected");
5308 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5310 tdata->ciphertext.data,
5311 (tdata->validDataLenInBits.len -
5312 tdata->cipher.offset_bits),
5313 tdata->cipher.offset_bits,
5314 "SNOW 3G Ciphertext data not as expected");
5316 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5319 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5320 "SNOW 3G Generated auth tag not as expected");
5326 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5327 uint8_t op_mode, uint8_t verify)
5329 struct crypto_testsuite_params *ts_params = &testsuite_params;
5330 struct crypto_unittest_params *ut_params = &unittest_params;
5334 uint8_t *plaintext = NULL, *ciphertext = NULL;
5335 unsigned int plaintext_pad_len;
5336 unsigned int plaintext_len;
5337 unsigned int ciphertext_pad_len;
5338 unsigned int ciphertext_len;
5340 struct rte_cryptodev_info dev_info;
5342 /* Verify the capabilities */
5343 struct rte_cryptodev_sym_capability_idx cap_idx;
5344 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5345 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5346 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5348 return TEST_SKIPPED;
5349 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5350 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5351 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5353 return TEST_SKIPPED;
5355 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5357 uint64_t feat_flags = dev_info.feature_flags;
5359 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5360 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5361 printf("Device doesn't support RAW data-path APIs.\n");
5362 return TEST_SKIPPED;
5365 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5366 return TEST_SKIPPED;
5368 if (op_mode == OUT_OF_PLACE) {
5369 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5370 return TEST_SKIPPED;
5371 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5372 printf("Device doesn't support digest encrypted.\n");
5373 return TEST_SKIPPED;
5377 /* Create KASUMI session */
5378 retval = create_wireless_algo_auth_cipher_session(
5379 ts_params->valid_devs[0],
5380 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5381 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5382 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5383 : RTE_CRYPTO_AUTH_OP_GENERATE),
5384 RTE_CRYPTO_AUTH_KASUMI_F9,
5385 RTE_CRYPTO_CIPHER_KASUMI_F8,
5386 tdata->key.data, tdata->key.len,
5387 0, tdata->digest.len,
5388 tdata->cipher_iv.len);
5393 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5394 if (op_mode == OUT_OF_PLACE)
5395 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5397 /* clear mbuf payload */
5398 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5399 rte_pktmbuf_tailroom(ut_params->ibuf));
5400 if (op_mode == OUT_OF_PLACE)
5401 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5402 rte_pktmbuf_tailroom(ut_params->obuf));
5404 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5405 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5406 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5407 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5410 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5411 ciphertext_pad_len);
5412 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5413 if (op_mode == OUT_OF_PLACE)
5414 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5415 debug_hexdump(stdout, "ciphertext:", ciphertext,
5418 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5420 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5421 if (op_mode == OUT_OF_PLACE)
5422 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5423 debug_hexdump(stdout, "plaintext:", plaintext,
5427 /* Create KASUMI operation */
5428 retval = create_wireless_algo_auth_cipher_operation(
5429 tdata->digest.data, tdata->digest.len,
5430 tdata->cipher_iv.data, tdata->cipher_iv.len,
5432 (tdata->digest.offset_bytes == 0 ?
5433 (verify ? ciphertext_pad_len : plaintext_pad_len)
5434 : tdata->digest.offset_bytes),
5435 tdata->validCipherLenInBits.len,
5436 tdata->validCipherOffsetInBits.len,
5437 tdata->validAuthLenInBits.len,
5439 op_mode, 0, verify);
5444 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5445 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5446 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5448 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5451 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5453 ut_params->obuf = (op_mode == IN_PLACE ?
5454 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5458 if (ut_params->obuf)
5459 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5462 plaintext = ciphertext;
5464 debug_hexdump(stdout, "plaintext:", plaintext,
5465 (tdata->plaintext.len >> 3) - tdata->digest.len);
5466 debug_hexdump(stdout, "plaintext expected:",
5467 tdata->plaintext.data,
5468 (tdata->plaintext.len >> 3) - tdata->digest.len);
5470 if (ut_params->obuf)
5471 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5474 ciphertext = plaintext;
5476 debug_hexdump(stdout, "ciphertext:", ciphertext,
5478 debug_hexdump(stdout, "ciphertext expected:",
5479 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5481 ut_params->digest = rte_pktmbuf_mtod(
5482 ut_params->obuf, uint8_t *) +
5483 (tdata->digest.offset_bytes == 0 ?
5484 plaintext_pad_len : tdata->digest.offset_bytes);
5486 debug_hexdump(stdout, "digest:", ut_params->digest,
5488 debug_hexdump(stdout, "digest expected:",
5489 tdata->digest.data, tdata->digest.len);
5494 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5496 tdata->plaintext.data,
5497 tdata->plaintext.len >> 3,
5498 "KASUMI Plaintext data not as expected");
5500 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5502 tdata->ciphertext.data,
5503 tdata->ciphertext.len >> 3,
5504 "KASUMI Ciphertext data not as expected");
5506 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5509 DIGEST_BYTE_LENGTH_KASUMI_F9,
5510 "KASUMI Generated auth tag not as expected");
5516 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5517 uint8_t op_mode, uint8_t verify)
5519 struct crypto_testsuite_params *ts_params = &testsuite_params;
5520 struct crypto_unittest_params *ut_params = &unittest_params;
5524 const uint8_t *plaintext = NULL;
5525 const uint8_t *ciphertext = NULL;
5526 const uint8_t *digest = NULL;
5527 unsigned int plaintext_pad_len;
5528 unsigned int plaintext_len;
5529 unsigned int ciphertext_pad_len;
5530 unsigned int ciphertext_len;
5531 uint8_t buffer[10000];
5532 uint8_t digest_buffer[10000];
5534 struct rte_cryptodev_info dev_info;
5536 /* Verify the capabilities */
5537 struct rte_cryptodev_sym_capability_idx cap_idx;
5538 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5539 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5540 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5542 return TEST_SKIPPED;
5543 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5544 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5545 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5547 return TEST_SKIPPED;
5549 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5550 return TEST_SKIPPED;
5552 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5554 uint64_t feat_flags = dev_info.feature_flags;
5556 if (op_mode == IN_PLACE) {
5557 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5558 printf("Device doesn't support in-place scatter-gather "
5559 "in both input and output mbufs.\n");
5560 return TEST_SKIPPED;
5562 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5563 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5564 printf("Device doesn't support RAW data-path APIs.\n");
5565 return TEST_SKIPPED;
5568 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5569 return TEST_SKIPPED;
5570 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5571 printf("Device doesn't support out-of-place scatter-gather "
5572 "in both input and output mbufs.\n");
5573 return TEST_SKIPPED;
5575 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5576 printf("Device doesn't support digest encrypted.\n");
5577 return TEST_SKIPPED;
5581 /* Create KASUMI session */
5582 retval = create_wireless_algo_auth_cipher_session(
5583 ts_params->valid_devs[0],
5584 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5585 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5586 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5587 : RTE_CRYPTO_AUTH_OP_GENERATE),
5588 RTE_CRYPTO_AUTH_KASUMI_F9,
5589 RTE_CRYPTO_CIPHER_KASUMI_F8,
5590 tdata->key.data, tdata->key.len,
5591 0, tdata->digest.len,
5592 tdata->cipher_iv.len);
5597 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5598 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5599 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5600 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5602 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5603 plaintext_pad_len, 15, 0);
5604 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5605 "Failed to allocate input buffer in mempool");
5607 if (op_mode == OUT_OF_PLACE) {
5608 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5609 plaintext_pad_len, 15, 0);
5610 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5611 "Failed to allocate output buffer in mempool");
5615 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5616 tdata->ciphertext.data);
5617 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5618 ciphertext_len, buffer);
5619 debug_hexdump(stdout, "ciphertext:", ciphertext,
5622 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5623 tdata->plaintext.data);
5624 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5625 plaintext_len, buffer);
5626 debug_hexdump(stdout, "plaintext:", plaintext,
5629 memset(buffer, 0, sizeof(buffer));
5631 /* Create KASUMI operation */
5632 retval = create_wireless_algo_auth_cipher_operation(
5633 tdata->digest.data, tdata->digest.len,
5634 tdata->cipher_iv.data, tdata->cipher_iv.len,
5636 (tdata->digest.offset_bytes == 0 ?
5637 (verify ? ciphertext_pad_len : plaintext_pad_len)
5638 : tdata->digest.offset_bytes),
5639 tdata->validCipherLenInBits.len,
5640 tdata->validCipherOffsetInBits.len,
5641 tdata->validAuthLenInBits.len,
5643 op_mode, 1, verify);
5648 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5649 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5650 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5652 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5655 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5657 ut_params->obuf = (op_mode == IN_PLACE ?
5658 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5661 if (ut_params->obuf)
5662 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5663 plaintext_len, buffer);
5665 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5666 plaintext_len, buffer);
5668 debug_hexdump(stdout, "plaintext:", plaintext,
5669 (tdata->plaintext.len >> 3) - tdata->digest.len);
5670 debug_hexdump(stdout, "plaintext expected:",
5671 tdata->plaintext.data,
5672 (tdata->plaintext.len >> 3) - tdata->digest.len);
5674 if (ut_params->obuf)
5675 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5676 ciphertext_len, buffer);
5678 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5679 ciphertext_len, buffer);
5681 debug_hexdump(stdout, "ciphertext:", ciphertext,
5683 debug_hexdump(stdout, "ciphertext expected:",
5684 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5686 if (ut_params->obuf)
5687 digest = rte_pktmbuf_read(ut_params->obuf,
5688 (tdata->digest.offset_bytes == 0 ?
5689 plaintext_pad_len : tdata->digest.offset_bytes),
5690 tdata->digest.len, digest_buffer);
5692 digest = rte_pktmbuf_read(ut_params->ibuf,
5693 (tdata->digest.offset_bytes == 0 ?
5694 plaintext_pad_len : tdata->digest.offset_bytes),
5695 tdata->digest.len, digest_buffer);
5697 debug_hexdump(stdout, "digest:", digest,
5699 debug_hexdump(stdout, "digest expected:",
5700 tdata->digest.data, tdata->digest.len);
5705 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5707 tdata->plaintext.data,
5708 tdata->plaintext.len >> 3,
5709 "KASUMI Plaintext data not as expected");
5711 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5713 tdata->ciphertext.data,
5714 tdata->validDataLenInBits.len,
5715 "KASUMI Ciphertext data not as expected");
5717 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5720 DIGEST_BYTE_LENGTH_KASUMI_F9,
5721 "KASUMI Generated auth tag not as expected");
5727 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5729 struct crypto_testsuite_params *ts_params = &testsuite_params;
5730 struct crypto_unittest_params *ut_params = &unittest_params;
5734 uint8_t *plaintext, *ciphertext;
5735 unsigned plaintext_pad_len;
5736 unsigned plaintext_len;
5737 struct rte_cryptodev_info dev_info;
5739 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5740 uint64_t feat_flags = dev_info.feature_flags;
5742 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5743 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5744 printf("Device doesn't support RAW data-path APIs.\n");
5745 return TEST_SKIPPED;
5748 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5749 return TEST_SKIPPED;
5751 /* Verify the capabilities */
5752 struct rte_cryptodev_sym_capability_idx cap_idx;
5753 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5754 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5755 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5757 return TEST_SKIPPED;
5758 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5759 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5760 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5762 return TEST_SKIPPED;
5764 /* Create KASUMI session */
5765 retval = create_wireless_algo_cipher_auth_session(
5766 ts_params->valid_devs[0],
5767 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5768 RTE_CRYPTO_AUTH_OP_GENERATE,
5769 RTE_CRYPTO_AUTH_KASUMI_F9,
5770 RTE_CRYPTO_CIPHER_KASUMI_F8,
5771 tdata->key.data, tdata->key.len,
5772 0, tdata->digest.len,
5773 tdata->cipher_iv.len);
5777 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5779 /* clear mbuf payload */
5780 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5781 rte_pktmbuf_tailroom(ut_params->ibuf));
5783 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5784 /* Append data which is padded to a multiple of */
5785 /* the algorithms block size */
5786 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5787 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5789 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5791 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5793 /* Create KASUMI operation */
5794 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5795 tdata->digest.len, NULL, 0,
5796 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5797 tdata->cipher_iv.data, tdata->cipher_iv.len,
5798 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5799 tdata->validCipherOffsetInBits.len,
5800 tdata->validAuthLenInBits.len,
5806 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5807 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5808 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5810 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5812 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5814 if (ut_params->op->sym->m_dst)
5815 ut_params->obuf = ut_params->op->sym->m_dst;
5817 ut_params->obuf = ut_params->op->sym->m_src;
5819 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5820 tdata->validCipherOffsetInBits.len >> 3);
5822 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5823 + plaintext_pad_len;
5825 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5826 (tdata->validCipherOffsetInBits.len >> 3);
5828 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5830 reference_ciphertext,
5831 tdata->validCipherLenInBits.len,
5832 "KASUMI Ciphertext data not as expected");
5835 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5838 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5839 "KASUMI Generated auth tag not as expected");
5844 test_zuc_encryption(const struct wireless_test_data *tdata)
5846 struct crypto_testsuite_params *ts_params = &testsuite_params;
5847 struct crypto_unittest_params *ut_params = &unittest_params;
5850 uint8_t *plaintext, *ciphertext;
5851 unsigned plaintext_pad_len;
5852 unsigned plaintext_len;
5853 struct rte_cryptodev_info dev_info;
5855 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5856 uint64_t feat_flags = dev_info.feature_flags;
5858 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5859 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5860 printf("Device doesn't support RAW data-path APIs.\n");
5861 return TEST_SKIPPED;
5864 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5865 return TEST_SKIPPED;
5867 struct rte_cryptodev_sym_capability_idx cap_idx;
5869 /* Check if device supports ZUC EEA3 */
5870 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5871 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5873 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5875 return TEST_SKIPPED;
5877 /* Create ZUC session */
5878 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5879 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5880 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5881 tdata->key.data, tdata->key.len,
5882 tdata->cipher_iv.len);
5886 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5888 /* Clear mbuf payload */
5889 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5890 rte_pktmbuf_tailroom(ut_params->ibuf));
5892 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5893 /* Append data which is padded to a multiple */
5894 /* of the algorithms block size */
5895 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5896 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5898 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5900 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5902 /* Create ZUC operation */
5903 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5904 tdata->cipher_iv.len,
5905 tdata->plaintext.len,
5910 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5911 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5912 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5914 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5916 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5918 ut_params->obuf = ut_params->op->sym->m_dst;
5919 if (ut_params->obuf)
5920 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5922 ciphertext = plaintext;
5924 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5927 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5929 tdata->ciphertext.data,
5930 tdata->validCipherLenInBits.len,
5931 "ZUC Ciphertext data not as expected");
5936 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5938 struct crypto_testsuite_params *ts_params = &testsuite_params;
5939 struct crypto_unittest_params *ut_params = &unittest_params;
5943 unsigned int plaintext_pad_len;
5944 unsigned int plaintext_len;
5945 const uint8_t *ciphertext;
5946 uint8_t ciphertext_buffer[2048];
5947 struct rte_cryptodev_info dev_info;
5949 struct rte_cryptodev_sym_capability_idx cap_idx;
5951 /* Check if device supports ZUC EEA3 */
5952 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5953 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5955 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5957 return TEST_SKIPPED;
5959 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5960 return TEST_SKIPPED;
5962 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5964 uint64_t feat_flags = dev_info.feature_flags;
5966 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5967 printf("Device doesn't support in-place scatter-gather. "
5969 return TEST_SKIPPED;
5972 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5973 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5974 printf("Device doesn't support RAW data-path APIs.\n");
5975 return TEST_SKIPPED;
5978 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5980 /* Append data which is padded to a multiple */
5981 /* of the algorithms block size */
5982 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5984 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5985 plaintext_pad_len, 10, 0);
5987 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5988 tdata->plaintext.data);
5990 /* Create ZUC session */
5991 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5992 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5993 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5994 tdata->key.data, tdata->key.len,
5995 tdata->cipher_iv.len);
5999 /* Clear mbuf payload */
6001 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6003 /* Create ZUC operation */
6004 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6005 tdata->cipher_iv.len, tdata->plaintext.len,
6010 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6011 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6012 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6014 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6016 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6018 ut_params->obuf = ut_params->op->sym->m_dst;
6019 if (ut_params->obuf)
6020 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6021 0, plaintext_len, ciphertext_buffer);
6023 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6024 0, plaintext_len, ciphertext_buffer);
6027 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6030 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6032 tdata->ciphertext.data,
6033 tdata->validCipherLenInBits.len,
6034 "ZUC Ciphertext data not as expected");
6040 test_zuc_authentication(const struct wireless_test_data *tdata)
6042 struct crypto_testsuite_params *ts_params = &testsuite_params;
6043 struct crypto_unittest_params *ut_params = &unittest_params;
6046 unsigned plaintext_pad_len;
6047 unsigned plaintext_len;
6050 struct rte_cryptodev_sym_capability_idx cap_idx;
6051 struct rte_cryptodev_info dev_info;
6053 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6054 uint64_t feat_flags = dev_info.feature_flags;
6056 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6057 (tdata->validAuthLenInBits.len % 8 != 0)) {
6058 printf("Device doesn't support NON-Byte Aligned Data.\n");
6059 return TEST_SKIPPED;
6062 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6063 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6064 printf("Device doesn't support RAW data-path APIs.\n");
6065 return TEST_SKIPPED;
6068 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6069 return TEST_SKIPPED;
6071 /* Check if device supports ZUC EIA3 */
6072 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6073 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6075 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6077 return TEST_SKIPPED;
6079 /* Create ZUC session */
6080 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6081 tdata->key.data, tdata->key.len,
6082 tdata->auth_iv.len, tdata->digest.len,
6083 RTE_CRYPTO_AUTH_OP_GENERATE,
6084 RTE_CRYPTO_AUTH_ZUC_EIA3);
6088 /* alloc mbuf and set payload */
6089 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6091 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6092 rte_pktmbuf_tailroom(ut_params->ibuf));
6094 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6095 /* Append data which is padded to a multiple of */
6096 /* the algorithms block size */
6097 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6098 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6100 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6102 /* Create ZUC operation */
6103 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6104 tdata->auth_iv.data, tdata->auth_iv.len,
6105 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6106 tdata->validAuthLenInBits.len,
6111 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6112 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6113 ut_params->op, 0, 1, 1, 0);
6115 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6117 ut_params->obuf = ut_params->op->sym->m_src;
6118 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6119 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6120 + plaintext_pad_len;
6123 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6127 "ZUC Generated auth tag not as expected");
6133 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6134 uint8_t op_mode, uint8_t verify)
6136 struct crypto_testsuite_params *ts_params = &testsuite_params;
6137 struct crypto_unittest_params *ut_params = &unittest_params;
6141 uint8_t *plaintext = NULL, *ciphertext = NULL;
6142 unsigned int plaintext_pad_len;
6143 unsigned int plaintext_len;
6144 unsigned int ciphertext_pad_len;
6145 unsigned int ciphertext_len;
6147 struct rte_cryptodev_info dev_info;
6148 struct rte_cryptodev_sym_capability_idx cap_idx;
6150 /* Check if device supports ZUC EIA3 */
6151 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6152 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6154 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6156 return TEST_SKIPPED;
6158 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6160 uint64_t feat_flags = dev_info.feature_flags;
6162 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6163 printf("Device doesn't support digest encrypted.\n");
6164 return TEST_SKIPPED;
6166 if (op_mode == IN_PLACE) {
6167 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6168 printf("Device doesn't support in-place scatter-gather "
6169 "in both input and output mbufs.\n");
6170 return TEST_SKIPPED;
6173 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6174 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6175 printf("Device doesn't support RAW data-path APIs.\n");
6176 return TEST_SKIPPED;
6179 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6180 return TEST_SKIPPED;
6181 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6182 printf("Device doesn't support out-of-place scatter-gather "
6183 "in both input and output mbufs.\n");
6184 return TEST_SKIPPED;
6188 /* Create ZUC session */
6189 retval = create_wireless_algo_auth_cipher_session(
6190 ts_params->valid_devs[0],
6191 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6192 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6193 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6194 : RTE_CRYPTO_AUTH_OP_GENERATE),
6195 RTE_CRYPTO_AUTH_ZUC_EIA3,
6196 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6197 tdata->key.data, tdata->key.len,
6198 tdata->auth_iv.len, tdata->digest.len,
6199 tdata->cipher_iv.len);
6204 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6205 if (op_mode == OUT_OF_PLACE)
6206 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6208 /* clear mbuf payload */
6209 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6210 rte_pktmbuf_tailroom(ut_params->ibuf));
6211 if (op_mode == OUT_OF_PLACE)
6212 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6213 rte_pktmbuf_tailroom(ut_params->obuf));
6215 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6216 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6217 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6218 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6221 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6222 ciphertext_pad_len);
6223 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6224 if (op_mode == OUT_OF_PLACE)
6225 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6226 debug_hexdump(stdout, "ciphertext:", ciphertext,
6229 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6231 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6232 if (op_mode == OUT_OF_PLACE)
6233 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6234 debug_hexdump(stdout, "plaintext:", plaintext,
6238 /* Create ZUC operation */
6239 retval = create_wireless_algo_auth_cipher_operation(
6240 tdata->digest.data, tdata->digest.len,
6241 tdata->cipher_iv.data, tdata->cipher_iv.len,
6242 tdata->auth_iv.data, tdata->auth_iv.len,
6243 (tdata->digest.offset_bytes == 0 ?
6244 (verify ? ciphertext_pad_len : plaintext_pad_len)
6245 : tdata->digest.offset_bytes),
6246 tdata->validCipherLenInBits.len,
6247 tdata->validCipherOffsetInBits.len,
6248 tdata->validAuthLenInBits.len,
6250 op_mode, 0, verify);
6255 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6256 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6257 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6259 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6262 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6264 ut_params->obuf = (op_mode == IN_PLACE ?
6265 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6269 if (ut_params->obuf)
6270 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6273 plaintext = ciphertext;
6275 debug_hexdump(stdout, "plaintext:", plaintext,
6276 (tdata->plaintext.len >> 3) - tdata->digest.len);
6277 debug_hexdump(stdout, "plaintext expected:",
6278 tdata->plaintext.data,
6279 (tdata->plaintext.len >> 3) - tdata->digest.len);
6281 if (ut_params->obuf)
6282 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6285 ciphertext = plaintext;
6287 debug_hexdump(stdout, "ciphertext:", ciphertext,
6289 debug_hexdump(stdout, "ciphertext expected:",
6290 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6292 ut_params->digest = rte_pktmbuf_mtod(
6293 ut_params->obuf, uint8_t *) +
6294 (tdata->digest.offset_bytes == 0 ?
6295 plaintext_pad_len : tdata->digest.offset_bytes);
6297 debug_hexdump(stdout, "digest:", ut_params->digest,
6299 debug_hexdump(stdout, "digest expected:",
6300 tdata->digest.data, tdata->digest.len);
6305 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6307 tdata->plaintext.data,
6308 tdata->plaintext.len >> 3,
6309 "ZUC Plaintext data not as expected");
6311 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6313 tdata->ciphertext.data,
6314 tdata->ciphertext.len >> 3,
6315 "ZUC Ciphertext data not as expected");
6317 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6320 DIGEST_BYTE_LENGTH_KASUMI_F9,
6321 "ZUC Generated auth tag not as expected");
6327 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6328 uint8_t op_mode, uint8_t verify)
6330 struct crypto_testsuite_params *ts_params = &testsuite_params;
6331 struct crypto_unittest_params *ut_params = &unittest_params;
6335 const uint8_t *plaintext = NULL;
6336 const uint8_t *ciphertext = NULL;
6337 const uint8_t *digest = NULL;
6338 unsigned int plaintext_pad_len;
6339 unsigned int plaintext_len;
6340 unsigned int ciphertext_pad_len;
6341 unsigned int ciphertext_len;
6342 uint8_t buffer[10000];
6343 uint8_t digest_buffer[10000];
6345 struct rte_cryptodev_info dev_info;
6346 struct rte_cryptodev_sym_capability_idx cap_idx;
6348 /* Check if device supports ZUC EIA3 */
6349 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6350 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6352 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6354 return TEST_SKIPPED;
6356 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6358 uint64_t feat_flags = dev_info.feature_flags;
6360 if (op_mode == IN_PLACE) {
6361 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6362 printf("Device doesn't support in-place scatter-gather "
6363 "in both input and output mbufs.\n");
6364 return TEST_SKIPPED;
6367 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6368 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6369 printf("Device doesn't support RAW data-path APIs.\n");
6370 return TEST_SKIPPED;
6373 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6374 return TEST_SKIPPED;
6375 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6376 printf("Device doesn't support out-of-place scatter-gather "
6377 "in both input and output mbufs.\n");
6378 return TEST_SKIPPED;
6380 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6381 printf("Device doesn't support digest encrypted.\n");
6382 return TEST_SKIPPED;
6386 /* Create ZUC session */
6387 retval = create_wireless_algo_auth_cipher_session(
6388 ts_params->valid_devs[0],
6389 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6390 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6391 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6392 : RTE_CRYPTO_AUTH_OP_GENERATE),
6393 RTE_CRYPTO_AUTH_ZUC_EIA3,
6394 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6395 tdata->key.data, tdata->key.len,
6396 tdata->auth_iv.len, tdata->digest.len,
6397 tdata->cipher_iv.len);
6402 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6403 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6404 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6405 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6407 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6408 plaintext_pad_len, 15, 0);
6409 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6410 "Failed to allocate input buffer in mempool");
6412 if (op_mode == OUT_OF_PLACE) {
6413 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6414 plaintext_pad_len, 15, 0);
6415 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6416 "Failed to allocate output buffer in mempool");
6420 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6421 tdata->ciphertext.data);
6422 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6423 ciphertext_len, buffer);
6424 debug_hexdump(stdout, "ciphertext:", ciphertext,
6427 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6428 tdata->plaintext.data);
6429 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6430 plaintext_len, buffer);
6431 debug_hexdump(stdout, "plaintext:", plaintext,
6434 memset(buffer, 0, sizeof(buffer));
6436 /* Create ZUC operation */
6437 retval = create_wireless_algo_auth_cipher_operation(
6438 tdata->digest.data, tdata->digest.len,
6439 tdata->cipher_iv.data, tdata->cipher_iv.len,
6441 (tdata->digest.offset_bytes == 0 ?
6442 (verify ? ciphertext_pad_len : plaintext_pad_len)
6443 : tdata->digest.offset_bytes),
6444 tdata->validCipherLenInBits.len,
6445 tdata->validCipherOffsetInBits.len,
6446 tdata->validAuthLenInBits.len,
6448 op_mode, 1, verify);
6453 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6454 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6455 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6457 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6460 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6462 ut_params->obuf = (op_mode == IN_PLACE ?
6463 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6466 if (ut_params->obuf)
6467 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6468 plaintext_len, buffer);
6470 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6471 plaintext_len, buffer);
6473 debug_hexdump(stdout, "plaintext:", plaintext,
6474 (tdata->plaintext.len >> 3) - tdata->digest.len);
6475 debug_hexdump(stdout, "plaintext expected:",
6476 tdata->plaintext.data,
6477 (tdata->plaintext.len >> 3) - tdata->digest.len);
6479 if (ut_params->obuf)
6480 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6481 ciphertext_len, buffer);
6483 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6484 ciphertext_len, buffer);
6486 debug_hexdump(stdout, "ciphertext:", ciphertext,
6488 debug_hexdump(stdout, "ciphertext expected:",
6489 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6491 if (ut_params->obuf)
6492 digest = rte_pktmbuf_read(ut_params->obuf,
6493 (tdata->digest.offset_bytes == 0 ?
6494 plaintext_pad_len : tdata->digest.offset_bytes),
6495 tdata->digest.len, digest_buffer);
6497 digest = rte_pktmbuf_read(ut_params->ibuf,
6498 (tdata->digest.offset_bytes == 0 ?
6499 plaintext_pad_len : tdata->digest.offset_bytes),
6500 tdata->digest.len, digest_buffer);
6502 debug_hexdump(stdout, "digest:", digest,
6504 debug_hexdump(stdout, "digest expected:",
6505 tdata->digest.data, tdata->digest.len);
6510 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6512 tdata->plaintext.data,
6513 tdata->plaintext.len >> 3,
6514 "ZUC Plaintext data not as expected");
6516 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6518 tdata->ciphertext.data,
6519 tdata->validDataLenInBits.len,
6520 "ZUC Ciphertext data not as expected");
6522 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6525 DIGEST_BYTE_LENGTH_KASUMI_F9,
6526 "ZUC Generated auth tag not as expected");
6532 test_kasumi_encryption_test_case_1(void)
6534 return test_kasumi_encryption(&kasumi_test_case_1);
6538 test_kasumi_encryption_test_case_1_sgl(void)
6540 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6544 test_kasumi_encryption_test_case_1_oop(void)
6546 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6550 test_kasumi_encryption_test_case_1_oop_sgl(void)
6552 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6556 test_kasumi_encryption_test_case_2(void)
6558 return test_kasumi_encryption(&kasumi_test_case_2);
6562 test_kasumi_encryption_test_case_3(void)
6564 return test_kasumi_encryption(&kasumi_test_case_3);
6568 test_kasumi_encryption_test_case_4(void)
6570 return test_kasumi_encryption(&kasumi_test_case_4);
6574 test_kasumi_encryption_test_case_5(void)
6576 return test_kasumi_encryption(&kasumi_test_case_5);
6580 test_kasumi_decryption_test_case_1(void)
6582 return test_kasumi_decryption(&kasumi_test_case_1);
6586 test_kasumi_decryption_test_case_1_oop(void)
6588 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6592 test_kasumi_decryption_test_case_2(void)
6594 return test_kasumi_decryption(&kasumi_test_case_2);
6598 test_kasumi_decryption_test_case_3(void)
6600 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6601 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6602 return TEST_SKIPPED;
6603 return test_kasumi_decryption(&kasumi_test_case_3);
6607 test_kasumi_decryption_test_case_4(void)
6609 return test_kasumi_decryption(&kasumi_test_case_4);
6613 test_kasumi_decryption_test_case_5(void)
6615 return test_kasumi_decryption(&kasumi_test_case_5);
6618 test_snow3g_encryption_test_case_1(void)
6620 return test_snow3g_encryption(&snow3g_test_case_1);
6624 test_snow3g_encryption_test_case_1_oop(void)
6626 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6630 test_snow3g_encryption_test_case_1_oop_sgl(void)
6632 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6637 test_snow3g_encryption_test_case_1_offset_oop(void)
6639 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6643 test_snow3g_encryption_test_case_2(void)
6645 return test_snow3g_encryption(&snow3g_test_case_2);
6649 test_snow3g_encryption_test_case_3(void)
6651 return test_snow3g_encryption(&snow3g_test_case_3);
6655 test_snow3g_encryption_test_case_4(void)
6657 return test_snow3g_encryption(&snow3g_test_case_4);
6661 test_snow3g_encryption_test_case_5(void)
6663 return test_snow3g_encryption(&snow3g_test_case_5);
6667 test_snow3g_decryption_test_case_1(void)
6669 return test_snow3g_decryption(&snow3g_test_case_1);
6673 test_snow3g_decryption_test_case_1_oop(void)
6675 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6679 test_snow3g_decryption_test_case_2(void)
6681 return test_snow3g_decryption(&snow3g_test_case_2);
6685 test_snow3g_decryption_test_case_3(void)
6687 return test_snow3g_decryption(&snow3g_test_case_3);
6691 test_snow3g_decryption_test_case_4(void)
6693 return test_snow3g_decryption(&snow3g_test_case_4);
6697 test_snow3g_decryption_test_case_5(void)
6699 return test_snow3g_decryption(&snow3g_test_case_5);
6703 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6704 * Pattern digest from snow3g_test_data must be allocated as
6705 * 4 last bytes in plaintext.
6708 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6709 struct snow3g_hash_test_data *output)
6711 if ((pattern != NULL) && (output != NULL)) {
6712 output->key.len = pattern->key.len;
6714 memcpy(output->key.data,
6715 pattern->key.data, pattern->key.len);
6717 output->auth_iv.len = pattern->auth_iv.len;
6719 memcpy(output->auth_iv.data,
6720 pattern->auth_iv.data, pattern->auth_iv.len);
6722 output->plaintext.len = pattern->plaintext.len;
6724 memcpy(output->plaintext.data,
6725 pattern->plaintext.data, pattern->plaintext.len >> 3);
6727 output->digest.len = pattern->digest.len;
6729 memcpy(output->digest.data,
6730 &pattern->plaintext.data[pattern->digest.offset_bytes],
6731 pattern->digest.len);
6733 output->validAuthLenInBits.len =
6734 pattern->validAuthLenInBits.len;
6739 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6742 test_snow3g_decryption_with_digest_test_case_1(void)
6744 struct snow3g_hash_test_data snow3g_hash_data;
6745 struct rte_cryptodev_info dev_info;
6746 struct crypto_testsuite_params *ts_params = &testsuite_params;
6748 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6749 uint64_t feat_flags = dev_info.feature_flags;
6751 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6752 printf("Device doesn't support encrypted digest operations.\n");
6753 return TEST_SKIPPED;
6757 * Function prepare data for hash veryfication test case.
6758 * Digest is allocated in 4 last bytes in plaintext, pattern.
6760 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6762 return test_snow3g_decryption(&snow3g_test_case_7) &
6763 test_snow3g_authentication_verify(&snow3g_hash_data);
6767 test_snow3g_cipher_auth_test_case_1(void)
6769 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6773 test_snow3g_auth_cipher_test_case_1(void)
6775 return test_snow3g_auth_cipher(
6776 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6780 test_snow3g_auth_cipher_test_case_2(void)
6782 return test_snow3g_auth_cipher(
6783 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6787 test_snow3g_auth_cipher_test_case_2_oop(void)
6789 return test_snow3g_auth_cipher(
6790 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6794 test_snow3g_auth_cipher_part_digest_enc(void)
6796 return test_snow3g_auth_cipher(
6797 &snow3g_auth_cipher_partial_digest_encryption,
6802 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6804 return test_snow3g_auth_cipher(
6805 &snow3g_auth_cipher_partial_digest_encryption,
6810 test_snow3g_auth_cipher_test_case_3_sgl(void)
6812 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6813 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6814 return TEST_SKIPPED;
6815 return test_snow3g_auth_cipher_sgl(
6816 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6820 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6822 return test_snow3g_auth_cipher_sgl(
6823 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6827 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6829 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6830 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6831 return TEST_SKIPPED;
6832 return test_snow3g_auth_cipher_sgl(
6833 &snow3g_auth_cipher_partial_digest_encryption,
6838 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6840 return test_snow3g_auth_cipher_sgl(
6841 &snow3g_auth_cipher_partial_digest_encryption,
6846 test_snow3g_auth_cipher_verify_test_case_1(void)
6848 return test_snow3g_auth_cipher(
6849 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6853 test_snow3g_auth_cipher_verify_test_case_2(void)
6855 return test_snow3g_auth_cipher(
6856 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6860 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6862 return test_snow3g_auth_cipher(
6863 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6867 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6869 return test_snow3g_auth_cipher(
6870 &snow3g_auth_cipher_partial_digest_encryption,
6875 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6877 return test_snow3g_auth_cipher(
6878 &snow3g_auth_cipher_partial_digest_encryption,
6883 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6885 return test_snow3g_auth_cipher_sgl(
6886 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6890 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6892 return test_snow3g_auth_cipher_sgl(
6893 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6897 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6899 return test_snow3g_auth_cipher_sgl(
6900 &snow3g_auth_cipher_partial_digest_encryption,
6905 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6907 return test_snow3g_auth_cipher_sgl(
6908 &snow3g_auth_cipher_partial_digest_encryption,
6913 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6915 return test_snow3g_auth_cipher(
6916 &snow3g_test_case_7, IN_PLACE, 0);
6920 test_kasumi_auth_cipher_test_case_1(void)
6922 return test_kasumi_auth_cipher(
6923 &kasumi_test_case_3, IN_PLACE, 0);
6927 test_kasumi_auth_cipher_test_case_2(void)
6929 return test_kasumi_auth_cipher(
6930 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6934 test_kasumi_auth_cipher_test_case_2_oop(void)
6936 return test_kasumi_auth_cipher(
6937 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6941 test_kasumi_auth_cipher_test_case_2_sgl(void)
6943 return test_kasumi_auth_cipher_sgl(
6944 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6948 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6950 return test_kasumi_auth_cipher_sgl(
6951 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6955 test_kasumi_auth_cipher_verify_test_case_1(void)
6957 return test_kasumi_auth_cipher(
6958 &kasumi_test_case_3, IN_PLACE, 1);
6962 test_kasumi_auth_cipher_verify_test_case_2(void)
6964 return test_kasumi_auth_cipher(
6965 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6969 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6971 return test_kasumi_auth_cipher(
6972 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6976 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6978 return test_kasumi_auth_cipher_sgl(
6979 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6983 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6985 return test_kasumi_auth_cipher_sgl(
6986 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6990 test_kasumi_cipher_auth_test_case_1(void)
6992 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6996 test_zuc_encryption_test_case_1(void)
6998 return test_zuc_encryption(&zuc_test_case_cipher_193b);
7002 test_zuc_encryption_test_case_2(void)
7004 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7008 test_zuc_encryption_test_case_3(void)
7010 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7014 test_zuc_encryption_test_case_4(void)
7016 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7020 test_zuc_encryption_test_case_5(void)
7022 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7026 test_zuc_encryption_test_case_6_sgl(void)
7028 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7032 test_zuc_encryption_test_case_7(void)
7034 return test_zuc_encryption(&zuc_test_case_cipher_800b_key_256b);
7038 test_zuc_hash_generate_test_case_1(void)
7040 return test_zuc_authentication(&zuc_test_case_auth_1b);
7044 test_zuc_hash_generate_test_case_2(void)
7046 return test_zuc_authentication(&zuc_test_case_auth_90b);
7050 test_zuc_hash_generate_test_case_3(void)
7052 return test_zuc_authentication(&zuc_test_case_auth_577b);
7056 test_zuc_hash_generate_test_case_4(void)
7058 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7062 test_zuc_hash_generate_test_case_5(void)
7064 return test_zuc_authentication(&zuc_test_auth_5670b);
7068 test_zuc_hash_generate_test_case_6(void)
7070 return test_zuc_authentication(&zuc_test_case_auth_128b);
7074 test_zuc_hash_generate_test_case_7(void)
7076 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7080 test_zuc_hash_generate_test_case_8(void)
7082 return test_zuc_authentication(&zuc_test_case_auth_584b);
7086 test_zuc_hash_generate_test_case_9(void)
7088 return test_zuc_authentication(&zuc_test_case_auth_584b_mac_64b);
7092 test_zuc_hash_generate_test_case_10(void)
7094 return test_zuc_authentication(&zuc_test_case_auth_2080b_mac_128b);
7098 test_zuc_cipher_auth_test_case_1(void)
7100 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7104 test_zuc_cipher_auth_test_case_2(void)
7106 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7110 test_zuc_auth_cipher_test_case_1(void)
7112 return test_zuc_auth_cipher(
7113 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7117 test_zuc_auth_cipher_test_case_1_oop(void)
7119 return test_zuc_auth_cipher(
7120 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7124 test_zuc_auth_cipher_test_case_1_sgl(void)
7126 return test_zuc_auth_cipher_sgl(
7127 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7131 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7133 return test_zuc_auth_cipher_sgl(
7134 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7138 test_zuc_auth_cipher_verify_test_case_1(void)
7140 return test_zuc_auth_cipher(
7141 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7145 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7147 return test_zuc_auth_cipher(
7148 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7152 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7154 return test_zuc_auth_cipher_sgl(
7155 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7159 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7161 return test_zuc_auth_cipher_sgl(
7162 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7166 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7168 uint8_t dev_id = testsuite_params.valid_devs[0];
7170 struct rte_cryptodev_sym_capability_idx cap_idx;
7172 /* Check if device supports particular cipher algorithm */
7173 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7174 cap_idx.algo.cipher = tdata->cipher_algo;
7175 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7176 return TEST_SKIPPED;
7178 /* Check if device supports particular hash algorithm */
7179 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7180 cap_idx.algo.auth = tdata->auth_algo;
7181 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7182 return TEST_SKIPPED;
7188 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7189 uint8_t op_mode, uint8_t verify)
7191 struct crypto_testsuite_params *ts_params = &testsuite_params;
7192 struct crypto_unittest_params *ut_params = &unittest_params;
7196 uint8_t *plaintext = NULL, *ciphertext = NULL;
7197 unsigned int plaintext_pad_len;
7198 unsigned int plaintext_len;
7199 unsigned int ciphertext_pad_len;
7200 unsigned int ciphertext_len;
7202 struct rte_cryptodev_info dev_info;
7203 struct rte_crypto_op *op;
7205 /* Check if device supports particular algorithms separately */
7206 if (test_mixed_check_if_unsupported(tdata))
7207 return TEST_SKIPPED;
7208 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7209 return TEST_SKIPPED;
7211 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7213 uint64_t feat_flags = dev_info.feature_flags;
7215 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7216 printf("Device doesn't support digest encrypted.\n");
7217 return TEST_SKIPPED;
7220 /* Create the session */
7222 retval = create_wireless_algo_cipher_auth_session(
7223 ts_params->valid_devs[0],
7224 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7225 RTE_CRYPTO_AUTH_OP_VERIFY,
7228 tdata->auth_key.data, tdata->auth_key.len,
7229 tdata->auth_iv.len, tdata->digest_enc.len,
7230 tdata->cipher_iv.len);
7232 retval = create_wireless_algo_auth_cipher_session(
7233 ts_params->valid_devs[0],
7234 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7235 RTE_CRYPTO_AUTH_OP_GENERATE,
7238 tdata->auth_key.data, tdata->auth_key.len,
7239 tdata->auth_iv.len, tdata->digest_enc.len,
7240 tdata->cipher_iv.len);
7244 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7245 if (op_mode == OUT_OF_PLACE)
7246 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7248 /* clear mbuf payload */
7249 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7250 rte_pktmbuf_tailroom(ut_params->ibuf));
7251 if (op_mode == OUT_OF_PLACE) {
7253 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7254 rte_pktmbuf_tailroom(ut_params->obuf));
7257 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7258 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7259 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7260 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7263 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7264 ciphertext_pad_len);
7265 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7266 if (op_mode == OUT_OF_PLACE)
7267 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7268 debug_hexdump(stdout, "ciphertext:", ciphertext,
7271 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7273 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7274 if (op_mode == OUT_OF_PLACE)
7275 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7276 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7279 /* Create the operation */
7280 retval = create_wireless_algo_auth_cipher_operation(
7281 tdata->digest_enc.data, tdata->digest_enc.len,
7282 tdata->cipher_iv.data, tdata->cipher_iv.len,
7283 tdata->auth_iv.data, tdata->auth_iv.len,
7284 (tdata->digest_enc.offset == 0 ?
7286 : tdata->digest_enc.offset),
7287 tdata->validCipherLen.len_bits,
7288 tdata->cipher.offset_bits,
7289 tdata->validAuthLen.len_bits,
7290 tdata->auth.offset_bits,
7291 op_mode, 0, verify);
7296 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7298 /* Check if the op failed because the device doesn't */
7299 /* support this particular combination of algorithms */
7300 if (op == NULL && ut_params->op->status ==
7301 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7302 printf("Device doesn't support this mixed combination. "
7304 return TEST_SKIPPED;
7308 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7310 ut_params->obuf = (op_mode == IN_PLACE ?
7311 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7314 if (ut_params->obuf)
7315 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7318 plaintext = ciphertext +
7319 (tdata->cipher.offset_bits >> 3);
7321 debug_hexdump(stdout, "plaintext:", plaintext,
7322 tdata->plaintext.len_bits >> 3);
7323 debug_hexdump(stdout, "plaintext expected:",
7324 tdata->plaintext.data,
7325 tdata->plaintext.len_bits >> 3);
7327 if (ut_params->obuf)
7328 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7331 ciphertext = plaintext;
7333 debug_hexdump(stdout, "ciphertext:", ciphertext,
7335 debug_hexdump(stdout, "ciphertext expected:",
7336 tdata->ciphertext.data,
7337 tdata->ciphertext.len_bits >> 3);
7339 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7340 + (tdata->digest_enc.offset == 0 ?
7341 plaintext_pad_len : tdata->digest_enc.offset);
7343 debug_hexdump(stdout, "digest:", ut_params->digest,
7344 tdata->digest_enc.len);
7345 debug_hexdump(stdout, "digest expected:",
7346 tdata->digest_enc.data,
7347 tdata->digest_enc.len);
7352 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7354 tdata->plaintext.data,
7355 tdata->plaintext.len_bits >> 3,
7356 "Plaintext data not as expected");
7358 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7360 tdata->ciphertext.data,
7361 tdata->validDataLen.len_bits,
7362 "Ciphertext data not as expected");
7364 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7366 tdata->digest_enc.data,
7367 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7368 "Generated auth tag not as expected");
7371 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7372 "crypto op processing failed");
7378 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7379 uint8_t op_mode, uint8_t verify)
7381 struct crypto_testsuite_params *ts_params = &testsuite_params;
7382 struct crypto_unittest_params *ut_params = &unittest_params;
7386 const uint8_t *plaintext = NULL;
7387 const uint8_t *ciphertext = NULL;
7388 const uint8_t *digest = NULL;
7389 unsigned int plaintext_pad_len;
7390 unsigned int plaintext_len;
7391 unsigned int ciphertext_pad_len;
7392 unsigned int ciphertext_len;
7393 uint8_t buffer[10000];
7394 uint8_t digest_buffer[10000];
7396 struct rte_cryptodev_info dev_info;
7397 struct rte_crypto_op *op;
7399 /* Check if device supports particular algorithms */
7400 if (test_mixed_check_if_unsupported(tdata))
7401 return TEST_SKIPPED;
7402 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7403 return TEST_SKIPPED;
7405 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7407 uint64_t feat_flags = dev_info.feature_flags;
7409 if (op_mode == IN_PLACE) {
7410 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7411 printf("Device doesn't support in-place scatter-gather "
7412 "in both input and output mbufs.\n");
7413 return TEST_SKIPPED;
7416 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7417 printf("Device doesn't support out-of-place scatter-gather "
7418 "in both input and output mbufs.\n");
7419 return TEST_SKIPPED;
7421 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7422 printf("Device doesn't support digest encrypted.\n");
7423 return TEST_SKIPPED;
7427 /* Create the session */
7429 retval = create_wireless_algo_cipher_auth_session(
7430 ts_params->valid_devs[0],
7431 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7432 RTE_CRYPTO_AUTH_OP_VERIFY,
7435 tdata->auth_key.data, tdata->auth_key.len,
7436 tdata->auth_iv.len, tdata->digest_enc.len,
7437 tdata->cipher_iv.len);
7439 retval = create_wireless_algo_auth_cipher_session(
7440 ts_params->valid_devs[0],
7441 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7442 RTE_CRYPTO_AUTH_OP_GENERATE,
7445 tdata->auth_key.data, tdata->auth_key.len,
7446 tdata->auth_iv.len, tdata->digest_enc.len,
7447 tdata->cipher_iv.len);
7451 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7452 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7453 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7454 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7456 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7457 ciphertext_pad_len, 15, 0);
7458 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7459 "Failed to allocate input buffer in mempool");
7461 if (op_mode == OUT_OF_PLACE) {
7462 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7463 plaintext_pad_len, 15, 0);
7464 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7465 "Failed to allocate output buffer in mempool");
7469 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7470 tdata->ciphertext.data);
7471 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7472 ciphertext_len, buffer);
7473 debug_hexdump(stdout, "ciphertext:", ciphertext,
7476 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7477 tdata->plaintext.data);
7478 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7479 plaintext_len, buffer);
7480 debug_hexdump(stdout, "plaintext:", plaintext,
7483 memset(buffer, 0, sizeof(buffer));
7485 /* Create the operation */
7486 retval = create_wireless_algo_auth_cipher_operation(
7487 tdata->digest_enc.data, tdata->digest_enc.len,
7488 tdata->cipher_iv.data, tdata->cipher_iv.len,
7489 tdata->auth_iv.data, tdata->auth_iv.len,
7490 (tdata->digest_enc.offset == 0 ?
7492 : tdata->digest_enc.offset),
7493 tdata->validCipherLen.len_bits,
7494 tdata->cipher.offset_bits,
7495 tdata->validAuthLen.len_bits,
7496 tdata->auth.offset_bits,
7497 op_mode, 1, verify);
7502 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7504 /* Check if the op failed because the device doesn't */
7505 /* support this particular combination of algorithms */
7506 if (op == NULL && ut_params->op->status ==
7507 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7508 printf("Device doesn't support this mixed combination. "
7510 return TEST_SKIPPED;
7514 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7516 ut_params->obuf = (op_mode == IN_PLACE ?
7517 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7520 if (ut_params->obuf)
7521 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7522 plaintext_len, buffer);
7524 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7525 plaintext_len, buffer);
7527 debug_hexdump(stdout, "plaintext:", plaintext,
7528 (tdata->plaintext.len_bits >> 3) -
7529 tdata->digest_enc.len);
7530 debug_hexdump(stdout, "plaintext expected:",
7531 tdata->plaintext.data,
7532 (tdata->plaintext.len_bits >> 3) -
7533 tdata->digest_enc.len);
7535 if (ut_params->obuf)
7536 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7537 ciphertext_len, buffer);
7539 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7540 ciphertext_len, buffer);
7542 debug_hexdump(stdout, "ciphertext:", ciphertext,
7544 debug_hexdump(stdout, "ciphertext expected:",
7545 tdata->ciphertext.data,
7546 tdata->ciphertext.len_bits >> 3);
7548 if (ut_params->obuf)
7549 digest = rte_pktmbuf_read(ut_params->obuf,
7550 (tdata->digest_enc.offset == 0 ?
7552 tdata->digest_enc.offset),
7553 tdata->digest_enc.len, digest_buffer);
7555 digest = rte_pktmbuf_read(ut_params->ibuf,
7556 (tdata->digest_enc.offset == 0 ?
7558 tdata->digest_enc.offset),
7559 tdata->digest_enc.len, digest_buffer);
7561 debug_hexdump(stdout, "digest:", digest,
7562 tdata->digest_enc.len);
7563 debug_hexdump(stdout, "digest expected:",
7564 tdata->digest_enc.data, tdata->digest_enc.len);
7569 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7571 tdata->plaintext.data,
7572 tdata->plaintext.len_bits >> 3,
7573 "Plaintext data not as expected");
7575 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7577 tdata->ciphertext.data,
7578 tdata->validDataLen.len_bits,
7579 "Ciphertext data not as expected");
7580 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7582 tdata->digest_enc.data,
7583 tdata->digest_enc.len,
7584 "Generated auth tag not as expected");
7587 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7588 "crypto op processing failed");
7593 /** AUTH AES CMAC + CIPHER AES CTR */
7596 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7598 return test_mixed_auth_cipher(
7599 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7603 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7605 return test_mixed_auth_cipher(
7606 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7610 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7612 return test_mixed_auth_cipher_sgl(
7613 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7617 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7619 return test_mixed_auth_cipher_sgl(
7620 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7624 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7626 return test_mixed_auth_cipher(
7627 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7631 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7633 return test_mixed_auth_cipher(
7634 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7638 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7640 return test_mixed_auth_cipher_sgl(
7641 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7645 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7647 return test_mixed_auth_cipher_sgl(
7648 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7651 /** MIXED AUTH + CIPHER */
7654 test_auth_zuc_cipher_snow_test_case_1(void)
7656 return test_mixed_auth_cipher(
7657 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7661 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7663 return test_mixed_auth_cipher(
7664 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7668 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7670 return test_mixed_auth_cipher(
7671 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7675 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7677 return test_mixed_auth_cipher(
7678 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7682 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7684 return test_mixed_auth_cipher(
7685 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7689 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7691 return test_mixed_auth_cipher(
7692 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7696 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7698 return test_mixed_auth_cipher(
7699 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7703 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7705 return test_mixed_auth_cipher(
7706 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7710 test_auth_snow_cipher_zuc_test_case_1(void)
7712 return test_mixed_auth_cipher(
7713 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7717 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7719 return test_mixed_auth_cipher(
7720 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7724 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7726 return test_mixed_auth_cipher(
7727 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7731 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7733 return test_mixed_auth_cipher(
7734 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7738 test_auth_null_cipher_snow_test_case_1(void)
7740 return test_mixed_auth_cipher(
7741 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7745 test_verify_auth_null_cipher_snow_test_case_1(void)
7747 return test_mixed_auth_cipher(
7748 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7752 test_auth_null_cipher_zuc_test_case_1(void)
7754 return test_mixed_auth_cipher(
7755 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7759 test_verify_auth_null_cipher_zuc_test_case_1(void)
7761 return test_mixed_auth_cipher(
7762 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7766 test_auth_snow_cipher_null_test_case_1(void)
7768 return test_mixed_auth_cipher(
7769 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7773 test_verify_auth_snow_cipher_null_test_case_1(void)
7775 return test_mixed_auth_cipher(
7776 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7780 test_auth_zuc_cipher_null_test_case_1(void)
7782 return test_mixed_auth_cipher(
7783 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7787 test_verify_auth_zuc_cipher_null_test_case_1(void)
7789 return test_mixed_auth_cipher(
7790 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7794 test_auth_null_cipher_aes_ctr_test_case_1(void)
7796 return test_mixed_auth_cipher(
7797 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7801 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7803 return test_mixed_auth_cipher(
7804 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7808 test_auth_aes_cmac_cipher_null_test_case_1(void)
7810 return test_mixed_auth_cipher(
7811 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7815 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7817 return test_mixed_auth_cipher(
7818 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7821 /* ***** AEAD algorithm Tests ***** */
7824 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7825 enum rte_crypto_aead_operation op,
7826 const uint8_t *key, const uint8_t key_len,
7827 const uint16_t aad_len, const uint8_t auth_len,
7830 uint8_t aead_key[key_len];
7832 struct crypto_testsuite_params *ts_params = &testsuite_params;
7833 struct crypto_unittest_params *ut_params = &unittest_params;
7835 memcpy(aead_key, key, key_len);
7837 /* Setup AEAD Parameters */
7838 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7839 ut_params->aead_xform.next = NULL;
7840 ut_params->aead_xform.aead.algo = algo;
7841 ut_params->aead_xform.aead.op = op;
7842 ut_params->aead_xform.aead.key.data = aead_key;
7843 ut_params->aead_xform.aead.key.length = key_len;
7844 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7845 ut_params->aead_xform.aead.iv.length = iv_len;
7846 ut_params->aead_xform.aead.digest_length = auth_len;
7847 ut_params->aead_xform.aead.aad_length = aad_len;
7849 debug_hexdump(stdout, "key:", key, key_len);
7851 /* Create Crypto session*/
7852 ut_params->sess = rte_cryptodev_sym_session_create(
7853 ts_params->session_mpool);
7855 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7856 &ut_params->aead_xform,
7857 ts_params->session_priv_mpool);
7859 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7865 create_aead_xform(struct rte_crypto_op *op,
7866 enum rte_crypto_aead_algorithm algo,
7867 enum rte_crypto_aead_operation aead_op,
7868 uint8_t *key, const uint8_t key_len,
7869 const uint8_t aad_len, const uint8_t auth_len,
7872 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7873 "failed to allocate space for crypto transform");
7875 struct rte_crypto_sym_op *sym_op = op->sym;
7877 /* Setup AEAD Parameters */
7878 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7879 sym_op->xform->next = NULL;
7880 sym_op->xform->aead.algo = algo;
7881 sym_op->xform->aead.op = aead_op;
7882 sym_op->xform->aead.key.data = key;
7883 sym_op->xform->aead.key.length = key_len;
7884 sym_op->xform->aead.iv.offset = IV_OFFSET;
7885 sym_op->xform->aead.iv.length = iv_len;
7886 sym_op->xform->aead.digest_length = auth_len;
7887 sym_op->xform->aead.aad_length = aad_len;
7889 debug_hexdump(stdout, "key:", key, key_len);
7895 create_aead_operation(enum rte_crypto_aead_operation op,
7896 const struct aead_test_data *tdata)
7898 struct crypto_testsuite_params *ts_params = &testsuite_params;
7899 struct crypto_unittest_params *ut_params = &unittest_params;
7901 uint8_t *plaintext, *ciphertext;
7902 unsigned int aad_pad_len, plaintext_pad_len;
7904 /* Generate Crypto op data structure */
7905 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7906 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7907 TEST_ASSERT_NOT_NULL(ut_params->op,
7908 "Failed to allocate symmetric crypto operation struct");
7910 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7912 /* Append aad data */
7913 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7914 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7915 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7917 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7918 "no room to append aad");
7920 sym_op->aead.aad.phys_addr =
7921 rte_pktmbuf_iova(ut_params->ibuf);
7922 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7923 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7924 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7927 /* Append IV at the end of the crypto operation*/
7928 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7929 uint8_t *, IV_OFFSET);
7931 /* Copy IV 1 byte after the IV pointer, according to the API */
7932 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7933 debug_hexdump(stdout, "iv:", iv_ptr,
7936 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7937 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7939 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7940 "no room to append aad");
7942 sym_op->aead.aad.phys_addr =
7943 rte_pktmbuf_iova(ut_params->ibuf);
7944 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7945 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7948 /* Append IV at the end of the crypto operation*/
7949 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7950 uint8_t *, IV_OFFSET);
7952 if (tdata->iv.len == 0) {
7953 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7954 debug_hexdump(stdout, "iv:", iv_ptr,
7957 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7958 debug_hexdump(stdout, "iv:", iv_ptr,
7963 /* Append plaintext/ciphertext */
7964 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7965 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7966 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7968 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7970 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7971 debug_hexdump(stdout, "plaintext:", plaintext,
7972 tdata->plaintext.len);
7974 if (ut_params->obuf) {
7975 ciphertext = (uint8_t *)rte_pktmbuf_append(
7977 plaintext_pad_len + aad_pad_len);
7978 TEST_ASSERT_NOT_NULL(ciphertext,
7979 "no room to append ciphertext");
7981 memset(ciphertext + aad_pad_len, 0,
7982 tdata->ciphertext.len);
7985 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7986 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7988 TEST_ASSERT_NOT_NULL(ciphertext,
7989 "no room to append ciphertext");
7991 memcpy(ciphertext, tdata->ciphertext.data,
7992 tdata->ciphertext.len);
7993 debug_hexdump(stdout, "ciphertext:", ciphertext,
7994 tdata->ciphertext.len);
7996 if (ut_params->obuf) {
7997 plaintext = (uint8_t *)rte_pktmbuf_append(
7999 plaintext_pad_len + aad_pad_len);
8000 TEST_ASSERT_NOT_NULL(plaintext,
8001 "no room to append plaintext");
8003 memset(plaintext + aad_pad_len, 0,
8004 tdata->plaintext.len);
8008 /* Append digest data */
8009 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8010 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8011 ut_params->obuf ? ut_params->obuf :
8013 tdata->auth_tag.len);
8014 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8015 "no room to append digest");
8016 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8017 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8018 ut_params->obuf ? ut_params->obuf :
8023 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8024 ut_params->ibuf, tdata->auth_tag.len);
8025 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8026 "no room to append digest");
8027 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8029 plaintext_pad_len + aad_pad_len);
8031 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8032 tdata->auth_tag.len);
8033 debug_hexdump(stdout, "digest:",
8034 sym_op->aead.digest.data,
8035 tdata->auth_tag.len);
8038 sym_op->aead.data.length = tdata->plaintext.len;
8039 sym_op->aead.data.offset = aad_pad_len;
8045 test_authenticated_encryption(const struct aead_test_data *tdata)
8047 struct crypto_testsuite_params *ts_params = &testsuite_params;
8048 struct crypto_unittest_params *ut_params = &unittest_params;
8051 uint8_t *ciphertext, *auth_tag;
8052 uint16_t plaintext_pad_len;
8054 struct rte_cryptodev_info dev_info;
8056 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8057 uint64_t feat_flags = dev_info.feature_flags;
8059 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8060 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8061 printf("Device doesn't support RAW data-path APIs.\n");
8062 return TEST_SKIPPED;
8065 /* Verify the capabilities */
8066 struct rte_cryptodev_sym_capability_idx cap_idx;
8067 const struct rte_cryptodev_symmetric_capability *capability;
8068 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8069 cap_idx.algo.aead = tdata->algo;
8070 capability = rte_cryptodev_sym_capability_get(
8071 ts_params->valid_devs[0], &cap_idx);
8072 if (capability == NULL)
8073 return TEST_SKIPPED;
8074 if (rte_cryptodev_sym_capability_check_aead(
8075 capability, tdata->key.len, tdata->auth_tag.len,
8076 tdata->aad.len, tdata->iv.len))
8077 return TEST_SKIPPED;
8079 /* Create AEAD session */
8080 retval = create_aead_session(ts_params->valid_devs[0],
8082 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8083 tdata->key.data, tdata->key.len,
8084 tdata->aad.len, tdata->auth_tag.len,
8089 if (tdata->aad.len > MBUF_SIZE) {
8090 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8091 /* Populate full size of add data */
8092 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8093 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8095 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8097 /* clear mbuf payload */
8098 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8099 rte_pktmbuf_tailroom(ut_params->ibuf));
8101 /* Create AEAD operation */
8102 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8106 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8108 ut_params->op->sym->m_src = ut_params->ibuf;
8110 /* Process crypto operation */
8111 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8112 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8113 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8114 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8115 ut_params->op, 0, 0, 0, 0);
8117 TEST_ASSERT_NOT_NULL(
8118 process_crypto_request(ts_params->valid_devs[0],
8119 ut_params->op), "failed to process sym crypto op");
8121 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8122 "crypto op processing failed");
8124 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8126 if (ut_params->op->sym->m_dst) {
8127 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8129 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8130 uint8_t *, plaintext_pad_len);
8132 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8134 ut_params->op->sym->cipher.data.offset);
8135 auth_tag = ciphertext + plaintext_pad_len;
8138 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8139 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8142 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8144 tdata->ciphertext.data,
8145 tdata->ciphertext.len,
8146 "Ciphertext data not as expected");
8148 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8150 tdata->auth_tag.data,
8151 tdata->auth_tag.len,
8152 "Generated auth tag not as expected");
8158 #ifdef RTE_LIB_SECURITY
8160 security_proto_supported(enum rte_security_session_action_type action,
8161 enum rte_security_session_protocol proto)
8163 struct crypto_testsuite_params *ts_params = &testsuite_params;
8165 const struct rte_security_capability *capabilities;
8166 const struct rte_security_capability *capability;
8169 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8170 rte_cryptodev_get_sec_ctx(
8171 ts_params->valid_devs[0]);
8174 capabilities = rte_security_capabilities_get(ctx);
8176 if (capabilities == NULL)
8179 while ((capability = &capabilities[i++])->action !=
8180 RTE_SECURITY_ACTION_TYPE_NONE) {
8181 if (capability->action == action &&
8182 capability->protocol == proto)
8189 /* Basic algorithm run function for async inplace mode.
8190 * Creates a session from input parameters and runs one operation
8191 * on input_vec. Checks the output of the crypto operation against
8194 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8195 enum rte_crypto_auth_operation opa,
8196 const uint8_t *input_vec, unsigned int input_vec_len,
8197 const uint8_t *output_vec,
8198 unsigned int output_vec_len,
8199 enum rte_crypto_cipher_algorithm cipher_alg,
8200 const uint8_t *cipher_key, uint32_t cipher_key_len,
8201 enum rte_crypto_auth_algorithm auth_alg,
8202 const uint8_t *auth_key, uint32_t auth_key_len,
8203 uint8_t bearer, enum rte_security_pdcp_domain domain,
8204 uint8_t packet_direction, uint8_t sn_size,
8205 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8207 struct crypto_testsuite_params *ts_params = &testsuite_params;
8208 struct crypto_unittest_params *ut_params = &unittest_params;
8210 int ret = TEST_SUCCESS;
8211 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8212 rte_cryptodev_get_sec_ctx(
8213 ts_params->valid_devs[0]);
8215 /* Verify the capabilities */
8216 struct rte_security_capability_idx sec_cap_idx;
8218 sec_cap_idx.action = ut_params->type;
8219 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8220 sec_cap_idx.pdcp.domain = domain;
8221 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8222 return TEST_SKIPPED;
8224 /* Generate test mbuf data */
8225 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8227 /* clear mbuf payload */
8228 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8229 rte_pktmbuf_tailroom(ut_params->ibuf));
8231 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8233 memcpy(plaintext, input_vec, input_vec_len);
8235 /* Out of place support */
8238 * For out-op-place we need to alloc another mbuf
8240 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8241 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8244 /* Setup Cipher Parameters */
8245 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8246 ut_params->cipher_xform.cipher.algo = cipher_alg;
8247 ut_params->cipher_xform.cipher.op = opc;
8248 ut_params->cipher_xform.cipher.key.data = cipher_key;
8249 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8250 ut_params->cipher_xform.cipher.iv.length =
8251 packet_direction ? 4 : 0;
8252 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8254 /* Setup HMAC Parameters if ICV header is required */
8255 if (auth_alg != 0) {
8256 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8257 ut_params->auth_xform.next = NULL;
8258 ut_params->auth_xform.auth.algo = auth_alg;
8259 ut_params->auth_xform.auth.op = opa;
8260 ut_params->auth_xform.auth.key.data = auth_key;
8261 ut_params->auth_xform.auth.key.length = auth_key_len;
8263 ut_params->cipher_xform.next = &ut_params->auth_xform;
8265 ut_params->cipher_xform.next = NULL;
8268 struct rte_security_session_conf sess_conf = {
8269 .action_type = ut_params->type,
8270 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8274 .pkt_dir = packet_direction,
8276 .hfn = packet_direction ? 0 : hfn,
8278 * hfn can be set as pdcp_test_hfn[i]
8279 * if hfn_ovrd is not set. Here, PDCP
8280 * packet direction is just used to
8281 * run half of the cases with session
8282 * HFN and other half with per packet
8285 .hfn_threshold = hfn_threshold,
8286 .hfn_ovrd = packet_direction ? 1 : 0,
8287 .sdap_enabled = sdap,
8289 .crypto_xform = &ut_params->cipher_xform
8292 /* Create security session */
8293 ut_params->sec_session = rte_security_session_create(ctx,
8294 &sess_conf, ts_params->session_mpool,
8295 ts_params->session_priv_mpool);
8297 if (!ut_params->sec_session) {
8298 printf("TestCase %s()-%d line %d failed %s: ",
8299 __func__, i, __LINE__, "Failed to allocate session");
8304 /* Generate crypto op data structure */
8305 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8306 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8307 if (!ut_params->op) {
8308 printf("TestCase %s()-%d line %d failed %s: ",
8309 __func__, i, __LINE__,
8310 "Failed to allocate symmetric crypto operation struct");
8315 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8316 uint32_t *, IV_OFFSET);
8317 *per_pkt_hfn = packet_direction ? hfn : 0;
8319 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8321 /* set crypto operation source mbuf */
8322 ut_params->op->sym->m_src = ut_params->ibuf;
8324 ut_params->op->sym->m_dst = ut_params->obuf;
8326 /* Process crypto operation */
8327 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8329 printf("TestCase %s()-%d line %d failed %s: ",
8330 __func__, i, __LINE__,
8331 "failed to process sym crypto op");
8336 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8337 printf("TestCase %s()-%d line %d failed %s: ",
8338 __func__, i, __LINE__, "crypto op processing failed");
8344 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8347 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8351 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8352 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8353 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8354 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8360 rte_crypto_op_free(ut_params->op);
8361 ut_params->op = NULL;
8363 if (ut_params->sec_session)
8364 rte_security_session_destroy(ctx, ut_params->sec_session);
8365 ut_params->sec_session = NULL;
8367 rte_pktmbuf_free(ut_params->ibuf);
8368 ut_params->ibuf = NULL;
8370 rte_pktmbuf_free(ut_params->obuf);
8371 ut_params->obuf = NULL;
8378 test_pdcp_proto_SGL(int i, int oop,
8379 enum rte_crypto_cipher_operation opc,
8380 enum rte_crypto_auth_operation opa,
8382 unsigned int input_vec_len,
8383 uint8_t *output_vec,
8384 unsigned int output_vec_len,
8386 uint32_t fragsz_oop)
8388 struct crypto_testsuite_params *ts_params = &testsuite_params;
8389 struct crypto_unittest_params *ut_params = &unittest_params;
8391 struct rte_mbuf *buf, *buf_oop = NULL;
8392 int ret = TEST_SUCCESS;
8396 unsigned int trn_data = 0;
8397 struct rte_cryptodev_info dev_info;
8398 uint64_t feat_flags;
8399 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8400 rte_cryptodev_get_sec_ctx(
8401 ts_params->valid_devs[0]);
8402 struct rte_mbuf *temp_mbuf;
8404 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8405 feat_flags = dev_info.feature_flags;
8407 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8408 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8409 printf("Device does not support RAW data-path APIs.\n");
8412 /* Verify the capabilities */
8413 struct rte_security_capability_idx sec_cap_idx;
8415 sec_cap_idx.action = ut_params->type;
8416 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8417 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8418 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8419 return TEST_SKIPPED;
8421 if (fragsz > input_vec_len)
8422 fragsz = input_vec_len;
8424 uint16_t plaintext_len = fragsz;
8425 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8427 if (fragsz_oop > output_vec_len)
8428 frag_size_oop = output_vec_len;
8431 if (input_vec_len % fragsz != 0) {
8432 if (input_vec_len / fragsz + 1 > 16)
8434 } else if (input_vec_len / fragsz > 16)
8437 /* Out of place support */
8440 * For out-op-place we need to alloc another mbuf
8442 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8443 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8444 buf_oop = ut_params->obuf;
8447 /* Generate test mbuf data */
8448 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8450 /* clear mbuf payload */
8451 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8452 rte_pktmbuf_tailroom(ut_params->ibuf));
8454 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8456 memcpy(plaintext, input_vec, plaintext_len);
8457 trn_data += plaintext_len;
8459 buf = ut_params->ibuf;
8462 * Loop until no more fragments
8465 while (trn_data < input_vec_len) {
8467 to_trn = (input_vec_len - trn_data < fragsz) ?
8468 (input_vec_len - trn_data) : fragsz;
8470 to_trn_tbl[ecx++] = to_trn;
8472 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8475 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8476 rte_pktmbuf_tailroom(buf));
8479 if (oop && !fragsz_oop) {
8481 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8482 buf_oop = buf_oop->next;
8483 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8484 0, rte_pktmbuf_tailroom(buf_oop));
8485 rte_pktmbuf_append(buf_oop, to_trn);
8488 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8491 memcpy(plaintext, input_vec + trn_data, to_trn);
8495 ut_params->ibuf->nb_segs = segs;
8498 if (fragsz_oop && oop) {
8502 trn_data = frag_size_oop;
8503 while (trn_data < output_vec_len) {
8506 (output_vec_len - trn_data <
8508 (output_vec_len - trn_data) :
8511 to_trn_tbl[ecx++] = to_trn;
8514 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8515 buf_oop = buf_oop->next;
8516 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8517 0, rte_pktmbuf_tailroom(buf_oop));
8518 rte_pktmbuf_append(buf_oop, to_trn);
8522 ut_params->obuf->nb_segs = segs;
8525 /* Setup Cipher Parameters */
8526 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8527 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8528 ut_params->cipher_xform.cipher.op = opc;
8529 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8530 ut_params->cipher_xform.cipher.key.length =
8531 pdcp_test_params[i].cipher_key_len;
8532 ut_params->cipher_xform.cipher.iv.length = 0;
8534 /* Setup HMAC Parameters if ICV header is required */
8535 if (pdcp_test_params[i].auth_alg != 0) {
8536 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8537 ut_params->auth_xform.next = NULL;
8538 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8539 ut_params->auth_xform.auth.op = opa;
8540 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8541 ut_params->auth_xform.auth.key.length =
8542 pdcp_test_params[i].auth_key_len;
8544 ut_params->cipher_xform.next = &ut_params->auth_xform;
8546 ut_params->cipher_xform.next = NULL;
8549 struct rte_security_session_conf sess_conf = {
8550 .action_type = ut_params->type,
8551 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8553 .bearer = pdcp_test_bearer[i],
8554 .domain = pdcp_test_params[i].domain,
8555 .pkt_dir = pdcp_test_packet_direction[i],
8556 .sn_size = pdcp_test_data_sn_size[i],
8557 .hfn = pdcp_test_hfn[i],
8558 .hfn_threshold = pdcp_test_hfn_threshold[i],
8561 .crypto_xform = &ut_params->cipher_xform
8564 /* Create security session */
8565 ut_params->sec_session = rte_security_session_create(ctx,
8566 &sess_conf, ts_params->session_mpool,
8567 ts_params->session_priv_mpool);
8569 if (!ut_params->sec_session) {
8570 printf("TestCase %s()-%d line %d failed %s: ",
8571 __func__, i, __LINE__, "Failed to allocate session");
8576 /* Generate crypto op data structure */
8577 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8578 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8579 if (!ut_params->op) {
8580 printf("TestCase %s()-%d line %d failed %s: ",
8581 __func__, i, __LINE__,
8582 "Failed to allocate symmetric crypto operation struct");
8587 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8589 /* set crypto operation source mbuf */
8590 ut_params->op->sym->m_src = ut_params->ibuf;
8592 ut_params->op->sym->m_dst = ut_params->obuf;
8594 /* Process crypto operation */
8595 temp_mbuf = ut_params->op->sym->m_src;
8596 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8597 /* filling lengths */
8599 ut_params->op->sym->cipher.data.length
8600 += temp_mbuf->pkt_len;
8601 ut_params->op->sym->auth.data.length
8602 += temp_mbuf->pkt_len;
8603 temp_mbuf = temp_mbuf->next;
8605 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8606 ut_params->op, 1, 1, 0, 0);
8608 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8611 if (ut_params->op == NULL) {
8612 printf("TestCase %s()-%d line %d failed %s: ",
8613 __func__, i, __LINE__,
8614 "failed to process sym crypto op");
8619 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8620 printf("TestCase %s()-%d line %d failed %s: ",
8621 __func__, i, __LINE__, "crypto op processing failed");
8627 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8630 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8634 fragsz = frag_size_oop;
8635 if (memcmp(ciphertext, output_vec, fragsz)) {
8636 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8637 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8638 rte_hexdump(stdout, "reference", output_vec, fragsz);
8643 buf = ut_params->op->sym->m_src->next;
8645 buf = ut_params->op->sym->m_dst->next;
8647 unsigned int off = fragsz;
8651 ciphertext = rte_pktmbuf_mtod(buf,
8653 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8654 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8655 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8656 rte_hexdump(stdout, "reference", output_vec + off,
8661 off += to_trn_tbl[ecx++];
8665 rte_crypto_op_free(ut_params->op);
8666 ut_params->op = NULL;
8668 if (ut_params->sec_session)
8669 rte_security_session_destroy(ctx, ut_params->sec_session);
8670 ut_params->sec_session = NULL;
8672 rte_pktmbuf_free(ut_params->ibuf);
8673 ut_params->ibuf = NULL;
8675 rte_pktmbuf_free(ut_params->obuf);
8676 ut_params->obuf = NULL;
8683 test_pdcp_proto_cplane_encap(int i)
8685 return test_pdcp_proto(
8686 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8687 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8688 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8689 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8690 pdcp_test_params[i].cipher_key_len,
8691 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8692 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8693 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8694 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8695 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8699 test_pdcp_proto_uplane_encap(int i)
8701 return test_pdcp_proto(
8702 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8703 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8704 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8705 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8706 pdcp_test_params[i].cipher_key_len,
8707 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8708 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8709 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8710 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8711 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8715 test_pdcp_proto_uplane_encap_with_int(int i)
8717 return test_pdcp_proto(
8718 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8719 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8720 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8721 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8722 pdcp_test_params[i].cipher_key_len,
8723 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8724 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8725 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8726 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8727 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8731 test_pdcp_proto_cplane_decap(int i)
8733 return test_pdcp_proto(
8734 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8735 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8736 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8737 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8738 pdcp_test_params[i].cipher_key_len,
8739 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8740 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8741 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8742 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8743 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8747 test_pdcp_proto_uplane_decap(int i)
8749 return test_pdcp_proto(
8750 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8751 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8752 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8753 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8754 pdcp_test_params[i].cipher_key_len,
8755 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8756 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8757 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8758 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8759 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8763 test_pdcp_proto_uplane_decap_with_int(int i)
8765 return test_pdcp_proto(
8766 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8767 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8768 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8769 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8770 pdcp_test_params[i].cipher_key_len,
8771 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8772 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8773 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8774 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8775 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8779 test_PDCP_PROTO_SGL_in_place_32B(void)
8781 /* i can be used for running any PDCP case
8782 * In this case it is uplane 12-bit AES-SNOW DL encap
8784 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8785 return test_pdcp_proto_SGL(i, IN_PLACE,
8786 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8787 RTE_CRYPTO_AUTH_OP_GENERATE,
8788 pdcp_test_data_in[i],
8789 pdcp_test_data_in_len[i],
8790 pdcp_test_data_out[i],
8791 pdcp_test_data_in_len[i]+4,
8795 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8797 /* i can be used for running any PDCP case
8798 * In this case it is uplane 18-bit NULL-NULL DL encap
8800 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8801 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8802 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8803 RTE_CRYPTO_AUTH_OP_GENERATE,
8804 pdcp_test_data_in[i],
8805 pdcp_test_data_in_len[i],
8806 pdcp_test_data_out[i],
8807 pdcp_test_data_in_len[i]+4,
8811 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8813 /* i can be used for running any PDCP case
8814 * In this case it is uplane 18-bit AES DL encap
8816 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8818 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8819 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8820 RTE_CRYPTO_AUTH_OP_GENERATE,
8821 pdcp_test_data_in[i],
8822 pdcp_test_data_in_len[i],
8823 pdcp_test_data_out[i],
8824 pdcp_test_data_in_len[i],
8828 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8830 /* i can be used for running any PDCP case
8831 * In this case it is cplane 12-bit AES-ZUC DL encap
8833 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8834 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8835 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8836 RTE_CRYPTO_AUTH_OP_GENERATE,
8837 pdcp_test_data_in[i],
8838 pdcp_test_data_in_len[i],
8839 pdcp_test_data_out[i],
8840 pdcp_test_data_in_len[i]+4,
8845 test_PDCP_SDAP_PROTO_encap_all(void)
8847 int i = 0, size = 0;
8848 int err, all_err = TEST_SUCCESS;
8849 const struct pdcp_sdap_test *cur_test;
8851 size = RTE_DIM(list_pdcp_sdap_tests);
8853 for (i = 0; i < size; i++) {
8854 cur_test = &list_pdcp_sdap_tests[i];
8855 err = test_pdcp_proto(
8856 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8857 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8858 cur_test->in_len, cur_test->data_out,
8859 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8860 cur_test->param.cipher_alg, cur_test->cipher_key,
8861 cur_test->param.cipher_key_len,
8862 cur_test->param.auth_alg,
8863 cur_test->auth_key, cur_test->param.auth_key_len,
8864 cur_test->bearer, cur_test->param.domain,
8865 cur_test->packet_direction, cur_test->sn_size,
8867 cur_test->hfn_threshold, SDAP_ENABLED);
8869 printf("\t%d) %s: Encapsulation failed\n",
8871 cur_test->param.name);
8874 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8875 cur_test->param.name);
8881 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8883 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8887 test_PDCP_PROTO_short_mac(void)
8889 int i = 0, size = 0;
8890 int err, all_err = TEST_SUCCESS;
8891 const struct pdcp_short_mac_test *cur_test;
8893 size = RTE_DIM(list_pdcp_smac_tests);
8895 for (i = 0; i < size; i++) {
8896 cur_test = &list_pdcp_smac_tests[i];
8897 err = test_pdcp_proto(
8898 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8899 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8900 cur_test->in_len, cur_test->data_out,
8901 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8902 RTE_CRYPTO_CIPHER_NULL, NULL,
8903 0, cur_test->param.auth_alg,
8904 cur_test->auth_key, cur_test->param.auth_key_len,
8905 0, cur_test->param.domain, 0, 0,
8908 printf("\t%d) %s: Short MAC test failed\n",
8910 cur_test->param.name);
8913 printf("\t%d) %s: Short MAC test PASS\n",
8915 cur_test->param.name);
8916 rte_hexdump(stdout, "MAC I",
8917 cur_test->data_out + cur_test->in_len + 2,
8924 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8926 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8931 test_PDCP_SDAP_PROTO_decap_all(void)
8933 int i = 0, size = 0;
8934 int err, all_err = TEST_SUCCESS;
8935 const struct pdcp_sdap_test *cur_test;
8937 size = RTE_DIM(list_pdcp_sdap_tests);
8939 for (i = 0; i < size; i++) {
8940 cur_test = &list_pdcp_sdap_tests[i];
8941 err = test_pdcp_proto(
8942 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8943 RTE_CRYPTO_AUTH_OP_VERIFY,
8945 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8946 cur_test->data_in, cur_test->in_len,
8947 cur_test->param.cipher_alg,
8948 cur_test->cipher_key, cur_test->param.cipher_key_len,
8949 cur_test->param.auth_alg, cur_test->auth_key,
8950 cur_test->param.auth_key_len, cur_test->bearer,
8951 cur_test->param.domain, cur_test->packet_direction,
8952 cur_test->sn_size, cur_test->hfn,
8953 cur_test->hfn_threshold, SDAP_ENABLED);
8955 printf("\t%d) %s: Decapsulation failed\n",
8957 cur_test->param.name);
8960 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8961 cur_test->param.name);
8967 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8969 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8973 test_ipsec_proto_process(const struct ipsec_test_data td[],
8974 struct ipsec_test_data res_d[],
8977 const struct ipsec_test_flags *flags)
8979 struct crypto_testsuite_params *ts_params = &testsuite_params;
8980 struct crypto_unittest_params *ut_params = &unittest_params;
8981 struct rte_security_capability_idx sec_cap_idx;
8982 const struct rte_security_capability *sec_cap;
8983 struct rte_security_ipsec_xform ipsec_xform;
8984 uint8_t dev_id = ts_params->valid_devs[0];
8985 enum rte_security_ipsec_sa_direction dir;
8986 struct ipsec_test_data *res_d_tmp = NULL;
8987 uint32_t src = RTE_IPV4(192, 168, 1, 0);
8988 uint32_t dst = RTE_IPV4(192, 168, 1, 1);
8989 int salt_len, i, ret = TEST_SUCCESS;
8990 struct rte_security_ctx *ctx;
8991 uint8_t *input_text;
8994 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8995 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8997 /* Use first test data to create session */
8999 /* Copy IPsec xform */
9000 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9002 dir = ipsec_xform.direction;
9003 verify = flags->tunnel_hdr_verify;
9005 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9006 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9008 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9012 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src, sizeof(src));
9013 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst, sizeof(dst));
9015 ctx = rte_cryptodev_get_sec_ctx(dev_id);
9017 sec_cap_idx.action = ut_params->type;
9018 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9019 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9020 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9021 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9023 if (flags->udp_encap)
9024 ipsec_xform.options.udp_encap = 1;
9026 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9027 if (sec_cap == NULL)
9028 return TEST_SKIPPED;
9030 /* Copy cipher session parameters */
9032 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9033 sizeof(ut_params->aead_xform));
9034 ut_params->aead_xform.aead.key.data = td[0].key.data;
9035 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9037 /* Verify crypto capabilities */
9038 if (test_ipsec_crypto_caps_aead_verify(
9040 &ut_params->aead_xform) != 0) {
9042 RTE_LOG(INFO, USER1,
9043 "Crypto capabilities not supported\n");
9044 return TEST_SKIPPED;
9047 /* Only AEAD supported now */
9048 return TEST_SKIPPED;
9051 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9052 return TEST_SKIPPED;
9054 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9055 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9057 struct rte_security_session_conf sess_conf = {
9058 .action_type = ut_params->type,
9059 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9060 .ipsec = ipsec_xform,
9061 .crypto_xform = &ut_params->aead_xform,
9064 /* Create security session */
9065 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9066 ts_params->session_mpool,
9067 ts_params->session_priv_mpool);
9069 if (ut_params->sec_session == NULL)
9070 return TEST_SKIPPED;
9072 for (i = 0; i < nb_td; i++) {
9073 /* Setup source mbuf payload */
9074 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9075 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9076 rte_pktmbuf_tailroom(ut_params->ibuf));
9078 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9079 td[i].input_text.len);
9081 memcpy(input_text, td[i].input_text.data,
9082 td[i].input_text.len);
9084 /* Generate crypto op data structure */
9085 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9086 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9087 if (!ut_params->op) {
9088 printf("TestCase %s line %d: %s\n",
9090 "failed to allocate crypto op");
9092 goto crypto_op_free;
9095 /* Attach session to operation */
9096 rte_security_attach_session(ut_params->op,
9097 ut_params->sec_session);
9099 /* Set crypto operation mbufs */
9100 ut_params->op->sym->m_src = ut_params->ibuf;
9101 ut_params->op->sym->m_dst = NULL;
9103 /* Copy IV in crypto operation when IV generation is disabled */
9104 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9105 ipsec_xform.options.iv_gen_disable == 1) {
9106 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9112 len = td[i].xform.aead.aead.iv.length;
9114 len = td[i].xform.chain.cipher.cipher.iv.length;
9116 memcpy(iv, td[i].iv.data, len);
9119 /* Process crypto operation */
9120 process_crypto_request(dev_id, ut_params->op);
9122 ret = test_ipsec_status_check(ut_params->op, flags, dir, i + 1);
9123 if (ret != TEST_SUCCESS)
9124 goto crypto_op_free;
9127 res_d_tmp = &res_d[i];
9129 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9130 res_d_tmp, silent, flags);
9131 if (ret != TEST_SUCCESS)
9132 goto crypto_op_free;
9134 rte_crypto_op_free(ut_params->op);
9135 ut_params->op = NULL;
9137 rte_pktmbuf_free(ut_params->ibuf);
9138 ut_params->ibuf = NULL;
9142 rte_crypto_op_free(ut_params->op);
9143 ut_params->op = NULL;
9145 rte_pktmbuf_free(ut_params->ibuf);
9146 ut_params->ibuf = NULL;
9148 if (ut_params->sec_session)
9149 rte_security_session_destroy(ctx, ut_params->sec_session);
9150 ut_params->sec_session = NULL;
9156 test_ipsec_proto_known_vec(const void *test_data)
9158 struct ipsec_test_data td_outb;
9159 struct ipsec_test_flags flags;
9161 memset(&flags, 0, sizeof(flags));
9163 memcpy(&td_outb, test_data, sizeof(td_outb));
9165 /* Disable IV gen to be able to test with known vectors */
9166 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9168 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9172 test_ipsec_proto_known_vec_inb(const void *td_outb)
9174 struct ipsec_test_flags flags;
9175 struct ipsec_test_data td_inb;
9177 memset(&flags, 0, sizeof(flags));
9179 test_ipsec_td_in_from_out(td_outb, &td_inb);
9181 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9185 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9187 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9188 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9189 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9192 if (flags->iv_gen ||
9193 flags->sa_expiry_pkts_soft ||
9194 flags->sa_expiry_pkts_hard)
9195 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9197 for (i = 0; i < RTE_DIM(aead_list); i++) {
9198 test_ipsec_td_prepare(&aead_list[i],
9204 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9206 if (ret == TEST_SKIPPED)
9209 if (ret == TEST_FAILED)
9212 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9214 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9216 if (ret == TEST_SKIPPED)
9219 if (ret == TEST_FAILED)
9222 if (flags->display_alg)
9223 test_ipsec_display_alg(&aead_list[i], NULL);
9229 return TEST_SUCCESS;
9231 return TEST_SKIPPED;
9235 test_ipsec_proto_display_list(const void *data __rte_unused)
9237 struct ipsec_test_flags flags;
9239 memset(&flags, 0, sizeof(flags));
9241 flags.display_alg = true;
9243 return test_ipsec_proto_all(&flags);
9247 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9249 struct ipsec_test_flags flags;
9251 memset(&flags, 0, sizeof(flags));
9253 flags.iv_gen = true;
9255 return test_ipsec_proto_all(&flags);
9259 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9261 struct ipsec_test_flags flags;
9263 memset(&flags, 0, sizeof(flags));
9265 flags.sa_expiry_pkts_soft = true;
9267 return test_ipsec_proto_all(&flags);
9271 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9273 struct ipsec_test_flags flags;
9275 memset(&flags, 0, sizeof(flags));
9277 flags.sa_expiry_pkts_hard = true;
9279 return test_ipsec_proto_all(&flags);
9283 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9285 struct ipsec_test_flags flags;
9287 memset(&flags, 0, sizeof(flags));
9289 flags.icv_corrupt = true;
9291 return test_ipsec_proto_all(&flags);
9295 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9297 struct ipsec_test_flags flags;
9299 memset(&flags, 0, sizeof(flags));
9301 flags.udp_encap = true;
9303 return test_ipsec_proto_all(&flags);
9307 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9309 struct ipsec_test_flags flags;
9311 memset(&flags, 0, sizeof(flags));
9313 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9315 return test_ipsec_proto_all(&flags);
9319 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9321 struct ipsec_test_flags flags;
9323 memset(&flags, 0, sizeof(flags));
9325 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9327 return test_ipsec_proto_all(&flags);
9331 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9333 struct ipsec_test_flags flags;
9335 memset(&flags, 0, sizeof(flags));
9337 flags.udp_encap = true;
9338 flags.udp_ports_verify = true;
9340 return test_ipsec_proto_all(&flags);
9344 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9346 struct ipsec_test_flags flags;
9348 memset(&flags, 0, sizeof(flags));
9350 flags.ip_csum = true;
9352 return test_ipsec_proto_all(&flags);
9356 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9358 struct ipsec_test_flags flags;
9360 memset(&flags, 0, sizeof(flags));
9362 flags.l4_csum = true;
9364 return test_ipsec_proto_all(&flags);
9368 test_PDCP_PROTO_all(void)
9370 struct crypto_testsuite_params *ts_params = &testsuite_params;
9371 struct crypto_unittest_params *ut_params = &unittest_params;
9372 struct rte_cryptodev_info dev_info;
9375 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9376 uint64_t feat_flags = dev_info.feature_flags;
9378 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9379 return TEST_SKIPPED;
9381 /* Set action type */
9382 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9383 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9386 if (security_proto_supported(ut_params->type,
9387 RTE_SECURITY_PROTOCOL_PDCP) < 0)
9388 return TEST_SKIPPED;
9390 status = test_PDCP_PROTO_cplane_encap_all();
9391 status += test_PDCP_PROTO_cplane_decap_all();
9392 status += test_PDCP_PROTO_uplane_encap_all();
9393 status += test_PDCP_PROTO_uplane_decap_all();
9394 status += test_PDCP_PROTO_SGL_in_place_32B();
9395 status += test_PDCP_PROTO_SGL_oop_32B_128B();
9396 status += test_PDCP_PROTO_SGL_oop_32B_40B();
9397 status += test_PDCP_PROTO_SGL_oop_128B_32B();
9398 status += test_PDCP_SDAP_PROTO_encap_all();
9399 status += test_PDCP_SDAP_PROTO_decap_all();
9400 status += test_PDCP_PROTO_short_mac();
9405 return TEST_SUCCESS;
9409 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
9411 struct crypto_testsuite_params *ts_params = &testsuite_params;
9412 struct crypto_unittest_params *ut_params = &unittest_params;
9413 uint8_t *plaintext, *ciphertext;
9415 int32_t cipher_len, crc_len;
9416 uint32_t crc_data_len;
9417 int ret = TEST_SUCCESS;
9419 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9420 rte_cryptodev_get_sec_ctx(
9421 ts_params->valid_devs[0]);
9423 /* Verify the capabilities */
9424 struct rte_security_capability_idx sec_cap_idx;
9425 const struct rte_security_capability *sec_cap;
9426 const struct rte_cryptodev_capabilities *crypto_cap;
9427 const struct rte_cryptodev_symmetric_capability *sym_cap;
9430 sec_cap_idx.action = ut_params->type;
9431 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9432 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9434 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9435 if (sec_cap == NULL)
9436 return TEST_SKIPPED;
9438 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9439 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9440 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9441 crypto_cap->sym.xform_type ==
9442 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9443 crypto_cap->sym.cipher.algo ==
9444 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9445 sym_cap = &crypto_cap->sym;
9446 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9453 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9454 return TEST_SKIPPED;
9456 /* Setup source mbuf payload */
9457 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9458 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9459 rte_pktmbuf_tailroom(ut_params->ibuf));
9461 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9462 d_td->ciphertext.len);
9464 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
9466 /* Setup cipher session parameters */
9467 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9468 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9469 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
9470 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9471 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9472 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9473 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9474 ut_params->cipher_xform.next = NULL;
9476 /* Setup DOCSIS session parameters */
9477 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9479 struct rte_security_session_conf sess_conf = {
9480 .action_type = ut_params->type,
9481 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9482 .docsis = ut_params->docsis_xform,
9483 .crypto_xform = &ut_params->cipher_xform,
9486 /* Create security session */
9487 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9488 ts_params->session_mpool,
9489 ts_params->session_priv_mpool);
9491 if (!ut_params->sec_session) {
9492 printf("TestCase %s(%d) line %d: %s\n",
9493 __func__, i, __LINE__, "failed to allocate session");
9498 /* Generate crypto op data structure */
9499 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9500 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9501 if (!ut_params->op) {
9502 printf("TestCase %s(%d) line %d: %s\n",
9503 __func__, i, __LINE__,
9504 "failed to allocate symmetric crypto operation");
9509 /* Setup CRC operation parameters */
9510 crc_len = d_td->ciphertext.no_crc == false ?
9511 (d_td->ciphertext.len -
9512 d_td->ciphertext.crc_offset -
9513 RTE_ETHER_CRC_LEN) :
9515 crc_len = crc_len > 0 ? crc_len : 0;
9516 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9517 ut_params->op->sym->auth.data.length = crc_len;
9518 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9520 /* Setup cipher operation parameters */
9521 cipher_len = d_td->ciphertext.no_cipher == false ?
9522 (d_td->ciphertext.len -
9523 d_td->ciphertext.cipher_offset) :
9525 cipher_len = cipher_len > 0 ? cipher_len : 0;
9526 ut_params->op->sym->cipher.data.length = cipher_len;
9527 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9529 /* Setup cipher IV */
9530 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9531 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9533 /* Attach session to operation */
9534 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9536 /* Set crypto operation mbufs */
9537 ut_params->op->sym->m_src = ut_params->ibuf;
9538 ut_params->op->sym->m_dst = NULL;
9540 /* Process crypto operation */
9541 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9543 printf("TestCase %s(%d) line %d: %s\n",
9544 __func__, i, __LINE__,
9545 "failed to process security crypto op");
9550 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9551 printf("TestCase %s(%d) line %d: %s\n",
9552 __func__, i, __LINE__, "crypto op processing failed");
9557 /* Validate plaintext */
9558 plaintext = ciphertext;
9560 if (memcmp(plaintext, d_td->plaintext.data,
9561 d_td->plaintext.len - crc_data_len)) {
9562 printf("TestCase %s(%d) line %d: %s\n",
9563 __func__, i, __LINE__, "plaintext not as expected\n");
9564 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9565 d_td->plaintext.len);
9566 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9572 rte_crypto_op_free(ut_params->op);
9573 ut_params->op = NULL;
9575 if (ut_params->sec_session)
9576 rte_security_session_destroy(ctx, ut_params->sec_session);
9577 ut_params->sec_session = NULL;
9579 rte_pktmbuf_free(ut_params->ibuf);
9580 ut_params->ibuf = NULL;
9586 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9588 struct crypto_testsuite_params *ts_params = &testsuite_params;
9589 struct crypto_unittest_params *ut_params = &unittest_params;
9590 uint8_t *plaintext, *ciphertext;
9592 int32_t cipher_len, crc_len;
9593 int ret = TEST_SUCCESS;
9595 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9596 rte_cryptodev_get_sec_ctx(
9597 ts_params->valid_devs[0]);
9599 /* Verify the capabilities */
9600 struct rte_security_capability_idx sec_cap_idx;
9601 const struct rte_security_capability *sec_cap;
9602 const struct rte_cryptodev_capabilities *crypto_cap;
9603 const struct rte_cryptodev_symmetric_capability *sym_cap;
9606 sec_cap_idx.action = ut_params->type;
9607 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9608 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9610 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9611 if (sec_cap == NULL)
9612 return TEST_SKIPPED;
9614 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9615 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9616 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9617 crypto_cap->sym.xform_type ==
9618 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9619 crypto_cap->sym.cipher.algo ==
9620 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9621 sym_cap = &crypto_cap->sym;
9622 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9629 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9630 return TEST_SKIPPED;
9632 /* Setup source mbuf payload */
9633 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9634 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9635 rte_pktmbuf_tailroom(ut_params->ibuf));
9637 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9638 d_td->plaintext.len);
9640 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9642 /* Setup cipher session parameters */
9643 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9644 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9645 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9646 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9647 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9648 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9649 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9650 ut_params->cipher_xform.next = NULL;
9652 /* Setup DOCSIS session parameters */
9653 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9655 struct rte_security_session_conf sess_conf = {
9656 .action_type = ut_params->type,
9657 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9658 .docsis = ut_params->docsis_xform,
9659 .crypto_xform = &ut_params->cipher_xform,
9662 /* Create security session */
9663 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9664 ts_params->session_mpool,
9665 ts_params->session_priv_mpool);
9667 if (!ut_params->sec_session) {
9668 printf("TestCase %s(%d) line %d: %s\n",
9669 __func__, i, __LINE__, "failed to allocate session");
9674 /* Generate crypto op data structure */
9675 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9676 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9677 if (!ut_params->op) {
9678 printf("TestCase %s(%d) line %d: %s\n",
9679 __func__, i, __LINE__,
9680 "failed to allocate security crypto operation");
9685 /* Setup CRC operation parameters */
9686 crc_len = d_td->plaintext.no_crc == false ?
9687 (d_td->plaintext.len -
9688 d_td->plaintext.crc_offset -
9689 RTE_ETHER_CRC_LEN) :
9691 crc_len = crc_len > 0 ? crc_len : 0;
9692 ut_params->op->sym->auth.data.length = crc_len;
9693 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9695 /* Setup cipher operation parameters */
9696 cipher_len = d_td->plaintext.no_cipher == false ?
9697 (d_td->plaintext.len -
9698 d_td->plaintext.cipher_offset) :
9700 cipher_len = cipher_len > 0 ? cipher_len : 0;
9701 ut_params->op->sym->cipher.data.length = cipher_len;
9702 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9704 /* Setup cipher IV */
9705 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9706 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9708 /* Attach session to operation */
9709 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9711 /* Set crypto operation mbufs */
9712 ut_params->op->sym->m_src = ut_params->ibuf;
9713 ut_params->op->sym->m_dst = NULL;
9715 /* Process crypto operation */
9716 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9718 printf("TestCase %s(%d) line %d: %s\n",
9719 __func__, i, __LINE__,
9720 "failed to process security crypto op");
9725 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9726 printf("TestCase %s(%d) line %d: %s\n",
9727 __func__, i, __LINE__, "crypto op processing failed");
9732 /* Validate ciphertext */
9733 ciphertext = plaintext;
9735 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9736 printf("TestCase %s(%d) line %d: %s\n",
9737 __func__, i, __LINE__, "ciphertext not as expected\n");
9738 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9739 d_td->ciphertext.len);
9740 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9746 rte_crypto_op_free(ut_params->op);
9747 ut_params->op = NULL;
9749 if (ut_params->sec_session)
9750 rte_security_session_destroy(ctx, ut_params->sec_session);
9751 ut_params->sec_session = NULL;
9753 rte_pktmbuf_free(ut_params->ibuf);
9754 ut_params->ibuf = NULL;
9759 #define TEST_DOCSIS_COUNT(func) do { \
9761 if (ret == TEST_SUCCESS) { \
9762 printf("\t%2d)", n++); \
9763 printf("+++++ PASSED:" #func"\n"); \
9765 } else if (ret == TEST_SKIPPED) { \
9766 printf("\t%2d)", n++); \
9767 printf("~~~~~ SKIPPED:" #func"\n"); \
9770 printf("\t%2d)", n++); \
9771 printf("----- FAILED:" #func"\n"); \
9777 test_DOCSIS_PROTO_uplink_all(void)
9779 int p = 0, s = 0, f = 0, n = 0;
9781 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9782 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9783 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9784 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9785 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9786 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9787 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9788 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9789 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9790 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9791 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9792 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9793 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9794 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9795 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9796 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9797 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9798 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9799 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9800 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9801 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9802 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9803 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9804 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9805 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9806 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9809 printf("## %s: %d passed out of %d (%d skipped)\n",
9816 test_DOCSIS_PROTO_downlink_all(void)
9818 int p = 0, s = 0, f = 0, n = 0;
9820 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9821 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9822 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9823 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9824 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9825 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9826 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9827 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9828 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9829 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9830 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9831 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9832 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9833 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9834 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9835 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9836 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9837 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9838 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9839 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9840 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9841 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9842 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9843 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9844 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9845 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9848 printf("## %s: %d passed out of %d (%d skipped)\n",
9855 test_DOCSIS_PROTO_all(void)
9857 struct crypto_testsuite_params *ts_params = &testsuite_params;
9858 struct crypto_unittest_params *ut_params = &unittest_params;
9859 struct rte_cryptodev_info dev_info;
9862 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9863 uint64_t feat_flags = dev_info.feature_flags;
9865 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9866 return TEST_SKIPPED;
9868 /* Set action type */
9869 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9870 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9873 if (security_proto_supported(ut_params->type,
9874 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9875 return TEST_SKIPPED;
9877 status = test_DOCSIS_PROTO_uplink_all();
9878 status += test_DOCSIS_PROTO_downlink_all();
9883 return TEST_SUCCESS;
9888 test_AES_GCM_authenticated_encryption_test_case_1(void)
9890 return test_authenticated_encryption(&gcm_test_case_1);
9894 test_AES_GCM_authenticated_encryption_test_case_2(void)
9896 return test_authenticated_encryption(&gcm_test_case_2);
9900 test_AES_GCM_authenticated_encryption_test_case_3(void)
9902 return test_authenticated_encryption(&gcm_test_case_3);
9906 test_AES_GCM_authenticated_encryption_test_case_4(void)
9908 return test_authenticated_encryption(&gcm_test_case_4);
9912 test_AES_GCM_authenticated_encryption_test_case_5(void)
9914 return test_authenticated_encryption(&gcm_test_case_5);
9918 test_AES_GCM_authenticated_encryption_test_case_6(void)
9920 return test_authenticated_encryption(&gcm_test_case_6);
9924 test_AES_GCM_authenticated_encryption_test_case_7(void)
9926 return test_authenticated_encryption(&gcm_test_case_7);
9930 test_AES_GCM_authenticated_encryption_test_case_8(void)
9932 return test_authenticated_encryption(&gcm_test_case_8);
9936 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9938 return test_authenticated_encryption(&gcm_J0_test_case_1);
9942 test_AES_GCM_auth_encryption_test_case_192_1(void)
9944 return test_authenticated_encryption(&gcm_test_case_192_1);
9948 test_AES_GCM_auth_encryption_test_case_192_2(void)
9950 return test_authenticated_encryption(&gcm_test_case_192_2);
9954 test_AES_GCM_auth_encryption_test_case_192_3(void)
9956 return test_authenticated_encryption(&gcm_test_case_192_3);
9960 test_AES_GCM_auth_encryption_test_case_192_4(void)
9962 return test_authenticated_encryption(&gcm_test_case_192_4);
9966 test_AES_GCM_auth_encryption_test_case_192_5(void)
9968 return test_authenticated_encryption(&gcm_test_case_192_5);
9972 test_AES_GCM_auth_encryption_test_case_192_6(void)
9974 return test_authenticated_encryption(&gcm_test_case_192_6);
9978 test_AES_GCM_auth_encryption_test_case_192_7(void)
9980 return test_authenticated_encryption(&gcm_test_case_192_7);
9984 test_AES_GCM_auth_encryption_test_case_256_1(void)
9986 return test_authenticated_encryption(&gcm_test_case_256_1);
9990 test_AES_GCM_auth_encryption_test_case_256_2(void)
9992 return test_authenticated_encryption(&gcm_test_case_256_2);
9996 test_AES_GCM_auth_encryption_test_case_256_3(void)
9998 return test_authenticated_encryption(&gcm_test_case_256_3);
10002 test_AES_GCM_auth_encryption_test_case_256_4(void)
10004 return test_authenticated_encryption(&gcm_test_case_256_4);
10008 test_AES_GCM_auth_encryption_test_case_256_5(void)
10010 return test_authenticated_encryption(&gcm_test_case_256_5);
10014 test_AES_GCM_auth_encryption_test_case_256_6(void)
10016 return test_authenticated_encryption(&gcm_test_case_256_6);
10020 test_AES_GCM_auth_encryption_test_case_256_7(void)
10022 return test_authenticated_encryption(&gcm_test_case_256_7);
10026 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10028 return test_authenticated_encryption(&gcm_test_case_aad_1);
10032 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10034 return test_authenticated_encryption(&gcm_test_case_aad_2);
10038 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10040 struct aead_test_data tdata;
10043 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10044 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10045 tdata.iv.data[0] += 1;
10046 res = test_authenticated_encryption(&tdata);
10047 if (res == TEST_SKIPPED)
10049 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10050 return TEST_SUCCESS;
10054 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10056 struct aead_test_data tdata;
10059 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10060 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10061 tdata.plaintext.data[0] += 1;
10062 res = test_authenticated_encryption(&tdata);
10063 if (res == TEST_SKIPPED)
10065 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10066 return TEST_SUCCESS;
10070 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10072 struct aead_test_data tdata;
10075 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10076 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10077 tdata.ciphertext.data[0] += 1;
10078 res = test_authenticated_encryption(&tdata);
10079 if (res == TEST_SKIPPED)
10081 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10082 return TEST_SUCCESS;
10086 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10088 struct aead_test_data tdata;
10091 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10092 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10093 tdata.aad.len += 1;
10094 res = test_authenticated_encryption(&tdata);
10095 if (res == TEST_SKIPPED)
10097 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10098 return TEST_SUCCESS;
10102 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10104 struct aead_test_data tdata;
10105 uint8_t aad[gcm_test_case_7.aad.len];
10108 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10109 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10110 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10112 tdata.aad.data = aad;
10113 res = test_authenticated_encryption(&tdata);
10114 if (res == TEST_SKIPPED)
10116 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10117 return TEST_SUCCESS;
10121 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10123 struct aead_test_data tdata;
10126 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10127 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10128 tdata.auth_tag.data[0] += 1;
10129 res = test_authenticated_encryption(&tdata);
10130 if (res == TEST_SKIPPED)
10132 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10133 return TEST_SUCCESS;
10137 test_authenticated_decryption(const struct aead_test_data *tdata)
10139 struct crypto_testsuite_params *ts_params = &testsuite_params;
10140 struct crypto_unittest_params *ut_params = &unittest_params;
10143 uint8_t *plaintext;
10145 struct rte_cryptodev_info dev_info;
10147 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10148 uint64_t feat_flags = dev_info.feature_flags;
10150 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10151 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10152 printf("Device doesn't support RAW data-path APIs.\n");
10153 return TEST_SKIPPED;
10156 /* Verify the capabilities */
10157 struct rte_cryptodev_sym_capability_idx cap_idx;
10158 const struct rte_cryptodev_symmetric_capability *capability;
10159 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10160 cap_idx.algo.aead = tdata->algo;
10161 capability = rte_cryptodev_sym_capability_get(
10162 ts_params->valid_devs[0], &cap_idx);
10163 if (capability == NULL)
10164 return TEST_SKIPPED;
10165 if (rte_cryptodev_sym_capability_check_aead(
10166 capability, tdata->key.len, tdata->auth_tag.len,
10167 tdata->aad.len, tdata->iv.len))
10168 return TEST_SKIPPED;
10170 /* Create AEAD session */
10171 retval = create_aead_session(ts_params->valid_devs[0],
10173 RTE_CRYPTO_AEAD_OP_DECRYPT,
10174 tdata->key.data, tdata->key.len,
10175 tdata->aad.len, tdata->auth_tag.len,
10180 /* alloc mbuf and set payload */
10181 if (tdata->aad.len > MBUF_SIZE) {
10182 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10183 /* Populate full size of add data */
10184 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10185 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10187 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10189 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10190 rte_pktmbuf_tailroom(ut_params->ibuf));
10192 /* Create AEAD operation */
10193 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10197 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10199 ut_params->op->sym->m_src = ut_params->ibuf;
10201 /* Process crypto operation */
10202 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10203 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10204 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10205 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10206 ut_params->op, 0, 0, 0, 0);
10208 TEST_ASSERT_NOT_NULL(
10209 process_crypto_request(ts_params->valid_devs[0],
10210 ut_params->op), "failed to process sym crypto op");
10212 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10213 "crypto op processing failed");
10215 if (ut_params->op->sym->m_dst)
10216 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10219 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10221 ut_params->op->sym->cipher.data.offset);
10223 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10225 /* Validate obuf */
10226 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10228 tdata->plaintext.data,
10229 tdata->plaintext.len,
10230 "Plaintext data not as expected");
10232 TEST_ASSERT_EQUAL(ut_params->op->status,
10233 RTE_CRYPTO_OP_STATUS_SUCCESS,
10234 "Authentication failed");
10240 test_AES_GCM_authenticated_decryption_test_case_1(void)
10242 return test_authenticated_decryption(&gcm_test_case_1);
10246 test_AES_GCM_authenticated_decryption_test_case_2(void)
10248 return test_authenticated_decryption(&gcm_test_case_2);
10252 test_AES_GCM_authenticated_decryption_test_case_3(void)
10254 return test_authenticated_decryption(&gcm_test_case_3);
10258 test_AES_GCM_authenticated_decryption_test_case_4(void)
10260 return test_authenticated_decryption(&gcm_test_case_4);
10264 test_AES_GCM_authenticated_decryption_test_case_5(void)
10266 return test_authenticated_decryption(&gcm_test_case_5);
10270 test_AES_GCM_authenticated_decryption_test_case_6(void)
10272 return test_authenticated_decryption(&gcm_test_case_6);
10276 test_AES_GCM_authenticated_decryption_test_case_7(void)
10278 return test_authenticated_decryption(&gcm_test_case_7);
10282 test_AES_GCM_authenticated_decryption_test_case_8(void)
10284 return test_authenticated_decryption(&gcm_test_case_8);
10288 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10290 return test_authenticated_decryption(&gcm_J0_test_case_1);
10294 test_AES_GCM_auth_decryption_test_case_192_1(void)
10296 return test_authenticated_decryption(&gcm_test_case_192_1);
10300 test_AES_GCM_auth_decryption_test_case_192_2(void)
10302 return test_authenticated_decryption(&gcm_test_case_192_2);
10306 test_AES_GCM_auth_decryption_test_case_192_3(void)
10308 return test_authenticated_decryption(&gcm_test_case_192_3);
10312 test_AES_GCM_auth_decryption_test_case_192_4(void)
10314 return test_authenticated_decryption(&gcm_test_case_192_4);
10318 test_AES_GCM_auth_decryption_test_case_192_5(void)
10320 return test_authenticated_decryption(&gcm_test_case_192_5);
10324 test_AES_GCM_auth_decryption_test_case_192_6(void)
10326 return test_authenticated_decryption(&gcm_test_case_192_6);
10330 test_AES_GCM_auth_decryption_test_case_192_7(void)
10332 return test_authenticated_decryption(&gcm_test_case_192_7);
10336 test_AES_GCM_auth_decryption_test_case_256_1(void)
10338 return test_authenticated_decryption(&gcm_test_case_256_1);
10342 test_AES_GCM_auth_decryption_test_case_256_2(void)
10344 return test_authenticated_decryption(&gcm_test_case_256_2);
10348 test_AES_GCM_auth_decryption_test_case_256_3(void)
10350 return test_authenticated_decryption(&gcm_test_case_256_3);
10354 test_AES_GCM_auth_decryption_test_case_256_4(void)
10356 return test_authenticated_decryption(&gcm_test_case_256_4);
10360 test_AES_GCM_auth_decryption_test_case_256_5(void)
10362 return test_authenticated_decryption(&gcm_test_case_256_5);
10366 test_AES_GCM_auth_decryption_test_case_256_6(void)
10368 return test_authenticated_decryption(&gcm_test_case_256_6);
10372 test_AES_GCM_auth_decryption_test_case_256_7(void)
10374 return test_authenticated_decryption(&gcm_test_case_256_7);
10378 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10380 return test_authenticated_decryption(&gcm_test_case_aad_1);
10384 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10386 return test_authenticated_decryption(&gcm_test_case_aad_2);
10390 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10392 struct aead_test_data tdata;
10395 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10396 tdata.iv.data[0] += 1;
10397 res = test_authenticated_decryption(&tdata);
10398 if (res == TEST_SKIPPED)
10400 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10401 return TEST_SUCCESS;
10405 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10407 struct aead_test_data tdata;
10410 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10411 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10412 tdata.plaintext.data[0] += 1;
10413 res = test_authenticated_decryption(&tdata);
10414 if (res == TEST_SKIPPED)
10416 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10417 return TEST_SUCCESS;
10421 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10423 struct aead_test_data tdata;
10426 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10427 tdata.ciphertext.data[0] += 1;
10428 res = test_authenticated_decryption(&tdata);
10429 if (res == TEST_SKIPPED)
10431 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10432 return TEST_SUCCESS;
10436 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10438 struct aead_test_data tdata;
10441 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10442 tdata.aad.len += 1;
10443 res = test_authenticated_decryption(&tdata);
10444 if (res == TEST_SKIPPED)
10446 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10447 return TEST_SUCCESS;
10451 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10453 struct aead_test_data tdata;
10454 uint8_t aad[gcm_test_case_7.aad.len];
10457 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10458 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10460 tdata.aad.data = aad;
10461 res = test_authenticated_decryption(&tdata);
10462 if (res == TEST_SKIPPED)
10464 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10465 return TEST_SUCCESS;
10469 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10471 struct aead_test_data tdata;
10474 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10475 tdata.auth_tag.data[0] += 1;
10476 res = test_authenticated_decryption(&tdata);
10477 if (res == TEST_SKIPPED)
10479 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10480 return TEST_SUCCESS;
10484 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10486 struct crypto_testsuite_params *ts_params = &testsuite_params;
10487 struct crypto_unittest_params *ut_params = &unittest_params;
10490 uint8_t *ciphertext, *auth_tag;
10491 uint16_t plaintext_pad_len;
10492 struct rte_cryptodev_info dev_info;
10494 /* Verify the capabilities */
10495 struct rte_cryptodev_sym_capability_idx cap_idx;
10496 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10497 cap_idx.algo.aead = tdata->algo;
10498 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10500 return TEST_SKIPPED;
10502 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10503 uint64_t feat_flags = dev_info.feature_flags;
10505 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10506 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
10507 return TEST_SKIPPED;
10509 /* not supported with CPU crypto */
10510 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10511 return TEST_SKIPPED;
10513 /* Create AEAD session */
10514 retval = create_aead_session(ts_params->valid_devs[0],
10516 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10517 tdata->key.data, tdata->key.len,
10518 tdata->aad.len, tdata->auth_tag.len,
10523 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10524 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10526 /* clear mbuf payload */
10527 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10528 rte_pktmbuf_tailroom(ut_params->ibuf));
10529 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10530 rte_pktmbuf_tailroom(ut_params->obuf));
10532 /* Create AEAD operation */
10533 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10537 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10539 ut_params->op->sym->m_src = ut_params->ibuf;
10540 ut_params->op->sym->m_dst = ut_params->obuf;
10542 /* Process crypto operation */
10543 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10544 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10545 ut_params->op, 0, 0, 0, 0);
10547 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10548 ut_params->op), "failed to process sym crypto op");
10550 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10551 "crypto op processing failed");
10553 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10555 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10556 ut_params->op->sym->cipher.data.offset);
10557 auth_tag = ciphertext + plaintext_pad_len;
10559 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10560 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10562 /* Validate obuf */
10563 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10565 tdata->ciphertext.data,
10566 tdata->ciphertext.len,
10567 "Ciphertext data not as expected");
10569 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10571 tdata->auth_tag.data,
10572 tdata->auth_tag.len,
10573 "Generated auth tag not as expected");
10580 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10582 return test_authenticated_encryption_oop(&gcm_test_case_5);
10586 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10588 struct crypto_testsuite_params *ts_params = &testsuite_params;
10589 struct crypto_unittest_params *ut_params = &unittest_params;
10592 uint8_t *plaintext;
10593 struct rte_cryptodev_info dev_info;
10595 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10596 uint64_t feat_flags = dev_info.feature_flags;
10598 /* Verify the capabilities */
10599 struct rte_cryptodev_sym_capability_idx cap_idx;
10600 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10601 cap_idx.algo.aead = tdata->algo;
10602 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10604 return TEST_SKIPPED;
10606 /* not supported with CPU crypto and raw data-path APIs*/
10607 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10608 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10609 return TEST_SKIPPED;
10611 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10612 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10613 printf("Device does not support RAW data-path APIs.\n");
10614 return TEST_SKIPPED;
10617 /* Create AEAD session */
10618 retval = create_aead_session(ts_params->valid_devs[0],
10620 RTE_CRYPTO_AEAD_OP_DECRYPT,
10621 tdata->key.data, tdata->key.len,
10622 tdata->aad.len, tdata->auth_tag.len,
10627 /* alloc mbuf and set payload */
10628 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10629 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10631 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10632 rte_pktmbuf_tailroom(ut_params->ibuf));
10633 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10634 rte_pktmbuf_tailroom(ut_params->obuf));
10636 /* Create AEAD operation */
10637 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10641 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10643 ut_params->op->sym->m_src = ut_params->ibuf;
10644 ut_params->op->sym->m_dst = ut_params->obuf;
10646 /* Process crypto operation */
10647 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10648 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10649 ut_params->op, 0, 0, 0, 0);
10651 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10652 ut_params->op), "failed to process sym crypto op");
10654 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10655 "crypto op processing failed");
10657 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10658 ut_params->op->sym->cipher.data.offset);
10660 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10662 /* Validate obuf */
10663 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10665 tdata->plaintext.data,
10666 tdata->plaintext.len,
10667 "Plaintext data not as expected");
10669 TEST_ASSERT_EQUAL(ut_params->op->status,
10670 RTE_CRYPTO_OP_STATUS_SUCCESS,
10671 "Authentication failed");
10676 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10678 return test_authenticated_decryption_oop(&gcm_test_case_5);
10682 test_authenticated_encryption_sessionless(
10683 const struct aead_test_data *tdata)
10685 struct crypto_testsuite_params *ts_params = &testsuite_params;
10686 struct crypto_unittest_params *ut_params = &unittest_params;
10689 uint8_t *ciphertext, *auth_tag;
10690 uint16_t plaintext_pad_len;
10691 uint8_t key[tdata->key.len + 1];
10692 struct rte_cryptodev_info dev_info;
10694 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10695 uint64_t feat_flags = dev_info.feature_flags;
10697 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10698 printf("Device doesn't support Sessionless ops.\n");
10699 return TEST_SKIPPED;
10702 /* not supported with CPU crypto */
10703 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10704 return TEST_SKIPPED;
10706 /* Verify the capabilities */
10707 struct rte_cryptodev_sym_capability_idx cap_idx;
10708 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10709 cap_idx.algo.aead = tdata->algo;
10710 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10712 return TEST_SKIPPED;
10714 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10716 /* clear mbuf payload */
10717 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10718 rte_pktmbuf_tailroom(ut_params->ibuf));
10720 /* Create AEAD operation */
10721 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10725 /* Create GCM xform */
10726 memcpy(key, tdata->key.data, tdata->key.len);
10727 retval = create_aead_xform(ut_params->op,
10729 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10730 key, tdata->key.len,
10731 tdata->aad.len, tdata->auth_tag.len,
10736 ut_params->op->sym->m_src = ut_params->ibuf;
10738 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10739 RTE_CRYPTO_OP_SESSIONLESS,
10740 "crypto op session type not sessionless");
10742 /* Process crypto operation */
10743 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10744 ut_params->op), "failed to process sym crypto op");
10746 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10748 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10749 "crypto op status not success");
10751 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10753 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10754 ut_params->op->sym->cipher.data.offset);
10755 auth_tag = ciphertext + plaintext_pad_len;
10757 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10758 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10760 /* Validate obuf */
10761 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10763 tdata->ciphertext.data,
10764 tdata->ciphertext.len,
10765 "Ciphertext data not as expected");
10767 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10769 tdata->auth_tag.data,
10770 tdata->auth_tag.len,
10771 "Generated auth tag not as expected");
10778 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10780 return test_authenticated_encryption_sessionless(
10785 test_authenticated_decryption_sessionless(
10786 const struct aead_test_data *tdata)
10788 struct crypto_testsuite_params *ts_params = &testsuite_params;
10789 struct crypto_unittest_params *ut_params = &unittest_params;
10792 uint8_t *plaintext;
10793 uint8_t key[tdata->key.len + 1];
10794 struct rte_cryptodev_info dev_info;
10796 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10797 uint64_t feat_flags = dev_info.feature_flags;
10799 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10800 printf("Device doesn't support Sessionless ops.\n");
10801 return TEST_SKIPPED;
10804 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10805 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10806 printf("Device doesn't support RAW data-path APIs.\n");
10807 return TEST_SKIPPED;
10810 /* not supported with CPU crypto */
10811 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10812 return TEST_SKIPPED;
10814 /* Verify the capabilities */
10815 struct rte_cryptodev_sym_capability_idx cap_idx;
10816 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10817 cap_idx.algo.aead = tdata->algo;
10818 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10820 return TEST_SKIPPED;
10822 /* alloc mbuf and set payload */
10823 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10825 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10826 rte_pktmbuf_tailroom(ut_params->ibuf));
10828 /* Create AEAD operation */
10829 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10833 /* Create AEAD xform */
10834 memcpy(key, tdata->key.data, tdata->key.len);
10835 retval = create_aead_xform(ut_params->op,
10837 RTE_CRYPTO_AEAD_OP_DECRYPT,
10838 key, tdata->key.len,
10839 tdata->aad.len, tdata->auth_tag.len,
10844 ut_params->op->sym->m_src = ut_params->ibuf;
10846 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10847 RTE_CRYPTO_OP_SESSIONLESS,
10848 "crypto op session type not sessionless");
10850 /* Process crypto operation */
10851 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10852 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10853 ut_params->op, 0, 0, 0, 0);
10855 TEST_ASSERT_NOT_NULL(process_crypto_request(
10856 ts_params->valid_devs[0], ut_params->op),
10857 "failed to process sym crypto op");
10859 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10861 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10862 "crypto op status not success");
10864 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10865 ut_params->op->sym->cipher.data.offset);
10867 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10869 /* Validate obuf */
10870 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10872 tdata->plaintext.data,
10873 tdata->plaintext.len,
10874 "Plaintext data not as expected");
10876 TEST_ASSERT_EQUAL(ut_params->op->status,
10877 RTE_CRYPTO_OP_STATUS_SUCCESS,
10878 "Authentication failed");
10883 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10885 return test_authenticated_decryption_sessionless(
10890 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10892 return test_authenticated_encryption(&ccm_test_case_128_1);
10896 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10898 return test_authenticated_encryption(&ccm_test_case_128_2);
10902 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10904 return test_authenticated_encryption(&ccm_test_case_128_3);
10908 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10910 return test_authenticated_decryption(&ccm_test_case_128_1);
10914 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10916 return test_authenticated_decryption(&ccm_test_case_128_2);
10920 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10922 return test_authenticated_decryption(&ccm_test_case_128_3);
10926 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10928 return test_authenticated_encryption(&ccm_test_case_192_1);
10932 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10934 return test_authenticated_encryption(&ccm_test_case_192_2);
10938 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10940 return test_authenticated_encryption(&ccm_test_case_192_3);
10944 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10946 return test_authenticated_decryption(&ccm_test_case_192_1);
10950 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10952 return test_authenticated_decryption(&ccm_test_case_192_2);
10956 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10958 return test_authenticated_decryption(&ccm_test_case_192_3);
10962 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10964 return test_authenticated_encryption(&ccm_test_case_256_1);
10968 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10970 return test_authenticated_encryption(&ccm_test_case_256_2);
10974 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10976 return test_authenticated_encryption(&ccm_test_case_256_3);
10980 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10982 return test_authenticated_decryption(&ccm_test_case_256_1);
10986 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10988 return test_authenticated_decryption(&ccm_test_case_256_2);
10992 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10994 return test_authenticated_decryption(&ccm_test_case_256_3);
11000 struct crypto_testsuite_params *ts_params = &testsuite_params;
11001 struct rte_cryptodev_stats stats;
11003 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11004 return TEST_SKIPPED;
11006 /* Verify the capabilities */
11007 struct rte_cryptodev_sym_capability_idx cap_idx;
11008 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11009 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11010 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11012 return TEST_SKIPPED;
11013 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11014 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11015 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11017 return TEST_SKIPPED;
11019 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11021 return TEST_SKIPPED;
11023 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11024 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11025 &stats) == -ENODEV),
11026 "rte_cryptodev_stats_get invalid dev failed");
11027 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11028 "rte_cryptodev_stats_get invalid Param failed");
11030 /* Test expected values */
11031 test_AES_CBC_HMAC_SHA1_encrypt_digest();
11032 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11034 "rte_cryptodev_stats_get failed");
11035 TEST_ASSERT((stats.enqueued_count == 1),
11036 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11037 TEST_ASSERT((stats.dequeued_count == 1),
11038 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11039 TEST_ASSERT((stats.enqueue_err_count == 0),
11040 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11041 TEST_ASSERT((stats.dequeue_err_count == 0),
11042 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11044 /* invalid device but should ignore and not reset device stats*/
11045 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11046 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11048 "rte_cryptodev_stats_get failed");
11049 TEST_ASSERT((stats.enqueued_count == 1),
11050 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11052 /* check that a valid reset clears stats */
11053 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11054 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11056 "rte_cryptodev_stats_get failed");
11057 TEST_ASSERT((stats.enqueued_count == 0),
11058 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11059 TEST_ASSERT((stats.dequeued_count == 0),
11060 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11062 return TEST_SUCCESS;
11065 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11066 struct crypto_unittest_params *ut_params,
11067 enum rte_crypto_auth_operation op,
11068 const struct HMAC_MD5_vector *test_case)
11072 memcpy(key, test_case->key.data, test_case->key.len);
11074 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11075 ut_params->auth_xform.next = NULL;
11076 ut_params->auth_xform.auth.op = op;
11078 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11080 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11081 ut_params->auth_xform.auth.key.length = test_case->key.len;
11082 ut_params->auth_xform.auth.key.data = key;
11084 ut_params->sess = rte_cryptodev_sym_session_create(
11085 ts_params->session_mpool);
11087 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11088 ut_params->sess, &ut_params->auth_xform,
11089 ts_params->session_priv_mpool);
11091 if (ut_params->sess == NULL)
11092 return TEST_FAILED;
11094 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11096 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11097 rte_pktmbuf_tailroom(ut_params->ibuf));
11102 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11103 const struct HMAC_MD5_vector *test_case,
11104 uint8_t **plaintext)
11106 uint16_t plaintext_pad_len;
11108 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11110 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11113 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11114 plaintext_pad_len);
11115 memcpy(*plaintext, test_case->plaintext.data,
11116 test_case->plaintext.len);
11118 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11119 ut_params->ibuf, MD5_DIGEST_LEN);
11120 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11121 "no room to append digest");
11122 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11123 ut_params->ibuf, plaintext_pad_len);
11125 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11126 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11127 test_case->auth_tag.len);
11130 sym_op->auth.data.offset = 0;
11131 sym_op->auth.data.length = test_case->plaintext.len;
11133 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11134 ut_params->op->sym->m_src = ut_params->ibuf;
11140 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11142 uint16_t plaintext_pad_len;
11143 uint8_t *plaintext, *auth_tag;
11145 struct crypto_testsuite_params *ts_params = &testsuite_params;
11146 struct crypto_unittest_params *ut_params = &unittest_params;
11147 struct rte_cryptodev_info dev_info;
11149 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11150 uint64_t feat_flags = dev_info.feature_flags;
11152 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11153 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11154 printf("Device doesn't support RAW data-path APIs.\n");
11155 return TEST_SKIPPED;
11158 /* Verify the capabilities */
11159 struct rte_cryptodev_sym_capability_idx cap_idx;
11160 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11161 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11162 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11164 return TEST_SKIPPED;
11166 if (MD5_HMAC_create_session(ts_params, ut_params,
11167 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11168 return TEST_FAILED;
11170 /* Generate Crypto op data structure */
11171 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11172 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11173 TEST_ASSERT_NOT_NULL(ut_params->op,
11174 "Failed to allocate symmetric crypto operation struct");
11176 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11179 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11180 return TEST_FAILED;
11182 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11183 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11185 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11186 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11187 ut_params->op, 0, 1, 0, 0);
11189 TEST_ASSERT_NOT_NULL(
11190 process_crypto_request(ts_params->valid_devs[0],
11192 "failed to process sym crypto op");
11194 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11195 "crypto op processing failed");
11197 if (ut_params->op->sym->m_dst) {
11198 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11199 uint8_t *, plaintext_pad_len);
11201 auth_tag = plaintext + plaintext_pad_len;
11204 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11206 test_case->auth_tag.data,
11207 test_case->auth_tag.len,
11208 "HMAC_MD5 generated tag not as expected");
11210 return TEST_SUCCESS;
11214 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11216 uint8_t *plaintext;
11218 struct crypto_testsuite_params *ts_params = &testsuite_params;
11219 struct crypto_unittest_params *ut_params = &unittest_params;
11220 struct rte_cryptodev_info dev_info;
11222 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11223 uint64_t feat_flags = dev_info.feature_flags;
11225 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11226 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11227 printf("Device doesn't support RAW data-path APIs.\n");
11228 return TEST_SKIPPED;
11231 /* Verify the capabilities */
11232 struct rte_cryptodev_sym_capability_idx cap_idx;
11233 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11234 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11235 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11237 return TEST_SKIPPED;
11239 if (MD5_HMAC_create_session(ts_params, ut_params,
11240 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11241 return TEST_FAILED;
11244 /* Generate Crypto op data structure */
11245 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11246 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11247 TEST_ASSERT_NOT_NULL(ut_params->op,
11248 "Failed to allocate symmetric crypto operation struct");
11250 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11251 return TEST_FAILED;
11253 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11254 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11256 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11257 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11258 ut_params->op, 0, 1, 0, 0);
11260 TEST_ASSERT_NOT_NULL(
11261 process_crypto_request(ts_params->valid_devs[0],
11263 "failed to process sym crypto op");
11265 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11266 "HMAC_MD5 crypto op processing failed");
11268 return TEST_SUCCESS;
11272 test_MD5_HMAC_generate_case_1(void)
11274 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11278 test_MD5_HMAC_verify_case_1(void)
11280 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11284 test_MD5_HMAC_generate_case_2(void)
11286 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11290 test_MD5_HMAC_verify_case_2(void)
11292 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11296 test_multi_session(void)
11298 struct crypto_testsuite_params *ts_params = &testsuite_params;
11299 struct crypto_unittest_params *ut_params = &unittest_params;
11301 struct rte_cryptodev_info dev_info;
11302 struct rte_cryptodev_sym_session **sessions;
11306 /* Verify the capabilities */
11307 struct rte_cryptodev_sym_capability_idx cap_idx;
11308 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11309 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11310 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11312 return TEST_SKIPPED;
11313 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11314 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11315 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11317 return TEST_SKIPPED;
11319 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11320 aes_cbc_key, hmac_sha512_key);
11323 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11325 sessions = rte_malloc(NULL,
11326 sizeof(struct rte_cryptodev_sym_session *) *
11327 (MAX_NB_SESSIONS + 1), 0);
11329 /* Create multiple crypto sessions*/
11330 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11332 sessions[i] = rte_cryptodev_sym_session_create(
11333 ts_params->session_mpool);
11335 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11336 sessions[i], &ut_params->auth_xform,
11337 ts_params->session_priv_mpool);
11338 TEST_ASSERT_NOT_NULL(sessions[i],
11339 "Session creation failed at session number %u",
11342 /* Attempt to send a request on each session */
11343 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11347 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11348 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11350 "Failed to perform decrypt on request number %u.", i);
11351 /* free crypto operation structure */
11353 rte_crypto_op_free(ut_params->op);
11356 * free mbuf - both obuf and ibuf are usually the same,
11357 * so check if they point at the same address is necessary,
11358 * to avoid freeing the mbuf twice.
11360 if (ut_params->obuf) {
11361 rte_pktmbuf_free(ut_params->obuf);
11362 if (ut_params->ibuf == ut_params->obuf)
11363 ut_params->ibuf = 0;
11364 ut_params->obuf = 0;
11366 if (ut_params->ibuf) {
11367 rte_pktmbuf_free(ut_params->ibuf);
11368 ut_params->ibuf = 0;
11372 sessions[i] = NULL;
11373 /* Next session create should fail */
11374 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11375 sessions[i], &ut_params->auth_xform,
11376 ts_params->session_priv_mpool);
11377 TEST_ASSERT_NULL(sessions[i],
11378 "Session creation succeeded unexpectedly!");
11380 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11381 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11383 rte_cryptodev_sym_session_free(sessions[i]);
11386 rte_free(sessions);
11388 return TEST_SUCCESS;
11391 struct multi_session_params {
11392 struct crypto_unittest_params ut_params;
11393 uint8_t *cipher_key;
11395 const uint8_t *cipher;
11396 const uint8_t *digest;
11400 #define MB_SESSION_NUMBER 3
11403 test_multi_session_random_usage(void)
11405 struct crypto_testsuite_params *ts_params = &testsuite_params;
11406 struct rte_cryptodev_info dev_info;
11407 struct rte_cryptodev_sym_session **sessions;
11409 struct multi_session_params ut_paramz[] = {
11412 .cipher_key = ms_aes_cbc_key0,
11413 .hmac_key = ms_hmac_key0,
11414 .cipher = ms_aes_cbc_cipher0,
11415 .digest = ms_hmac_digest0,
11416 .iv = ms_aes_cbc_iv0
11419 .cipher_key = ms_aes_cbc_key1,
11420 .hmac_key = ms_hmac_key1,
11421 .cipher = ms_aes_cbc_cipher1,
11422 .digest = ms_hmac_digest1,
11423 .iv = ms_aes_cbc_iv1
11426 .cipher_key = ms_aes_cbc_key2,
11427 .hmac_key = ms_hmac_key2,
11428 .cipher = ms_aes_cbc_cipher2,
11429 .digest = ms_hmac_digest2,
11430 .iv = ms_aes_cbc_iv2
11435 /* Verify the capabilities */
11436 struct rte_cryptodev_sym_capability_idx cap_idx;
11437 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11438 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11439 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11441 return TEST_SKIPPED;
11442 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11443 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11444 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11446 return TEST_SKIPPED;
11448 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11450 sessions = rte_malloc(NULL,
11451 (sizeof(struct rte_cryptodev_sym_session *)
11452 * MAX_NB_SESSIONS) + 1, 0);
11454 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11455 sessions[i] = rte_cryptodev_sym_session_create(
11456 ts_params->session_mpool);
11458 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11459 sizeof(struct crypto_unittest_params));
11461 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11462 &ut_paramz[i].ut_params,
11463 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11465 /* Create multiple crypto sessions*/
11466 rte_cryptodev_sym_session_init(
11467 ts_params->valid_devs[0],
11469 &ut_paramz[i].ut_params.auth_xform,
11470 ts_params->session_priv_mpool);
11472 TEST_ASSERT_NOT_NULL(sessions[i],
11473 "Session creation failed at session number %u",
11479 for (i = 0; i < 40000; i++) {
11481 j = rand() % MB_SESSION_NUMBER;
11483 TEST_ASSERT_SUCCESS(
11484 test_AES_CBC_HMAC_SHA512_decrypt_perform(
11486 &ut_paramz[j].ut_params,
11487 ts_params, ut_paramz[j].cipher,
11488 ut_paramz[j].digest,
11490 "Failed to perform decrypt on request number %u.", i);
11492 if (ut_paramz[j].ut_params.op)
11493 rte_crypto_op_free(ut_paramz[j].ut_params.op);
11496 * free mbuf - both obuf and ibuf are usually the same,
11497 * so check if they point at the same address is necessary,
11498 * to avoid freeing the mbuf twice.
11500 if (ut_paramz[j].ut_params.obuf) {
11501 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11502 if (ut_paramz[j].ut_params.ibuf
11503 == ut_paramz[j].ut_params.obuf)
11504 ut_paramz[j].ut_params.ibuf = 0;
11505 ut_paramz[j].ut_params.obuf = 0;
11507 if (ut_paramz[j].ut_params.ibuf) {
11508 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11509 ut_paramz[j].ut_params.ibuf = 0;
11513 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11514 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11516 rte_cryptodev_sym_session_free(sessions[i]);
11519 rte_free(sessions);
11521 return TEST_SUCCESS;
11524 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11525 0xab, 0xab, 0xab, 0xab,
11526 0xab, 0xab, 0xab, 0xab,
11527 0xab, 0xab, 0xab, 0xab};
11530 test_null_invalid_operation(void)
11532 struct crypto_testsuite_params *ts_params = &testsuite_params;
11533 struct crypto_unittest_params *ut_params = &unittest_params;
11536 /* This test is for NULL PMD only */
11537 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11538 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11539 return TEST_SKIPPED;
11541 /* Setup Cipher Parameters */
11542 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11543 ut_params->cipher_xform.next = NULL;
11545 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11546 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11548 ut_params->sess = rte_cryptodev_sym_session_create(
11549 ts_params->session_mpool);
11551 /* Create Crypto session*/
11552 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11553 ut_params->sess, &ut_params->cipher_xform,
11554 ts_params->session_priv_mpool);
11555 TEST_ASSERT(ret < 0,
11556 "Session creation succeeded unexpectedly");
11559 /* Setup HMAC Parameters */
11560 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11561 ut_params->auth_xform.next = NULL;
11563 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11564 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11566 ut_params->sess = rte_cryptodev_sym_session_create(
11567 ts_params->session_mpool);
11569 /* Create Crypto session*/
11570 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11571 ut_params->sess, &ut_params->auth_xform,
11572 ts_params->session_priv_mpool);
11573 TEST_ASSERT(ret < 0,
11574 "Session creation succeeded unexpectedly");
11576 return TEST_SUCCESS;
11580 #define NULL_BURST_LENGTH (32)
11583 test_null_burst_operation(void)
11585 struct crypto_testsuite_params *ts_params = &testsuite_params;
11586 struct crypto_unittest_params *ut_params = &unittest_params;
11588 unsigned i, burst_len = NULL_BURST_LENGTH;
11590 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11591 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11593 /* This test is for NULL PMD only */
11594 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11595 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11596 return TEST_SKIPPED;
11598 /* Setup Cipher Parameters */
11599 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11600 ut_params->cipher_xform.next = &ut_params->auth_xform;
11602 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11603 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11605 /* Setup HMAC Parameters */
11606 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11607 ut_params->auth_xform.next = NULL;
11609 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11610 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11612 ut_params->sess = rte_cryptodev_sym_session_create(
11613 ts_params->session_mpool);
11615 /* Create Crypto session*/
11616 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11617 ut_params->sess, &ut_params->cipher_xform,
11618 ts_params->session_priv_mpool);
11619 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11621 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11622 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11623 burst_len, "failed to generate burst of crypto ops");
11625 /* Generate an operation for each mbuf in burst */
11626 for (i = 0; i < burst_len; i++) {
11627 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11629 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11631 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11635 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11637 burst[i]->sym->m_src = m;
11640 /* Process crypto operation */
11641 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11642 0, burst, burst_len),
11644 "Error enqueuing burst");
11646 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11647 0, burst_dequeued, burst_len),
11649 "Error dequeuing burst");
11652 for (i = 0; i < burst_len; i++) {
11654 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11655 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11657 "data not as expected");
11659 rte_pktmbuf_free(burst[i]->sym->m_src);
11660 rte_crypto_op_free(burst[i]);
11663 return TEST_SUCCESS;
11667 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11668 uint16_t nb_ops, void *user_param)
11670 RTE_SET_USED(dev_id);
11671 RTE_SET_USED(qp_id);
11673 RTE_SET_USED(user_param);
11675 printf("crypto enqueue callback called\n");
11680 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11681 uint16_t nb_ops, void *user_param)
11683 RTE_SET_USED(dev_id);
11684 RTE_SET_USED(qp_id);
11686 RTE_SET_USED(user_param);
11688 printf("crypto dequeue callback called\n");
11693 * Thread using enqueue/dequeue callback with RCU.
11696 test_enqdeq_callback_thread(void *arg)
11699 /* DP thread calls rte_cryptodev_enqueue_burst()/
11700 * rte_cryptodev_dequeue_burst() and invokes callback.
11702 test_null_burst_operation();
11707 test_enq_callback_setup(void)
11709 struct crypto_testsuite_params *ts_params = &testsuite_params;
11710 struct rte_cryptodev_info dev_info;
11711 struct rte_cryptodev_qp_conf qp_conf = {
11712 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11715 struct rte_cryptodev_cb *cb;
11716 uint16_t qp_id = 0;
11718 /* Stop the device in case it's started so it can be configured */
11719 rte_cryptodev_stop(ts_params->valid_devs[0]);
11721 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11723 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11725 "Failed to configure cryptodev %u",
11726 ts_params->valid_devs[0]);
11728 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11729 qp_conf.mp_session = ts_params->session_mpool;
11730 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11732 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11733 ts_params->valid_devs[0], qp_id, &qp_conf,
11734 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11736 "rte_cryptodev_queue_pair_setup: num_inflights "
11737 "%u on qp %u on cryptodev %u",
11738 qp_conf.nb_descriptors, qp_id,
11739 ts_params->valid_devs[0]);
11741 /* Test with invalid crypto device */
11742 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11743 qp_id, test_enq_callback, NULL);
11744 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11745 "cryptodev %u did not fail",
11746 qp_id, RTE_CRYPTO_MAX_DEVS);
11748 /* Test with invalid queue pair */
11749 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11750 dev_info.max_nb_queue_pairs + 1,
11751 test_enq_callback, NULL);
11752 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11753 "cryptodev %u did not fail",
11754 dev_info.max_nb_queue_pairs + 1,
11755 ts_params->valid_devs[0]);
11757 /* Test with NULL callback */
11758 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11759 qp_id, NULL, NULL);
11760 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11761 "cryptodev %u did not fail",
11762 qp_id, ts_params->valid_devs[0]);
11764 /* Test with valid configuration */
11765 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11766 qp_id, test_enq_callback, NULL);
11767 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11768 "qp %u on cryptodev %u",
11769 qp_id, ts_params->valid_devs[0]);
11771 rte_cryptodev_start(ts_params->valid_devs[0]);
11773 /* Launch a thread */
11774 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11775 rte_get_next_lcore(-1, 1, 0));
11777 /* Wait until reader exited. */
11778 rte_eal_mp_wait_lcore();
11780 /* Test with invalid crypto device */
11781 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11782 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11783 "Expected call to fail as crypto device is invalid");
11785 /* Test with invalid queue pair */
11786 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11787 ts_params->valid_devs[0],
11788 dev_info.max_nb_queue_pairs + 1, cb),
11789 "Expected call to fail as queue pair is invalid");
11791 /* Test with NULL callback */
11792 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11793 ts_params->valid_devs[0], qp_id, NULL),
11794 "Expected call to fail as callback is NULL");
11796 /* Test with valid configuration */
11797 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11798 ts_params->valid_devs[0], qp_id, cb),
11799 "Failed test to remove callback on "
11800 "qp %u on cryptodev %u",
11801 qp_id, ts_params->valid_devs[0]);
11803 return TEST_SUCCESS;
11807 test_deq_callback_setup(void)
11809 struct crypto_testsuite_params *ts_params = &testsuite_params;
11810 struct rte_cryptodev_info dev_info;
11811 struct rte_cryptodev_qp_conf qp_conf = {
11812 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11815 struct rte_cryptodev_cb *cb;
11816 uint16_t qp_id = 0;
11818 /* Stop the device in case it's started so it can be configured */
11819 rte_cryptodev_stop(ts_params->valid_devs[0]);
11821 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11823 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11825 "Failed to configure cryptodev %u",
11826 ts_params->valid_devs[0]);
11828 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11829 qp_conf.mp_session = ts_params->session_mpool;
11830 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11832 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11833 ts_params->valid_devs[0], qp_id, &qp_conf,
11834 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11836 "rte_cryptodev_queue_pair_setup: num_inflights "
11837 "%u on qp %u on cryptodev %u",
11838 qp_conf.nb_descriptors, qp_id,
11839 ts_params->valid_devs[0]);
11841 /* Test with invalid crypto device */
11842 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11843 qp_id, test_deq_callback, NULL);
11844 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11845 "cryptodev %u did not fail",
11846 qp_id, RTE_CRYPTO_MAX_DEVS);
11848 /* Test with invalid queue pair */
11849 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11850 dev_info.max_nb_queue_pairs + 1,
11851 test_deq_callback, NULL);
11852 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11853 "cryptodev %u did not fail",
11854 dev_info.max_nb_queue_pairs + 1,
11855 ts_params->valid_devs[0]);
11857 /* Test with NULL callback */
11858 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11859 qp_id, NULL, NULL);
11860 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11861 "cryptodev %u did not fail",
11862 qp_id, ts_params->valid_devs[0]);
11864 /* Test with valid configuration */
11865 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11866 qp_id, test_deq_callback, NULL);
11867 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11868 "qp %u on cryptodev %u",
11869 qp_id, ts_params->valid_devs[0]);
11871 rte_cryptodev_start(ts_params->valid_devs[0]);
11873 /* Launch a thread */
11874 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11875 rte_get_next_lcore(-1, 1, 0));
11877 /* Wait until reader exited. */
11878 rte_eal_mp_wait_lcore();
11880 /* Test with invalid crypto device */
11881 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11882 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11883 "Expected call to fail as crypto device is invalid");
11885 /* Test with invalid queue pair */
11886 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11887 ts_params->valid_devs[0],
11888 dev_info.max_nb_queue_pairs + 1, cb),
11889 "Expected call to fail as queue pair is invalid");
11891 /* Test with NULL callback */
11892 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11893 ts_params->valid_devs[0], qp_id, NULL),
11894 "Expected call to fail as callback is NULL");
11896 /* Test with valid configuration */
11897 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11898 ts_params->valid_devs[0], qp_id, cb),
11899 "Failed test to remove callback on "
11900 "qp %u on cryptodev %u",
11901 qp_id, ts_params->valid_devs[0]);
11903 return TEST_SUCCESS;
11907 generate_gmac_large_plaintext(uint8_t *data)
11911 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11912 memcpy(&data[i], &data[0], 32);
11916 create_gmac_operation(enum rte_crypto_auth_operation op,
11917 const struct gmac_test_data *tdata)
11919 struct crypto_testsuite_params *ts_params = &testsuite_params;
11920 struct crypto_unittest_params *ut_params = &unittest_params;
11921 struct rte_crypto_sym_op *sym_op;
11923 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11925 /* Generate Crypto op data structure */
11926 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11927 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11928 TEST_ASSERT_NOT_NULL(ut_params->op,
11929 "Failed to allocate symmetric crypto operation struct");
11931 sym_op = ut_params->op->sym;
11933 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11934 ut_params->ibuf, tdata->gmac_tag.len);
11935 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11936 "no room to append digest");
11938 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11939 ut_params->ibuf, plaintext_pad_len);
11941 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11942 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11943 tdata->gmac_tag.len);
11944 debug_hexdump(stdout, "digest:",
11945 sym_op->auth.digest.data,
11946 tdata->gmac_tag.len);
11949 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11950 uint8_t *, IV_OFFSET);
11952 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11954 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11956 sym_op->cipher.data.length = 0;
11957 sym_op->cipher.data.offset = 0;
11959 sym_op->auth.data.offset = 0;
11960 sym_op->auth.data.length = tdata->plaintext.len;
11966 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11967 const struct gmac_test_data *tdata,
11968 void *digest_mem, uint64_t digest_phys)
11970 struct crypto_testsuite_params *ts_params = &testsuite_params;
11971 struct crypto_unittest_params *ut_params = &unittest_params;
11972 struct rte_crypto_sym_op *sym_op;
11974 /* Generate Crypto op data structure */
11975 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11976 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11977 TEST_ASSERT_NOT_NULL(ut_params->op,
11978 "Failed to allocate symmetric crypto operation struct");
11980 sym_op = ut_params->op->sym;
11982 sym_op->auth.digest.data = digest_mem;
11983 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11984 "no room to append digest");
11986 sym_op->auth.digest.phys_addr = digest_phys;
11988 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11989 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11990 tdata->gmac_tag.len);
11991 debug_hexdump(stdout, "digest:",
11992 sym_op->auth.digest.data,
11993 tdata->gmac_tag.len);
11996 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11997 uint8_t *, IV_OFFSET);
11999 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12001 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12003 sym_op->cipher.data.length = 0;
12004 sym_op->cipher.data.offset = 0;
12006 sym_op->auth.data.offset = 0;
12007 sym_op->auth.data.length = tdata->plaintext.len;
12012 static int create_gmac_session(uint8_t dev_id,
12013 const struct gmac_test_data *tdata,
12014 enum rte_crypto_auth_operation auth_op)
12016 uint8_t auth_key[tdata->key.len];
12018 struct crypto_testsuite_params *ts_params = &testsuite_params;
12019 struct crypto_unittest_params *ut_params = &unittest_params;
12021 memcpy(auth_key, tdata->key.data, tdata->key.len);
12023 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12024 ut_params->auth_xform.next = NULL;
12026 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12027 ut_params->auth_xform.auth.op = auth_op;
12028 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12029 ut_params->auth_xform.auth.key.length = tdata->key.len;
12030 ut_params->auth_xform.auth.key.data = auth_key;
12031 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12032 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12035 ut_params->sess = rte_cryptodev_sym_session_create(
12036 ts_params->session_mpool);
12038 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12039 &ut_params->auth_xform,
12040 ts_params->session_priv_mpool);
12042 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12048 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12050 struct crypto_testsuite_params *ts_params = &testsuite_params;
12051 struct crypto_unittest_params *ut_params = &unittest_params;
12052 struct rte_cryptodev_info dev_info;
12054 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12055 uint64_t feat_flags = dev_info.feature_flags;
12057 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12058 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12059 printf("Device doesn't support RAW data-path APIs.\n");
12060 return TEST_SKIPPED;
12065 uint8_t *auth_tag, *plaintext;
12066 uint16_t plaintext_pad_len;
12068 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12069 "No GMAC length in the source data");
12071 /* Verify the capabilities */
12072 struct rte_cryptodev_sym_capability_idx cap_idx;
12073 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12074 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12075 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12077 return TEST_SKIPPED;
12079 retval = create_gmac_session(ts_params->valid_devs[0],
12080 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12085 if (tdata->plaintext.len > MBUF_SIZE)
12086 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12088 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12089 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12090 "Failed to allocate input buffer in mempool");
12092 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12093 rte_pktmbuf_tailroom(ut_params->ibuf));
12095 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12097 * Runtime generate the large plain text instead of use hard code
12098 * plain text vector. It is done to avoid create huge source file
12099 * with the test vector.
12101 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12102 generate_gmac_large_plaintext(tdata->plaintext.data);
12104 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12105 plaintext_pad_len);
12106 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12108 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12109 debug_hexdump(stdout, "plaintext:", plaintext,
12110 tdata->plaintext.len);
12112 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12118 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12120 ut_params->op->sym->m_src = ut_params->ibuf;
12122 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12123 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12125 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12126 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12127 ut_params->op, 0, 1, 0, 0);
12129 TEST_ASSERT_NOT_NULL(
12130 process_crypto_request(ts_params->valid_devs[0],
12131 ut_params->op), "failed to process sym crypto op");
12133 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12134 "crypto op processing failed");
12136 if (ut_params->op->sym->m_dst) {
12137 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12138 uint8_t *, plaintext_pad_len);
12140 auth_tag = plaintext + plaintext_pad_len;
12143 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12145 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12147 tdata->gmac_tag.data,
12148 tdata->gmac_tag.len,
12149 "GMAC Generated auth tag not as expected");
12155 test_AES_GMAC_authentication_test_case_1(void)
12157 return test_AES_GMAC_authentication(&gmac_test_case_1);
12161 test_AES_GMAC_authentication_test_case_2(void)
12163 return test_AES_GMAC_authentication(&gmac_test_case_2);
12167 test_AES_GMAC_authentication_test_case_3(void)
12169 return test_AES_GMAC_authentication(&gmac_test_case_3);
12173 test_AES_GMAC_authentication_test_case_4(void)
12175 return test_AES_GMAC_authentication(&gmac_test_case_4);
12179 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12181 struct crypto_testsuite_params *ts_params = &testsuite_params;
12182 struct crypto_unittest_params *ut_params = &unittest_params;
12184 uint32_t plaintext_pad_len;
12185 uint8_t *plaintext;
12186 struct rte_cryptodev_info dev_info;
12188 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12189 uint64_t feat_flags = dev_info.feature_flags;
12191 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12192 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12193 printf("Device doesn't support RAW data-path APIs.\n");
12194 return TEST_SKIPPED;
12197 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12198 "No GMAC length in the source data");
12200 /* Verify the capabilities */
12201 struct rte_cryptodev_sym_capability_idx cap_idx;
12202 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12203 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12204 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12206 return TEST_SKIPPED;
12208 retval = create_gmac_session(ts_params->valid_devs[0],
12209 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12214 if (tdata->plaintext.len > MBUF_SIZE)
12215 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12217 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12218 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12219 "Failed to allocate input buffer in mempool");
12221 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12222 rte_pktmbuf_tailroom(ut_params->ibuf));
12224 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12227 * Runtime generate the large plain text instead of use hard code
12228 * plain text vector. It is done to avoid create huge source file
12229 * with the test vector.
12231 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12232 generate_gmac_large_plaintext(tdata->plaintext.data);
12234 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12235 plaintext_pad_len);
12236 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12238 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12239 debug_hexdump(stdout, "plaintext:", plaintext,
12240 tdata->plaintext.len);
12242 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
12248 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12250 ut_params->op->sym->m_src = ut_params->ibuf;
12252 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12253 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12255 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12256 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12257 ut_params->op, 0, 1, 0, 0);
12259 TEST_ASSERT_NOT_NULL(
12260 process_crypto_request(ts_params->valid_devs[0],
12261 ut_params->op), "failed to process sym crypto op");
12263 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12264 "crypto op processing failed");
12271 test_AES_GMAC_authentication_verify_test_case_1(void)
12273 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12277 test_AES_GMAC_authentication_verify_test_case_2(void)
12279 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12283 test_AES_GMAC_authentication_verify_test_case_3(void)
12285 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12289 test_AES_GMAC_authentication_verify_test_case_4(void)
12291 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12295 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12298 struct crypto_testsuite_params *ts_params = &testsuite_params;
12299 struct crypto_unittest_params *ut_params = &unittest_params;
12300 struct rte_cryptodev_info dev_info;
12301 uint64_t feature_flags;
12302 unsigned int trn_data = 0;
12303 void *digest_mem = NULL;
12305 unsigned int to_trn = 0;
12306 struct rte_mbuf *buf = NULL;
12307 uint8_t *auth_tag, *plaintext;
12310 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12311 "No GMAC length in the source data");
12313 /* Verify the capabilities */
12314 struct rte_cryptodev_sym_capability_idx cap_idx;
12315 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12316 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12317 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12319 return TEST_SKIPPED;
12321 /* Check for any input SGL support */
12322 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12323 feature_flags = dev_info.feature_flags;
12325 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12326 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12327 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12328 return TEST_SKIPPED;
12330 if (fragsz > tdata->plaintext.len)
12331 fragsz = tdata->plaintext.len;
12333 uint16_t plaintext_len = fragsz;
12335 retval = create_gmac_session(ts_params->valid_devs[0],
12336 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12341 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12342 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12343 "Failed to allocate input buffer in mempool");
12345 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12346 rte_pktmbuf_tailroom(ut_params->ibuf));
12348 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12350 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12352 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12354 trn_data += plaintext_len;
12356 buf = ut_params->ibuf;
12359 * Loop until no more fragments
12362 while (trn_data < tdata->plaintext.len) {
12364 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12365 (tdata->plaintext.len - trn_data) : fragsz;
12367 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12370 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12371 rte_pktmbuf_tailroom(buf));
12373 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12376 memcpy(plaintext, tdata->plaintext.data + trn_data,
12378 trn_data += to_trn;
12379 if (trn_data == tdata->plaintext.len)
12380 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12381 tdata->gmac_tag.len);
12383 ut_params->ibuf->nb_segs = segs;
12386 * Place digest at the end of the last buffer
12388 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12391 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12392 + tdata->gmac_tag.len);
12393 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12394 tdata->plaintext.len);
12397 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12398 tdata, digest_mem, digest_phys);
12403 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12405 ut_params->op->sym->m_src = ut_params->ibuf;
12407 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12408 return TEST_SKIPPED;
12410 TEST_ASSERT_NOT_NULL(
12411 process_crypto_request(ts_params->valid_devs[0],
12412 ut_params->op), "failed to process sym crypto op");
12414 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12415 "crypto op processing failed");
12417 auth_tag = digest_mem;
12418 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12419 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12421 tdata->gmac_tag.data,
12422 tdata->gmac_tag.len,
12423 "GMAC Generated auth tag not as expected");
12428 /* Segment size not multiple of block size (16B) */
12430 test_AES_GMAC_authentication_SGL_40B(void)
12432 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12436 test_AES_GMAC_authentication_SGL_80B(void)
12438 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12442 test_AES_GMAC_authentication_SGL_2048B(void)
12444 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12447 /* Segment size not multiple of block size (16B) */
12449 test_AES_GMAC_authentication_SGL_2047B(void)
12451 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12454 struct test_crypto_vector {
12455 enum rte_crypto_cipher_algorithm crypto_algo;
12456 unsigned int cipher_offset;
12457 unsigned int cipher_len;
12470 const uint8_t *data;
12475 const uint8_t *data;
12479 enum rte_crypto_auth_algorithm auth_algo;
12480 unsigned int auth_offset;
12488 const uint8_t *data;
12498 static const struct test_crypto_vector
12499 hmac_sha1_test_crypto_vector = {
12500 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12502 .data = plaintext_hash,
12507 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12508 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12509 0xDE, 0xF4, 0xDE, 0xAD
12515 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12516 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12517 0x3F, 0x91, 0x64, 0x59
12523 static const struct test_crypto_vector
12524 aes128_gmac_test_vector = {
12525 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12527 .data = plaintext_hash,
12532 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12533 0x08, 0x09, 0x0A, 0x0B
12539 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12540 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12546 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12547 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12553 static const struct test_crypto_vector
12554 aes128cbc_hmac_sha1_test_vector = {
12555 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12556 .cipher_offset = 0,
12560 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12561 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12567 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12568 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12573 .data = plaintext_hash,
12577 .data = ciphertext512_aes128cbc,
12580 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12584 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12585 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12586 0xDE, 0xF4, 0xDE, 0xAD
12592 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12593 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12594 0x18, 0x8C, 0x1D, 0x32
12600 static const struct test_crypto_vector
12601 aes128cbc_hmac_sha1_aad_test_vector = {
12602 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12603 .cipher_offset = 8,
12607 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12608 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12614 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12615 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12620 .data = plaintext_hash,
12624 .data = ciphertext512_aes128cbc_aad,
12627 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12631 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12632 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12633 0xDE, 0xF4, 0xDE, 0xAD
12639 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12640 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12641 0x62, 0x0F, 0xFB, 0x10
12648 data_corruption(uint8_t *data)
12654 tag_corruption(uint8_t *data, unsigned int tag_offset)
12656 data[tag_offset] += 1;
12660 create_auth_session(struct crypto_unittest_params *ut_params,
12662 const struct test_crypto_vector *reference,
12663 enum rte_crypto_auth_operation auth_op)
12665 struct crypto_testsuite_params *ts_params = &testsuite_params;
12666 uint8_t auth_key[reference->auth_key.len + 1];
12668 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12670 /* Setup Authentication Parameters */
12671 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12672 ut_params->auth_xform.auth.op = auth_op;
12673 ut_params->auth_xform.next = NULL;
12674 ut_params->auth_xform.auth.algo = reference->auth_algo;
12675 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12676 ut_params->auth_xform.auth.key.data = auth_key;
12677 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12679 /* Create Crypto session*/
12680 ut_params->sess = rte_cryptodev_sym_session_create(
12681 ts_params->session_mpool);
12683 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12684 &ut_params->auth_xform,
12685 ts_params->session_priv_mpool);
12687 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12693 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12695 const struct test_crypto_vector *reference,
12696 enum rte_crypto_auth_operation auth_op,
12697 enum rte_crypto_cipher_operation cipher_op)
12699 struct crypto_testsuite_params *ts_params = &testsuite_params;
12700 uint8_t cipher_key[reference->cipher_key.len + 1];
12701 uint8_t auth_key[reference->auth_key.len + 1];
12703 memcpy(cipher_key, reference->cipher_key.data,
12704 reference->cipher_key.len);
12705 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12707 /* Setup Authentication Parameters */
12708 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12709 ut_params->auth_xform.auth.op = auth_op;
12710 ut_params->auth_xform.auth.algo = reference->auth_algo;
12711 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12712 ut_params->auth_xform.auth.key.data = auth_key;
12713 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12715 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12716 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12717 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12719 ut_params->auth_xform.next = &ut_params->cipher_xform;
12721 /* Setup Cipher Parameters */
12722 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12723 ut_params->cipher_xform.next = NULL;
12724 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12725 ut_params->cipher_xform.cipher.op = cipher_op;
12726 ut_params->cipher_xform.cipher.key.data = cipher_key;
12727 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12728 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12729 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12732 /* Create Crypto session*/
12733 ut_params->sess = rte_cryptodev_sym_session_create(
12734 ts_params->session_mpool);
12736 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12737 &ut_params->auth_xform,
12738 ts_params->session_priv_mpool);
12740 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12746 create_auth_operation(struct crypto_testsuite_params *ts_params,
12747 struct crypto_unittest_params *ut_params,
12748 const struct test_crypto_vector *reference,
12749 unsigned int auth_generate)
12751 /* Generate Crypto op data structure */
12752 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12753 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12754 TEST_ASSERT_NOT_NULL(ut_params->op,
12755 "Failed to allocate pktmbuf offload");
12757 /* Set crypto operation data parameters */
12758 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12760 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12762 /* set crypto operation source mbuf */
12763 sym_op->m_src = ut_params->ibuf;
12766 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12767 ut_params->ibuf, reference->digest.len);
12769 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12770 "no room to append auth tag");
12772 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12773 ut_params->ibuf, reference->plaintext.len);
12776 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12778 memcpy(sym_op->auth.digest.data,
12779 reference->digest.data,
12780 reference->digest.len);
12782 debug_hexdump(stdout, "digest:",
12783 sym_op->auth.digest.data,
12784 reference->digest.len);
12786 sym_op->auth.data.length = reference->plaintext.len;
12787 sym_op->auth.data.offset = 0;
12793 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12794 struct crypto_unittest_params *ut_params,
12795 const struct test_crypto_vector *reference,
12796 unsigned int auth_generate)
12798 /* Generate Crypto op data structure */
12799 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12800 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12801 TEST_ASSERT_NOT_NULL(ut_params->op,
12802 "Failed to allocate pktmbuf offload");
12804 /* Set crypto operation data parameters */
12805 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12807 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12809 /* set crypto operation source mbuf */
12810 sym_op->m_src = ut_params->ibuf;
12813 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12814 ut_params->ibuf, reference->digest.len);
12816 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12817 "no room to append auth tag");
12819 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12820 ut_params->ibuf, reference->ciphertext.len);
12823 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12825 memcpy(sym_op->auth.digest.data,
12826 reference->digest.data,
12827 reference->digest.len);
12829 debug_hexdump(stdout, "digest:",
12830 sym_op->auth.digest.data,
12831 reference->digest.len);
12833 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12834 reference->iv.data, reference->iv.len);
12836 sym_op->cipher.data.length = 0;
12837 sym_op->cipher.data.offset = 0;
12839 sym_op->auth.data.length = reference->plaintext.len;
12840 sym_op->auth.data.offset = 0;
12846 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12847 struct crypto_unittest_params *ut_params,
12848 const struct test_crypto_vector *reference,
12849 unsigned int auth_generate)
12851 /* Generate Crypto op data structure */
12852 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12853 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12854 TEST_ASSERT_NOT_NULL(ut_params->op,
12855 "Failed to allocate pktmbuf offload");
12857 /* Set crypto operation data parameters */
12858 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12860 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12862 /* set crypto operation source mbuf */
12863 sym_op->m_src = ut_params->ibuf;
12866 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12867 ut_params->ibuf, reference->digest.len);
12869 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12870 "no room to append auth tag");
12872 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12873 ut_params->ibuf, reference->ciphertext.len);
12876 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12878 memcpy(sym_op->auth.digest.data,
12879 reference->digest.data,
12880 reference->digest.len);
12882 debug_hexdump(stdout, "digest:",
12883 sym_op->auth.digest.data,
12884 reference->digest.len);
12886 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12887 reference->iv.data, reference->iv.len);
12889 sym_op->cipher.data.length = reference->cipher_len;
12890 sym_op->cipher.data.offset = reference->cipher_offset;
12892 sym_op->auth.data.length = reference->plaintext.len;
12893 sym_op->auth.data.offset = reference->auth_offset;
12899 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12900 struct crypto_unittest_params *ut_params,
12901 const struct test_crypto_vector *reference)
12903 return create_auth_operation(ts_params, ut_params, reference, 0);
12907 create_auth_verify_GMAC_operation(
12908 struct crypto_testsuite_params *ts_params,
12909 struct crypto_unittest_params *ut_params,
12910 const struct test_crypto_vector *reference)
12912 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12916 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12917 struct crypto_unittest_params *ut_params,
12918 const struct test_crypto_vector *reference)
12920 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12924 test_authentication_verify_fail_when_data_corruption(
12925 struct crypto_testsuite_params *ts_params,
12926 struct crypto_unittest_params *ut_params,
12927 const struct test_crypto_vector *reference,
12928 unsigned int data_corrupted)
12932 uint8_t *plaintext;
12933 struct rte_cryptodev_info dev_info;
12935 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12936 uint64_t feat_flags = dev_info.feature_flags;
12938 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12939 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12940 printf("Device doesn't support RAW data-path APIs.\n");
12941 return TEST_SKIPPED;
12944 /* Verify the capabilities */
12945 struct rte_cryptodev_sym_capability_idx cap_idx;
12946 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12947 cap_idx.algo.auth = reference->auth_algo;
12948 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12950 return TEST_SKIPPED;
12953 /* Create session */
12954 retval = create_auth_session(ut_params,
12955 ts_params->valid_devs[0],
12957 RTE_CRYPTO_AUTH_OP_VERIFY);
12961 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12962 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12963 "Failed to allocate input buffer in mempool");
12965 /* clear mbuf payload */
12966 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12967 rte_pktmbuf_tailroom(ut_params->ibuf));
12969 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12970 reference->plaintext.len);
12971 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12972 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12974 debug_hexdump(stdout, "plaintext:", plaintext,
12975 reference->plaintext.len);
12977 /* Create operation */
12978 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12983 if (data_corrupted)
12984 data_corruption(plaintext);
12986 tag_corruption(plaintext, reference->plaintext.len);
12988 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12989 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12991 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12992 RTE_CRYPTO_OP_STATUS_SUCCESS,
12993 "authentication not failed");
12994 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12995 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12996 ut_params->op, 0, 1, 0, 0);
12998 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13000 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13007 test_authentication_verify_GMAC_fail_when_corruption(
13008 struct crypto_testsuite_params *ts_params,
13009 struct crypto_unittest_params *ut_params,
13010 const struct test_crypto_vector *reference,
13011 unsigned int data_corrupted)
13014 uint8_t *plaintext;
13015 struct rte_cryptodev_info dev_info;
13017 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13018 uint64_t feat_flags = dev_info.feature_flags;
13020 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13021 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13022 printf("Device doesn't support RAW data-path APIs.\n");
13023 return TEST_SKIPPED;
13026 /* Verify the capabilities */
13027 struct rte_cryptodev_sym_capability_idx cap_idx;
13028 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13029 cap_idx.algo.auth = reference->auth_algo;
13030 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13032 return TEST_SKIPPED;
13034 /* Create session */
13035 retval = create_auth_cipher_session(ut_params,
13036 ts_params->valid_devs[0],
13038 RTE_CRYPTO_AUTH_OP_VERIFY,
13039 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13043 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13044 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13045 "Failed to allocate input buffer in mempool");
13047 /* clear mbuf payload */
13048 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13049 rte_pktmbuf_tailroom(ut_params->ibuf));
13051 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13052 reference->plaintext.len);
13053 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13054 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13056 debug_hexdump(stdout, "plaintext:", plaintext,
13057 reference->plaintext.len);
13059 /* Create operation */
13060 retval = create_auth_verify_GMAC_operation(ts_params,
13067 if (data_corrupted)
13068 data_corruption(plaintext);
13070 tag_corruption(plaintext, reference->aad.len);
13072 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13073 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13075 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13076 RTE_CRYPTO_OP_STATUS_SUCCESS,
13077 "authentication not failed");
13078 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13079 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13080 ut_params->op, 0, 1, 0, 0);
13082 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13084 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13091 test_authenticated_decryption_fail_when_corruption(
13092 struct crypto_testsuite_params *ts_params,
13093 struct crypto_unittest_params *ut_params,
13094 const struct test_crypto_vector *reference,
13095 unsigned int data_corrupted)
13099 uint8_t *ciphertext;
13100 struct rte_cryptodev_info dev_info;
13102 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13103 uint64_t feat_flags = dev_info.feature_flags;
13105 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13106 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13107 printf("Device doesn't support RAW data-path APIs.\n");
13108 return TEST_SKIPPED;
13111 /* Verify the capabilities */
13112 struct rte_cryptodev_sym_capability_idx cap_idx;
13113 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13114 cap_idx.algo.auth = reference->auth_algo;
13115 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13117 return TEST_SKIPPED;
13118 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13119 cap_idx.algo.cipher = reference->crypto_algo;
13120 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13122 return TEST_SKIPPED;
13124 /* Create session */
13125 retval = create_auth_cipher_session(ut_params,
13126 ts_params->valid_devs[0],
13128 RTE_CRYPTO_AUTH_OP_VERIFY,
13129 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13133 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13134 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13135 "Failed to allocate input buffer in mempool");
13137 /* clear mbuf payload */
13138 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13139 rte_pktmbuf_tailroom(ut_params->ibuf));
13141 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13142 reference->ciphertext.len);
13143 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13144 memcpy(ciphertext, reference->ciphertext.data,
13145 reference->ciphertext.len);
13147 /* Create operation */
13148 retval = create_cipher_auth_verify_operation(ts_params,
13155 if (data_corrupted)
13156 data_corruption(ciphertext);
13158 tag_corruption(ciphertext, reference->ciphertext.len);
13160 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13161 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13163 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13164 RTE_CRYPTO_OP_STATUS_SUCCESS,
13165 "authentication not failed");
13166 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13167 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13168 ut_params->op, 1, 1, 0, 0);
13170 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13172 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13179 test_authenticated_encrypt_with_esn(
13180 struct crypto_testsuite_params *ts_params,
13181 struct crypto_unittest_params *ut_params,
13182 const struct test_crypto_vector *reference)
13186 uint8_t *authciphertext, *plaintext, *auth_tag;
13187 uint16_t plaintext_pad_len;
13188 uint8_t cipher_key[reference->cipher_key.len + 1];
13189 uint8_t auth_key[reference->auth_key.len + 1];
13190 struct rte_cryptodev_info dev_info;
13192 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13193 uint64_t feat_flags = dev_info.feature_flags;
13195 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13196 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13197 printf("Device doesn't support RAW data-path APIs.\n");
13198 return TEST_SKIPPED;
13201 /* Verify the capabilities */
13202 struct rte_cryptodev_sym_capability_idx cap_idx;
13203 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13204 cap_idx.algo.auth = reference->auth_algo;
13205 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13207 return TEST_SKIPPED;
13208 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13209 cap_idx.algo.cipher = reference->crypto_algo;
13210 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13212 return TEST_SKIPPED;
13214 /* Create session */
13215 memcpy(cipher_key, reference->cipher_key.data,
13216 reference->cipher_key.len);
13217 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13219 /* Setup Cipher Parameters */
13220 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13221 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13222 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13223 ut_params->cipher_xform.cipher.key.data = cipher_key;
13224 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13225 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13226 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13228 ut_params->cipher_xform.next = &ut_params->auth_xform;
13230 /* Setup Authentication Parameters */
13231 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13232 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13233 ut_params->auth_xform.auth.algo = reference->auth_algo;
13234 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13235 ut_params->auth_xform.auth.key.data = auth_key;
13236 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13237 ut_params->auth_xform.next = NULL;
13239 /* Create Crypto session*/
13240 ut_params->sess = rte_cryptodev_sym_session_create(
13241 ts_params->session_mpool);
13243 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13245 &ut_params->cipher_xform,
13246 ts_params->session_priv_mpool);
13248 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13251 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13252 "Failed to allocate input buffer in mempool");
13254 /* clear mbuf payload */
13255 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13256 rte_pktmbuf_tailroom(ut_params->ibuf));
13258 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13259 reference->plaintext.len);
13260 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13261 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13263 /* Create operation */
13264 retval = create_cipher_auth_operation(ts_params,
13271 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13272 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13274 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13275 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13276 ut_params->op, 1, 1, 0, 0);
13278 ut_params->op = process_crypto_request(
13279 ts_params->valid_devs[0], ut_params->op);
13281 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13283 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13284 "crypto op processing failed");
13286 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13288 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13289 ut_params->op->sym->auth.data.offset);
13290 auth_tag = authciphertext + plaintext_pad_len;
13291 debug_hexdump(stdout, "ciphertext:", authciphertext,
13292 reference->ciphertext.len);
13293 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13295 /* Validate obuf */
13296 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13298 reference->ciphertext.data,
13299 reference->ciphertext.len,
13300 "Ciphertext data not as expected");
13302 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13304 reference->digest.data,
13305 reference->digest.len,
13306 "Generated digest not as expected");
13308 return TEST_SUCCESS;
13313 test_authenticated_decrypt_with_esn(
13314 struct crypto_testsuite_params *ts_params,
13315 struct crypto_unittest_params *ut_params,
13316 const struct test_crypto_vector *reference)
13320 uint8_t *ciphertext;
13321 uint8_t cipher_key[reference->cipher_key.len + 1];
13322 uint8_t auth_key[reference->auth_key.len + 1];
13323 struct rte_cryptodev_info dev_info;
13325 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13326 uint64_t feat_flags = dev_info.feature_flags;
13328 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13329 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13330 printf("Device doesn't support RAW data-path APIs.\n");
13331 return TEST_SKIPPED;
13334 /* Verify the capabilities */
13335 struct rte_cryptodev_sym_capability_idx cap_idx;
13336 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13337 cap_idx.algo.auth = reference->auth_algo;
13338 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13340 return TEST_SKIPPED;
13341 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13342 cap_idx.algo.cipher = reference->crypto_algo;
13343 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13345 return TEST_SKIPPED;
13347 /* Create session */
13348 memcpy(cipher_key, reference->cipher_key.data,
13349 reference->cipher_key.len);
13350 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13352 /* Setup Authentication Parameters */
13353 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13354 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13355 ut_params->auth_xform.auth.algo = reference->auth_algo;
13356 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13357 ut_params->auth_xform.auth.key.data = auth_key;
13358 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13359 ut_params->auth_xform.next = &ut_params->cipher_xform;
13361 /* Setup Cipher Parameters */
13362 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13363 ut_params->cipher_xform.next = NULL;
13364 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13365 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13366 ut_params->cipher_xform.cipher.key.data = cipher_key;
13367 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13368 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13369 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13371 /* Create Crypto session*/
13372 ut_params->sess = rte_cryptodev_sym_session_create(
13373 ts_params->session_mpool);
13375 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13377 &ut_params->auth_xform,
13378 ts_params->session_priv_mpool);
13380 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13382 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13383 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13384 "Failed to allocate input buffer in mempool");
13386 /* clear mbuf payload */
13387 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13388 rte_pktmbuf_tailroom(ut_params->ibuf));
13390 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13391 reference->ciphertext.len);
13392 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13393 memcpy(ciphertext, reference->ciphertext.data,
13394 reference->ciphertext.len);
13396 /* Create operation */
13397 retval = create_cipher_auth_verify_operation(ts_params,
13404 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13405 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13407 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13408 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13409 ut_params->op, 1, 1, 0, 0);
13411 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13414 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13415 TEST_ASSERT_EQUAL(ut_params->op->status,
13416 RTE_CRYPTO_OP_STATUS_SUCCESS,
13417 "crypto op processing passed");
13419 ut_params->obuf = ut_params->op->sym->m_src;
13420 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13426 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13427 const struct aead_test_data *tdata,
13428 void *digest_mem, uint64_t digest_phys)
13430 struct crypto_testsuite_params *ts_params = &testsuite_params;
13431 struct crypto_unittest_params *ut_params = &unittest_params;
13433 const unsigned int auth_tag_len = tdata->auth_tag.len;
13434 const unsigned int iv_len = tdata->iv.len;
13435 unsigned int aad_len = tdata->aad.len;
13436 unsigned int aad_len_pad = 0;
13438 /* Generate Crypto op data structure */
13439 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13440 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13441 TEST_ASSERT_NOT_NULL(ut_params->op,
13442 "Failed to allocate symmetric crypto operation struct");
13444 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13446 sym_op->aead.digest.data = digest_mem;
13448 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13449 "no room to append digest");
13451 sym_op->aead.digest.phys_addr = digest_phys;
13453 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13454 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13456 debug_hexdump(stdout, "digest:",
13457 sym_op->aead.digest.data,
13461 /* Append aad data */
13462 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13463 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13464 uint8_t *, IV_OFFSET);
13466 /* Copy IV 1 byte after the IV pointer, according to the API */
13467 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13469 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13471 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13472 ut_params->ibuf, aad_len);
13473 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13474 "no room to prepend aad");
13475 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13478 memset(sym_op->aead.aad.data, 0, aad_len);
13479 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
13480 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13482 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13483 debug_hexdump(stdout, "aad:",
13484 sym_op->aead.aad.data, aad_len);
13486 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13487 uint8_t *, IV_OFFSET);
13489 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13491 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13493 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13494 ut_params->ibuf, aad_len_pad);
13495 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13496 "no room to prepend aad");
13497 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13500 memset(sym_op->aead.aad.data, 0, aad_len);
13501 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13503 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13504 debug_hexdump(stdout, "aad:",
13505 sym_op->aead.aad.data, aad_len);
13508 sym_op->aead.data.length = tdata->plaintext.len;
13509 sym_op->aead.data.offset = aad_len_pad;
13514 #define SGL_MAX_NO 16
13517 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13518 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13520 struct crypto_testsuite_params *ts_params = &testsuite_params;
13521 struct crypto_unittest_params *ut_params = &unittest_params;
13522 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13525 int to_trn_tbl[SGL_MAX_NO];
13527 unsigned int trn_data = 0;
13528 uint8_t *plaintext, *ciphertext, *auth_tag;
13529 struct rte_cryptodev_info dev_info;
13531 /* Verify the capabilities */
13532 struct rte_cryptodev_sym_capability_idx cap_idx;
13533 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13534 cap_idx.algo.aead = tdata->algo;
13535 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13537 return TEST_SKIPPED;
13539 /* OOP not supported with CPU crypto */
13540 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13541 return TEST_SKIPPED;
13543 /* Detailed check for the particular SGL support flag */
13544 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13546 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13547 if (sgl_in && (!(dev_info.feature_flags &
13548 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13549 return TEST_SKIPPED;
13551 uint64_t feat_flags = dev_info.feature_flags;
13553 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13554 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13555 printf("Device doesn't support RAW data-path APIs.\n");
13556 return TEST_SKIPPED;
13559 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13560 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13561 tdata->plaintext.len;
13562 /* Raw data path API does not support OOP */
13563 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13564 return TEST_SKIPPED;
13565 if (sgl_in && !sgl_out) {
13566 if (!(dev_info.feature_flags &
13567 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13568 return TEST_SKIPPED;
13569 } else if (!sgl_in && sgl_out) {
13570 if (!(dev_info.feature_flags &
13571 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13572 return TEST_SKIPPED;
13573 } else if (sgl_in && sgl_out) {
13574 if (!(dev_info.feature_flags &
13575 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13576 return TEST_SKIPPED;
13580 if (fragsz > tdata->plaintext.len)
13581 fragsz = tdata->plaintext.len;
13583 uint16_t plaintext_len = fragsz;
13584 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13586 if (fragsz_oop > tdata->plaintext.len)
13587 frag_size_oop = tdata->plaintext.len;
13590 void *digest_mem = NULL;
13592 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13594 if (tdata->plaintext.len % fragsz != 0) {
13595 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13598 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13603 * For out-op-place we need to alloc another mbuf
13606 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13607 rte_pktmbuf_append(ut_params->obuf,
13608 frag_size_oop + prepend_len);
13609 buf_oop = ut_params->obuf;
13612 /* Create AEAD session */
13613 retval = create_aead_session(ts_params->valid_devs[0],
13615 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13616 tdata->key.data, tdata->key.len,
13617 tdata->aad.len, tdata->auth_tag.len,
13622 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13624 /* clear mbuf payload */
13625 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13626 rte_pktmbuf_tailroom(ut_params->ibuf));
13628 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13631 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13633 trn_data += plaintext_len;
13635 buf = ut_params->ibuf;
13638 * Loop until no more fragments
13641 while (trn_data < tdata->plaintext.len) {
13643 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13644 (tdata->plaintext.len - trn_data) : fragsz;
13646 to_trn_tbl[ecx++] = to_trn;
13648 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13651 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13652 rte_pktmbuf_tailroom(buf));
13655 if (oop && !fragsz_oop) {
13656 buf_last_oop = buf_oop->next =
13657 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13658 buf_oop = buf_oop->next;
13659 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13660 0, rte_pktmbuf_tailroom(buf_oop));
13661 rte_pktmbuf_append(buf_oop, to_trn);
13664 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13667 memcpy(plaintext, tdata->plaintext.data + trn_data,
13669 trn_data += to_trn;
13670 if (trn_data == tdata->plaintext.len) {
13673 digest_mem = rte_pktmbuf_append(buf_oop,
13674 tdata->auth_tag.len);
13676 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13677 tdata->auth_tag.len);
13681 uint64_t digest_phys = 0;
13683 ut_params->ibuf->nb_segs = segs;
13686 if (fragsz_oop && oop) {
13690 if (frag_size_oop == tdata->plaintext.len) {
13691 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13692 tdata->auth_tag.len);
13694 digest_phys = rte_pktmbuf_iova_offset(
13696 tdata->plaintext.len + prepend_len);
13699 trn_data = frag_size_oop;
13700 while (trn_data < tdata->plaintext.len) {
13703 (tdata->plaintext.len - trn_data <
13705 (tdata->plaintext.len - trn_data) :
13708 to_trn_tbl[ecx++] = to_trn;
13710 buf_last_oop = buf_oop->next =
13711 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13712 buf_oop = buf_oop->next;
13713 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13714 0, rte_pktmbuf_tailroom(buf_oop));
13715 rte_pktmbuf_append(buf_oop, to_trn);
13717 trn_data += to_trn;
13719 if (trn_data == tdata->plaintext.len) {
13720 digest_mem = rte_pktmbuf_append(buf_oop,
13721 tdata->auth_tag.len);
13725 ut_params->obuf->nb_segs = segs;
13729 * Place digest at the end of the last buffer
13732 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13733 if (oop && buf_last_oop)
13734 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13736 if (!digest_mem && !oop) {
13737 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13738 + tdata->auth_tag.len);
13739 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13740 tdata->plaintext.len);
13743 /* Create AEAD operation */
13744 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13745 tdata, digest_mem, digest_phys);
13750 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13752 ut_params->op->sym->m_src = ut_params->ibuf;
13754 ut_params->op->sym->m_dst = ut_params->obuf;
13756 /* Process crypto operation */
13757 if (oop == IN_PLACE &&
13758 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13759 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13760 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13761 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13762 ut_params->op, 0, 0, 0, 0);
13764 TEST_ASSERT_NOT_NULL(
13765 process_crypto_request(ts_params->valid_devs[0],
13766 ut_params->op), "failed to process sym crypto op");
13768 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13769 "crypto op processing failed");
13772 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13773 uint8_t *, prepend_len);
13775 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13776 uint8_t *, prepend_len);
13780 fragsz = fragsz_oop;
13782 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13784 tdata->ciphertext.data,
13786 "Ciphertext data not as expected");
13788 buf = ut_params->op->sym->m_src->next;
13790 buf = ut_params->op->sym->m_dst->next;
13792 unsigned int off = fragsz;
13796 ciphertext = rte_pktmbuf_mtod(buf,
13799 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13801 tdata->ciphertext.data + off,
13803 "Ciphertext data not as expected");
13805 off += to_trn_tbl[ecx++];
13809 auth_tag = digest_mem;
13810 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13812 tdata->auth_tag.data,
13813 tdata->auth_tag.len,
13814 "Generated auth tag not as expected");
13820 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13822 return test_authenticated_encryption_SGL(
13823 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13827 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13829 return test_authenticated_encryption_SGL(
13830 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13834 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13836 return test_authenticated_encryption_SGL(
13837 &gcm_test_case_8, OUT_OF_PLACE, 400,
13838 gcm_test_case_8.plaintext.len);
13842 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13844 /* This test is not for OPENSSL PMD */
13845 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13846 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13847 return TEST_SKIPPED;
13849 return test_authenticated_encryption_SGL(
13850 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13854 test_authentication_verify_fail_when_data_corrupted(
13855 struct crypto_testsuite_params *ts_params,
13856 struct crypto_unittest_params *ut_params,
13857 const struct test_crypto_vector *reference)
13859 return test_authentication_verify_fail_when_data_corruption(
13860 ts_params, ut_params, reference, 1);
13864 test_authentication_verify_fail_when_tag_corrupted(
13865 struct crypto_testsuite_params *ts_params,
13866 struct crypto_unittest_params *ut_params,
13867 const struct test_crypto_vector *reference)
13869 return test_authentication_verify_fail_when_data_corruption(
13870 ts_params, ut_params, reference, 0);
13874 test_authentication_verify_GMAC_fail_when_data_corrupted(
13875 struct crypto_testsuite_params *ts_params,
13876 struct crypto_unittest_params *ut_params,
13877 const struct test_crypto_vector *reference)
13879 return test_authentication_verify_GMAC_fail_when_corruption(
13880 ts_params, ut_params, reference, 1);
13884 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13885 struct crypto_testsuite_params *ts_params,
13886 struct crypto_unittest_params *ut_params,
13887 const struct test_crypto_vector *reference)
13889 return test_authentication_verify_GMAC_fail_when_corruption(
13890 ts_params, ut_params, reference, 0);
13894 test_authenticated_decryption_fail_when_data_corrupted(
13895 struct crypto_testsuite_params *ts_params,
13896 struct crypto_unittest_params *ut_params,
13897 const struct test_crypto_vector *reference)
13899 return test_authenticated_decryption_fail_when_corruption(
13900 ts_params, ut_params, reference, 1);
13904 test_authenticated_decryption_fail_when_tag_corrupted(
13905 struct crypto_testsuite_params *ts_params,
13906 struct crypto_unittest_params *ut_params,
13907 const struct test_crypto_vector *reference)
13909 return test_authenticated_decryption_fail_when_corruption(
13910 ts_params, ut_params, reference, 0);
13914 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13916 return test_authentication_verify_fail_when_data_corrupted(
13917 &testsuite_params, &unittest_params,
13918 &hmac_sha1_test_crypto_vector);
13922 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13924 return test_authentication_verify_fail_when_tag_corrupted(
13925 &testsuite_params, &unittest_params,
13926 &hmac_sha1_test_crypto_vector);
13930 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13932 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13933 &testsuite_params, &unittest_params,
13934 &aes128_gmac_test_vector);
13938 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13940 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13941 &testsuite_params, &unittest_params,
13942 &aes128_gmac_test_vector);
13946 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13948 return test_authenticated_decryption_fail_when_data_corrupted(
13951 &aes128cbc_hmac_sha1_test_vector);
13955 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13957 return test_authenticated_decryption_fail_when_tag_corrupted(
13960 &aes128cbc_hmac_sha1_test_vector);
13964 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13966 return test_authenticated_encrypt_with_esn(
13969 &aes128cbc_hmac_sha1_aad_test_vector);
13973 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13975 return test_authenticated_decrypt_with_esn(
13978 &aes128cbc_hmac_sha1_aad_test_vector);
13982 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13984 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13988 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13990 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13993 #ifdef RTE_CRYPTO_SCHEDULER
13995 /* global AESNI worker IDs for the scheduler test */
13996 uint8_t aesni_ids[2];
13999 scheduler_testsuite_setup(void)
14002 int32_t nb_devs, ret;
14003 char vdev_args[VDEV_ARGS_SIZE] = {""};
14004 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14005 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
14006 uint16_t worker_core_count = 0;
14007 uint16_t socket_id = 0;
14009 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14010 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14012 /* Identify the Worker Cores
14013 * Use 2 worker cores for the device args
14015 RTE_LCORE_FOREACH_WORKER(i) {
14016 if (worker_core_count > 1)
14018 snprintf(vdev_args, sizeof(vdev_args),
14019 "%s%d", temp_str, i);
14020 strcpy(temp_str, vdev_args);
14021 strlcat(temp_str, ";", sizeof(temp_str));
14022 worker_core_count++;
14023 socket_id = rte_lcore_to_socket_id(i);
14025 if (worker_core_count != 2) {
14026 RTE_LOG(ERR, USER1,
14027 "Cryptodev scheduler test require at least "
14028 "two worker cores to run. "
14029 "Please use the correct coremask.\n");
14030 return TEST_FAILED;
14032 strcpy(temp_str, vdev_args);
14033 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14034 temp_str, socket_id);
14035 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14036 nb_devs = rte_cryptodev_device_count_by_driver(
14037 rte_cryptodev_driver_id_get(
14038 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14040 ret = rte_vdev_init(
14041 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14043 TEST_ASSERT(ret == 0,
14044 "Failed to create instance %u of pmd : %s",
14045 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14048 return testsuite_setup();
14052 test_scheduler_attach_worker_op(void)
14054 struct crypto_testsuite_params *ts_params = &testsuite_params;
14055 uint8_t sched_id = ts_params->valid_devs[0];
14056 uint32_t i, nb_devs_attached = 0;
14058 char vdev_name[32];
14059 unsigned int count = rte_cryptodev_count();
14061 /* create 2 AESNI_MB vdevs on top of existing devices */
14062 for (i = count; i < count + 2; i++) {
14063 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14064 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14066 ret = rte_vdev_init(vdev_name, NULL);
14068 TEST_ASSERT(ret == 0,
14069 "Failed to create instance %u of"
14071 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14074 RTE_LOG(ERR, USER1,
14075 "Failed to create 2 AESNI MB PMDs.\n");
14076 return TEST_SKIPPED;
14080 /* attach 2 AESNI_MB cdevs */
14081 for (i = count; i < count + 2; i++) {
14082 struct rte_cryptodev_info info;
14083 unsigned int session_size;
14085 rte_cryptodev_info_get(i, &info);
14086 if (info.driver_id != rte_cryptodev_driver_id_get(
14087 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14090 session_size = rte_cryptodev_sym_get_private_session_size(i);
14092 * Create the session mempool again, since now there are new devices
14093 * to use the mempool.
14095 if (ts_params->session_mpool) {
14096 rte_mempool_free(ts_params->session_mpool);
14097 ts_params->session_mpool = NULL;
14099 if (ts_params->session_priv_mpool) {
14100 rte_mempool_free(ts_params->session_priv_mpool);
14101 ts_params->session_priv_mpool = NULL;
14104 if (info.sym.max_nb_sessions != 0 &&
14105 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14106 RTE_LOG(ERR, USER1,
14107 "Device does not support "
14108 "at least %u sessions\n",
14110 return TEST_FAILED;
14113 * Create mempool with maximum number of sessions,
14114 * to include the session headers
14116 if (ts_params->session_mpool == NULL) {
14117 ts_params->session_mpool =
14118 rte_cryptodev_sym_session_pool_create(
14120 MAX_NB_SESSIONS, 0, 0, 0,
14122 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14123 "session mempool allocation failed");
14127 * Create mempool with maximum number of sessions,
14128 * to include device specific session private data
14130 if (ts_params->session_priv_mpool == NULL) {
14131 ts_params->session_priv_mpool = rte_mempool_create(
14132 "test_sess_mp_priv",
14135 0, 0, NULL, NULL, NULL,
14136 NULL, SOCKET_ID_ANY,
14139 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14140 "session mempool allocation failed");
14143 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14144 ts_params->qp_conf.mp_session_private =
14145 ts_params->session_priv_mpool;
14147 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14150 TEST_ASSERT(ret == 0,
14151 "Failed to attach device %u of pmd : %s", i,
14152 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14154 aesni_ids[nb_devs_attached] = (uint8_t)i;
14156 nb_devs_attached++;
14163 test_scheduler_detach_worker_op(void)
14165 struct crypto_testsuite_params *ts_params = &testsuite_params;
14166 uint8_t sched_id = ts_params->valid_devs[0];
14170 for (i = 0; i < 2; i++) {
14171 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14173 TEST_ASSERT(ret == 0,
14174 "Failed to detach device %u", aesni_ids[i]);
14181 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14183 struct crypto_testsuite_params *ts_params = &testsuite_params;
14184 uint8_t sched_id = ts_params->valid_devs[0];
14186 return rte_cryptodev_scheduler_mode_set(sched_id,
14191 test_scheduler_mode_roundrobin_op(void)
14193 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14194 0, "Failed to set roundrobin mode");
14200 test_scheduler_mode_multicore_op(void)
14202 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14203 0, "Failed to set multicore mode");
14209 test_scheduler_mode_failover_op(void)
14211 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
14212 0, "Failed to set failover mode");
14218 test_scheduler_mode_pkt_size_distr_op(void)
14220 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
14221 0, "Failed to set pktsize mode");
14227 scheduler_multicore_testsuite_setup(void)
14229 if (test_scheduler_attach_worker_op() < 0)
14230 return TEST_SKIPPED;
14231 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
14232 return TEST_SKIPPED;
14237 scheduler_roundrobin_testsuite_setup(void)
14239 if (test_scheduler_attach_worker_op() < 0)
14240 return TEST_SKIPPED;
14241 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
14242 return TEST_SKIPPED;
14247 scheduler_failover_testsuite_setup(void)
14249 if (test_scheduler_attach_worker_op() < 0)
14250 return TEST_SKIPPED;
14251 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
14252 return TEST_SKIPPED;
14257 scheduler_pkt_size_distr_testsuite_setup(void)
14259 if (test_scheduler_attach_worker_op() < 0)
14260 return TEST_SKIPPED;
14261 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14262 return TEST_SKIPPED;
14267 scheduler_mode_testsuite_teardown(void)
14269 test_scheduler_detach_worker_op();
14272 #endif /* RTE_CRYPTO_SCHEDULER */
14274 static struct unit_test_suite end_testsuite = {
14275 .suite_name = NULL,
14278 .unit_test_suites = NULL
14281 #ifdef RTE_LIB_SECURITY
14282 static struct unit_test_suite ipsec_proto_testsuite = {
14283 .suite_name = "IPsec Proto Unit Test Suite",
14284 .setup = ipsec_proto_testsuite_setup,
14285 .unit_test_cases = {
14286 TEST_CASE_NAMED_WITH_DATA(
14287 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14288 ut_setup_security, ut_teardown,
14289 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
14290 TEST_CASE_NAMED_WITH_DATA(
14291 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14292 ut_setup_security, ut_teardown,
14293 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
14294 TEST_CASE_NAMED_WITH_DATA(
14295 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14296 ut_setup_security, ut_teardown,
14297 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
14298 TEST_CASE_NAMED_WITH_DATA(
14299 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14300 ut_setup_security, ut_teardown,
14301 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14302 TEST_CASE_NAMED_WITH_DATA(
14303 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14304 ut_setup_security, ut_teardown,
14305 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14306 TEST_CASE_NAMED_WITH_DATA(
14307 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14308 ut_setup_security, ut_teardown,
14309 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14310 TEST_CASE_NAMED_ST(
14311 "Combined test alg list",
14312 ut_setup_security, ut_teardown,
14313 test_ipsec_proto_display_list),
14314 TEST_CASE_NAMED_ST(
14316 ut_setup_security, ut_teardown,
14317 test_ipsec_proto_iv_gen),
14318 TEST_CASE_NAMED_ST(
14319 "UDP encapsulation",
14320 ut_setup_security, ut_teardown,
14321 test_ipsec_proto_udp_encap),
14322 TEST_CASE_NAMED_ST(
14323 "UDP encapsulation ports verification test",
14324 ut_setup_security, ut_teardown,
14325 test_ipsec_proto_udp_ports_verify),
14326 TEST_CASE_NAMED_ST(
14327 "SA expiry packets soft",
14328 ut_setup_security, ut_teardown,
14329 test_ipsec_proto_sa_exp_pkts_soft),
14330 TEST_CASE_NAMED_ST(
14331 "SA expiry packets hard",
14332 ut_setup_security, ut_teardown,
14333 test_ipsec_proto_sa_exp_pkts_hard),
14334 TEST_CASE_NAMED_ST(
14335 "Negative test: ICV corruption",
14336 ut_setup_security, ut_teardown,
14337 test_ipsec_proto_err_icv_corrupt),
14338 TEST_CASE_NAMED_ST(
14339 "Tunnel dst addr verification",
14340 ut_setup_security, ut_teardown,
14341 test_ipsec_proto_tunnel_dst_addr_verify),
14342 TEST_CASE_NAMED_ST(
14343 "Tunnel src and dst addr verification",
14344 ut_setup_security, ut_teardown,
14345 test_ipsec_proto_tunnel_src_dst_addr_verify),
14346 TEST_CASE_NAMED_ST(
14347 "Inner IP checksum",
14348 ut_setup_security, ut_teardown,
14349 test_ipsec_proto_inner_ip_csum),
14350 TEST_CASE_NAMED_ST(
14351 "Inner L4 checksum",
14352 ut_setup_security, ut_teardown,
14353 test_ipsec_proto_inner_l4_csum),
14354 TEST_CASES_END() /**< NULL terminate unit test array */
14358 static struct unit_test_suite pdcp_proto_testsuite = {
14359 .suite_name = "PDCP Proto Unit Test Suite",
14360 .setup = pdcp_proto_testsuite_setup,
14361 .unit_test_cases = {
14362 TEST_CASE_ST(ut_setup_security, ut_teardown,
14363 test_PDCP_PROTO_all),
14364 TEST_CASES_END() /**< NULL terminate unit test array */
14368 static struct unit_test_suite docsis_proto_testsuite = {
14369 .suite_name = "Docsis Proto Unit Test Suite",
14370 .setup = docsis_proto_testsuite_setup,
14371 .unit_test_cases = {
14372 TEST_CASE_ST(ut_setup_security, ut_teardown,
14373 test_DOCSIS_PROTO_all),
14374 TEST_CASES_END() /**< NULL terminate unit test array */
14379 static struct unit_test_suite cryptodev_gen_testsuite = {
14380 .suite_name = "Crypto General Unit Test Suite",
14381 .setup = crypto_gen_testsuite_setup,
14382 .unit_test_cases = {
14383 TEST_CASE_ST(ut_setup, ut_teardown,
14384 test_device_configure_invalid_dev_id),
14385 TEST_CASE_ST(ut_setup, ut_teardown,
14386 test_queue_pair_descriptor_setup),
14387 TEST_CASE_ST(ut_setup, ut_teardown,
14388 test_device_configure_invalid_queue_pair_ids),
14389 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
14390 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
14391 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
14392 TEST_CASES_END() /**< NULL terminate unit test array */
14396 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
14397 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
14398 .setup = negative_hmac_sha1_testsuite_setup,
14399 .unit_test_cases = {
14400 /** Negative tests */
14401 TEST_CASE_ST(ut_setup, ut_teardown,
14402 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14403 TEST_CASE_ST(ut_setup, ut_teardown,
14404 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14405 TEST_CASE_ST(ut_setup, ut_teardown,
14406 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14407 TEST_CASE_ST(ut_setup, ut_teardown,
14408 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14410 TEST_CASES_END() /**< NULL terminate unit test array */
14414 static struct unit_test_suite cryptodev_multi_session_testsuite = {
14415 .suite_name = "Multi Session Unit Test Suite",
14416 .setup = multi_session_testsuite_setup,
14417 .unit_test_cases = {
14418 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14419 TEST_CASE_ST(ut_setup, ut_teardown,
14420 test_multi_session_random_usage),
14422 TEST_CASES_END() /**< NULL terminate unit test array */
14426 static struct unit_test_suite cryptodev_null_testsuite = {
14427 .suite_name = "NULL Test Suite",
14428 .setup = null_testsuite_setup,
14429 .unit_test_cases = {
14430 TEST_CASE_ST(ut_setup, ut_teardown,
14431 test_null_invalid_operation),
14432 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
14437 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
14438 .suite_name = "AES CCM Authenticated Test Suite",
14439 .setup = aes_ccm_auth_testsuite_setup,
14440 .unit_test_cases = {
14441 /** AES CCM Authenticated Encryption 128 bits key*/
14442 TEST_CASE_ST(ut_setup, ut_teardown,
14443 test_AES_CCM_authenticated_encryption_test_case_128_1),
14444 TEST_CASE_ST(ut_setup, ut_teardown,
14445 test_AES_CCM_authenticated_encryption_test_case_128_2),
14446 TEST_CASE_ST(ut_setup, ut_teardown,
14447 test_AES_CCM_authenticated_encryption_test_case_128_3),
14449 /** AES CCM Authenticated Decryption 128 bits key*/
14450 TEST_CASE_ST(ut_setup, ut_teardown,
14451 test_AES_CCM_authenticated_decryption_test_case_128_1),
14452 TEST_CASE_ST(ut_setup, ut_teardown,
14453 test_AES_CCM_authenticated_decryption_test_case_128_2),
14454 TEST_CASE_ST(ut_setup, ut_teardown,
14455 test_AES_CCM_authenticated_decryption_test_case_128_3),
14457 /** AES CCM Authenticated Encryption 192 bits key */
14458 TEST_CASE_ST(ut_setup, ut_teardown,
14459 test_AES_CCM_authenticated_encryption_test_case_192_1),
14460 TEST_CASE_ST(ut_setup, ut_teardown,
14461 test_AES_CCM_authenticated_encryption_test_case_192_2),
14462 TEST_CASE_ST(ut_setup, ut_teardown,
14463 test_AES_CCM_authenticated_encryption_test_case_192_3),
14465 /** AES CCM Authenticated Decryption 192 bits key*/
14466 TEST_CASE_ST(ut_setup, ut_teardown,
14467 test_AES_CCM_authenticated_decryption_test_case_192_1),
14468 TEST_CASE_ST(ut_setup, ut_teardown,
14469 test_AES_CCM_authenticated_decryption_test_case_192_2),
14470 TEST_CASE_ST(ut_setup, ut_teardown,
14471 test_AES_CCM_authenticated_decryption_test_case_192_3),
14473 /** AES CCM Authenticated Encryption 256 bits key */
14474 TEST_CASE_ST(ut_setup, ut_teardown,
14475 test_AES_CCM_authenticated_encryption_test_case_256_1),
14476 TEST_CASE_ST(ut_setup, ut_teardown,
14477 test_AES_CCM_authenticated_encryption_test_case_256_2),
14478 TEST_CASE_ST(ut_setup, ut_teardown,
14479 test_AES_CCM_authenticated_encryption_test_case_256_3),
14481 /** AES CCM Authenticated Decryption 256 bits key*/
14482 TEST_CASE_ST(ut_setup, ut_teardown,
14483 test_AES_CCM_authenticated_decryption_test_case_256_1),
14484 TEST_CASE_ST(ut_setup, ut_teardown,
14485 test_AES_CCM_authenticated_decryption_test_case_256_2),
14486 TEST_CASE_ST(ut_setup, ut_teardown,
14487 test_AES_CCM_authenticated_decryption_test_case_256_3),
14492 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
14493 .suite_name = "AES GCM Authenticated Test Suite",
14494 .setup = aes_gcm_auth_testsuite_setup,
14495 .unit_test_cases = {
14496 /** AES GCM Authenticated Encryption */
14497 TEST_CASE_ST(ut_setup, ut_teardown,
14498 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
14499 TEST_CASE_ST(ut_setup, ut_teardown,
14500 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
14501 TEST_CASE_ST(ut_setup, ut_teardown,
14502 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
14503 TEST_CASE_ST(ut_setup, ut_teardown,
14504 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
14505 TEST_CASE_ST(ut_setup, ut_teardown,
14506 test_AES_GCM_authenticated_encryption_test_case_1),
14507 TEST_CASE_ST(ut_setup, ut_teardown,
14508 test_AES_GCM_authenticated_encryption_test_case_2),
14509 TEST_CASE_ST(ut_setup, ut_teardown,
14510 test_AES_GCM_authenticated_encryption_test_case_3),
14511 TEST_CASE_ST(ut_setup, ut_teardown,
14512 test_AES_GCM_authenticated_encryption_test_case_4),
14513 TEST_CASE_ST(ut_setup, ut_teardown,
14514 test_AES_GCM_authenticated_encryption_test_case_5),
14515 TEST_CASE_ST(ut_setup, ut_teardown,
14516 test_AES_GCM_authenticated_encryption_test_case_6),
14517 TEST_CASE_ST(ut_setup, ut_teardown,
14518 test_AES_GCM_authenticated_encryption_test_case_7),
14519 TEST_CASE_ST(ut_setup, ut_teardown,
14520 test_AES_GCM_authenticated_encryption_test_case_8),
14521 TEST_CASE_ST(ut_setup, ut_teardown,
14522 test_AES_GCM_J0_authenticated_encryption_test_case_1),
14524 /** AES GCM Authenticated Decryption */
14525 TEST_CASE_ST(ut_setup, ut_teardown,
14526 test_AES_GCM_authenticated_decryption_test_case_1),
14527 TEST_CASE_ST(ut_setup, ut_teardown,
14528 test_AES_GCM_authenticated_decryption_test_case_2),
14529 TEST_CASE_ST(ut_setup, ut_teardown,
14530 test_AES_GCM_authenticated_decryption_test_case_3),
14531 TEST_CASE_ST(ut_setup, ut_teardown,
14532 test_AES_GCM_authenticated_decryption_test_case_4),
14533 TEST_CASE_ST(ut_setup, ut_teardown,
14534 test_AES_GCM_authenticated_decryption_test_case_5),
14535 TEST_CASE_ST(ut_setup, ut_teardown,
14536 test_AES_GCM_authenticated_decryption_test_case_6),
14537 TEST_CASE_ST(ut_setup, ut_teardown,
14538 test_AES_GCM_authenticated_decryption_test_case_7),
14539 TEST_CASE_ST(ut_setup, ut_teardown,
14540 test_AES_GCM_authenticated_decryption_test_case_8),
14541 TEST_CASE_ST(ut_setup, ut_teardown,
14542 test_AES_GCM_J0_authenticated_decryption_test_case_1),
14544 /** AES GCM Authenticated Encryption 192 bits key */
14545 TEST_CASE_ST(ut_setup, ut_teardown,
14546 test_AES_GCM_auth_encryption_test_case_192_1),
14547 TEST_CASE_ST(ut_setup, ut_teardown,
14548 test_AES_GCM_auth_encryption_test_case_192_2),
14549 TEST_CASE_ST(ut_setup, ut_teardown,
14550 test_AES_GCM_auth_encryption_test_case_192_3),
14551 TEST_CASE_ST(ut_setup, ut_teardown,
14552 test_AES_GCM_auth_encryption_test_case_192_4),
14553 TEST_CASE_ST(ut_setup, ut_teardown,
14554 test_AES_GCM_auth_encryption_test_case_192_5),
14555 TEST_CASE_ST(ut_setup, ut_teardown,
14556 test_AES_GCM_auth_encryption_test_case_192_6),
14557 TEST_CASE_ST(ut_setup, ut_teardown,
14558 test_AES_GCM_auth_encryption_test_case_192_7),
14560 /** AES GCM Authenticated Decryption 192 bits key */
14561 TEST_CASE_ST(ut_setup, ut_teardown,
14562 test_AES_GCM_auth_decryption_test_case_192_1),
14563 TEST_CASE_ST(ut_setup, ut_teardown,
14564 test_AES_GCM_auth_decryption_test_case_192_2),
14565 TEST_CASE_ST(ut_setup, ut_teardown,
14566 test_AES_GCM_auth_decryption_test_case_192_3),
14567 TEST_CASE_ST(ut_setup, ut_teardown,
14568 test_AES_GCM_auth_decryption_test_case_192_4),
14569 TEST_CASE_ST(ut_setup, ut_teardown,
14570 test_AES_GCM_auth_decryption_test_case_192_5),
14571 TEST_CASE_ST(ut_setup, ut_teardown,
14572 test_AES_GCM_auth_decryption_test_case_192_6),
14573 TEST_CASE_ST(ut_setup, ut_teardown,
14574 test_AES_GCM_auth_decryption_test_case_192_7),
14576 /** AES GCM Authenticated Encryption 256 bits key */
14577 TEST_CASE_ST(ut_setup, ut_teardown,
14578 test_AES_GCM_auth_encryption_test_case_256_1),
14579 TEST_CASE_ST(ut_setup, ut_teardown,
14580 test_AES_GCM_auth_encryption_test_case_256_2),
14581 TEST_CASE_ST(ut_setup, ut_teardown,
14582 test_AES_GCM_auth_encryption_test_case_256_3),
14583 TEST_CASE_ST(ut_setup, ut_teardown,
14584 test_AES_GCM_auth_encryption_test_case_256_4),
14585 TEST_CASE_ST(ut_setup, ut_teardown,
14586 test_AES_GCM_auth_encryption_test_case_256_5),
14587 TEST_CASE_ST(ut_setup, ut_teardown,
14588 test_AES_GCM_auth_encryption_test_case_256_6),
14589 TEST_CASE_ST(ut_setup, ut_teardown,
14590 test_AES_GCM_auth_encryption_test_case_256_7),
14592 /** AES GCM Authenticated Decryption 256 bits key */
14593 TEST_CASE_ST(ut_setup, ut_teardown,
14594 test_AES_GCM_auth_decryption_test_case_256_1),
14595 TEST_CASE_ST(ut_setup, ut_teardown,
14596 test_AES_GCM_auth_decryption_test_case_256_2),
14597 TEST_CASE_ST(ut_setup, ut_teardown,
14598 test_AES_GCM_auth_decryption_test_case_256_3),
14599 TEST_CASE_ST(ut_setup, ut_teardown,
14600 test_AES_GCM_auth_decryption_test_case_256_4),
14601 TEST_CASE_ST(ut_setup, ut_teardown,
14602 test_AES_GCM_auth_decryption_test_case_256_5),
14603 TEST_CASE_ST(ut_setup, ut_teardown,
14604 test_AES_GCM_auth_decryption_test_case_256_6),
14605 TEST_CASE_ST(ut_setup, ut_teardown,
14606 test_AES_GCM_auth_decryption_test_case_256_7),
14608 /** AES GCM Authenticated Encryption big aad size */
14609 TEST_CASE_ST(ut_setup, ut_teardown,
14610 test_AES_GCM_auth_encryption_test_case_aad_1),
14611 TEST_CASE_ST(ut_setup, ut_teardown,
14612 test_AES_GCM_auth_encryption_test_case_aad_2),
14614 /** AES GCM Authenticated Decryption big aad size */
14615 TEST_CASE_ST(ut_setup, ut_teardown,
14616 test_AES_GCM_auth_decryption_test_case_aad_1),
14617 TEST_CASE_ST(ut_setup, ut_teardown,
14618 test_AES_GCM_auth_decryption_test_case_aad_2),
14620 /** Out of place tests */
14621 TEST_CASE_ST(ut_setup, ut_teardown,
14622 test_AES_GCM_authenticated_encryption_oop_test_case_1),
14623 TEST_CASE_ST(ut_setup, ut_teardown,
14624 test_AES_GCM_authenticated_decryption_oop_test_case_1),
14626 /** Session-less tests */
14627 TEST_CASE_ST(ut_setup, ut_teardown,
14628 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
14629 TEST_CASE_ST(ut_setup, ut_teardown,
14630 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
14636 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
14637 .suite_name = "AES GMAC Authentication Test Suite",
14638 .setup = aes_gmac_auth_testsuite_setup,
14639 .unit_test_cases = {
14640 TEST_CASE_ST(ut_setup, ut_teardown,
14641 test_AES_GMAC_authentication_test_case_1),
14642 TEST_CASE_ST(ut_setup, ut_teardown,
14643 test_AES_GMAC_authentication_verify_test_case_1),
14644 TEST_CASE_ST(ut_setup, ut_teardown,
14645 test_AES_GMAC_authentication_test_case_2),
14646 TEST_CASE_ST(ut_setup, ut_teardown,
14647 test_AES_GMAC_authentication_verify_test_case_2),
14648 TEST_CASE_ST(ut_setup, ut_teardown,
14649 test_AES_GMAC_authentication_test_case_3),
14650 TEST_CASE_ST(ut_setup, ut_teardown,
14651 test_AES_GMAC_authentication_verify_test_case_3),
14652 TEST_CASE_ST(ut_setup, ut_teardown,
14653 test_AES_GMAC_authentication_test_case_4),
14654 TEST_CASE_ST(ut_setup, ut_teardown,
14655 test_AES_GMAC_authentication_verify_test_case_4),
14656 TEST_CASE_ST(ut_setup, ut_teardown,
14657 test_AES_GMAC_authentication_SGL_40B),
14658 TEST_CASE_ST(ut_setup, ut_teardown,
14659 test_AES_GMAC_authentication_SGL_80B),
14660 TEST_CASE_ST(ut_setup, ut_teardown,
14661 test_AES_GMAC_authentication_SGL_2048B),
14662 TEST_CASE_ST(ut_setup, ut_teardown,
14663 test_AES_GMAC_authentication_SGL_2047B),
14669 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14670 .suite_name = "Chacha20-Poly1305 Test Suite",
14671 .setup = chacha20_poly1305_testsuite_setup,
14672 .unit_test_cases = {
14673 TEST_CASE_ST(ut_setup, ut_teardown,
14674 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14675 TEST_CASE_ST(ut_setup, ut_teardown,
14676 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14681 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14682 .suite_name = "SNOW 3G Test Suite",
14683 .setup = snow3g_testsuite_setup,
14684 .unit_test_cases = {
14685 /** SNOW 3G encrypt only (UEA2) */
14686 TEST_CASE_ST(ut_setup, ut_teardown,
14687 test_snow3g_encryption_test_case_1),
14688 TEST_CASE_ST(ut_setup, ut_teardown,
14689 test_snow3g_encryption_test_case_2),
14690 TEST_CASE_ST(ut_setup, ut_teardown,
14691 test_snow3g_encryption_test_case_3),
14692 TEST_CASE_ST(ut_setup, ut_teardown,
14693 test_snow3g_encryption_test_case_4),
14694 TEST_CASE_ST(ut_setup, ut_teardown,
14695 test_snow3g_encryption_test_case_5),
14697 TEST_CASE_ST(ut_setup, ut_teardown,
14698 test_snow3g_encryption_test_case_1_oop),
14699 TEST_CASE_ST(ut_setup, ut_teardown,
14700 test_snow3g_encryption_test_case_1_oop_sgl),
14701 TEST_CASE_ST(ut_setup, ut_teardown,
14702 test_snow3g_encryption_test_case_1_offset_oop),
14703 TEST_CASE_ST(ut_setup, ut_teardown,
14704 test_snow3g_decryption_test_case_1_oop),
14706 /** SNOW 3G generate auth, then encrypt (UEA2) */
14707 TEST_CASE_ST(ut_setup, ut_teardown,
14708 test_snow3g_auth_cipher_test_case_1),
14709 TEST_CASE_ST(ut_setup, ut_teardown,
14710 test_snow3g_auth_cipher_test_case_2),
14711 TEST_CASE_ST(ut_setup, ut_teardown,
14712 test_snow3g_auth_cipher_test_case_2_oop),
14713 TEST_CASE_ST(ut_setup, ut_teardown,
14714 test_snow3g_auth_cipher_part_digest_enc),
14715 TEST_CASE_ST(ut_setup, ut_teardown,
14716 test_snow3g_auth_cipher_part_digest_enc_oop),
14717 TEST_CASE_ST(ut_setup, ut_teardown,
14718 test_snow3g_auth_cipher_test_case_3_sgl),
14719 TEST_CASE_ST(ut_setup, ut_teardown,
14720 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14721 TEST_CASE_ST(ut_setup, ut_teardown,
14722 test_snow3g_auth_cipher_part_digest_enc_sgl),
14723 TEST_CASE_ST(ut_setup, ut_teardown,
14724 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14726 /** SNOW 3G decrypt (UEA2), then verify auth */
14727 TEST_CASE_ST(ut_setup, ut_teardown,
14728 test_snow3g_auth_cipher_verify_test_case_1),
14729 TEST_CASE_ST(ut_setup, ut_teardown,
14730 test_snow3g_auth_cipher_verify_test_case_2),
14731 TEST_CASE_ST(ut_setup, ut_teardown,
14732 test_snow3g_auth_cipher_verify_test_case_2_oop),
14733 TEST_CASE_ST(ut_setup, ut_teardown,
14734 test_snow3g_auth_cipher_verify_part_digest_enc),
14735 TEST_CASE_ST(ut_setup, ut_teardown,
14736 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14737 TEST_CASE_ST(ut_setup, ut_teardown,
14738 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14739 TEST_CASE_ST(ut_setup, ut_teardown,
14740 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14741 TEST_CASE_ST(ut_setup, ut_teardown,
14742 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14743 TEST_CASE_ST(ut_setup, ut_teardown,
14744 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14746 /** SNOW 3G decrypt only (UEA2) */
14747 TEST_CASE_ST(ut_setup, ut_teardown,
14748 test_snow3g_decryption_test_case_1),
14749 TEST_CASE_ST(ut_setup, ut_teardown,
14750 test_snow3g_decryption_test_case_2),
14751 TEST_CASE_ST(ut_setup, ut_teardown,
14752 test_snow3g_decryption_test_case_3),
14753 TEST_CASE_ST(ut_setup, ut_teardown,
14754 test_snow3g_decryption_test_case_4),
14755 TEST_CASE_ST(ut_setup, ut_teardown,
14756 test_snow3g_decryption_test_case_5),
14757 TEST_CASE_ST(ut_setup, ut_teardown,
14758 test_snow3g_decryption_with_digest_test_case_1),
14759 TEST_CASE_ST(ut_setup, ut_teardown,
14760 test_snow3g_hash_generate_test_case_1),
14761 TEST_CASE_ST(ut_setup, ut_teardown,
14762 test_snow3g_hash_generate_test_case_2),
14763 TEST_CASE_ST(ut_setup, ut_teardown,
14764 test_snow3g_hash_generate_test_case_3),
14766 /* Tests with buffers which length is not byte-aligned */
14767 TEST_CASE_ST(ut_setup, ut_teardown,
14768 test_snow3g_hash_generate_test_case_4),
14769 TEST_CASE_ST(ut_setup, ut_teardown,
14770 test_snow3g_hash_generate_test_case_5),
14771 TEST_CASE_ST(ut_setup, ut_teardown,
14772 test_snow3g_hash_generate_test_case_6),
14773 TEST_CASE_ST(ut_setup, ut_teardown,
14774 test_snow3g_hash_verify_test_case_1),
14775 TEST_CASE_ST(ut_setup, ut_teardown,
14776 test_snow3g_hash_verify_test_case_2),
14777 TEST_CASE_ST(ut_setup, ut_teardown,
14778 test_snow3g_hash_verify_test_case_3),
14780 /* Tests with buffers which length is not byte-aligned */
14781 TEST_CASE_ST(ut_setup, ut_teardown,
14782 test_snow3g_hash_verify_test_case_4),
14783 TEST_CASE_ST(ut_setup, ut_teardown,
14784 test_snow3g_hash_verify_test_case_5),
14785 TEST_CASE_ST(ut_setup, ut_teardown,
14786 test_snow3g_hash_verify_test_case_6),
14787 TEST_CASE_ST(ut_setup, ut_teardown,
14788 test_snow3g_cipher_auth_test_case_1),
14789 TEST_CASE_ST(ut_setup, ut_teardown,
14790 test_snow3g_auth_cipher_with_digest_test_case_1),
14795 static struct unit_test_suite cryptodev_zuc_testsuite = {
14796 .suite_name = "ZUC Test Suite",
14797 .setup = zuc_testsuite_setup,
14798 .unit_test_cases = {
14799 /** ZUC encrypt only (EEA3) */
14800 TEST_CASE_ST(ut_setup, ut_teardown,
14801 test_zuc_encryption_test_case_1),
14802 TEST_CASE_ST(ut_setup, ut_teardown,
14803 test_zuc_encryption_test_case_2),
14804 TEST_CASE_ST(ut_setup, ut_teardown,
14805 test_zuc_encryption_test_case_3),
14806 TEST_CASE_ST(ut_setup, ut_teardown,
14807 test_zuc_encryption_test_case_4),
14808 TEST_CASE_ST(ut_setup, ut_teardown,
14809 test_zuc_encryption_test_case_5),
14810 TEST_CASE_ST(ut_setup, ut_teardown,
14811 test_zuc_encryption_test_case_6_sgl),
14812 TEST_CASE_ST(ut_setup, ut_teardown,
14813 test_zuc_encryption_test_case_7),
14815 /** ZUC authenticate (EIA3) */
14816 TEST_CASE_ST(ut_setup, ut_teardown,
14817 test_zuc_hash_generate_test_case_1),
14818 TEST_CASE_ST(ut_setup, ut_teardown,
14819 test_zuc_hash_generate_test_case_2),
14820 TEST_CASE_ST(ut_setup, ut_teardown,
14821 test_zuc_hash_generate_test_case_3),
14822 TEST_CASE_ST(ut_setup, ut_teardown,
14823 test_zuc_hash_generate_test_case_4),
14824 TEST_CASE_ST(ut_setup, ut_teardown,
14825 test_zuc_hash_generate_test_case_5),
14826 TEST_CASE_ST(ut_setup, ut_teardown,
14827 test_zuc_hash_generate_test_case_6),
14828 TEST_CASE_ST(ut_setup, ut_teardown,
14829 test_zuc_hash_generate_test_case_7),
14830 TEST_CASE_ST(ut_setup, ut_teardown,
14831 test_zuc_hash_generate_test_case_8),
14832 TEST_CASE_ST(ut_setup, ut_teardown,
14833 test_zuc_hash_generate_test_case_9),
14834 TEST_CASE_ST(ut_setup, ut_teardown,
14835 test_zuc_hash_generate_test_case_10),
14838 /** ZUC alg-chain (EEA3/EIA3) */
14839 TEST_CASE_ST(ut_setup, ut_teardown,
14840 test_zuc_cipher_auth_test_case_1),
14841 TEST_CASE_ST(ut_setup, ut_teardown,
14842 test_zuc_cipher_auth_test_case_2),
14844 /** ZUC generate auth, then encrypt (EEA3) */
14845 TEST_CASE_ST(ut_setup, ut_teardown,
14846 test_zuc_auth_cipher_test_case_1),
14847 TEST_CASE_ST(ut_setup, ut_teardown,
14848 test_zuc_auth_cipher_test_case_1_oop),
14849 TEST_CASE_ST(ut_setup, ut_teardown,
14850 test_zuc_auth_cipher_test_case_1_sgl),
14851 TEST_CASE_ST(ut_setup, ut_teardown,
14852 test_zuc_auth_cipher_test_case_1_oop_sgl),
14854 /** ZUC decrypt (EEA3), then verify auth */
14855 TEST_CASE_ST(ut_setup, ut_teardown,
14856 test_zuc_auth_cipher_verify_test_case_1),
14857 TEST_CASE_ST(ut_setup, ut_teardown,
14858 test_zuc_auth_cipher_verify_test_case_1_oop),
14859 TEST_CASE_ST(ut_setup, ut_teardown,
14860 test_zuc_auth_cipher_verify_test_case_1_sgl),
14861 TEST_CASE_ST(ut_setup, ut_teardown,
14862 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14867 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14868 .suite_name = "HMAC_MD5 Authentication Test Suite",
14869 .setup = hmac_md5_auth_testsuite_setup,
14870 .unit_test_cases = {
14871 TEST_CASE_ST(ut_setup, ut_teardown,
14872 test_MD5_HMAC_generate_case_1),
14873 TEST_CASE_ST(ut_setup, ut_teardown,
14874 test_MD5_HMAC_verify_case_1),
14875 TEST_CASE_ST(ut_setup, ut_teardown,
14876 test_MD5_HMAC_generate_case_2),
14877 TEST_CASE_ST(ut_setup, ut_teardown,
14878 test_MD5_HMAC_verify_case_2),
14883 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14884 .suite_name = "Kasumi Test Suite",
14885 .setup = kasumi_testsuite_setup,
14886 .unit_test_cases = {
14887 /** KASUMI hash only (UIA1) */
14888 TEST_CASE_ST(ut_setup, ut_teardown,
14889 test_kasumi_hash_generate_test_case_1),
14890 TEST_CASE_ST(ut_setup, ut_teardown,
14891 test_kasumi_hash_generate_test_case_2),
14892 TEST_CASE_ST(ut_setup, ut_teardown,
14893 test_kasumi_hash_generate_test_case_3),
14894 TEST_CASE_ST(ut_setup, ut_teardown,
14895 test_kasumi_hash_generate_test_case_4),
14896 TEST_CASE_ST(ut_setup, ut_teardown,
14897 test_kasumi_hash_generate_test_case_5),
14898 TEST_CASE_ST(ut_setup, ut_teardown,
14899 test_kasumi_hash_generate_test_case_6),
14901 TEST_CASE_ST(ut_setup, ut_teardown,
14902 test_kasumi_hash_verify_test_case_1),
14903 TEST_CASE_ST(ut_setup, ut_teardown,
14904 test_kasumi_hash_verify_test_case_2),
14905 TEST_CASE_ST(ut_setup, ut_teardown,
14906 test_kasumi_hash_verify_test_case_3),
14907 TEST_CASE_ST(ut_setup, ut_teardown,
14908 test_kasumi_hash_verify_test_case_4),
14909 TEST_CASE_ST(ut_setup, ut_teardown,
14910 test_kasumi_hash_verify_test_case_5),
14912 /** KASUMI encrypt only (UEA1) */
14913 TEST_CASE_ST(ut_setup, ut_teardown,
14914 test_kasumi_encryption_test_case_1),
14915 TEST_CASE_ST(ut_setup, ut_teardown,
14916 test_kasumi_encryption_test_case_1_sgl),
14917 TEST_CASE_ST(ut_setup, ut_teardown,
14918 test_kasumi_encryption_test_case_1_oop),
14919 TEST_CASE_ST(ut_setup, ut_teardown,
14920 test_kasumi_encryption_test_case_1_oop_sgl),
14921 TEST_CASE_ST(ut_setup, ut_teardown,
14922 test_kasumi_encryption_test_case_2),
14923 TEST_CASE_ST(ut_setup, ut_teardown,
14924 test_kasumi_encryption_test_case_3),
14925 TEST_CASE_ST(ut_setup, ut_teardown,
14926 test_kasumi_encryption_test_case_4),
14927 TEST_CASE_ST(ut_setup, ut_teardown,
14928 test_kasumi_encryption_test_case_5),
14930 /** KASUMI decrypt only (UEA1) */
14931 TEST_CASE_ST(ut_setup, ut_teardown,
14932 test_kasumi_decryption_test_case_1),
14933 TEST_CASE_ST(ut_setup, ut_teardown,
14934 test_kasumi_decryption_test_case_2),
14935 TEST_CASE_ST(ut_setup, ut_teardown,
14936 test_kasumi_decryption_test_case_3),
14937 TEST_CASE_ST(ut_setup, ut_teardown,
14938 test_kasumi_decryption_test_case_4),
14939 TEST_CASE_ST(ut_setup, ut_teardown,
14940 test_kasumi_decryption_test_case_5),
14941 TEST_CASE_ST(ut_setup, ut_teardown,
14942 test_kasumi_decryption_test_case_1_oop),
14943 TEST_CASE_ST(ut_setup, ut_teardown,
14944 test_kasumi_cipher_auth_test_case_1),
14946 /** KASUMI generate auth, then encrypt (F8) */
14947 TEST_CASE_ST(ut_setup, ut_teardown,
14948 test_kasumi_auth_cipher_test_case_1),
14949 TEST_CASE_ST(ut_setup, ut_teardown,
14950 test_kasumi_auth_cipher_test_case_2),
14951 TEST_CASE_ST(ut_setup, ut_teardown,
14952 test_kasumi_auth_cipher_test_case_2_oop),
14953 TEST_CASE_ST(ut_setup, ut_teardown,
14954 test_kasumi_auth_cipher_test_case_2_sgl),
14955 TEST_CASE_ST(ut_setup, ut_teardown,
14956 test_kasumi_auth_cipher_test_case_2_oop_sgl),
14958 /** KASUMI decrypt (F8), then verify auth */
14959 TEST_CASE_ST(ut_setup, ut_teardown,
14960 test_kasumi_auth_cipher_verify_test_case_1),
14961 TEST_CASE_ST(ut_setup, ut_teardown,
14962 test_kasumi_auth_cipher_verify_test_case_2),
14963 TEST_CASE_ST(ut_setup, ut_teardown,
14964 test_kasumi_auth_cipher_verify_test_case_2_oop),
14965 TEST_CASE_ST(ut_setup, ut_teardown,
14966 test_kasumi_auth_cipher_verify_test_case_2_sgl),
14967 TEST_CASE_ST(ut_setup, ut_teardown,
14968 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14974 static struct unit_test_suite cryptodev_esn_testsuite = {
14975 .suite_name = "ESN Test Suite",
14976 .setup = esn_testsuite_setup,
14977 .unit_test_cases = {
14978 TEST_CASE_ST(ut_setup, ut_teardown,
14979 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14980 TEST_CASE_ST(ut_setup, ut_teardown,
14981 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14986 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
14987 .suite_name = "Negative AES GCM Test Suite",
14988 .setup = negative_aes_gcm_testsuite_setup,
14989 .unit_test_cases = {
14990 TEST_CASE_ST(ut_setup, ut_teardown,
14991 test_AES_GCM_auth_encryption_fail_iv_corrupt),
14992 TEST_CASE_ST(ut_setup, ut_teardown,
14993 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14994 TEST_CASE_ST(ut_setup, ut_teardown,
14995 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14996 TEST_CASE_ST(ut_setup, ut_teardown,
14997 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14998 TEST_CASE_ST(ut_setup, ut_teardown,
14999 test_AES_GCM_auth_encryption_fail_aad_corrupt),
15000 TEST_CASE_ST(ut_setup, ut_teardown,
15001 test_AES_GCM_auth_encryption_fail_tag_corrupt),
15002 TEST_CASE_ST(ut_setup, ut_teardown,
15003 test_AES_GCM_auth_decryption_fail_iv_corrupt),
15004 TEST_CASE_ST(ut_setup, ut_teardown,
15005 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
15006 TEST_CASE_ST(ut_setup, ut_teardown,
15007 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
15008 TEST_CASE_ST(ut_setup, ut_teardown,
15009 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
15010 TEST_CASE_ST(ut_setup, ut_teardown,
15011 test_AES_GCM_auth_decryption_fail_aad_corrupt),
15012 TEST_CASE_ST(ut_setup, ut_teardown,
15013 test_AES_GCM_auth_decryption_fail_tag_corrupt),
15019 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
15020 .suite_name = "Negative AES GMAC Test Suite",
15021 .setup = negative_aes_gmac_testsuite_setup,
15022 .unit_test_cases = {
15023 TEST_CASE_ST(ut_setup, ut_teardown,
15024 authentication_verify_AES128_GMAC_fail_data_corrupt),
15025 TEST_CASE_ST(ut_setup, ut_teardown,
15026 authentication_verify_AES128_GMAC_fail_tag_corrupt),
15032 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
15033 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
15034 .setup = mixed_cipher_hash_testsuite_setup,
15035 .unit_test_cases = {
15036 /** AUTH AES CMAC + CIPHER AES CTR */
15037 TEST_CASE_ST(ut_setup, ut_teardown,
15038 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
15039 TEST_CASE_ST(ut_setup, ut_teardown,
15040 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15041 TEST_CASE_ST(ut_setup, ut_teardown,
15042 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15043 TEST_CASE_ST(ut_setup, ut_teardown,
15044 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15045 TEST_CASE_ST(ut_setup, ut_teardown,
15046 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
15047 TEST_CASE_ST(ut_setup, ut_teardown,
15048 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15049 TEST_CASE_ST(ut_setup, ut_teardown,
15050 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15051 TEST_CASE_ST(ut_setup, ut_teardown,
15052 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15054 /** AUTH ZUC + CIPHER SNOW3G */
15055 TEST_CASE_ST(ut_setup, ut_teardown,
15056 test_auth_zuc_cipher_snow_test_case_1),
15057 TEST_CASE_ST(ut_setup, ut_teardown,
15058 test_verify_auth_zuc_cipher_snow_test_case_1),
15059 /** AUTH AES CMAC + CIPHER SNOW3G */
15060 TEST_CASE_ST(ut_setup, ut_teardown,
15061 test_auth_aes_cmac_cipher_snow_test_case_1),
15062 TEST_CASE_ST(ut_setup, ut_teardown,
15063 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
15064 /** AUTH ZUC + CIPHER AES CTR */
15065 TEST_CASE_ST(ut_setup, ut_teardown,
15066 test_auth_zuc_cipher_aes_ctr_test_case_1),
15067 TEST_CASE_ST(ut_setup, ut_teardown,
15068 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
15069 /** AUTH SNOW3G + CIPHER AES CTR */
15070 TEST_CASE_ST(ut_setup, ut_teardown,
15071 test_auth_snow_cipher_aes_ctr_test_case_1),
15072 TEST_CASE_ST(ut_setup, ut_teardown,
15073 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
15074 /** AUTH SNOW3G + CIPHER ZUC */
15075 TEST_CASE_ST(ut_setup, ut_teardown,
15076 test_auth_snow_cipher_zuc_test_case_1),
15077 TEST_CASE_ST(ut_setup, ut_teardown,
15078 test_verify_auth_snow_cipher_zuc_test_case_1),
15079 /** AUTH AES CMAC + CIPHER ZUC */
15080 TEST_CASE_ST(ut_setup, ut_teardown,
15081 test_auth_aes_cmac_cipher_zuc_test_case_1),
15082 TEST_CASE_ST(ut_setup, ut_teardown,
15083 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
15085 /** AUTH NULL + CIPHER SNOW3G */
15086 TEST_CASE_ST(ut_setup, ut_teardown,
15087 test_auth_null_cipher_snow_test_case_1),
15088 TEST_CASE_ST(ut_setup, ut_teardown,
15089 test_verify_auth_null_cipher_snow_test_case_1),
15090 /** AUTH NULL + CIPHER ZUC */
15091 TEST_CASE_ST(ut_setup, ut_teardown,
15092 test_auth_null_cipher_zuc_test_case_1),
15093 TEST_CASE_ST(ut_setup, ut_teardown,
15094 test_verify_auth_null_cipher_zuc_test_case_1),
15095 /** AUTH SNOW3G + CIPHER NULL */
15096 TEST_CASE_ST(ut_setup, ut_teardown,
15097 test_auth_snow_cipher_null_test_case_1),
15098 TEST_CASE_ST(ut_setup, ut_teardown,
15099 test_verify_auth_snow_cipher_null_test_case_1),
15100 /** AUTH ZUC + CIPHER NULL */
15101 TEST_CASE_ST(ut_setup, ut_teardown,
15102 test_auth_zuc_cipher_null_test_case_1),
15103 TEST_CASE_ST(ut_setup, ut_teardown,
15104 test_verify_auth_zuc_cipher_null_test_case_1),
15105 /** AUTH NULL + CIPHER AES CTR */
15106 TEST_CASE_ST(ut_setup, ut_teardown,
15107 test_auth_null_cipher_aes_ctr_test_case_1),
15108 TEST_CASE_ST(ut_setup, ut_teardown,
15109 test_verify_auth_null_cipher_aes_ctr_test_case_1),
15110 /** AUTH AES CMAC + CIPHER NULL */
15111 TEST_CASE_ST(ut_setup, ut_teardown,
15112 test_auth_aes_cmac_cipher_null_test_case_1),
15113 TEST_CASE_ST(ut_setup, ut_teardown,
15114 test_verify_auth_aes_cmac_cipher_null_test_case_1),
15120 run_cryptodev_testsuite(const char *pmd_name)
15122 uint8_t ret, j, i = 0, blk_start_idx = 0;
15123 const enum blockcipher_test_type blk_suites[] = {
15124 BLKCIPHER_AES_CHAIN_TYPE,
15125 BLKCIPHER_AES_CIPHERONLY_TYPE,
15126 BLKCIPHER_AES_DOCSIS_TYPE,
15127 BLKCIPHER_3DES_CHAIN_TYPE,
15128 BLKCIPHER_3DES_CIPHERONLY_TYPE,
15129 BLKCIPHER_DES_CIPHERONLY_TYPE,
15130 BLKCIPHER_DES_DOCSIS_TYPE,
15131 BLKCIPHER_AUTHONLY_TYPE};
15132 struct unit_test_suite *static_suites[] = {
15133 &cryptodev_multi_session_testsuite,
15134 &cryptodev_null_testsuite,
15135 &cryptodev_aes_ccm_auth_testsuite,
15136 &cryptodev_aes_gcm_auth_testsuite,
15137 &cryptodev_aes_gmac_auth_testsuite,
15138 &cryptodev_snow3g_testsuite,
15139 &cryptodev_chacha20_poly1305_testsuite,
15140 &cryptodev_zuc_testsuite,
15141 &cryptodev_hmac_md5_auth_testsuite,
15142 &cryptodev_kasumi_testsuite,
15143 &cryptodev_esn_testsuite,
15144 &cryptodev_negative_aes_gcm_testsuite,
15145 &cryptodev_negative_aes_gmac_testsuite,
15146 &cryptodev_mixed_cipher_hash_testsuite,
15147 &cryptodev_negative_hmac_sha1_testsuite,
15148 &cryptodev_gen_testsuite,
15149 #ifdef RTE_LIB_SECURITY
15150 &ipsec_proto_testsuite,
15151 &pdcp_proto_testsuite,
15152 &docsis_proto_testsuite,
15156 static struct unit_test_suite ts = {
15157 .suite_name = "Cryptodev Unit Test Suite",
15158 .setup = testsuite_setup,
15159 .teardown = testsuite_teardown,
15160 .unit_test_cases = {TEST_CASES_END()}
15163 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
15165 if (gbl_driver_id == -1) {
15166 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
15167 return TEST_SKIPPED;
15170 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15171 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
15173 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
15174 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15175 ret = unit_test_suite_runner(&ts);
15177 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
15178 free(ts.unit_test_suites);
15183 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
15185 struct rte_cryptodev_info dev_info;
15186 uint8_t i, nb_devs;
15189 driver_id = rte_cryptodev_driver_id_get(pmd_name);
15190 if (driver_id == -1) {
15191 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
15192 return TEST_SKIPPED;
15195 nb_devs = rte_cryptodev_count();
15197 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
15198 return TEST_SKIPPED;
15201 for (i = 0; i < nb_devs; i++) {
15202 rte_cryptodev_info_get(i, &dev_info);
15203 if (dev_info.driver_id == driver_id) {
15204 if (!(dev_info.feature_flags & flag)) {
15205 RTE_LOG(INFO, USER1, "%s not supported\n",
15207 return TEST_SKIPPED;
15209 return 0; /* found */
15213 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
15214 return TEST_SKIPPED;
15218 test_cryptodev_qat(void)
15220 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
15224 test_cryptodev_virtio(void)
15226 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
15230 test_cryptodev_aesni_mb(void)
15232 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15236 test_cryptodev_cpu_aesni_mb(void)
15239 enum rte_security_session_action_type at = gbl_action_type;
15240 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15241 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15242 gbl_action_type = at;
15247 test_cryptodev_openssl(void)
15249 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
15253 test_cryptodev_aesni_gcm(void)
15255 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15259 test_cryptodev_cpu_aesni_gcm(void)
15262 enum rte_security_session_action_type at = gbl_action_type;
15263 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15264 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15265 gbl_action_type = at;
15270 test_cryptodev_mlx5(void)
15272 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
15276 test_cryptodev_null(void)
15278 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
15282 test_cryptodev_sw_snow3g(void)
15284 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
15288 test_cryptodev_sw_kasumi(void)
15290 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
15294 test_cryptodev_sw_zuc(void)
15296 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
15300 test_cryptodev_armv8(void)
15302 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
15306 test_cryptodev_mrvl(void)
15308 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
15311 #ifdef RTE_CRYPTO_SCHEDULER
15314 test_cryptodev_scheduler(void)
15316 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
15317 const enum blockcipher_test_type blk_suites[] = {
15318 BLKCIPHER_AES_CHAIN_TYPE,
15319 BLKCIPHER_AES_CIPHERONLY_TYPE,
15320 BLKCIPHER_AUTHONLY_TYPE
15322 static struct unit_test_suite scheduler_multicore = {
15323 .suite_name = "Scheduler Multicore Unit Test Suite",
15324 .setup = scheduler_multicore_testsuite_setup,
15325 .teardown = scheduler_mode_testsuite_teardown,
15326 .unit_test_cases = {TEST_CASES_END()}
15328 static struct unit_test_suite scheduler_round_robin = {
15329 .suite_name = "Scheduler Round Robin Unit Test Suite",
15330 .setup = scheduler_roundrobin_testsuite_setup,
15331 .teardown = scheduler_mode_testsuite_teardown,
15332 .unit_test_cases = {TEST_CASES_END()}
15334 static struct unit_test_suite scheduler_failover = {
15335 .suite_name = "Scheduler Failover Unit Test Suite",
15336 .setup = scheduler_failover_testsuite_setup,
15337 .teardown = scheduler_mode_testsuite_teardown,
15338 .unit_test_cases = {TEST_CASES_END()}
15340 static struct unit_test_suite scheduler_pkt_size_distr = {
15341 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
15342 .setup = scheduler_pkt_size_distr_testsuite_setup,
15343 .teardown = scheduler_mode_testsuite_teardown,
15344 .unit_test_cases = {TEST_CASES_END()}
15346 struct unit_test_suite *sched_mode_suites[] = {
15347 &scheduler_multicore,
15348 &scheduler_round_robin,
15349 &scheduler_failover,
15350 &scheduler_pkt_size_distr
15352 static struct unit_test_suite scheduler_config = {
15353 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
15354 .unit_test_cases = {
15355 TEST_CASE(test_scheduler_attach_worker_op),
15356 TEST_CASE(test_scheduler_mode_multicore_op),
15357 TEST_CASE(test_scheduler_mode_roundrobin_op),
15358 TEST_CASE(test_scheduler_mode_failover_op),
15359 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
15360 TEST_CASE(test_scheduler_detach_worker_op),
15362 TEST_CASES_END() /**< NULL terminate array */
15365 struct unit_test_suite *static_suites[] = {
15369 static struct unit_test_suite ts = {
15370 .suite_name = "Scheduler Unit Test Suite",
15371 .setup = scheduler_testsuite_setup,
15372 .teardown = testsuite_teardown,
15373 .unit_test_cases = {TEST_CASES_END()}
15376 gbl_driver_id = rte_cryptodev_driver_id_get(
15377 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15379 if (gbl_driver_id == -1) {
15380 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
15381 return TEST_SKIPPED;
15384 if (rte_cryptodev_driver_id_get(
15385 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
15386 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
15387 return TEST_SKIPPED;
15390 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15392 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
15393 (struct unit_test_suite *) *
15394 (RTE_DIM(blk_suites) + 1));
15395 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
15396 blk_suites, RTE_DIM(blk_suites));
15397 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
15400 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15401 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
15402 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
15403 RTE_DIM(sched_mode_suites));
15404 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15405 ret = unit_test_suite_runner(&ts);
15407 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15408 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
15409 (*sched_mode_suites[sched_i]),
15410 RTE_DIM(blk_suites));
15411 free(sched_mode_suites[sched_i]->unit_test_suites);
15413 free(ts.unit_test_suites);
15417 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
15422 test_cryptodev_dpaa2_sec(void)
15424 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
15428 test_cryptodev_dpaa_sec(void)
15430 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
15434 test_cryptodev_ccp(void)
15436 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
15440 test_cryptodev_octeontx(void)
15442 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
15446 test_cryptodev_octeontx2(void)
15448 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
15452 test_cryptodev_caam_jr(void)
15454 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
15458 test_cryptodev_nitrox(void)
15460 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
15464 test_cryptodev_bcmfs(void)
15466 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
15470 test_cryptodev_qat_raw_api(void)
15472 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
15475 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15480 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15481 ret = run_cryptodev_testsuite(pmd_name);
15482 global_api_test_type = CRYPTODEV_API_TEST;
15488 test_cryptodev_cn9k(void)
15490 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
15494 test_cryptodev_cn10k(void)
15496 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
15500 test_cryptodev_dpaa2_sec_raw_api(void)
15502 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
15505 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15510 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15511 ret = run_cryptodev_testsuite(pmd_name);
15512 global_api_test_type = CRYPTODEV_API_TEST;
15518 test_cryptodev_dpaa_sec_raw_api(void)
15520 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
15523 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15528 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15529 ret = run_cryptodev_testsuite(pmd_name);
15530 global_api_test_type = CRYPTODEV_API_TEST;
15535 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
15536 test_cryptodev_dpaa2_sec_raw_api);
15537 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
15538 test_cryptodev_dpaa_sec_raw_api);
15539 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
15540 test_cryptodev_qat_raw_api);
15541 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
15542 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
15543 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
15544 test_cryptodev_cpu_aesni_mb);
15545 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
15546 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
15547 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
15548 test_cryptodev_cpu_aesni_gcm);
15549 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
15550 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
15551 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
15552 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
15553 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
15554 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
15555 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
15556 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
15557 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
15558 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
15559 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
15560 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
15561 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
15562 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
15563 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
15564 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
15565 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
15566 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);