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>
19 #include <rte_cryptodev_pmd.h>
20 #include <rte_string_fns.h>
22 #ifdef RTE_CRYPTO_SCHEDULER
23 #include <rte_cryptodev_scheduler.h>
24 #include <rte_cryptodev_scheduler_operations.h>
27 #include <rte_lcore.h>
30 #include "test_cryptodev.h"
32 #include "test_cryptodev_blockcipher.h"
33 #include "test_cryptodev_aes_test_vectors.h"
34 #include "test_cryptodev_des_test_vectors.h"
35 #include "test_cryptodev_hash_test_vectors.h"
36 #include "test_cryptodev_kasumi_test_vectors.h"
37 #include "test_cryptodev_kasumi_hash_test_vectors.h"
38 #include "test_cryptodev_snow3g_test_vectors.h"
39 #include "test_cryptodev_snow3g_hash_test_vectors.h"
40 #include "test_cryptodev_zuc_test_vectors.h"
41 #include "test_cryptodev_aead_test_vectors.h"
42 #include "test_cryptodev_hmac_test_vectors.h"
43 #include "test_cryptodev_mixed_test_vectors.h"
44 #ifdef RTE_LIB_SECURITY
45 #include "test_cryptodev_security_pdcp_test_vectors.h"
46 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
47 #include "test_cryptodev_security_pdcp_test_func.h"
48 #include "test_cryptodev_security_docsis_test_vectors.h"
50 #define SDAP_DISABLED 0
51 #define SDAP_ENABLED 1
54 #define VDEV_ARGS_SIZE 100
55 #define MAX_NB_SESSIONS 4
57 #define MAX_DRV_SERVICE_CTX_SIZE 256
59 #define MAX_RAW_DEQUEUE_COUNT 65535
62 #define OUT_OF_PLACE 1
65 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
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_testsuite_params {
76 struct rte_mempool *mbuf_pool;
77 struct rte_mempool *large_mbuf_pool;
78 struct rte_mempool *op_mpool;
79 struct rte_mempool *session_mpool;
80 struct rte_mempool *session_priv_mpool;
81 struct rte_cryptodev_config conf;
82 struct rte_cryptodev_qp_conf qp_conf;
84 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
85 uint8_t valid_dev_count;
88 struct crypto_unittest_params {
89 struct rte_crypto_sym_xform cipher_xform;
90 struct rte_crypto_sym_xform auth_xform;
91 struct rte_crypto_sym_xform aead_xform;
92 #ifdef RTE_LIB_SECURITY
93 struct rte_security_docsis_xform docsis_xform;
97 struct rte_cryptodev_sym_session *sess;
98 #ifdef RTE_LIB_SECURITY
99 struct rte_security_session *sec_session;
102 #ifdef RTE_LIB_SECURITY
103 enum rte_security_session_action_type type;
105 struct rte_crypto_op *op;
107 struct rte_mbuf *obuf, *ibuf;
112 #define ALIGN_POW2_ROUNDUP(num, align) \
113 (((num) + (align) - 1) & ~((align) - 1))
115 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
116 for (j = 0; j < num_child_ts; index++, j++) \
117 parent_ts.unit_test_suites[index] = child_ts[j]
120 * Forward declarations.
123 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
124 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
128 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
129 struct crypto_unittest_params *ut_params,
130 struct crypto_testsuite_params *ts_param,
131 const uint8_t *cipher,
132 const uint8_t *digest,
135 static struct rte_mbuf *
136 setup_test_string(struct rte_mempool *mpool,
137 const char *string, size_t len, uint8_t blocksize)
139 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
140 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
142 memset(m->buf_addr, 0, m->buf_len);
144 char *dst = rte_pktmbuf_append(m, t_len);
151 rte_memcpy(dst, string, t_len);
153 memset(dst, 0, t_len);
159 /* Get number of bytes in X bits (rounding up) */
161 ceil_byte_length(uint32_t num_bits)
164 return ((num_bits >> 3) + 1);
166 return (num_bits >> 3);
170 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
171 uint8_t is_op_success)
173 struct rte_crypto_op *op = user_data;
174 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
175 RTE_CRYPTO_OP_STATUS_ERROR;
179 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
180 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
181 uint8_t len_in_bits, uint8_t cipher_iv_len)
183 struct rte_crypto_sym_op *sop = op->sym;
184 struct rte_crypto_op *ret_op = NULL;
185 struct rte_crypto_vec data_vec[UINT8_MAX];
186 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
187 union rte_crypto_sym_ofs ofs;
188 struct rte_crypto_sym_vec vec;
189 struct rte_crypto_sgl sgl;
191 union rte_cryptodev_session_ctx sess;
193 struct rte_crypto_raw_dp_ctx *ctx;
194 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
198 int ctx_service_size;
200 int enqueue_status, dequeue_status;
202 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
203 if (ctx_service_size < 0) {
204 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
208 ctx = malloc(ctx_service_size);
210 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
214 /* Both are enums, setting crypto_sess will suit any session type */
215 sess.crypto_sess = op->sym->session;
217 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
218 op->sess_type, sess, 0) < 0) {
219 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
225 aad_auth_iv.iova = 0;
226 aad_auth_iv.va = NULL;
233 vec.digest = &digest;
234 vec.aad = &aad_auth_iv;
235 vec.status = &status;
239 if (is_cipher && is_auth) {
240 cipher_offset = sop->cipher.data.offset;
241 cipher_len = sop->cipher.data.length;
242 auth_offset = sop->auth.data.offset;
243 auth_len = sop->auth.data.length;
244 max_len = RTE_MAX(cipher_offset + cipher_len,
245 auth_offset + auth_len);
247 max_len = max_len >> 3;
248 cipher_offset = cipher_offset >> 3;
249 auth_offset = auth_offset >> 3;
250 cipher_len = cipher_len >> 3;
251 auth_len = auth_len >> 3;
253 ofs.ofs.cipher.head = cipher_offset;
254 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
255 ofs.ofs.auth.head = auth_offset;
256 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
257 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
258 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
259 aad_auth_iv.va = rte_crypto_op_ctod_offset(
260 op, void *, IV_OFFSET + cipher_iv_len);
261 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
263 digest.va = (void *)sop->auth.digest.data;
264 digest.iova = sop->auth.digest.phys_addr;
266 } else if (is_cipher) {
267 cipher_offset = sop->cipher.data.offset;
268 cipher_len = sop->cipher.data.length;
269 max_len = cipher_len + cipher_offset;
271 max_len = max_len >> 3;
272 cipher_offset = cipher_offset >> 3;
273 cipher_len = cipher_len >> 3;
275 ofs.ofs.cipher.head = cipher_offset;
276 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
277 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
278 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
280 } else if (is_auth) {
281 auth_offset = sop->auth.data.offset;
282 auth_len = sop->auth.data.length;
283 max_len = auth_len + auth_offset;
285 max_len = max_len >> 3;
286 auth_offset = auth_offset >> 3;
287 auth_len = auth_len >> 3;
289 ofs.ofs.auth.head = auth_offset;
290 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
291 aad_auth_iv.va = rte_crypto_op_ctod_offset(
292 op, void *, IV_OFFSET + cipher_iv_len);
293 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
295 digest.va = (void *)sop->auth.digest.data;
296 digest.iova = sop->auth.digest.phys_addr;
299 cipher_offset = sop->aead.data.offset;
300 cipher_len = sop->aead.data.length;
301 max_len = cipher_len + cipher_offset;
303 max_len = max_len >> 3;
304 cipher_offset = cipher_offset >> 3;
305 cipher_len = cipher_len >> 3;
307 ofs.ofs.cipher.head = cipher_offset;
308 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
309 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
310 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
311 aad_auth_iv.va = (void *)sop->aead.aad.data;
312 aad_auth_iv.iova = sop->aead.aad.phys_addr;
313 digest.va = (void *)sop->aead.digest.data;
314 digest.iova = sop->aead.digest.phys_addr;
317 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
318 data_vec, RTE_DIM(data_vec));
319 if (n < 0 || n > sop->m_src->nb_segs) {
320 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
326 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
327 &enqueue_status) < 1) {
328 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
332 if (enqueue_status == 0) {
333 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
335 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
338 } else if (enqueue_status < 0) {
339 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
344 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
345 n = rte_cryptodev_raw_dequeue_burst(ctx,
346 NULL, 1, post_process_raw_dp_op,
347 (void **)&ret_op, 0, &n_success,
349 if (dequeue_status < 0) {
350 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
357 if (n == 1 && dequeue_status == 0) {
358 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
359 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
364 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
365 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
366 RTE_CRYPTO_OP_STATUS_SUCCESS;
373 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
376 struct rte_crypto_sym_op *sop;
377 union rte_crypto_sym_ofs ofs;
378 struct rte_crypto_sgl sgl;
379 struct rte_crypto_sym_vec symvec;
380 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
381 struct rte_crypto_vec vec[UINT8_MAX];
385 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
386 sop->aead.data.length, vec, RTE_DIM(vec));
388 if (n < 0 || n != sop->m_src->nb_segs) {
389 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
397 symvec.digest = &digest_ptr;
398 symvec.aad = &aad_ptr;
402 /* for CPU crypto the IOVA address is not required */
403 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
404 digest_ptr.va = (void *)sop->aead.digest.data;
405 aad_ptr.va = (void *)sop->aead.aad.data;
409 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
413 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
415 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
419 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
422 struct rte_crypto_sym_op *sop;
423 union rte_crypto_sym_ofs ofs;
424 struct rte_crypto_sgl sgl;
425 struct rte_crypto_sym_vec symvec;
426 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
427 struct rte_crypto_vec vec[UINT8_MAX];
431 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
432 sop->auth.data.length, vec, RTE_DIM(vec));
434 if (n < 0 || n != sop->m_src->nb_segs) {
435 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
443 symvec.digest = &digest_ptr;
447 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
448 digest_ptr.va = (void *)sop->auth.digest.data;
451 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
452 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
453 (sop->cipher.data.offset + sop->cipher.data.length);
455 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
459 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
461 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
464 static struct rte_crypto_op *
465 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
468 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
470 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
471 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
477 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
480 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
481 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
488 static struct crypto_testsuite_params testsuite_params = { NULL };
489 static struct crypto_unittest_params unittest_params;
492 testsuite_setup(void)
494 struct crypto_testsuite_params *ts_params = &testsuite_params;
495 struct rte_cryptodev_info info;
496 uint32_t i = 0, nb_devs, dev_id;
499 memset(ts_params, 0, sizeof(*ts_params));
501 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
502 if (ts_params->mbuf_pool == NULL) {
503 /* Not already created so create */
504 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
506 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
508 if (ts_params->mbuf_pool == NULL) {
509 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
514 ts_params->large_mbuf_pool = rte_mempool_lookup(
515 "CRYPTO_LARGE_MBUFPOOL");
516 if (ts_params->large_mbuf_pool == NULL) {
517 /* Not already created so create */
518 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
519 "CRYPTO_LARGE_MBUFPOOL",
522 if (ts_params->large_mbuf_pool == NULL) {
524 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
529 ts_params->op_mpool = rte_crypto_op_pool_create(
530 "MBUF_CRYPTO_SYM_OP_POOL",
531 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
532 NUM_MBUFS, MBUF_CACHE_SIZE,
534 sizeof(struct rte_crypto_sym_xform) +
537 if (ts_params->op_mpool == NULL) {
538 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
542 nb_devs = rte_cryptodev_count();
544 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
548 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
549 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
550 rte_cryptodev_driver_name_get(gbl_driver_id));
554 /* Create list of valid crypto devs */
555 for (i = 0; i < nb_devs; i++) {
556 rte_cryptodev_info_get(i, &info);
557 if (info.driver_id == gbl_driver_id)
558 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
561 if (ts_params->valid_dev_count < 1)
564 /* Set up all the qps on the first of the valid devices found */
566 dev_id = ts_params->valid_devs[0];
568 rte_cryptodev_info_get(dev_id, &info);
570 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
571 ts_params->conf.socket_id = SOCKET_ID_ANY;
572 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
574 unsigned int session_size =
575 rte_cryptodev_sym_get_private_session_size(dev_id);
577 #ifdef RTE_LIB_SECURITY
578 unsigned int security_session_size = rte_security_session_get_size(
579 rte_cryptodev_get_sec_ctx(dev_id));
581 if (session_size < security_session_size)
582 session_size = security_session_size;
585 * Create mempool with maximum number of sessions.
587 if (info.sym.max_nb_sessions != 0 &&
588 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
589 RTE_LOG(ERR, USER1, "Device does not support "
590 "at least %u sessions\n",
595 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
596 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
598 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
599 "session mempool allocation failed");
601 ts_params->session_priv_mpool = rte_mempool_create(
605 0, 0, NULL, NULL, NULL,
608 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
609 "session mempool allocation failed");
613 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
615 "Failed to configure cryptodev %u with %u qps",
616 dev_id, ts_params->conf.nb_queue_pairs);
618 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
619 ts_params->qp_conf.mp_session = ts_params->session_mpool;
620 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
622 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
623 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
624 dev_id, qp_id, &ts_params->qp_conf,
625 rte_cryptodev_socket_id(dev_id)),
626 "Failed to setup queue pair %u on cryptodev %u",
634 testsuite_teardown(void)
636 struct crypto_testsuite_params *ts_params = &testsuite_params;
639 if (ts_params->mbuf_pool != NULL) {
640 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
641 rte_mempool_avail_count(ts_params->mbuf_pool));
644 if (ts_params->op_mpool != NULL) {
645 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
646 rte_mempool_avail_count(ts_params->op_mpool));
649 /* Free session mempools */
650 if (ts_params->session_priv_mpool != NULL) {
651 rte_mempool_free(ts_params->session_priv_mpool);
652 ts_params->session_priv_mpool = NULL;
655 if (ts_params->session_mpool != NULL) {
656 rte_mempool_free(ts_params->session_mpool);
657 ts_params->session_mpool = NULL;
660 res = rte_cryptodev_close(ts_params->valid_devs[0]);
662 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
666 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
667 const int *algs, uint16_t num_algs)
669 uint8_t dev_id = testsuite_params.valid_devs[0];
670 bool some_alg_supported = FALSE;
673 for (i = 0; i < num_algs && !some_alg_supported; i++) {
674 struct rte_cryptodev_sym_capability_idx alg = {
677 if (rte_cryptodev_sym_capability_get(dev_id,
679 some_alg_supported = TRUE;
681 if (!some_alg_supported)
688 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
689 uint16_t num_ciphers)
691 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
692 (const int *) ciphers, num_ciphers);
696 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
699 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
700 (const int *) auths, num_auths);
704 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
707 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
708 (const int *) aeads, num_aeads);
712 null_testsuite_setup(void)
714 struct crypto_testsuite_params *ts_params = &testsuite_params;
715 uint8_t dev_id = ts_params->valid_devs[0];
716 struct rte_cryptodev_info dev_info;
717 const enum rte_crypto_cipher_algorithm ciphers[] = {
718 RTE_CRYPTO_CIPHER_NULL
720 const enum rte_crypto_auth_algorithm auths[] = {
724 rte_cryptodev_info_get(dev_id, &dev_info);
726 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
727 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
728 "testsuite not met\n");
732 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
733 && check_auth_capabilities_supported(auths,
734 RTE_DIM(auths)) != 0) {
735 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
736 "testsuite not met\n");
744 crypto_gen_testsuite_setup(void)
746 struct crypto_testsuite_params *ts_params = &testsuite_params;
747 uint8_t dev_id = ts_params->valid_devs[0];
748 struct rte_cryptodev_info dev_info;
750 rte_cryptodev_info_get(dev_id, &dev_info);
752 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
753 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
754 "testsuite not met\n");
761 #ifdef RTE_LIB_SECURITY
763 pdcp_proto_testsuite_setup(void)
765 struct crypto_testsuite_params *ts_params = &testsuite_params;
766 uint8_t dev_id = ts_params->valid_devs[0];
767 struct rte_cryptodev_info dev_info;
768 const enum rte_crypto_cipher_algorithm ciphers[] = {
769 RTE_CRYPTO_CIPHER_NULL,
770 RTE_CRYPTO_CIPHER_AES_CTR,
771 RTE_CRYPTO_CIPHER_ZUC_EEA3,
772 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
774 const enum rte_crypto_auth_algorithm auths[] = {
775 RTE_CRYPTO_AUTH_NULL,
776 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
777 RTE_CRYPTO_AUTH_AES_CMAC,
778 RTE_CRYPTO_AUTH_ZUC_EIA3
781 rte_cryptodev_info_get(dev_id, &dev_info);
783 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
784 !(dev_info.feature_flags &
785 RTE_CRYPTODEV_FF_SECURITY)) {
786 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
787 "testsuite not met\n");
791 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
792 && check_auth_capabilities_supported(auths,
793 RTE_DIM(auths)) != 0) {
794 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
795 "testsuite not met\n");
803 docsis_proto_testsuite_setup(void)
805 struct crypto_testsuite_params *ts_params = &testsuite_params;
806 uint8_t dev_id = ts_params->valid_devs[0];
807 struct rte_cryptodev_info dev_info;
808 const enum rte_crypto_cipher_algorithm ciphers[] = {
809 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
812 rte_cryptodev_info_get(dev_id, &dev_info);
814 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
815 !(dev_info.feature_flags &
816 RTE_CRYPTODEV_FF_SECURITY)) {
817 RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
818 "Proto testsuite not met\n");
822 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
823 RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
824 "testsuite not met\n");
833 aes_ccm_auth_testsuite_setup(void)
835 struct crypto_testsuite_params *ts_params = &testsuite_params;
836 uint8_t dev_id = ts_params->valid_devs[0];
837 struct rte_cryptodev_info dev_info;
838 const enum rte_crypto_aead_algorithm aeads[] = {
839 RTE_CRYPTO_AEAD_AES_CCM
842 rte_cryptodev_info_get(dev_id, &dev_info);
844 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
845 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
846 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
847 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
848 "testsuite not met\n");
852 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
853 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
854 "testsuite not met\n");
862 aes_gcm_auth_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_aead_algorithm aeads[] = {
868 RTE_CRYPTO_AEAD_AES_GCM
871 rte_cryptodev_info_get(dev_id, &dev_info);
873 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
874 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
875 "testsuite not met\n");
879 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
880 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
881 "testsuite not met\n");
889 aes_gmac_auth_testsuite_setup(void)
891 struct crypto_testsuite_params *ts_params = &testsuite_params;
892 uint8_t dev_id = ts_params->valid_devs[0];
893 struct rte_cryptodev_info dev_info;
894 const enum rte_crypto_auth_algorithm auths[] = {
895 RTE_CRYPTO_AUTH_AES_GMAC
898 rte_cryptodev_info_get(dev_id, &dev_info);
900 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
901 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
902 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
903 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
904 "testsuite not met\n");
908 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
909 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
910 "testsuite not met\n");
918 chacha20_poly1305_testsuite_setup(void)
920 struct crypto_testsuite_params *ts_params = &testsuite_params;
921 uint8_t dev_id = ts_params->valid_devs[0];
922 struct rte_cryptodev_info dev_info;
923 const enum rte_crypto_aead_algorithm aeads[] = {
924 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
927 rte_cryptodev_info_get(dev_id, &dev_info);
929 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
930 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
931 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
932 RTE_LOG(INFO, USER1, "Feature flag requirements for "
933 "Chacha20-Poly1305 testsuite not met\n");
937 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
938 RTE_LOG(INFO, USER1, "Capability requirements for "
939 "Chacha20-Poly1305 testsuite not met\n");
947 snow3g_testsuite_setup(void)
949 struct crypto_testsuite_params *ts_params = &testsuite_params;
950 uint8_t dev_id = ts_params->valid_devs[0];
951 struct rte_cryptodev_info dev_info;
952 const enum rte_crypto_cipher_algorithm ciphers[] = {
953 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
956 const enum rte_crypto_auth_algorithm auths[] = {
957 RTE_CRYPTO_AUTH_SNOW3G_UIA2
960 rte_cryptodev_info_get(dev_id, &dev_info);
962 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
963 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
964 "testsuite not met\n");
968 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
969 && check_auth_capabilities_supported(auths,
970 RTE_DIM(auths)) != 0) {
971 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
972 "testsuite not met\n");
980 zuc_testsuite_setup(void)
982 struct crypto_testsuite_params *ts_params = &testsuite_params;
983 uint8_t dev_id = ts_params->valid_devs[0];
984 struct rte_cryptodev_info dev_info;
985 const enum rte_crypto_cipher_algorithm ciphers[] = {
986 RTE_CRYPTO_CIPHER_ZUC_EEA3
988 const enum rte_crypto_auth_algorithm auths[] = {
989 RTE_CRYPTO_AUTH_ZUC_EIA3
992 rte_cryptodev_info_get(dev_id, &dev_info);
994 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
995 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
996 "testsuite not met\n");
1000 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1001 && check_auth_capabilities_supported(auths,
1002 RTE_DIM(auths)) != 0) {
1003 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1004 "testsuite not met\n");
1005 return TEST_SKIPPED;
1012 hmac_md5_auth_testsuite_setup(void)
1014 struct crypto_testsuite_params *ts_params = &testsuite_params;
1015 uint8_t dev_id = ts_params->valid_devs[0];
1016 struct rte_cryptodev_info dev_info;
1017 const enum rte_crypto_auth_algorithm auths[] = {
1018 RTE_CRYPTO_AUTH_MD5_HMAC
1021 rte_cryptodev_info_get(dev_id, &dev_info);
1023 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1024 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1025 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1026 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1027 "Auth testsuite not met\n");
1028 return TEST_SKIPPED;
1031 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1032 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1033 "testsuite not met\n");
1034 return TEST_SKIPPED;
1041 kasumi_testsuite_setup(void)
1043 struct crypto_testsuite_params *ts_params = &testsuite_params;
1044 uint8_t dev_id = ts_params->valid_devs[0];
1045 struct rte_cryptodev_info dev_info;
1046 const enum rte_crypto_cipher_algorithm ciphers[] = {
1047 RTE_CRYPTO_CIPHER_KASUMI_F8
1049 const enum rte_crypto_auth_algorithm auths[] = {
1050 RTE_CRYPTO_AUTH_KASUMI_F9
1053 rte_cryptodev_info_get(dev_id, &dev_info);
1055 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1056 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1057 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1058 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1059 "testsuite not met\n");
1060 return TEST_SKIPPED;
1063 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1064 && check_auth_capabilities_supported(auths,
1065 RTE_DIM(auths)) != 0) {
1066 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1067 "testsuite not met\n");
1068 return TEST_SKIPPED;
1075 negative_aes_gcm_testsuite_setup(void)
1077 struct crypto_testsuite_params *ts_params = &testsuite_params;
1078 uint8_t dev_id = ts_params->valid_devs[0];
1079 struct rte_cryptodev_info dev_info;
1080 const enum rte_crypto_aead_algorithm aeads[] = {
1081 RTE_CRYPTO_AEAD_AES_GCM
1084 rte_cryptodev_info_get(dev_id, &dev_info);
1086 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1087 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1088 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1089 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1090 "AES GCM testsuite not met\n");
1091 return TEST_SKIPPED;
1094 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1095 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1096 "AES GCM testsuite not met\n");
1097 return TEST_SKIPPED;
1104 negative_aes_gmac_testsuite_setup(void)
1106 struct crypto_testsuite_params *ts_params = &testsuite_params;
1107 uint8_t dev_id = ts_params->valid_devs[0];
1108 struct rte_cryptodev_info dev_info;
1109 const enum rte_crypto_auth_algorithm auths[] = {
1110 RTE_CRYPTO_AUTH_AES_GMAC
1113 rte_cryptodev_info_get(dev_id, &dev_info);
1115 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1116 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1117 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1118 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1119 "AES GMAC testsuite not met\n");
1120 return TEST_SKIPPED;
1123 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1124 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1125 "AES GMAC testsuite not met\n");
1126 return TEST_SKIPPED;
1133 mixed_cipher_hash_testsuite_setup(void)
1135 struct crypto_testsuite_params *ts_params = &testsuite_params;
1136 uint8_t dev_id = ts_params->valid_devs[0];
1137 struct rte_cryptodev_info dev_info;
1138 uint64_t feat_flags;
1139 const enum rte_crypto_cipher_algorithm ciphers[] = {
1140 RTE_CRYPTO_CIPHER_NULL,
1141 RTE_CRYPTO_CIPHER_AES_CTR,
1142 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1143 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1145 const enum rte_crypto_auth_algorithm auths[] = {
1146 RTE_CRYPTO_AUTH_NULL,
1147 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1148 RTE_CRYPTO_AUTH_AES_CMAC,
1149 RTE_CRYPTO_AUTH_ZUC_EIA3
1152 rte_cryptodev_info_get(dev_id, &dev_info);
1153 feat_flags = dev_info.feature_flags;
1155 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1156 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1157 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1158 "Cipher Hash testsuite not met\n");
1159 return TEST_SKIPPED;
1162 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1163 && check_auth_capabilities_supported(auths,
1164 RTE_DIM(auths)) != 0) {
1165 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1166 "Cipher Hash testsuite not met\n");
1167 return TEST_SKIPPED;
1174 esn_testsuite_setup(void)
1176 struct crypto_testsuite_params *ts_params = &testsuite_params;
1177 uint8_t dev_id = ts_params->valid_devs[0];
1178 struct rte_cryptodev_info dev_info;
1179 const enum rte_crypto_cipher_algorithm ciphers[] = {
1180 RTE_CRYPTO_CIPHER_AES_CBC
1182 const enum rte_crypto_auth_algorithm auths[] = {
1183 RTE_CRYPTO_AUTH_SHA1_HMAC
1186 rte_cryptodev_info_get(dev_id, &dev_info);
1188 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1189 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1190 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1191 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1192 "testsuite not met\n");
1193 return TEST_SKIPPED;
1196 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1197 && check_auth_capabilities_supported(auths,
1198 RTE_DIM(auths)) != 0) {
1199 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1200 "testsuite not met\n");
1201 return TEST_SKIPPED;
1208 multi_session_testsuite_setup(void)
1210 struct crypto_testsuite_params *ts_params = &testsuite_params;
1211 uint8_t dev_id = ts_params->valid_devs[0];
1212 struct rte_cryptodev_info dev_info;
1213 const enum rte_crypto_cipher_algorithm ciphers[] = {
1214 RTE_CRYPTO_CIPHER_AES_CBC
1216 const enum rte_crypto_auth_algorithm auths[] = {
1217 RTE_CRYPTO_AUTH_SHA512_HMAC
1220 rte_cryptodev_info_get(dev_id, &dev_info);
1222 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1223 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1224 "Session testsuite not met\n");
1225 return TEST_SKIPPED;
1228 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1229 && check_auth_capabilities_supported(auths,
1230 RTE_DIM(auths)) != 0) {
1231 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1232 "Session testsuite not met\n");
1233 return TEST_SKIPPED;
1240 negative_hmac_sha1_testsuite_setup(void)
1242 struct crypto_testsuite_params *ts_params = &testsuite_params;
1243 uint8_t dev_id = ts_params->valid_devs[0];
1244 struct rte_cryptodev_info dev_info;
1245 const enum rte_crypto_cipher_algorithm ciphers[] = {
1246 RTE_CRYPTO_CIPHER_AES_CBC
1248 const enum rte_crypto_auth_algorithm auths[] = {
1249 RTE_CRYPTO_AUTH_SHA1_HMAC
1252 rte_cryptodev_info_get(dev_id, &dev_info);
1254 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1255 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1256 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1257 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1258 "HMAC SHA1 testsuite not met\n");
1259 return TEST_SKIPPED;
1262 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1263 && check_auth_capabilities_supported(auths,
1264 RTE_DIM(auths)) != 0) {
1265 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1266 "HMAC SHA1 testsuite not met\n");
1267 return TEST_SKIPPED;
1274 dev_configure_and_start(uint64_t ff_disable)
1276 struct crypto_testsuite_params *ts_params = &testsuite_params;
1277 struct crypto_unittest_params *ut_params = &unittest_params;
1281 /* Clear unit test parameters before running test */
1282 memset(ut_params, 0, sizeof(*ut_params));
1284 /* Reconfigure device to default parameters */
1285 ts_params->conf.socket_id = SOCKET_ID_ANY;
1286 ts_params->conf.ff_disable = ff_disable;
1287 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1288 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1289 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1291 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1293 "Failed to configure cryptodev %u",
1294 ts_params->valid_devs[0]);
1296 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1297 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1298 ts_params->valid_devs[0], qp_id,
1299 &ts_params->qp_conf,
1300 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1301 "Failed to setup queue pair %u on cryptodev %u",
1302 qp_id, ts_params->valid_devs[0]);
1306 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1308 /* Start the device */
1309 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1310 "Failed to start cryptodev %u",
1311 ts_params->valid_devs[0]);
1313 return TEST_SUCCESS;
1319 /* Configure and start the device with security feature disabled */
1320 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1324 ut_setup_security(void)
1326 /* Configure and start the device with no features disabled */
1327 return dev_configure_and_start(0);
1333 struct crypto_testsuite_params *ts_params = &testsuite_params;
1334 struct crypto_unittest_params *ut_params = &unittest_params;
1335 struct rte_cryptodev_stats stats;
1337 /* free crypto session structure */
1338 #ifdef RTE_LIB_SECURITY
1339 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1340 if (ut_params->sec_session) {
1341 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1342 (ts_params->valid_devs[0]),
1343 ut_params->sec_session);
1344 ut_params->sec_session = NULL;
1349 if (ut_params->sess) {
1350 rte_cryptodev_sym_session_clear(
1351 ts_params->valid_devs[0],
1353 rte_cryptodev_sym_session_free(ut_params->sess);
1354 ut_params->sess = NULL;
1358 /* free crypto operation structure */
1360 rte_crypto_op_free(ut_params->op);
1363 * free mbuf - both obuf and ibuf are usually the same,
1364 * so check if they point at the same address is necessary,
1365 * to avoid freeing the mbuf twice.
1367 if (ut_params->obuf) {
1368 rte_pktmbuf_free(ut_params->obuf);
1369 if (ut_params->ibuf == ut_params->obuf)
1370 ut_params->ibuf = 0;
1371 ut_params->obuf = 0;
1373 if (ut_params->ibuf) {
1374 rte_pktmbuf_free(ut_params->ibuf);
1375 ut_params->ibuf = 0;
1378 if (ts_params->mbuf_pool != NULL)
1379 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1380 rte_mempool_avail_count(ts_params->mbuf_pool));
1382 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1384 /* Stop the device */
1385 rte_cryptodev_stop(ts_params->valid_devs[0]);
1389 test_device_configure_invalid_dev_id(void)
1391 struct crypto_testsuite_params *ts_params = &testsuite_params;
1392 uint16_t dev_id, num_devs = 0;
1394 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1395 "Need at least %d devices for test", 1);
1397 /* valid dev_id values */
1398 dev_id = ts_params->valid_devs[0];
1400 /* Stop the device in case it's started so it can be configured */
1401 rte_cryptodev_stop(dev_id);
1403 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1404 "Failed test for rte_cryptodev_configure: "
1405 "invalid dev_num %u", dev_id);
1407 /* invalid dev_id values */
1410 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1411 "Failed test for rte_cryptodev_configure: "
1412 "invalid dev_num %u", dev_id);
1416 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1417 "Failed test for rte_cryptodev_configure:"
1418 "invalid dev_num %u", dev_id);
1420 return TEST_SUCCESS;
1424 test_device_configure_invalid_queue_pair_ids(void)
1426 struct crypto_testsuite_params *ts_params = &testsuite_params;
1427 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1429 /* Stop the device in case it's started so it can be configured */
1430 rte_cryptodev_stop(ts_params->valid_devs[0]);
1432 /* valid - max value queue pairs */
1433 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1435 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1437 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1438 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1440 /* valid - one queue pairs */
1441 ts_params->conf.nb_queue_pairs = 1;
1443 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1445 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1446 ts_params->valid_devs[0],
1447 ts_params->conf.nb_queue_pairs);
1450 /* invalid - zero queue pairs */
1451 ts_params->conf.nb_queue_pairs = 0;
1453 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1455 "Failed test for rte_cryptodev_configure, dev_id %u,"
1457 ts_params->valid_devs[0],
1458 ts_params->conf.nb_queue_pairs);
1461 /* invalid - max value supported by field queue pairs */
1462 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1464 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1466 "Failed test for rte_cryptodev_configure, dev_id %u,"
1468 ts_params->valid_devs[0],
1469 ts_params->conf.nb_queue_pairs);
1472 /* invalid - max value + 1 queue pairs */
1473 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1475 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1477 "Failed test for rte_cryptodev_configure, dev_id %u,"
1479 ts_params->valid_devs[0],
1480 ts_params->conf.nb_queue_pairs);
1482 /* revert to original testsuite value */
1483 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1485 return TEST_SUCCESS;
1489 test_queue_pair_descriptor_setup(void)
1491 struct crypto_testsuite_params *ts_params = &testsuite_params;
1492 struct rte_cryptodev_qp_conf qp_conf = {
1493 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1497 /* Stop the device in case it's started so it can be configured */
1498 rte_cryptodev_stop(ts_params->valid_devs[0]);
1500 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1502 "Failed to configure cryptodev %u",
1503 ts_params->valid_devs[0]);
1506 * Test various ring sizes on this device. memzones can't be
1507 * freed so are re-used if ring is released and re-created.
1509 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1510 qp_conf.mp_session = ts_params->session_mpool;
1511 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1513 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1514 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1515 ts_params->valid_devs[0], qp_id, &qp_conf,
1516 rte_cryptodev_socket_id(
1517 ts_params->valid_devs[0])),
1519 "rte_cryptodev_queue_pair_setup: num_inflights "
1520 "%u on qp %u on cryptodev %u",
1521 qp_conf.nb_descriptors, qp_id,
1522 ts_params->valid_devs[0]);
1525 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1527 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1528 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1529 ts_params->valid_devs[0], qp_id, &qp_conf,
1530 rte_cryptodev_socket_id(
1531 ts_params->valid_devs[0])),
1533 " rte_cryptodev_queue_pair_setup: num_inflights"
1534 " %u on qp %u on cryptodev %u",
1535 qp_conf.nb_descriptors, qp_id,
1536 ts_params->valid_devs[0]);
1539 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1541 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1542 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1543 ts_params->valid_devs[0], qp_id, &qp_conf,
1544 rte_cryptodev_socket_id(
1545 ts_params->valid_devs[0])),
1547 "rte_cryptodev_queue_pair_setup: num_inflights"
1548 " %u on qp %u on cryptodev %u",
1549 qp_conf.nb_descriptors, qp_id,
1550 ts_params->valid_devs[0]);
1553 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1555 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1556 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1557 ts_params->valid_devs[0], qp_id, &qp_conf,
1558 rte_cryptodev_socket_id(
1559 ts_params->valid_devs[0])),
1561 " rte_cryptodev_queue_pair_setup:"
1562 "num_inflights %u on qp %u on cryptodev %u",
1563 qp_conf.nb_descriptors, qp_id,
1564 ts_params->valid_devs[0]);
1567 /* test invalid queue pair id */
1568 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1570 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1572 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1573 ts_params->valid_devs[0],
1575 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1576 "Failed test for rte_cryptodev_queue_pair_setup:"
1577 "invalid qp %u on cryptodev %u",
1578 qp_id, ts_params->valid_devs[0]);
1580 qp_id = 0xffff; /*invalid*/
1582 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1583 ts_params->valid_devs[0],
1585 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1586 "Failed test for rte_cryptodev_queue_pair_setup:"
1587 "invalid qp %u on cryptodev %u",
1588 qp_id, ts_params->valid_devs[0]);
1590 return TEST_SUCCESS;
1593 /* ***** Plaintext data for tests ***** */
1595 const char catch_22_quote_1[] =
1596 "There was only one catch and that was Catch-22, which "
1597 "specified that a concern for one's safety in the face of "
1598 "dangers that were real and immediate was the process of a "
1599 "rational mind. Orr was crazy and could be grounded. All he "
1600 "had to do was ask; and as soon as he did, he would no longer "
1601 "be crazy and would have to fly more missions. Orr would be "
1602 "crazy to fly more missions and sane if he didn't, but if he "
1603 "was sane he had to fly them. If he flew them he was crazy "
1604 "and didn't have to; but if he didn't want to he was sane and "
1605 "had to. Yossarian was moved very deeply by the absolute "
1606 "simplicity of this clause of Catch-22 and let out a "
1607 "respectful whistle. \"That's some catch, that Catch-22\", he "
1608 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1610 const char catch_22_quote[] =
1611 "What a lousy earth! He wondered how many people were "
1612 "destitute that same night even in his own prosperous country, "
1613 "how many homes were shanties, how many husbands were drunk "
1614 "and wives socked, and how many children were bullied, abused, "
1615 "or abandoned. How many families hungered for food they could "
1616 "not afford to buy? How many hearts were broken? How many "
1617 "suicides would take place that same night, how many people "
1618 "would go insane? How many cockroaches and landlords would "
1619 "triumph? How many winners were losers, successes failures, "
1620 "and rich men poor men? How many wise guys were stupid? How "
1621 "many happy endings were unhappy endings? How many honest men "
1622 "were liars, brave men cowards, loyal men traitors, how many "
1623 "sainted men were corrupt, how many people in positions of "
1624 "trust had sold their souls to bodyguards, how many had never "
1625 "had souls? How many straight-and-narrow paths were crooked "
1626 "paths? How many best families were worst families and how "
1627 "many good people were bad people? When you added them all up "
1628 "and then subtracted, you might be left with only the children, "
1629 "and perhaps with Albert Einstein and an old violinist or "
1630 "sculptor somewhere.";
1632 #define QUOTE_480_BYTES (480)
1633 #define QUOTE_512_BYTES (512)
1634 #define QUOTE_768_BYTES (768)
1635 #define QUOTE_1024_BYTES (1024)
1639 /* ***** SHA1 Hash Tests ***** */
1641 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1643 static uint8_t hmac_sha1_key[] = {
1644 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1645 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1646 0xDE, 0xF4, 0xDE, 0xAD };
1648 /* ***** SHA224 Hash Tests ***** */
1650 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1653 /* ***** AES-CBC Cipher Tests ***** */
1655 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1656 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1658 static uint8_t aes_cbc_key[] = {
1659 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1660 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1662 static uint8_t aes_cbc_iv[] = {
1663 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1664 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1667 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1669 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1670 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1671 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1672 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1673 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1674 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1675 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1676 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1677 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1678 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1679 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1680 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1681 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1682 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1683 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1684 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1685 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1686 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1687 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1688 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1689 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1690 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1691 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1692 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1693 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1694 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1695 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1696 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1697 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1698 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1699 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1700 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1701 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1702 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1703 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1704 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1705 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1706 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1707 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1708 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1709 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1710 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1711 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1712 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1713 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1714 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1715 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1716 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1717 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1718 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1719 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1720 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1721 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1722 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1723 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1724 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1725 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1726 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1727 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1728 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1729 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1730 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1731 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1732 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1733 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1736 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1737 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1738 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1739 0x18, 0x8c, 0x1d, 0x32
1743 /* Multisession Vector context Test */
1744 /*Begin Session 0 */
1745 static uint8_t ms_aes_cbc_key0[] = {
1746 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1747 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1750 static uint8_t ms_aes_cbc_iv0[] = {
1751 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1752 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1755 static const uint8_t ms_aes_cbc_cipher0[] = {
1756 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1757 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1758 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1759 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1760 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1761 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1762 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1763 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1764 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1765 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1766 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1767 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1768 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1769 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1770 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1771 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1772 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1773 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1774 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1775 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1776 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1777 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1778 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1779 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1780 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1781 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1782 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1783 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1784 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1785 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1786 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1787 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1788 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1789 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1790 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1791 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1792 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1793 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1794 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1795 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1796 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1797 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1798 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1799 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1800 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1801 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1802 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1803 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1804 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1805 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1806 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1807 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1808 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1809 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1810 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1811 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1812 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1813 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1814 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1815 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1816 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1817 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1818 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1819 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1823 static uint8_t ms_hmac_key0[] = {
1824 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1825 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1826 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1827 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1828 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1829 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1830 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1831 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1834 static const uint8_t ms_hmac_digest0[] = {
1835 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1836 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1837 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1838 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1839 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1840 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1841 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1842 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1846 /* Begin session 1 */
1848 static uint8_t ms_aes_cbc_key1[] = {
1849 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1850 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1853 static uint8_t ms_aes_cbc_iv1[] = {
1854 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1855 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1858 static const uint8_t ms_aes_cbc_cipher1[] = {
1859 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1860 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1861 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1862 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1863 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1864 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1865 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1866 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1867 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1868 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1869 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1870 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1871 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1872 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1873 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1874 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1875 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1876 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1877 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1878 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1879 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1880 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1881 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1882 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1883 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1884 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1885 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1886 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1887 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1888 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1889 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1890 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1891 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1892 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1893 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1894 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1895 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1896 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1897 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1898 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1899 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1900 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1901 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1902 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1903 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1904 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1905 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1906 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1907 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1908 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1909 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1910 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1911 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1912 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1913 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1914 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1915 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1916 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1917 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1918 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1919 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1920 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1921 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1922 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1926 static uint8_t ms_hmac_key1[] = {
1927 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1928 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1929 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1930 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1931 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1932 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1933 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1934 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1937 static const uint8_t ms_hmac_digest1[] = {
1938 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1939 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1940 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1941 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1942 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1943 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1944 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1945 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1948 /* Begin Session 2 */
1949 static uint8_t ms_aes_cbc_key2[] = {
1950 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1951 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1954 static uint8_t ms_aes_cbc_iv2[] = {
1955 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1956 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1959 static const uint8_t ms_aes_cbc_cipher2[] = {
1960 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1961 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1962 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1963 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1964 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1965 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1966 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1967 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1968 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1969 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1970 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1971 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1972 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1973 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1974 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1975 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1976 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1977 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1978 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1979 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1980 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1981 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1982 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1983 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1984 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1985 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1986 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1987 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1988 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1989 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1990 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1991 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1992 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1993 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1994 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1995 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1996 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1997 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1998 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1999 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2000 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2001 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2002 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2003 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2004 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2005 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2006 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2007 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2008 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2009 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2010 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2011 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2012 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2013 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2014 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2015 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2016 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2017 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2018 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2019 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2020 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2021 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2022 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2023 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2026 static uint8_t ms_hmac_key2[] = {
2027 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2028 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2029 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2030 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2031 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2032 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2033 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2034 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2037 static const uint8_t ms_hmac_digest2[] = {
2038 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2039 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2040 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2041 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2042 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2043 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2044 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2045 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2052 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2054 struct crypto_testsuite_params *ts_params = &testsuite_params;
2055 struct crypto_unittest_params *ut_params = &unittest_params;
2057 /* Verify the capabilities */
2058 struct rte_cryptodev_sym_capability_idx cap_idx;
2059 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2060 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2061 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2063 return TEST_SKIPPED;
2064 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2065 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2066 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2068 return TEST_SKIPPED;
2070 /* Generate test mbuf data and space for digest */
2071 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2072 catch_22_quote, QUOTE_512_BYTES, 0);
2074 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2075 DIGEST_BYTE_LENGTH_SHA1);
2076 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2078 /* Setup Cipher Parameters */
2079 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2080 ut_params->cipher_xform.next = &ut_params->auth_xform;
2082 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2083 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2084 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2085 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2086 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2087 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2089 /* Setup HMAC Parameters */
2090 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2092 ut_params->auth_xform.next = NULL;
2094 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2095 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2096 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2097 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2098 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2100 ut_params->sess = rte_cryptodev_sym_session_create(
2101 ts_params->session_mpool);
2103 /* Create crypto session*/
2104 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2105 ut_params->sess, &ut_params->cipher_xform,
2106 ts_params->session_priv_mpool);
2107 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2109 /* Generate crypto op data structure */
2110 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2111 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2112 TEST_ASSERT_NOT_NULL(ut_params->op,
2113 "Failed to allocate symmetric crypto operation struct");
2115 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2117 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2119 /* set crypto operation source mbuf */
2120 sym_op->m_src = ut_params->ibuf;
2122 /* Set crypto operation authentication parameters */
2123 sym_op->auth.digest.data = ut_params->digest;
2124 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2125 ut_params->ibuf, QUOTE_512_BYTES);
2127 sym_op->auth.data.offset = 0;
2128 sym_op->auth.data.length = QUOTE_512_BYTES;
2130 /* Copy IV at the end of the crypto operation */
2131 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2132 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2134 /* Set crypto operation cipher parameters */
2135 sym_op->cipher.data.offset = 0;
2136 sym_op->cipher.data.length = QUOTE_512_BYTES;
2138 /* Process crypto operation */
2139 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2140 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2143 TEST_ASSERT_NOT_NULL(
2144 process_crypto_request(ts_params->valid_devs[0],
2146 "failed to process sym crypto op");
2148 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2149 "crypto op processing failed");
2152 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2155 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2156 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2158 "ciphertext data not as expected");
2160 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2162 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2163 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2164 gbl_driver_id == rte_cryptodev_driver_id_get(
2165 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2166 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2167 DIGEST_BYTE_LENGTH_SHA1,
2168 "Generated digest data not as expected");
2170 return TEST_SUCCESS;
2173 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2175 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2177 static uint8_t hmac_sha512_key[] = {
2178 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2179 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2180 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2181 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2182 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2183 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2184 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2185 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2187 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2188 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2189 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2190 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2191 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2192 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2193 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2194 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2195 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2200 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2201 struct crypto_unittest_params *ut_params,
2202 uint8_t *cipher_key,
2206 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2207 struct crypto_unittest_params *ut_params,
2208 struct crypto_testsuite_params *ts_params,
2209 const uint8_t *cipher,
2210 const uint8_t *digest,
2215 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2216 struct crypto_unittest_params *ut_params,
2217 uint8_t *cipher_key,
2221 /* Setup Cipher Parameters */
2222 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2223 ut_params->cipher_xform.next = NULL;
2225 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2226 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2227 ut_params->cipher_xform.cipher.key.data = cipher_key;
2228 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2229 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2230 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2232 /* Setup HMAC Parameters */
2233 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2234 ut_params->auth_xform.next = &ut_params->cipher_xform;
2236 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2237 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2238 ut_params->auth_xform.auth.key.data = hmac_key;
2239 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2240 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2242 return TEST_SUCCESS;
2247 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2248 struct crypto_unittest_params *ut_params,
2249 struct crypto_testsuite_params *ts_params,
2250 const uint8_t *cipher,
2251 const uint8_t *digest,
2254 /* Generate test mbuf data and digest */
2255 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2258 QUOTE_512_BYTES, 0);
2260 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2261 DIGEST_BYTE_LENGTH_SHA512);
2262 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2264 rte_memcpy(ut_params->digest,
2266 DIGEST_BYTE_LENGTH_SHA512);
2268 /* Generate Crypto op data structure */
2269 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2270 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2271 TEST_ASSERT_NOT_NULL(ut_params->op,
2272 "Failed to allocate symmetric crypto operation struct");
2274 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2276 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2278 /* set crypto operation source mbuf */
2279 sym_op->m_src = ut_params->ibuf;
2281 sym_op->auth.digest.data = ut_params->digest;
2282 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2283 ut_params->ibuf, QUOTE_512_BYTES);
2285 sym_op->auth.data.offset = 0;
2286 sym_op->auth.data.length = QUOTE_512_BYTES;
2288 /* Copy IV at the end of the crypto operation */
2289 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2290 iv, CIPHER_IV_LENGTH_AES_CBC);
2292 sym_op->cipher.data.offset = 0;
2293 sym_op->cipher.data.length = QUOTE_512_BYTES;
2295 /* Process crypto operation */
2296 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2297 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2299 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2300 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2301 ut_params->op, 1, 1, 0, 0);
2303 TEST_ASSERT_NOT_NULL(
2304 process_crypto_request(ts_params->valid_devs[0],
2306 "failed to process sym crypto op");
2308 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2309 "crypto op processing failed");
2311 ut_params->obuf = ut_params->op->sym->m_src;
2314 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2315 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2318 "Plaintext data not as expected");
2321 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2322 "Digest verification failed");
2324 return TEST_SUCCESS;
2328 test_blockcipher(enum blockcipher_test_type test_type)
2330 struct crypto_testsuite_params *ts_params = &testsuite_params;
2333 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2334 ts_params->op_mpool,
2335 ts_params->session_mpool, ts_params->session_priv_mpool,
2336 ts_params->valid_devs[0],
2339 if (status == -ENOTSUP)
2342 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2344 return TEST_SUCCESS;
2348 test_AES_cipheronly_all(void)
2350 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
2354 test_AES_docsis_all(void)
2356 /* Data-path service does not support DOCSIS yet */
2357 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2358 return TEST_SKIPPED;
2359 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
2363 test_DES_docsis_all(void)
2365 /* Data-path service does not support DOCSIS yet */
2366 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2367 return TEST_SKIPPED;
2368 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
2372 test_DES_cipheronly_all(void)
2374 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
2378 test_authonly_all(void)
2380 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
2384 test_AES_chain_all(void)
2386 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
2390 test_3DES_chain_all(void)
2392 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
2396 test_3DES_cipheronly_all(void)
2398 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
2401 /* ***** SNOW 3G Tests ***** */
2403 create_wireless_algo_hash_session(uint8_t dev_id,
2404 const uint8_t *key, const uint8_t key_len,
2405 const uint8_t iv_len, const uint8_t auth_len,
2406 enum rte_crypto_auth_operation op,
2407 enum rte_crypto_auth_algorithm algo)
2409 uint8_t hash_key[key_len];
2412 struct crypto_testsuite_params *ts_params = &testsuite_params;
2413 struct crypto_unittest_params *ut_params = &unittest_params;
2415 memcpy(hash_key, key, key_len);
2417 debug_hexdump(stdout, "key:", key, key_len);
2419 /* Setup Authentication Parameters */
2420 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2421 ut_params->auth_xform.next = NULL;
2423 ut_params->auth_xform.auth.op = op;
2424 ut_params->auth_xform.auth.algo = algo;
2425 ut_params->auth_xform.auth.key.length = key_len;
2426 ut_params->auth_xform.auth.key.data = hash_key;
2427 ut_params->auth_xform.auth.digest_length = auth_len;
2428 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2429 ut_params->auth_xform.auth.iv.length = iv_len;
2430 ut_params->sess = rte_cryptodev_sym_session_create(
2431 ts_params->session_mpool);
2433 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2434 &ut_params->auth_xform,
2435 ts_params->session_priv_mpool);
2436 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2437 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2442 create_wireless_algo_cipher_session(uint8_t dev_id,
2443 enum rte_crypto_cipher_operation op,
2444 enum rte_crypto_cipher_algorithm algo,
2445 const uint8_t *key, const uint8_t key_len,
2448 uint8_t cipher_key[key_len];
2450 struct crypto_testsuite_params *ts_params = &testsuite_params;
2451 struct crypto_unittest_params *ut_params = &unittest_params;
2453 memcpy(cipher_key, key, key_len);
2455 /* Setup Cipher Parameters */
2456 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2457 ut_params->cipher_xform.next = NULL;
2459 ut_params->cipher_xform.cipher.algo = algo;
2460 ut_params->cipher_xform.cipher.op = op;
2461 ut_params->cipher_xform.cipher.key.data = cipher_key;
2462 ut_params->cipher_xform.cipher.key.length = key_len;
2463 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2464 ut_params->cipher_xform.cipher.iv.length = iv_len;
2466 debug_hexdump(stdout, "key:", key, key_len);
2468 /* Create Crypto session */
2469 ut_params->sess = rte_cryptodev_sym_session_create(
2470 ts_params->session_mpool);
2472 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2473 &ut_params->cipher_xform,
2474 ts_params->session_priv_mpool);
2475 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2476 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2481 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2482 unsigned int cipher_len,
2483 unsigned int cipher_offset)
2485 struct crypto_testsuite_params *ts_params = &testsuite_params;
2486 struct crypto_unittest_params *ut_params = &unittest_params;
2488 /* Generate Crypto op data structure */
2489 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2490 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2491 TEST_ASSERT_NOT_NULL(ut_params->op,
2492 "Failed to allocate pktmbuf offload");
2494 /* Set crypto operation data parameters */
2495 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2497 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2499 /* set crypto operation source mbuf */
2500 sym_op->m_src = ut_params->ibuf;
2503 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2505 sym_op->cipher.data.length = cipher_len;
2506 sym_op->cipher.data.offset = cipher_offset;
2511 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2512 unsigned int cipher_len,
2513 unsigned int cipher_offset)
2515 struct crypto_testsuite_params *ts_params = &testsuite_params;
2516 struct crypto_unittest_params *ut_params = &unittest_params;
2518 /* Generate Crypto op data structure */
2519 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2520 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2521 TEST_ASSERT_NOT_NULL(ut_params->op,
2522 "Failed to allocate pktmbuf offload");
2524 /* Set crypto operation data parameters */
2525 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2527 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2529 /* set crypto operation source mbuf */
2530 sym_op->m_src = ut_params->ibuf;
2531 sym_op->m_dst = ut_params->obuf;
2534 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2536 sym_op->cipher.data.length = cipher_len;
2537 sym_op->cipher.data.offset = cipher_offset;
2542 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2543 enum rte_crypto_cipher_operation cipher_op,
2544 enum rte_crypto_auth_operation auth_op,
2545 enum rte_crypto_auth_algorithm auth_algo,
2546 enum rte_crypto_cipher_algorithm cipher_algo,
2547 const uint8_t *key, uint8_t key_len,
2548 uint8_t auth_iv_len, uint8_t auth_len,
2549 uint8_t cipher_iv_len)
2552 uint8_t cipher_auth_key[key_len];
2555 struct crypto_testsuite_params *ts_params = &testsuite_params;
2556 struct crypto_unittest_params *ut_params = &unittest_params;
2558 memcpy(cipher_auth_key, key, key_len);
2560 /* Setup Authentication Parameters */
2561 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2562 ut_params->auth_xform.next = NULL;
2564 ut_params->auth_xform.auth.op = auth_op;
2565 ut_params->auth_xform.auth.algo = auth_algo;
2566 ut_params->auth_xform.auth.key.length = key_len;
2567 /* Hash key = cipher key */
2568 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2569 ut_params->auth_xform.auth.digest_length = auth_len;
2570 /* Auth IV will be after cipher IV */
2571 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2572 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2574 /* Setup Cipher Parameters */
2575 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2576 ut_params->cipher_xform.next = &ut_params->auth_xform;
2578 ut_params->cipher_xform.cipher.algo = cipher_algo;
2579 ut_params->cipher_xform.cipher.op = cipher_op;
2580 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2581 ut_params->cipher_xform.cipher.key.length = key_len;
2582 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2583 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2585 debug_hexdump(stdout, "key:", key, key_len);
2587 /* Create Crypto session*/
2588 ut_params->sess = rte_cryptodev_sym_session_create(
2589 ts_params->session_mpool);
2590 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2592 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2593 &ut_params->cipher_xform,
2594 ts_params->session_priv_mpool);
2595 if (status == -ENOTSUP)
2596 return TEST_SKIPPED;
2598 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2603 create_wireless_cipher_auth_session(uint8_t dev_id,
2604 enum rte_crypto_cipher_operation cipher_op,
2605 enum rte_crypto_auth_operation auth_op,
2606 enum rte_crypto_auth_algorithm auth_algo,
2607 enum rte_crypto_cipher_algorithm cipher_algo,
2608 const struct wireless_test_data *tdata)
2610 const uint8_t key_len = tdata->key.len;
2611 uint8_t cipher_auth_key[key_len];
2614 struct crypto_testsuite_params *ts_params = &testsuite_params;
2615 struct crypto_unittest_params *ut_params = &unittest_params;
2616 const uint8_t *key = tdata->key.data;
2617 const uint8_t auth_len = tdata->digest.len;
2618 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2619 uint8_t auth_iv_len = tdata->auth_iv.len;
2621 memcpy(cipher_auth_key, key, key_len);
2623 /* Setup Authentication Parameters */
2624 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2625 ut_params->auth_xform.next = NULL;
2627 ut_params->auth_xform.auth.op = auth_op;
2628 ut_params->auth_xform.auth.algo = auth_algo;
2629 ut_params->auth_xform.auth.key.length = key_len;
2630 /* Hash key = cipher key */
2631 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2632 ut_params->auth_xform.auth.digest_length = auth_len;
2633 /* Auth IV will be after cipher IV */
2634 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2635 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2637 /* Setup Cipher Parameters */
2638 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2639 ut_params->cipher_xform.next = &ut_params->auth_xform;
2641 ut_params->cipher_xform.cipher.algo = cipher_algo;
2642 ut_params->cipher_xform.cipher.op = cipher_op;
2643 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2644 ut_params->cipher_xform.cipher.key.length = key_len;
2645 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2646 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2649 debug_hexdump(stdout, "key:", key, key_len);
2651 /* Create Crypto session*/
2652 ut_params->sess = rte_cryptodev_sym_session_create(
2653 ts_params->session_mpool);
2655 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2656 &ut_params->cipher_xform,
2657 ts_params->session_priv_mpool);
2658 if (status == -ENOTSUP)
2659 return TEST_SKIPPED;
2661 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2662 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2667 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2668 const struct wireless_test_data *tdata)
2670 return create_wireless_cipher_auth_session(dev_id,
2671 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2672 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2673 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2677 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2678 enum rte_crypto_cipher_operation cipher_op,
2679 enum rte_crypto_auth_operation auth_op,
2680 enum rte_crypto_auth_algorithm auth_algo,
2681 enum rte_crypto_cipher_algorithm cipher_algo,
2682 const uint8_t *key, const uint8_t key_len,
2683 uint8_t auth_iv_len, uint8_t auth_len,
2684 uint8_t cipher_iv_len)
2686 uint8_t auth_cipher_key[key_len];
2688 struct crypto_testsuite_params *ts_params = &testsuite_params;
2689 struct crypto_unittest_params *ut_params = &unittest_params;
2691 memcpy(auth_cipher_key, key, key_len);
2693 /* Setup Authentication Parameters */
2694 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2695 ut_params->auth_xform.auth.op = auth_op;
2696 ut_params->auth_xform.next = &ut_params->cipher_xform;
2697 ut_params->auth_xform.auth.algo = auth_algo;
2698 ut_params->auth_xform.auth.key.length = key_len;
2699 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2700 ut_params->auth_xform.auth.digest_length = auth_len;
2701 /* Auth IV will be after cipher IV */
2702 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2703 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2705 /* Setup Cipher Parameters */
2706 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2707 ut_params->cipher_xform.next = NULL;
2708 ut_params->cipher_xform.cipher.algo = cipher_algo;
2709 ut_params->cipher_xform.cipher.op = cipher_op;
2710 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2711 ut_params->cipher_xform.cipher.key.length = key_len;
2712 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2713 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2715 debug_hexdump(stdout, "key:", key, key_len);
2717 /* Create Crypto session*/
2718 ut_params->sess = rte_cryptodev_sym_session_create(
2719 ts_params->session_mpool);
2720 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2722 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2723 ut_params->auth_xform.next = NULL;
2724 ut_params->cipher_xform.next = &ut_params->auth_xform;
2725 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2726 &ut_params->cipher_xform,
2727 ts_params->session_priv_mpool);
2730 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2731 &ut_params->auth_xform,
2732 ts_params->session_priv_mpool);
2734 if (status == -ENOTSUP)
2735 return TEST_SKIPPED;
2737 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2743 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2744 unsigned int auth_tag_len,
2745 const uint8_t *iv, unsigned int iv_len,
2746 unsigned int data_pad_len,
2747 enum rte_crypto_auth_operation op,
2748 unsigned int auth_len, unsigned int auth_offset)
2750 struct crypto_testsuite_params *ts_params = &testsuite_params;
2752 struct crypto_unittest_params *ut_params = &unittest_params;
2754 /* Generate Crypto op data structure */
2755 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2756 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2757 TEST_ASSERT_NOT_NULL(ut_params->op,
2758 "Failed to allocate pktmbuf offload");
2760 /* Set crypto operation data parameters */
2761 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2763 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2765 /* set crypto operation source mbuf */
2766 sym_op->m_src = ut_params->ibuf;
2769 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2772 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2773 ut_params->ibuf, auth_tag_len);
2775 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2776 "no room to append auth tag");
2777 ut_params->digest = sym_op->auth.digest.data;
2778 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2779 ut_params->ibuf, data_pad_len);
2780 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2781 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2783 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2785 debug_hexdump(stdout, "digest:",
2786 sym_op->auth.digest.data,
2789 sym_op->auth.data.length = auth_len;
2790 sym_op->auth.data.offset = auth_offset;
2796 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2797 enum rte_crypto_auth_operation op)
2799 struct crypto_testsuite_params *ts_params = &testsuite_params;
2800 struct crypto_unittest_params *ut_params = &unittest_params;
2802 const uint8_t *auth_tag = tdata->digest.data;
2803 const unsigned int auth_tag_len = tdata->digest.len;
2804 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2805 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2807 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2808 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2809 const uint8_t *auth_iv = tdata->auth_iv.data;
2810 const uint8_t auth_iv_len = tdata->auth_iv.len;
2811 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2812 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2814 /* Generate Crypto op data structure */
2815 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2816 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2817 TEST_ASSERT_NOT_NULL(ut_params->op,
2818 "Failed to allocate pktmbuf offload");
2819 /* Set crypto operation data parameters */
2820 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2822 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2824 /* set crypto operation source mbuf */
2825 sym_op->m_src = ut_params->ibuf;
2828 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2829 ut_params->ibuf, auth_tag_len);
2831 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2832 "no room to append auth tag");
2833 ut_params->digest = sym_op->auth.digest.data;
2834 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2835 ut_params->ibuf, data_pad_len);
2836 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2837 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2839 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2841 debug_hexdump(stdout, "digest:",
2842 sym_op->auth.digest.data,
2845 /* Copy cipher and auth IVs at the end of the crypto operation */
2846 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2848 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2849 iv_ptr += cipher_iv_len;
2850 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2852 sym_op->cipher.data.length = cipher_len;
2853 sym_op->cipher.data.offset = 0;
2854 sym_op->auth.data.length = auth_len;
2855 sym_op->auth.data.offset = 0;
2861 create_zuc_cipher_hash_generate_operation(
2862 const struct wireless_test_data *tdata)
2864 return create_wireless_cipher_hash_operation(tdata,
2865 RTE_CRYPTO_AUTH_OP_GENERATE);
2869 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2870 const unsigned auth_tag_len,
2871 const uint8_t *auth_iv, uint8_t auth_iv_len,
2872 unsigned data_pad_len,
2873 enum rte_crypto_auth_operation op,
2874 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2875 const unsigned cipher_len, const unsigned cipher_offset,
2876 const unsigned auth_len, const unsigned auth_offset)
2878 struct crypto_testsuite_params *ts_params = &testsuite_params;
2879 struct crypto_unittest_params *ut_params = &unittest_params;
2881 enum rte_crypto_cipher_algorithm cipher_algo =
2882 ut_params->cipher_xform.cipher.algo;
2883 enum rte_crypto_auth_algorithm auth_algo =
2884 ut_params->auth_xform.auth.algo;
2886 /* Generate Crypto op data structure */
2887 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2888 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2889 TEST_ASSERT_NOT_NULL(ut_params->op,
2890 "Failed to allocate pktmbuf offload");
2891 /* Set crypto operation data parameters */
2892 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2894 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2896 /* set crypto operation source mbuf */
2897 sym_op->m_src = ut_params->ibuf;
2900 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2901 ut_params->ibuf, auth_tag_len);
2903 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2904 "no room to append auth tag");
2905 ut_params->digest = sym_op->auth.digest.data;
2907 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2908 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2909 ut_params->ibuf, data_pad_len);
2911 struct rte_mbuf *m = ut_params->ibuf;
2912 unsigned int offset = data_pad_len;
2914 while (offset > m->data_len && m->next != NULL) {
2915 offset -= m->data_len;
2918 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2922 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2923 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2925 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2927 debug_hexdump(stdout, "digest:",
2928 sym_op->auth.digest.data,
2931 /* Copy cipher and auth IVs at the end of the crypto operation */
2932 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2934 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2935 iv_ptr += cipher_iv_len;
2936 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2938 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2939 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2940 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2941 sym_op->cipher.data.length = cipher_len;
2942 sym_op->cipher.data.offset = cipher_offset;
2944 sym_op->cipher.data.length = cipher_len >> 3;
2945 sym_op->cipher.data.offset = cipher_offset >> 3;
2948 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2949 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2950 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2951 sym_op->auth.data.length = auth_len;
2952 sym_op->auth.data.offset = auth_offset;
2954 sym_op->auth.data.length = auth_len >> 3;
2955 sym_op->auth.data.offset = auth_offset >> 3;
2962 create_wireless_algo_auth_cipher_operation(
2963 const uint8_t *auth_tag, unsigned int auth_tag_len,
2964 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2965 const uint8_t *auth_iv, uint8_t auth_iv_len,
2966 unsigned int data_pad_len,
2967 unsigned int cipher_len, unsigned int cipher_offset,
2968 unsigned int auth_len, unsigned int auth_offset,
2969 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2971 struct crypto_testsuite_params *ts_params = &testsuite_params;
2972 struct crypto_unittest_params *ut_params = &unittest_params;
2974 enum rte_crypto_cipher_algorithm cipher_algo =
2975 ut_params->cipher_xform.cipher.algo;
2976 enum rte_crypto_auth_algorithm auth_algo =
2977 ut_params->auth_xform.auth.algo;
2979 /* Generate Crypto op data structure */
2980 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2981 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2982 TEST_ASSERT_NOT_NULL(ut_params->op,
2983 "Failed to allocate pktmbuf offload");
2985 /* Set crypto operation data parameters */
2986 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2988 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2990 /* set crypto operation mbufs */
2991 sym_op->m_src = ut_params->ibuf;
2992 if (op_mode == OUT_OF_PLACE)
2993 sym_op->m_dst = ut_params->obuf;
2997 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2998 (op_mode == IN_PLACE ?
2999 ut_params->ibuf : ut_params->obuf),
3000 uint8_t *, data_pad_len);
3001 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3002 (op_mode == IN_PLACE ?
3003 ut_params->ibuf : ut_params->obuf),
3005 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3007 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3008 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3009 sym_op->m_src : sym_op->m_dst);
3010 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3011 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3012 sgl_buf = sgl_buf->next;
3014 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3015 uint8_t *, remaining_off);
3016 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3018 memset(sym_op->auth.digest.data, 0, remaining_off);
3019 while (sgl_buf->next != NULL) {
3020 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3021 0, rte_pktmbuf_data_len(sgl_buf));
3022 sgl_buf = sgl_buf->next;
3026 /* Copy digest for the verification */
3028 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3030 /* Copy cipher and auth IVs at the end of the crypto operation */
3031 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3032 ut_params->op, uint8_t *, IV_OFFSET);
3034 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3035 iv_ptr += cipher_iv_len;
3036 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3038 /* Only copy over the offset data needed from src to dst in OOP,
3039 * if the auth and cipher offsets are not aligned
3041 if (op_mode == OUT_OF_PLACE) {
3042 if (cipher_offset > auth_offset)
3044 rte_pktmbuf_mtod_offset(
3046 uint8_t *, auth_offset >> 3),
3047 rte_pktmbuf_mtod_offset(
3049 uint8_t *, auth_offset >> 3),
3050 ((cipher_offset >> 3) - (auth_offset >> 3)));
3053 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3054 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3055 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3056 sym_op->cipher.data.length = cipher_len;
3057 sym_op->cipher.data.offset = cipher_offset;
3059 sym_op->cipher.data.length = cipher_len >> 3;
3060 sym_op->cipher.data.offset = cipher_offset >> 3;
3063 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3064 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3065 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3066 sym_op->auth.data.length = auth_len;
3067 sym_op->auth.data.offset = auth_offset;
3069 sym_op->auth.data.length = auth_len >> 3;
3070 sym_op->auth.data.offset = auth_offset >> 3;
3077 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3079 struct crypto_testsuite_params *ts_params = &testsuite_params;
3080 struct crypto_unittest_params *ut_params = &unittest_params;
3083 unsigned plaintext_pad_len;
3084 unsigned plaintext_len;
3086 struct rte_cryptodev_info dev_info;
3088 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3089 uint64_t feat_flags = dev_info.feature_flags;
3091 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3092 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3093 printf("Device doesn't support NON-Byte Aligned Data.\n");
3094 return TEST_SKIPPED;
3097 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3098 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3099 printf("Device doesn't support RAW data-path APIs.\n");
3100 return TEST_SKIPPED;
3103 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3104 return TEST_SKIPPED;
3106 /* Verify the capabilities */
3107 struct rte_cryptodev_sym_capability_idx cap_idx;
3108 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3109 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3110 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3112 return TEST_SKIPPED;
3114 /* Create SNOW 3G session */
3115 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3116 tdata->key.data, tdata->key.len,
3117 tdata->auth_iv.len, tdata->digest.len,
3118 RTE_CRYPTO_AUTH_OP_GENERATE,
3119 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3123 /* alloc mbuf and set payload */
3124 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3126 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3127 rte_pktmbuf_tailroom(ut_params->ibuf));
3129 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3130 /* Append data which is padded to a multiple of */
3131 /* the algorithms block size */
3132 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3133 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3135 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3137 /* Create SNOW 3G operation */
3138 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3139 tdata->auth_iv.data, tdata->auth_iv.len,
3140 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3141 tdata->validAuthLenInBits.len,
3146 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3147 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3148 ut_params->op, 0, 1, 1, 0);
3150 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3152 ut_params->obuf = ut_params->op->sym->m_src;
3153 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3154 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3155 + plaintext_pad_len;
3158 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3161 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3162 "SNOW 3G Generated auth tag not as expected");
3168 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3170 struct crypto_testsuite_params *ts_params = &testsuite_params;
3171 struct crypto_unittest_params *ut_params = &unittest_params;
3174 unsigned plaintext_pad_len;
3175 unsigned plaintext_len;
3177 struct rte_cryptodev_info dev_info;
3179 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3180 uint64_t feat_flags = dev_info.feature_flags;
3182 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3183 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3184 printf("Device doesn't support NON-Byte Aligned Data.\n");
3185 return TEST_SKIPPED;
3188 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3189 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3190 printf("Device doesn't support RAW data-path APIs.\n");
3191 return TEST_SKIPPED;
3194 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3195 return TEST_SKIPPED;
3197 /* Verify the capabilities */
3198 struct rte_cryptodev_sym_capability_idx cap_idx;
3199 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3200 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3201 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3203 return TEST_SKIPPED;
3205 /* Create SNOW 3G session */
3206 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3207 tdata->key.data, tdata->key.len,
3208 tdata->auth_iv.len, tdata->digest.len,
3209 RTE_CRYPTO_AUTH_OP_VERIFY,
3210 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3213 /* alloc mbuf and set payload */
3214 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3216 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3217 rte_pktmbuf_tailroom(ut_params->ibuf));
3219 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3220 /* Append data which is padded to a multiple of */
3221 /* the algorithms block size */
3222 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3223 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3225 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3227 /* Create SNOW 3G operation */
3228 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3230 tdata->auth_iv.data, tdata->auth_iv.len,
3232 RTE_CRYPTO_AUTH_OP_VERIFY,
3233 tdata->validAuthLenInBits.len,
3238 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3239 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3240 ut_params->op, 0, 1, 1, 0);
3242 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3244 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3245 ut_params->obuf = ut_params->op->sym->m_src;
3246 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3247 + plaintext_pad_len;
3250 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3259 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3261 struct crypto_testsuite_params *ts_params = &testsuite_params;
3262 struct crypto_unittest_params *ut_params = &unittest_params;
3265 unsigned plaintext_pad_len;
3266 unsigned plaintext_len;
3268 struct rte_cryptodev_info dev_info;
3270 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3271 uint64_t feat_flags = dev_info.feature_flags;
3273 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3274 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3275 printf("Device doesn't support RAW data-path APIs.\n");
3276 return TEST_SKIPPED;
3279 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3280 return TEST_SKIPPED;
3282 /* Verify the capabilities */
3283 struct rte_cryptodev_sym_capability_idx cap_idx;
3284 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3285 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3286 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3288 return TEST_SKIPPED;
3290 /* Create KASUMI session */
3291 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3292 tdata->key.data, tdata->key.len,
3293 0, tdata->digest.len,
3294 RTE_CRYPTO_AUTH_OP_GENERATE,
3295 RTE_CRYPTO_AUTH_KASUMI_F9);
3299 /* alloc mbuf and set payload */
3300 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3302 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3303 rte_pktmbuf_tailroom(ut_params->ibuf));
3305 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3306 /* Append data which is padded to a multiple of */
3307 /* the algorithms block size */
3308 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3309 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3311 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3313 /* Create KASUMI operation */
3314 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3316 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3317 tdata->plaintext.len,
3322 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3323 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3325 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3326 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3327 ut_params->op, 0, 1, 1, 0);
3329 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3332 ut_params->obuf = ut_params->op->sym->m_src;
3333 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3334 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3335 + plaintext_pad_len;
3338 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3341 DIGEST_BYTE_LENGTH_KASUMI_F9,
3342 "KASUMI Generated auth tag not as expected");
3348 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3350 struct crypto_testsuite_params *ts_params = &testsuite_params;
3351 struct crypto_unittest_params *ut_params = &unittest_params;
3354 unsigned plaintext_pad_len;
3355 unsigned plaintext_len;
3357 struct rte_cryptodev_info dev_info;
3359 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3360 uint64_t feat_flags = dev_info.feature_flags;
3362 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3363 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3364 printf("Device doesn't support RAW data-path APIs.\n");
3365 return TEST_SKIPPED;
3368 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3369 return TEST_SKIPPED;
3371 /* Verify the capabilities */
3372 struct rte_cryptodev_sym_capability_idx cap_idx;
3373 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3374 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3375 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3377 return TEST_SKIPPED;
3379 /* Create KASUMI session */
3380 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3381 tdata->key.data, tdata->key.len,
3382 0, tdata->digest.len,
3383 RTE_CRYPTO_AUTH_OP_VERIFY,
3384 RTE_CRYPTO_AUTH_KASUMI_F9);
3387 /* alloc mbuf and set payload */
3388 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3390 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3391 rte_pktmbuf_tailroom(ut_params->ibuf));
3393 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3394 /* Append data which is padded to a multiple */
3395 /* of the algorithms block size */
3396 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3397 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3399 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3401 /* Create KASUMI operation */
3402 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3406 RTE_CRYPTO_AUTH_OP_VERIFY,
3407 tdata->plaintext.len,
3412 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3413 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3414 ut_params->op, 0, 1, 1, 0);
3416 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3418 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3419 ut_params->obuf = ut_params->op->sym->m_src;
3420 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3421 + plaintext_pad_len;
3424 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3433 test_snow3g_hash_generate_test_case_1(void)
3435 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3439 test_snow3g_hash_generate_test_case_2(void)
3441 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3445 test_snow3g_hash_generate_test_case_3(void)
3447 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3451 test_snow3g_hash_generate_test_case_4(void)
3453 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3457 test_snow3g_hash_generate_test_case_5(void)
3459 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3463 test_snow3g_hash_generate_test_case_6(void)
3465 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3469 test_snow3g_hash_verify_test_case_1(void)
3471 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3476 test_snow3g_hash_verify_test_case_2(void)
3478 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3482 test_snow3g_hash_verify_test_case_3(void)
3484 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3488 test_snow3g_hash_verify_test_case_4(void)
3490 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3494 test_snow3g_hash_verify_test_case_5(void)
3496 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3500 test_snow3g_hash_verify_test_case_6(void)
3502 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3506 test_kasumi_hash_generate_test_case_1(void)
3508 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3512 test_kasumi_hash_generate_test_case_2(void)
3514 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3518 test_kasumi_hash_generate_test_case_3(void)
3520 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3524 test_kasumi_hash_generate_test_case_4(void)
3526 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3530 test_kasumi_hash_generate_test_case_5(void)
3532 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3536 test_kasumi_hash_generate_test_case_6(void)
3538 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3542 test_kasumi_hash_verify_test_case_1(void)
3544 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3548 test_kasumi_hash_verify_test_case_2(void)
3550 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3554 test_kasumi_hash_verify_test_case_3(void)
3556 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3560 test_kasumi_hash_verify_test_case_4(void)
3562 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3566 test_kasumi_hash_verify_test_case_5(void)
3568 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3572 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3574 struct crypto_testsuite_params *ts_params = &testsuite_params;
3575 struct crypto_unittest_params *ut_params = &unittest_params;
3578 uint8_t *plaintext, *ciphertext;
3579 unsigned plaintext_pad_len;
3580 unsigned plaintext_len;
3581 struct rte_cryptodev_info dev_info;
3583 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3584 uint64_t feat_flags = dev_info.feature_flags;
3586 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3587 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3588 printf("Device doesn't support RAW data-path APIs.\n");
3589 return TEST_SKIPPED;
3592 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3593 return TEST_SKIPPED;
3595 /* Verify the capabilities */
3596 struct rte_cryptodev_sym_capability_idx cap_idx;
3597 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3598 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3599 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3601 return TEST_SKIPPED;
3603 /* Create KASUMI session */
3604 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3605 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3606 RTE_CRYPTO_CIPHER_KASUMI_F8,
3607 tdata->key.data, tdata->key.len,
3608 tdata->cipher_iv.len);
3612 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3614 /* Clear mbuf payload */
3615 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3616 rte_pktmbuf_tailroom(ut_params->ibuf));
3618 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3619 /* Append data which is padded to a multiple */
3620 /* of the algorithms block size */
3621 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3622 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3624 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3626 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3628 /* Create KASUMI operation */
3629 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3630 tdata->cipher_iv.len,
3631 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3632 tdata->validCipherOffsetInBits.len);
3636 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3637 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3638 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3640 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3642 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3644 ut_params->obuf = ut_params->op->sym->m_dst;
3645 if (ut_params->obuf)
3646 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3648 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3650 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3652 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3653 (tdata->validCipherOffsetInBits.len >> 3);
3655 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3657 reference_ciphertext,
3658 tdata->validCipherLenInBits.len,
3659 "KASUMI Ciphertext data not as expected");
3664 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3666 struct crypto_testsuite_params *ts_params = &testsuite_params;
3667 struct crypto_unittest_params *ut_params = &unittest_params;
3671 unsigned int plaintext_pad_len;
3672 unsigned int plaintext_len;
3674 uint8_t buffer[10000];
3675 const uint8_t *ciphertext;
3677 struct rte_cryptodev_info dev_info;
3679 /* Verify the capabilities */
3680 struct rte_cryptodev_sym_capability_idx cap_idx;
3681 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3682 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3683 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3685 return TEST_SKIPPED;
3687 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3689 uint64_t feat_flags = dev_info.feature_flags;
3691 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3692 printf("Device doesn't support in-place scatter-gather. "
3694 return TEST_SKIPPED;
3697 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3698 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3699 printf("Device doesn't support RAW data-path APIs.\n");
3700 return TEST_SKIPPED;
3703 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3704 return TEST_SKIPPED;
3706 /* Create KASUMI session */
3707 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3708 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3709 RTE_CRYPTO_CIPHER_KASUMI_F8,
3710 tdata->key.data, tdata->key.len,
3711 tdata->cipher_iv.len);
3715 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3718 /* Append data which is padded to a multiple */
3719 /* of the algorithms block size */
3720 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3722 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3723 plaintext_pad_len, 10, 0);
3725 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3727 /* Create KASUMI operation */
3728 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3729 tdata->cipher_iv.len,
3730 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3731 tdata->validCipherOffsetInBits.len);
3735 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3736 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3737 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3739 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3741 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3743 ut_params->obuf = ut_params->op->sym->m_dst;
3745 if (ut_params->obuf)
3746 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3747 plaintext_len, buffer);
3749 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3750 tdata->validCipherOffsetInBits.len >> 3,
3751 plaintext_len, buffer);
3754 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3756 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3757 (tdata->validCipherOffsetInBits.len >> 3);
3759 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3761 reference_ciphertext,
3762 tdata->validCipherLenInBits.len,
3763 "KASUMI Ciphertext data not as expected");
3768 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3770 struct crypto_testsuite_params *ts_params = &testsuite_params;
3771 struct crypto_unittest_params *ut_params = &unittest_params;
3774 uint8_t *plaintext, *ciphertext;
3775 unsigned plaintext_pad_len;
3776 unsigned plaintext_len;
3778 /* Verify the capabilities */
3779 struct rte_cryptodev_sym_capability_idx cap_idx;
3780 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3781 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3782 /* Data-path service does not support OOP */
3783 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3785 return TEST_SKIPPED;
3787 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3788 return TEST_SKIPPED;
3790 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3791 return TEST_SKIPPED;
3793 /* Create KASUMI session */
3794 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3795 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3796 RTE_CRYPTO_CIPHER_KASUMI_F8,
3797 tdata->key.data, tdata->key.len,
3798 tdata->cipher_iv.len);
3802 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3803 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3805 /* Clear mbuf payload */
3806 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3807 rte_pktmbuf_tailroom(ut_params->ibuf));
3809 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3810 /* Append data which is padded to a multiple */
3811 /* of the algorithms block size */
3812 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3813 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3815 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3816 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3818 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3820 /* Create KASUMI operation */
3821 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3822 tdata->cipher_iv.len,
3823 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3824 tdata->validCipherOffsetInBits.len);
3828 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3830 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3832 ut_params->obuf = ut_params->op->sym->m_dst;
3833 if (ut_params->obuf)
3834 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3836 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3838 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3840 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3841 (tdata->validCipherOffsetInBits.len >> 3);
3843 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3845 reference_ciphertext,
3846 tdata->validCipherLenInBits.len,
3847 "KASUMI Ciphertext data not as expected");
3852 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3854 struct crypto_testsuite_params *ts_params = &testsuite_params;
3855 struct crypto_unittest_params *ut_params = &unittest_params;
3858 unsigned int plaintext_pad_len;
3859 unsigned int plaintext_len;
3861 const uint8_t *ciphertext;
3862 uint8_t buffer[2048];
3864 struct rte_cryptodev_info dev_info;
3866 /* Verify the capabilities */
3867 struct rte_cryptodev_sym_capability_idx cap_idx;
3868 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3869 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3870 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3872 return TEST_SKIPPED;
3874 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3875 return TEST_SKIPPED;
3877 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3878 return TEST_SKIPPED;
3880 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3882 uint64_t feat_flags = dev_info.feature_flags;
3883 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3884 printf("Device doesn't support out-of-place scatter-gather "
3885 "in both input and output mbufs. "
3887 return TEST_SKIPPED;
3890 /* Create KASUMI session */
3891 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3892 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3893 RTE_CRYPTO_CIPHER_KASUMI_F8,
3894 tdata->key.data, tdata->key.len,
3895 tdata->cipher_iv.len);
3899 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3900 /* Append data which is padded to a multiple */
3901 /* of the algorithms block size */
3902 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3904 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3905 plaintext_pad_len, 10, 0);
3906 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3907 plaintext_pad_len, 3, 0);
3909 /* Append data which is padded to a multiple */
3910 /* of the algorithms block size */
3911 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3913 /* Create KASUMI operation */
3914 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3915 tdata->cipher_iv.len,
3916 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3917 tdata->validCipherOffsetInBits.len);
3921 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3923 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3925 ut_params->obuf = ut_params->op->sym->m_dst;
3926 if (ut_params->obuf)
3927 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3928 plaintext_pad_len, buffer);
3930 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3931 tdata->validCipherOffsetInBits.len >> 3,
3932 plaintext_pad_len, buffer);
3934 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3935 (tdata->validCipherOffsetInBits.len >> 3);
3937 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3939 reference_ciphertext,
3940 tdata->validCipherLenInBits.len,
3941 "KASUMI Ciphertext data not as expected");
3947 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3949 struct crypto_testsuite_params *ts_params = &testsuite_params;
3950 struct crypto_unittest_params *ut_params = &unittest_params;
3953 uint8_t *ciphertext, *plaintext;
3954 unsigned ciphertext_pad_len;
3955 unsigned ciphertext_len;
3957 /* Verify the capabilities */
3958 struct rte_cryptodev_sym_capability_idx cap_idx;
3959 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3960 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3961 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3963 return TEST_SKIPPED;
3965 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3966 return TEST_SKIPPED;
3968 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3969 return TEST_SKIPPED;
3971 /* Create KASUMI session */
3972 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3973 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3974 RTE_CRYPTO_CIPHER_KASUMI_F8,
3975 tdata->key.data, tdata->key.len,
3976 tdata->cipher_iv.len);
3980 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3981 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3983 /* Clear mbuf payload */
3984 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3985 rte_pktmbuf_tailroom(ut_params->ibuf));
3987 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3988 /* Append data which is padded to a multiple */
3989 /* of the algorithms block size */
3990 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3991 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3992 ciphertext_pad_len);
3993 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3994 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3996 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3998 /* Create KASUMI operation */
3999 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4000 tdata->cipher_iv.len,
4001 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4002 tdata->validCipherOffsetInBits.len);
4006 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4008 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4010 ut_params->obuf = ut_params->op->sym->m_dst;
4011 if (ut_params->obuf)
4012 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4014 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4016 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4018 const uint8_t *reference_plaintext = tdata->plaintext.data +
4019 (tdata->validCipherOffsetInBits.len >> 3);
4021 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4023 reference_plaintext,
4024 tdata->validCipherLenInBits.len,
4025 "KASUMI Plaintext data not as expected");
4030 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4032 struct crypto_testsuite_params *ts_params = &testsuite_params;
4033 struct crypto_unittest_params *ut_params = &unittest_params;
4036 uint8_t *ciphertext, *plaintext;
4037 unsigned ciphertext_pad_len;
4038 unsigned ciphertext_len;
4039 struct rte_cryptodev_info dev_info;
4041 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4042 uint64_t feat_flags = dev_info.feature_flags;
4044 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4045 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4046 printf("Device doesn't support RAW data-path APIs.\n");
4047 return TEST_SKIPPED;
4050 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4051 return TEST_SKIPPED;
4053 /* Verify the capabilities */
4054 struct rte_cryptodev_sym_capability_idx cap_idx;
4055 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4056 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4057 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4059 return TEST_SKIPPED;
4061 /* Create KASUMI session */
4062 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4063 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4064 RTE_CRYPTO_CIPHER_KASUMI_F8,
4065 tdata->key.data, tdata->key.len,
4066 tdata->cipher_iv.len);
4070 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4072 /* Clear mbuf payload */
4073 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4074 rte_pktmbuf_tailroom(ut_params->ibuf));
4076 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4077 /* Append data which is padded to a multiple */
4078 /* of the algorithms block size */
4079 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4080 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4081 ciphertext_pad_len);
4082 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4084 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4086 /* Create KASUMI operation */
4087 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4088 tdata->cipher_iv.len,
4089 tdata->ciphertext.len,
4090 tdata->validCipherOffsetInBits.len);
4094 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4095 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4096 ut_params->op, 1, 0, 1, 0);
4098 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4100 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4102 ut_params->obuf = ut_params->op->sym->m_dst;
4103 if (ut_params->obuf)
4104 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4106 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4108 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4110 const uint8_t *reference_plaintext = tdata->plaintext.data +
4111 (tdata->validCipherOffsetInBits.len >> 3);
4113 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4115 reference_plaintext,
4116 tdata->validCipherLenInBits.len,
4117 "KASUMI Plaintext data not as expected");
4122 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4124 struct crypto_testsuite_params *ts_params = &testsuite_params;
4125 struct crypto_unittest_params *ut_params = &unittest_params;
4128 uint8_t *plaintext, *ciphertext;
4129 unsigned plaintext_pad_len;
4130 unsigned plaintext_len;
4131 struct rte_cryptodev_info dev_info;
4133 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4134 uint64_t feat_flags = dev_info.feature_flags;
4136 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4137 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4138 printf("Device doesn't support RAW data-path APIs.\n");
4139 return TEST_SKIPPED;
4142 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4143 return TEST_SKIPPED;
4145 /* Verify the capabilities */
4146 struct rte_cryptodev_sym_capability_idx cap_idx;
4147 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4148 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4149 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4151 return TEST_SKIPPED;
4153 /* Create SNOW 3G session */
4154 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4155 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4156 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4157 tdata->key.data, tdata->key.len,
4158 tdata->cipher_iv.len);
4162 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4164 /* Clear mbuf payload */
4165 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4166 rte_pktmbuf_tailroom(ut_params->ibuf));
4168 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4169 /* Append data which is padded to a multiple of */
4170 /* the algorithms block size */
4171 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4172 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4174 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4176 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4178 /* Create SNOW 3G operation */
4179 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4180 tdata->cipher_iv.len,
4181 tdata->validCipherLenInBits.len,
4186 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4187 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4188 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4190 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4192 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4194 ut_params->obuf = ut_params->op->sym->m_dst;
4195 if (ut_params->obuf)
4196 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4198 ciphertext = plaintext;
4200 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4203 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4205 tdata->ciphertext.data,
4206 tdata->validDataLenInBits.len,
4207 "SNOW 3G Ciphertext data not as expected");
4213 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4215 struct crypto_testsuite_params *ts_params = &testsuite_params;
4216 struct crypto_unittest_params *ut_params = &unittest_params;
4217 uint8_t *plaintext, *ciphertext;
4220 unsigned plaintext_pad_len;
4221 unsigned plaintext_len;
4223 /* Verify the capabilities */
4224 struct rte_cryptodev_sym_capability_idx cap_idx;
4225 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4226 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4227 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4229 return TEST_SKIPPED;
4231 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4232 return TEST_SKIPPED;
4234 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4235 return TEST_SKIPPED;
4237 /* Create SNOW 3G session */
4238 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4239 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4240 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4241 tdata->key.data, tdata->key.len,
4242 tdata->cipher_iv.len);
4246 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4247 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4249 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4250 "Failed to allocate input buffer in mempool");
4251 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4252 "Failed to allocate output buffer in mempool");
4254 /* Clear mbuf payload */
4255 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4256 rte_pktmbuf_tailroom(ut_params->ibuf));
4258 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4259 /* Append data which is padded to a multiple of */
4260 /* the algorithms block size */
4261 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4262 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4264 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4265 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4267 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4269 /* Create SNOW 3G operation */
4270 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4271 tdata->cipher_iv.len,
4272 tdata->validCipherLenInBits.len,
4277 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4279 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4281 ut_params->obuf = ut_params->op->sym->m_dst;
4282 if (ut_params->obuf)
4283 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4285 ciphertext = plaintext;
4287 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4290 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4292 tdata->ciphertext.data,
4293 tdata->validDataLenInBits.len,
4294 "SNOW 3G Ciphertext data not as expected");
4299 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4301 struct crypto_testsuite_params *ts_params = &testsuite_params;
4302 struct crypto_unittest_params *ut_params = &unittest_params;
4305 unsigned int plaintext_pad_len;
4306 unsigned int plaintext_len;
4307 uint8_t buffer[10000];
4308 const uint8_t *ciphertext;
4310 struct rte_cryptodev_info dev_info;
4312 /* Verify the capabilities */
4313 struct rte_cryptodev_sym_capability_idx cap_idx;
4314 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4315 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4316 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4318 return TEST_SKIPPED;
4320 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4321 return TEST_SKIPPED;
4323 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4324 return TEST_SKIPPED;
4326 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4328 uint64_t feat_flags = dev_info.feature_flags;
4330 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4331 printf("Device doesn't support out-of-place scatter-gather "
4332 "in both input and output mbufs. "
4334 return TEST_SKIPPED;
4337 /* Create SNOW 3G session */
4338 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4339 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4340 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4341 tdata->key.data, tdata->key.len,
4342 tdata->cipher_iv.len);
4346 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4347 /* Append data which is padded to a multiple of */
4348 /* the algorithms block size */
4349 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4351 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4352 plaintext_pad_len, 10, 0);
4353 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4354 plaintext_pad_len, 3, 0);
4356 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4357 "Failed to allocate input buffer in mempool");
4358 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4359 "Failed to allocate output buffer in mempool");
4361 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4363 /* Create SNOW 3G operation */
4364 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4365 tdata->cipher_iv.len,
4366 tdata->validCipherLenInBits.len,
4371 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4373 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4375 ut_params->obuf = ut_params->op->sym->m_dst;
4376 if (ut_params->obuf)
4377 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4378 plaintext_len, buffer);
4380 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4381 plaintext_len, buffer);
4383 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4386 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4388 tdata->ciphertext.data,
4389 tdata->validDataLenInBits.len,
4390 "SNOW 3G Ciphertext data not as expected");
4395 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4397 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4399 uint8_t curr_byte, prev_byte;
4400 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4401 uint8_t lower_byte_mask = (1 << offset) - 1;
4404 prev_byte = buffer[0];
4405 buffer[0] >>= offset;
4407 for (i = 1; i < length_in_bytes; i++) {
4408 curr_byte = buffer[i];
4409 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4410 (curr_byte >> offset);
4411 prev_byte = curr_byte;
4416 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4418 struct crypto_testsuite_params *ts_params = &testsuite_params;
4419 struct crypto_unittest_params *ut_params = &unittest_params;
4420 uint8_t *plaintext, *ciphertext;
4422 uint32_t plaintext_len;
4423 uint32_t plaintext_pad_len;
4424 uint8_t extra_offset = 4;
4425 uint8_t *expected_ciphertext_shifted;
4426 struct rte_cryptodev_info dev_info;
4428 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4429 uint64_t feat_flags = dev_info.feature_flags;
4431 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4432 ((tdata->validDataLenInBits.len % 8) != 0)) {
4433 printf("Device doesn't support NON-Byte Aligned Data.\n");
4434 return TEST_SKIPPED;
4437 /* Verify the capabilities */
4438 struct rte_cryptodev_sym_capability_idx cap_idx;
4439 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4440 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4441 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4443 return TEST_SKIPPED;
4445 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4446 return TEST_SKIPPED;
4448 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4449 return TEST_SKIPPED;
4451 /* Create SNOW 3G session */
4452 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4453 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4454 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4455 tdata->key.data, tdata->key.len,
4456 tdata->cipher_iv.len);
4460 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4461 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4463 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4464 "Failed to allocate input buffer in mempool");
4465 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4466 "Failed to allocate output buffer in mempool");
4468 /* Clear mbuf payload */
4469 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4470 rte_pktmbuf_tailroom(ut_params->ibuf));
4472 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4474 * Append data which is padded to a
4475 * multiple of the algorithms block size
4477 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4479 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4482 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4484 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4485 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4487 #ifdef RTE_APP_TEST_DEBUG
4488 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4490 /* Create SNOW 3G operation */
4491 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4492 tdata->cipher_iv.len,
4493 tdata->validCipherLenInBits.len,
4498 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4500 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4502 ut_params->obuf = ut_params->op->sym->m_dst;
4503 if (ut_params->obuf)
4504 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4506 ciphertext = plaintext;
4508 #ifdef RTE_APP_TEST_DEBUG
4509 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4512 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4514 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4515 "failed to reserve memory for ciphertext shifted\n");
4517 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4518 ceil_byte_length(tdata->ciphertext.len));
4519 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4522 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4524 expected_ciphertext_shifted,
4525 tdata->validDataLenInBits.len,
4527 "SNOW 3G Ciphertext data not as expected");
4531 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4533 struct crypto_testsuite_params *ts_params = &testsuite_params;
4534 struct crypto_unittest_params *ut_params = &unittest_params;
4538 uint8_t *plaintext, *ciphertext;
4539 unsigned ciphertext_pad_len;
4540 unsigned ciphertext_len;
4541 struct rte_cryptodev_info dev_info;
4543 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4544 uint64_t feat_flags = dev_info.feature_flags;
4546 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4547 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4548 printf("Device doesn't support RAW data-path APIs.\n");
4549 return TEST_SKIPPED;
4552 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4553 return TEST_SKIPPED;
4555 /* Verify the capabilities */
4556 struct rte_cryptodev_sym_capability_idx cap_idx;
4557 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4558 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4559 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4561 return TEST_SKIPPED;
4563 /* Create SNOW 3G session */
4564 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4565 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4566 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4567 tdata->key.data, tdata->key.len,
4568 tdata->cipher_iv.len);
4572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4574 /* Clear mbuf payload */
4575 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4576 rte_pktmbuf_tailroom(ut_params->ibuf));
4578 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4579 /* Append data which is padded to a multiple of */
4580 /* the algorithms block size */
4581 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4582 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4583 ciphertext_pad_len);
4584 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4586 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4588 /* Create SNOW 3G operation */
4589 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4590 tdata->cipher_iv.len,
4591 tdata->validCipherLenInBits.len,
4592 tdata->cipher.offset_bits);
4596 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4597 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4598 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4600 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4602 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4603 ut_params->obuf = ut_params->op->sym->m_dst;
4604 if (ut_params->obuf)
4605 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4607 plaintext = ciphertext;
4609 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4612 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4613 tdata->plaintext.data,
4614 tdata->validDataLenInBits.len,
4615 "SNOW 3G Plaintext data not as expected");
4619 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4621 struct crypto_testsuite_params *ts_params = &testsuite_params;
4622 struct crypto_unittest_params *ut_params = &unittest_params;
4626 uint8_t *plaintext, *ciphertext;
4627 unsigned ciphertext_pad_len;
4628 unsigned ciphertext_len;
4630 /* Verify the capabilities */
4631 struct rte_cryptodev_sym_capability_idx cap_idx;
4632 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4633 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4634 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4636 return TEST_SKIPPED;
4638 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4639 return TEST_SKIPPED;
4641 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4642 return TEST_SKIPPED;
4644 /* Create SNOW 3G session */
4645 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4646 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4647 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4648 tdata->key.data, tdata->key.len,
4649 tdata->cipher_iv.len);
4653 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4654 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4656 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4657 "Failed to allocate input buffer");
4658 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4659 "Failed to allocate output buffer");
4661 /* Clear mbuf payload */
4662 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4663 rte_pktmbuf_tailroom(ut_params->ibuf));
4665 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4666 rte_pktmbuf_tailroom(ut_params->obuf));
4668 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4669 /* Append data which is padded to a multiple of */
4670 /* the algorithms block size */
4671 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4672 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4673 ciphertext_pad_len);
4674 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4675 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4677 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4679 /* Create SNOW 3G operation */
4680 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4681 tdata->cipher_iv.len,
4682 tdata->validCipherLenInBits.len,
4687 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4689 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4690 ut_params->obuf = ut_params->op->sym->m_dst;
4691 if (ut_params->obuf)
4692 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4694 plaintext = ciphertext;
4696 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4699 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4700 tdata->plaintext.data,
4701 tdata->validDataLenInBits.len,
4702 "SNOW 3G Plaintext data not as expected");
4707 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4709 struct crypto_testsuite_params *ts_params = &testsuite_params;
4710 struct crypto_unittest_params *ut_params = &unittest_params;
4714 uint8_t *plaintext, *ciphertext;
4715 unsigned int plaintext_pad_len;
4716 unsigned int plaintext_len;
4718 struct rte_cryptodev_info dev_info;
4719 struct rte_cryptodev_sym_capability_idx cap_idx;
4721 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4722 uint64_t feat_flags = dev_info.feature_flags;
4724 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4725 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4726 (tdata->validDataLenInBits.len % 8 != 0))) {
4727 printf("Device doesn't support NON-Byte Aligned Data.\n");
4728 return TEST_SKIPPED;
4731 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4732 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4733 printf("Device doesn't support RAW data-path APIs.\n");
4734 return TEST_SKIPPED;
4737 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4738 return TEST_SKIPPED;
4740 /* Check if device supports ZUC EEA3 */
4741 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4742 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4744 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4746 return TEST_SKIPPED;
4748 /* Check if device supports ZUC EIA3 */
4749 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4750 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4752 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4754 return TEST_SKIPPED;
4756 /* Create ZUC session */
4757 retval = create_zuc_cipher_auth_encrypt_generate_session(
4758 ts_params->valid_devs[0],
4762 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4764 /* clear mbuf payload */
4765 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4766 rte_pktmbuf_tailroom(ut_params->ibuf));
4768 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4769 /* Append data which is padded to a multiple of */
4770 /* the algorithms block size */
4771 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4772 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4774 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4776 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4778 /* Create ZUC operation */
4779 retval = create_zuc_cipher_hash_generate_operation(tdata);
4783 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4784 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4785 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4787 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4789 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4790 ut_params->obuf = ut_params->op->sym->m_src;
4791 if (ut_params->obuf)
4792 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4794 ciphertext = plaintext;
4796 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4798 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4800 tdata->ciphertext.data,
4801 tdata->validDataLenInBits.len,
4802 "ZUC Ciphertext data not as expected");
4804 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4805 + plaintext_pad_len;
4808 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4812 "ZUC Generated auth tag not as expected");
4817 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4819 struct crypto_testsuite_params *ts_params = &testsuite_params;
4820 struct crypto_unittest_params *ut_params = &unittest_params;
4824 uint8_t *plaintext, *ciphertext;
4825 unsigned plaintext_pad_len;
4826 unsigned plaintext_len;
4827 struct rte_cryptodev_info dev_info;
4829 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4830 uint64_t feat_flags = dev_info.feature_flags;
4832 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4833 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4834 printf("Device doesn't support RAW data-path APIs.\n");
4835 return TEST_SKIPPED;
4838 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4839 return TEST_SKIPPED;
4841 /* Verify the capabilities */
4842 struct rte_cryptodev_sym_capability_idx cap_idx;
4843 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4844 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4845 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4847 return TEST_SKIPPED;
4848 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4849 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4850 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4852 return TEST_SKIPPED;
4854 /* Create SNOW 3G session */
4855 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4856 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4857 RTE_CRYPTO_AUTH_OP_GENERATE,
4858 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4859 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4860 tdata->key.data, tdata->key.len,
4861 tdata->auth_iv.len, tdata->digest.len,
4862 tdata->cipher_iv.len);
4865 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4867 /* clear mbuf payload */
4868 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4869 rte_pktmbuf_tailroom(ut_params->ibuf));
4871 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4872 /* Append data which is padded to a multiple of */
4873 /* the algorithms block size */
4874 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4875 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4877 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4879 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4881 /* Create SNOW 3G operation */
4882 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4883 tdata->digest.len, tdata->auth_iv.data,
4885 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4886 tdata->cipher_iv.data, tdata->cipher_iv.len,
4887 tdata->validCipherLenInBits.len,
4889 tdata->validAuthLenInBits.len,
4895 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4896 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4897 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4899 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4901 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4902 ut_params->obuf = ut_params->op->sym->m_src;
4903 if (ut_params->obuf)
4904 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4906 ciphertext = plaintext;
4908 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4910 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4912 tdata->ciphertext.data,
4913 tdata->validDataLenInBits.len,
4914 "SNOW 3G Ciphertext data not as expected");
4916 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4917 + plaintext_pad_len;
4920 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4923 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4924 "SNOW 3G Generated auth tag not as expected");
4929 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4930 uint8_t op_mode, uint8_t verify)
4932 struct crypto_testsuite_params *ts_params = &testsuite_params;
4933 struct crypto_unittest_params *ut_params = &unittest_params;
4937 uint8_t *plaintext = NULL, *ciphertext = NULL;
4938 unsigned int plaintext_pad_len;
4939 unsigned int plaintext_len;
4940 unsigned int ciphertext_pad_len;
4941 unsigned int ciphertext_len;
4943 struct rte_cryptodev_info dev_info;
4945 /* Verify the capabilities */
4946 struct rte_cryptodev_sym_capability_idx cap_idx;
4947 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4948 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4949 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4951 return TEST_SKIPPED;
4952 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4953 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4954 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4956 return TEST_SKIPPED;
4958 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4959 return TEST_SKIPPED;
4961 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4963 uint64_t feat_flags = dev_info.feature_flags;
4965 if (op_mode == OUT_OF_PLACE) {
4966 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4967 printf("Device doesn't support digest encrypted.\n");
4968 return TEST_SKIPPED;
4970 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4971 return TEST_SKIPPED;
4974 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4975 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4976 printf("Device doesn't support RAW data-path APIs.\n");
4977 return TEST_SKIPPED;
4980 /* Create SNOW 3G session */
4981 retval = create_wireless_algo_auth_cipher_session(
4982 ts_params->valid_devs[0],
4983 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4984 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4985 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4986 : RTE_CRYPTO_AUTH_OP_GENERATE),
4987 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4988 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4989 tdata->key.data, tdata->key.len,
4990 tdata->auth_iv.len, tdata->digest.len,
4991 tdata->cipher_iv.len);
4995 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4996 if (op_mode == OUT_OF_PLACE)
4997 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4999 /* clear mbuf payload */
5000 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5001 rte_pktmbuf_tailroom(ut_params->ibuf));
5002 if (op_mode == OUT_OF_PLACE)
5003 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5004 rte_pktmbuf_tailroom(ut_params->obuf));
5006 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5007 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5008 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5009 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5012 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5013 ciphertext_pad_len);
5014 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5015 if (op_mode == OUT_OF_PLACE)
5016 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5017 debug_hexdump(stdout, "ciphertext:", ciphertext,
5020 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5022 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5023 if (op_mode == OUT_OF_PLACE)
5024 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5025 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5028 /* Create SNOW 3G operation */
5029 retval = create_wireless_algo_auth_cipher_operation(
5030 tdata->digest.data, tdata->digest.len,
5031 tdata->cipher_iv.data, tdata->cipher_iv.len,
5032 tdata->auth_iv.data, tdata->auth_iv.len,
5033 (tdata->digest.offset_bytes == 0 ?
5034 (verify ? ciphertext_pad_len : plaintext_pad_len)
5035 : tdata->digest.offset_bytes),
5036 tdata->validCipherLenInBits.len,
5037 tdata->cipher.offset_bits,
5038 tdata->validAuthLenInBits.len,
5039 tdata->auth.offset_bits,
5040 op_mode, 0, verify);
5045 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5046 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5047 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5049 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5052 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5054 ut_params->obuf = (op_mode == IN_PLACE ?
5055 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5058 if (ut_params->obuf)
5059 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5062 plaintext = ciphertext +
5063 (tdata->cipher.offset_bits >> 3);
5065 debug_hexdump(stdout, "plaintext:", plaintext,
5066 (tdata->plaintext.len >> 3) - tdata->digest.len);
5067 debug_hexdump(stdout, "plaintext expected:",
5068 tdata->plaintext.data,
5069 (tdata->plaintext.len >> 3) - tdata->digest.len);
5071 if (ut_params->obuf)
5072 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5075 ciphertext = plaintext;
5077 debug_hexdump(stdout, "ciphertext:", ciphertext,
5079 debug_hexdump(stdout, "ciphertext expected:",
5080 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5082 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5083 + (tdata->digest.offset_bytes == 0 ?
5084 plaintext_pad_len : tdata->digest.offset_bytes);
5086 debug_hexdump(stdout, "digest:", ut_params->digest,
5088 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5094 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5096 tdata->plaintext.data,
5097 (tdata->plaintext.len - tdata->cipher.offset_bits -
5098 (tdata->digest.len << 3)),
5099 tdata->cipher.offset_bits,
5100 "SNOW 3G Plaintext data not as expected");
5102 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5104 tdata->ciphertext.data,
5105 (tdata->validDataLenInBits.len -
5106 tdata->cipher.offset_bits),
5107 tdata->cipher.offset_bits,
5108 "SNOW 3G Ciphertext data not as expected");
5110 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5113 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5114 "SNOW 3G Generated auth tag not as expected");
5120 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5121 uint8_t op_mode, uint8_t verify)
5123 struct crypto_testsuite_params *ts_params = &testsuite_params;
5124 struct crypto_unittest_params *ut_params = &unittest_params;
5128 const uint8_t *plaintext = NULL;
5129 const uint8_t *ciphertext = NULL;
5130 const uint8_t *digest = NULL;
5131 unsigned int plaintext_pad_len;
5132 unsigned int plaintext_len;
5133 unsigned int ciphertext_pad_len;
5134 unsigned int ciphertext_len;
5135 uint8_t buffer[10000];
5136 uint8_t digest_buffer[10000];
5138 struct rte_cryptodev_info dev_info;
5140 /* Verify the capabilities */
5141 struct rte_cryptodev_sym_capability_idx cap_idx;
5142 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5143 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5144 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5146 return TEST_SKIPPED;
5147 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5148 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5149 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5151 return TEST_SKIPPED;
5153 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5154 return TEST_SKIPPED;
5156 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5158 uint64_t feat_flags = dev_info.feature_flags;
5160 if (op_mode == IN_PLACE) {
5161 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5162 printf("Device doesn't support in-place scatter-gather "
5163 "in both input and output mbufs.\n");
5164 return TEST_SKIPPED;
5166 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5167 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5168 printf("Device doesn't support RAW data-path APIs.\n");
5169 return TEST_SKIPPED;
5172 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5173 return TEST_SKIPPED;
5174 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5175 printf("Device doesn't support out-of-place scatter-gather "
5176 "in both input and output mbufs.\n");
5177 return TEST_SKIPPED;
5179 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5180 printf("Device doesn't support digest encrypted.\n");
5181 return TEST_SKIPPED;
5185 /* Create SNOW 3G session */
5186 retval = create_wireless_algo_auth_cipher_session(
5187 ts_params->valid_devs[0],
5188 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5189 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5190 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5191 : RTE_CRYPTO_AUTH_OP_GENERATE),
5192 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5193 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5194 tdata->key.data, tdata->key.len,
5195 tdata->auth_iv.len, tdata->digest.len,
5196 tdata->cipher_iv.len);
5201 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5202 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5203 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5204 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5206 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5207 plaintext_pad_len, 15, 0);
5208 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5209 "Failed to allocate input buffer in mempool");
5211 if (op_mode == OUT_OF_PLACE) {
5212 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5213 plaintext_pad_len, 15, 0);
5214 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5215 "Failed to allocate output buffer in mempool");
5219 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5220 tdata->ciphertext.data);
5221 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5222 ciphertext_len, buffer);
5223 debug_hexdump(stdout, "ciphertext:", ciphertext,
5226 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5227 tdata->plaintext.data);
5228 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5229 plaintext_len, buffer);
5230 debug_hexdump(stdout, "plaintext:", plaintext,
5233 memset(buffer, 0, sizeof(buffer));
5235 /* Create SNOW 3G operation */
5236 retval = create_wireless_algo_auth_cipher_operation(
5237 tdata->digest.data, tdata->digest.len,
5238 tdata->cipher_iv.data, tdata->cipher_iv.len,
5239 tdata->auth_iv.data, tdata->auth_iv.len,
5240 (tdata->digest.offset_bytes == 0 ?
5241 (verify ? ciphertext_pad_len : plaintext_pad_len)
5242 : tdata->digest.offset_bytes),
5243 tdata->validCipherLenInBits.len,
5244 tdata->cipher.offset_bits,
5245 tdata->validAuthLenInBits.len,
5246 tdata->auth.offset_bits,
5247 op_mode, 1, verify);
5252 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5253 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5254 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5256 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5259 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5261 ut_params->obuf = (op_mode == IN_PLACE ?
5262 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5265 if (ut_params->obuf)
5266 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5267 plaintext_len, buffer);
5269 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5270 plaintext_len, buffer);
5272 debug_hexdump(stdout, "plaintext:", plaintext,
5273 (tdata->plaintext.len >> 3) - tdata->digest.len);
5274 debug_hexdump(stdout, "plaintext expected:",
5275 tdata->plaintext.data,
5276 (tdata->plaintext.len >> 3) - tdata->digest.len);
5278 if (ut_params->obuf)
5279 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5280 ciphertext_len, buffer);
5282 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5283 ciphertext_len, buffer);
5285 debug_hexdump(stdout, "ciphertext:", ciphertext,
5287 debug_hexdump(stdout, "ciphertext expected:",
5288 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5290 if (ut_params->obuf)
5291 digest = rte_pktmbuf_read(ut_params->obuf,
5292 (tdata->digest.offset_bytes == 0 ?
5293 plaintext_pad_len : tdata->digest.offset_bytes),
5294 tdata->digest.len, digest_buffer);
5296 digest = rte_pktmbuf_read(ut_params->ibuf,
5297 (tdata->digest.offset_bytes == 0 ?
5298 plaintext_pad_len : tdata->digest.offset_bytes),
5299 tdata->digest.len, digest_buffer);
5301 debug_hexdump(stdout, "digest:", digest,
5303 debug_hexdump(stdout, "digest expected:",
5304 tdata->digest.data, tdata->digest.len);
5309 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5311 tdata->plaintext.data,
5312 (tdata->plaintext.len - tdata->cipher.offset_bits -
5313 (tdata->digest.len << 3)),
5314 tdata->cipher.offset_bits,
5315 "SNOW 3G Plaintext data not as expected");
5317 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5319 tdata->ciphertext.data,
5320 (tdata->validDataLenInBits.len -
5321 tdata->cipher.offset_bits),
5322 tdata->cipher.offset_bits,
5323 "SNOW 3G Ciphertext data not as expected");
5325 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5328 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5329 "SNOW 3G Generated auth tag not as expected");
5335 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5336 uint8_t op_mode, uint8_t verify)
5338 struct crypto_testsuite_params *ts_params = &testsuite_params;
5339 struct crypto_unittest_params *ut_params = &unittest_params;
5343 uint8_t *plaintext = NULL, *ciphertext = NULL;
5344 unsigned int plaintext_pad_len;
5345 unsigned int plaintext_len;
5346 unsigned int ciphertext_pad_len;
5347 unsigned int ciphertext_len;
5349 struct rte_cryptodev_info dev_info;
5351 /* Verify the capabilities */
5352 struct rte_cryptodev_sym_capability_idx cap_idx;
5353 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5354 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5355 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5357 return TEST_SKIPPED;
5358 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5359 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5360 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5362 return TEST_SKIPPED;
5364 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5366 uint64_t feat_flags = dev_info.feature_flags;
5368 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5369 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5370 printf("Device doesn't support RAW data-path APIs.\n");
5371 return TEST_SKIPPED;
5374 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5375 return TEST_SKIPPED;
5377 if (op_mode == OUT_OF_PLACE) {
5378 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5379 return TEST_SKIPPED;
5380 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5381 printf("Device doesn't support digest encrypted.\n");
5382 return TEST_SKIPPED;
5386 /* Create KASUMI session */
5387 retval = create_wireless_algo_auth_cipher_session(
5388 ts_params->valid_devs[0],
5389 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5390 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5391 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5392 : RTE_CRYPTO_AUTH_OP_GENERATE),
5393 RTE_CRYPTO_AUTH_KASUMI_F9,
5394 RTE_CRYPTO_CIPHER_KASUMI_F8,
5395 tdata->key.data, tdata->key.len,
5396 0, tdata->digest.len,
5397 tdata->cipher_iv.len);
5402 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5403 if (op_mode == OUT_OF_PLACE)
5404 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5406 /* clear mbuf payload */
5407 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5408 rte_pktmbuf_tailroom(ut_params->ibuf));
5409 if (op_mode == OUT_OF_PLACE)
5410 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5411 rte_pktmbuf_tailroom(ut_params->obuf));
5413 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5414 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5415 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5416 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5419 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5420 ciphertext_pad_len);
5421 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5422 if (op_mode == OUT_OF_PLACE)
5423 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5424 debug_hexdump(stdout, "ciphertext:", ciphertext,
5427 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5429 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5430 if (op_mode == OUT_OF_PLACE)
5431 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5432 debug_hexdump(stdout, "plaintext:", plaintext,
5436 /* Create KASUMI operation */
5437 retval = create_wireless_algo_auth_cipher_operation(
5438 tdata->digest.data, tdata->digest.len,
5439 tdata->cipher_iv.data, tdata->cipher_iv.len,
5441 (tdata->digest.offset_bytes == 0 ?
5442 (verify ? ciphertext_pad_len : plaintext_pad_len)
5443 : tdata->digest.offset_bytes),
5444 tdata->validCipherLenInBits.len,
5445 tdata->validCipherOffsetInBits.len,
5446 tdata->validAuthLenInBits.len,
5448 op_mode, 0, verify);
5453 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5454 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5455 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5457 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5460 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5462 ut_params->obuf = (op_mode == IN_PLACE ?
5463 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5467 if (ut_params->obuf)
5468 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5471 plaintext = ciphertext;
5473 debug_hexdump(stdout, "plaintext:", plaintext,
5474 (tdata->plaintext.len >> 3) - tdata->digest.len);
5475 debug_hexdump(stdout, "plaintext expected:",
5476 tdata->plaintext.data,
5477 (tdata->plaintext.len >> 3) - tdata->digest.len);
5479 if (ut_params->obuf)
5480 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5483 ciphertext = plaintext;
5485 debug_hexdump(stdout, "ciphertext:", ciphertext,
5487 debug_hexdump(stdout, "ciphertext expected:",
5488 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5490 ut_params->digest = rte_pktmbuf_mtod(
5491 ut_params->obuf, uint8_t *) +
5492 (tdata->digest.offset_bytes == 0 ?
5493 plaintext_pad_len : tdata->digest.offset_bytes);
5495 debug_hexdump(stdout, "digest:", ut_params->digest,
5497 debug_hexdump(stdout, "digest expected:",
5498 tdata->digest.data, tdata->digest.len);
5503 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5505 tdata->plaintext.data,
5506 tdata->plaintext.len >> 3,
5507 "KASUMI Plaintext data not as expected");
5509 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5511 tdata->ciphertext.data,
5512 tdata->ciphertext.len >> 3,
5513 "KASUMI Ciphertext data not as expected");
5515 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5518 DIGEST_BYTE_LENGTH_KASUMI_F9,
5519 "KASUMI Generated auth tag not as expected");
5525 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5526 uint8_t op_mode, uint8_t verify)
5528 struct crypto_testsuite_params *ts_params = &testsuite_params;
5529 struct crypto_unittest_params *ut_params = &unittest_params;
5533 const uint8_t *plaintext = NULL;
5534 const uint8_t *ciphertext = NULL;
5535 const uint8_t *digest = NULL;
5536 unsigned int plaintext_pad_len;
5537 unsigned int plaintext_len;
5538 unsigned int ciphertext_pad_len;
5539 unsigned int ciphertext_len;
5540 uint8_t buffer[10000];
5541 uint8_t digest_buffer[10000];
5543 struct rte_cryptodev_info dev_info;
5545 /* Verify the capabilities */
5546 struct rte_cryptodev_sym_capability_idx cap_idx;
5547 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5548 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5549 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5551 return TEST_SKIPPED;
5552 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5553 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5554 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5556 return TEST_SKIPPED;
5558 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5559 return TEST_SKIPPED;
5561 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5563 uint64_t feat_flags = dev_info.feature_flags;
5565 if (op_mode == IN_PLACE) {
5566 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5567 printf("Device doesn't support in-place scatter-gather "
5568 "in both input and output mbufs.\n");
5569 return TEST_SKIPPED;
5571 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5572 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5573 printf("Device doesn't support RAW data-path APIs.\n");
5574 return TEST_SKIPPED;
5577 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5578 return TEST_SKIPPED;
5579 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5580 printf("Device doesn't support out-of-place scatter-gather "
5581 "in both input and output mbufs.\n");
5582 return TEST_SKIPPED;
5584 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5585 printf("Device doesn't support digest encrypted.\n");
5586 return TEST_SKIPPED;
5590 /* Create KASUMI session */
5591 retval = create_wireless_algo_auth_cipher_session(
5592 ts_params->valid_devs[0],
5593 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5594 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5595 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5596 : RTE_CRYPTO_AUTH_OP_GENERATE),
5597 RTE_CRYPTO_AUTH_KASUMI_F9,
5598 RTE_CRYPTO_CIPHER_KASUMI_F8,
5599 tdata->key.data, tdata->key.len,
5600 0, tdata->digest.len,
5601 tdata->cipher_iv.len);
5606 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5607 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5608 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5609 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5611 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5612 plaintext_pad_len, 15, 0);
5613 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5614 "Failed to allocate input buffer in mempool");
5616 if (op_mode == OUT_OF_PLACE) {
5617 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5618 plaintext_pad_len, 15, 0);
5619 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5620 "Failed to allocate output buffer in mempool");
5624 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5625 tdata->ciphertext.data);
5626 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5627 ciphertext_len, buffer);
5628 debug_hexdump(stdout, "ciphertext:", ciphertext,
5631 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5632 tdata->plaintext.data);
5633 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5634 plaintext_len, buffer);
5635 debug_hexdump(stdout, "plaintext:", plaintext,
5638 memset(buffer, 0, sizeof(buffer));
5640 /* Create KASUMI operation */
5641 retval = create_wireless_algo_auth_cipher_operation(
5642 tdata->digest.data, tdata->digest.len,
5643 tdata->cipher_iv.data, tdata->cipher_iv.len,
5645 (tdata->digest.offset_bytes == 0 ?
5646 (verify ? ciphertext_pad_len : plaintext_pad_len)
5647 : tdata->digest.offset_bytes),
5648 tdata->validCipherLenInBits.len,
5649 tdata->validCipherOffsetInBits.len,
5650 tdata->validAuthLenInBits.len,
5652 op_mode, 1, verify);
5657 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5658 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5659 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5661 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5664 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5666 ut_params->obuf = (op_mode == IN_PLACE ?
5667 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5670 if (ut_params->obuf)
5671 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5672 plaintext_len, buffer);
5674 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5675 plaintext_len, buffer);
5677 debug_hexdump(stdout, "plaintext:", plaintext,
5678 (tdata->plaintext.len >> 3) - tdata->digest.len);
5679 debug_hexdump(stdout, "plaintext expected:",
5680 tdata->plaintext.data,
5681 (tdata->plaintext.len >> 3) - tdata->digest.len);
5683 if (ut_params->obuf)
5684 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5685 ciphertext_len, buffer);
5687 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5688 ciphertext_len, buffer);
5690 debug_hexdump(stdout, "ciphertext:", ciphertext,
5692 debug_hexdump(stdout, "ciphertext expected:",
5693 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5695 if (ut_params->obuf)
5696 digest = rte_pktmbuf_read(ut_params->obuf,
5697 (tdata->digest.offset_bytes == 0 ?
5698 plaintext_pad_len : tdata->digest.offset_bytes),
5699 tdata->digest.len, digest_buffer);
5701 digest = rte_pktmbuf_read(ut_params->ibuf,
5702 (tdata->digest.offset_bytes == 0 ?
5703 plaintext_pad_len : tdata->digest.offset_bytes),
5704 tdata->digest.len, digest_buffer);
5706 debug_hexdump(stdout, "digest:", digest,
5708 debug_hexdump(stdout, "digest expected:",
5709 tdata->digest.data, tdata->digest.len);
5714 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5716 tdata->plaintext.data,
5717 tdata->plaintext.len >> 3,
5718 "KASUMI Plaintext data not as expected");
5720 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5722 tdata->ciphertext.data,
5723 tdata->validDataLenInBits.len,
5724 "KASUMI Ciphertext data not as expected");
5726 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5729 DIGEST_BYTE_LENGTH_KASUMI_F9,
5730 "KASUMI Generated auth tag not as expected");
5736 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5738 struct crypto_testsuite_params *ts_params = &testsuite_params;
5739 struct crypto_unittest_params *ut_params = &unittest_params;
5743 uint8_t *plaintext, *ciphertext;
5744 unsigned plaintext_pad_len;
5745 unsigned plaintext_len;
5746 struct rte_cryptodev_info dev_info;
5748 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5749 uint64_t feat_flags = dev_info.feature_flags;
5751 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5752 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5753 printf("Device doesn't support RAW data-path APIs.\n");
5754 return TEST_SKIPPED;
5757 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5758 return TEST_SKIPPED;
5760 /* Verify the capabilities */
5761 struct rte_cryptodev_sym_capability_idx cap_idx;
5762 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5763 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5764 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5766 return TEST_SKIPPED;
5767 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5768 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5769 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5771 return TEST_SKIPPED;
5773 /* Create KASUMI session */
5774 retval = create_wireless_algo_cipher_auth_session(
5775 ts_params->valid_devs[0],
5776 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5777 RTE_CRYPTO_AUTH_OP_GENERATE,
5778 RTE_CRYPTO_AUTH_KASUMI_F9,
5779 RTE_CRYPTO_CIPHER_KASUMI_F8,
5780 tdata->key.data, tdata->key.len,
5781 0, tdata->digest.len,
5782 tdata->cipher_iv.len);
5786 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5788 /* clear mbuf payload */
5789 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5790 rte_pktmbuf_tailroom(ut_params->ibuf));
5792 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5793 /* Append data which is padded to a multiple of */
5794 /* the algorithms block size */
5795 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5796 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5798 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5800 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5802 /* Create KASUMI operation */
5803 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5804 tdata->digest.len, NULL, 0,
5805 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5806 tdata->cipher_iv.data, tdata->cipher_iv.len,
5807 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5808 tdata->validCipherOffsetInBits.len,
5809 tdata->validAuthLenInBits.len,
5815 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5816 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5817 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5819 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5821 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5823 if (ut_params->op->sym->m_dst)
5824 ut_params->obuf = ut_params->op->sym->m_dst;
5826 ut_params->obuf = ut_params->op->sym->m_src;
5828 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5829 tdata->validCipherOffsetInBits.len >> 3);
5831 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5832 + plaintext_pad_len;
5834 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5835 (tdata->validCipherOffsetInBits.len >> 3);
5837 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5839 reference_ciphertext,
5840 tdata->validCipherLenInBits.len,
5841 "KASUMI Ciphertext data not as expected");
5844 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5847 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5848 "KASUMI Generated auth tag not as expected");
5853 test_zuc_encryption(const struct wireless_test_data *tdata)
5855 struct crypto_testsuite_params *ts_params = &testsuite_params;
5856 struct crypto_unittest_params *ut_params = &unittest_params;
5859 uint8_t *plaintext, *ciphertext;
5860 unsigned plaintext_pad_len;
5861 unsigned plaintext_len;
5862 struct rte_cryptodev_info dev_info;
5864 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5865 uint64_t feat_flags = dev_info.feature_flags;
5867 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5868 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5869 printf("Device doesn't support RAW data-path APIs.\n");
5870 return TEST_SKIPPED;
5873 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5874 return TEST_SKIPPED;
5876 struct rte_cryptodev_sym_capability_idx cap_idx;
5878 /* Check if device supports ZUC EEA3 */
5879 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5880 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5882 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5884 return TEST_SKIPPED;
5886 /* Create ZUC session */
5887 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5888 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5889 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5890 tdata->key.data, tdata->key.len,
5891 tdata->cipher_iv.len);
5895 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5897 /* Clear mbuf payload */
5898 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5899 rte_pktmbuf_tailroom(ut_params->ibuf));
5901 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5902 /* Append data which is padded to a multiple */
5903 /* of the algorithms block size */
5904 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5905 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5907 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5909 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5911 /* Create ZUC operation */
5912 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5913 tdata->cipher_iv.len,
5914 tdata->plaintext.len,
5919 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5920 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5921 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5923 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5925 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5927 ut_params->obuf = ut_params->op->sym->m_dst;
5928 if (ut_params->obuf)
5929 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5931 ciphertext = plaintext;
5933 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5936 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5938 tdata->ciphertext.data,
5939 tdata->validCipherLenInBits.len,
5940 "ZUC Ciphertext data not as expected");
5945 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5947 struct crypto_testsuite_params *ts_params = &testsuite_params;
5948 struct crypto_unittest_params *ut_params = &unittest_params;
5952 unsigned int plaintext_pad_len;
5953 unsigned int plaintext_len;
5954 const uint8_t *ciphertext;
5955 uint8_t ciphertext_buffer[2048];
5956 struct rte_cryptodev_info dev_info;
5958 struct rte_cryptodev_sym_capability_idx cap_idx;
5960 /* Check if device supports ZUC EEA3 */
5961 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5962 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5964 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5966 return TEST_SKIPPED;
5968 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5969 return TEST_SKIPPED;
5971 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5973 uint64_t feat_flags = dev_info.feature_flags;
5975 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5976 printf("Device doesn't support in-place scatter-gather. "
5978 return TEST_SKIPPED;
5981 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5982 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5983 printf("Device doesn't support RAW data-path APIs.\n");
5984 return TEST_SKIPPED;
5987 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5989 /* Append data which is padded to a multiple */
5990 /* of the algorithms block size */
5991 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5993 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5994 plaintext_pad_len, 10, 0);
5996 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5997 tdata->plaintext.data);
5999 /* Create ZUC session */
6000 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6001 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6002 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6003 tdata->key.data, tdata->key.len,
6004 tdata->cipher_iv.len);
6008 /* Clear mbuf payload */
6010 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6012 /* Create ZUC operation */
6013 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6014 tdata->cipher_iv.len, tdata->plaintext.len,
6019 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6020 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6021 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6023 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6025 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6027 ut_params->obuf = ut_params->op->sym->m_dst;
6028 if (ut_params->obuf)
6029 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6030 0, plaintext_len, ciphertext_buffer);
6032 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6033 0, plaintext_len, ciphertext_buffer);
6036 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6039 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6041 tdata->ciphertext.data,
6042 tdata->validCipherLenInBits.len,
6043 "ZUC Ciphertext data not as expected");
6049 test_zuc_authentication(const struct wireless_test_data *tdata)
6051 struct crypto_testsuite_params *ts_params = &testsuite_params;
6052 struct crypto_unittest_params *ut_params = &unittest_params;
6055 unsigned plaintext_pad_len;
6056 unsigned plaintext_len;
6059 struct rte_cryptodev_sym_capability_idx cap_idx;
6060 struct rte_cryptodev_info dev_info;
6062 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6063 uint64_t feat_flags = dev_info.feature_flags;
6065 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6066 (tdata->validAuthLenInBits.len % 8 != 0)) {
6067 printf("Device doesn't support NON-Byte Aligned Data.\n");
6068 return TEST_SKIPPED;
6071 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6072 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6073 printf("Device doesn't support RAW data-path APIs.\n");
6074 return TEST_SKIPPED;
6077 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6078 return TEST_SKIPPED;
6080 /* Check if device supports ZUC EIA3 */
6081 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6082 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6084 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6086 return TEST_SKIPPED;
6088 /* Create ZUC session */
6089 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6090 tdata->key.data, tdata->key.len,
6091 tdata->auth_iv.len, tdata->digest.len,
6092 RTE_CRYPTO_AUTH_OP_GENERATE,
6093 RTE_CRYPTO_AUTH_ZUC_EIA3);
6097 /* alloc mbuf and set payload */
6098 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6100 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6101 rte_pktmbuf_tailroom(ut_params->ibuf));
6103 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6104 /* Append data which is padded to a multiple of */
6105 /* the algorithms block size */
6106 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6107 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6109 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6111 /* Create ZUC operation */
6112 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6113 tdata->auth_iv.data, tdata->auth_iv.len,
6114 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6115 tdata->validAuthLenInBits.len,
6120 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6121 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6122 ut_params->op, 0, 1, 1, 0);
6124 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6126 ut_params->obuf = ut_params->op->sym->m_src;
6127 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6128 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6129 + plaintext_pad_len;
6132 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6136 "ZUC Generated auth tag not as expected");
6142 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6143 uint8_t op_mode, uint8_t verify)
6145 struct crypto_testsuite_params *ts_params = &testsuite_params;
6146 struct crypto_unittest_params *ut_params = &unittest_params;
6150 uint8_t *plaintext = NULL, *ciphertext = NULL;
6151 unsigned int plaintext_pad_len;
6152 unsigned int plaintext_len;
6153 unsigned int ciphertext_pad_len;
6154 unsigned int ciphertext_len;
6156 struct rte_cryptodev_info dev_info;
6157 struct rte_cryptodev_sym_capability_idx cap_idx;
6159 /* Check if device supports ZUC EIA3 */
6160 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6161 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6163 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6165 return TEST_SKIPPED;
6167 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6169 uint64_t feat_flags = dev_info.feature_flags;
6171 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6172 printf("Device doesn't support digest encrypted.\n");
6173 return TEST_SKIPPED;
6175 if (op_mode == IN_PLACE) {
6176 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6177 printf("Device doesn't support in-place scatter-gather "
6178 "in both input and output mbufs.\n");
6179 return TEST_SKIPPED;
6182 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6183 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6184 printf("Device doesn't support RAW data-path APIs.\n");
6185 return TEST_SKIPPED;
6188 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6189 return TEST_SKIPPED;
6190 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6191 printf("Device doesn't support out-of-place scatter-gather "
6192 "in both input and output mbufs.\n");
6193 return TEST_SKIPPED;
6197 /* Create ZUC session */
6198 retval = create_wireless_algo_auth_cipher_session(
6199 ts_params->valid_devs[0],
6200 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6201 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6202 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6203 : RTE_CRYPTO_AUTH_OP_GENERATE),
6204 RTE_CRYPTO_AUTH_ZUC_EIA3,
6205 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6206 tdata->key.data, tdata->key.len,
6207 tdata->auth_iv.len, tdata->digest.len,
6208 tdata->cipher_iv.len);
6213 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6214 if (op_mode == OUT_OF_PLACE)
6215 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6217 /* clear mbuf payload */
6218 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6219 rte_pktmbuf_tailroom(ut_params->ibuf));
6220 if (op_mode == OUT_OF_PLACE)
6221 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6222 rte_pktmbuf_tailroom(ut_params->obuf));
6224 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6225 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6226 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6227 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6230 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6231 ciphertext_pad_len);
6232 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6233 if (op_mode == OUT_OF_PLACE)
6234 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6235 debug_hexdump(stdout, "ciphertext:", ciphertext,
6238 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6240 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6241 if (op_mode == OUT_OF_PLACE)
6242 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6243 debug_hexdump(stdout, "plaintext:", plaintext,
6247 /* Create ZUC operation */
6248 retval = create_wireless_algo_auth_cipher_operation(
6249 tdata->digest.data, tdata->digest.len,
6250 tdata->cipher_iv.data, tdata->cipher_iv.len,
6251 tdata->auth_iv.data, tdata->auth_iv.len,
6252 (tdata->digest.offset_bytes == 0 ?
6253 (verify ? ciphertext_pad_len : plaintext_pad_len)
6254 : tdata->digest.offset_bytes),
6255 tdata->validCipherLenInBits.len,
6256 tdata->validCipherOffsetInBits.len,
6257 tdata->validAuthLenInBits.len,
6259 op_mode, 0, verify);
6264 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6265 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6266 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6268 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6271 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6273 ut_params->obuf = (op_mode == IN_PLACE ?
6274 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6278 if (ut_params->obuf)
6279 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6282 plaintext = ciphertext;
6284 debug_hexdump(stdout, "plaintext:", plaintext,
6285 (tdata->plaintext.len >> 3) - tdata->digest.len);
6286 debug_hexdump(stdout, "plaintext expected:",
6287 tdata->plaintext.data,
6288 (tdata->plaintext.len >> 3) - tdata->digest.len);
6290 if (ut_params->obuf)
6291 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6294 ciphertext = plaintext;
6296 debug_hexdump(stdout, "ciphertext:", ciphertext,
6298 debug_hexdump(stdout, "ciphertext expected:",
6299 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6301 ut_params->digest = rte_pktmbuf_mtod(
6302 ut_params->obuf, uint8_t *) +
6303 (tdata->digest.offset_bytes == 0 ?
6304 plaintext_pad_len : tdata->digest.offset_bytes);
6306 debug_hexdump(stdout, "digest:", ut_params->digest,
6308 debug_hexdump(stdout, "digest expected:",
6309 tdata->digest.data, tdata->digest.len);
6314 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6316 tdata->plaintext.data,
6317 tdata->plaintext.len >> 3,
6318 "ZUC Plaintext data not as expected");
6320 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6322 tdata->ciphertext.data,
6323 tdata->ciphertext.len >> 3,
6324 "ZUC Ciphertext data not as expected");
6326 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6329 DIGEST_BYTE_LENGTH_KASUMI_F9,
6330 "ZUC Generated auth tag not as expected");
6336 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6337 uint8_t op_mode, uint8_t verify)
6339 struct crypto_testsuite_params *ts_params = &testsuite_params;
6340 struct crypto_unittest_params *ut_params = &unittest_params;
6344 const uint8_t *plaintext = NULL;
6345 const uint8_t *ciphertext = NULL;
6346 const uint8_t *digest = NULL;
6347 unsigned int plaintext_pad_len;
6348 unsigned int plaintext_len;
6349 unsigned int ciphertext_pad_len;
6350 unsigned int ciphertext_len;
6351 uint8_t buffer[10000];
6352 uint8_t digest_buffer[10000];
6354 struct rte_cryptodev_info dev_info;
6355 struct rte_cryptodev_sym_capability_idx cap_idx;
6357 /* Check if device supports ZUC EIA3 */
6358 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6359 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6361 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6363 return TEST_SKIPPED;
6365 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6367 uint64_t feat_flags = dev_info.feature_flags;
6369 if (op_mode == IN_PLACE) {
6370 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6371 printf("Device doesn't support in-place scatter-gather "
6372 "in both input and output mbufs.\n");
6373 return TEST_SKIPPED;
6376 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6377 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6378 printf("Device doesn't support RAW data-path APIs.\n");
6379 return TEST_SKIPPED;
6382 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6383 return TEST_SKIPPED;
6384 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6385 printf("Device doesn't support out-of-place scatter-gather "
6386 "in both input and output mbufs.\n");
6387 return TEST_SKIPPED;
6389 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6390 printf("Device doesn't support digest encrypted.\n");
6391 return TEST_SKIPPED;
6395 /* Create ZUC session */
6396 retval = create_wireless_algo_auth_cipher_session(
6397 ts_params->valid_devs[0],
6398 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6399 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6400 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6401 : RTE_CRYPTO_AUTH_OP_GENERATE),
6402 RTE_CRYPTO_AUTH_ZUC_EIA3,
6403 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6404 tdata->key.data, tdata->key.len,
6405 tdata->auth_iv.len, tdata->digest.len,
6406 tdata->cipher_iv.len);
6411 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6412 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6413 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6414 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6416 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6417 plaintext_pad_len, 15, 0);
6418 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6419 "Failed to allocate input buffer in mempool");
6421 if (op_mode == OUT_OF_PLACE) {
6422 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6423 plaintext_pad_len, 15, 0);
6424 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6425 "Failed to allocate output buffer in mempool");
6429 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6430 tdata->ciphertext.data);
6431 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6432 ciphertext_len, buffer);
6433 debug_hexdump(stdout, "ciphertext:", ciphertext,
6436 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6437 tdata->plaintext.data);
6438 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6439 plaintext_len, buffer);
6440 debug_hexdump(stdout, "plaintext:", plaintext,
6443 memset(buffer, 0, sizeof(buffer));
6445 /* Create ZUC operation */
6446 retval = create_wireless_algo_auth_cipher_operation(
6447 tdata->digest.data, tdata->digest.len,
6448 tdata->cipher_iv.data, tdata->cipher_iv.len,
6450 (tdata->digest.offset_bytes == 0 ?
6451 (verify ? ciphertext_pad_len : plaintext_pad_len)
6452 : tdata->digest.offset_bytes),
6453 tdata->validCipherLenInBits.len,
6454 tdata->validCipherOffsetInBits.len,
6455 tdata->validAuthLenInBits.len,
6457 op_mode, 1, verify);
6462 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6463 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6464 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6466 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6469 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6471 ut_params->obuf = (op_mode == IN_PLACE ?
6472 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6475 if (ut_params->obuf)
6476 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6477 plaintext_len, buffer);
6479 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6480 plaintext_len, buffer);
6482 debug_hexdump(stdout, "plaintext:", plaintext,
6483 (tdata->plaintext.len >> 3) - tdata->digest.len);
6484 debug_hexdump(stdout, "plaintext expected:",
6485 tdata->plaintext.data,
6486 (tdata->plaintext.len >> 3) - tdata->digest.len);
6488 if (ut_params->obuf)
6489 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6490 ciphertext_len, buffer);
6492 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6493 ciphertext_len, buffer);
6495 debug_hexdump(stdout, "ciphertext:", ciphertext,
6497 debug_hexdump(stdout, "ciphertext expected:",
6498 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6500 if (ut_params->obuf)
6501 digest = rte_pktmbuf_read(ut_params->obuf,
6502 (tdata->digest.offset_bytes == 0 ?
6503 plaintext_pad_len : tdata->digest.offset_bytes),
6504 tdata->digest.len, digest_buffer);
6506 digest = rte_pktmbuf_read(ut_params->ibuf,
6507 (tdata->digest.offset_bytes == 0 ?
6508 plaintext_pad_len : tdata->digest.offset_bytes),
6509 tdata->digest.len, digest_buffer);
6511 debug_hexdump(stdout, "digest:", digest,
6513 debug_hexdump(stdout, "digest expected:",
6514 tdata->digest.data, tdata->digest.len);
6519 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6521 tdata->plaintext.data,
6522 tdata->plaintext.len >> 3,
6523 "ZUC Plaintext data not as expected");
6525 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6527 tdata->ciphertext.data,
6528 tdata->validDataLenInBits.len,
6529 "ZUC Ciphertext data not as expected");
6531 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6534 DIGEST_BYTE_LENGTH_KASUMI_F9,
6535 "ZUC Generated auth tag not as expected");
6541 test_kasumi_encryption_test_case_1(void)
6543 return test_kasumi_encryption(&kasumi_test_case_1);
6547 test_kasumi_encryption_test_case_1_sgl(void)
6549 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6553 test_kasumi_encryption_test_case_1_oop(void)
6555 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6559 test_kasumi_encryption_test_case_1_oop_sgl(void)
6561 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6565 test_kasumi_encryption_test_case_2(void)
6567 return test_kasumi_encryption(&kasumi_test_case_2);
6571 test_kasumi_encryption_test_case_3(void)
6573 return test_kasumi_encryption(&kasumi_test_case_3);
6577 test_kasumi_encryption_test_case_4(void)
6579 return test_kasumi_encryption(&kasumi_test_case_4);
6583 test_kasumi_encryption_test_case_5(void)
6585 return test_kasumi_encryption(&kasumi_test_case_5);
6589 test_kasumi_decryption_test_case_1(void)
6591 return test_kasumi_decryption(&kasumi_test_case_1);
6595 test_kasumi_decryption_test_case_1_oop(void)
6597 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6601 test_kasumi_decryption_test_case_2(void)
6603 return test_kasumi_decryption(&kasumi_test_case_2);
6607 test_kasumi_decryption_test_case_3(void)
6609 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6610 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6611 return TEST_SKIPPED;
6612 return test_kasumi_decryption(&kasumi_test_case_3);
6616 test_kasumi_decryption_test_case_4(void)
6618 return test_kasumi_decryption(&kasumi_test_case_4);
6622 test_kasumi_decryption_test_case_5(void)
6624 return test_kasumi_decryption(&kasumi_test_case_5);
6627 test_snow3g_encryption_test_case_1(void)
6629 return test_snow3g_encryption(&snow3g_test_case_1);
6633 test_snow3g_encryption_test_case_1_oop(void)
6635 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6639 test_snow3g_encryption_test_case_1_oop_sgl(void)
6641 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6646 test_snow3g_encryption_test_case_1_offset_oop(void)
6648 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6652 test_snow3g_encryption_test_case_2(void)
6654 return test_snow3g_encryption(&snow3g_test_case_2);
6658 test_snow3g_encryption_test_case_3(void)
6660 return test_snow3g_encryption(&snow3g_test_case_3);
6664 test_snow3g_encryption_test_case_4(void)
6666 return test_snow3g_encryption(&snow3g_test_case_4);
6670 test_snow3g_encryption_test_case_5(void)
6672 return test_snow3g_encryption(&snow3g_test_case_5);
6676 test_snow3g_decryption_test_case_1(void)
6678 return test_snow3g_decryption(&snow3g_test_case_1);
6682 test_snow3g_decryption_test_case_1_oop(void)
6684 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6688 test_snow3g_decryption_test_case_2(void)
6690 return test_snow3g_decryption(&snow3g_test_case_2);
6694 test_snow3g_decryption_test_case_3(void)
6696 return test_snow3g_decryption(&snow3g_test_case_3);
6700 test_snow3g_decryption_test_case_4(void)
6702 return test_snow3g_decryption(&snow3g_test_case_4);
6706 test_snow3g_decryption_test_case_5(void)
6708 return test_snow3g_decryption(&snow3g_test_case_5);
6712 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6713 * Pattern digest from snow3g_test_data must be allocated as
6714 * 4 last bytes in plaintext.
6717 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6718 struct snow3g_hash_test_data *output)
6720 if ((pattern != NULL) && (output != NULL)) {
6721 output->key.len = pattern->key.len;
6723 memcpy(output->key.data,
6724 pattern->key.data, pattern->key.len);
6726 output->auth_iv.len = pattern->auth_iv.len;
6728 memcpy(output->auth_iv.data,
6729 pattern->auth_iv.data, pattern->auth_iv.len);
6731 output->plaintext.len = pattern->plaintext.len;
6733 memcpy(output->plaintext.data,
6734 pattern->plaintext.data, pattern->plaintext.len >> 3);
6736 output->digest.len = pattern->digest.len;
6738 memcpy(output->digest.data,
6739 &pattern->plaintext.data[pattern->digest.offset_bytes],
6740 pattern->digest.len);
6742 output->validAuthLenInBits.len =
6743 pattern->validAuthLenInBits.len;
6748 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6751 test_snow3g_decryption_with_digest_test_case_1(void)
6753 struct snow3g_hash_test_data snow3g_hash_data;
6754 struct rte_cryptodev_info dev_info;
6755 struct crypto_testsuite_params *ts_params = &testsuite_params;
6757 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6758 uint64_t feat_flags = dev_info.feature_flags;
6760 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6761 printf("Device doesn't support encrypted digest operations.\n");
6762 return TEST_SKIPPED;
6766 * Function prepare data for hash veryfication test case.
6767 * Digest is allocated in 4 last bytes in plaintext, pattern.
6769 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6771 return test_snow3g_decryption(&snow3g_test_case_7) &
6772 test_snow3g_authentication_verify(&snow3g_hash_data);
6776 test_snow3g_cipher_auth_test_case_1(void)
6778 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6782 test_snow3g_auth_cipher_test_case_1(void)
6784 return test_snow3g_auth_cipher(
6785 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6789 test_snow3g_auth_cipher_test_case_2(void)
6791 return test_snow3g_auth_cipher(
6792 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6796 test_snow3g_auth_cipher_test_case_2_oop(void)
6798 return test_snow3g_auth_cipher(
6799 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6803 test_snow3g_auth_cipher_part_digest_enc(void)
6805 return test_snow3g_auth_cipher(
6806 &snow3g_auth_cipher_partial_digest_encryption,
6811 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6813 return test_snow3g_auth_cipher(
6814 &snow3g_auth_cipher_partial_digest_encryption,
6819 test_snow3g_auth_cipher_test_case_3_sgl(void)
6821 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6822 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6823 return TEST_SKIPPED;
6824 return test_snow3g_auth_cipher_sgl(
6825 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6829 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6831 return test_snow3g_auth_cipher_sgl(
6832 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6836 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6838 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6839 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6840 return TEST_SKIPPED;
6841 return test_snow3g_auth_cipher_sgl(
6842 &snow3g_auth_cipher_partial_digest_encryption,
6847 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6849 return test_snow3g_auth_cipher_sgl(
6850 &snow3g_auth_cipher_partial_digest_encryption,
6855 test_snow3g_auth_cipher_verify_test_case_1(void)
6857 return test_snow3g_auth_cipher(
6858 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6862 test_snow3g_auth_cipher_verify_test_case_2(void)
6864 return test_snow3g_auth_cipher(
6865 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6869 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6871 return test_snow3g_auth_cipher(
6872 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6876 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6878 return test_snow3g_auth_cipher(
6879 &snow3g_auth_cipher_partial_digest_encryption,
6884 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6886 return test_snow3g_auth_cipher(
6887 &snow3g_auth_cipher_partial_digest_encryption,
6892 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6894 return test_snow3g_auth_cipher_sgl(
6895 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6899 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6901 return test_snow3g_auth_cipher_sgl(
6902 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6906 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6908 return test_snow3g_auth_cipher_sgl(
6909 &snow3g_auth_cipher_partial_digest_encryption,
6914 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6916 return test_snow3g_auth_cipher_sgl(
6917 &snow3g_auth_cipher_partial_digest_encryption,
6922 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6924 return test_snow3g_auth_cipher(
6925 &snow3g_test_case_7, IN_PLACE, 0);
6929 test_kasumi_auth_cipher_test_case_1(void)
6931 return test_kasumi_auth_cipher(
6932 &kasumi_test_case_3, IN_PLACE, 0);
6936 test_kasumi_auth_cipher_test_case_2(void)
6938 return test_kasumi_auth_cipher(
6939 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6943 test_kasumi_auth_cipher_test_case_2_oop(void)
6945 return test_kasumi_auth_cipher(
6946 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6950 test_kasumi_auth_cipher_test_case_2_sgl(void)
6952 return test_kasumi_auth_cipher_sgl(
6953 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6957 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6959 return test_kasumi_auth_cipher_sgl(
6960 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6964 test_kasumi_auth_cipher_verify_test_case_1(void)
6966 return test_kasumi_auth_cipher(
6967 &kasumi_test_case_3, IN_PLACE, 1);
6971 test_kasumi_auth_cipher_verify_test_case_2(void)
6973 return test_kasumi_auth_cipher(
6974 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6978 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6980 return test_kasumi_auth_cipher(
6981 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6985 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6987 return test_kasumi_auth_cipher_sgl(
6988 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6992 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6994 return test_kasumi_auth_cipher_sgl(
6995 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6999 test_kasumi_cipher_auth_test_case_1(void)
7001 return test_kasumi_cipher_auth(&kasumi_test_case_6);
7005 test_zuc_encryption_test_case_1(void)
7007 return test_zuc_encryption(&zuc_test_case_cipher_193b);
7011 test_zuc_encryption_test_case_2(void)
7013 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7017 test_zuc_encryption_test_case_3(void)
7019 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7023 test_zuc_encryption_test_case_4(void)
7025 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7029 test_zuc_encryption_test_case_5(void)
7031 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7035 test_zuc_encryption_test_case_6_sgl(void)
7037 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7041 test_zuc_hash_generate_test_case_1(void)
7043 return test_zuc_authentication(&zuc_test_case_auth_1b);
7047 test_zuc_hash_generate_test_case_2(void)
7049 return test_zuc_authentication(&zuc_test_case_auth_90b);
7053 test_zuc_hash_generate_test_case_3(void)
7055 return test_zuc_authentication(&zuc_test_case_auth_577b);
7059 test_zuc_hash_generate_test_case_4(void)
7061 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7065 test_zuc_hash_generate_test_case_5(void)
7067 return test_zuc_authentication(&zuc_test_auth_5670b);
7071 test_zuc_hash_generate_test_case_6(void)
7073 return test_zuc_authentication(&zuc_test_case_auth_128b);
7077 test_zuc_hash_generate_test_case_7(void)
7079 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7083 test_zuc_hash_generate_test_case_8(void)
7085 return test_zuc_authentication(&zuc_test_case_auth_584b);
7089 test_zuc_cipher_auth_test_case_1(void)
7091 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7095 test_zuc_cipher_auth_test_case_2(void)
7097 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7101 test_zuc_auth_cipher_test_case_1(void)
7103 return test_zuc_auth_cipher(
7104 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7108 test_zuc_auth_cipher_test_case_1_oop(void)
7110 return test_zuc_auth_cipher(
7111 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7115 test_zuc_auth_cipher_test_case_1_sgl(void)
7117 return test_zuc_auth_cipher_sgl(
7118 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7122 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7124 return test_zuc_auth_cipher_sgl(
7125 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7129 test_zuc_auth_cipher_verify_test_case_1(void)
7131 return test_zuc_auth_cipher(
7132 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7136 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7138 return test_zuc_auth_cipher(
7139 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7143 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7145 return test_zuc_auth_cipher_sgl(
7146 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7150 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7152 return test_zuc_auth_cipher_sgl(
7153 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7157 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7159 uint8_t dev_id = testsuite_params.valid_devs[0];
7161 struct rte_cryptodev_sym_capability_idx cap_idx;
7163 /* Check if device supports particular cipher algorithm */
7164 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7165 cap_idx.algo.cipher = tdata->cipher_algo;
7166 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7167 return TEST_SKIPPED;
7169 /* Check if device supports particular hash algorithm */
7170 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7171 cap_idx.algo.auth = tdata->auth_algo;
7172 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7173 return TEST_SKIPPED;
7179 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7180 uint8_t op_mode, uint8_t verify)
7182 struct crypto_testsuite_params *ts_params = &testsuite_params;
7183 struct crypto_unittest_params *ut_params = &unittest_params;
7187 uint8_t *plaintext = NULL, *ciphertext = NULL;
7188 unsigned int plaintext_pad_len;
7189 unsigned int plaintext_len;
7190 unsigned int ciphertext_pad_len;
7191 unsigned int ciphertext_len;
7193 struct rte_cryptodev_info dev_info;
7194 struct rte_crypto_op *op;
7196 /* Check if device supports particular algorithms separately */
7197 if (test_mixed_check_if_unsupported(tdata))
7198 return TEST_SKIPPED;
7199 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7200 return TEST_SKIPPED;
7202 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7204 uint64_t feat_flags = dev_info.feature_flags;
7206 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7207 printf("Device doesn't support digest encrypted.\n");
7208 return TEST_SKIPPED;
7211 /* Create the session */
7213 retval = create_wireless_algo_cipher_auth_session(
7214 ts_params->valid_devs[0],
7215 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7216 RTE_CRYPTO_AUTH_OP_VERIFY,
7219 tdata->auth_key.data, tdata->auth_key.len,
7220 tdata->auth_iv.len, tdata->digest_enc.len,
7221 tdata->cipher_iv.len);
7223 retval = create_wireless_algo_auth_cipher_session(
7224 ts_params->valid_devs[0],
7225 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7226 RTE_CRYPTO_AUTH_OP_GENERATE,
7229 tdata->auth_key.data, tdata->auth_key.len,
7230 tdata->auth_iv.len, tdata->digest_enc.len,
7231 tdata->cipher_iv.len);
7235 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7236 if (op_mode == OUT_OF_PLACE)
7237 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7239 /* clear mbuf payload */
7240 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7241 rte_pktmbuf_tailroom(ut_params->ibuf));
7242 if (op_mode == OUT_OF_PLACE) {
7244 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7245 rte_pktmbuf_tailroom(ut_params->obuf));
7248 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7249 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7250 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7251 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7254 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7255 ciphertext_pad_len);
7256 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7257 if (op_mode == OUT_OF_PLACE)
7258 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7259 debug_hexdump(stdout, "ciphertext:", ciphertext,
7262 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7264 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7265 if (op_mode == OUT_OF_PLACE)
7266 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7267 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7270 /* Create the operation */
7271 retval = create_wireless_algo_auth_cipher_operation(
7272 tdata->digest_enc.data, tdata->digest_enc.len,
7273 tdata->cipher_iv.data, tdata->cipher_iv.len,
7274 tdata->auth_iv.data, tdata->auth_iv.len,
7275 (tdata->digest_enc.offset == 0 ?
7277 : tdata->digest_enc.offset),
7278 tdata->validCipherLen.len_bits,
7279 tdata->cipher.offset_bits,
7280 tdata->validAuthLen.len_bits,
7281 tdata->auth.offset_bits,
7282 op_mode, 0, verify);
7287 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7289 /* Check if the op failed because the device doesn't */
7290 /* support this particular combination of algorithms */
7291 if (op == NULL && ut_params->op->status ==
7292 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7293 printf("Device doesn't support this mixed combination. "
7295 return TEST_SKIPPED;
7299 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7301 ut_params->obuf = (op_mode == IN_PLACE ?
7302 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7305 if (ut_params->obuf)
7306 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7309 plaintext = ciphertext +
7310 (tdata->cipher.offset_bits >> 3);
7312 debug_hexdump(stdout, "plaintext:", plaintext,
7313 tdata->plaintext.len_bits >> 3);
7314 debug_hexdump(stdout, "plaintext expected:",
7315 tdata->plaintext.data,
7316 tdata->plaintext.len_bits >> 3);
7318 if (ut_params->obuf)
7319 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7322 ciphertext = plaintext;
7324 debug_hexdump(stdout, "ciphertext:", ciphertext,
7326 debug_hexdump(stdout, "ciphertext expected:",
7327 tdata->ciphertext.data,
7328 tdata->ciphertext.len_bits >> 3);
7330 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7331 + (tdata->digest_enc.offset == 0 ?
7332 plaintext_pad_len : tdata->digest_enc.offset);
7334 debug_hexdump(stdout, "digest:", ut_params->digest,
7335 tdata->digest_enc.len);
7336 debug_hexdump(stdout, "digest expected:",
7337 tdata->digest_enc.data,
7338 tdata->digest_enc.len);
7343 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7345 tdata->plaintext.data,
7346 tdata->plaintext.len_bits >> 3,
7347 "Plaintext data not as expected");
7349 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7351 tdata->ciphertext.data,
7352 tdata->validDataLen.len_bits,
7353 "Ciphertext data not as expected");
7355 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7357 tdata->digest_enc.data,
7358 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7359 "Generated auth tag not as expected");
7362 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7363 "crypto op processing failed");
7369 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7370 uint8_t op_mode, uint8_t verify)
7372 struct crypto_testsuite_params *ts_params = &testsuite_params;
7373 struct crypto_unittest_params *ut_params = &unittest_params;
7377 const uint8_t *plaintext = NULL;
7378 const uint8_t *ciphertext = NULL;
7379 const uint8_t *digest = NULL;
7380 unsigned int plaintext_pad_len;
7381 unsigned int plaintext_len;
7382 unsigned int ciphertext_pad_len;
7383 unsigned int ciphertext_len;
7384 uint8_t buffer[10000];
7385 uint8_t digest_buffer[10000];
7387 struct rte_cryptodev_info dev_info;
7388 struct rte_crypto_op *op;
7390 /* Check if device supports particular algorithms */
7391 if (test_mixed_check_if_unsupported(tdata))
7392 return TEST_SKIPPED;
7393 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7394 return TEST_SKIPPED;
7396 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7398 uint64_t feat_flags = dev_info.feature_flags;
7400 if (op_mode == IN_PLACE) {
7401 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7402 printf("Device doesn't support in-place scatter-gather "
7403 "in both input and output mbufs.\n");
7404 return TEST_SKIPPED;
7407 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7408 printf("Device doesn't support out-of-place scatter-gather "
7409 "in both input and output mbufs.\n");
7410 return TEST_SKIPPED;
7412 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7413 printf("Device doesn't support digest encrypted.\n");
7414 return TEST_SKIPPED;
7418 /* Create the session */
7420 retval = create_wireless_algo_cipher_auth_session(
7421 ts_params->valid_devs[0],
7422 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7423 RTE_CRYPTO_AUTH_OP_VERIFY,
7426 tdata->auth_key.data, tdata->auth_key.len,
7427 tdata->auth_iv.len, tdata->digest_enc.len,
7428 tdata->cipher_iv.len);
7430 retval = create_wireless_algo_auth_cipher_session(
7431 ts_params->valid_devs[0],
7432 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7433 RTE_CRYPTO_AUTH_OP_GENERATE,
7436 tdata->auth_key.data, tdata->auth_key.len,
7437 tdata->auth_iv.len, tdata->digest_enc.len,
7438 tdata->cipher_iv.len);
7442 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7443 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7444 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7445 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7447 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7448 ciphertext_pad_len, 15, 0);
7449 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7450 "Failed to allocate input buffer in mempool");
7452 if (op_mode == OUT_OF_PLACE) {
7453 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7454 plaintext_pad_len, 15, 0);
7455 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7456 "Failed to allocate output buffer in mempool");
7460 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7461 tdata->ciphertext.data);
7462 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7463 ciphertext_len, buffer);
7464 debug_hexdump(stdout, "ciphertext:", ciphertext,
7467 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7468 tdata->plaintext.data);
7469 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7470 plaintext_len, buffer);
7471 debug_hexdump(stdout, "plaintext:", plaintext,
7474 memset(buffer, 0, sizeof(buffer));
7476 /* Create the operation */
7477 retval = create_wireless_algo_auth_cipher_operation(
7478 tdata->digest_enc.data, tdata->digest_enc.len,
7479 tdata->cipher_iv.data, tdata->cipher_iv.len,
7480 tdata->auth_iv.data, tdata->auth_iv.len,
7481 (tdata->digest_enc.offset == 0 ?
7483 : tdata->digest_enc.offset),
7484 tdata->validCipherLen.len_bits,
7485 tdata->cipher.offset_bits,
7486 tdata->validAuthLen.len_bits,
7487 tdata->auth.offset_bits,
7488 op_mode, 1, verify);
7493 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7495 /* Check if the op failed because the device doesn't */
7496 /* support this particular combination of algorithms */
7497 if (op == NULL && ut_params->op->status ==
7498 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7499 printf("Device doesn't support this mixed combination. "
7501 return TEST_SKIPPED;
7505 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7507 ut_params->obuf = (op_mode == IN_PLACE ?
7508 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7511 if (ut_params->obuf)
7512 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7513 plaintext_len, buffer);
7515 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7516 plaintext_len, buffer);
7518 debug_hexdump(stdout, "plaintext:", plaintext,
7519 (tdata->plaintext.len_bits >> 3) -
7520 tdata->digest_enc.len);
7521 debug_hexdump(stdout, "plaintext expected:",
7522 tdata->plaintext.data,
7523 (tdata->plaintext.len_bits >> 3) -
7524 tdata->digest_enc.len);
7526 if (ut_params->obuf)
7527 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7528 ciphertext_len, buffer);
7530 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7531 ciphertext_len, buffer);
7533 debug_hexdump(stdout, "ciphertext:", ciphertext,
7535 debug_hexdump(stdout, "ciphertext expected:",
7536 tdata->ciphertext.data,
7537 tdata->ciphertext.len_bits >> 3);
7539 if (ut_params->obuf)
7540 digest = rte_pktmbuf_read(ut_params->obuf,
7541 (tdata->digest_enc.offset == 0 ?
7543 tdata->digest_enc.offset),
7544 tdata->digest_enc.len, digest_buffer);
7546 digest = rte_pktmbuf_read(ut_params->ibuf,
7547 (tdata->digest_enc.offset == 0 ?
7549 tdata->digest_enc.offset),
7550 tdata->digest_enc.len, digest_buffer);
7552 debug_hexdump(stdout, "digest:", digest,
7553 tdata->digest_enc.len);
7554 debug_hexdump(stdout, "digest expected:",
7555 tdata->digest_enc.data, tdata->digest_enc.len);
7560 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7562 tdata->plaintext.data,
7563 tdata->plaintext.len_bits >> 3,
7564 "Plaintext data not as expected");
7566 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7568 tdata->ciphertext.data,
7569 tdata->validDataLen.len_bits,
7570 "Ciphertext data not as expected");
7571 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7573 tdata->digest_enc.data,
7574 tdata->digest_enc.len,
7575 "Generated auth tag not as expected");
7578 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7579 "crypto op processing failed");
7584 /** AUTH AES CMAC + CIPHER AES CTR */
7587 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7589 return test_mixed_auth_cipher(
7590 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7594 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7596 return test_mixed_auth_cipher(
7597 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7601 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7603 return test_mixed_auth_cipher_sgl(
7604 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7608 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7610 return test_mixed_auth_cipher_sgl(
7611 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7615 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7617 return test_mixed_auth_cipher(
7618 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7622 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7624 return test_mixed_auth_cipher(
7625 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7629 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7631 return test_mixed_auth_cipher_sgl(
7632 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7636 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7638 return test_mixed_auth_cipher_sgl(
7639 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7642 /** MIXED AUTH + CIPHER */
7645 test_auth_zuc_cipher_snow_test_case_1(void)
7647 return test_mixed_auth_cipher(
7648 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7652 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7654 return test_mixed_auth_cipher(
7655 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7659 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7661 return test_mixed_auth_cipher(
7662 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7666 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7668 return test_mixed_auth_cipher(
7669 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7673 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7675 return test_mixed_auth_cipher(
7676 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7680 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7682 return test_mixed_auth_cipher(
7683 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7687 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7689 return test_mixed_auth_cipher(
7690 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7694 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7696 return test_mixed_auth_cipher(
7697 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7701 test_auth_snow_cipher_zuc_test_case_1(void)
7703 return test_mixed_auth_cipher(
7704 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7708 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7710 return test_mixed_auth_cipher(
7711 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7715 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7717 return test_mixed_auth_cipher(
7718 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7722 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7724 return test_mixed_auth_cipher(
7725 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7729 test_auth_null_cipher_snow_test_case_1(void)
7731 return test_mixed_auth_cipher(
7732 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7736 test_verify_auth_null_cipher_snow_test_case_1(void)
7738 return test_mixed_auth_cipher(
7739 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7743 test_auth_null_cipher_zuc_test_case_1(void)
7745 return test_mixed_auth_cipher(
7746 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7750 test_verify_auth_null_cipher_zuc_test_case_1(void)
7752 return test_mixed_auth_cipher(
7753 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7757 test_auth_snow_cipher_null_test_case_1(void)
7759 return test_mixed_auth_cipher(
7760 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7764 test_verify_auth_snow_cipher_null_test_case_1(void)
7766 return test_mixed_auth_cipher(
7767 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7771 test_auth_zuc_cipher_null_test_case_1(void)
7773 return test_mixed_auth_cipher(
7774 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7778 test_verify_auth_zuc_cipher_null_test_case_1(void)
7780 return test_mixed_auth_cipher(
7781 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7785 test_auth_null_cipher_aes_ctr_test_case_1(void)
7787 return test_mixed_auth_cipher(
7788 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7792 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7794 return test_mixed_auth_cipher(
7795 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7799 test_auth_aes_cmac_cipher_null_test_case_1(void)
7801 return test_mixed_auth_cipher(
7802 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7806 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7808 return test_mixed_auth_cipher(
7809 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7812 /* ***** AEAD algorithm Tests ***** */
7815 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7816 enum rte_crypto_aead_operation op,
7817 const uint8_t *key, const uint8_t key_len,
7818 const uint16_t aad_len, const uint8_t auth_len,
7821 uint8_t aead_key[key_len];
7823 struct crypto_testsuite_params *ts_params = &testsuite_params;
7824 struct crypto_unittest_params *ut_params = &unittest_params;
7826 memcpy(aead_key, key, key_len);
7828 /* Setup AEAD Parameters */
7829 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7830 ut_params->aead_xform.next = NULL;
7831 ut_params->aead_xform.aead.algo = algo;
7832 ut_params->aead_xform.aead.op = op;
7833 ut_params->aead_xform.aead.key.data = aead_key;
7834 ut_params->aead_xform.aead.key.length = key_len;
7835 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7836 ut_params->aead_xform.aead.iv.length = iv_len;
7837 ut_params->aead_xform.aead.digest_length = auth_len;
7838 ut_params->aead_xform.aead.aad_length = aad_len;
7840 debug_hexdump(stdout, "key:", key, key_len);
7842 /* Create Crypto session*/
7843 ut_params->sess = rte_cryptodev_sym_session_create(
7844 ts_params->session_mpool);
7846 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7847 &ut_params->aead_xform,
7848 ts_params->session_priv_mpool);
7850 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7856 create_aead_xform(struct rte_crypto_op *op,
7857 enum rte_crypto_aead_algorithm algo,
7858 enum rte_crypto_aead_operation aead_op,
7859 uint8_t *key, const uint8_t key_len,
7860 const uint8_t aad_len, const uint8_t auth_len,
7863 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7864 "failed to allocate space for crypto transform");
7866 struct rte_crypto_sym_op *sym_op = op->sym;
7868 /* Setup AEAD Parameters */
7869 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7870 sym_op->xform->next = NULL;
7871 sym_op->xform->aead.algo = algo;
7872 sym_op->xform->aead.op = aead_op;
7873 sym_op->xform->aead.key.data = key;
7874 sym_op->xform->aead.key.length = key_len;
7875 sym_op->xform->aead.iv.offset = IV_OFFSET;
7876 sym_op->xform->aead.iv.length = iv_len;
7877 sym_op->xform->aead.digest_length = auth_len;
7878 sym_op->xform->aead.aad_length = aad_len;
7880 debug_hexdump(stdout, "key:", key, key_len);
7886 create_aead_operation(enum rte_crypto_aead_operation op,
7887 const struct aead_test_data *tdata)
7889 struct crypto_testsuite_params *ts_params = &testsuite_params;
7890 struct crypto_unittest_params *ut_params = &unittest_params;
7892 uint8_t *plaintext, *ciphertext;
7893 unsigned int aad_pad_len, plaintext_pad_len;
7895 /* Generate Crypto op data structure */
7896 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7897 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7898 TEST_ASSERT_NOT_NULL(ut_params->op,
7899 "Failed to allocate symmetric crypto operation struct");
7901 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7903 /* Append aad data */
7904 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7905 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7906 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7908 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7909 "no room to append aad");
7911 sym_op->aead.aad.phys_addr =
7912 rte_pktmbuf_iova(ut_params->ibuf);
7913 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7914 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7915 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7918 /* Append IV at the end of the crypto operation*/
7919 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7920 uint8_t *, IV_OFFSET);
7922 /* Copy IV 1 byte after the IV pointer, according to the API */
7923 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7924 debug_hexdump(stdout, "iv:", iv_ptr,
7927 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7928 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7930 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7931 "no room to append aad");
7933 sym_op->aead.aad.phys_addr =
7934 rte_pktmbuf_iova(ut_params->ibuf);
7935 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7936 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7939 /* Append IV at the end of the crypto operation*/
7940 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7941 uint8_t *, IV_OFFSET);
7943 if (tdata->iv.len == 0) {
7944 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7945 debug_hexdump(stdout, "iv:", iv_ptr,
7948 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7949 debug_hexdump(stdout, "iv:", iv_ptr,
7954 /* Append plaintext/ciphertext */
7955 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7956 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7957 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7959 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7961 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7962 debug_hexdump(stdout, "plaintext:", plaintext,
7963 tdata->plaintext.len);
7965 if (ut_params->obuf) {
7966 ciphertext = (uint8_t *)rte_pktmbuf_append(
7968 plaintext_pad_len + aad_pad_len);
7969 TEST_ASSERT_NOT_NULL(ciphertext,
7970 "no room to append ciphertext");
7972 memset(ciphertext + aad_pad_len, 0,
7973 tdata->ciphertext.len);
7976 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7977 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7979 TEST_ASSERT_NOT_NULL(ciphertext,
7980 "no room to append ciphertext");
7982 memcpy(ciphertext, tdata->ciphertext.data,
7983 tdata->ciphertext.len);
7984 debug_hexdump(stdout, "ciphertext:", ciphertext,
7985 tdata->ciphertext.len);
7987 if (ut_params->obuf) {
7988 plaintext = (uint8_t *)rte_pktmbuf_append(
7990 plaintext_pad_len + aad_pad_len);
7991 TEST_ASSERT_NOT_NULL(plaintext,
7992 "no room to append plaintext");
7994 memset(plaintext + aad_pad_len, 0,
7995 tdata->plaintext.len);
7999 /* Append digest data */
8000 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8001 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8002 ut_params->obuf ? ut_params->obuf :
8004 tdata->auth_tag.len);
8005 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8006 "no room to append digest");
8007 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8008 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8009 ut_params->obuf ? ut_params->obuf :
8014 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8015 ut_params->ibuf, tdata->auth_tag.len);
8016 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8017 "no room to append digest");
8018 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8020 plaintext_pad_len + aad_pad_len);
8022 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8023 tdata->auth_tag.len);
8024 debug_hexdump(stdout, "digest:",
8025 sym_op->aead.digest.data,
8026 tdata->auth_tag.len);
8029 sym_op->aead.data.length = tdata->plaintext.len;
8030 sym_op->aead.data.offset = aad_pad_len;
8036 test_authenticated_encryption(const struct aead_test_data *tdata)
8038 struct crypto_testsuite_params *ts_params = &testsuite_params;
8039 struct crypto_unittest_params *ut_params = &unittest_params;
8042 uint8_t *ciphertext, *auth_tag;
8043 uint16_t plaintext_pad_len;
8045 struct rte_cryptodev_info dev_info;
8047 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8048 uint64_t feat_flags = dev_info.feature_flags;
8050 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8051 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8052 printf("Device doesn't support RAW data-path APIs.\n");
8053 return TEST_SKIPPED;
8056 /* Verify the capabilities */
8057 struct rte_cryptodev_sym_capability_idx cap_idx;
8058 const struct rte_cryptodev_symmetric_capability *capability;
8059 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8060 cap_idx.algo.aead = tdata->algo;
8061 capability = rte_cryptodev_sym_capability_get(
8062 ts_params->valid_devs[0], &cap_idx);
8063 if (capability == NULL)
8064 return TEST_SKIPPED;
8065 if (rte_cryptodev_sym_capability_check_aead(
8066 capability, tdata->key.len, tdata->auth_tag.len,
8067 tdata->aad.len, tdata->iv.len))
8068 return TEST_SKIPPED;
8070 /* Create AEAD session */
8071 retval = create_aead_session(ts_params->valid_devs[0],
8073 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8074 tdata->key.data, tdata->key.len,
8075 tdata->aad.len, tdata->auth_tag.len,
8080 if (tdata->aad.len > MBUF_SIZE) {
8081 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8082 /* Populate full size of add data */
8083 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8084 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8086 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8088 /* clear mbuf payload */
8089 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8090 rte_pktmbuf_tailroom(ut_params->ibuf));
8092 /* Create AEAD operation */
8093 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8097 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8099 ut_params->op->sym->m_src = ut_params->ibuf;
8101 /* Process crypto operation */
8102 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8103 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8104 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8105 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8106 ut_params->op, 0, 0, 0, 0);
8108 TEST_ASSERT_NOT_NULL(
8109 process_crypto_request(ts_params->valid_devs[0],
8110 ut_params->op), "failed to process sym crypto op");
8112 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8113 "crypto op processing failed");
8115 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8117 if (ut_params->op->sym->m_dst) {
8118 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8120 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8121 uint8_t *, plaintext_pad_len);
8123 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8125 ut_params->op->sym->cipher.data.offset);
8126 auth_tag = ciphertext + plaintext_pad_len;
8129 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8130 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8133 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8135 tdata->ciphertext.data,
8136 tdata->ciphertext.len,
8137 "Ciphertext data not as expected");
8139 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8141 tdata->auth_tag.data,
8142 tdata->auth_tag.len,
8143 "Generated auth tag not as expected");
8149 #ifdef RTE_LIB_SECURITY
8151 security_proto_supported(enum rte_security_session_action_type action,
8152 enum rte_security_session_protocol proto)
8154 struct crypto_testsuite_params *ts_params = &testsuite_params;
8156 const struct rte_security_capability *capabilities;
8157 const struct rte_security_capability *capability;
8160 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8161 rte_cryptodev_get_sec_ctx(
8162 ts_params->valid_devs[0]);
8165 capabilities = rte_security_capabilities_get(ctx);
8167 if (capabilities == NULL)
8170 while ((capability = &capabilities[i++])->action !=
8171 RTE_SECURITY_ACTION_TYPE_NONE) {
8172 if (capability->action == action &&
8173 capability->protocol == proto)
8180 /* Basic algorithm run function for async inplace mode.
8181 * Creates a session from input parameters and runs one operation
8182 * on input_vec. Checks the output of the crypto operation against
8185 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8186 enum rte_crypto_auth_operation opa,
8187 const uint8_t *input_vec, unsigned int input_vec_len,
8188 const uint8_t *output_vec,
8189 unsigned int output_vec_len,
8190 enum rte_crypto_cipher_algorithm cipher_alg,
8191 const uint8_t *cipher_key, uint32_t cipher_key_len,
8192 enum rte_crypto_auth_algorithm auth_alg,
8193 const uint8_t *auth_key, uint32_t auth_key_len,
8194 uint8_t bearer, enum rte_security_pdcp_domain domain,
8195 uint8_t packet_direction, uint8_t sn_size,
8196 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8198 struct crypto_testsuite_params *ts_params = &testsuite_params;
8199 struct crypto_unittest_params *ut_params = &unittest_params;
8201 int ret = TEST_SUCCESS;
8202 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8203 rte_cryptodev_get_sec_ctx(
8204 ts_params->valid_devs[0]);
8206 /* Verify the capabilities */
8207 struct rte_security_capability_idx sec_cap_idx;
8209 sec_cap_idx.action = ut_params->type;
8210 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8211 sec_cap_idx.pdcp.domain = domain;
8212 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8213 return TEST_SKIPPED;
8215 /* Generate test mbuf data */
8216 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8218 /* clear mbuf payload */
8219 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8220 rte_pktmbuf_tailroom(ut_params->ibuf));
8222 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8224 memcpy(plaintext, input_vec, input_vec_len);
8226 /* Out of place support */
8229 * For out-op-place we need to alloc another mbuf
8231 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8232 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8235 /* Setup Cipher Parameters */
8236 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8237 ut_params->cipher_xform.cipher.algo = cipher_alg;
8238 ut_params->cipher_xform.cipher.op = opc;
8239 ut_params->cipher_xform.cipher.key.data = cipher_key;
8240 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8241 ut_params->cipher_xform.cipher.iv.length =
8242 packet_direction ? 4 : 0;
8243 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8245 /* Setup HMAC Parameters if ICV header is required */
8246 if (auth_alg != 0) {
8247 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8248 ut_params->auth_xform.next = NULL;
8249 ut_params->auth_xform.auth.algo = auth_alg;
8250 ut_params->auth_xform.auth.op = opa;
8251 ut_params->auth_xform.auth.key.data = auth_key;
8252 ut_params->auth_xform.auth.key.length = auth_key_len;
8254 ut_params->cipher_xform.next = &ut_params->auth_xform;
8256 ut_params->cipher_xform.next = NULL;
8259 struct rte_security_session_conf sess_conf = {
8260 .action_type = ut_params->type,
8261 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8265 .pkt_dir = packet_direction,
8267 .hfn = packet_direction ? 0 : hfn,
8269 * hfn can be set as pdcp_test_hfn[i]
8270 * if hfn_ovrd is not set. Here, PDCP
8271 * packet direction is just used to
8272 * run half of the cases with session
8273 * HFN and other half with per packet
8276 .hfn_threshold = hfn_threshold,
8277 .hfn_ovrd = packet_direction ? 1 : 0,
8278 .sdap_enabled = sdap,
8280 .crypto_xform = &ut_params->cipher_xform
8283 /* Create security session */
8284 ut_params->sec_session = rte_security_session_create(ctx,
8285 &sess_conf, ts_params->session_mpool,
8286 ts_params->session_priv_mpool);
8288 if (!ut_params->sec_session) {
8289 printf("TestCase %s()-%d line %d failed %s: ",
8290 __func__, i, __LINE__, "Failed to allocate session");
8295 /* Generate crypto op data structure */
8296 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8297 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8298 if (!ut_params->op) {
8299 printf("TestCase %s()-%d line %d failed %s: ",
8300 __func__, i, __LINE__,
8301 "Failed to allocate symmetric crypto operation struct");
8306 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8307 uint32_t *, IV_OFFSET);
8308 *per_pkt_hfn = packet_direction ? hfn : 0;
8310 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8312 /* set crypto operation source mbuf */
8313 ut_params->op->sym->m_src = ut_params->ibuf;
8315 ut_params->op->sym->m_dst = ut_params->obuf;
8317 /* Process crypto operation */
8318 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8320 printf("TestCase %s()-%d line %d failed %s: ",
8321 __func__, i, __LINE__,
8322 "failed to process sym crypto op");
8327 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8328 printf("TestCase %s()-%d line %d failed %s: ",
8329 __func__, i, __LINE__, "crypto op processing failed");
8335 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8338 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8342 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8343 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8344 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8345 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8351 rte_crypto_op_free(ut_params->op);
8352 ut_params->op = NULL;
8354 if (ut_params->sec_session)
8355 rte_security_session_destroy(ctx, ut_params->sec_session);
8356 ut_params->sec_session = NULL;
8358 rte_pktmbuf_free(ut_params->ibuf);
8359 ut_params->ibuf = NULL;
8361 rte_pktmbuf_free(ut_params->obuf);
8362 ut_params->obuf = NULL;
8369 test_pdcp_proto_SGL(int i, int oop,
8370 enum rte_crypto_cipher_operation opc,
8371 enum rte_crypto_auth_operation opa,
8373 unsigned int input_vec_len,
8374 uint8_t *output_vec,
8375 unsigned int output_vec_len,
8377 uint32_t fragsz_oop)
8379 struct crypto_testsuite_params *ts_params = &testsuite_params;
8380 struct crypto_unittest_params *ut_params = &unittest_params;
8382 struct rte_mbuf *buf, *buf_oop = NULL;
8383 int ret = TEST_SUCCESS;
8387 unsigned int trn_data = 0;
8388 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8389 rte_cryptodev_get_sec_ctx(
8390 ts_params->valid_devs[0]);
8392 /* Verify the capabilities */
8393 struct rte_security_capability_idx sec_cap_idx;
8395 sec_cap_idx.action = ut_params->type;
8396 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8397 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8398 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8399 return TEST_SKIPPED;
8401 if (fragsz > input_vec_len)
8402 fragsz = input_vec_len;
8404 uint16_t plaintext_len = fragsz;
8405 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8407 if (fragsz_oop > output_vec_len)
8408 frag_size_oop = output_vec_len;
8411 if (input_vec_len % fragsz != 0) {
8412 if (input_vec_len / fragsz + 1 > 16)
8414 } else if (input_vec_len / fragsz > 16)
8417 /* Out of place support */
8420 * For out-op-place we need to alloc another mbuf
8422 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8423 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8424 buf_oop = ut_params->obuf;
8427 /* Generate test mbuf data */
8428 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8430 /* clear mbuf payload */
8431 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8432 rte_pktmbuf_tailroom(ut_params->ibuf));
8434 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8436 memcpy(plaintext, input_vec, plaintext_len);
8437 trn_data += plaintext_len;
8439 buf = ut_params->ibuf;
8442 * Loop until no more fragments
8445 while (trn_data < input_vec_len) {
8447 to_trn = (input_vec_len - trn_data < fragsz) ?
8448 (input_vec_len - trn_data) : fragsz;
8450 to_trn_tbl[ecx++] = to_trn;
8452 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8455 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8456 rte_pktmbuf_tailroom(buf));
8459 if (oop && !fragsz_oop) {
8461 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8462 buf_oop = buf_oop->next;
8463 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8464 0, rte_pktmbuf_tailroom(buf_oop));
8465 rte_pktmbuf_append(buf_oop, to_trn);
8468 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8471 memcpy(plaintext, input_vec + trn_data, to_trn);
8475 ut_params->ibuf->nb_segs = segs;
8478 if (fragsz_oop && oop) {
8482 trn_data = frag_size_oop;
8483 while (trn_data < output_vec_len) {
8486 (output_vec_len - trn_data <
8488 (output_vec_len - trn_data) :
8491 to_trn_tbl[ecx++] = to_trn;
8494 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8495 buf_oop = buf_oop->next;
8496 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8497 0, rte_pktmbuf_tailroom(buf_oop));
8498 rte_pktmbuf_append(buf_oop, to_trn);
8502 ut_params->obuf->nb_segs = segs;
8505 /* Setup Cipher Parameters */
8506 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8507 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8508 ut_params->cipher_xform.cipher.op = opc;
8509 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8510 ut_params->cipher_xform.cipher.key.length =
8511 pdcp_test_params[i].cipher_key_len;
8512 ut_params->cipher_xform.cipher.iv.length = 0;
8514 /* Setup HMAC Parameters if ICV header is required */
8515 if (pdcp_test_params[i].auth_alg != 0) {
8516 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8517 ut_params->auth_xform.next = NULL;
8518 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8519 ut_params->auth_xform.auth.op = opa;
8520 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8521 ut_params->auth_xform.auth.key.length =
8522 pdcp_test_params[i].auth_key_len;
8524 ut_params->cipher_xform.next = &ut_params->auth_xform;
8526 ut_params->cipher_xform.next = NULL;
8529 struct rte_security_session_conf sess_conf = {
8530 .action_type = ut_params->type,
8531 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8533 .bearer = pdcp_test_bearer[i],
8534 .domain = pdcp_test_params[i].domain,
8535 .pkt_dir = pdcp_test_packet_direction[i],
8536 .sn_size = pdcp_test_data_sn_size[i],
8537 .hfn = pdcp_test_hfn[i],
8538 .hfn_threshold = pdcp_test_hfn_threshold[i],
8541 .crypto_xform = &ut_params->cipher_xform
8544 /* Create security session */
8545 ut_params->sec_session = rte_security_session_create(ctx,
8546 &sess_conf, ts_params->session_mpool,
8547 ts_params->session_priv_mpool);
8549 if (!ut_params->sec_session) {
8550 printf("TestCase %s()-%d line %d failed %s: ",
8551 __func__, i, __LINE__, "Failed to allocate session");
8556 /* Generate crypto op data structure */
8557 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8558 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8559 if (!ut_params->op) {
8560 printf("TestCase %s()-%d line %d failed %s: ",
8561 __func__, i, __LINE__,
8562 "Failed to allocate symmetric crypto operation struct");
8567 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8569 /* set crypto operation source mbuf */
8570 ut_params->op->sym->m_src = ut_params->ibuf;
8572 ut_params->op->sym->m_dst = ut_params->obuf;
8574 /* Process crypto operation */
8575 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8577 printf("TestCase %s()-%d line %d failed %s: ",
8578 __func__, i, __LINE__,
8579 "failed to process sym crypto op");
8584 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8585 printf("TestCase %s()-%d line %d failed %s: ",
8586 __func__, i, __LINE__, "crypto op processing failed");
8592 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8595 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8599 fragsz = frag_size_oop;
8600 if (memcmp(ciphertext, output_vec, fragsz)) {
8601 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8602 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8603 rte_hexdump(stdout, "reference", output_vec, fragsz);
8608 buf = ut_params->op->sym->m_src->next;
8610 buf = ut_params->op->sym->m_dst->next;
8612 unsigned int off = fragsz;
8616 ciphertext = rte_pktmbuf_mtod(buf,
8618 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8619 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8620 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8621 rte_hexdump(stdout, "reference", output_vec + off,
8626 off += to_trn_tbl[ecx++];
8630 rte_crypto_op_free(ut_params->op);
8631 ut_params->op = NULL;
8633 if (ut_params->sec_session)
8634 rte_security_session_destroy(ctx, ut_params->sec_session);
8635 ut_params->sec_session = NULL;
8637 rte_pktmbuf_free(ut_params->ibuf);
8638 ut_params->ibuf = NULL;
8640 rte_pktmbuf_free(ut_params->obuf);
8641 ut_params->obuf = NULL;
8648 test_pdcp_proto_cplane_encap(int i)
8650 return test_pdcp_proto(
8651 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8652 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8653 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8654 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8655 pdcp_test_params[i].cipher_key_len,
8656 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8657 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8658 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8659 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8660 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8664 test_pdcp_proto_uplane_encap(int i)
8666 return test_pdcp_proto(
8667 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8668 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8669 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8670 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8671 pdcp_test_params[i].cipher_key_len,
8672 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8673 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8674 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8675 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8676 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8680 test_pdcp_proto_uplane_encap_with_int(int i)
8682 return test_pdcp_proto(
8683 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8684 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8685 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8686 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8687 pdcp_test_params[i].cipher_key_len,
8688 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8689 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8690 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8691 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8692 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8696 test_pdcp_proto_cplane_decap(int i)
8698 return test_pdcp_proto(
8699 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8700 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8701 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8702 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8703 pdcp_test_params[i].cipher_key_len,
8704 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8705 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8706 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8707 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8708 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8712 test_pdcp_proto_uplane_decap(int i)
8714 return test_pdcp_proto(
8715 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8716 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8717 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8718 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8719 pdcp_test_params[i].cipher_key_len,
8720 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8721 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8722 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8723 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8724 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8728 test_pdcp_proto_uplane_decap_with_int(int i)
8730 return test_pdcp_proto(
8731 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8732 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8733 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8734 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8735 pdcp_test_params[i].cipher_key_len,
8736 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8737 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8738 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8739 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8740 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8744 test_PDCP_PROTO_SGL_in_place_32B(void)
8746 /* i can be used for running any PDCP case
8747 * In this case it is uplane 12-bit AES-SNOW DL encap
8749 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8750 return test_pdcp_proto_SGL(i, IN_PLACE,
8751 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8752 RTE_CRYPTO_AUTH_OP_GENERATE,
8753 pdcp_test_data_in[i],
8754 pdcp_test_data_in_len[i],
8755 pdcp_test_data_out[i],
8756 pdcp_test_data_in_len[i]+4,
8760 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8762 /* i can be used for running any PDCP case
8763 * In this case it is uplane 18-bit NULL-NULL DL encap
8765 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8766 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8767 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8768 RTE_CRYPTO_AUTH_OP_GENERATE,
8769 pdcp_test_data_in[i],
8770 pdcp_test_data_in_len[i],
8771 pdcp_test_data_out[i],
8772 pdcp_test_data_in_len[i]+4,
8776 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8778 /* i can be used for running any PDCP case
8779 * In this case it is uplane 18-bit AES DL encap
8781 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8783 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8784 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8785 RTE_CRYPTO_AUTH_OP_GENERATE,
8786 pdcp_test_data_in[i],
8787 pdcp_test_data_in_len[i],
8788 pdcp_test_data_out[i],
8789 pdcp_test_data_in_len[i],
8793 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8795 /* i can be used for running any PDCP case
8796 * In this case it is cplane 12-bit AES-ZUC DL encap
8798 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8799 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8800 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8801 RTE_CRYPTO_AUTH_OP_GENERATE,
8802 pdcp_test_data_in[i],
8803 pdcp_test_data_in_len[i],
8804 pdcp_test_data_out[i],
8805 pdcp_test_data_in_len[i]+4,
8810 test_PDCP_SDAP_PROTO_encap_all(void)
8812 int i = 0, size = 0;
8813 int err, all_err = TEST_SUCCESS;
8814 const struct pdcp_sdap_test *cur_test;
8816 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8818 for (i = 0; i < size; i++) {
8819 cur_test = &list_pdcp_sdap_tests[i];
8820 err = test_pdcp_proto(
8821 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8822 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8823 cur_test->in_len, cur_test->data_out,
8824 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8825 cur_test->param.cipher_alg, cur_test->cipher_key,
8826 cur_test->param.cipher_key_len,
8827 cur_test->param.auth_alg,
8828 cur_test->auth_key, cur_test->param.auth_key_len,
8829 cur_test->bearer, cur_test->param.domain,
8830 cur_test->packet_direction, cur_test->sn_size,
8832 cur_test->hfn_threshold, SDAP_ENABLED);
8834 printf("\t%d) %s: Encapsulation failed\n",
8836 cur_test->param.name);
8839 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8840 cur_test->param.name);
8846 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8848 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8852 test_PDCP_SDAP_PROTO_decap_all(void)
8854 int i = 0, size = 0;
8855 int err, all_err = TEST_SUCCESS;
8856 const struct pdcp_sdap_test *cur_test;
8858 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8860 for (i = 0; i < size; i++) {
8861 cur_test = &list_pdcp_sdap_tests[i];
8862 err = test_pdcp_proto(
8863 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8864 RTE_CRYPTO_AUTH_OP_VERIFY,
8866 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8867 cur_test->data_in, cur_test->in_len,
8868 cur_test->param.cipher_alg,
8869 cur_test->cipher_key, cur_test->param.cipher_key_len,
8870 cur_test->param.auth_alg, cur_test->auth_key,
8871 cur_test->param.auth_key_len, cur_test->bearer,
8872 cur_test->param.domain, cur_test->packet_direction,
8873 cur_test->sn_size, cur_test->hfn,
8874 cur_test->hfn_threshold, SDAP_ENABLED);
8876 printf("\t%d) %s: Decapsulation failed\n",
8878 cur_test->param.name);
8881 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8882 cur_test->param.name);
8888 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8890 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8894 test_PDCP_PROTO_all(void)
8896 struct crypto_testsuite_params *ts_params = &testsuite_params;
8897 struct crypto_unittest_params *ut_params = &unittest_params;
8898 struct rte_cryptodev_info dev_info;
8901 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8902 uint64_t feat_flags = dev_info.feature_flags;
8904 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8905 return TEST_SKIPPED;
8907 /* Set action type */
8908 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8909 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8912 if (security_proto_supported(ut_params->type,
8913 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8914 return TEST_SKIPPED;
8916 status = test_PDCP_PROTO_cplane_encap_all();
8917 status += test_PDCP_PROTO_cplane_decap_all();
8918 status += test_PDCP_PROTO_uplane_encap_all();
8919 status += test_PDCP_PROTO_uplane_decap_all();
8920 status += test_PDCP_PROTO_SGL_in_place_32B();
8921 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8922 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8923 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8924 status += test_PDCP_SDAP_PROTO_encap_all();
8925 status += test_PDCP_SDAP_PROTO_decap_all();
8930 return TEST_SUCCESS;
8934 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8936 struct crypto_testsuite_params *ts_params = &testsuite_params;
8937 struct crypto_unittest_params *ut_params = &unittest_params;
8938 uint8_t *plaintext, *ciphertext;
8940 int32_t cipher_len, crc_len;
8941 uint32_t crc_data_len;
8942 int ret = TEST_SUCCESS;
8944 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8945 rte_cryptodev_get_sec_ctx(
8946 ts_params->valid_devs[0]);
8948 /* Verify the capabilities */
8949 struct rte_security_capability_idx sec_cap_idx;
8950 const struct rte_security_capability *sec_cap;
8951 const struct rte_cryptodev_capabilities *crypto_cap;
8952 const struct rte_cryptodev_symmetric_capability *sym_cap;
8955 sec_cap_idx.action = ut_params->type;
8956 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8957 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8959 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8960 if (sec_cap == NULL)
8961 return TEST_SKIPPED;
8963 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8964 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8965 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8966 crypto_cap->sym.xform_type ==
8967 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8968 crypto_cap->sym.cipher.algo ==
8969 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8970 sym_cap = &crypto_cap->sym;
8971 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8978 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8979 return TEST_SKIPPED;
8981 /* Setup source mbuf payload */
8982 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8983 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8984 rte_pktmbuf_tailroom(ut_params->ibuf));
8986 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8987 d_td->ciphertext.len);
8989 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8991 /* Setup cipher session parameters */
8992 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8993 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8994 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8995 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8996 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8997 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8998 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8999 ut_params->cipher_xform.next = NULL;
9001 /* Setup DOCSIS session parameters */
9002 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9004 struct rte_security_session_conf sess_conf = {
9005 .action_type = ut_params->type,
9006 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9007 .docsis = ut_params->docsis_xform,
9008 .crypto_xform = &ut_params->cipher_xform,
9011 /* Create security session */
9012 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9013 ts_params->session_mpool,
9014 ts_params->session_priv_mpool);
9016 if (!ut_params->sec_session) {
9017 printf("TestCase %s(%d) line %d: %s\n",
9018 __func__, i, __LINE__, "failed to allocate session");
9023 /* Generate crypto op data structure */
9024 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9025 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9026 if (!ut_params->op) {
9027 printf("TestCase %s(%d) line %d: %s\n",
9028 __func__, i, __LINE__,
9029 "failed to allocate symmetric crypto operation");
9034 /* Setup CRC operation parameters */
9035 crc_len = d_td->ciphertext.no_crc == false ?
9036 (d_td->ciphertext.len -
9037 d_td->ciphertext.crc_offset -
9038 RTE_ETHER_CRC_LEN) :
9040 crc_len = crc_len > 0 ? crc_len : 0;
9041 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9042 ut_params->op->sym->auth.data.length = crc_len;
9043 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9045 /* Setup cipher operation parameters */
9046 cipher_len = d_td->ciphertext.no_cipher == false ?
9047 (d_td->ciphertext.len -
9048 d_td->ciphertext.cipher_offset) :
9050 cipher_len = cipher_len > 0 ? cipher_len : 0;
9051 ut_params->op->sym->cipher.data.length = cipher_len;
9052 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9054 /* Setup cipher IV */
9055 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9056 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9058 /* Attach session to operation */
9059 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9061 /* Set crypto operation mbufs */
9062 ut_params->op->sym->m_src = ut_params->ibuf;
9063 ut_params->op->sym->m_dst = NULL;
9065 /* Process crypto operation */
9066 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9068 printf("TestCase %s(%d) line %d: %s\n",
9069 __func__, i, __LINE__,
9070 "failed to process security crypto op");
9075 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9076 printf("TestCase %s(%d) line %d: %s\n",
9077 __func__, i, __LINE__, "crypto op processing failed");
9082 /* Validate plaintext */
9083 plaintext = ciphertext;
9085 if (memcmp(plaintext, d_td->plaintext.data,
9086 d_td->plaintext.len - crc_data_len)) {
9087 printf("TestCase %s(%d) line %d: %s\n",
9088 __func__, i, __LINE__, "plaintext not as expected\n");
9089 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9090 d_td->plaintext.len);
9091 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9097 rte_crypto_op_free(ut_params->op);
9098 ut_params->op = NULL;
9100 if (ut_params->sec_session)
9101 rte_security_session_destroy(ctx, ut_params->sec_session);
9102 ut_params->sec_session = NULL;
9104 rte_pktmbuf_free(ut_params->ibuf);
9105 ut_params->ibuf = NULL;
9111 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9113 struct crypto_testsuite_params *ts_params = &testsuite_params;
9114 struct crypto_unittest_params *ut_params = &unittest_params;
9115 uint8_t *plaintext, *ciphertext;
9117 int32_t cipher_len, crc_len;
9118 int ret = TEST_SUCCESS;
9120 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9121 rte_cryptodev_get_sec_ctx(
9122 ts_params->valid_devs[0]);
9124 /* Verify the capabilities */
9125 struct rte_security_capability_idx sec_cap_idx;
9126 const struct rte_security_capability *sec_cap;
9127 const struct rte_cryptodev_capabilities *crypto_cap;
9128 const struct rte_cryptodev_symmetric_capability *sym_cap;
9131 sec_cap_idx.action = ut_params->type;
9132 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9133 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9135 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9136 if (sec_cap == NULL)
9137 return TEST_SKIPPED;
9139 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9140 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9141 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9142 crypto_cap->sym.xform_type ==
9143 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9144 crypto_cap->sym.cipher.algo ==
9145 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9146 sym_cap = &crypto_cap->sym;
9147 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9154 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9155 return TEST_SKIPPED;
9157 /* Setup source mbuf payload */
9158 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9159 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9160 rte_pktmbuf_tailroom(ut_params->ibuf));
9162 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9163 d_td->plaintext.len);
9165 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9167 /* Setup cipher session parameters */
9168 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9169 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9170 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9171 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9172 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9173 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9174 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9175 ut_params->cipher_xform.next = NULL;
9177 /* Setup DOCSIS session parameters */
9178 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9180 struct rte_security_session_conf sess_conf = {
9181 .action_type = ut_params->type,
9182 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9183 .docsis = ut_params->docsis_xform,
9184 .crypto_xform = &ut_params->cipher_xform,
9187 /* Create security session */
9188 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9189 ts_params->session_mpool,
9190 ts_params->session_priv_mpool);
9192 if (!ut_params->sec_session) {
9193 printf("TestCase %s(%d) line %d: %s\n",
9194 __func__, i, __LINE__, "failed to allocate session");
9199 /* Generate crypto op data structure */
9200 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9201 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9202 if (!ut_params->op) {
9203 printf("TestCase %s(%d) line %d: %s\n",
9204 __func__, i, __LINE__,
9205 "failed to allocate security crypto operation");
9210 /* Setup CRC operation parameters */
9211 crc_len = d_td->plaintext.no_crc == false ?
9212 (d_td->plaintext.len -
9213 d_td->plaintext.crc_offset -
9214 RTE_ETHER_CRC_LEN) :
9216 crc_len = crc_len > 0 ? crc_len : 0;
9217 ut_params->op->sym->auth.data.length = crc_len;
9218 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9220 /* Setup cipher operation parameters */
9221 cipher_len = d_td->plaintext.no_cipher == false ?
9222 (d_td->plaintext.len -
9223 d_td->plaintext.cipher_offset) :
9225 cipher_len = cipher_len > 0 ? cipher_len : 0;
9226 ut_params->op->sym->cipher.data.length = cipher_len;
9227 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9229 /* Setup cipher IV */
9230 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9231 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9233 /* Attach session to operation */
9234 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9236 /* Set crypto operation mbufs */
9237 ut_params->op->sym->m_src = ut_params->ibuf;
9238 ut_params->op->sym->m_dst = NULL;
9240 /* Process crypto operation */
9241 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9243 printf("TestCase %s(%d) line %d: %s\n",
9244 __func__, i, __LINE__,
9245 "failed to process security crypto op");
9250 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9251 printf("TestCase %s(%d) line %d: %s\n",
9252 __func__, i, __LINE__, "crypto op processing failed");
9257 /* Validate ciphertext */
9258 ciphertext = plaintext;
9260 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9261 printf("TestCase %s(%d) line %d: %s\n",
9262 __func__, i, __LINE__, "ciphertext not as expected\n");
9263 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9264 d_td->ciphertext.len);
9265 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9271 rte_crypto_op_free(ut_params->op);
9272 ut_params->op = NULL;
9274 if (ut_params->sec_session)
9275 rte_security_session_destroy(ctx, ut_params->sec_session);
9276 ut_params->sec_session = NULL;
9278 rte_pktmbuf_free(ut_params->ibuf);
9279 ut_params->ibuf = NULL;
9284 #define TEST_DOCSIS_COUNT(func) do { \
9286 if (ret == TEST_SUCCESS) { \
9287 printf("\t%2d)", n++); \
9288 printf("+++++ PASSED:" #func"\n"); \
9290 } else if (ret == TEST_SKIPPED) { \
9291 printf("\t%2d)", n++); \
9292 printf("~~~~~ SKIPPED:" #func"\n"); \
9295 printf("\t%2d)", n++); \
9296 printf("----- FAILED:" #func"\n"); \
9302 test_DOCSIS_PROTO_uplink_all(void)
9304 int p = 0, s = 0, f = 0, n = 0;
9306 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9307 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9308 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9309 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9310 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9311 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9312 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9313 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9314 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9315 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9316 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9317 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9318 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9319 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9320 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9321 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9322 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9323 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9324 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9325 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9326 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9327 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9328 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9329 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9330 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9331 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9334 printf("## %s: %d passed out of %d (%d skipped)\n",
9341 test_DOCSIS_PROTO_downlink_all(void)
9343 int p = 0, s = 0, f = 0, n = 0;
9345 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9346 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9347 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9348 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9349 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9350 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9351 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9352 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9353 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9354 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9355 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9356 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9357 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9358 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9359 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9360 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9361 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9362 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9363 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9364 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9365 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9366 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9367 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9368 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9369 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9370 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9373 printf("## %s: %d passed out of %d (%d skipped)\n",
9380 test_DOCSIS_PROTO_all(void)
9382 struct crypto_testsuite_params *ts_params = &testsuite_params;
9383 struct crypto_unittest_params *ut_params = &unittest_params;
9384 struct rte_cryptodev_info dev_info;
9387 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9388 uint64_t feat_flags = dev_info.feature_flags;
9390 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9391 return TEST_SKIPPED;
9393 /* Set action type */
9394 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9395 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9398 if (security_proto_supported(ut_params->type,
9399 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9400 return TEST_SKIPPED;
9402 status = test_DOCSIS_PROTO_uplink_all();
9403 status += test_DOCSIS_PROTO_downlink_all();
9408 return TEST_SUCCESS;
9413 test_AES_GCM_authenticated_encryption_test_case_1(void)
9415 return test_authenticated_encryption(&gcm_test_case_1);
9419 test_AES_GCM_authenticated_encryption_test_case_2(void)
9421 return test_authenticated_encryption(&gcm_test_case_2);
9425 test_AES_GCM_authenticated_encryption_test_case_3(void)
9427 return test_authenticated_encryption(&gcm_test_case_3);
9431 test_AES_GCM_authenticated_encryption_test_case_4(void)
9433 return test_authenticated_encryption(&gcm_test_case_4);
9437 test_AES_GCM_authenticated_encryption_test_case_5(void)
9439 return test_authenticated_encryption(&gcm_test_case_5);
9443 test_AES_GCM_authenticated_encryption_test_case_6(void)
9445 return test_authenticated_encryption(&gcm_test_case_6);
9449 test_AES_GCM_authenticated_encryption_test_case_7(void)
9451 return test_authenticated_encryption(&gcm_test_case_7);
9455 test_AES_GCM_authenticated_encryption_test_case_8(void)
9457 return test_authenticated_encryption(&gcm_test_case_8);
9461 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9463 return test_authenticated_encryption(&gcm_J0_test_case_1);
9467 test_AES_GCM_auth_encryption_test_case_192_1(void)
9469 return test_authenticated_encryption(&gcm_test_case_192_1);
9473 test_AES_GCM_auth_encryption_test_case_192_2(void)
9475 return test_authenticated_encryption(&gcm_test_case_192_2);
9479 test_AES_GCM_auth_encryption_test_case_192_3(void)
9481 return test_authenticated_encryption(&gcm_test_case_192_3);
9485 test_AES_GCM_auth_encryption_test_case_192_4(void)
9487 return test_authenticated_encryption(&gcm_test_case_192_4);
9491 test_AES_GCM_auth_encryption_test_case_192_5(void)
9493 return test_authenticated_encryption(&gcm_test_case_192_5);
9497 test_AES_GCM_auth_encryption_test_case_192_6(void)
9499 return test_authenticated_encryption(&gcm_test_case_192_6);
9503 test_AES_GCM_auth_encryption_test_case_192_7(void)
9505 return test_authenticated_encryption(&gcm_test_case_192_7);
9509 test_AES_GCM_auth_encryption_test_case_256_1(void)
9511 return test_authenticated_encryption(&gcm_test_case_256_1);
9515 test_AES_GCM_auth_encryption_test_case_256_2(void)
9517 return test_authenticated_encryption(&gcm_test_case_256_2);
9521 test_AES_GCM_auth_encryption_test_case_256_3(void)
9523 return test_authenticated_encryption(&gcm_test_case_256_3);
9527 test_AES_GCM_auth_encryption_test_case_256_4(void)
9529 return test_authenticated_encryption(&gcm_test_case_256_4);
9533 test_AES_GCM_auth_encryption_test_case_256_5(void)
9535 return test_authenticated_encryption(&gcm_test_case_256_5);
9539 test_AES_GCM_auth_encryption_test_case_256_6(void)
9541 return test_authenticated_encryption(&gcm_test_case_256_6);
9545 test_AES_GCM_auth_encryption_test_case_256_7(void)
9547 return test_authenticated_encryption(&gcm_test_case_256_7);
9551 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9553 return test_authenticated_encryption(&gcm_test_case_aad_1);
9557 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9559 return test_authenticated_encryption(&gcm_test_case_aad_2);
9563 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9565 struct aead_test_data tdata;
9568 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9569 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9570 tdata.iv.data[0] += 1;
9571 res = test_authenticated_encryption(&tdata);
9572 if (res == TEST_SKIPPED)
9574 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9575 return TEST_SUCCESS;
9579 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9581 struct aead_test_data tdata;
9584 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9585 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9586 tdata.plaintext.data[0] += 1;
9587 res = test_authenticated_encryption(&tdata);
9588 if (res == TEST_SKIPPED)
9590 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9591 return TEST_SUCCESS;
9595 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9597 struct aead_test_data tdata;
9600 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9601 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9602 tdata.ciphertext.data[0] += 1;
9603 res = test_authenticated_encryption(&tdata);
9604 if (res == TEST_SKIPPED)
9606 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9607 return TEST_SUCCESS;
9611 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9613 struct aead_test_data tdata;
9616 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9617 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9619 res = test_authenticated_encryption(&tdata);
9620 if (res == TEST_SKIPPED)
9622 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9623 return TEST_SUCCESS;
9627 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9629 struct aead_test_data tdata;
9630 uint8_t aad[gcm_test_case_7.aad.len];
9633 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9634 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9635 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9637 tdata.aad.data = aad;
9638 res = test_authenticated_encryption(&tdata);
9639 if (res == TEST_SKIPPED)
9641 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9642 return TEST_SUCCESS;
9646 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9648 struct aead_test_data tdata;
9651 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9652 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9653 tdata.auth_tag.data[0] += 1;
9654 res = test_authenticated_encryption(&tdata);
9655 if (res == TEST_SKIPPED)
9657 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9658 return TEST_SUCCESS;
9662 test_authenticated_decryption(const struct aead_test_data *tdata)
9664 struct crypto_testsuite_params *ts_params = &testsuite_params;
9665 struct crypto_unittest_params *ut_params = &unittest_params;
9670 struct rte_cryptodev_info dev_info;
9672 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9673 uint64_t feat_flags = dev_info.feature_flags;
9675 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9676 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9677 printf("Device doesn't support RAW data-path APIs.\n");
9678 return TEST_SKIPPED;
9681 /* Verify the capabilities */
9682 struct rte_cryptodev_sym_capability_idx cap_idx;
9683 const struct rte_cryptodev_symmetric_capability *capability;
9684 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9685 cap_idx.algo.aead = tdata->algo;
9686 capability = rte_cryptodev_sym_capability_get(
9687 ts_params->valid_devs[0], &cap_idx);
9688 if (capability == NULL)
9689 return TEST_SKIPPED;
9690 if (rte_cryptodev_sym_capability_check_aead(
9691 capability, tdata->key.len, tdata->auth_tag.len,
9692 tdata->aad.len, tdata->iv.len))
9693 return TEST_SKIPPED;
9695 /* Create AEAD session */
9696 retval = create_aead_session(ts_params->valid_devs[0],
9698 RTE_CRYPTO_AEAD_OP_DECRYPT,
9699 tdata->key.data, tdata->key.len,
9700 tdata->aad.len, tdata->auth_tag.len,
9705 /* alloc mbuf and set payload */
9706 if (tdata->aad.len > MBUF_SIZE) {
9707 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9708 /* Populate full size of add data */
9709 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9710 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9712 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9714 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9715 rte_pktmbuf_tailroom(ut_params->ibuf));
9717 /* Create AEAD operation */
9718 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9722 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9724 ut_params->op->sym->m_src = ut_params->ibuf;
9726 /* Process crypto operation */
9727 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9728 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9729 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9730 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9731 ut_params->op, 0, 0, 0, 0);
9733 TEST_ASSERT_NOT_NULL(
9734 process_crypto_request(ts_params->valid_devs[0],
9735 ut_params->op), "failed to process sym crypto op");
9737 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9738 "crypto op processing failed");
9740 if (ut_params->op->sym->m_dst)
9741 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9744 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9746 ut_params->op->sym->cipher.data.offset);
9748 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9751 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9753 tdata->plaintext.data,
9754 tdata->plaintext.len,
9755 "Plaintext data not as expected");
9757 TEST_ASSERT_EQUAL(ut_params->op->status,
9758 RTE_CRYPTO_OP_STATUS_SUCCESS,
9759 "Authentication failed");
9765 test_AES_GCM_authenticated_decryption_test_case_1(void)
9767 return test_authenticated_decryption(&gcm_test_case_1);
9771 test_AES_GCM_authenticated_decryption_test_case_2(void)
9773 return test_authenticated_decryption(&gcm_test_case_2);
9777 test_AES_GCM_authenticated_decryption_test_case_3(void)
9779 return test_authenticated_decryption(&gcm_test_case_3);
9783 test_AES_GCM_authenticated_decryption_test_case_4(void)
9785 return test_authenticated_decryption(&gcm_test_case_4);
9789 test_AES_GCM_authenticated_decryption_test_case_5(void)
9791 return test_authenticated_decryption(&gcm_test_case_5);
9795 test_AES_GCM_authenticated_decryption_test_case_6(void)
9797 return test_authenticated_decryption(&gcm_test_case_6);
9801 test_AES_GCM_authenticated_decryption_test_case_7(void)
9803 return test_authenticated_decryption(&gcm_test_case_7);
9807 test_AES_GCM_authenticated_decryption_test_case_8(void)
9809 return test_authenticated_decryption(&gcm_test_case_8);
9813 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9815 return test_authenticated_decryption(&gcm_J0_test_case_1);
9819 test_AES_GCM_auth_decryption_test_case_192_1(void)
9821 return test_authenticated_decryption(&gcm_test_case_192_1);
9825 test_AES_GCM_auth_decryption_test_case_192_2(void)
9827 return test_authenticated_decryption(&gcm_test_case_192_2);
9831 test_AES_GCM_auth_decryption_test_case_192_3(void)
9833 return test_authenticated_decryption(&gcm_test_case_192_3);
9837 test_AES_GCM_auth_decryption_test_case_192_4(void)
9839 return test_authenticated_decryption(&gcm_test_case_192_4);
9843 test_AES_GCM_auth_decryption_test_case_192_5(void)
9845 return test_authenticated_decryption(&gcm_test_case_192_5);
9849 test_AES_GCM_auth_decryption_test_case_192_6(void)
9851 return test_authenticated_decryption(&gcm_test_case_192_6);
9855 test_AES_GCM_auth_decryption_test_case_192_7(void)
9857 return test_authenticated_decryption(&gcm_test_case_192_7);
9861 test_AES_GCM_auth_decryption_test_case_256_1(void)
9863 return test_authenticated_decryption(&gcm_test_case_256_1);
9867 test_AES_GCM_auth_decryption_test_case_256_2(void)
9869 return test_authenticated_decryption(&gcm_test_case_256_2);
9873 test_AES_GCM_auth_decryption_test_case_256_3(void)
9875 return test_authenticated_decryption(&gcm_test_case_256_3);
9879 test_AES_GCM_auth_decryption_test_case_256_4(void)
9881 return test_authenticated_decryption(&gcm_test_case_256_4);
9885 test_AES_GCM_auth_decryption_test_case_256_5(void)
9887 return test_authenticated_decryption(&gcm_test_case_256_5);
9891 test_AES_GCM_auth_decryption_test_case_256_6(void)
9893 return test_authenticated_decryption(&gcm_test_case_256_6);
9897 test_AES_GCM_auth_decryption_test_case_256_7(void)
9899 return test_authenticated_decryption(&gcm_test_case_256_7);
9903 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9905 return test_authenticated_decryption(&gcm_test_case_aad_1);
9909 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9911 return test_authenticated_decryption(&gcm_test_case_aad_2);
9915 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9917 struct aead_test_data tdata;
9920 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9921 tdata.iv.data[0] += 1;
9922 res = test_authenticated_decryption(&tdata);
9923 if (res == TEST_SKIPPED)
9925 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9926 return TEST_SUCCESS;
9930 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9932 struct aead_test_data tdata;
9935 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9936 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9937 tdata.plaintext.data[0] += 1;
9938 res = test_authenticated_decryption(&tdata);
9939 if (res == TEST_SKIPPED)
9941 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9942 return TEST_SUCCESS;
9946 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9948 struct aead_test_data tdata;
9951 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9952 tdata.ciphertext.data[0] += 1;
9953 res = test_authenticated_decryption(&tdata);
9954 if (res == TEST_SKIPPED)
9956 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9957 return TEST_SUCCESS;
9961 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9963 struct aead_test_data tdata;
9966 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9968 res = test_authenticated_decryption(&tdata);
9969 if (res == TEST_SKIPPED)
9971 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9972 return TEST_SUCCESS;
9976 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9978 struct aead_test_data tdata;
9979 uint8_t aad[gcm_test_case_7.aad.len];
9982 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9983 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9985 tdata.aad.data = aad;
9986 res = test_authenticated_decryption(&tdata);
9987 if (res == TEST_SKIPPED)
9989 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9990 return TEST_SUCCESS;
9994 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9996 struct aead_test_data tdata;
9999 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10000 tdata.auth_tag.data[0] += 1;
10001 res = test_authenticated_decryption(&tdata);
10002 if (res == TEST_SKIPPED)
10004 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10005 return TEST_SUCCESS;
10009 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10011 struct crypto_testsuite_params *ts_params = &testsuite_params;
10012 struct crypto_unittest_params *ut_params = &unittest_params;
10015 uint8_t *ciphertext, *auth_tag;
10016 uint16_t plaintext_pad_len;
10018 /* Verify the capabilities */
10019 struct rte_cryptodev_sym_capability_idx cap_idx;
10020 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10021 cap_idx.algo.aead = tdata->algo;
10022 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10024 return TEST_SKIPPED;
10026 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10027 return TEST_SKIPPED;
10029 /* not supported with CPU crypto */
10030 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10031 return TEST_SKIPPED;
10033 /* Create AEAD session */
10034 retval = create_aead_session(ts_params->valid_devs[0],
10036 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10037 tdata->key.data, tdata->key.len,
10038 tdata->aad.len, tdata->auth_tag.len,
10043 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10044 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10046 /* clear mbuf payload */
10047 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10048 rte_pktmbuf_tailroom(ut_params->ibuf));
10049 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10050 rte_pktmbuf_tailroom(ut_params->obuf));
10052 /* Create AEAD operation */
10053 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10057 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10059 ut_params->op->sym->m_src = ut_params->ibuf;
10060 ut_params->op->sym->m_dst = ut_params->obuf;
10062 /* Process crypto operation */
10063 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10064 ut_params->op), "failed to process sym crypto op");
10066 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10067 "crypto op processing failed");
10069 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10071 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10072 ut_params->op->sym->cipher.data.offset);
10073 auth_tag = ciphertext + plaintext_pad_len;
10075 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10076 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10078 /* Validate obuf */
10079 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10081 tdata->ciphertext.data,
10082 tdata->ciphertext.len,
10083 "Ciphertext data not as expected");
10085 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10087 tdata->auth_tag.data,
10088 tdata->auth_tag.len,
10089 "Generated auth tag not as expected");
10096 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10098 return test_authenticated_encryption_oop(&gcm_test_case_5);
10102 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10104 struct crypto_testsuite_params *ts_params = &testsuite_params;
10105 struct crypto_unittest_params *ut_params = &unittest_params;
10108 uint8_t *plaintext;
10110 /* Verify the capabilities */
10111 struct rte_cryptodev_sym_capability_idx cap_idx;
10112 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10113 cap_idx.algo.aead = tdata->algo;
10114 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10116 return TEST_SKIPPED;
10118 /* not supported with CPU crypto and raw data-path APIs*/
10119 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10120 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10121 return TEST_SKIPPED;
10123 /* Create AEAD session */
10124 retval = create_aead_session(ts_params->valid_devs[0],
10126 RTE_CRYPTO_AEAD_OP_DECRYPT,
10127 tdata->key.data, tdata->key.len,
10128 tdata->aad.len, tdata->auth_tag.len,
10133 /* alloc mbuf and set payload */
10134 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10135 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10137 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10138 rte_pktmbuf_tailroom(ut_params->ibuf));
10139 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10140 rte_pktmbuf_tailroom(ut_params->obuf));
10142 /* Create AEAD operation */
10143 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10147 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10149 ut_params->op->sym->m_src = ut_params->ibuf;
10150 ut_params->op->sym->m_dst = ut_params->obuf;
10152 /* Process crypto operation */
10153 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10154 ut_params->op), "failed to process sym crypto op");
10156 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10157 "crypto op processing failed");
10159 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10160 ut_params->op->sym->cipher.data.offset);
10162 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10164 /* Validate obuf */
10165 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10167 tdata->plaintext.data,
10168 tdata->plaintext.len,
10169 "Plaintext data not as expected");
10171 TEST_ASSERT_EQUAL(ut_params->op->status,
10172 RTE_CRYPTO_OP_STATUS_SUCCESS,
10173 "Authentication failed");
10178 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10180 return test_authenticated_decryption_oop(&gcm_test_case_5);
10184 test_authenticated_encryption_sessionless(
10185 const struct aead_test_data *tdata)
10187 struct crypto_testsuite_params *ts_params = &testsuite_params;
10188 struct crypto_unittest_params *ut_params = &unittest_params;
10191 uint8_t *ciphertext, *auth_tag;
10192 uint16_t plaintext_pad_len;
10193 uint8_t key[tdata->key.len + 1];
10194 struct rte_cryptodev_info dev_info;
10196 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10197 uint64_t feat_flags = dev_info.feature_flags;
10199 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10200 printf("Device doesn't support Sessionless ops.\n");
10201 return TEST_SKIPPED;
10204 /* not supported with CPU crypto */
10205 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10206 return TEST_SKIPPED;
10208 /* Verify the capabilities */
10209 struct rte_cryptodev_sym_capability_idx cap_idx;
10210 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10211 cap_idx.algo.aead = tdata->algo;
10212 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10214 return TEST_SKIPPED;
10216 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10218 /* clear mbuf payload */
10219 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10220 rte_pktmbuf_tailroom(ut_params->ibuf));
10222 /* Create AEAD operation */
10223 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10227 /* Create GCM xform */
10228 memcpy(key, tdata->key.data, tdata->key.len);
10229 retval = create_aead_xform(ut_params->op,
10231 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10232 key, tdata->key.len,
10233 tdata->aad.len, tdata->auth_tag.len,
10238 ut_params->op->sym->m_src = ut_params->ibuf;
10240 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10241 RTE_CRYPTO_OP_SESSIONLESS,
10242 "crypto op session type not sessionless");
10244 /* Process crypto operation */
10245 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10246 ut_params->op), "failed to process sym crypto op");
10248 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10250 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10251 "crypto op status not success");
10253 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10255 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10256 ut_params->op->sym->cipher.data.offset);
10257 auth_tag = ciphertext + plaintext_pad_len;
10259 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10260 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10262 /* Validate obuf */
10263 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10265 tdata->ciphertext.data,
10266 tdata->ciphertext.len,
10267 "Ciphertext data not as expected");
10269 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10271 tdata->auth_tag.data,
10272 tdata->auth_tag.len,
10273 "Generated auth tag not as expected");
10280 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10282 return test_authenticated_encryption_sessionless(
10287 test_authenticated_decryption_sessionless(
10288 const struct aead_test_data *tdata)
10290 struct crypto_testsuite_params *ts_params = &testsuite_params;
10291 struct crypto_unittest_params *ut_params = &unittest_params;
10294 uint8_t *plaintext;
10295 uint8_t key[tdata->key.len + 1];
10296 struct rte_cryptodev_info dev_info;
10298 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10299 uint64_t feat_flags = dev_info.feature_flags;
10301 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10302 printf("Device doesn't support Sessionless ops.\n");
10303 return TEST_SKIPPED;
10306 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10307 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10308 printf("Device doesn't support RAW data-path APIs.\n");
10309 return TEST_SKIPPED;
10312 /* not supported with CPU crypto */
10313 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10314 return TEST_SKIPPED;
10316 /* Verify the capabilities */
10317 struct rte_cryptodev_sym_capability_idx cap_idx;
10318 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10319 cap_idx.algo.aead = tdata->algo;
10320 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10322 return TEST_SKIPPED;
10324 /* alloc mbuf and set payload */
10325 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10327 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10328 rte_pktmbuf_tailroom(ut_params->ibuf));
10330 /* Create AEAD operation */
10331 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10335 /* Create AEAD xform */
10336 memcpy(key, tdata->key.data, tdata->key.len);
10337 retval = create_aead_xform(ut_params->op,
10339 RTE_CRYPTO_AEAD_OP_DECRYPT,
10340 key, tdata->key.len,
10341 tdata->aad.len, tdata->auth_tag.len,
10346 ut_params->op->sym->m_src = ut_params->ibuf;
10348 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10349 RTE_CRYPTO_OP_SESSIONLESS,
10350 "crypto op session type not sessionless");
10352 /* Process crypto operation */
10353 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10354 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10355 ut_params->op, 0, 0, 0, 0);
10357 TEST_ASSERT_NOT_NULL(process_crypto_request(
10358 ts_params->valid_devs[0], ut_params->op),
10359 "failed to process sym crypto op");
10361 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10363 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10364 "crypto op status not success");
10366 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10367 ut_params->op->sym->cipher.data.offset);
10369 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10371 /* Validate obuf */
10372 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10374 tdata->plaintext.data,
10375 tdata->plaintext.len,
10376 "Plaintext data not as expected");
10378 TEST_ASSERT_EQUAL(ut_params->op->status,
10379 RTE_CRYPTO_OP_STATUS_SUCCESS,
10380 "Authentication failed");
10385 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10387 return test_authenticated_decryption_sessionless(
10392 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10394 return test_authenticated_encryption(&ccm_test_case_128_1);
10398 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10400 return test_authenticated_encryption(&ccm_test_case_128_2);
10404 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10406 return test_authenticated_encryption(&ccm_test_case_128_3);
10410 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10412 return test_authenticated_decryption(&ccm_test_case_128_1);
10416 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10418 return test_authenticated_decryption(&ccm_test_case_128_2);
10422 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10424 return test_authenticated_decryption(&ccm_test_case_128_3);
10428 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10430 return test_authenticated_encryption(&ccm_test_case_192_1);
10434 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10436 return test_authenticated_encryption(&ccm_test_case_192_2);
10440 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10442 return test_authenticated_encryption(&ccm_test_case_192_3);
10446 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10448 return test_authenticated_decryption(&ccm_test_case_192_1);
10452 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10454 return test_authenticated_decryption(&ccm_test_case_192_2);
10458 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10460 return test_authenticated_decryption(&ccm_test_case_192_3);
10464 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10466 return test_authenticated_encryption(&ccm_test_case_256_1);
10470 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10472 return test_authenticated_encryption(&ccm_test_case_256_2);
10476 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10478 return test_authenticated_encryption(&ccm_test_case_256_3);
10482 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10484 return test_authenticated_decryption(&ccm_test_case_256_1);
10488 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10490 return test_authenticated_decryption(&ccm_test_case_256_2);
10494 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10496 return test_authenticated_decryption(&ccm_test_case_256_3);
10502 struct crypto_testsuite_params *ts_params = &testsuite_params;
10503 struct rte_cryptodev_stats stats;
10505 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10506 return TEST_SKIPPED;
10508 /* Verify the capabilities */
10509 struct rte_cryptodev_sym_capability_idx cap_idx;
10510 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10511 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10512 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10514 return TEST_SKIPPED;
10515 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10516 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10517 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10519 return TEST_SKIPPED;
10521 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10523 return TEST_SKIPPED;
10525 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10526 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10527 &stats) == -ENODEV),
10528 "rte_cryptodev_stats_get invalid dev failed");
10529 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10530 "rte_cryptodev_stats_get invalid Param failed");
10532 /* Test expected values */
10533 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10534 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10536 "rte_cryptodev_stats_get failed");
10537 TEST_ASSERT((stats.enqueued_count == 1),
10538 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10539 TEST_ASSERT((stats.dequeued_count == 1),
10540 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10541 TEST_ASSERT((stats.enqueue_err_count == 0),
10542 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10543 TEST_ASSERT((stats.dequeue_err_count == 0),
10544 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10546 /* invalid device but should ignore and not reset device stats*/
10547 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10548 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10550 "rte_cryptodev_stats_get failed");
10551 TEST_ASSERT((stats.enqueued_count == 1),
10552 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10554 /* check that a valid reset clears stats */
10555 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10556 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10558 "rte_cryptodev_stats_get failed");
10559 TEST_ASSERT((stats.enqueued_count == 0),
10560 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10561 TEST_ASSERT((stats.dequeued_count == 0),
10562 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10564 return TEST_SUCCESS;
10567 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10568 struct crypto_unittest_params *ut_params,
10569 enum rte_crypto_auth_operation op,
10570 const struct HMAC_MD5_vector *test_case)
10574 memcpy(key, test_case->key.data, test_case->key.len);
10576 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10577 ut_params->auth_xform.next = NULL;
10578 ut_params->auth_xform.auth.op = op;
10580 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10582 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10583 ut_params->auth_xform.auth.key.length = test_case->key.len;
10584 ut_params->auth_xform.auth.key.data = key;
10586 ut_params->sess = rte_cryptodev_sym_session_create(
10587 ts_params->session_mpool);
10589 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10590 ut_params->sess, &ut_params->auth_xform,
10591 ts_params->session_priv_mpool);
10593 if (ut_params->sess == NULL)
10594 return TEST_FAILED;
10596 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10598 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10599 rte_pktmbuf_tailroom(ut_params->ibuf));
10604 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10605 const struct HMAC_MD5_vector *test_case,
10606 uint8_t **plaintext)
10608 uint16_t plaintext_pad_len;
10610 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10612 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10615 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10616 plaintext_pad_len);
10617 memcpy(*plaintext, test_case->plaintext.data,
10618 test_case->plaintext.len);
10620 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10621 ut_params->ibuf, MD5_DIGEST_LEN);
10622 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10623 "no room to append digest");
10624 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10625 ut_params->ibuf, plaintext_pad_len);
10627 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10628 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10629 test_case->auth_tag.len);
10632 sym_op->auth.data.offset = 0;
10633 sym_op->auth.data.length = test_case->plaintext.len;
10635 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10636 ut_params->op->sym->m_src = ut_params->ibuf;
10642 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10644 uint16_t plaintext_pad_len;
10645 uint8_t *plaintext, *auth_tag;
10647 struct crypto_testsuite_params *ts_params = &testsuite_params;
10648 struct crypto_unittest_params *ut_params = &unittest_params;
10649 struct rte_cryptodev_info dev_info;
10651 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10652 uint64_t feat_flags = dev_info.feature_flags;
10654 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10655 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10656 printf("Device doesn't support RAW data-path APIs.\n");
10657 return TEST_SKIPPED;
10660 /* Verify the capabilities */
10661 struct rte_cryptodev_sym_capability_idx cap_idx;
10662 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10663 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10664 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10666 return TEST_SKIPPED;
10668 if (MD5_HMAC_create_session(ts_params, ut_params,
10669 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10670 return TEST_FAILED;
10672 /* Generate Crypto op data structure */
10673 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10674 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10675 TEST_ASSERT_NOT_NULL(ut_params->op,
10676 "Failed to allocate symmetric crypto operation struct");
10678 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10681 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10682 return TEST_FAILED;
10684 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10685 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10687 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10688 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10689 ut_params->op, 0, 1, 0, 0);
10691 TEST_ASSERT_NOT_NULL(
10692 process_crypto_request(ts_params->valid_devs[0],
10694 "failed to process sym crypto op");
10696 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10697 "crypto op processing failed");
10699 if (ut_params->op->sym->m_dst) {
10700 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10701 uint8_t *, plaintext_pad_len);
10703 auth_tag = plaintext + plaintext_pad_len;
10706 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10708 test_case->auth_tag.data,
10709 test_case->auth_tag.len,
10710 "HMAC_MD5 generated tag not as expected");
10712 return TEST_SUCCESS;
10716 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10718 uint8_t *plaintext;
10720 struct crypto_testsuite_params *ts_params = &testsuite_params;
10721 struct crypto_unittest_params *ut_params = &unittest_params;
10722 struct rte_cryptodev_info dev_info;
10724 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10725 uint64_t feat_flags = dev_info.feature_flags;
10727 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10728 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10729 printf("Device doesn't support RAW data-path APIs.\n");
10730 return TEST_SKIPPED;
10733 /* Verify the capabilities */
10734 struct rte_cryptodev_sym_capability_idx cap_idx;
10735 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10736 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10737 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10739 return TEST_SKIPPED;
10741 if (MD5_HMAC_create_session(ts_params, ut_params,
10742 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10743 return TEST_FAILED;
10746 /* Generate Crypto op data structure */
10747 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10748 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10749 TEST_ASSERT_NOT_NULL(ut_params->op,
10750 "Failed to allocate symmetric crypto operation struct");
10752 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10753 return TEST_FAILED;
10755 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10756 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10758 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10759 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10760 ut_params->op, 0, 1, 0, 0);
10762 TEST_ASSERT_NOT_NULL(
10763 process_crypto_request(ts_params->valid_devs[0],
10765 "failed to process sym crypto op");
10767 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10768 "HMAC_MD5 crypto op processing failed");
10770 return TEST_SUCCESS;
10774 test_MD5_HMAC_generate_case_1(void)
10776 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10780 test_MD5_HMAC_verify_case_1(void)
10782 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10786 test_MD5_HMAC_generate_case_2(void)
10788 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10792 test_MD5_HMAC_verify_case_2(void)
10794 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10798 test_multi_session(void)
10800 struct crypto_testsuite_params *ts_params = &testsuite_params;
10801 struct crypto_unittest_params *ut_params = &unittest_params;
10803 struct rte_cryptodev_info dev_info;
10804 struct rte_cryptodev_sym_session **sessions;
10808 /* Verify the capabilities */
10809 struct rte_cryptodev_sym_capability_idx cap_idx;
10810 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10811 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10812 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10814 return TEST_SKIPPED;
10815 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10816 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10817 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10819 return TEST_SKIPPED;
10821 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10822 aes_cbc_key, hmac_sha512_key);
10825 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10827 sessions = rte_malloc(NULL,
10828 (sizeof(struct rte_cryptodev_sym_session *) *
10829 MAX_NB_SESSIONS) + 1, 0);
10831 /* Create multiple crypto sessions*/
10832 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10834 sessions[i] = rte_cryptodev_sym_session_create(
10835 ts_params->session_mpool);
10837 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10838 sessions[i], &ut_params->auth_xform,
10839 ts_params->session_priv_mpool);
10840 TEST_ASSERT_NOT_NULL(sessions[i],
10841 "Session creation failed at session number %u",
10844 /* Attempt to send a request on each session */
10845 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10849 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10850 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10852 "Failed to perform decrypt on request number %u.", i);
10853 /* free crypto operation structure */
10855 rte_crypto_op_free(ut_params->op);
10858 * free mbuf - both obuf and ibuf are usually the same,
10859 * so check if they point at the same address is necessary,
10860 * to avoid freeing the mbuf twice.
10862 if (ut_params->obuf) {
10863 rte_pktmbuf_free(ut_params->obuf);
10864 if (ut_params->ibuf == ut_params->obuf)
10865 ut_params->ibuf = 0;
10866 ut_params->obuf = 0;
10868 if (ut_params->ibuf) {
10869 rte_pktmbuf_free(ut_params->ibuf);
10870 ut_params->ibuf = 0;
10874 /* Next session create should fail */
10875 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10876 sessions[i], &ut_params->auth_xform,
10877 ts_params->session_priv_mpool);
10878 TEST_ASSERT_NULL(sessions[i],
10879 "Session creation succeeded unexpectedly!");
10881 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10882 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10884 rte_cryptodev_sym_session_free(sessions[i]);
10887 rte_free(sessions);
10889 return TEST_SUCCESS;
10892 struct multi_session_params {
10893 struct crypto_unittest_params ut_params;
10894 uint8_t *cipher_key;
10896 const uint8_t *cipher;
10897 const uint8_t *digest;
10901 #define MB_SESSION_NUMBER 3
10904 test_multi_session_random_usage(void)
10906 struct crypto_testsuite_params *ts_params = &testsuite_params;
10907 struct rte_cryptodev_info dev_info;
10908 struct rte_cryptodev_sym_session **sessions;
10910 struct multi_session_params ut_paramz[] = {
10913 .cipher_key = ms_aes_cbc_key0,
10914 .hmac_key = ms_hmac_key0,
10915 .cipher = ms_aes_cbc_cipher0,
10916 .digest = ms_hmac_digest0,
10917 .iv = ms_aes_cbc_iv0
10920 .cipher_key = ms_aes_cbc_key1,
10921 .hmac_key = ms_hmac_key1,
10922 .cipher = ms_aes_cbc_cipher1,
10923 .digest = ms_hmac_digest1,
10924 .iv = ms_aes_cbc_iv1
10927 .cipher_key = ms_aes_cbc_key2,
10928 .hmac_key = ms_hmac_key2,
10929 .cipher = ms_aes_cbc_cipher2,
10930 .digest = ms_hmac_digest2,
10931 .iv = ms_aes_cbc_iv2
10936 /* Verify the capabilities */
10937 struct rte_cryptodev_sym_capability_idx cap_idx;
10938 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10939 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10940 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10942 return TEST_SKIPPED;
10943 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10944 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10945 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10947 return TEST_SKIPPED;
10949 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10951 sessions = rte_malloc(NULL,
10952 (sizeof(struct rte_cryptodev_sym_session *)
10953 * MAX_NB_SESSIONS) + 1, 0);
10955 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10956 sessions[i] = rte_cryptodev_sym_session_create(
10957 ts_params->session_mpool);
10959 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10960 sizeof(struct crypto_unittest_params));
10962 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10963 &ut_paramz[i].ut_params,
10964 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10966 /* Create multiple crypto sessions*/
10967 rte_cryptodev_sym_session_init(
10968 ts_params->valid_devs[0],
10970 &ut_paramz[i].ut_params.auth_xform,
10971 ts_params->session_priv_mpool);
10973 TEST_ASSERT_NOT_NULL(sessions[i],
10974 "Session creation failed at session number %u",
10980 for (i = 0; i < 40000; i++) {
10982 j = rand() % MB_SESSION_NUMBER;
10984 TEST_ASSERT_SUCCESS(
10985 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10987 &ut_paramz[j].ut_params,
10988 ts_params, ut_paramz[j].cipher,
10989 ut_paramz[j].digest,
10991 "Failed to perform decrypt on request number %u.", i);
10993 if (ut_paramz[j].ut_params.op)
10994 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10997 * free mbuf - both obuf and ibuf are usually the same,
10998 * so check if they point at the same address is necessary,
10999 * to avoid freeing the mbuf twice.
11001 if (ut_paramz[j].ut_params.obuf) {
11002 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11003 if (ut_paramz[j].ut_params.ibuf
11004 == ut_paramz[j].ut_params.obuf)
11005 ut_paramz[j].ut_params.ibuf = 0;
11006 ut_paramz[j].ut_params.obuf = 0;
11008 if (ut_paramz[j].ut_params.ibuf) {
11009 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11010 ut_paramz[j].ut_params.ibuf = 0;
11014 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11015 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11017 rte_cryptodev_sym_session_free(sessions[i]);
11020 rte_free(sessions);
11022 return TEST_SUCCESS;
11025 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11026 0xab, 0xab, 0xab, 0xab,
11027 0xab, 0xab, 0xab, 0xab,
11028 0xab, 0xab, 0xab, 0xab};
11031 test_null_invalid_operation(void)
11033 struct crypto_testsuite_params *ts_params = &testsuite_params;
11034 struct crypto_unittest_params *ut_params = &unittest_params;
11037 /* This test is for NULL PMD only */
11038 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11039 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11040 return TEST_SKIPPED;
11042 /* Setup Cipher Parameters */
11043 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11044 ut_params->cipher_xform.next = NULL;
11046 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11047 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11049 ut_params->sess = rte_cryptodev_sym_session_create(
11050 ts_params->session_mpool);
11052 /* Create Crypto session*/
11053 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11054 ut_params->sess, &ut_params->cipher_xform,
11055 ts_params->session_priv_mpool);
11056 TEST_ASSERT(ret < 0,
11057 "Session creation succeeded unexpectedly");
11060 /* Setup HMAC Parameters */
11061 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11062 ut_params->auth_xform.next = NULL;
11064 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11065 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11067 ut_params->sess = rte_cryptodev_sym_session_create(
11068 ts_params->session_mpool);
11070 /* Create Crypto session*/
11071 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11072 ut_params->sess, &ut_params->auth_xform,
11073 ts_params->session_priv_mpool);
11074 TEST_ASSERT(ret < 0,
11075 "Session creation succeeded unexpectedly");
11077 return TEST_SUCCESS;
11081 #define NULL_BURST_LENGTH (32)
11084 test_null_burst_operation(void)
11086 struct crypto_testsuite_params *ts_params = &testsuite_params;
11087 struct crypto_unittest_params *ut_params = &unittest_params;
11089 unsigned i, burst_len = NULL_BURST_LENGTH;
11091 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11092 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11094 /* This test is for NULL PMD only */
11095 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11096 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11097 return TEST_SKIPPED;
11099 /* Setup Cipher Parameters */
11100 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11101 ut_params->cipher_xform.next = &ut_params->auth_xform;
11103 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11104 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11106 /* Setup HMAC Parameters */
11107 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11108 ut_params->auth_xform.next = NULL;
11110 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11111 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11113 ut_params->sess = rte_cryptodev_sym_session_create(
11114 ts_params->session_mpool);
11116 /* Create Crypto session*/
11117 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11118 ut_params->sess, &ut_params->cipher_xform,
11119 ts_params->session_priv_mpool);
11120 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11122 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11123 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11124 burst_len, "failed to generate burst of crypto ops");
11126 /* Generate an operation for each mbuf in burst */
11127 for (i = 0; i < burst_len; i++) {
11128 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11130 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11132 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11136 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11138 burst[i]->sym->m_src = m;
11141 /* Process crypto operation */
11142 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11143 0, burst, burst_len),
11145 "Error enqueuing burst");
11147 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11148 0, burst_dequeued, burst_len),
11150 "Error dequeuing burst");
11153 for (i = 0; i < burst_len; i++) {
11155 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11156 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11158 "data not as expected");
11160 rte_pktmbuf_free(burst[i]->sym->m_src);
11161 rte_crypto_op_free(burst[i]);
11164 return TEST_SUCCESS;
11168 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11169 uint16_t nb_ops, void *user_param)
11171 RTE_SET_USED(dev_id);
11172 RTE_SET_USED(qp_id);
11174 RTE_SET_USED(user_param);
11176 printf("crypto enqueue callback called\n");
11181 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11182 uint16_t nb_ops, void *user_param)
11184 RTE_SET_USED(dev_id);
11185 RTE_SET_USED(qp_id);
11187 RTE_SET_USED(user_param);
11189 printf("crypto dequeue callback called\n");
11194 * Thread using enqueue/dequeue callback with RCU.
11197 test_enqdeq_callback_thread(void *arg)
11200 /* DP thread calls rte_cryptodev_enqueue_burst()/
11201 * rte_cryptodev_dequeue_burst() and invokes callback.
11203 test_null_burst_operation();
11208 test_enq_callback_setup(void)
11210 struct crypto_testsuite_params *ts_params = &testsuite_params;
11211 struct rte_cryptodev_info dev_info;
11212 struct rte_cryptodev_qp_conf qp_conf = {
11213 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11216 struct rte_cryptodev_cb *cb;
11217 uint16_t qp_id = 0;
11219 /* Stop the device in case it's started so it can be configured */
11220 rte_cryptodev_stop(ts_params->valid_devs[0]);
11222 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11224 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11226 "Failed to configure cryptodev %u",
11227 ts_params->valid_devs[0]);
11229 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11230 qp_conf.mp_session = ts_params->session_mpool;
11231 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11233 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11234 ts_params->valid_devs[0], qp_id, &qp_conf,
11235 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11237 "rte_cryptodev_queue_pair_setup: num_inflights "
11238 "%u on qp %u on cryptodev %u",
11239 qp_conf.nb_descriptors, qp_id,
11240 ts_params->valid_devs[0]);
11242 /* Test with invalid crypto device */
11243 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11244 qp_id, test_enq_callback, NULL);
11245 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11246 "cryptodev %u did not fail",
11247 qp_id, RTE_CRYPTO_MAX_DEVS);
11249 /* Test with invalid queue pair */
11250 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11251 dev_info.max_nb_queue_pairs + 1,
11252 test_enq_callback, NULL);
11253 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11254 "cryptodev %u did not fail",
11255 dev_info.max_nb_queue_pairs + 1,
11256 ts_params->valid_devs[0]);
11258 /* Test with NULL callback */
11259 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11260 qp_id, NULL, NULL);
11261 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11262 "cryptodev %u did not fail",
11263 qp_id, ts_params->valid_devs[0]);
11265 /* Test with valid configuration */
11266 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11267 qp_id, test_enq_callback, NULL);
11268 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11269 "qp %u on cryptodev %u",
11270 qp_id, ts_params->valid_devs[0]);
11272 rte_cryptodev_start(ts_params->valid_devs[0]);
11274 /* Launch a thread */
11275 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11276 rte_get_next_lcore(-1, 1, 0));
11278 /* Wait until reader exited. */
11279 rte_eal_mp_wait_lcore();
11281 /* Test with invalid crypto device */
11282 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11283 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11284 "Expected call to fail as crypto device is invalid");
11286 /* Test with invalid queue pair */
11287 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11288 ts_params->valid_devs[0],
11289 dev_info.max_nb_queue_pairs + 1, cb),
11290 "Expected call to fail as queue pair is invalid");
11292 /* Test with NULL callback */
11293 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11294 ts_params->valid_devs[0], qp_id, NULL),
11295 "Expected call to fail as callback is NULL");
11297 /* Test with valid configuration */
11298 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11299 ts_params->valid_devs[0], qp_id, cb),
11300 "Failed test to remove callback on "
11301 "qp %u on cryptodev %u",
11302 qp_id, ts_params->valid_devs[0]);
11304 return TEST_SUCCESS;
11308 test_deq_callback_setup(void)
11310 struct crypto_testsuite_params *ts_params = &testsuite_params;
11311 struct rte_cryptodev_info dev_info;
11312 struct rte_cryptodev_qp_conf qp_conf = {
11313 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11316 struct rte_cryptodev_cb *cb;
11317 uint16_t qp_id = 0;
11319 /* Stop the device in case it's started so it can be configured */
11320 rte_cryptodev_stop(ts_params->valid_devs[0]);
11322 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11324 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11326 "Failed to configure cryptodev %u",
11327 ts_params->valid_devs[0]);
11329 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11330 qp_conf.mp_session = ts_params->session_mpool;
11331 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11333 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11334 ts_params->valid_devs[0], qp_id, &qp_conf,
11335 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11337 "rte_cryptodev_queue_pair_setup: num_inflights "
11338 "%u on qp %u on cryptodev %u",
11339 qp_conf.nb_descriptors, qp_id,
11340 ts_params->valid_devs[0]);
11342 /* Test with invalid crypto device */
11343 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11344 qp_id, test_deq_callback, NULL);
11345 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11346 "cryptodev %u did not fail",
11347 qp_id, RTE_CRYPTO_MAX_DEVS);
11349 /* Test with invalid queue pair */
11350 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11351 dev_info.max_nb_queue_pairs + 1,
11352 test_deq_callback, NULL);
11353 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11354 "cryptodev %u did not fail",
11355 dev_info.max_nb_queue_pairs + 1,
11356 ts_params->valid_devs[0]);
11358 /* Test with NULL callback */
11359 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11360 qp_id, NULL, NULL);
11361 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11362 "cryptodev %u did not fail",
11363 qp_id, ts_params->valid_devs[0]);
11365 /* Test with valid configuration */
11366 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11367 qp_id, test_deq_callback, NULL);
11368 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11369 "qp %u on cryptodev %u",
11370 qp_id, ts_params->valid_devs[0]);
11372 rte_cryptodev_start(ts_params->valid_devs[0]);
11374 /* Launch a thread */
11375 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11376 rte_get_next_lcore(-1, 1, 0));
11378 /* Wait until reader exited. */
11379 rte_eal_mp_wait_lcore();
11381 /* Test with invalid crypto device */
11382 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11383 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11384 "Expected call to fail as crypto device is invalid");
11386 /* Test with invalid queue pair */
11387 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11388 ts_params->valid_devs[0],
11389 dev_info.max_nb_queue_pairs + 1, cb),
11390 "Expected call to fail as queue pair is invalid");
11392 /* Test with NULL callback */
11393 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11394 ts_params->valid_devs[0], qp_id, NULL),
11395 "Expected call to fail as callback is NULL");
11397 /* Test with valid configuration */
11398 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11399 ts_params->valid_devs[0], qp_id, cb),
11400 "Failed test to remove callback on "
11401 "qp %u on cryptodev %u",
11402 qp_id, ts_params->valid_devs[0]);
11404 return TEST_SUCCESS;
11408 generate_gmac_large_plaintext(uint8_t *data)
11412 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11413 memcpy(&data[i], &data[0], 32);
11417 create_gmac_operation(enum rte_crypto_auth_operation op,
11418 const struct gmac_test_data *tdata)
11420 struct crypto_testsuite_params *ts_params = &testsuite_params;
11421 struct crypto_unittest_params *ut_params = &unittest_params;
11422 struct rte_crypto_sym_op *sym_op;
11424 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11426 /* Generate Crypto op data structure */
11427 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11428 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11429 TEST_ASSERT_NOT_NULL(ut_params->op,
11430 "Failed to allocate symmetric crypto operation struct");
11432 sym_op = ut_params->op->sym;
11434 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11435 ut_params->ibuf, tdata->gmac_tag.len);
11436 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11437 "no room to append digest");
11439 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11440 ut_params->ibuf, plaintext_pad_len);
11442 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11443 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11444 tdata->gmac_tag.len);
11445 debug_hexdump(stdout, "digest:",
11446 sym_op->auth.digest.data,
11447 tdata->gmac_tag.len);
11450 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11451 uint8_t *, IV_OFFSET);
11453 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11455 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11457 sym_op->cipher.data.length = 0;
11458 sym_op->cipher.data.offset = 0;
11460 sym_op->auth.data.offset = 0;
11461 sym_op->auth.data.length = tdata->plaintext.len;
11467 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11468 const struct gmac_test_data *tdata,
11469 void *digest_mem, uint64_t digest_phys)
11471 struct crypto_testsuite_params *ts_params = &testsuite_params;
11472 struct crypto_unittest_params *ut_params = &unittest_params;
11473 struct rte_crypto_sym_op *sym_op;
11475 /* Generate Crypto op data structure */
11476 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11477 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11478 TEST_ASSERT_NOT_NULL(ut_params->op,
11479 "Failed to allocate symmetric crypto operation struct");
11481 sym_op = ut_params->op->sym;
11483 sym_op->auth.digest.data = digest_mem;
11484 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11485 "no room to append digest");
11487 sym_op->auth.digest.phys_addr = digest_phys;
11489 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11490 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11491 tdata->gmac_tag.len);
11492 debug_hexdump(stdout, "digest:",
11493 sym_op->auth.digest.data,
11494 tdata->gmac_tag.len);
11497 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11498 uint8_t *, IV_OFFSET);
11500 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11502 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11504 sym_op->cipher.data.length = 0;
11505 sym_op->cipher.data.offset = 0;
11507 sym_op->auth.data.offset = 0;
11508 sym_op->auth.data.length = tdata->plaintext.len;
11513 static int create_gmac_session(uint8_t dev_id,
11514 const struct gmac_test_data *tdata,
11515 enum rte_crypto_auth_operation auth_op)
11517 uint8_t auth_key[tdata->key.len];
11519 struct crypto_testsuite_params *ts_params = &testsuite_params;
11520 struct crypto_unittest_params *ut_params = &unittest_params;
11522 memcpy(auth_key, tdata->key.data, tdata->key.len);
11524 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11525 ut_params->auth_xform.next = NULL;
11527 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11528 ut_params->auth_xform.auth.op = auth_op;
11529 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11530 ut_params->auth_xform.auth.key.length = tdata->key.len;
11531 ut_params->auth_xform.auth.key.data = auth_key;
11532 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11533 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11536 ut_params->sess = rte_cryptodev_sym_session_create(
11537 ts_params->session_mpool);
11539 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11540 &ut_params->auth_xform,
11541 ts_params->session_priv_mpool);
11543 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11549 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11551 struct crypto_testsuite_params *ts_params = &testsuite_params;
11552 struct crypto_unittest_params *ut_params = &unittest_params;
11553 struct rte_cryptodev_info dev_info;
11555 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11556 uint64_t feat_flags = dev_info.feature_flags;
11558 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11559 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11560 printf("Device doesn't support RAW data-path APIs.\n");
11561 return TEST_SKIPPED;
11566 uint8_t *auth_tag, *plaintext;
11567 uint16_t plaintext_pad_len;
11569 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11570 "No GMAC length in the source data");
11572 /* Verify the capabilities */
11573 struct rte_cryptodev_sym_capability_idx cap_idx;
11574 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11575 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11576 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11578 return TEST_SKIPPED;
11580 retval = create_gmac_session(ts_params->valid_devs[0],
11581 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11586 if (tdata->plaintext.len > MBUF_SIZE)
11587 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11589 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11590 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11591 "Failed to allocate input buffer in mempool");
11593 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11594 rte_pktmbuf_tailroom(ut_params->ibuf));
11596 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11598 * Runtime generate the large plain text instead of use hard code
11599 * plain text vector. It is done to avoid create huge source file
11600 * with the test vector.
11602 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11603 generate_gmac_large_plaintext(tdata->plaintext.data);
11605 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11606 plaintext_pad_len);
11607 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11609 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11610 debug_hexdump(stdout, "plaintext:", plaintext,
11611 tdata->plaintext.len);
11613 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11619 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11621 ut_params->op->sym->m_src = ut_params->ibuf;
11623 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11624 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11626 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11627 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11628 ut_params->op, 0, 1, 0, 0);
11630 TEST_ASSERT_NOT_NULL(
11631 process_crypto_request(ts_params->valid_devs[0],
11632 ut_params->op), "failed to process sym crypto op");
11634 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11635 "crypto op processing failed");
11637 if (ut_params->op->sym->m_dst) {
11638 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11639 uint8_t *, plaintext_pad_len);
11641 auth_tag = plaintext + plaintext_pad_len;
11644 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11646 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11648 tdata->gmac_tag.data,
11649 tdata->gmac_tag.len,
11650 "GMAC Generated auth tag not as expected");
11656 test_AES_GMAC_authentication_test_case_1(void)
11658 return test_AES_GMAC_authentication(&gmac_test_case_1);
11662 test_AES_GMAC_authentication_test_case_2(void)
11664 return test_AES_GMAC_authentication(&gmac_test_case_2);
11668 test_AES_GMAC_authentication_test_case_3(void)
11670 return test_AES_GMAC_authentication(&gmac_test_case_3);
11674 test_AES_GMAC_authentication_test_case_4(void)
11676 return test_AES_GMAC_authentication(&gmac_test_case_4);
11680 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11682 struct crypto_testsuite_params *ts_params = &testsuite_params;
11683 struct crypto_unittest_params *ut_params = &unittest_params;
11685 uint32_t plaintext_pad_len;
11686 uint8_t *plaintext;
11687 struct rte_cryptodev_info dev_info;
11689 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11690 uint64_t feat_flags = dev_info.feature_flags;
11692 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11693 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11694 printf("Device doesn't support RAW data-path APIs.\n");
11695 return TEST_SKIPPED;
11698 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11699 "No GMAC length in the source data");
11701 /* Verify the capabilities */
11702 struct rte_cryptodev_sym_capability_idx cap_idx;
11703 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11704 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11705 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11707 return TEST_SKIPPED;
11709 retval = create_gmac_session(ts_params->valid_devs[0],
11710 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11715 if (tdata->plaintext.len > MBUF_SIZE)
11716 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11718 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11719 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11720 "Failed to allocate input buffer in mempool");
11722 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11723 rte_pktmbuf_tailroom(ut_params->ibuf));
11725 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11728 * Runtime generate the large plain text instead of use hard code
11729 * plain text vector. It is done to avoid create huge source file
11730 * with the test vector.
11732 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11733 generate_gmac_large_plaintext(tdata->plaintext.data);
11735 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11736 plaintext_pad_len);
11737 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11739 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11740 debug_hexdump(stdout, "plaintext:", plaintext,
11741 tdata->plaintext.len);
11743 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11749 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11751 ut_params->op->sym->m_src = ut_params->ibuf;
11753 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11754 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11756 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11757 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11758 ut_params->op, 0, 1, 0, 0);
11760 TEST_ASSERT_NOT_NULL(
11761 process_crypto_request(ts_params->valid_devs[0],
11762 ut_params->op), "failed to process sym crypto op");
11764 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11765 "crypto op processing failed");
11772 test_AES_GMAC_authentication_verify_test_case_1(void)
11774 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11778 test_AES_GMAC_authentication_verify_test_case_2(void)
11780 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11784 test_AES_GMAC_authentication_verify_test_case_3(void)
11786 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11790 test_AES_GMAC_authentication_verify_test_case_4(void)
11792 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11796 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11799 struct crypto_testsuite_params *ts_params = &testsuite_params;
11800 struct crypto_unittest_params *ut_params = &unittest_params;
11801 struct rte_cryptodev_info dev_info;
11802 uint64_t feature_flags;
11803 unsigned int trn_data = 0;
11804 void *digest_mem = NULL;
11806 unsigned int to_trn = 0;
11807 struct rte_mbuf *buf = NULL;
11808 uint8_t *auth_tag, *plaintext;
11811 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11812 "No GMAC length in the source data");
11814 /* Verify the capabilities */
11815 struct rte_cryptodev_sym_capability_idx cap_idx;
11816 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11817 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11818 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11820 return TEST_SKIPPED;
11822 /* Check for any input SGL support */
11823 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11824 feature_flags = dev_info.feature_flags;
11826 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11827 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11828 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11829 return TEST_SKIPPED;
11831 if (fragsz > tdata->plaintext.len)
11832 fragsz = tdata->plaintext.len;
11834 uint16_t plaintext_len = fragsz;
11836 retval = create_gmac_session(ts_params->valid_devs[0],
11837 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11842 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11843 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11844 "Failed to allocate input buffer in mempool");
11846 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11847 rte_pktmbuf_tailroom(ut_params->ibuf));
11849 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11851 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11853 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11855 trn_data += plaintext_len;
11857 buf = ut_params->ibuf;
11860 * Loop until no more fragments
11863 while (trn_data < tdata->plaintext.len) {
11865 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11866 (tdata->plaintext.len - trn_data) : fragsz;
11868 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11871 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11872 rte_pktmbuf_tailroom(buf));
11874 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11877 memcpy(plaintext, tdata->plaintext.data + trn_data,
11879 trn_data += to_trn;
11880 if (trn_data == tdata->plaintext.len)
11881 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11882 tdata->gmac_tag.len);
11884 ut_params->ibuf->nb_segs = segs;
11887 * Place digest at the end of the last buffer
11889 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11892 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11893 + tdata->gmac_tag.len);
11894 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11895 tdata->plaintext.len);
11898 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11899 tdata, digest_mem, digest_phys);
11904 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11906 ut_params->op->sym->m_src = ut_params->ibuf;
11908 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11909 return TEST_SKIPPED;
11911 TEST_ASSERT_NOT_NULL(
11912 process_crypto_request(ts_params->valid_devs[0],
11913 ut_params->op), "failed to process sym crypto op");
11915 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11916 "crypto op processing failed");
11918 auth_tag = digest_mem;
11919 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11920 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11922 tdata->gmac_tag.data,
11923 tdata->gmac_tag.len,
11924 "GMAC Generated auth tag not as expected");
11929 /* Segment size not multiple of block size (16B) */
11931 test_AES_GMAC_authentication_SGL_40B(void)
11933 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11937 test_AES_GMAC_authentication_SGL_80B(void)
11939 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11943 test_AES_GMAC_authentication_SGL_2048B(void)
11945 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11948 /* Segment size not multiple of block size (16B) */
11950 test_AES_GMAC_authentication_SGL_2047B(void)
11952 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11955 struct test_crypto_vector {
11956 enum rte_crypto_cipher_algorithm crypto_algo;
11957 unsigned int cipher_offset;
11958 unsigned int cipher_len;
11971 const uint8_t *data;
11976 const uint8_t *data;
11980 enum rte_crypto_auth_algorithm auth_algo;
11981 unsigned int auth_offset;
11989 const uint8_t *data;
11999 static const struct test_crypto_vector
12000 hmac_sha1_test_crypto_vector = {
12001 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12003 .data = plaintext_hash,
12008 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12009 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12010 0xDE, 0xF4, 0xDE, 0xAD
12016 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12017 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12018 0x3F, 0x91, 0x64, 0x59
12024 static const struct test_crypto_vector
12025 aes128_gmac_test_vector = {
12026 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12028 .data = plaintext_hash,
12033 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12034 0x08, 0x09, 0x0A, 0x0B
12040 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12041 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12047 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12048 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12054 static const struct test_crypto_vector
12055 aes128cbc_hmac_sha1_test_vector = {
12056 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12057 .cipher_offset = 0,
12061 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12062 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12068 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12069 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12074 .data = plaintext_hash,
12078 .data = ciphertext512_aes128cbc,
12081 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12085 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12086 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12087 0xDE, 0xF4, 0xDE, 0xAD
12093 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12094 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12095 0x18, 0x8C, 0x1D, 0x32
12101 static const struct test_crypto_vector
12102 aes128cbc_hmac_sha1_aad_test_vector = {
12103 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12104 .cipher_offset = 8,
12108 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12109 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12115 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12116 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12121 .data = plaintext_hash,
12125 .data = ciphertext512_aes128cbc_aad,
12128 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12132 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12133 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12134 0xDE, 0xF4, 0xDE, 0xAD
12140 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12141 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12142 0x62, 0x0F, 0xFB, 0x10
12149 data_corruption(uint8_t *data)
12155 tag_corruption(uint8_t *data, unsigned int tag_offset)
12157 data[tag_offset] += 1;
12161 create_auth_session(struct crypto_unittest_params *ut_params,
12163 const struct test_crypto_vector *reference,
12164 enum rte_crypto_auth_operation auth_op)
12166 struct crypto_testsuite_params *ts_params = &testsuite_params;
12167 uint8_t auth_key[reference->auth_key.len + 1];
12169 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12171 /* Setup Authentication Parameters */
12172 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12173 ut_params->auth_xform.auth.op = auth_op;
12174 ut_params->auth_xform.next = NULL;
12175 ut_params->auth_xform.auth.algo = reference->auth_algo;
12176 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12177 ut_params->auth_xform.auth.key.data = auth_key;
12178 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12180 /* Create Crypto session*/
12181 ut_params->sess = rte_cryptodev_sym_session_create(
12182 ts_params->session_mpool);
12184 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12185 &ut_params->auth_xform,
12186 ts_params->session_priv_mpool);
12188 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12194 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12196 const struct test_crypto_vector *reference,
12197 enum rte_crypto_auth_operation auth_op,
12198 enum rte_crypto_cipher_operation cipher_op)
12200 struct crypto_testsuite_params *ts_params = &testsuite_params;
12201 uint8_t cipher_key[reference->cipher_key.len + 1];
12202 uint8_t auth_key[reference->auth_key.len + 1];
12204 memcpy(cipher_key, reference->cipher_key.data,
12205 reference->cipher_key.len);
12206 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12208 /* Setup Authentication Parameters */
12209 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12210 ut_params->auth_xform.auth.op = auth_op;
12211 ut_params->auth_xform.auth.algo = reference->auth_algo;
12212 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12213 ut_params->auth_xform.auth.key.data = auth_key;
12214 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12216 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12217 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12218 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12220 ut_params->auth_xform.next = &ut_params->cipher_xform;
12222 /* Setup Cipher Parameters */
12223 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12224 ut_params->cipher_xform.next = NULL;
12225 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12226 ut_params->cipher_xform.cipher.op = cipher_op;
12227 ut_params->cipher_xform.cipher.key.data = cipher_key;
12228 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12229 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12230 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12233 /* Create Crypto session*/
12234 ut_params->sess = rte_cryptodev_sym_session_create(
12235 ts_params->session_mpool);
12237 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12238 &ut_params->auth_xform,
12239 ts_params->session_priv_mpool);
12241 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12247 create_auth_operation(struct crypto_testsuite_params *ts_params,
12248 struct crypto_unittest_params *ut_params,
12249 const struct test_crypto_vector *reference,
12250 unsigned int auth_generate)
12252 /* Generate Crypto op data structure */
12253 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12254 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12255 TEST_ASSERT_NOT_NULL(ut_params->op,
12256 "Failed to allocate pktmbuf offload");
12258 /* Set crypto operation data parameters */
12259 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12261 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12263 /* set crypto operation source mbuf */
12264 sym_op->m_src = ut_params->ibuf;
12267 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12268 ut_params->ibuf, reference->digest.len);
12270 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12271 "no room to append auth tag");
12273 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12274 ut_params->ibuf, reference->plaintext.len);
12277 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12279 memcpy(sym_op->auth.digest.data,
12280 reference->digest.data,
12281 reference->digest.len);
12283 debug_hexdump(stdout, "digest:",
12284 sym_op->auth.digest.data,
12285 reference->digest.len);
12287 sym_op->auth.data.length = reference->plaintext.len;
12288 sym_op->auth.data.offset = 0;
12294 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12295 struct crypto_unittest_params *ut_params,
12296 const struct test_crypto_vector *reference,
12297 unsigned int auth_generate)
12299 /* Generate Crypto op data structure */
12300 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12301 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12302 TEST_ASSERT_NOT_NULL(ut_params->op,
12303 "Failed to allocate pktmbuf offload");
12305 /* Set crypto operation data parameters */
12306 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12308 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12310 /* set crypto operation source mbuf */
12311 sym_op->m_src = ut_params->ibuf;
12314 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12315 ut_params->ibuf, reference->digest.len);
12317 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12318 "no room to append auth tag");
12320 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12321 ut_params->ibuf, reference->ciphertext.len);
12324 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12326 memcpy(sym_op->auth.digest.data,
12327 reference->digest.data,
12328 reference->digest.len);
12330 debug_hexdump(stdout, "digest:",
12331 sym_op->auth.digest.data,
12332 reference->digest.len);
12334 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12335 reference->iv.data, reference->iv.len);
12337 sym_op->cipher.data.length = 0;
12338 sym_op->cipher.data.offset = 0;
12340 sym_op->auth.data.length = reference->plaintext.len;
12341 sym_op->auth.data.offset = 0;
12347 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12348 struct crypto_unittest_params *ut_params,
12349 const struct test_crypto_vector *reference,
12350 unsigned int auth_generate)
12352 /* Generate Crypto op data structure */
12353 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12354 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12355 TEST_ASSERT_NOT_NULL(ut_params->op,
12356 "Failed to allocate pktmbuf offload");
12358 /* Set crypto operation data parameters */
12359 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12361 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12363 /* set crypto operation source mbuf */
12364 sym_op->m_src = ut_params->ibuf;
12367 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12368 ut_params->ibuf, reference->digest.len);
12370 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12371 "no room to append auth tag");
12373 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12374 ut_params->ibuf, reference->ciphertext.len);
12377 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12379 memcpy(sym_op->auth.digest.data,
12380 reference->digest.data,
12381 reference->digest.len);
12383 debug_hexdump(stdout, "digest:",
12384 sym_op->auth.digest.data,
12385 reference->digest.len);
12387 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12388 reference->iv.data, reference->iv.len);
12390 sym_op->cipher.data.length = reference->cipher_len;
12391 sym_op->cipher.data.offset = reference->cipher_offset;
12393 sym_op->auth.data.length = reference->plaintext.len;
12394 sym_op->auth.data.offset = reference->auth_offset;
12400 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12401 struct crypto_unittest_params *ut_params,
12402 const struct test_crypto_vector *reference)
12404 return create_auth_operation(ts_params, ut_params, reference, 0);
12408 create_auth_verify_GMAC_operation(
12409 struct crypto_testsuite_params *ts_params,
12410 struct crypto_unittest_params *ut_params,
12411 const struct test_crypto_vector *reference)
12413 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12417 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12418 struct crypto_unittest_params *ut_params,
12419 const struct test_crypto_vector *reference)
12421 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12425 test_authentication_verify_fail_when_data_corruption(
12426 struct crypto_testsuite_params *ts_params,
12427 struct crypto_unittest_params *ut_params,
12428 const struct test_crypto_vector *reference,
12429 unsigned int data_corrupted)
12433 uint8_t *plaintext;
12434 struct rte_cryptodev_info dev_info;
12436 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12437 uint64_t feat_flags = dev_info.feature_flags;
12439 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12440 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12441 printf("Device doesn't support RAW data-path APIs.\n");
12442 return TEST_SKIPPED;
12445 /* Verify the capabilities */
12446 struct rte_cryptodev_sym_capability_idx cap_idx;
12447 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12448 cap_idx.algo.auth = reference->auth_algo;
12449 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12451 return TEST_SKIPPED;
12454 /* Create session */
12455 retval = create_auth_session(ut_params,
12456 ts_params->valid_devs[0],
12458 RTE_CRYPTO_AUTH_OP_VERIFY);
12462 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12463 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12464 "Failed to allocate input buffer in mempool");
12466 /* clear mbuf payload */
12467 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12468 rte_pktmbuf_tailroom(ut_params->ibuf));
12470 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12471 reference->plaintext.len);
12472 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12473 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12475 debug_hexdump(stdout, "plaintext:", plaintext,
12476 reference->plaintext.len);
12478 /* Create operation */
12479 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12484 if (data_corrupted)
12485 data_corruption(plaintext);
12487 tag_corruption(plaintext, reference->plaintext.len);
12489 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12490 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12492 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12493 RTE_CRYPTO_OP_STATUS_SUCCESS,
12494 "authentication not failed");
12495 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12496 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12497 ut_params->op, 0, 1, 0, 0);
12499 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12501 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12508 test_authentication_verify_GMAC_fail_when_corruption(
12509 struct crypto_testsuite_params *ts_params,
12510 struct crypto_unittest_params *ut_params,
12511 const struct test_crypto_vector *reference,
12512 unsigned int data_corrupted)
12515 uint8_t *plaintext;
12516 struct rte_cryptodev_info dev_info;
12518 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12519 uint64_t feat_flags = dev_info.feature_flags;
12521 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12522 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12523 printf("Device doesn't support RAW data-path APIs.\n");
12524 return TEST_SKIPPED;
12527 /* Verify the capabilities */
12528 struct rte_cryptodev_sym_capability_idx cap_idx;
12529 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12530 cap_idx.algo.auth = reference->auth_algo;
12531 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12533 return TEST_SKIPPED;
12535 /* Create session */
12536 retval = create_auth_cipher_session(ut_params,
12537 ts_params->valid_devs[0],
12539 RTE_CRYPTO_AUTH_OP_VERIFY,
12540 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12544 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12545 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12546 "Failed to allocate input buffer in mempool");
12548 /* clear mbuf payload */
12549 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12550 rte_pktmbuf_tailroom(ut_params->ibuf));
12552 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12553 reference->plaintext.len);
12554 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12555 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12557 debug_hexdump(stdout, "plaintext:", plaintext,
12558 reference->plaintext.len);
12560 /* Create operation */
12561 retval = create_auth_verify_GMAC_operation(ts_params,
12568 if (data_corrupted)
12569 data_corruption(plaintext);
12571 tag_corruption(plaintext, reference->aad.len);
12573 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12574 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12576 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12577 RTE_CRYPTO_OP_STATUS_SUCCESS,
12578 "authentication not failed");
12579 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12580 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12581 ut_params->op, 0, 1, 0, 0);
12583 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12585 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12592 test_authenticated_decryption_fail_when_corruption(
12593 struct crypto_testsuite_params *ts_params,
12594 struct crypto_unittest_params *ut_params,
12595 const struct test_crypto_vector *reference,
12596 unsigned int data_corrupted)
12600 uint8_t *ciphertext;
12601 struct rte_cryptodev_info dev_info;
12603 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12604 uint64_t feat_flags = dev_info.feature_flags;
12606 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12607 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12608 printf("Device doesn't support RAW data-path APIs.\n");
12609 return TEST_SKIPPED;
12612 /* Verify the capabilities */
12613 struct rte_cryptodev_sym_capability_idx cap_idx;
12614 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12615 cap_idx.algo.auth = reference->auth_algo;
12616 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12618 return TEST_SKIPPED;
12619 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12620 cap_idx.algo.cipher = reference->crypto_algo;
12621 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12623 return TEST_SKIPPED;
12625 /* Create session */
12626 retval = create_auth_cipher_session(ut_params,
12627 ts_params->valid_devs[0],
12629 RTE_CRYPTO_AUTH_OP_VERIFY,
12630 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12634 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12635 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12636 "Failed to allocate input buffer in mempool");
12638 /* clear mbuf payload */
12639 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12640 rte_pktmbuf_tailroom(ut_params->ibuf));
12642 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12643 reference->ciphertext.len);
12644 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12645 memcpy(ciphertext, reference->ciphertext.data,
12646 reference->ciphertext.len);
12648 /* Create operation */
12649 retval = create_cipher_auth_verify_operation(ts_params,
12656 if (data_corrupted)
12657 data_corruption(ciphertext);
12659 tag_corruption(ciphertext, reference->ciphertext.len);
12661 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12662 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12664 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12665 RTE_CRYPTO_OP_STATUS_SUCCESS,
12666 "authentication not failed");
12667 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12668 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12669 ut_params->op, 1, 1, 0, 0);
12671 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12673 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12680 test_authenticated_encryt_with_esn(
12681 struct crypto_testsuite_params *ts_params,
12682 struct crypto_unittest_params *ut_params,
12683 const struct test_crypto_vector *reference)
12687 uint8_t *authciphertext, *plaintext, *auth_tag;
12688 uint16_t plaintext_pad_len;
12689 uint8_t cipher_key[reference->cipher_key.len + 1];
12690 uint8_t auth_key[reference->auth_key.len + 1];
12691 struct rte_cryptodev_info dev_info;
12693 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12694 uint64_t feat_flags = dev_info.feature_flags;
12696 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12697 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12698 printf("Device doesn't support RAW data-path APIs.\n");
12699 return TEST_SKIPPED;
12702 /* Verify the capabilities */
12703 struct rte_cryptodev_sym_capability_idx cap_idx;
12704 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12705 cap_idx.algo.auth = reference->auth_algo;
12706 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12708 return TEST_SKIPPED;
12709 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12710 cap_idx.algo.cipher = reference->crypto_algo;
12711 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12713 return TEST_SKIPPED;
12715 /* Create session */
12716 memcpy(cipher_key, reference->cipher_key.data,
12717 reference->cipher_key.len);
12718 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12720 /* Setup Cipher Parameters */
12721 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12722 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12723 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12724 ut_params->cipher_xform.cipher.key.data = cipher_key;
12725 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12726 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12727 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12729 ut_params->cipher_xform.next = &ut_params->auth_xform;
12731 /* Setup Authentication Parameters */
12732 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12733 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12734 ut_params->auth_xform.auth.algo = reference->auth_algo;
12735 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12736 ut_params->auth_xform.auth.key.data = auth_key;
12737 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12738 ut_params->auth_xform.next = NULL;
12740 /* Create Crypto session*/
12741 ut_params->sess = rte_cryptodev_sym_session_create(
12742 ts_params->session_mpool);
12744 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12746 &ut_params->cipher_xform,
12747 ts_params->session_priv_mpool);
12749 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12751 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12752 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12753 "Failed to allocate input buffer in mempool");
12755 /* clear mbuf payload */
12756 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12757 rte_pktmbuf_tailroom(ut_params->ibuf));
12759 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12760 reference->plaintext.len);
12761 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12762 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12764 /* Create operation */
12765 retval = create_cipher_auth_operation(ts_params,
12772 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12773 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12775 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12776 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12777 ut_params->op, 1, 1, 0, 0);
12779 ut_params->op = process_crypto_request(
12780 ts_params->valid_devs[0], ut_params->op);
12782 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12784 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12785 "crypto op processing failed");
12787 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12789 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12790 ut_params->op->sym->auth.data.offset);
12791 auth_tag = authciphertext + plaintext_pad_len;
12792 debug_hexdump(stdout, "ciphertext:", authciphertext,
12793 reference->ciphertext.len);
12794 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12796 /* Validate obuf */
12797 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12799 reference->ciphertext.data,
12800 reference->ciphertext.len,
12801 "Ciphertext data not as expected");
12803 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12805 reference->digest.data,
12806 reference->digest.len,
12807 "Generated digest not as expected");
12809 return TEST_SUCCESS;
12814 test_authenticated_decrypt_with_esn(
12815 struct crypto_testsuite_params *ts_params,
12816 struct crypto_unittest_params *ut_params,
12817 const struct test_crypto_vector *reference)
12821 uint8_t *ciphertext;
12822 uint8_t cipher_key[reference->cipher_key.len + 1];
12823 uint8_t auth_key[reference->auth_key.len + 1];
12824 struct rte_cryptodev_info dev_info;
12826 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12827 uint64_t feat_flags = dev_info.feature_flags;
12829 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12830 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12831 printf("Device doesn't support RAW data-path APIs.\n");
12832 return TEST_SKIPPED;
12835 /* Verify the capabilities */
12836 struct rte_cryptodev_sym_capability_idx cap_idx;
12837 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12838 cap_idx.algo.auth = reference->auth_algo;
12839 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12841 return TEST_SKIPPED;
12842 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12843 cap_idx.algo.cipher = reference->crypto_algo;
12844 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12846 return TEST_SKIPPED;
12848 /* Create session */
12849 memcpy(cipher_key, reference->cipher_key.data,
12850 reference->cipher_key.len);
12851 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12853 /* Setup Authentication Parameters */
12854 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12855 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12856 ut_params->auth_xform.auth.algo = reference->auth_algo;
12857 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12858 ut_params->auth_xform.auth.key.data = auth_key;
12859 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12860 ut_params->auth_xform.next = &ut_params->cipher_xform;
12862 /* Setup Cipher Parameters */
12863 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12864 ut_params->cipher_xform.next = NULL;
12865 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12866 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12867 ut_params->cipher_xform.cipher.key.data = cipher_key;
12868 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12869 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12870 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12872 /* Create Crypto session*/
12873 ut_params->sess = rte_cryptodev_sym_session_create(
12874 ts_params->session_mpool);
12876 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12878 &ut_params->auth_xform,
12879 ts_params->session_priv_mpool);
12881 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12883 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12884 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12885 "Failed to allocate input buffer in mempool");
12887 /* clear mbuf payload */
12888 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12889 rte_pktmbuf_tailroom(ut_params->ibuf));
12891 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12892 reference->ciphertext.len);
12893 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12894 memcpy(ciphertext, reference->ciphertext.data,
12895 reference->ciphertext.len);
12897 /* Create operation */
12898 retval = create_cipher_auth_verify_operation(ts_params,
12905 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12906 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12908 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12909 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12910 ut_params->op, 1, 1, 0, 0);
12912 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12915 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12916 TEST_ASSERT_EQUAL(ut_params->op->status,
12917 RTE_CRYPTO_OP_STATUS_SUCCESS,
12918 "crypto op processing passed");
12920 ut_params->obuf = ut_params->op->sym->m_src;
12921 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12927 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12928 const struct aead_test_data *tdata,
12929 void *digest_mem, uint64_t digest_phys)
12931 struct crypto_testsuite_params *ts_params = &testsuite_params;
12932 struct crypto_unittest_params *ut_params = &unittest_params;
12934 const unsigned int auth_tag_len = tdata->auth_tag.len;
12935 const unsigned int iv_len = tdata->iv.len;
12936 unsigned int aad_len = tdata->aad.len;
12937 unsigned int aad_len_pad = 0;
12939 /* Generate Crypto op data structure */
12940 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12941 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12942 TEST_ASSERT_NOT_NULL(ut_params->op,
12943 "Failed to allocate symmetric crypto operation struct");
12945 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12947 sym_op->aead.digest.data = digest_mem;
12949 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12950 "no room to append digest");
12952 sym_op->aead.digest.phys_addr = digest_phys;
12954 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12955 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12957 debug_hexdump(stdout, "digest:",
12958 sym_op->aead.digest.data,
12962 /* Append aad data */
12963 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12964 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12965 uint8_t *, IV_OFFSET);
12967 /* Copy IV 1 byte after the IV pointer, according to the API */
12968 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12970 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12972 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12973 ut_params->ibuf, aad_len);
12974 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12975 "no room to prepend aad");
12976 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12979 memset(sym_op->aead.aad.data, 0, aad_len);
12980 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12981 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12983 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12984 debug_hexdump(stdout, "aad:",
12985 sym_op->aead.aad.data, aad_len);
12987 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12988 uint8_t *, IV_OFFSET);
12990 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12992 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12994 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12995 ut_params->ibuf, aad_len_pad);
12996 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12997 "no room to prepend aad");
12998 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13001 memset(sym_op->aead.aad.data, 0, aad_len);
13002 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13004 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13005 debug_hexdump(stdout, "aad:",
13006 sym_op->aead.aad.data, aad_len);
13009 sym_op->aead.data.length = tdata->plaintext.len;
13010 sym_op->aead.data.offset = aad_len_pad;
13015 #define SGL_MAX_NO 16
13018 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13019 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13021 struct crypto_testsuite_params *ts_params = &testsuite_params;
13022 struct crypto_unittest_params *ut_params = &unittest_params;
13023 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13026 int to_trn_tbl[SGL_MAX_NO];
13028 unsigned int trn_data = 0;
13029 uint8_t *plaintext, *ciphertext, *auth_tag;
13030 struct rte_cryptodev_info dev_info;
13032 /* Verify the capabilities */
13033 struct rte_cryptodev_sym_capability_idx cap_idx;
13034 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13035 cap_idx.algo.aead = tdata->algo;
13036 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13038 return TEST_SKIPPED;
13040 /* OOP not supported with CPU crypto */
13041 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13042 return TEST_SKIPPED;
13044 /* Detailed check for the particular SGL support flag */
13045 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13047 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13048 if (sgl_in && (!(dev_info.feature_flags &
13049 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13050 return TEST_SKIPPED;
13052 uint64_t feat_flags = dev_info.feature_flags;
13054 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13055 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13056 printf("Device doesn't support RAW data-path APIs.\n");
13057 return TEST_SKIPPED;
13060 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13061 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13062 tdata->plaintext.len;
13063 /* Raw data path API does not support OOP */
13064 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13065 return TEST_SKIPPED;
13066 if (sgl_in && !sgl_out) {
13067 if (!(dev_info.feature_flags &
13068 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13069 return TEST_SKIPPED;
13070 } else if (!sgl_in && sgl_out) {
13071 if (!(dev_info.feature_flags &
13072 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13073 return TEST_SKIPPED;
13074 } else if (sgl_in && sgl_out) {
13075 if (!(dev_info.feature_flags &
13076 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13077 return TEST_SKIPPED;
13081 if (fragsz > tdata->plaintext.len)
13082 fragsz = tdata->plaintext.len;
13084 uint16_t plaintext_len = fragsz;
13085 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13087 if (fragsz_oop > tdata->plaintext.len)
13088 frag_size_oop = tdata->plaintext.len;
13091 void *digest_mem = NULL;
13093 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13095 if (tdata->plaintext.len % fragsz != 0) {
13096 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13099 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13104 * For out-op-place we need to alloc another mbuf
13107 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13108 rte_pktmbuf_append(ut_params->obuf,
13109 frag_size_oop + prepend_len);
13110 buf_oop = ut_params->obuf;
13113 /* Create AEAD session */
13114 retval = create_aead_session(ts_params->valid_devs[0],
13116 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13117 tdata->key.data, tdata->key.len,
13118 tdata->aad.len, tdata->auth_tag.len,
13123 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13125 /* clear mbuf payload */
13126 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13127 rte_pktmbuf_tailroom(ut_params->ibuf));
13129 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13132 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13134 trn_data += plaintext_len;
13136 buf = ut_params->ibuf;
13139 * Loop until no more fragments
13142 while (trn_data < tdata->plaintext.len) {
13144 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13145 (tdata->plaintext.len - trn_data) : fragsz;
13147 to_trn_tbl[ecx++] = to_trn;
13149 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13152 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13153 rte_pktmbuf_tailroom(buf));
13156 if (oop && !fragsz_oop) {
13157 buf_last_oop = buf_oop->next =
13158 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13159 buf_oop = buf_oop->next;
13160 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13161 0, rte_pktmbuf_tailroom(buf_oop));
13162 rte_pktmbuf_append(buf_oop, to_trn);
13165 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13168 memcpy(plaintext, tdata->plaintext.data + trn_data,
13170 trn_data += to_trn;
13171 if (trn_data == tdata->plaintext.len) {
13174 digest_mem = rte_pktmbuf_append(buf_oop,
13175 tdata->auth_tag.len);
13177 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13178 tdata->auth_tag.len);
13182 uint64_t digest_phys = 0;
13184 ut_params->ibuf->nb_segs = segs;
13187 if (fragsz_oop && oop) {
13191 if (frag_size_oop == tdata->plaintext.len) {
13192 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13193 tdata->auth_tag.len);
13195 digest_phys = rte_pktmbuf_iova_offset(
13197 tdata->plaintext.len + prepend_len);
13200 trn_data = frag_size_oop;
13201 while (trn_data < tdata->plaintext.len) {
13204 (tdata->plaintext.len - trn_data <
13206 (tdata->plaintext.len - trn_data) :
13209 to_trn_tbl[ecx++] = to_trn;
13211 buf_last_oop = buf_oop->next =
13212 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13213 buf_oop = buf_oop->next;
13214 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13215 0, rte_pktmbuf_tailroom(buf_oop));
13216 rte_pktmbuf_append(buf_oop, to_trn);
13218 trn_data += to_trn;
13220 if (trn_data == tdata->plaintext.len) {
13221 digest_mem = rte_pktmbuf_append(buf_oop,
13222 tdata->auth_tag.len);
13226 ut_params->obuf->nb_segs = segs;
13230 * Place digest at the end of the last buffer
13233 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13234 if (oop && buf_last_oop)
13235 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13237 if (!digest_mem && !oop) {
13238 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13239 + tdata->auth_tag.len);
13240 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13241 tdata->plaintext.len);
13244 /* Create AEAD operation */
13245 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13246 tdata, digest_mem, digest_phys);
13251 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13253 ut_params->op->sym->m_src = ut_params->ibuf;
13255 ut_params->op->sym->m_dst = ut_params->obuf;
13257 /* Process crypto operation */
13258 if (oop == IN_PLACE &&
13259 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13260 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13261 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13262 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13263 ut_params->op, 0, 0, 0, 0);
13265 TEST_ASSERT_NOT_NULL(
13266 process_crypto_request(ts_params->valid_devs[0],
13267 ut_params->op), "failed to process sym crypto op");
13269 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13270 "crypto op processing failed");
13273 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13274 uint8_t *, prepend_len);
13276 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13277 uint8_t *, prepend_len);
13281 fragsz = fragsz_oop;
13283 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13285 tdata->ciphertext.data,
13287 "Ciphertext data not as expected");
13289 buf = ut_params->op->sym->m_src->next;
13291 buf = ut_params->op->sym->m_dst->next;
13293 unsigned int off = fragsz;
13297 ciphertext = rte_pktmbuf_mtod(buf,
13300 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13302 tdata->ciphertext.data + off,
13304 "Ciphertext data not as expected");
13306 off += to_trn_tbl[ecx++];
13310 auth_tag = digest_mem;
13311 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13313 tdata->auth_tag.data,
13314 tdata->auth_tag.len,
13315 "Generated auth tag not as expected");
13321 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13323 return test_authenticated_encryption_SGL(
13324 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13328 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13330 return test_authenticated_encryption_SGL(
13331 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13335 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13337 return test_authenticated_encryption_SGL(
13338 &gcm_test_case_8, OUT_OF_PLACE, 400,
13339 gcm_test_case_8.plaintext.len);
13343 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13345 /* This test is not for OPENSSL PMD */
13346 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13347 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13348 return TEST_SKIPPED;
13350 return test_authenticated_encryption_SGL(
13351 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13355 test_authentication_verify_fail_when_data_corrupted(
13356 struct crypto_testsuite_params *ts_params,
13357 struct crypto_unittest_params *ut_params,
13358 const struct test_crypto_vector *reference)
13360 return test_authentication_verify_fail_when_data_corruption(
13361 ts_params, ut_params, reference, 1);
13365 test_authentication_verify_fail_when_tag_corrupted(
13366 struct crypto_testsuite_params *ts_params,
13367 struct crypto_unittest_params *ut_params,
13368 const struct test_crypto_vector *reference)
13370 return test_authentication_verify_fail_when_data_corruption(
13371 ts_params, ut_params, reference, 0);
13375 test_authentication_verify_GMAC_fail_when_data_corrupted(
13376 struct crypto_testsuite_params *ts_params,
13377 struct crypto_unittest_params *ut_params,
13378 const struct test_crypto_vector *reference)
13380 return test_authentication_verify_GMAC_fail_when_corruption(
13381 ts_params, ut_params, reference, 1);
13385 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13386 struct crypto_testsuite_params *ts_params,
13387 struct crypto_unittest_params *ut_params,
13388 const struct test_crypto_vector *reference)
13390 return test_authentication_verify_GMAC_fail_when_corruption(
13391 ts_params, ut_params, reference, 0);
13395 test_authenticated_decryption_fail_when_data_corrupted(
13396 struct crypto_testsuite_params *ts_params,
13397 struct crypto_unittest_params *ut_params,
13398 const struct test_crypto_vector *reference)
13400 return test_authenticated_decryption_fail_when_corruption(
13401 ts_params, ut_params, reference, 1);
13405 test_authenticated_decryption_fail_when_tag_corrupted(
13406 struct crypto_testsuite_params *ts_params,
13407 struct crypto_unittest_params *ut_params,
13408 const struct test_crypto_vector *reference)
13410 return test_authenticated_decryption_fail_when_corruption(
13411 ts_params, ut_params, reference, 0);
13415 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13417 return test_authentication_verify_fail_when_data_corrupted(
13418 &testsuite_params, &unittest_params,
13419 &hmac_sha1_test_crypto_vector);
13423 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13425 return test_authentication_verify_fail_when_tag_corrupted(
13426 &testsuite_params, &unittest_params,
13427 &hmac_sha1_test_crypto_vector);
13431 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13433 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13434 &testsuite_params, &unittest_params,
13435 &aes128_gmac_test_vector);
13439 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13441 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13442 &testsuite_params, &unittest_params,
13443 &aes128_gmac_test_vector);
13447 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13449 return test_authenticated_decryption_fail_when_data_corrupted(
13452 &aes128cbc_hmac_sha1_test_vector);
13456 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13458 return test_authenticated_decryption_fail_when_tag_corrupted(
13461 &aes128cbc_hmac_sha1_test_vector);
13465 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13467 return test_authenticated_encryt_with_esn(
13470 &aes128cbc_hmac_sha1_aad_test_vector);
13474 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13476 return test_authenticated_decrypt_with_esn(
13479 &aes128cbc_hmac_sha1_aad_test_vector);
13483 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13485 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13489 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13491 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13494 #ifdef RTE_CRYPTO_SCHEDULER
13496 /* global AESNI worker IDs for the scheduler test */
13497 uint8_t aesni_ids[2];
13500 scheduler_testsuite_setup(void)
13503 int32_t nb_devs, ret;
13504 char vdev_args[VDEV_ARGS_SIZE] = {""};
13505 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
13506 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
13507 uint16_t worker_core_count = 0;
13508 uint16_t socket_id = 0;
13510 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13511 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
13513 /* Identify the Worker Cores
13514 * Use 2 worker cores for the device args
13516 RTE_LCORE_FOREACH_WORKER(i) {
13517 if (worker_core_count > 1)
13519 snprintf(vdev_args, sizeof(vdev_args),
13520 "%s%d", temp_str, i);
13521 strcpy(temp_str, vdev_args);
13522 strlcat(temp_str, ";", sizeof(temp_str));
13523 worker_core_count++;
13524 socket_id = rte_lcore_to_socket_id(i);
13526 if (worker_core_count != 2) {
13527 RTE_LOG(ERR, USER1,
13528 "Cryptodev scheduler test require at least "
13529 "two worker cores to run. "
13530 "Please use the correct coremask.\n");
13531 return TEST_FAILED;
13533 strcpy(temp_str, vdev_args);
13534 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
13535 temp_str, socket_id);
13536 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
13537 nb_devs = rte_cryptodev_device_count_by_driver(
13538 rte_cryptodev_driver_id_get(
13539 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
13541 ret = rte_vdev_init(
13542 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
13544 TEST_ASSERT(ret == 0,
13545 "Failed to create instance %u of pmd : %s",
13546 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13549 return testsuite_setup();
13553 test_scheduler_attach_slave_op(void)
13555 struct crypto_testsuite_params *ts_params = &testsuite_params;
13556 uint8_t sched_id = ts_params->valid_devs[0];
13557 uint32_t nb_devs, i, nb_devs_attached = 0;
13559 char vdev_name[32];
13561 /* create 2 AESNI_MB if necessary */
13562 nb_devs = rte_cryptodev_device_count_by_driver(
13563 rte_cryptodev_driver_id_get(
13564 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13566 for (i = nb_devs; i < 2; i++) {
13567 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13568 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13570 ret = rte_vdev_init(vdev_name, NULL);
13572 TEST_ASSERT(ret == 0,
13573 "Failed to create instance %u of"
13575 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13579 /* attach 2 AESNI_MB cdevs */
13580 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13582 struct rte_cryptodev_info info;
13583 unsigned int session_size;
13585 rte_cryptodev_info_get(i, &info);
13586 if (info.driver_id != rte_cryptodev_driver_id_get(
13587 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13590 session_size = rte_cryptodev_sym_get_private_session_size(i);
13592 * Create the session mempool again, since now there are new devices
13593 * to use the mempool.
13595 if (ts_params->session_mpool) {
13596 rte_mempool_free(ts_params->session_mpool);
13597 ts_params->session_mpool = NULL;
13599 if (ts_params->session_priv_mpool) {
13600 rte_mempool_free(ts_params->session_priv_mpool);
13601 ts_params->session_priv_mpool = NULL;
13604 if (info.sym.max_nb_sessions != 0 &&
13605 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13606 RTE_LOG(ERR, USER1,
13607 "Device does not support "
13608 "at least %u sessions\n",
13610 return TEST_FAILED;
13613 * Create mempool with maximum number of sessions,
13614 * to include the session headers
13616 if (ts_params->session_mpool == NULL) {
13617 ts_params->session_mpool =
13618 rte_cryptodev_sym_session_pool_create(
13620 MAX_NB_SESSIONS, 0, 0, 0,
13622 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13623 "session mempool allocation failed");
13627 * Create mempool with maximum number of sessions,
13628 * to include device specific session private data
13630 if (ts_params->session_priv_mpool == NULL) {
13631 ts_params->session_priv_mpool = rte_mempool_create(
13632 "test_sess_mp_priv",
13635 0, 0, NULL, NULL, NULL,
13636 NULL, SOCKET_ID_ANY,
13639 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13640 "session mempool allocation failed");
13643 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13644 ts_params->qp_conf.mp_session_private =
13645 ts_params->session_priv_mpool;
13647 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13650 TEST_ASSERT(ret == 0,
13651 "Failed to attach device %u of pmd : %s", i,
13652 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13654 aesni_ids[nb_devs_attached] = (uint8_t)i;
13656 nb_devs_attached++;
13663 test_scheduler_detach_slave_op(void)
13665 struct crypto_testsuite_params *ts_params = &testsuite_params;
13666 uint8_t sched_id = ts_params->valid_devs[0];
13670 for (i = 0; i < 2; i++) {
13671 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13673 TEST_ASSERT(ret == 0,
13674 "Failed to detach device %u", aesni_ids[i]);
13681 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13683 struct crypto_testsuite_params *ts_params = &testsuite_params;
13684 uint8_t sched_id = ts_params->valid_devs[0];
13686 return rte_cryptodev_scheduler_mode_set(sched_id,
13691 test_scheduler_mode_roundrobin_op(void)
13693 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13694 0, "Failed to set roundrobin mode");
13700 test_scheduler_mode_multicore_op(void)
13702 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13703 0, "Failed to set multicore mode");
13709 test_scheduler_mode_failover_op(void)
13711 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13712 0, "Failed to set failover mode");
13718 test_scheduler_mode_pkt_size_distr_op(void)
13720 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13721 0, "Failed to set pktsize mode");
13727 scheduler_multicore_testsuite_setup(void)
13729 if (test_scheduler_attach_slave_op() < 0)
13730 return TEST_SKIPPED;
13731 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
13732 return TEST_SKIPPED;
13737 scheduler_roundrobin_testsuite_setup(void)
13739 if (test_scheduler_attach_slave_op() < 0)
13740 return TEST_SKIPPED;
13741 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
13742 return TEST_SKIPPED;
13747 scheduler_failover_testsuite_setup(void)
13749 if (test_scheduler_attach_slave_op() < 0)
13750 return TEST_SKIPPED;
13751 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
13752 return TEST_SKIPPED;
13757 scheduler_pkt_size_distr_testsuite_setup(void)
13759 if (test_scheduler_attach_slave_op() < 0)
13760 return TEST_SKIPPED;
13761 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
13762 return TEST_SKIPPED;
13767 scheduler_mode_testsuite_teardown(void)
13769 test_scheduler_detach_slave_op();
13772 #endif /* RTE_CRYPTO_SCHEDULER */
13774 static struct unit_test_suite end_testsuite = {
13775 .suite_name = NULL,
13778 .unit_test_suites = NULL
13781 #ifdef RTE_LIB_SECURITY
13782 static struct unit_test_suite pdcp_proto_testsuite = {
13783 .suite_name = "PDCP Proto Unit Test Suite",
13784 .setup = pdcp_proto_testsuite_setup,
13785 .unit_test_cases = {
13786 TEST_CASE_ST(ut_setup_security, ut_teardown,
13787 test_PDCP_PROTO_all),
13788 TEST_CASES_END() /**< NULL terminate unit test array */
13792 static struct unit_test_suite docsis_proto_testsuite = {
13793 .suite_name = "Docsis Proto Unit Test Suite",
13794 .setup = docsis_proto_testsuite_setup,
13795 .unit_test_cases = {
13796 TEST_CASE_ST(ut_setup_security, ut_teardown,
13797 test_DOCSIS_PROTO_all),
13798 TEST_CASES_END() /**< NULL terminate unit test array */
13803 static struct unit_test_suite cryptodev_gen_testsuite = {
13804 .suite_name = "Crypto General Unit Test Suite",
13805 .setup = crypto_gen_testsuite_setup,
13806 .unit_test_cases = {
13807 TEST_CASE_ST(ut_setup, ut_teardown,
13808 test_device_configure_invalid_dev_id),
13809 TEST_CASE_ST(ut_setup, ut_teardown,
13810 test_queue_pair_descriptor_setup),
13811 TEST_CASE_ST(ut_setup, ut_teardown,
13812 test_device_configure_invalid_queue_pair_ids),
13813 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13814 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13815 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13816 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13817 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
13818 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
13819 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
13820 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13821 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13822 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13823 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13824 TEST_CASES_END() /**< NULL terminate unit test array */
13828 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
13829 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
13830 .setup = negative_hmac_sha1_testsuite_setup,
13831 .unit_test_cases = {
13832 /** Negative tests */
13833 TEST_CASE_ST(ut_setup, ut_teardown,
13834 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13835 TEST_CASE_ST(ut_setup, ut_teardown,
13836 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13837 TEST_CASE_ST(ut_setup, ut_teardown,
13838 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13839 TEST_CASE_ST(ut_setup, ut_teardown,
13840 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13842 TEST_CASES_END() /**< NULL terminate unit test array */
13846 static struct unit_test_suite cryptodev_multi_session_testsuite = {
13847 .suite_name = "Multi Session Unit Test Suite",
13848 .setup = multi_session_testsuite_setup,
13849 .unit_test_cases = {
13850 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13851 TEST_CASE_ST(ut_setup, ut_teardown,
13852 test_multi_session_random_usage),
13854 TEST_CASES_END() /**< NULL terminate unit test array */
13858 static struct unit_test_suite cryptodev_null_testsuite = {
13859 .suite_name = "NULL Test Suite",
13860 .setup = null_testsuite_setup,
13861 .unit_test_cases = {
13862 TEST_CASE_ST(ut_setup, ut_teardown,
13863 test_null_invalid_operation),
13864 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13869 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
13870 .suite_name = "AES CCM Authenticated Test Suite",
13871 .setup = aes_ccm_auth_testsuite_setup,
13872 .unit_test_cases = {
13873 /** AES CCM Authenticated Encryption 128 bits key*/
13874 TEST_CASE_ST(ut_setup, ut_teardown,
13875 test_AES_CCM_authenticated_encryption_test_case_128_1),
13876 TEST_CASE_ST(ut_setup, ut_teardown,
13877 test_AES_CCM_authenticated_encryption_test_case_128_2),
13878 TEST_CASE_ST(ut_setup, ut_teardown,
13879 test_AES_CCM_authenticated_encryption_test_case_128_3),
13881 /** AES CCM Authenticated Decryption 128 bits key*/
13882 TEST_CASE_ST(ut_setup, ut_teardown,
13883 test_AES_CCM_authenticated_decryption_test_case_128_1),
13884 TEST_CASE_ST(ut_setup, ut_teardown,
13885 test_AES_CCM_authenticated_decryption_test_case_128_2),
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_AES_CCM_authenticated_decryption_test_case_128_3),
13889 /** AES CCM Authenticated Encryption 192 bits key */
13890 TEST_CASE_ST(ut_setup, ut_teardown,
13891 test_AES_CCM_authenticated_encryption_test_case_192_1),
13892 TEST_CASE_ST(ut_setup, ut_teardown,
13893 test_AES_CCM_authenticated_encryption_test_case_192_2),
13894 TEST_CASE_ST(ut_setup, ut_teardown,
13895 test_AES_CCM_authenticated_encryption_test_case_192_3),
13897 /** AES CCM Authenticated Decryption 192 bits key*/
13898 TEST_CASE_ST(ut_setup, ut_teardown,
13899 test_AES_CCM_authenticated_decryption_test_case_192_1),
13900 TEST_CASE_ST(ut_setup, ut_teardown,
13901 test_AES_CCM_authenticated_decryption_test_case_192_2),
13902 TEST_CASE_ST(ut_setup, ut_teardown,
13903 test_AES_CCM_authenticated_decryption_test_case_192_3),
13905 /** AES CCM Authenticated Encryption 256 bits key */
13906 TEST_CASE_ST(ut_setup, ut_teardown,
13907 test_AES_CCM_authenticated_encryption_test_case_256_1),
13908 TEST_CASE_ST(ut_setup, ut_teardown,
13909 test_AES_CCM_authenticated_encryption_test_case_256_2),
13910 TEST_CASE_ST(ut_setup, ut_teardown,
13911 test_AES_CCM_authenticated_encryption_test_case_256_3),
13913 /** AES CCM Authenticated Decryption 256 bits key*/
13914 TEST_CASE_ST(ut_setup, ut_teardown,
13915 test_AES_CCM_authenticated_decryption_test_case_256_1),
13916 TEST_CASE_ST(ut_setup, ut_teardown,
13917 test_AES_CCM_authenticated_decryption_test_case_256_2),
13918 TEST_CASE_ST(ut_setup, ut_teardown,
13919 test_AES_CCM_authenticated_decryption_test_case_256_3),
13924 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
13925 .suite_name = "AES GCM Authenticated Test Suite",
13926 .setup = aes_gcm_auth_testsuite_setup,
13927 .unit_test_cases = {
13928 /** AES GCM Authenticated Encryption */
13929 TEST_CASE_ST(ut_setup, ut_teardown,
13930 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13931 TEST_CASE_ST(ut_setup, ut_teardown,
13932 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13933 TEST_CASE_ST(ut_setup, ut_teardown,
13934 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13935 TEST_CASE_ST(ut_setup, ut_teardown,
13936 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13937 TEST_CASE_ST(ut_setup, ut_teardown,
13938 test_AES_GCM_authenticated_encryption_test_case_1),
13939 TEST_CASE_ST(ut_setup, ut_teardown,
13940 test_AES_GCM_authenticated_encryption_test_case_2),
13941 TEST_CASE_ST(ut_setup, ut_teardown,
13942 test_AES_GCM_authenticated_encryption_test_case_3),
13943 TEST_CASE_ST(ut_setup, ut_teardown,
13944 test_AES_GCM_authenticated_encryption_test_case_4),
13945 TEST_CASE_ST(ut_setup, ut_teardown,
13946 test_AES_GCM_authenticated_encryption_test_case_5),
13947 TEST_CASE_ST(ut_setup, ut_teardown,
13948 test_AES_GCM_authenticated_encryption_test_case_6),
13949 TEST_CASE_ST(ut_setup, ut_teardown,
13950 test_AES_GCM_authenticated_encryption_test_case_7),
13951 TEST_CASE_ST(ut_setup, ut_teardown,
13952 test_AES_GCM_authenticated_encryption_test_case_8),
13953 TEST_CASE_ST(ut_setup, ut_teardown,
13954 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13956 /** AES GCM Authenticated Decryption */
13957 TEST_CASE_ST(ut_setup, ut_teardown,
13958 test_AES_GCM_authenticated_decryption_test_case_1),
13959 TEST_CASE_ST(ut_setup, ut_teardown,
13960 test_AES_GCM_authenticated_decryption_test_case_2),
13961 TEST_CASE_ST(ut_setup, ut_teardown,
13962 test_AES_GCM_authenticated_decryption_test_case_3),
13963 TEST_CASE_ST(ut_setup, ut_teardown,
13964 test_AES_GCM_authenticated_decryption_test_case_4),
13965 TEST_CASE_ST(ut_setup, ut_teardown,
13966 test_AES_GCM_authenticated_decryption_test_case_5),
13967 TEST_CASE_ST(ut_setup, ut_teardown,
13968 test_AES_GCM_authenticated_decryption_test_case_6),
13969 TEST_CASE_ST(ut_setup, ut_teardown,
13970 test_AES_GCM_authenticated_decryption_test_case_7),
13971 TEST_CASE_ST(ut_setup, ut_teardown,
13972 test_AES_GCM_authenticated_decryption_test_case_8),
13973 TEST_CASE_ST(ut_setup, ut_teardown,
13974 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13976 /** AES GCM Authenticated Encryption 192 bits key */
13977 TEST_CASE_ST(ut_setup, ut_teardown,
13978 test_AES_GCM_auth_encryption_test_case_192_1),
13979 TEST_CASE_ST(ut_setup, ut_teardown,
13980 test_AES_GCM_auth_encryption_test_case_192_2),
13981 TEST_CASE_ST(ut_setup, ut_teardown,
13982 test_AES_GCM_auth_encryption_test_case_192_3),
13983 TEST_CASE_ST(ut_setup, ut_teardown,
13984 test_AES_GCM_auth_encryption_test_case_192_4),
13985 TEST_CASE_ST(ut_setup, ut_teardown,
13986 test_AES_GCM_auth_encryption_test_case_192_5),
13987 TEST_CASE_ST(ut_setup, ut_teardown,
13988 test_AES_GCM_auth_encryption_test_case_192_6),
13989 TEST_CASE_ST(ut_setup, ut_teardown,
13990 test_AES_GCM_auth_encryption_test_case_192_7),
13992 /** AES GCM Authenticated Decryption 192 bits key */
13993 TEST_CASE_ST(ut_setup, ut_teardown,
13994 test_AES_GCM_auth_decryption_test_case_192_1),
13995 TEST_CASE_ST(ut_setup, ut_teardown,
13996 test_AES_GCM_auth_decryption_test_case_192_2),
13997 TEST_CASE_ST(ut_setup, ut_teardown,
13998 test_AES_GCM_auth_decryption_test_case_192_3),
13999 TEST_CASE_ST(ut_setup, ut_teardown,
14000 test_AES_GCM_auth_decryption_test_case_192_4),
14001 TEST_CASE_ST(ut_setup, ut_teardown,
14002 test_AES_GCM_auth_decryption_test_case_192_5),
14003 TEST_CASE_ST(ut_setup, ut_teardown,
14004 test_AES_GCM_auth_decryption_test_case_192_6),
14005 TEST_CASE_ST(ut_setup, ut_teardown,
14006 test_AES_GCM_auth_decryption_test_case_192_7),
14008 /** AES GCM Authenticated Encryption 256 bits key */
14009 TEST_CASE_ST(ut_setup, ut_teardown,
14010 test_AES_GCM_auth_encryption_test_case_256_1),
14011 TEST_CASE_ST(ut_setup, ut_teardown,
14012 test_AES_GCM_auth_encryption_test_case_256_2),
14013 TEST_CASE_ST(ut_setup, ut_teardown,
14014 test_AES_GCM_auth_encryption_test_case_256_3),
14015 TEST_CASE_ST(ut_setup, ut_teardown,
14016 test_AES_GCM_auth_encryption_test_case_256_4),
14017 TEST_CASE_ST(ut_setup, ut_teardown,
14018 test_AES_GCM_auth_encryption_test_case_256_5),
14019 TEST_CASE_ST(ut_setup, ut_teardown,
14020 test_AES_GCM_auth_encryption_test_case_256_6),
14021 TEST_CASE_ST(ut_setup, ut_teardown,
14022 test_AES_GCM_auth_encryption_test_case_256_7),
14024 /** AES GCM Authenticated Decryption 256 bits key */
14025 TEST_CASE_ST(ut_setup, ut_teardown,
14026 test_AES_GCM_auth_decryption_test_case_256_1),
14027 TEST_CASE_ST(ut_setup, ut_teardown,
14028 test_AES_GCM_auth_decryption_test_case_256_2),
14029 TEST_CASE_ST(ut_setup, ut_teardown,
14030 test_AES_GCM_auth_decryption_test_case_256_3),
14031 TEST_CASE_ST(ut_setup, ut_teardown,
14032 test_AES_GCM_auth_decryption_test_case_256_4),
14033 TEST_CASE_ST(ut_setup, ut_teardown,
14034 test_AES_GCM_auth_decryption_test_case_256_5),
14035 TEST_CASE_ST(ut_setup, ut_teardown,
14036 test_AES_GCM_auth_decryption_test_case_256_6),
14037 TEST_CASE_ST(ut_setup, ut_teardown,
14038 test_AES_GCM_auth_decryption_test_case_256_7),
14040 /** AES GCM Authenticated Encryption big aad size */
14041 TEST_CASE_ST(ut_setup, ut_teardown,
14042 test_AES_GCM_auth_encryption_test_case_aad_1),
14043 TEST_CASE_ST(ut_setup, ut_teardown,
14044 test_AES_GCM_auth_encryption_test_case_aad_2),
14046 /** AES GCM Authenticated Decryption big aad size */
14047 TEST_CASE_ST(ut_setup, ut_teardown,
14048 test_AES_GCM_auth_decryption_test_case_aad_1),
14049 TEST_CASE_ST(ut_setup, ut_teardown,
14050 test_AES_GCM_auth_decryption_test_case_aad_2),
14052 /** Out of place tests */
14053 TEST_CASE_ST(ut_setup, ut_teardown,
14054 test_AES_GCM_authenticated_encryption_oop_test_case_1),
14055 TEST_CASE_ST(ut_setup, ut_teardown,
14056 test_AES_GCM_authenticated_decryption_oop_test_case_1),
14058 /** Session-less tests */
14059 TEST_CASE_ST(ut_setup, ut_teardown,
14060 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
14061 TEST_CASE_ST(ut_setup, ut_teardown,
14062 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
14068 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
14069 .suite_name = "AES GMAC Authentication Test Suite",
14070 .setup = aes_gmac_auth_testsuite_setup,
14071 .unit_test_cases = {
14072 TEST_CASE_ST(ut_setup, ut_teardown,
14073 test_AES_GMAC_authentication_test_case_1),
14074 TEST_CASE_ST(ut_setup, ut_teardown,
14075 test_AES_GMAC_authentication_verify_test_case_1),
14076 TEST_CASE_ST(ut_setup, ut_teardown,
14077 test_AES_GMAC_authentication_test_case_2),
14078 TEST_CASE_ST(ut_setup, ut_teardown,
14079 test_AES_GMAC_authentication_verify_test_case_2),
14080 TEST_CASE_ST(ut_setup, ut_teardown,
14081 test_AES_GMAC_authentication_test_case_3),
14082 TEST_CASE_ST(ut_setup, ut_teardown,
14083 test_AES_GMAC_authentication_verify_test_case_3),
14084 TEST_CASE_ST(ut_setup, ut_teardown,
14085 test_AES_GMAC_authentication_test_case_4),
14086 TEST_CASE_ST(ut_setup, ut_teardown,
14087 test_AES_GMAC_authentication_verify_test_case_4),
14088 TEST_CASE_ST(ut_setup, ut_teardown,
14089 test_AES_GMAC_authentication_SGL_40B),
14090 TEST_CASE_ST(ut_setup, ut_teardown,
14091 test_AES_GMAC_authentication_SGL_80B),
14092 TEST_CASE_ST(ut_setup, ut_teardown,
14093 test_AES_GMAC_authentication_SGL_2048B),
14094 TEST_CASE_ST(ut_setup, ut_teardown,
14095 test_AES_GMAC_authentication_SGL_2047B),
14101 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14102 .suite_name = "Chacha20-Poly1305 Test Suite",
14103 .setup = chacha20_poly1305_testsuite_setup,
14104 .unit_test_cases = {
14105 TEST_CASE_ST(ut_setup, ut_teardown,
14106 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14107 TEST_CASE_ST(ut_setup, ut_teardown,
14108 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14113 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14114 .suite_name = "SNOW 3G Test Suite",
14115 .setup = snow3g_testsuite_setup,
14116 .unit_test_cases = {
14117 /** SNOW 3G encrypt only (UEA2) */
14118 TEST_CASE_ST(ut_setup, ut_teardown,
14119 test_snow3g_encryption_test_case_1),
14120 TEST_CASE_ST(ut_setup, ut_teardown,
14121 test_snow3g_encryption_test_case_2),
14122 TEST_CASE_ST(ut_setup, ut_teardown,
14123 test_snow3g_encryption_test_case_3),
14124 TEST_CASE_ST(ut_setup, ut_teardown,
14125 test_snow3g_encryption_test_case_4),
14126 TEST_CASE_ST(ut_setup, ut_teardown,
14127 test_snow3g_encryption_test_case_5),
14129 TEST_CASE_ST(ut_setup, ut_teardown,
14130 test_snow3g_encryption_test_case_1_oop),
14131 TEST_CASE_ST(ut_setup, ut_teardown,
14132 test_snow3g_encryption_test_case_1_oop_sgl),
14133 TEST_CASE_ST(ut_setup, ut_teardown,
14134 test_snow3g_encryption_test_case_1_offset_oop),
14135 TEST_CASE_ST(ut_setup, ut_teardown,
14136 test_snow3g_decryption_test_case_1_oop),
14138 /** SNOW 3G generate auth, then encrypt (UEA2) */
14139 TEST_CASE_ST(ut_setup, ut_teardown,
14140 test_snow3g_auth_cipher_test_case_1),
14141 TEST_CASE_ST(ut_setup, ut_teardown,
14142 test_snow3g_auth_cipher_test_case_2),
14143 TEST_CASE_ST(ut_setup, ut_teardown,
14144 test_snow3g_auth_cipher_test_case_2_oop),
14145 TEST_CASE_ST(ut_setup, ut_teardown,
14146 test_snow3g_auth_cipher_part_digest_enc),
14147 TEST_CASE_ST(ut_setup, ut_teardown,
14148 test_snow3g_auth_cipher_part_digest_enc_oop),
14149 TEST_CASE_ST(ut_setup, ut_teardown,
14150 test_snow3g_auth_cipher_test_case_3_sgl),
14151 TEST_CASE_ST(ut_setup, ut_teardown,
14152 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14153 TEST_CASE_ST(ut_setup, ut_teardown,
14154 test_snow3g_auth_cipher_part_digest_enc_sgl),
14155 TEST_CASE_ST(ut_setup, ut_teardown,
14156 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14158 /** SNOW 3G decrypt (UEA2), then verify auth */
14159 TEST_CASE_ST(ut_setup, ut_teardown,
14160 test_snow3g_auth_cipher_verify_test_case_1),
14161 TEST_CASE_ST(ut_setup, ut_teardown,
14162 test_snow3g_auth_cipher_verify_test_case_2),
14163 TEST_CASE_ST(ut_setup, ut_teardown,
14164 test_snow3g_auth_cipher_verify_test_case_2_oop),
14165 TEST_CASE_ST(ut_setup, ut_teardown,
14166 test_snow3g_auth_cipher_verify_part_digest_enc),
14167 TEST_CASE_ST(ut_setup, ut_teardown,
14168 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14169 TEST_CASE_ST(ut_setup, ut_teardown,
14170 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14171 TEST_CASE_ST(ut_setup, ut_teardown,
14172 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14173 TEST_CASE_ST(ut_setup, ut_teardown,
14174 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14175 TEST_CASE_ST(ut_setup, ut_teardown,
14176 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14178 /** SNOW 3G decrypt only (UEA2) */
14179 TEST_CASE_ST(ut_setup, ut_teardown,
14180 test_snow3g_decryption_test_case_1),
14181 TEST_CASE_ST(ut_setup, ut_teardown,
14182 test_snow3g_decryption_test_case_2),
14183 TEST_CASE_ST(ut_setup, ut_teardown,
14184 test_snow3g_decryption_test_case_3),
14185 TEST_CASE_ST(ut_setup, ut_teardown,
14186 test_snow3g_decryption_test_case_4),
14187 TEST_CASE_ST(ut_setup, ut_teardown,
14188 test_snow3g_decryption_test_case_5),
14189 TEST_CASE_ST(ut_setup, ut_teardown,
14190 test_snow3g_decryption_with_digest_test_case_1),
14191 TEST_CASE_ST(ut_setup, ut_teardown,
14192 test_snow3g_hash_generate_test_case_1),
14193 TEST_CASE_ST(ut_setup, ut_teardown,
14194 test_snow3g_hash_generate_test_case_2),
14195 TEST_CASE_ST(ut_setup, ut_teardown,
14196 test_snow3g_hash_generate_test_case_3),
14198 /* Tests with buffers which length is not byte-aligned */
14199 TEST_CASE_ST(ut_setup, ut_teardown,
14200 test_snow3g_hash_generate_test_case_4),
14201 TEST_CASE_ST(ut_setup, ut_teardown,
14202 test_snow3g_hash_generate_test_case_5),
14203 TEST_CASE_ST(ut_setup, ut_teardown,
14204 test_snow3g_hash_generate_test_case_6),
14205 TEST_CASE_ST(ut_setup, ut_teardown,
14206 test_snow3g_hash_verify_test_case_1),
14207 TEST_CASE_ST(ut_setup, ut_teardown,
14208 test_snow3g_hash_verify_test_case_2),
14209 TEST_CASE_ST(ut_setup, ut_teardown,
14210 test_snow3g_hash_verify_test_case_3),
14212 /* Tests with buffers which length is not byte-aligned */
14213 TEST_CASE_ST(ut_setup, ut_teardown,
14214 test_snow3g_hash_verify_test_case_4),
14215 TEST_CASE_ST(ut_setup, ut_teardown,
14216 test_snow3g_hash_verify_test_case_5),
14217 TEST_CASE_ST(ut_setup, ut_teardown,
14218 test_snow3g_hash_verify_test_case_6),
14219 TEST_CASE_ST(ut_setup, ut_teardown,
14220 test_snow3g_cipher_auth_test_case_1),
14221 TEST_CASE_ST(ut_setup, ut_teardown,
14222 test_snow3g_auth_cipher_with_digest_test_case_1),
14227 static struct unit_test_suite cryptodev_zuc_testsuite = {
14228 .suite_name = "ZUC Test Suite",
14229 .setup = zuc_testsuite_setup,
14230 .unit_test_cases = {
14231 /** ZUC encrypt only (EEA3) */
14232 TEST_CASE_ST(ut_setup, ut_teardown,
14233 test_zuc_encryption_test_case_1),
14234 TEST_CASE_ST(ut_setup, ut_teardown,
14235 test_zuc_encryption_test_case_2),
14236 TEST_CASE_ST(ut_setup, ut_teardown,
14237 test_zuc_encryption_test_case_3),
14238 TEST_CASE_ST(ut_setup, ut_teardown,
14239 test_zuc_encryption_test_case_4),
14240 TEST_CASE_ST(ut_setup, ut_teardown,
14241 test_zuc_encryption_test_case_5),
14242 TEST_CASE_ST(ut_setup, ut_teardown,
14243 test_zuc_encryption_test_case_6_sgl),
14245 /** ZUC authenticate (EIA3) */
14246 TEST_CASE_ST(ut_setup, ut_teardown,
14247 test_zuc_hash_generate_test_case_1),
14248 TEST_CASE_ST(ut_setup, ut_teardown,
14249 test_zuc_hash_generate_test_case_2),
14250 TEST_CASE_ST(ut_setup, ut_teardown,
14251 test_zuc_hash_generate_test_case_3),
14252 TEST_CASE_ST(ut_setup, ut_teardown,
14253 test_zuc_hash_generate_test_case_4),
14254 TEST_CASE_ST(ut_setup, ut_teardown,
14255 test_zuc_hash_generate_test_case_5),
14256 TEST_CASE_ST(ut_setup, ut_teardown,
14257 test_zuc_hash_generate_test_case_6),
14258 TEST_CASE_ST(ut_setup, ut_teardown,
14259 test_zuc_hash_generate_test_case_7),
14260 TEST_CASE_ST(ut_setup, ut_teardown,
14261 test_zuc_hash_generate_test_case_8),
14263 /** ZUC alg-chain (EEA3/EIA3) */
14264 TEST_CASE_ST(ut_setup, ut_teardown,
14265 test_zuc_cipher_auth_test_case_1),
14266 TEST_CASE_ST(ut_setup, ut_teardown,
14267 test_zuc_cipher_auth_test_case_2),
14269 /** ZUC generate auth, then encrypt (EEA3) */
14270 TEST_CASE_ST(ut_setup, ut_teardown,
14271 test_zuc_auth_cipher_test_case_1),
14272 TEST_CASE_ST(ut_setup, ut_teardown,
14273 test_zuc_auth_cipher_test_case_1_oop),
14274 TEST_CASE_ST(ut_setup, ut_teardown,
14275 test_zuc_auth_cipher_test_case_1_sgl),
14276 TEST_CASE_ST(ut_setup, ut_teardown,
14277 test_zuc_auth_cipher_test_case_1_oop_sgl),
14279 /** ZUC decrypt (EEA3), then verify auth */
14280 TEST_CASE_ST(ut_setup, ut_teardown,
14281 test_zuc_auth_cipher_verify_test_case_1),
14282 TEST_CASE_ST(ut_setup, ut_teardown,
14283 test_zuc_auth_cipher_verify_test_case_1_oop),
14284 TEST_CASE_ST(ut_setup, ut_teardown,
14285 test_zuc_auth_cipher_verify_test_case_1_sgl),
14286 TEST_CASE_ST(ut_setup, ut_teardown,
14287 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14292 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14293 .suite_name = "HMAC_MD5 Authentication Test Suite",
14294 .setup = hmac_md5_auth_testsuite_setup,
14295 .unit_test_cases = {
14296 TEST_CASE_ST(ut_setup, ut_teardown,
14297 test_MD5_HMAC_generate_case_1),
14298 TEST_CASE_ST(ut_setup, ut_teardown,
14299 test_MD5_HMAC_verify_case_1),
14300 TEST_CASE_ST(ut_setup, ut_teardown,
14301 test_MD5_HMAC_generate_case_2),
14302 TEST_CASE_ST(ut_setup, ut_teardown,
14303 test_MD5_HMAC_verify_case_2),
14308 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14309 .suite_name = "Kasumi Test Suite",
14310 .setup = kasumi_testsuite_setup,
14311 .unit_test_cases = {
14312 /** KASUMI hash only (UIA1) */
14313 TEST_CASE_ST(ut_setup, ut_teardown,
14314 test_kasumi_hash_generate_test_case_1),
14315 TEST_CASE_ST(ut_setup, ut_teardown,
14316 test_kasumi_hash_generate_test_case_2),
14317 TEST_CASE_ST(ut_setup, ut_teardown,
14318 test_kasumi_hash_generate_test_case_3),
14319 TEST_CASE_ST(ut_setup, ut_teardown,
14320 test_kasumi_hash_generate_test_case_4),
14321 TEST_CASE_ST(ut_setup, ut_teardown,
14322 test_kasumi_hash_generate_test_case_5),
14323 TEST_CASE_ST(ut_setup, ut_teardown,
14324 test_kasumi_hash_generate_test_case_6),
14326 TEST_CASE_ST(ut_setup, ut_teardown,
14327 test_kasumi_hash_verify_test_case_1),
14328 TEST_CASE_ST(ut_setup, ut_teardown,
14329 test_kasumi_hash_verify_test_case_2),
14330 TEST_CASE_ST(ut_setup, ut_teardown,
14331 test_kasumi_hash_verify_test_case_3),
14332 TEST_CASE_ST(ut_setup, ut_teardown,
14333 test_kasumi_hash_verify_test_case_4),
14334 TEST_CASE_ST(ut_setup, ut_teardown,
14335 test_kasumi_hash_verify_test_case_5),
14337 /** KASUMI encrypt only (UEA1) */
14338 TEST_CASE_ST(ut_setup, ut_teardown,
14339 test_kasumi_encryption_test_case_1),
14340 TEST_CASE_ST(ut_setup, ut_teardown,
14341 test_kasumi_encryption_test_case_1_sgl),
14342 TEST_CASE_ST(ut_setup, ut_teardown,
14343 test_kasumi_encryption_test_case_1_oop),
14344 TEST_CASE_ST(ut_setup, ut_teardown,
14345 test_kasumi_encryption_test_case_1_oop_sgl),
14346 TEST_CASE_ST(ut_setup, ut_teardown,
14347 test_kasumi_encryption_test_case_2),
14348 TEST_CASE_ST(ut_setup, ut_teardown,
14349 test_kasumi_encryption_test_case_3),
14350 TEST_CASE_ST(ut_setup, ut_teardown,
14351 test_kasumi_encryption_test_case_4),
14352 TEST_CASE_ST(ut_setup, ut_teardown,
14353 test_kasumi_encryption_test_case_5),
14355 /** KASUMI decrypt only (UEA1) */
14356 TEST_CASE_ST(ut_setup, ut_teardown,
14357 test_kasumi_decryption_test_case_1),
14358 TEST_CASE_ST(ut_setup, ut_teardown,
14359 test_kasumi_decryption_test_case_2),
14360 TEST_CASE_ST(ut_setup, ut_teardown,
14361 test_kasumi_decryption_test_case_3),
14362 TEST_CASE_ST(ut_setup, ut_teardown,
14363 test_kasumi_decryption_test_case_4),
14364 TEST_CASE_ST(ut_setup, ut_teardown,
14365 test_kasumi_decryption_test_case_5),
14366 TEST_CASE_ST(ut_setup, ut_teardown,
14367 test_kasumi_decryption_test_case_1_oop),
14369 TEST_CASE_ST(ut_setup, ut_teardown,
14370 test_kasumi_cipher_auth_test_case_1),
14372 /** KASUMI generate auth, then encrypt (F8) */
14373 TEST_CASE_ST(ut_setup, ut_teardown,
14374 test_kasumi_auth_cipher_test_case_1),
14375 TEST_CASE_ST(ut_setup, ut_teardown,
14376 test_kasumi_auth_cipher_test_case_2),
14377 TEST_CASE_ST(ut_setup, ut_teardown,
14378 test_kasumi_auth_cipher_test_case_2_oop),
14379 TEST_CASE_ST(ut_setup, ut_teardown,
14380 test_kasumi_auth_cipher_test_case_2_sgl),
14381 TEST_CASE_ST(ut_setup, ut_teardown,
14382 test_kasumi_auth_cipher_test_case_2_oop_sgl),
14384 /** KASUMI decrypt (F8), then verify auth */
14385 TEST_CASE_ST(ut_setup, ut_teardown,
14386 test_kasumi_auth_cipher_verify_test_case_1),
14387 TEST_CASE_ST(ut_setup, ut_teardown,
14388 test_kasumi_auth_cipher_verify_test_case_2),
14389 TEST_CASE_ST(ut_setup, ut_teardown,
14390 test_kasumi_auth_cipher_verify_test_case_2_oop),
14391 TEST_CASE_ST(ut_setup, ut_teardown,
14392 test_kasumi_auth_cipher_verify_test_case_2_sgl),
14393 TEST_CASE_ST(ut_setup, ut_teardown,
14394 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14400 static struct unit_test_suite cryptodev_esn_testsuite = {
14401 .suite_name = "ESN Test Suite",
14402 .setup = esn_testsuite_setup,
14403 .unit_test_cases = {
14404 TEST_CASE_ST(ut_setup, ut_teardown,
14405 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14406 TEST_CASE_ST(ut_setup, ut_teardown,
14407 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14412 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
14413 .suite_name = "Negative AES GCM Test Suite",
14414 .setup = negative_aes_gcm_testsuite_setup,
14415 .unit_test_cases = {
14416 TEST_CASE_ST(ut_setup, ut_teardown,
14417 test_AES_GCM_auth_encryption_fail_iv_corrupt),
14418 TEST_CASE_ST(ut_setup, ut_teardown,
14419 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14420 TEST_CASE_ST(ut_setup, ut_teardown,
14421 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14422 TEST_CASE_ST(ut_setup, ut_teardown,
14423 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14424 TEST_CASE_ST(ut_setup, ut_teardown,
14425 test_AES_GCM_auth_encryption_fail_aad_corrupt),
14426 TEST_CASE_ST(ut_setup, ut_teardown,
14427 test_AES_GCM_auth_encryption_fail_tag_corrupt),
14428 TEST_CASE_ST(ut_setup, ut_teardown,
14429 test_AES_GCM_auth_decryption_fail_iv_corrupt),
14430 TEST_CASE_ST(ut_setup, ut_teardown,
14431 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
14432 TEST_CASE_ST(ut_setup, ut_teardown,
14433 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
14434 TEST_CASE_ST(ut_setup, ut_teardown,
14435 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
14436 TEST_CASE_ST(ut_setup, ut_teardown,
14437 test_AES_GCM_auth_decryption_fail_aad_corrupt),
14438 TEST_CASE_ST(ut_setup, ut_teardown,
14439 test_AES_GCM_auth_decryption_fail_tag_corrupt),
14445 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
14446 .suite_name = "Negative AES GMAC Test Suite",
14447 .setup = negative_aes_gmac_testsuite_setup,
14448 .unit_test_cases = {
14449 TEST_CASE_ST(ut_setup, ut_teardown,
14450 authentication_verify_AES128_GMAC_fail_data_corrupt),
14451 TEST_CASE_ST(ut_setup, ut_teardown,
14452 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14458 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
14459 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
14460 .setup = mixed_cipher_hash_testsuite_setup,
14461 .unit_test_cases = {
14462 /** AUTH AES CMAC + CIPHER AES CTR */
14463 TEST_CASE_ST(ut_setup, ut_teardown,
14464 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
14465 TEST_CASE_ST(ut_setup, ut_teardown,
14466 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14467 TEST_CASE_ST(ut_setup, ut_teardown,
14468 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14469 TEST_CASE_ST(ut_setup, ut_teardown,
14470 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14471 TEST_CASE_ST(ut_setup, ut_teardown,
14472 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
14473 TEST_CASE_ST(ut_setup, ut_teardown,
14474 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14475 TEST_CASE_ST(ut_setup, ut_teardown,
14476 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14477 TEST_CASE_ST(ut_setup, ut_teardown,
14478 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14480 /** AUTH ZUC + CIPHER SNOW3G */
14481 TEST_CASE_ST(ut_setup, ut_teardown,
14482 test_auth_zuc_cipher_snow_test_case_1),
14483 TEST_CASE_ST(ut_setup, ut_teardown,
14484 test_verify_auth_zuc_cipher_snow_test_case_1),
14485 /** AUTH AES CMAC + CIPHER SNOW3G */
14486 TEST_CASE_ST(ut_setup, ut_teardown,
14487 test_auth_aes_cmac_cipher_snow_test_case_1),
14488 TEST_CASE_ST(ut_setup, ut_teardown,
14489 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
14490 /** AUTH ZUC + CIPHER AES CTR */
14491 TEST_CASE_ST(ut_setup, ut_teardown,
14492 test_auth_zuc_cipher_aes_ctr_test_case_1),
14493 TEST_CASE_ST(ut_setup, ut_teardown,
14494 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
14495 /** AUTH SNOW3G + CIPHER AES CTR */
14496 TEST_CASE_ST(ut_setup, ut_teardown,
14497 test_auth_snow_cipher_aes_ctr_test_case_1),
14498 TEST_CASE_ST(ut_setup, ut_teardown,
14499 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
14500 /** AUTH SNOW3G + CIPHER ZUC */
14501 TEST_CASE_ST(ut_setup, ut_teardown,
14502 test_auth_snow_cipher_zuc_test_case_1),
14503 TEST_CASE_ST(ut_setup, ut_teardown,
14504 test_verify_auth_snow_cipher_zuc_test_case_1),
14505 /** AUTH AES CMAC + CIPHER ZUC */
14506 TEST_CASE_ST(ut_setup, ut_teardown,
14507 test_auth_aes_cmac_cipher_zuc_test_case_1),
14508 TEST_CASE_ST(ut_setup, ut_teardown,
14509 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
14511 /** AUTH NULL + CIPHER SNOW3G */
14512 TEST_CASE_ST(ut_setup, ut_teardown,
14513 test_auth_null_cipher_snow_test_case_1),
14514 TEST_CASE_ST(ut_setup, ut_teardown,
14515 test_verify_auth_null_cipher_snow_test_case_1),
14516 /** AUTH NULL + CIPHER ZUC */
14517 TEST_CASE_ST(ut_setup, ut_teardown,
14518 test_auth_null_cipher_zuc_test_case_1),
14519 TEST_CASE_ST(ut_setup, ut_teardown,
14520 test_verify_auth_null_cipher_zuc_test_case_1),
14521 /** AUTH SNOW3G + CIPHER NULL */
14522 TEST_CASE_ST(ut_setup, ut_teardown,
14523 test_auth_snow_cipher_null_test_case_1),
14524 TEST_CASE_ST(ut_setup, ut_teardown,
14525 test_verify_auth_snow_cipher_null_test_case_1),
14526 /** AUTH ZUC + CIPHER NULL */
14527 TEST_CASE_ST(ut_setup, ut_teardown,
14528 test_auth_zuc_cipher_null_test_case_1),
14529 TEST_CASE_ST(ut_setup, ut_teardown,
14530 test_verify_auth_zuc_cipher_null_test_case_1),
14531 /** AUTH NULL + CIPHER AES CTR */
14532 TEST_CASE_ST(ut_setup, ut_teardown,
14533 test_auth_null_cipher_aes_ctr_test_case_1),
14534 TEST_CASE_ST(ut_setup, ut_teardown,
14535 test_verify_auth_null_cipher_aes_ctr_test_case_1),
14536 /** AUTH AES CMAC + CIPHER NULL */
14537 TEST_CASE_ST(ut_setup, ut_teardown,
14538 test_auth_aes_cmac_cipher_null_test_case_1),
14539 TEST_CASE_ST(ut_setup, ut_teardown,
14540 test_verify_auth_aes_cmac_cipher_null_test_case_1),
14546 run_cryptodev_testsuite(const char *pmd_name)
14548 uint8_t ret, j, i = 0;
14549 struct unit_test_suite *static_suites[] = {
14550 &cryptodev_multi_session_testsuite,
14551 &cryptodev_null_testsuite,
14552 &cryptodev_aes_ccm_auth_testsuite,
14553 &cryptodev_aes_gcm_auth_testsuite,
14554 &cryptodev_aes_gmac_auth_testsuite,
14555 &cryptodev_snow3g_testsuite,
14556 &cryptodev_chacha20_poly1305_testsuite,
14557 &cryptodev_zuc_testsuite,
14558 &cryptodev_hmac_md5_auth_testsuite,
14559 &cryptodev_kasumi_testsuite,
14560 &cryptodev_esn_testsuite,
14561 &cryptodev_negative_aes_gcm_testsuite,
14562 &cryptodev_negative_aes_gmac_testsuite,
14563 &cryptodev_mixed_cipher_hash_testsuite,
14564 &cryptodev_negative_hmac_sha1_testsuite,
14565 &cryptodev_gen_testsuite,
14566 #ifdef RTE_LIB_SECURITY
14567 &pdcp_proto_testsuite,
14568 &docsis_proto_testsuite,
14572 static struct unit_test_suite ts = {
14573 .suite_name = "Cryptodev Unit Test Suite",
14574 .setup = testsuite_setup,
14575 .teardown = testsuite_teardown,
14576 .unit_test_cases = {TEST_CASES_END()}
14579 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
14581 if (gbl_driver_id == -1) {
14582 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
14583 return TEST_FAILED;
14586 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14587 RTE_DIM(static_suites));
14589 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14590 ret = unit_test_suite_runner(&ts);
14592 free(ts.unit_test_suites);
14597 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14599 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14603 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14605 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14609 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14611 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14615 test_cryptodev_cpu_aesni_mb(void)
14618 enum rte_security_session_action_type at = gbl_action_type;
14619 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14620 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14621 gbl_action_type = at;
14626 test_cryptodev_openssl(void)
14628 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14632 test_cryptodev_aesni_gcm(void)
14634 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14638 test_cryptodev_cpu_aesni_gcm(void)
14641 enum rte_security_session_action_type at = gbl_action_type;
14642 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14643 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14644 gbl_action_type = at;
14649 test_cryptodev_null(void)
14651 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14655 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14657 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14661 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14663 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14667 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14669 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14673 test_cryptodev_armv8(void)
14675 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14679 test_cryptodev_mrvl(void)
14681 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14684 #ifdef RTE_CRYPTO_SCHEDULER
14687 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14689 uint8_t ret, j, i = 0;
14690 static struct unit_test_suite scheduler_multicore = {
14691 .suite_name = "Scheduler Multicore Unit Test Suite",
14692 .setup = scheduler_multicore_testsuite_setup,
14693 .teardown = scheduler_mode_testsuite_teardown,
14694 .unit_test_cases = {
14695 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14696 TEST_CASE_ST(ut_setup, ut_teardown,
14697 test_AES_cipheronly_all),
14698 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14702 static struct unit_test_suite scheduler_round_robin = {
14703 .suite_name = "Scheduler Round Robin Unit Test Suite",
14704 .setup = scheduler_roundrobin_testsuite_setup,
14705 .teardown = scheduler_mode_testsuite_teardown,
14706 .unit_test_cases = {
14707 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14708 TEST_CASE_ST(ut_setup, ut_teardown,
14709 test_AES_cipheronly_all),
14710 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14714 static struct unit_test_suite scheduler_failover = {
14715 .suite_name = "Scheduler Failover Unit Test Suite",
14716 .setup = scheduler_failover_testsuite_setup,
14717 .teardown = scheduler_mode_testsuite_teardown,
14718 .unit_test_cases = {
14719 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14720 TEST_CASE_ST(ut_setup, ut_teardown,
14721 test_AES_cipheronly_all),
14722 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14726 static struct unit_test_suite scheduler_pkt_size_distr = {
14727 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
14728 .setup = scheduler_pkt_size_distr_testsuite_setup,
14729 .teardown = scheduler_mode_testsuite_teardown,
14730 .unit_test_cases = {
14731 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14732 TEST_CASE_ST(ut_setup, ut_teardown,
14733 test_AES_cipheronly_all),
14734 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14738 struct unit_test_suite *sched_mode_suites[] = {
14739 &scheduler_multicore,
14740 &scheduler_round_robin,
14741 &scheduler_failover,
14742 &scheduler_pkt_size_distr
14744 static struct unit_test_suite scheduler_config = {
14745 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
14746 .unit_test_cases = {
14747 TEST_CASE(test_scheduler_attach_slave_op),
14748 TEST_CASE(test_scheduler_mode_multicore_op),
14749 TEST_CASE(test_scheduler_mode_roundrobin_op),
14750 TEST_CASE(test_scheduler_mode_failover_op),
14751 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
14752 TEST_CASE(test_scheduler_detach_slave_op),
14754 TEST_CASES_END() /**< NULL terminate array */
14757 struct unit_test_suite *static_suites[] = {
14761 static struct unit_test_suite ts = {
14762 .suite_name = "Scheduler Unit Test Suite",
14763 .setup = scheduler_testsuite_setup,
14764 .teardown = testsuite_teardown,
14765 .unit_test_cases = {TEST_CASES_END()}
14768 gbl_driver_id = rte_cryptodev_driver_id_get(
14769 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14771 if (gbl_driver_id == -1) {
14772 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14773 return TEST_SKIPPED;
14776 if (rte_cryptodev_driver_id_get(
14777 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14778 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14779 return TEST_SKIPPED;
14782 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14783 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
14784 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
14785 RTE_DIM(sched_mode_suites));
14786 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14787 ret = unit_test_suite_runner(&ts);
14789 free(ts.unit_test_suites);
14793 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14798 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14800 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14804 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14806 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14810 test_cryptodev_ccp(void)
14812 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14816 test_cryptodev_octeontx(void)
14818 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14822 test_cryptodev_octeontx2(void)
14824 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14828 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14830 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14834 test_cryptodev_nitrox(void)
14836 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14840 test_cryptodev_bcmfs(void)
14842 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14846 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14850 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14851 ret = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14852 global_api_test_type = CRYPTODEV_API_TEST;
14857 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14858 test_cryptodev_qat_raw_api);
14859 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14860 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14861 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14862 test_cryptodev_cpu_aesni_mb);
14863 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14864 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14865 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14866 test_cryptodev_cpu_aesni_gcm);
14867 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14868 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14869 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14870 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14871 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14872 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14873 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14874 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14875 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14876 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14877 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14878 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14879 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14880 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14881 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);