1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
20 #include <rte_string_fns.h>
24 #ifdef RTE_CRYPTO_SCHEDULER
25 #include <rte_cryptodev_scheduler.h>
26 #include <rte_cryptodev_scheduler_operations.h>
29 #include <rte_lcore.h>
32 #include "test_cryptodev.h"
34 #include "test_cryptodev_blockcipher.h"
35 #include "test_cryptodev_aes_test_vectors.h"
36 #include "test_cryptodev_des_test_vectors.h"
37 #include "test_cryptodev_hash_test_vectors.h"
38 #include "test_cryptodev_kasumi_test_vectors.h"
39 #include "test_cryptodev_kasumi_hash_test_vectors.h"
40 #include "test_cryptodev_snow3g_test_vectors.h"
41 #include "test_cryptodev_snow3g_hash_test_vectors.h"
42 #include "test_cryptodev_zuc_test_vectors.h"
43 #include "test_cryptodev_aead_test_vectors.h"
44 #include "test_cryptodev_hmac_test_vectors.h"
45 #include "test_cryptodev_mixed_test_vectors.h"
46 #ifdef RTE_LIB_SECURITY
47 #include "test_cryptodev_security_ipsec.h"
48 #include "test_cryptodev_security_ipsec_test_vectors.h"
49 #include "test_cryptodev_security_pdcp_test_vectors.h"
50 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
51 #include "test_cryptodev_security_pdcp_test_func.h"
52 #include "test_cryptodev_security_docsis_test_vectors.h"
54 #define SDAP_DISABLED 0
55 #define SDAP_ENABLED 1
58 #define VDEV_ARGS_SIZE 100
59 #define MAX_NB_SESSIONS 4
61 #define MAX_DRV_SERVICE_CTX_SIZE 256
63 #define MAX_RAW_DEQUEUE_COUNT 65535
66 #define OUT_OF_PLACE 1
68 static int gbl_driver_id;
70 static enum rte_security_session_action_type gbl_action_type =
71 RTE_SECURITY_ACTION_TYPE_NONE;
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 struct crypto_unittest_params {
76 struct rte_crypto_sym_xform cipher_xform;
77 struct rte_crypto_sym_xform auth_xform;
78 struct rte_crypto_sym_xform aead_xform;
79 #ifdef RTE_LIB_SECURITY
80 struct rte_security_docsis_xform docsis_xform;
84 struct rte_cryptodev_sym_session *sess;
85 #ifdef RTE_LIB_SECURITY
86 struct rte_security_session *sec_session;
89 #ifdef RTE_LIB_SECURITY
90 enum rte_security_session_action_type type;
92 struct rte_crypto_op *op;
94 struct rte_mbuf *obuf, *ibuf;
99 #define ALIGN_POW2_ROUNDUP(num, align) \
100 (((num) + (align) - 1) & ~((align) - 1))
102 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
103 for (j = 0; j < num_child_ts; index++, j++) \
104 parent_ts.unit_test_suites[index] = child_ts[j]
106 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
107 for (j = 0; j < num_blk_types; index++, j++) \
108 parent_ts.unit_test_suites[index] = \
109 build_blockcipher_test_suite(blk_types[j])
111 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
112 for (j = index; j < index + num_blk_types; j++) \
113 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
116 * Forward declarations.
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 struct crypto_unittest_params *ut_params,
126 struct crypto_testsuite_params *ts_param,
127 const uint8_t *cipher,
128 const uint8_t *digest,
132 security_proto_supported(enum rte_security_session_action_type action,
133 enum rte_security_session_protocol proto);
136 dev_configure_and_start(uint64_t ff_disable);
138 static struct rte_mbuf *
139 setup_test_string(struct rte_mempool *mpool,
140 const char *string, size_t len, uint8_t blocksize)
142 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
143 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
148 memset(m->buf_addr, 0, m->buf_len);
149 dst = rte_pktmbuf_append(m, t_len);
155 rte_memcpy(dst, string, t_len);
157 memset(dst, 0, t_len);
163 /* Get number of bytes in X bits (rounding up) */
165 ceil_byte_length(uint32_t num_bits)
168 return ((num_bits >> 3) + 1);
170 return (num_bits >> 3);
174 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
175 uint8_t is_op_success)
177 struct rte_crypto_op *op = user_data;
178 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
179 RTE_CRYPTO_OP_STATUS_ERROR;
183 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
184 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
185 uint8_t len_in_bits, uint8_t cipher_iv_len)
187 struct rte_crypto_sym_op *sop = op->sym;
188 struct rte_crypto_op *ret_op = NULL;
189 struct rte_crypto_vec data_vec[UINT8_MAX];
190 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
191 union rte_crypto_sym_ofs ofs;
192 struct rte_crypto_sym_vec vec;
193 struct rte_crypto_sgl sgl;
195 union rte_cryptodev_session_ctx sess;
197 struct rte_crypto_raw_dp_ctx *ctx;
198 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
202 int ctx_service_size;
204 int enqueue_status, dequeue_status;
206 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
207 if (ctx_service_size < 0) {
208 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
212 ctx = malloc(ctx_service_size);
214 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
218 /* Both are enums, setting crypto_sess will suit any session type */
219 sess.crypto_sess = op->sym->session;
221 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
222 op->sess_type, sess, 0) < 0) {
223 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
229 aad_auth_iv.iova = 0;
230 aad_auth_iv.va = NULL;
237 vec.digest = &digest;
238 vec.aad = &aad_auth_iv;
239 vec.status = &status;
243 if (is_cipher && is_auth) {
244 cipher_offset = sop->cipher.data.offset;
245 cipher_len = sop->cipher.data.length;
246 auth_offset = sop->auth.data.offset;
247 auth_len = sop->auth.data.length;
248 max_len = RTE_MAX(cipher_offset + cipher_len,
249 auth_offset + auth_len);
251 max_len = max_len >> 3;
252 cipher_offset = cipher_offset >> 3;
253 auth_offset = auth_offset >> 3;
254 cipher_len = cipher_len >> 3;
255 auth_len = auth_len >> 3;
257 ofs.ofs.cipher.head = cipher_offset;
258 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
259 ofs.ofs.auth.head = auth_offset;
260 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
261 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
262 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
263 aad_auth_iv.va = rte_crypto_op_ctod_offset(
264 op, void *, IV_OFFSET + cipher_iv_len);
265 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
267 digest.va = (void *)sop->auth.digest.data;
268 digest.iova = sop->auth.digest.phys_addr;
270 } else if (is_cipher) {
271 cipher_offset = sop->cipher.data.offset;
272 cipher_len = sop->cipher.data.length;
273 max_len = cipher_len + cipher_offset;
275 max_len = max_len >> 3;
276 cipher_offset = cipher_offset >> 3;
277 cipher_len = cipher_len >> 3;
279 ofs.ofs.cipher.head = cipher_offset;
280 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
281 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
282 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
284 } else if (is_auth) {
285 auth_offset = sop->auth.data.offset;
286 auth_len = sop->auth.data.length;
287 max_len = auth_len + auth_offset;
289 max_len = max_len >> 3;
290 auth_offset = auth_offset >> 3;
291 auth_len = auth_len >> 3;
293 ofs.ofs.auth.head = auth_offset;
294 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
295 aad_auth_iv.va = rte_crypto_op_ctod_offset(
296 op, void *, IV_OFFSET + cipher_iv_len);
297 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
299 digest.va = (void *)sop->auth.digest.data;
300 digest.iova = sop->auth.digest.phys_addr;
303 cipher_offset = sop->aead.data.offset;
304 cipher_len = sop->aead.data.length;
305 max_len = cipher_len + cipher_offset;
307 max_len = max_len >> 3;
308 cipher_offset = cipher_offset >> 3;
309 cipher_len = cipher_len >> 3;
311 ofs.ofs.cipher.head = cipher_offset;
312 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
313 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
314 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
315 aad_auth_iv.va = (void *)sop->aead.aad.data;
316 aad_auth_iv.iova = sop->aead.aad.phys_addr;
317 digest.va = (void *)sop->aead.digest.data;
318 digest.iova = sop->aead.digest.phys_addr;
321 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
322 data_vec, RTE_DIM(data_vec));
323 if (n < 0 || n > sop->m_src->nb_segs) {
324 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
330 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
331 &enqueue_status) < 1) {
332 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
336 if (enqueue_status == 0) {
337 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
339 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
342 } else if (enqueue_status < 0) {
343 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
348 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
349 n = rte_cryptodev_raw_dequeue_burst(ctx,
350 NULL, 1, post_process_raw_dp_op,
351 (void **)&ret_op, 0, &n_success,
353 if (dequeue_status < 0) {
354 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
361 if (n == 1 && dequeue_status == 0) {
362 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
363 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
368 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
369 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
370 RTE_CRYPTO_OP_STATUS_SUCCESS;
377 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
380 struct rte_crypto_sym_op *sop;
381 union rte_crypto_sym_ofs ofs;
382 struct rte_crypto_sgl sgl;
383 struct rte_crypto_sym_vec symvec;
384 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
385 struct rte_crypto_vec vec[UINT8_MAX];
389 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
390 sop->aead.data.length, vec, RTE_DIM(vec));
392 if (n < 0 || n != sop->m_src->nb_segs) {
393 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
401 symvec.digest = &digest_ptr;
402 symvec.aad = &aad_ptr;
406 /* for CPU crypto the IOVA address is not required */
407 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
408 digest_ptr.va = (void *)sop->aead.digest.data;
409 aad_ptr.va = (void *)sop->aead.aad.data;
413 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
417 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
419 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
423 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
426 struct rte_crypto_sym_op *sop;
427 union rte_crypto_sym_ofs ofs;
428 struct rte_crypto_sgl sgl;
429 struct rte_crypto_sym_vec symvec;
430 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
431 struct rte_crypto_vec vec[UINT8_MAX];
435 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
436 sop->auth.data.length, vec, RTE_DIM(vec));
438 if (n < 0 || n != sop->m_src->nb_segs) {
439 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
447 symvec.digest = &digest_ptr;
451 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
452 digest_ptr.va = (void *)sop->auth.digest.data;
455 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
456 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
457 (sop->cipher.data.offset + sop->cipher.data.length);
459 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
463 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
465 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
468 static struct rte_crypto_op *
469 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
472 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
474 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
475 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
481 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
484 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
485 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
492 static struct crypto_testsuite_params testsuite_params = { NULL };
493 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
494 static struct crypto_unittest_params unittest_params;
497 testsuite_setup(void)
499 struct crypto_testsuite_params *ts_params = &testsuite_params;
500 struct rte_cryptodev_info info;
501 uint32_t i = 0, nb_devs, dev_id;
504 memset(ts_params, 0, sizeof(*ts_params));
506 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
507 if (ts_params->mbuf_pool == NULL) {
508 /* Not already created so create */
509 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
511 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
513 if (ts_params->mbuf_pool == NULL) {
514 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
519 ts_params->large_mbuf_pool = rte_mempool_lookup(
520 "CRYPTO_LARGE_MBUFPOOL");
521 if (ts_params->large_mbuf_pool == NULL) {
522 /* Not already created so create */
523 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
524 "CRYPTO_LARGE_MBUFPOOL",
527 if (ts_params->large_mbuf_pool == NULL) {
529 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
534 ts_params->op_mpool = rte_crypto_op_pool_create(
535 "MBUF_CRYPTO_SYM_OP_POOL",
536 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
537 NUM_MBUFS, MBUF_CACHE_SIZE,
539 sizeof(struct rte_crypto_sym_xform) +
542 if (ts_params->op_mpool == NULL) {
543 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
547 nb_devs = rte_cryptodev_count();
549 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
553 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
554 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
555 rte_cryptodev_driver_name_get(gbl_driver_id));
559 /* Create list of valid crypto devs */
560 for (i = 0; i < nb_devs; i++) {
561 rte_cryptodev_info_get(i, &info);
562 if (info.driver_id == gbl_driver_id)
563 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
566 if (ts_params->valid_dev_count < 1)
569 /* Set up all the qps on the first of the valid devices found */
571 dev_id = ts_params->valid_devs[0];
573 rte_cryptodev_info_get(dev_id, &info);
575 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
576 ts_params->conf.socket_id = SOCKET_ID_ANY;
577 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
579 unsigned int session_size =
580 rte_cryptodev_sym_get_private_session_size(dev_id);
582 #ifdef RTE_LIB_SECURITY
583 unsigned int security_session_size = rte_security_session_get_size(
584 rte_cryptodev_get_sec_ctx(dev_id));
586 if (session_size < security_session_size)
587 session_size = security_session_size;
590 * Create mempool with maximum number of sessions.
592 if (info.sym.max_nb_sessions != 0 &&
593 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
594 RTE_LOG(ERR, USER1, "Device does not support "
595 "at least %u sessions\n",
600 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
601 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
603 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
604 "session mempool allocation failed");
606 ts_params->session_priv_mpool = rte_mempool_create(
610 0, 0, NULL, NULL, NULL,
613 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
614 "session mempool allocation failed");
618 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
620 "Failed to configure cryptodev %u with %u qps",
621 dev_id, ts_params->conf.nb_queue_pairs);
623 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
624 ts_params->qp_conf.mp_session = ts_params->session_mpool;
625 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
627 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
628 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
629 dev_id, qp_id, &ts_params->qp_conf,
630 rte_cryptodev_socket_id(dev_id)),
631 "Failed to setup queue pair %u on cryptodev %u",
639 testsuite_teardown(void)
641 struct crypto_testsuite_params *ts_params = &testsuite_params;
644 if (ts_params->mbuf_pool != NULL) {
645 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
646 rte_mempool_avail_count(ts_params->mbuf_pool));
649 if (ts_params->op_mpool != NULL) {
650 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
651 rte_mempool_avail_count(ts_params->op_mpool));
654 /* Free session mempools */
655 if (ts_params->session_priv_mpool != NULL) {
656 rte_mempool_free(ts_params->session_priv_mpool);
657 ts_params->session_priv_mpool = NULL;
660 if (ts_params->session_mpool != NULL) {
661 rte_mempool_free(ts_params->session_mpool);
662 ts_params->session_mpool = NULL;
665 res = rte_cryptodev_close(ts_params->valid_devs[0]);
667 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
671 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
672 const int *algs, uint16_t num_algs)
674 uint8_t dev_id = testsuite_params.valid_devs[0];
675 bool some_alg_supported = FALSE;
678 for (i = 0; i < num_algs && !some_alg_supported; i++) {
679 struct rte_cryptodev_sym_capability_idx alg = {
682 if (rte_cryptodev_sym_capability_get(dev_id,
684 some_alg_supported = TRUE;
686 if (!some_alg_supported)
693 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
694 uint16_t num_ciphers)
696 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
697 (const int *) ciphers, num_ciphers);
701 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
704 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
705 (const int *) auths, num_auths);
709 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
712 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
713 (const int *) aeads, num_aeads);
717 null_testsuite_setup(void)
719 struct crypto_testsuite_params *ts_params = &testsuite_params;
720 uint8_t dev_id = ts_params->valid_devs[0];
721 struct rte_cryptodev_info dev_info;
722 const enum rte_crypto_cipher_algorithm ciphers[] = {
723 RTE_CRYPTO_CIPHER_NULL
725 const enum rte_crypto_auth_algorithm auths[] = {
729 rte_cryptodev_info_get(dev_id, &dev_info);
731 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
732 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
733 "testsuite not met\n");
737 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
738 && check_auth_capabilities_supported(auths,
739 RTE_DIM(auths)) != 0) {
740 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
741 "testsuite not met\n");
749 crypto_gen_testsuite_setup(void)
751 struct crypto_testsuite_params *ts_params = &testsuite_params;
752 uint8_t dev_id = ts_params->valid_devs[0];
753 struct rte_cryptodev_info dev_info;
755 rte_cryptodev_info_get(dev_id, &dev_info);
757 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
758 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
759 "testsuite not met\n");
766 #ifdef RTE_LIB_SECURITY
768 ipsec_proto_testsuite_setup(void)
770 struct crypto_testsuite_params *ts_params = &testsuite_params;
771 struct crypto_unittest_params *ut_params = &unittest_params;
772 struct rte_cryptodev_info dev_info;
775 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
777 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
778 RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
779 "testsuite not met\n");
783 /* Reconfigure to enable security */
784 ret = dev_configure_and_start(0);
785 if (ret != TEST_SUCCESS)
788 /* Set action type */
789 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
791 if (security_proto_supported(
792 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
793 RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
794 RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
800 * Stop the device. Device would be started again by individual test
801 * case setup routine.
803 rte_cryptodev_stop(ts_params->valid_devs[0]);
809 pdcp_proto_testsuite_setup(void)
811 struct crypto_testsuite_params *ts_params = &testsuite_params;
812 uint8_t dev_id = ts_params->valid_devs[0];
813 struct rte_cryptodev_info dev_info;
814 const enum rte_crypto_cipher_algorithm ciphers[] = {
815 RTE_CRYPTO_CIPHER_NULL,
816 RTE_CRYPTO_CIPHER_AES_CTR,
817 RTE_CRYPTO_CIPHER_ZUC_EEA3,
818 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
820 const enum rte_crypto_auth_algorithm auths[] = {
821 RTE_CRYPTO_AUTH_NULL,
822 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
823 RTE_CRYPTO_AUTH_AES_CMAC,
824 RTE_CRYPTO_AUTH_ZUC_EIA3
827 rte_cryptodev_info_get(dev_id, &dev_info);
829 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
830 !(dev_info.feature_flags &
831 RTE_CRYPTODEV_FF_SECURITY)) {
832 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
833 "testsuite not met\n");
837 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
838 && check_auth_capabilities_supported(auths,
839 RTE_DIM(auths)) != 0) {
840 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
841 "testsuite not met\n");
849 docsis_proto_testsuite_setup(void)
851 struct crypto_testsuite_params *ts_params = &testsuite_params;
852 uint8_t dev_id = ts_params->valid_devs[0];
853 struct rte_cryptodev_info dev_info;
854 const enum rte_crypto_cipher_algorithm ciphers[] = {
855 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
858 rte_cryptodev_info_get(dev_id, &dev_info);
860 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
861 !(dev_info.feature_flags &
862 RTE_CRYPTODEV_FF_SECURITY)) {
863 RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
864 "Proto testsuite not met\n");
868 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
869 RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
870 "testsuite not met\n");
879 aes_ccm_auth_testsuite_setup(void)
881 struct crypto_testsuite_params *ts_params = &testsuite_params;
882 uint8_t dev_id = ts_params->valid_devs[0];
883 struct rte_cryptodev_info dev_info;
884 const enum rte_crypto_aead_algorithm aeads[] = {
885 RTE_CRYPTO_AEAD_AES_CCM
888 rte_cryptodev_info_get(dev_id, &dev_info);
890 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
891 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
892 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
893 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
894 "testsuite not met\n");
898 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
899 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
900 "testsuite not met\n");
908 aes_gcm_auth_testsuite_setup(void)
910 struct crypto_testsuite_params *ts_params = &testsuite_params;
911 uint8_t dev_id = ts_params->valid_devs[0];
912 struct rte_cryptodev_info dev_info;
913 const enum rte_crypto_aead_algorithm aeads[] = {
914 RTE_CRYPTO_AEAD_AES_GCM
917 rte_cryptodev_info_get(dev_id, &dev_info);
919 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
920 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
921 "testsuite not met\n");
925 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
926 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
927 "testsuite not met\n");
935 aes_gmac_auth_testsuite_setup(void)
937 struct crypto_testsuite_params *ts_params = &testsuite_params;
938 uint8_t dev_id = ts_params->valid_devs[0];
939 struct rte_cryptodev_info dev_info;
940 const enum rte_crypto_auth_algorithm auths[] = {
941 RTE_CRYPTO_AUTH_AES_GMAC
944 rte_cryptodev_info_get(dev_id, &dev_info);
946 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
947 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
948 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
949 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
950 "testsuite not met\n");
954 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
955 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
956 "testsuite not met\n");
964 chacha20_poly1305_testsuite_setup(void)
966 struct crypto_testsuite_params *ts_params = &testsuite_params;
967 uint8_t dev_id = ts_params->valid_devs[0];
968 struct rte_cryptodev_info dev_info;
969 const enum rte_crypto_aead_algorithm aeads[] = {
970 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
973 rte_cryptodev_info_get(dev_id, &dev_info);
975 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
976 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
977 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
978 RTE_LOG(INFO, USER1, "Feature flag requirements for "
979 "Chacha20-Poly1305 testsuite not met\n");
983 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
984 RTE_LOG(INFO, USER1, "Capability requirements for "
985 "Chacha20-Poly1305 testsuite not met\n");
993 snow3g_testsuite_setup(void)
995 struct crypto_testsuite_params *ts_params = &testsuite_params;
996 uint8_t dev_id = ts_params->valid_devs[0];
997 struct rte_cryptodev_info dev_info;
998 const enum rte_crypto_cipher_algorithm ciphers[] = {
999 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1002 const enum rte_crypto_auth_algorithm auths[] = {
1003 RTE_CRYPTO_AUTH_SNOW3G_UIA2
1006 rte_cryptodev_info_get(dev_id, &dev_info);
1008 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1009 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1010 "testsuite not met\n");
1011 return TEST_SKIPPED;
1014 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1015 && check_auth_capabilities_supported(auths,
1016 RTE_DIM(auths)) != 0) {
1017 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1018 "testsuite not met\n");
1019 return TEST_SKIPPED;
1026 zuc_testsuite_setup(void)
1028 struct crypto_testsuite_params *ts_params = &testsuite_params;
1029 uint8_t dev_id = ts_params->valid_devs[0];
1030 struct rte_cryptodev_info dev_info;
1031 const enum rte_crypto_cipher_algorithm ciphers[] = {
1032 RTE_CRYPTO_CIPHER_ZUC_EEA3
1034 const enum rte_crypto_auth_algorithm auths[] = {
1035 RTE_CRYPTO_AUTH_ZUC_EIA3
1038 rte_cryptodev_info_get(dev_id, &dev_info);
1040 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1041 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1042 "testsuite not met\n");
1043 return TEST_SKIPPED;
1046 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1047 && check_auth_capabilities_supported(auths,
1048 RTE_DIM(auths)) != 0) {
1049 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1050 "testsuite not met\n");
1051 return TEST_SKIPPED;
1058 hmac_md5_auth_testsuite_setup(void)
1060 struct crypto_testsuite_params *ts_params = &testsuite_params;
1061 uint8_t dev_id = ts_params->valid_devs[0];
1062 struct rte_cryptodev_info dev_info;
1063 const enum rte_crypto_auth_algorithm auths[] = {
1064 RTE_CRYPTO_AUTH_MD5_HMAC
1067 rte_cryptodev_info_get(dev_id, &dev_info);
1069 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1070 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1071 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1072 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1073 "Auth testsuite not met\n");
1074 return TEST_SKIPPED;
1077 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1078 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1079 "testsuite not met\n");
1080 return TEST_SKIPPED;
1087 kasumi_testsuite_setup(void)
1089 struct crypto_testsuite_params *ts_params = &testsuite_params;
1090 uint8_t dev_id = ts_params->valid_devs[0];
1091 struct rte_cryptodev_info dev_info;
1092 const enum rte_crypto_cipher_algorithm ciphers[] = {
1093 RTE_CRYPTO_CIPHER_KASUMI_F8
1095 const enum rte_crypto_auth_algorithm auths[] = {
1096 RTE_CRYPTO_AUTH_KASUMI_F9
1099 rte_cryptodev_info_get(dev_id, &dev_info);
1101 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1102 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1103 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1104 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1105 "testsuite not met\n");
1106 return TEST_SKIPPED;
1109 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1110 && check_auth_capabilities_supported(auths,
1111 RTE_DIM(auths)) != 0) {
1112 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1113 "testsuite not met\n");
1114 return TEST_SKIPPED;
1121 negative_aes_gcm_testsuite_setup(void)
1123 struct crypto_testsuite_params *ts_params = &testsuite_params;
1124 uint8_t dev_id = ts_params->valid_devs[0];
1125 struct rte_cryptodev_info dev_info;
1126 const enum rte_crypto_aead_algorithm aeads[] = {
1127 RTE_CRYPTO_AEAD_AES_GCM
1130 rte_cryptodev_info_get(dev_id, &dev_info);
1132 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1133 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1134 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1135 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1136 "AES GCM testsuite not met\n");
1137 return TEST_SKIPPED;
1140 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1141 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1142 "AES GCM testsuite not met\n");
1143 return TEST_SKIPPED;
1150 negative_aes_gmac_testsuite_setup(void)
1152 struct crypto_testsuite_params *ts_params = &testsuite_params;
1153 uint8_t dev_id = ts_params->valid_devs[0];
1154 struct rte_cryptodev_info dev_info;
1155 const enum rte_crypto_auth_algorithm auths[] = {
1156 RTE_CRYPTO_AUTH_AES_GMAC
1159 rte_cryptodev_info_get(dev_id, &dev_info);
1161 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1162 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1163 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1164 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1165 "AES GMAC testsuite not met\n");
1166 return TEST_SKIPPED;
1169 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1170 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1171 "AES GMAC testsuite not met\n");
1172 return TEST_SKIPPED;
1179 mixed_cipher_hash_testsuite_setup(void)
1181 struct crypto_testsuite_params *ts_params = &testsuite_params;
1182 uint8_t dev_id = ts_params->valid_devs[0];
1183 struct rte_cryptodev_info dev_info;
1184 uint64_t feat_flags;
1185 const enum rte_crypto_cipher_algorithm ciphers[] = {
1186 RTE_CRYPTO_CIPHER_NULL,
1187 RTE_CRYPTO_CIPHER_AES_CTR,
1188 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1189 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1191 const enum rte_crypto_auth_algorithm auths[] = {
1192 RTE_CRYPTO_AUTH_NULL,
1193 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1194 RTE_CRYPTO_AUTH_AES_CMAC,
1195 RTE_CRYPTO_AUTH_ZUC_EIA3
1198 rte_cryptodev_info_get(dev_id, &dev_info);
1199 feat_flags = dev_info.feature_flags;
1201 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1202 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1203 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1204 "Cipher Hash testsuite not met\n");
1205 return TEST_SKIPPED;
1208 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1209 && check_auth_capabilities_supported(auths,
1210 RTE_DIM(auths)) != 0) {
1211 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1212 "Cipher Hash testsuite not met\n");
1213 return TEST_SKIPPED;
1220 esn_testsuite_setup(void)
1222 struct crypto_testsuite_params *ts_params = &testsuite_params;
1223 uint8_t dev_id = ts_params->valid_devs[0];
1224 struct rte_cryptodev_info dev_info;
1225 const enum rte_crypto_cipher_algorithm ciphers[] = {
1226 RTE_CRYPTO_CIPHER_AES_CBC
1228 const enum rte_crypto_auth_algorithm auths[] = {
1229 RTE_CRYPTO_AUTH_SHA1_HMAC
1232 rte_cryptodev_info_get(dev_id, &dev_info);
1234 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1235 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1236 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1237 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1238 "testsuite not met\n");
1239 return TEST_SKIPPED;
1242 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1243 && check_auth_capabilities_supported(auths,
1244 RTE_DIM(auths)) != 0) {
1245 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1246 "testsuite not met\n");
1247 return TEST_SKIPPED;
1254 multi_session_testsuite_setup(void)
1256 struct crypto_testsuite_params *ts_params = &testsuite_params;
1257 uint8_t dev_id = ts_params->valid_devs[0];
1258 struct rte_cryptodev_info dev_info;
1259 const enum rte_crypto_cipher_algorithm ciphers[] = {
1260 RTE_CRYPTO_CIPHER_AES_CBC
1262 const enum rte_crypto_auth_algorithm auths[] = {
1263 RTE_CRYPTO_AUTH_SHA512_HMAC
1266 rte_cryptodev_info_get(dev_id, &dev_info);
1268 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1269 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1270 "Session testsuite not met\n");
1271 return TEST_SKIPPED;
1274 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1275 && check_auth_capabilities_supported(auths,
1276 RTE_DIM(auths)) != 0) {
1277 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1278 "Session testsuite not met\n");
1279 return TEST_SKIPPED;
1286 negative_hmac_sha1_testsuite_setup(void)
1288 struct crypto_testsuite_params *ts_params = &testsuite_params;
1289 uint8_t dev_id = ts_params->valid_devs[0];
1290 struct rte_cryptodev_info dev_info;
1291 const enum rte_crypto_cipher_algorithm ciphers[] = {
1292 RTE_CRYPTO_CIPHER_AES_CBC
1294 const enum rte_crypto_auth_algorithm auths[] = {
1295 RTE_CRYPTO_AUTH_SHA1_HMAC
1298 rte_cryptodev_info_get(dev_id, &dev_info);
1300 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1301 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1302 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1303 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1304 "HMAC SHA1 testsuite not met\n");
1305 return TEST_SKIPPED;
1308 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1309 && check_auth_capabilities_supported(auths,
1310 RTE_DIM(auths)) != 0) {
1311 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1312 "HMAC SHA1 testsuite not met\n");
1313 return TEST_SKIPPED;
1320 dev_configure_and_start(uint64_t ff_disable)
1322 struct crypto_testsuite_params *ts_params = &testsuite_params;
1323 struct crypto_unittest_params *ut_params = &unittest_params;
1327 /* Clear unit test parameters before running test */
1328 memset(ut_params, 0, sizeof(*ut_params));
1330 /* Reconfigure device to default parameters */
1331 ts_params->conf.socket_id = SOCKET_ID_ANY;
1332 ts_params->conf.ff_disable = ff_disable;
1333 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1334 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1335 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1337 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1339 "Failed to configure cryptodev %u",
1340 ts_params->valid_devs[0]);
1342 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1343 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1344 ts_params->valid_devs[0], qp_id,
1345 &ts_params->qp_conf,
1346 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1347 "Failed to setup queue pair %u on cryptodev %u",
1348 qp_id, ts_params->valid_devs[0]);
1352 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1354 /* Start the device */
1355 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1356 "Failed to start cryptodev %u",
1357 ts_params->valid_devs[0]);
1359 return TEST_SUCCESS;
1365 /* Configure and start the device with security feature disabled */
1366 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1370 ut_setup_security(void)
1372 /* Configure and start the device with no features disabled */
1373 return dev_configure_and_start(0);
1379 struct crypto_testsuite_params *ts_params = &testsuite_params;
1380 struct crypto_unittest_params *ut_params = &unittest_params;
1381 struct rte_cryptodev_stats stats;
1383 /* free crypto session structure */
1384 #ifdef RTE_LIB_SECURITY
1385 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1386 if (ut_params->sec_session) {
1387 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1388 (ts_params->valid_devs[0]),
1389 ut_params->sec_session);
1390 ut_params->sec_session = NULL;
1395 if (ut_params->sess) {
1396 rte_cryptodev_sym_session_clear(
1397 ts_params->valid_devs[0],
1399 rte_cryptodev_sym_session_free(ut_params->sess);
1400 ut_params->sess = NULL;
1404 /* free crypto operation structure */
1406 rte_crypto_op_free(ut_params->op);
1409 * free mbuf - both obuf and ibuf are usually the same,
1410 * so check if they point at the same address is necessary,
1411 * to avoid freeing the mbuf twice.
1413 if (ut_params->obuf) {
1414 rte_pktmbuf_free(ut_params->obuf);
1415 if (ut_params->ibuf == ut_params->obuf)
1416 ut_params->ibuf = 0;
1417 ut_params->obuf = 0;
1419 if (ut_params->ibuf) {
1420 rte_pktmbuf_free(ut_params->ibuf);
1421 ut_params->ibuf = 0;
1424 if (ts_params->mbuf_pool != NULL)
1425 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1426 rte_mempool_avail_count(ts_params->mbuf_pool));
1428 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1430 /* Stop the device */
1431 rte_cryptodev_stop(ts_params->valid_devs[0]);
1435 test_device_configure_invalid_dev_id(void)
1437 struct crypto_testsuite_params *ts_params = &testsuite_params;
1438 uint16_t dev_id, num_devs = 0;
1440 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1441 "Need at least %d devices for test", 1);
1443 /* valid dev_id values */
1444 dev_id = ts_params->valid_devs[0];
1446 /* Stop the device in case it's started so it can be configured */
1447 rte_cryptodev_stop(dev_id);
1449 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1450 "Failed test for rte_cryptodev_configure: "
1451 "invalid dev_num %u", dev_id);
1453 /* invalid dev_id values */
1456 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1457 "Failed test for rte_cryptodev_configure: "
1458 "invalid dev_num %u", dev_id);
1462 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1463 "Failed test for rte_cryptodev_configure:"
1464 "invalid dev_num %u", dev_id);
1466 return TEST_SUCCESS;
1470 test_device_configure_invalid_queue_pair_ids(void)
1472 struct crypto_testsuite_params *ts_params = &testsuite_params;
1473 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1475 /* Stop the device in case it's started so it can be configured */
1476 rte_cryptodev_stop(ts_params->valid_devs[0]);
1478 /* valid - max value queue pairs */
1479 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1481 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1483 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1484 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1486 /* valid - one queue pairs */
1487 ts_params->conf.nb_queue_pairs = 1;
1489 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1491 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1492 ts_params->valid_devs[0],
1493 ts_params->conf.nb_queue_pairs);
1496 /* invalid - zero queue pairs */
1497 ts_params->conf.nb_queue_pairs = 0;
1499 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1501 "Failed test for rte_cryptodev_configure, dev_id %u,"
1503 ts_params->valid_devs[0],
1504 ts_params->conf.nb_queue_pairs);
1507 /* invalid - max value supported by field queue pairs */
1508 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1510 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1512 "Failed test for rte_cryptodev_configure, dev_id %u,"
1514 ts_params->valid_devs[0],
1515 ts_params->conf.nb_queue_pairs);
1518 /* invalid - max value + 1 queue pairs */
1519 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1521 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1523 "Failed test for rte_cryptodev_configure, dev_id %u,"
1525 ts_params->valid_devs[0],
1526 ts_params->conf.nb_queue_pairs);
1528 /* revert to original testsuite value */
1529 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1531 return TEST_SUCCESS;
1535 test_queue_pair_descriptor_setup(void)
1537 struct crypto_testsuite_params *ts_params = &testsuite_params;
1538 struct rte_cryptodev_qp_conf qp_conf = {
1539 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1543 /* Stop the device in case it's started so it can be configured */
1544 rte_cryptodev_stop(ts_params->valid_devs[0]);
1546 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1548 "Failed to configure cryptodev %u",
1549 ts_params->valid_devs[0]);
1552 * Test various ring sizes on this device. memzones can't be
1553 * freed so are re-used if ring is released and re-created.
1555 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1556 qp_conf.mp_session = ts_params->session_mpool;
1557 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1559 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1560 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1561 ts_params->valid_devs[0], qp_id, &qp_conf,
1562 rte_cryptodev_socket_id(
1563 ts_params->valid_devs[0])),
1565 "rte_cryptodev_queue_pair_setup: num_inflights "
1566 "%u on qp %u on cryptodev %u",
1567 qp_conf.nb_descriptors, qp_id,
1568 ts_params->valid_devs[0]);
1571 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1573 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1574 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1575 ts_params->valid_devs[0], qp_id, &qp_conf,
1576 rte_cryptodev_socket_id(
1577 ts_params->valid_devs[0])),
1579 " rte_cryptodev_queue_pair_setup: num_inflights"
1580 " %u on qp %u on cryptodev %u",
1581 qp_conf.nb_descriptors, qp_id,
1582 ts_params->valid_devs[0]);
1585 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1587 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1588 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1589 ts_params->valid_devs[0], qp_id, &qp_conf,
1590 rte_cryptodev_socket_id(
1591 ts_params->valid_devs[0])),
1593 "rte_cryptodev_queue_pair_setup: num_inflights"
1594 " %u on qp %u on cryptodev %u",
1595 qp_conf.nb_descriptors, qp_id,
1596 ts_params->valid_devs[0]);
1599 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1601 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1602 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1603 ts_params->valid_devs[0], qp_id, &qp_conf,
1604 rte_cryptodev_socket_id(
1605 ts_params->valid_devs[0])),
1607 " rte_cryptodev_queue_pair_setup:"
1608 "num_inflights %u on qp %u on cryptodev %u",
1609 qp_conf.nb_descriptors, qp_id,
1610 ts_params->valid_devs[0]);
1613 /* test invalid queue pair id */
1614 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1616 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1618 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1619 ts_params->valid_devs[0],
1621 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1622 "Failed test for rte_cryptodev_queue_pair_setup:"
1623 "invalid qp %u on cryptodev %u",
1624 qp_id, ts_params->valid_devs[0]);
1626 qp_id = 0xffff; /*invalid*/
1628 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1629 ts_params->valid_devs[0],
1631 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1632 "Failed test for rte_cryptodev_queue_pair_setup:"
1633 "invalid qp %u on cryptodev %u",
1634 qp_id, ts_params->valid_devs[0]);
1636 return TEST_SUCCESS;
1639 /* ***** Plaintext data for tests ***** */
1641 const char catch_22_quote_1[] =
1642 "There was only one catch and that was Catch-22, which "
1643 "specified that a concern for one's safety in the face of "
1644 "dangers that were real and immediate was the process of a "
1645 "rational mind. Orr was crazy and could be grounded. All he "
1646 "had to do was ask; and as soon as he did, he would no longer "
1647 "be crazy and would have to fly more missions. Orr would be "
1648 "crazy to fly more missions and sane if he didn't, but if he "
1649 "was sane he had to fly them. If he flew them he was crazy "
1650 "and didn't have to; but if he didn't want to he was sane and "
1651 "had to. Yossarian was moved very deeply by the absolute "
1652 "simplicity of this clause of Catch-22 and let out a "
1653 "respectful whistle. \"That's some catch, that Catch-22\", he "
1654 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1656 const char catch_22_quote[] =
1657 "What a lousy earth! He wondered how many people were "
1658 "destitute that same night even in his own prosperous country, "
1659 "how many homes were shanties, how many husbands were drunk "
1660 "and wives socked, and how many children were bullied, abused, "
1661 "or abandoned. How many families hungered for food they could "
1662 "not afford to buy? How many hearts were broken? How many "
1663 "suicides would take place that same night, how many people "
1664 "would go insane? How many cockroaches and landlords would "
1665 "triumph? How many winners were losers, successes failures, "
1666 "and rich men poor men? How many wise guys were stupid? How "
1667 "many happy endings were unhappy endings? How many honest men "
1668 "were liars, brave men cowards, loyal men traitors, how many "
1669 "sainted men were corrupt, how many people in positions of "
1670 "trust had sold their souls to bodyguards, how many had never "
1671 "had souls? How many straight-and-narrow paths were crooked "
1672 "paths? How many best families were worst families and how "
1673 "many good people were bad people? When you added them all up "
1674 "and then subtracted, you might be left with only the children, "
1675 "and perhaps with Albert Einstein and an old violinist or "
1676 "sculptor somewhere.";
1678 #define QUOTE_480_BYTES (480)
1679 #define QUOTE_512_BYTES (512)
1680 #define QUOTE_768_BYTES (768)
1681 #define QUOTE_1024_BYTES (1024)
1685 /* ***** SHA1 Hash Tests ***** */
1687 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1689 static uint8_t hmac_sha1_key[] = {
1690 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1691 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1692 0xDE, 0xF4, 0xDE, 0xAD };
1694 /* ***** SHA224 Hash Tests ***** */
1696 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1699 /* ***** AES-CBC Cipher Tests ***** */
1701 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1702 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1704 static uint8_t aes_cbc_key[] = {
1705 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1706 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1708 static uint8_t aes_cbc_iv[] = {
1709 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1710 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1713 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1715 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1716 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1717 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1718 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1719 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1720 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1721 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1722 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1723 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1724 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1725 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1726 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1727 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1728 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1729 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1730 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1731 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1732 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1733 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1734 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1735 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1736 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1737 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1738 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1739 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1740 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1741 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1742 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1743 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1744 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1745 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1746 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1747 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1748 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1749 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1750 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1751 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1752 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1753 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1754 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1755 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1756 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1757 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1758 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1759 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1760 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1761 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1762 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1763 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1764 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1765 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1766 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1767 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1768 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1769 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1770 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1771 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1772 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1773 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1774 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1775 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1776 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1777 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1778 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1779 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1782 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1783 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1784 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1785 0x18, 0x8c, 0x1d, 0x32
1789 /* Multisession Vector context Test */
1790 /*Begin Session 0 */
1791 static uint8_t ms_aes_cbc_key0[] = {
1792 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1793 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1796 static uint8_t ms_aes_cbc_iv0[] = {
1797 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1798 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1801 static const uint8_t ms_aes_cbc_cipher0[] = {
1802 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1803 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1804 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1805 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1806 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1807 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1808 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1809 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1810 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1811 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1812 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1813 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1814 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1815 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1816 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1817 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1818 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1819 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1820 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1821 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1822 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1823 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1824 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1825 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1826 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1827 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1828 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1829 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1830 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1831 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1832 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1833 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1834 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1835 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1836 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1837 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1838 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1839 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1840 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1841 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1842 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1843 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1844 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1845 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1846 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1847 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1848 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1849 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1850 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1851 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1852 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1853 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1854 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1855 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1856 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1857 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1858 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1859 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1860 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1861 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1862 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1863 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1864 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1865 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1869 static uint8_t ms_hmac_key0[] = {
1870 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1871 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1872 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1873 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1874 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1875 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1876 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1877 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1880 static const uint8_t ms_hmac_digest0[] = {
1881 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1882 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1883 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1884 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1885 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1886 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1887 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1888 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1892 /* Begin session 1 */
1894 static uint8_t ms_aes_cbc_key1[] = {
1895 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1896 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1899 static uint8_t ms_aes_cbc_iv1[] = {
1900 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1901 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1904 static const uint8_t ms_aes_cbc_cipher1[] = {
1905 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1906 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1907 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1908 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1909 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1910 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1911 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1912 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1913 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1914 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1915 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1916 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1917 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1918 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1919 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1920 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1921 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1922 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1923 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1924 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1925 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1926 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1927 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1928 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1929 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1930 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1931 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1932 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1933 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1934 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1935 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1936 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1937 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1938 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1939 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1940 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1941 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1942 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1943 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1944 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1945 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1946 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1947 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1948 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1949 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1950 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1951 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1952 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1953 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1954 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1955 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1956 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1957 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1958 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1959 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1960 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1961 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1962 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1963 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1964 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1965 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1966 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1967 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1968 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1972 static uint8_t ms_hmac_key1[] = {
1973 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1974 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1975 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1976 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1977 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1978 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1979 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1980 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1983 static const uint8_t ms_hmac_digest1[] = {
1984 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1985 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1986 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1987 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1988 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1989 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1990 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1991 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1994 /* Begin Session 2 */
1995 static uint8_t ms_aes_cbc_key2[] = {
1996 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1997 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2000 static uint8_t ms_aes_cbc_iv2[] = {
2001 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2002 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2005 static const uint8_t ms_aes_cbc_cipher2[] = {
2006 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2007 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2008 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2009 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2010 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2011 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2012 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2013 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2014 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2015 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2016 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2017 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2018 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2019 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2020 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2021 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2022 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2023 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2024 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2025 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2026 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2027 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2028 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2029 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2030 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2031 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2032 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2033 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2034 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2035 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2036 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2037 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2038 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2039 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2040 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2041 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2042 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2043 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2044 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2045 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2046 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2047 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2048 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2049 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2050 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2051 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2052 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2053 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2054 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2055 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2056 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2057 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2058 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2059 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2060 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2061 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2062 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2063 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2064 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2065 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2066 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2067 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2068 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2069 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2072 static uint8_t ms_hmac_key2[] = {
2073 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2074 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2075 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2076 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2077 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2078 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2079 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2080 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2083 static const uint8_t ms_hmac_digest2[] = {
2084 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2085 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2086 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2087 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2088 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2089 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2090 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2091 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2098 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2100 struct crypto_testsuite_params *ts_params = &testsuite_params;
2101 struct crypto_unittest_params *ut_params = &unittest_params;
2103 /* Verify the capabilities */
2104 struct rte_cryptodev_sym_capability_idx cap_idx;
2105 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2106 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2107 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2109 return TEST_SKIPPED;
2110 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2111 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2112 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2114 return TEST_SKIPPED;
2116 /* Generate test mbuf data and space for digest */
2117 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2118 catch_22_quote, QUOTE_512_BYTES, 0);
2120 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2121 DIGEST_BYTE_LENGTH_SHA1);
2122 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2124 /* Setup Cipher Parameters */
2125 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2126 ut_params->cipher_xform.next = &ut_params->auth_xform;
2128 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2129 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2130 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2131 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2132 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2133 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2135 /* Setup HMAC Parameters */
2136 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2138 ut_params->auth_xform.next = NULL;
2140 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2141 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2142 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2143 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2144 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2146 ut_params->sess = rte_cryptodev_sym_session_create(
2147 ts_params->session_mpool);
2149 /* Create crypto session*/
2150 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2151 ut_params->sess, &ut_params->cipher_xform,
2152 ts_params->session_priv_mpool);
2153 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2155 /* Generate crypto op data structure */
2156 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2157 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2158 TEST_ASSERT_NOT_NULL(ut_params->op,
2159 "Failed to allocate symmetric crypto operation struct");
2161 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2163 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2165 /* set crypto operation source mbuf */
2166 sym_op->m_src = ut_params->ibuf;
2168 /* Set crypto operation authentication parameters */
2169 sym_op->auth.digest.data = ut_params->digest;
2170 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2171 ut_params->ibuf, QUOTE_512_BYTES);
2173 sym_op->auth.data.offset = 0;
2174 sym_op->auth.data.length = QUOTE_512_BYTES;
2176 /* Copy IV at the end of the crypto operation */
2177 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2178 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2180 /* Set crypto operation cipher parameters */
2181 sym_op->cipher.data.offset = 0;
2182 sym_op->cipher.data.length = QUOTE_512_BYTES;
2184 /* Process crypto operation */
2185 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2186 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2189 TEST_ASSERT_NOT_NULL(
2190 process_crypto_request(ts_params->valid_devs[0],
2192 "failed to process sym crypto op");
2194 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2195 "crypto op processing failed");
2198 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2201 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2202 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2204 "ciphertext data not as expected");
2206 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2208 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2209 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2210 gbl_driver_id == rte_cryptodev_driver_id_get(
2211 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2212 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2213 DIGEST_BYTE_LENGTH_SHA1,
2214 "Generated digest data not as expected");
2216 return TEST_SUCCESS;
2219 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2221 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2223 static uint8_t hmac_sha512_key[] = {
2224 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2225 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2226 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2227 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2228 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2229 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2230 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2231 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2233 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2234 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2235 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2236 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2237 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2238 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2239 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2240 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2241 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2246 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2247 struct crypto_unittest_params *ut_params,
2248 uint8_t *cipher_key,
2252 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2253 struct crypto_unittest_params *ut_params,
2254 struct crypto_testsuite_params *ts_params,
2255 const uint8_t *cipher,
2256 const uint8_t *digest,
2261 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2262 struct crypto_unittest_params *ut_params,
2263 uint8_t *cipher_key,
2267 /* Setup Cipher Parameters */
2268 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2269 ut_params->cipher_xform.next = NULL;
2271 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2272 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2273 ut_params->cipher_xform.cipher.key.data = cipher_key;
2274 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2275 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2276 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2278 /* Setup HMAC Parameters */
2279 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2280 ut_params->auth_xform.next = &ut_params->cipher_xform;
2282 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2283 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2284 ut_params->auth_xform.auth.key.data = hmac_key;
2285 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2286 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2288 return TEST_SUCCESS;
2293 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2294 struct crypto_unittest_params *ut_params,
2295 struct crypto_testsuite_params *ts_params,
2296 const uint8_t *cipher,
2297 const uint8_t *digest,
2300 /* Generate test mbuf data and digest */
2301 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2304 QUOTE_512_BYTES, 0);
2306 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2307 DIGEST_BYTE_LENGTH_SHA512);
2308 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2310 rte_memcpy(ut_params->digest,
2312 DIGEST_BYTE_LENGTH_SHA512);
2314 /* Generate Crypto op data structure */
2315 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2316 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2317 TEST_ASSERT_NOT_NULL(ut_params->op,
2318 "Failed to allocate symmetric crypto operation struct");
2320 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2322 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2324 /* set crypto operation source mbuf */
2325 sym_op->m_src = ut_params->ibuf;
2327 sym_op->auth.digest.data = ut_params->digest;
2328 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2329 ut_params->ibuf, QUOTE_512_BYTES);
2331 sym_op->auth.data.offset = 0;
2332 sym_op->auth.data.length = QUOTE_512_BYTES;
2334 /* Copy IV at the end of the crypto operation */
2335 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2336 iv, CIPHER_IV_LENGTH_AES_CBC);
2338 sym_op->cipher.data.offset = 0;
2339 sym_op->cipher.data.length = QUOTE_512_BYTES;
2341 /* Process crypto operation */
2342 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2343 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2345 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2346 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2347 ut_params->op, 1, 1, 0, 0);
2349 TEST_ASSERT_NOT_NULL(
2350 process_crypto_request(ts_params->valid_devs[0],
2352 "failed to process sym crypto op");
2354 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2355 "crypto op processing failed");
2357 ut_params->obuf = ut_params->op->sym->m_src;
2360 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2361 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2364 "Plaintext data not as expected");
2367 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2368 "Digest verification failed");
2370 return TEST_SUCCESS;
2373 /* ***** SNOW 3G Tests ***** */
2375 create_wireless_algo_hash_session(uint8_t dev_id,
2376 const uint8_t *key, const uint8_t key_len,
2377 const uint8_t iv_len, const uint8_t auth_len,
2378 enum rte_crypto_auth_operation op,
2379 enum rte_crypto_auth_algorithm algo)
2381 uint8_t hash_key[key_len];
2384 struct crypto_testsuite_params *ts_params = &testsuite_params;
2385 struct crypto_unittest_params *ut_params = &unittest_params;
2387 memcpy(hash_key, key, key_len);
2389 debug_hexdump(stdout, "key:", key, key_len);
2391 /* Setup Authentication Parameters */
2392 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2393 ut_params->auth_xform.next = NULL;
2395 ut_params->auth_xform.auth.op = op;
2396 ut_params->auth_xform.auth.algo = algo;
2397 ut_params->auth_xform.auth.key.length = key_len;
2398 ut_params->auth_xform.auth.key.data = hash_key;
2399 ut_params->auth_xform.auth.digest_length = auth_len;
2400 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2401 ut_params->auth_xform.auth.iv.length = iv_len;
2402 ut_params->sess = rte_cryptodev_sym_session_create(
2403 ts_params->session_mpool);
2405 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2406 &ut_params->auth_xform,
2407 ts_params->session_priv_mpool);
2408 if (status == -ENOTSUP)
2409 return TEST_SKIPPED;
2411 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2412 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2417 create_wireless_algo_cipher_session(uint8_t dev_id,
2418 enum rte_crypto_cipher_operation op,
2419 enum rte_crypto_cipher_algorithm algo,
2420 const uint8_t *key, const uint8_t key_len,
2423 uint8_t cipher_key[key_len];
2425 struct crypto_testsuite_params *ts_params = &testsuite_params;
2426 struct crypto_unittest_params *ut_params = &unittest_params;
2428 memcpy(cipher_key, key, key_len);
2430 /* Setup Cipher Parameters */
2431 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2432 ut_params->cipher_xform.next = NULL;
2434 ut_params->cipher_xform.cipher.algo = algo;
2435 ut_params->cipher_xform.cipher.op = op;
2436 ut_params->cipher_xform.cipher.key.data = cipher_key;
2437 ut_params->cipher_xform.cipher.key.length = key_len;
2438 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2439 ut_params->cipher_xform.cipher.iv.length = iv_len;
2441 debug_hexdump(stdout, "key:", key, key_len);
2443 /* Create Crypto session */
2444 ut_params->sess = rte_cryptodev_sym_session_create(
2445 ts_params->session_mpool);
2447 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2448 &ut_params->cipher_xform,
2449 ts_params->session_priv_mpool);
2450 if (status == -ENOTSUP)
2451 return TEST_SKIPPED;
2453 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2454 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2459 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2460 unsigned int cipher_len,
2461 unsigned int cipher_offset)
2463 struct crypto_testsuite_params *ts_params = &testsuite_params;
2464 struct crypto_unittest_params *ut_params = &unittest_params;
2466 /* Generate Crypto op data structure */
2467 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2468 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2469 TEST_ASSERT_NOT_NULL(ut_params->op,
2470 "Failed to allocate pktmbuf offload");
2472 /* Set crypto operation data parameters */
2473 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2475 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2477 /* set crypto operation source mbuf */
2478 sym_op->m_src = ut_params->ibuf;
2481 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2483 sym_op->cipher.data.length = cipher_len;
2484 sym_op->cipher.data.offset = cipher_offset;
2489 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2490 unsigned int cipher_len,
2491 unsigned int cipher_offset)
2493 struct crypto_testsuite_params *ts_params = &testsuite_params;
2494 struct crypto_unittest_params *ut_params = &unittest_params;
2496 /* Generate Crypto op data structure */
2497 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2498 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2499 TEST_ASSERT_NOT_NULL(ut_params->op,
2500 "Failed to allocate pktmbuf offload");
2502 /* Set crypto operation data parameters */
2503 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2505 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2507 /* set crypto operation source mbuf */
2508 sym_op->m_src = ut_params->ibuf;
2509 sym_op->m_dst = ut_params->obuf;
2512 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2514 sym_op->cipher.data.length = cipher_len;
2515 sym_op->cipher.data.offset = cipher_offset;
2520 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2521 enum rte_crypto_cipher_operation cipher_op,
2522 enum rte_crypto_auth_operation auth_op,
2523 enum rte_crypto_auth_algorithm auth_algo,
2524 enum rte_crypto_cipher_algorithm cipher_algo,
2525 const uint8_t *key, uint8_t key_len,
2526 uint8_t auth_iv_len, uint8_t auth_len,
2527 uint8_t cipher_iv_len)
2530 uint8_t cipher_auth_key[key_len];
2533 struct crypto_testsuite_params *ts_params = &testsuite_params;
2534 struct crypto_unittest_params *ut_params = &unittest_params;
2536 memcpy(cipher_auth_key, key, key_len);
2538 /* Setup Authentication Parameters */
2539 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2540 ut_params->auth_xform.next = NULL;
2542 ut_params->auth_xform.auth.op = auth_op;
2543 ut_params->auth_xform.auth.algo = auth_algo;
2544 ut_params->auth_xform.auth.key.length = key_len;
2545 /* Hash key = cipher key */
2546 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2547 ut_params->auth_xform.auth.digest_length = auth_len;
2548 /* Auth IV will be after cipher IV */
2549 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2550 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2552 /* Setup Cipher Parameters */
2553 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2554 ut_params->cipher_xform.next = &ut_params->auth_xform;
2556 ut_params->cipher_xform.cipher.algo = cipher_algo;
2557 ut_params->cipher_xform.cipher.op = cipher_op;
2558 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2559 ut_params->cipher_xform.cipher.key.length = key_len;
2560 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2561 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2563 debug_hexdump(stdout, "key:", key, key_len);
2565 /* Create Crypto session*/
2566 ut_params->sess = rte_cryptodev_sym_session_create(
2567 ts_params->session_mpool);
2568 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2570 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2571 &ut_params->cipher_xform,
2572 ts_params->session_priv_mpool);
2573 if (status == -ENOTSUP)
2574 return TEST_SKIPPED;
2576 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2581 create_wireless_cipher_auth_session(uint8_t dev_id,
2582 enum rte_crypto_cipher_operation cipher_op,
2583 enum rte_crypto_auth_operation auth_op,
2584 enum rte_crypto_auth_algorithm auth_algo,
2585 enum rte_crypto_cipher_algorithm cipher_algo,
2586 const struct wireless_test_data *tdata)
2588 const uint8_t key_len = tdata->key.len;
2589 uint8_t cipher_auth_key[key_len];
2592 struct crypto_testsuite_params *ts_params = &testsuite_params;
2593 struct crypto_unittest_params *ut_params = &unittest_params;
2594 const uint8_t *key = tdata->key.data;
2595 const uint8_t auth_len = tdata->digest.len;
2596 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2597 uint8_t auth_iv_len = tdata->auth_iv.len;
2599 memcpy(cipher_auth_key, key, key_len);
2601 /* Setup Authentication Parameters */
2602 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2603 ut_params->auth_xform.next = NULL;
2605 ut_params->auth_xform.auth.op = auth_op;
2606 ut_params->auth_xform.auth.algo = auth_algo;
2607 ut_params->auth_xform.auth.key.length = key_len;
2608 /* Hash key = cipher key */
2609 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2610 ut_params->auth_xform.auth.digest_length = auth_len;
2611 /* Auth IV will be after cipher IV */
2612 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2613 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2615 /* Setup Cipher Parameters */
2616 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2617 ut_params->cipher_xform.next = &ut_params->auth_xform;
2619 ut_params->cipher_xform.cipher.algo = cipher_algo;
2620 ut_params->cipher_xform.cipher.op = cipher_op;
2621 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2622 ut_params->cipher_xform.cipher.key.length = key_len;
2623 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2624 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2627 debug_hexdump(stdout, "key:", key, key_len);
2629 /* Create Crypto session*/
2630 ut_params->sess = rte_cryptodev_sym_session_create(
2631 ts_params->session_mpool);
2633 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2634 &ut_params->cipher_xform,
2635 ts_params->session_priv_mpool);
2636 if (status == -ENOTSUP)
2637 return TEST_SKIPPED;
2639 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2640 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2645 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2646 const struct wireless_test_data *tdata)
2648 return create_wireless_cipher_auth_session(dev_id,
2649 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2650 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2651 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2655 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2656 enum rte_crypto_cipher_operation cipher_op,
2657 enum rte_crypto_auth_operation auth_op,
2658 enum rte_crypto_auth_algorithm auth_algo,
2659 enum rte_crypto_cipher_algorithm cipher_algo,
2660 const uint8_t *key, const uint8_t key_len,
2661 uint8_t auth_iv_len, uint8_t auth_len,
2662 uint8_t cipher_iv_len)
2664 uint8_t auth_cipher_key[key_len];
2666 struct crypto_testsuite_params *ts_params = &testsuite_params;
2667 struct crypto_unittest_params *ut_params = &unittest_params;
2669 memcpy(auth_cipher_key, key, key_len);
2671 /* Setup Authentication Parameters */
2672 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2673 ut_params->auth_xform.auth.op = auth_op;
2674 ut_params->auth_xform.next = &ut_params->cipher_xform;
2675 ut_params->auth_xform.auth.algo = auth_algo;
2676 ut_params->auth_xform.auth.key.length = key_len;
2677 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2678 ut_params->auth_xform.auth.digest_length = auth_len;
2679 /* Auth IV will be after cipher IV */
2680 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2681 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2683 /* Setup Cipher Parameters */
2684 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2685 ut_params->cipher_xform.next = NULL;
2686 ut_params->cipher_xform.cipher.algo = cipher_algo;
2687 ut_params->cipher_xform.cipher.op = cipher_op;
2688 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2689 ut_params->cipher_xform.cipher.key.length = key_len;
2690 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2691 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2693 debug_hexdump(stdout, "key:", key, key_len);
2695 /* Create Crypto session*/
2696 ut_params->sess = rte_cryptodev_sym_session_create(
2697 ts_params->session_mpool);
2698 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2700 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2701 ut_params->auth_xform.next = NULL;
2702 ut_params->cipher_xform.next = &ut_params->auth_xform;
2703 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2704 &ut_params->cipher_xform,
2705 ts_params->session_priv_mpool);
2708 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2709 &ut_params->auth_xform,
2710 ts_params->session_priv_mpool);
2712 if (status == -ENOTSUP)
2713 return TEST_SKIPPED;
2715 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2721 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2722 unsigned int auth_tag_len,
2723 const uint8_t *iv, unsigned int iv_len,
2724 unsigned int data_pad_len,
2725 enum rte_crypto_auth_operation op,
2726 unsigned int auth_len, unsigned int auth_offset)
2728 struct crypto_testsuite_params *ts_params = &testsuite_params;
2730 struct crypto_unittest_params *ut_params = &unittest_params;
2732 /* Generate Crypto op data structure */
2733 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2734 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2735 TEST_ASSERT_NOT_NULL(ut_params->op,
2736 "Failed to allocate pktmbuf offload");
2738 /* Set crypto operation data parameters */
2739 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2741 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2743 /* set crypto operation source mbuf */
2744 sym_op->m_src = ut_params->ibuf;
2747 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2750 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2751 ut_params->ibuf, auth_tag_len);
2753 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2754 "no room to append auth tag");
2755 ut_params->digest = sym_op->auth.digest.data;
2756 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2757 ut_params->ibuf, data_pad_len);
2758 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2759 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2761 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2763 debug_hexdump(stdout, "digest:",
2764 sym_op->auth.digest.data,
2767 sym_op->auth.data.length = auth_len;
2768 sym_op->auth.data.offset = auth_offset;
2774 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2775 enum rte_crypto_auth_operation op)
2777 struct crypto_testsuite_params *ts_params = &testsuite_params;
2778 struct crypto_unittest_params *ut_params = &unittest_params;
2780 const uint8_t *auth_tag = tdata->digest.data;
2781 const unsigned int auth_tag_len = tdata->digest.len;
2782 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2783 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2785 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2786 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2787 const uint8_t *auth_iv = tdata->auth_iv.data;
2788 const uint8_t auth_iv_len = tdata->auth_iv.len;
2789 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2790 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2792 /* Generate Crypto op data structure */
2793 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2794 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2795 TEST_ASSERT_NOT_NULL(ut_params->op,
2796 "Failed to allocate pktmbuf offload");
2797 /* Set crypto operation data parameters */
2798 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2800 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2802 /* set crypto operation source mbuf */
2803 sym_op->m_src = ut_params->ibuf;
2806 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2807 ut_params->ibuf, auth_tag_len);
2809 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2810 "no room to append auth tag");
2811 ut_params->digest = sym_op->auth.digest.data;
2812 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2813 ut_params->ibuf, data_pad_len);
2814 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2815 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2817 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2819 debug_hexdump(stdout, "digest:",
2820 sym_op->auth.digest.data,
2823 /* Copy cipher and auth IVs at the end of the crypto operation */
2824 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2826 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2827 iv_ptr += cipher_iv_len;
2828 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2830 sym_op->cipher.data.length = cipher_len;
2831 sym_op->cipher.data.offset = 0;
2832 sym_op->auth.data.length = auth_len;
2833 sym_op->auth.data.offset = 0;
2839 create_zuc_cipher_hash_generate_operation(
2840 const struct wireless_test_data *tdata)
2842 return create_wireless_cipher_hash_operation(tdata,
2843 RTE_CRYPTO_AUTH_OP_GENERATE);
2847 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2848 const unsigned auth_tag_len,
2849 const uint8_t *auth_iv, uint8_t auth_iv_len,
2850 unsigned data_pad_len,
2851 enum rte_crypto_auth_operation op,
2852 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2853 const unsigned cipher_len, const unsigned cipher_offset,
2854 const unsigned auth_len, const unsigned auth_offset)
2856 struct crypto_testsuite_params *ts_params = &testsuite_params;
2857 struct crypto_unittest_params *ut_params = &unittest_params;
2859 enum rte_crypto_cipher_algorithm cipher_algo =
2860 ut_params->cipher_xform.cipher.algo;
2861 enum rte_crypto_auth_algorithm auth_algo =
2862 ut_params->auth_xform.auth.algo;
2864 /* Generate Crypto op data structure */
2865 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2866 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2867 TEST_ASSERT_NOT_NULL(ut_params->op,
2868 "Failed to allocate pktmbuf offload");
2869 /* Set crypto operation data parameters */
2870 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2872 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2874 /* set crypto operation source mbuf */
2875 sym_op->m_src = ut_params->ibuf;
2878 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2879 ut_params->ibuf, auth_tag_len);
2881 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2882 "no room to append auth tag");
2883 ut_params->digest = sym_op->auth.digest.data;
2885 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2886 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2887 ut_params->ibuf, data_pad_len);
2889 struct rte_mbuf *m = ut_params->ibuf;
2890 unsigned int offset = data_pad_len;
2892 while (offset > m->data_len && m->next != NULL) {
2893 offset -= m->data_len;
2896 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2900 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2901 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2903 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2905 debug_hexdump(stdout, "digest:",
2906 sym_op->auth.digest.data,
2909 /* Copy cipher and auth IVs at the end of the crypto operation */
2910 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2912 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2913 iv_ptr += cipher_iv_len;
2914 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2916 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2917 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2918 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2919 sym_op->cipher.data.length = cipher_len;
2920 sym_op->cipher.data.offset = cipher_offset;
2922 sym_op->cipher.data.length = cipher_len >> 3;
2923 sym_op->cipher.data.offset = cipher_offset >> 3;
2926 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2927 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2928 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2929 sym_op->auth.data.length = auth_len;
2930 sym_op->auth.data.offset = auth_offset;
2932 sym_op->auth.data.length = auth_len >> 3;
2933 sym_op->auth.data.offset = auth_offset >> 3;
2940 create_wireless_algo_auth_cipher_operation(
2941 const uint8_t *auth_tag, unsigned int auth_tag_len,
2942 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2943 const uint8_t *auth_iv, uint8_t auth_iv_len,
2944 unsigned int data_pad_len,
2945 unsigned int cipher_len, unsigned int cipher_offset,
2946 unsigned int auth_len, unsigned int auth_offset,
2947 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2949 struct crypto_testsuite_params *ts_params = &testsuite_params;
2950 struct crypto_unittest_params *ut_params = &unittest_params;
2952 enum rte_crypto_cipher_algorithm cipher_algo =
2953 ut_params->cipher_xform.cipher.algo;
2954 enum rte_crypto_auth_algorithm auth_algo =
2955 ut_params->auth_xform.auth.algo;
2957 /* Generate Crypto op data structure */
2958 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2959 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2960 TEST_ASSERT_NOT_NULL(ut_params->op,
2961 "Failed to allocate pktmbuf offload");
2963 /* Set crypto operation data parameters */
2964 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2966 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2968 /* set crypto operation mbufs */
2969 sym_op->m_src = ut_params->ibuf;
2970 if (op_mode == OUT_OF_PLACE)
2971 sym_op->m_dst = ut_params->obuf;
2975 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2976 (op_mode == IN_PLACE ?
2977 ut_params->ibuf : ut_params->obuf),
2978 uint8_t *, data_pad_len);
2979 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2980 (op_mode == IN_PLACE ?
2981 ut_params->ibuf : ut_params->obuf),
2983 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2985 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2986 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2987 sym_op->m_src : sym_op->m_dst);
2988 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2989 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2990 sgl_buf = sgl_buf->next;
2992 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2993 uint8_t *, remaining_off);
2994 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2996 memset(sym_op->auth.digest.data, 0, remaining_off);
2997 while (sgl_buf->next != NULL) {
2998 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2999 0, rte_pktmbuf_data_len(sgl_buf));
3000 sgl_buf = sgl_buf->next;
3004 /* Copy digest for the verification */
3006 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3008 /* Copy cipher and auth IVs at the end of the crypto operation */
3009 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3010 ut_params->op, uint8_t *, IV_OFFSET);
3012 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3013 iv_ptr += cipher_iv_len;
3014 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3016 /* Only copy over the offset data needed from src to dst in OOP,
3017 * if the auth and cipher offsets are not aligned
3019 if (op_mode == OUT_OF_PLACE) {
3020 if (cipher_offset > auth_offset)
3022 rte_pktmbuf_mtod_offset(
3024 uint8_t *, auth_offset >> 3),
3025 rte_pktmbuf_mtod_offset(
3027 uint8_t *, auth_offset >> 3),
3028 ((cipher_offset >> 3) - (auth_offset >> 3)));
3031 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3032 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3033 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3034 sym_op->cipher.data.length = cipher_len;
3035 sym_op->cipher.data.offset = cipher_offset;
3037 sym_op->cipher.data.length = cipher_len >> 3;
3038 sym_op->cipher.data.offset = cipher_offset >> 3;
3041 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3042 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3043 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3044 sym_op->auth.data.length = auth_len;
3045 sym_op->auth.data.offset = auth_offset;
3047 sym_op->auth.data.length = auth_len >> 3;
3048 sym_op->auth.data.offset = auth_offset >> 3;
3055 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3057 struct crypto_testsuite_params *ts_params = &testsuite_params;
3058 struct crypto_unittest_params *ut_params = &unittest_params;
3061 unsigned plaintext_pad_len;
3062 unsigned plaintext_len;
3064 struct rte_cryptodev_info dev_info;
3066 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3067 uint64_t feat_flags = dev_info.feature_flags;
3069 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3070 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3071 printf("Device doesn't support NON-Byte Aligned Data.\n");
3072 return TEST_SKIPPED;
3075 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3076 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3077 printf("Device doesn't support RAW data-path APIs.\n");
3078 return TEST_SKIPPED;
3081 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3082 return TEST_SKIPPED;
3084 /* Verify the capabilities */
3085 struct rte_cryptodev_sym_capability_idx cap_idx;
3086 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3087 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3088 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3090 return TEST_SKIPPED;
3092 /* Create SNOW 3G session */
3093 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3094 tdata->key.data, tdata->key.len,
3095 tdata->auth_iv.len, tdata->digest.len,
3096 RTE_CRYPTO_AUTH_OP_GENERATE,
3097 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3101 /* alloc mbuf and set payload */
3102 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3104 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3105 rte_pktmbuf_tailroom(ut_params->ibuf));
3107 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3108 /* Append data which is padded to a multiple of */
3109 /* the algorithms block size */
3110 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3111 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3113 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3115 /* Create SNOW 3G operation */
3116 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3117 tdata->auth_iv.data, tdata->auth_iv.len,
3118 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3119 tdata->validAuthLenInBits.len,
3124 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3125 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3126 ut_params->op, 0, 1, 1, 0);
3128 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3130 ut_params->obuf = ut_params->op->sym->m_src;
3131 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3132 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3133 + plaintext_pad_len;
3136 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3139 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3140 "SNOW 3G Generated auth tag not as expected");
3146 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3148 struct crypto_testsuite_params *ts_params = &testsuite_params;
3149 struct crypto_unittest_params *ut_params = &unittest_params;
3152 unsigned plaintext_pad_len;
3153 unsigned plaintext_len;
3155 struct rte_cryptodev_info dev_info;
3157 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3158 uint64_t feat_flags = dev_info.feature_flags;
3160 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3161 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3162 printf("Device doesn't support NON-Byte Aligned Data.\n");
3163 return TEST_SKIPPED;
3166 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3167 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3168 printf("Device doesn't support RAW data-path APIs.\n");
3169 return TEST_SKIPPED;
3172 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3173 return TEST_SKIPPED;
3175 /* Verify the capabilities */
3176 struct rte_cryptodev_sym_capability_idx cap_idx;
3177 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3178 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3179 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3181 return TEST_SKIPPED;
3183 /* Create SNOW 3G session */
3184 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3185 tdata->key.data, tdata->key.len,
3186 tdata->auth_iv.len, tdata->digest.len,
3187 RTE_CRYPTO_AUTH_OP_VERIFY,
3188 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3191 /* alloc mbuf and set payload */
3192 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3195 rte_pktmbuf_tailroom(ut_params->ibuf));
3197 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3198 /* Append data which is padded to a multiple of */
3199 /* the algorithms block size */
3200 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3201 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3203 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3205 /* Create SNOW 3G operation */
3206 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3208 tdata->auth_iv.data, tdata->auth_iv.len,
3210 RTE_CRYPTO_AUTH_OP_VERIFY,
3211 tdata->validAuthLenInBits.len,
3216 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3217 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3218 ut_params->op, 0, 1, 1, 0);
3220 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3222 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3223 ut_params->obuf = ut_params->op->sym->m_src;
3224 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3225 + plaintext_pad_len;
3228 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3237 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3239 struct crypto_testsuite_params *ts_params = &testsuite_params;
3240 struct crypto_unittest_params *ut_params = &unittest_params;
3243 unsigned plaintext_pad_len;
3244 unsigned plaintext_len;
3246 struct rte_cryptodev_info dev_info;
3248 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3249 uint64_t feat_flags = dev_info.feature_flags;
3251 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3252 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3253 printf("Device doesn't support RAW data-path APIs.\n");
3254 return TEST_SKIPPED;
3257 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3258 return TEST_SKIPPED;
3260 /* Verify the capabilities */
3261 struct rte_cryptodev_sym_capability_idx cap_idx;
3262 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3263 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3264 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3266 return TEST_SKIPPED;
3268 /* Create KASUMI session */
3269 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3270 tdata->key.data, tdata->key.len,
3271 0, tdata->digest.len,
3272 RTE_CRYPTO_AUTH_OP_GENERATE,
3273 RTE_CRYPTO_AUTH_KASUMI_F9);
3277 /* alloc mbuf and set payload */
3278 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3280 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3281 rte_pktmbuf_tailroom(ut_params->ibuf));
3283 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3284 /* Append data which is padded to a multiple of */
3285 /* the algorithms block size */
3286 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3287 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3289 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3291 /* Create KASUMI operation */
3292 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3294 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3295 tdata->plaintext.len,
3300 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3301 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3303 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3304 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3305 ut_params->op, 0, 1, 1, 0);
3307 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3310 ut_params->obuf = ut_params->op->sym->m_src;
3311 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3312 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3313 + plaintext_pad_len;
3316 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3319 DIGEST_BYTE_LENGTH_KASUMI_F9,
3320 "KASUMI Generated auth tag not as expected");
3326 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3328 struct crypto_testsuite_params *ts_params = &testsuite_params;
3329 struct crypto_unittest_params *ut_params = &unittest_params;
3332 unsigned plaintext_pad_len;
3333 unsigned plaintext_len;
3335 struct rte_cryptodev_info dev_info;
3337 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3338 uint64_t feat_flags = dev_info.feature_flags;
3340 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3341 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3342 printf("Device doesn't support RAW data-path APIs.\n");
3343 return TEST_SKIPPED;
3346 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3347 return TEST_SKIPPED;
3349 /* Verify the capabilities */
3350 struct rte_cryptodev_sym_capability_idx cap_idx;
3351 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3352 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3353 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3355 return TEST_SKIPPED;
3357 /* Create KASUMI session */
3358 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3359 tdata->key.data, tdata->key.len,
3360 0, tdata->digest.len,
3361 RTE_CRYPTO_AUTH_OP_VERIFY,
3362 RTE_CRYPTO_AUTH_KASUMI_F9);
3365 /* alloc mbuf and set payload */
3366 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3368 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3369 rte_pktmbuf_tailroom(ut_params->ibuf));
3371 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3372 /* Append data which is padded to a multiple */
3373 /* of the algorithms block size */
3374 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3375 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3377 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3379 /* Create KASUMI operation */
3380 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3384 RTE_CRYPTO_AUTH_OP_VERIFY,
3385 tdata->plaintext.len,
3390 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3391 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3392 ut_params->op, 0, 1, 1, 0);
3394 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3396 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3397 ut_params->obuf = ut_params->op->sym->m_src;
3398 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3399 + plaintext_pad_len;
3402 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3411 test_snow3g_hash_generate_test_case_1(void)
3413 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3417 test_snow3g_hash_generate_test_case_2(void)
3419 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3423 test_snow3g_hash_generate_test_case_3(void)
3425 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3429 test_snow3g_hash_generate_test_case_4(void)
3431 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3435 test_snow3g_hash_generate_test_case_5(void)
3437 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3441 test_snow3g_hash_generate_test_case_6(void)
3443 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3447 test_snow3g_hash_verify_test_case_1(void)
3449 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3454 test_snow3g_hash_verify_test_case_2(void)
3456 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3460 test_snow3g_hash_verify_test_case_3(void)
3462 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3466 test_snow3g_hash_verify_test_case_4(void)
3468 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3472 test_snow3g_hash_verify_test_case_5(void)
3474 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3478 test_snow3g_hash_verify_test_case_6(void)
3480 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3484 test_kasumi_hash_generate_test_case_1(void)
3486 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3490 test_kasumi_hash_generate_test_case_2(void)
3492 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3496 test_kasumi_hash_generate_test_case_3(void)
3498 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3502 test_kasumi_hash_generate_test_case_4(void)
3504 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3508 test_kasumi_hash_generate_test_case_5(void)
3510 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3514 test_kasumi_hash_generate_test_case_6(void)
3516 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3520 test_kasumi_hash_verify_test_case_1(void)
3522 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3526 test_kasumi_hash_verify_test_case_2(void)
3528 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3532 test_kasumi_hash_verify_test_case_3(void)
3534 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3538 test_kasumi_hash_verify_test_case_4(void)
3540 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3544 test_kasumi_hash_verify_test_case_5(void)
3546 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3550 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3552 struct crypto_testsuite_params *ts_params = &testsuite_params;
3553 struct crypto_unittest_params *ut_params = &unittest_params;
3556 uint8_t *plaintext, *ciphertext;
3557 unsigned plaintext_pad_len;
3558 unsigned plaintext_len;
3559 struct rte_cryptodev_info dev_info;
3561 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3562 uint64_t feat_flags = dev_info.feature_flags;
3564 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3565 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3566 printf("Device doesn't support RAW data-path APIs.\n");
3567 return TEST_SKIPPED;
3570 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3571 return TEST_SKIPPED;
3573 /* Verify the capabilities */
3574 struct rte_cryptodev_sym_capability_idx cap_idx;
3575 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3576 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3577 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3579 return TEST_SKIPPED;
3581 /* Create KASUMI session */
3582 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3583 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3584 RTE_CRYPTO_CIPHER_KASUMI_F8,
3585 tdata->key.data, tdata->key.len,
3586 tdata->cipher_iv.len);
3590 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3592 /* Clear mbuf payload */
3593 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3594 rte_pktmbuf_tailroom(ut_params->ibuf));
3596 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3597 /* Append data which is padded to a multiple */
3598 /* of the algorithms block size */
3599 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3600 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3602 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3604 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3606 /* Create KASUMI operation */
3607 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3608 tdata->cipher_iv.len,
3609 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3610 tdata->validCipherOffsetInBits.len);
3614 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3615 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3616 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3618 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3620 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3622 ut_params->obuf = ut_params->op->sym->m_dst;
3623 if (ut_params->obuf)
3624 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3626 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3628 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3630 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3631 (tdata->validCipherOffsetInBits.len >> 3);
3633 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3635 reference_ciphertext,
3636 tdata->validCipherLenInBits.len,
3637 "KASUMI Ciphertext data not as expected");
3642 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3644 struct crypto_testsuite_params *ts_params = &testsuite_params;
3645 struct crypto_unittest_params *ut_params = &unittest_params;
3649 unsigned int plaintext_pad_len;
3650 unsigned int plaintext_len;
3652 uint8_t buffer[10000];
3653 const uint8_t *ciphertext;
3655 struct rte_cryptodev_info dev_info;
3657 /* Verify the capabilities */
3658 struct rte_cryptodev_sym_capability_idx cap_idx;
3659 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3660 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3661 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3663 return TEST_SKIPPED;
3665 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3667 uint64_t feat_flags = dev_info.feature_flags;
3669 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3670 printf("Device doesn't support in-place scatter-gather. "
3672 return TEST_SKIPPED;
3675 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3676 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3677 printf("Device doesn't support RAW data-path APIs.\n");
3678 return TEST_SKIPPED;
3681 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3682 return TEST_SKIPPED;
3684 /* Create KASUMI session */
3685 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3686 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3687 RTE_CRYPTO_CIPHER_KASUMI_F8,
3688 tdata->key.data, tdata->key.len,
3689 tdata->cipher_iv.len);
3693 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3696 /* Append data which is padded to a multiple */
3697 /* of the algorithms block size */
3698 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3700 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3701 plaintext_pad_len, 10, 0);
3703 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3705 /* Create KASUMI operation */
3706 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3707 tdata->cipher_iv.len,
3708 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3709 tdata->validCipherOffsetInBits.len);
3713 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3714 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3715 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3717 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3719 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3721 ut_params->obuf = ut_params->op->sym->m_dst;
3723 if (ut_params->obuf)
3724 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3725 plaintext_len, buffer);
3727 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3728 tdata->validCipherOffsetInBits.len >> 3,
3729 plaintext_len, buffer);
3732 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3734 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3735 (tdata->validCipherOffsetInBits.len >> 3);
3737 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3739 reference_ciphertext,
3740 tdata->validCipherLenInBits.len,
3741 "KASUMI Ciphertext data not as expected");
3746 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3748 struct crypto_testsuite_params *ts_params = &testsuite_params;
3749 struct crypto_unittest_params *ut_params = &unittest_params;
3752 uint8_t *plaintext, *ciphertext;
3753 unsigned plaintext_pad_len;
3754 unsigned plaintext_len;
3756 /* Verify the capabilities */
3757 struct rte_cryptodev_sym_capability_idx cap_idx;
3758 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3759 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3760 /* Data-path service does not support OOP */
3761 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3763 return TEST_SKIPPED;
3765 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3766 return TEST_SKIPPED;
3768 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3769 return TEST_SKIPPED;
3771 /* Create KASUMI session */
3772 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3773 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3774 RTE_CRYPTO_CIPHER_KASUMI_F8,
3775 tdata->key.data, tdata->key.len,
3776 tdata->cipher_iv.len);
3780 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3781 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3783 /* Clear mbuf payload */
3784 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3785 rte_pktmbuf_tailroom(ut_params->ibuf));
3787 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3788 /* Append data which is padded to a multiple */
3789 /* of the algorithms block size */
3790 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3791 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3793 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3794 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3796 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3798 /* Create KASUMI operation */
3799 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3800 tdata->cipher_iv.len,
3801 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3802 tdata->validCipherOffsetInBits.len);
3806 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3808 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3810 ut_params->obuf = ut_params->op->sym->m_dst;
3811 if (ut_params->obuf)
3812 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3814 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3816 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3818 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3819 (tdata->validCipherOffsetInBits.len >> 3);
3821 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3823 reference_ciphertext,
3824 tdata->validCipherLenInBits.len,
3825 "KASUMI Ciphertext data not as expected");
3830 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3832 struct crypto_testsuite_params *ts_params = &testsuite_params;
3833 struct crypto_unittest_params *ut_params = &unittest_params;
3836 unsigned int plaintext_pad_len;
3837 unsigned int plaintext_len;
3839 const uint8_t *ciphertext;
3840 uint8_t buffer[2048];
3842 struct rte_cryptodev_info dev_info;
3844 /* Verify the capabilities */
3845 struct rte_cryptodev_sym_capability_idx cap_idx;
3846 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3847 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3848 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3850 return TEST_SKIPPED;
3852 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3853 return TEST_SKIPPED;
3855 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3856 return TEST_SKIPPED;
3858 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3860 uint64_t feat_flags = dev_info.feature_flags;
3861 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3862 printf("Device doesn't support out-of-place scatter-gather "
3863 "in both input and output mbufs. "
3865 return TEST_SKIPPED;
3868 /* Create KASUMI session */
3869 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3870 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3871 RTE_CRYPTO_CIPHER_KASUMI_F8,
3872 tdata->key.data, tdata->key.len,
3873 tdata->cipher_iv.len);
3877 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3878 /* Append data which is padded to a multiple */
3879 /* of the algorithms block size */
3880 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3882 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3883 plaintext_pad_len, 10, 0);
3884 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3885 plaintext_pad_len, 3, 0);
3887 /* Append data which is padded to a multiple */
3888 /* of the algorithms block size */
3889 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3891 /* Create KASUMI operation */
3892 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3893 tdata->cipher_iv.len,
3894 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3895 tdata->validCipherOffsetInBits.len);
3899 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3901 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3903 ut_params->obuf = ut_params->op->sym->m_dst;
3904 if (ut_params->obuf)
3905 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3906 plaintext_pad_len, buffer);
3908 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3909 tdata->validCipherOffsetInBits.len >> 3,
3910 plaintext_pad_len, buffer);
3912 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3913 (tdata->validCipherOffsetInBits.len >> 3);
3915 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3917 reference_ciphertext,
3918 tdata->validCipherLenInBits.len,
3919 "KASUMI Ciphertext data not as expected");
3925 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3927 struct crypto_testsuite_params *ts_params = &testsuite_params;
3928 struct crypto_unittest_params *ut_params = &unittest_params;
3931 uint8_t *ciphertext, *plaintext;
3932 unsigned ciphertext_pad_len;
3933 unsigned ciphertext_len;
3935 /* Verify the capabilities */
3936 struct rte_cryptodev_sym_capability_idx cap_idx;
3937 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3938 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3939 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3941 return TEST_SKIPPED;
3943 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3944 return TEST_SKIPPED;
3946 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3947 return TEST_SKIPPED;
3949 /* Create KASUMI session */
3950 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3951 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3952 RTE_CRYPTO_CIPHER_KASUMI_F8,
3953 tdata->key.data, tdata->key.len,
3954 tdata->cipher_iv.len);
3958 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3959 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3961 /* Clear mbuf payload */
3962 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3963 rte_pktmbuf_tailroom(ut_params->ibuf));
3965 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3966 /* Append data which is padded to a multiple */
3967 /* of the algorithms block size */
3968 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3969 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3970 ciphertext_pad_len);
3971 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3972 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3974 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3976 /* Create KASUMI operation */
3977 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3978 tdata->cipher_iv.len,
3979 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3980 tdata->validCipherOffsetInBits.len);
3984 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3986 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3988 ut_params->obuf = ut_params->op->sym->m_dst;
3989 if (ut_params->obuf)
3990 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3992 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3994 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3996 const uint8_t *reference_plaintext = tdata->plaintext.data +
3997 (tdata->validCipherOffsetInBits.len >> 3);
3999 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4001 reference_plaintext,
4002 tdata->validCipherLenInBits.len,
4003 "KASUMI Plaintext data not as expected");
4008 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4010 struct crypto_testsuite_params *ts_params = &testsuite_params;
4011 struct crypto_unittest_params *ut_params = &unittest_params;
4014 uint8_t *ciphertext, *plaintext;
4015 unsigned ciphertext_pad_len;
4016 unsigned ciphertext_len;
4017 struct rte_cryptodev_info dev_info;
4019 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4020 uint64_t feat_flags = dev_info.feature_flags;
4022 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4023 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4024 printf("Device doesn't support RAW data-path APIs.\n");
4025 return TEST_SKIPPED;
4028 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4029 return TEST_SKIPPED;
4031 /* Verify the capabilities */
4032 struct rte_cryptodev_sym_capability_idx cap_idx;
4033 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4034 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4035 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4037 return TEST_SKIPPED;
4039 /* Create KASUMI session */
4040 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4041 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4042 RTE_CRYPTO_CIPHER_KASUMI_F8,
4043 tdata->key.data, tdata->key.len,
4044 tdata->cipher_iv.len);
4048 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4050 /* Clear mbuf payload */
4051 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4052 rte_pktmbuf_tailroom(ut_params->ibuf));
4054 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4055 /* Append data which is padded to a multiple */
4056 /* of the algorithms block size */
4057 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4058 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4059 ciphertext_pad_len);
4060 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4062 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4064 /* Create KASUMI operation */
4065 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4066 tdata->cipher_iv.len,
4067 tdata->ciphertext.len,
4068 tdata->validCipherOffsetInBits.len);
4072 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4073 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4074 ut_params->op, 1, 0, 1, 0);
4076 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4078 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4080 ut_params->obuf = ut_params->op->sym->m_dst;
4081 if (ut_params->obuf)
4082 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4084 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4086 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4088 const uint8_t *reference_plaintext = tdata->plaintext.data +
4089 (tdata->validCipherOffsetInBits.len >> 3);
4091 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4093 reference_plaintext,
4094 tdata->validCipherLenInBits.len,
4095 "KASUMI Plaintext data not as expected");
4100 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4102 struct crypto_testsuite_params *ts_params = &testsuite_params;
4103 struct crypto_unittest_params *ut_params = &unittest_params;
4106 uint8_t *plaintext, *ciphertext;
4107 unsigned plaintext_pad_len;
4108 unsigned plaintext_len;
4109 struct rte_cryptodev_info dev_info;
4111 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4112 uint64_t feat_flags = dev_info.feature_flags;
4114 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4115 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4116 printf("Device doesn't support RAW data-path APIs.\n");
4117 return TEST_SKIPPED;
4120 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4121 return TEST_SKIPPED;
4123 /* Verify the capabilities */
4124 struct rte_cryptodev_sym_capability_idx cap_idx;
4125 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4126 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4127 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4129 return TEST_SKIPPED;
4131 /* Create SNOW 3G session */
4132 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4133 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4134 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4135 tdata->key.data, tdata->key.len,
4136 tdata->cipher_iv.len);
4140 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4142 /* Clear mbuf payload */
4143 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4144 rte_pktmbuf_tailroom(ut_params->ibuf));
4146 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4147 /* Append data which is padded to a multiple of */
4148 /* the algorithms block size */
4149 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4150 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4152 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4154 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4156 /* Create SNOW 3G operation */
4157 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4158 tdata->cipher_iv.len,
4159 tdata->validCipherLenInBits.len,
4164 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4165 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4166 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4168 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4170 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4172 ut_params->obuf = ut_params->op->sym->m_dst;
4173 if (ut_params->obuf)
4174 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4176 ciphertext = plaintext;
4178 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4181 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4183 tdata->ciphertext.data,
4184 tdata->validDataLenInBits.len,
4185 "SNOW 3G Ciphertext data not as expected");
4191 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4193 struct crypto_testsuite_params *ts_params = &testsuite_params;
4194 struct crypto_unittest_params *ut_params = &unittest_params;
4195 uint8_t *plaintext, *ciphertext;
4198 unsigned plaintext_pad_len;
4199 unsigned plaintext_len;
4201 /* Verify the capabilities */
4202 struct rte_cryptodev_sym_capability_idx cap_idx;
4203 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4204 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4205 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4207 return TEST_SKIPPED;
4209 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4210 return TEST_SKIPPED;
4212 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4213 return TEST_SKIPPED;
4215 /* Create SNOW 3G session */
4216 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4217 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4218 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4219 tdata->key.data, tdata->key.len,
4220 tdata->cipher_iv.len);
4224 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4225 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4227 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4228 "Failed to allocate input buffer in mempool");
4229 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4230 "Failed to allocate output buffer in mempool");
4232 /* Clear mbuf payload */
4233 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4234 rte_pktmbuf_tailroom(ut_params->ibuf));
4236 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4237 /* Append data which is padded to a multiple of */
4238 /* the algorithms block size */
4239 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4240 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4242 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4243 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4245 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4247 /* Create SNOW 3G operation */
4248 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4249 tdata->cipher_iv.len,
4250 tdata->validCipherLenInBits.len,
4255 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4257 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4259 ut_params->obuf = ut_params->op->sym->m_dst;
4260 if (ut_params->obuf)
4261 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4263 ciphertext = plaintext;
4265 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4268 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4270 tdata->ciphertext.data,
4271 tdata->validDataLenInBits.len,
4272 "SNOW 3G Ciphertext data not as expected");
4277 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4279 struct crypto_testsuite_params *ts_params = &testsuite_params;
4280 struct crypto_unittest_params *ut_params = &unittest_params;
4283 unsigned int plaintext_pad_len;
4284 unsigned int plaintext_len;
4285 uint8_t buffer[10000];
4286 const uint8_t *ciphertext;
4288 struct rte_cryptodev_info dev_info;
4290 /* Verify the capabilities */
4291 struct rte_cryptodev_sym_capability_idx cap_idx;
4292 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4293 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4294 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4296 return TEST_SKIPPED;
4298 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4299 return TEST_SKIPPED;
4301 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4302 return TEST_SKIPPED;
4304 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4306 uint64_t feat_flags = dev_info.feature_flags;
4308 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4309 printf("Device doesn't support out-of-place scatter-gather "
4310 "in both input and output mbufs. "
4312 return TEST_SKIPPED;
4315 /* Create SNOW 3G session */
4316 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4317 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4318 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4319 tdata->key.data, tdata->key.len,
4320 tdata->cipher_iv.len);
4324 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4325 /* Append data which is padded to a multiple of */
4326 /* the algorithms block size */
4327 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4329 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4330 plaintext_pad_len, 10, 0);
4331 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4332 plaintext_pad_len, 3, 0);
4334 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4335 "Failed to allocate input buffer in mempool");
4336 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4337 "Failed to allocate output buffer in mempool");
4339 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4341 /* Create SNOW 3G operation */
4342 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4343 tdata->cipher_iv.len,
4344 tdata->validCipherLenInBits.len,
4349 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4351 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4353 ut_params->obuf = ut_params->op->sym->m_dst;
4354 if (ut_params->obuf)
4355 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4356 plaintext_len, buffer);
4358 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4359 plaintext_len, buffer);
4361 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4364 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4366 tdata->ciphertext.data,
4367 tdata->validDataLenInBits.len,
4368 "SNOW 3G Ciphertext data not as expected");
4373 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4375 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4377 uint8_t curr_byte, prev_byte;
4378 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4379 uint8_t lower_byte_mask = (1 << offset) - 1;
4382 prev_byte = buffer[0];
4383 buffer[0] >>= offset;
4385 for (i = 1; i < length_in_bytes; i++) {
4386 curr_byte = buffer[i];
4387 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4388 (curr_byte >> offset);
4389 prev_byte = curr_byte;
4394 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4396 struct crypto_testsuite_params *ts_params = &testsuite_params;
4397 struct crypto_unittest_params *ut_params = &unittest_params;
4398 uint8_t *plaintext, *ciphertext;
4400 uint32_t plaintext_len;
4401 uint32_t plaintext_pad_len;
4402 uint8_t extra_offset = 4;
4403 uint8_t *expected_ciphertext_shifted;
4404 struct rte_cryptodev_info dev_info;
4406 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4407 uint64_t feat_flags = dev_info.feature_flags;
4409 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4410 ((tdata->validDataLenInBits.len % 8) != 0)) {
4411 printf("Device doesn't support NON-Byte Aligned Data.\n");
4412 return TEST_SKIPPED;
4415 /* Verify the capabilities */
4416 struct rte_cryptodev_sym_capability_idx cap_idx;
4417 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4418 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4419 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4421 return TEST_SKIPPED;
4423 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4424 return TEST_SKIPPED;
4426 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4427 return TEST_SKIPPED;
4429 /* Create SNOW 3G session */
4430 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4431 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4432 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4433 tdata->key.data, tdata->key.len,
4434 tdata->cipher_iv.len);
4438 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4439 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4441 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4442 "Failed to allocate input buffer in mempool");
4443 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4444 "Failed to allocate output buffer in mempool");
4446 /* Clear mbuf payload */
4447 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4448 rte_pktmbuf_tailroom(ut_params->ibuf));
4450 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4452 * Append data which is padded to a
4453 * multiple of the algorithms block size
4455 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4457 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4460 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4462 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4463 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4465 #ifdef RTE_APP_TEST_DEBUG
4466 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4468 /* Create SNOW 3G operation */
4469 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4470 tdata->cipher_iv.len,
4471 tdata->validCipherLenInBits.len,
4476 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4478 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4480 ut_params->obuf = ut_params->op->sym->m_dst;
4481 if (ut_params->obuf)
4482 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4484 ciphertext = plaintext;
4486 #ifdef RTE_APP_TEST_DEBUG
4487 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4490 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4492 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4493 "failed to reserve memory for ciphertext shifted\n");
4495 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4496 ceil_byte_length(tdata->ciphertext.len));
4497 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4500 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4502 expected_ciphertext_shifted,
4503 tdata->validDataLenInBits.len,
4505 "SNOW 3G Ciphertext data not as expected");
4509 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4511 struct crypto_testsuite_params *ts_params = &testsuite_params;
4512 struct crypto_unittest_params *ut_params = &unittest_params;
4516 uint8_t *plaintext, *ciphertext;
4517 unsigned ciphertext_pad_len;
4518 unsigned ciphertext_len;
4519 struct rte_cryptodev_info dev_info;
4521 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4522 uint64_t feat_flags = dev_info.feature_flags;
4524 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4525 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4526 printf("Device doesn't support RAW data-path APIs.\n");
4527 return TEST_SKIPPED;
4530 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4531 return TEST_SKIPPED;
4533 /* Verify the capabilities */
4534 struct rte_cryptodev_sym_capability_idx cap_idx;
4535 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4536 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4537 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4539 return TEST_SKIPPED;
4541 /* Create SNOW 3G session */
4542 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4543 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4544 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4545 tdata->key.data, tdata->key.len,
4546 tdata->cipher_iv.len);
4550 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4552 /* Clear mbuf payload */
4553 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4554 rte_pktmbuf_tailroom(ut_params->ibuf));
4556 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4557 /* Append data which is padded to a multiple of */
4558 /* the algorithms block size */
4559 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4560 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4561 ciphertext_pad_len);
4562 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4564 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4566 /* Create SNOW 3G operation */
4567 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4568 tdata->cipher_iv.len,
4569 tdata->validCipherLenInBits.len,
4570 tdata->cipher.offset_bits);
4574 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4575 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4576 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4578 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4580 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4581 ut_params->obuf = ut_params->op->sym->m_dst;
4582 if (ut_params->obuf)
4583 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4585 plaintext = ciphertext;
4587 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4590 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4591 tdata->plaintext.data,
4592 tdata->validDataLenInBits.len,
4593 "SNOW 3G Plaintext data not as expected");
4597 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4599 struct crypto_testsuite_params *ts_params = &testsuite_params;
4600 struct crypto_unittest_params *ut_params = &unittest_params;
4604 uint8_t *plaintext, *ciphertext;
4605 unsigned ciphertext_pad_len;
4606 unsigned ciphertext_len;
4608 /* Verify the capabilities */
4609 struct rte_cryptodev_sym_capability_idx cap_idx;
4610 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4611 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4612 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4614 return TEST_SKIPPED;
4616 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4617 return TEST_SKIPPED;
4619 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4620 return TEST_SKIPPED;
4622 /* Create SNOW 3G session */
4623 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4624 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4625 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4626 tdata->key.data, tdata->key.len,
4627 tdata->cipher_iv.len);
4631 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4632 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4634 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4635 "Failed to allocate input buffer");
4636 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4637 "Failed to allocate output buffer");
4639 /* Clear mbuf payload */
4640 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4641 rte_pktmbuf_tailroom(ut_params->ibuf));
4643 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4644 rte_pktmbuf_tailroom(ut_params->obuf));
4646 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4647 /* Append data which is padded to a multiple of */
4648 /* the algorithms block size */
4649 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4650 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4651 ciphertext_pad_len);
4652 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4653 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4655 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4657 /* Create SNOW 3G operation */
4658 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4659 tdata->cipher_iv.len,
4660 tdata->validCipherLenInBits.len,
4665 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4667 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4668 ut_params->obuf = ut_params->op->sym->m_dst;
4669 if (ut_params->obuf)
4670 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4672 plaintext = ciphertext;
4674 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4677 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4678 tdata->plaintext.data,
4679 tdata->validDataLenInBits.len,
4680 "SNOW 3G Plaintext data not as expected");
4685 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4687 struct crypto_testsuite_params *ts_params = &testsuite_params;
4688 struct crypto_unittest_params *ut_params = &unittest_params;
4692 uint8_t *plaintext, *ciphertext;
4693 unsigned int plaintext_pad_len;
4694 unsigned int plaintext_len;
4696 struct rte_cryptodev_info dev_info;
4697 struct rte_cryptodev_sym_capability_idx cap_idx;
4699 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4700 uint64_t feat_flags = dev_info.feature_flags;
4702 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4703 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4704 (tdata->validDataLenInBits.len % 8 != 0))) {
4705 printf("Device doesn't support NON-Byte Aligned Data.\n");
4706 return TEST_SKIPPED;
4709 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4710 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4711 printf("Device doesn't support RAW data-path APIs.\n");
4712 return TEST_SKIPPED;
4715 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4716 return TEST_SKIPPED;
4718 /* Check if device supports ZUC EEA3 */
4719 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4720 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4722 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4724 return TEST_SKIPPED;
4726 /* Check if device supports ZUC EIA3 */
4727 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4728 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4730 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4732 return TEST_SKIPPED;
4734 /* Create ZUC session */
4735 retval = create_zuc_cipher_auth_encrypt_generate_session(
4736 ts_params->valid_devs[0],
4740 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4742 /* clear mbuf payload */
4743 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4744 rte_pktmbuf_tailroom(ut_params->ibuf));
4746 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4747 /* Append data which is padded to a multiple of */
4748 /* the algorithms block size */
4749 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4750 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4752 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4754 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4756 /* Create ZUC operation */
4757 retval = create_zuc_cipher_hash_generate_operation(tdata);
4761 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4762 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4763 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4765 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4767 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4768 ut_params->obuf = ut_params->op->sym->m_src;
4769 if (ut_params->obuf)
4770 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4772 ciphertext = plaintext;
4774 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4776 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4778 tdata->ciphertext.data,
4779 tdata->validDataLenInBits.len,
4780 "ZUC Ciphertext data not as expected");
4782 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4783 + plaintext_pad_len;
4786 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4790 "ZUC Generated auth tag not as expected");
4795 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4797 struct crypto_testsuite_params *ts_params = &testsuite_params;
4798 struct crypto_unittest_params *ut_params = &unittest_params;
4802 uint8_t *plaintext, *ciphertext;
4803 unsigned plaintext_pad_len;
4804 unsigned plaintext_len;
4805 struct rte_cryptodev_info dev_info;
4807 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4808 uint64_t feat_flags = dev_info.feature_flags;
4810 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4811 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4812 printf("Device doesn't support RAW data-path APIs.\n");
4813 return TEST_SKIPPED;
4816 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4817 return TEST_SKIPPED;
4819 /* Verify the capabilities */
4820 struct rte_cryptodev_sym_capability_idx cap_idx;
4821 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4822 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4823 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4825 return TEST_SKIPPED;
4826 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4827 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4828 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4830 return TEST_SKIPPED;
4832 /* Create SNOW 3G session */
4833 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4834 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4835 RTE_CRYPTO_AUTH_OP_GENERATE,
4836 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4837 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4838 tdata->key.data, tdata->key.len,
4839 tdata->auth_iv.len, tdata->digest.len,
4840 tdata->cipher_iv.len);
4843 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4845 /* clear mbuf payload */
4846 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4847 rte_pktmbuf_tailroom(ut_params->ibuf));
4849 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4850 /* Append data which is padded to a multiple of */
4851 /* the algorithms block size */
4852 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4853 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4855 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4857 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4859 /* Create SNOW 3G operation */
4860 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4861 tdata->digest.len, tdata->auth_iv.data,
4863 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4864 tdata->cipher_iv.data, tdata->cipher_iv.len,
4865 tdata->validCipherLenInBits.len,
4867 tdata->validAuthLenInBits.len,
4873 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4874 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4875 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4877 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4879 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4880 ut_params->obuf = ut_params->op->sym->m_src;
4881 if (ut_params->obuf)
4882 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4884 ciphertext = plaintext;
4886 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4888 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4890 tdata->ciphertext.data,
4891 tdata->validDataLenInBits.len,
4892 "SNOW 3G Ciphertext data not as expected");
4894 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4895 + plaintext_pad_len;
4898 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4901 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4902 "SNOW 3G Generated auth tag not as expected");
4907 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4908 uint8_t op_mode, uint8_t verify)
4910 struct crypto_testsuite_params *ts_params = &testsuite_params;
4911 struct crypto_unittest_params *ut_params = &unittest_params;
4915 uint8_t *plaintext = NULL, *ciphertext = NULL;
4916 unsigned int plaintext_pad_len;
4917 unsigned int plaintext_len;
4918 unsigned int ciphertext_pad_len;
4919 unsigned int ciphertext_len;
4921 struct rte_cryptodev_info dev_info;
4923 /* Verify the capabilities */
4924 struct rte_cryptodev_sym_capability_idx cap_idx;
4925 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4926 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4927 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4929 return TEST_SKIPPED;
4930 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4931 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4932 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4934 return TEST_SKIPPED;
4936 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4937 return TEST_SKIPPED;
4939 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4941 uint64_t feat_flags = dev_info.feature_flags;
4943 if (op_mode == OUT_OF_PLACE) {
4944 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4945 printf("Device doesn't support digest encrypted.\n");
4946 return TEST_SKIPPED;
4948 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4949 return TEST_SKIPPED;
4952 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4953 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4954 printf("Device doesn't support RAW data-path APIs.\n");
4955 return TEST_SKIPPED;
4958 /* Create SNOW 3G session */
4959 retval = create_wireless_algo_auth_cipher_session(
4960 ts_params->valid_devs[0],
4961 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4962 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4963 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4964 : RTE_CRYPTO_AUTH_OP_GENERATE),
4965 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4966 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4967 tdata->key.data, tdata->key.len,
4968 tdata->auth_iv.len, tdata->digest.len,
4969 tdata->cipher_iv.len);
4973 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4974 if (op_mode == OUT_OF_PLACE)
4975 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4977 /* clear mbuf payload */
4978 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4979 rte_pktmbuf_tailroom(ut_params->ibuf));
4980 if (op_mode == OUT_OF_PLACE)
4981 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4982 rte_pktmbuf_tailroom(ut_params->obuf));
4984 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4985 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4986 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4987 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4990 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4991 ciphertext_pad_len);
4992 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4993 if (op_mode == OUT_OF_PLACE)
4994 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4995 debug_hexdump(stdout, "ciphertext:", ciphertext,
4998 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5000 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5001 if (op_mode == OUT_OF_PLACE)
5002 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5003 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5006 /* Create SNOW 3G operation */
5007 retval = create_wireless_algo_auth_cipher_operation(
5008 tdata->digest.data, tdata->digest.len,
5009 tdata->cipher_iv.data, tdata->cipher_iv.len,
5010 tdata->auth_iv.data, tdata->auth_iv.len,
5011 (tdata->digest.offset_bytes == 0 ?
5012 (verify ? ciphertext_pad_len : plaintext_pad_len)
5013 : tdata->digest.offset_bytes),
5014 tdata->validCipherLenInBits.len,
5015 tdata->cipher.offset_bits,
5016 tdata->validAuthLenInBits.len,
5017 tdata->auth.offset_bits,
5018 op_mode, 0, verify);
5023 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5024 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5025 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5027 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5030 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5032 ut_params->obuf = (op_mode == IN_PLACE ?
5033 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5036 if (ut_params->obuf)
5037 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5040 plaintext = ciphertext +
5041 (tdata->cipher.offset_bits >> 3);
5043 debug_hexdump(stdout, "plaintext:", plaintext,
5044 (tdata->plaintext.len >> 3) - tdata->digest.len);
5045 debug_hexdump(stdout, "plaintext expected:",
5046 tdata->plaintext.data,
5047 (tdata->plaintext.len >> 3) - tdata->digest.len);
5049 if (ut_params->obuf)
5050 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5053 ciphertext = plaintext;
5055 debug_hexdump(stdout, "ciphertext:", ciphertext,
5057 debug_hexdump(stdout, "ciphertext expected:",
5058 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5060 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5061 + (tdata->digest.offset_bytes == 0 ?
5062 plaintext_pad_len : tdata->digest.offset_bytes);
5064 debug_hexdump(stdout, "digest:", ut_params->digest,
5066 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5072 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5074 tdata->plaintext.data,
5075 (tdata->plaintext.len - tdata->cipher.offset_bits -
5076 (tdata->digest.len << 3)),
5077 tdata->cipher.offset_bits,
5078 "SNOW 3G Plaintext data not as expected");
5080 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5082 tdata->ciphertext.data,
5083 (tdata->validDataLenInBits.len -
5084 tdata->cipher.offset_bits),
5085 tdata->cipher.offset_bits,
5086 "SNOW 3G Ciphertext data not as expected");
5088 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5091 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5092 "SNOW 3G Generated auth tag not as expected");
5098 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5099 uint8_t op_mode, uint8_t verify)
5101 struct crypto_testsuite_params *ts_params = &testsuite_params;
5102 struct crypto_unittest_params *ut_params = &unittest_params;
5106 const uint8_t *plaintext = NULL;
5107 const uint8_t *ciphertext = NULL;
5108 const uint8_t *digest = NULL;
5109 unsigned int plaintext_pad_len;
5110 unsigned int plaintext_len;
5111 unsigned int ciphertext_pad_len;
5112 unsigned int ciphertext_len;
5113 uint8_t buffer[10000];
5114 uint8_t digest_buffer[10000];
5116 struct rte_cryptodev_info dev_info;
5118 /* Verify the capabilities */
5119 struct rte_cryptodev_sym_capability_idx cap_idx;
5120 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5121 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5122 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5124 return TEST_SKIPPED;
5125 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5126 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5127 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5129 return TEST_SKIPPED;
5131 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5132 return TEST_SKIPPED;
5134 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5136 uint64_t feat_flags = dev_info.feature_flags;
5138 if (op_mode == IN_PLACE) {
5139 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5140 printf("Device doesn't support in-place scatter-gather "
5141 "in both input and output mbufs.\n");
5142 return TEST_SKIPPED;
5144 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5145 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5146 printf("Device doesn't support RAW data-path APIs.\n");
5147 return TEST_SKIPPED;
5150 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5151 return TEST_SKIPPED;
5152 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5153 printf("Device doesn't support out-of-place scatter-gather "
5154 "in both input and output mbufs.\n");
5155 return TEST_SKIPPED;
5157 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5158 printf("Device doesn't support digest encrypted.\n");
5159 return TEST_SKIPPED;
5163 /* Create SNOW 3G session */
5164 retval = create_wireless_algo_auth_cipher_session(
5165 ts_params->valid_devs[0],
5166 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5167 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5168 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5169 : RTE_CRYPTO_AUTH_OP_GENERATE),
5170 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5171 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5172 tdata->key.data, tdata->key.len,
5173 tdata->auth_iv.len, tdata->digest.len,
5174 tdata->cipher_iv.len);
5179 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5180 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5181 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5182 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5184 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5185 plaintext_pad_len, 15, 0);
5186 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5187 "Failed to allocate input buffer in mempool");
5189 if (op_mode == OUT_OF_PLACE) {
5190 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5191 plaintext_pad_len, 15, 0);
5192 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5193 "Failed to allocate output buffer in mempool");
5197 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5198 tdata->ciphertext.data);
5199 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5200 ciphertext_len, buffer);
5201 debug_hexdump(stdout, "ciphertext:", ciphertext,
5204 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5205 tdata->plaintext.data);
5206 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5207 plaintext_len, buffer);
5208 debug_hexdump(stdout, "plaintext:", plaintext,
5211 memset(buffer, 0, sizeof(buffer));
5213 /* Create SNOW 3G operation */
5214 retval = create_wireless_algo_auth_cipher_operation(
5215 tdata->digest.data, tdata->digest.len,
5216 tdata->cipher_iv.data, tdata->cipher_iv.len,
5217 tdata->auth_iv.data, tdata->auth_iv.len,
5218 (tdata->digest.offset_bytes == 0 ?
5219 (verify ? ciphertext_pad_len : plaintext_pad_len)
5220 : tdata->digest.offset_bytes),
5221 tdata->validCipherLenInBits.len,
5222 tdata->cipher.offset_bits,
5223 tdata->validAuthLenInBits.len,
5224 tdata->auth.offset_bits,
5225 op_mode, 1, verify);
5230 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5231 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5232 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5234 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5237 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5239 ut_params->obuf = (op_mode == IN_PLACE ?
5240 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5243 if (ut_params->obuf)
5244 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5245 plaintext_len, buffer);
5247 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5248 plaintext_len, buffer);
5250 debug_hexdump(stdout, "plaintext:", plaintext,
5251 (tdata->plaintext.len >> 3) - tdata->digest.len);
5252 debug_hexdump(stdout, "plaintext expected:",
5253 tdata->plaintext.data,
5254 (tdata->plaintext.len >> 3) - tdata->digest.len);
5256 if (ut_params->obuf)
5257 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5258 ciphertext_len, buffer);
5260 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5261 ciphertext_len, buffer);
5263 debug_hexdump(stdout, "ciphertext:", ciphertext,
5265 debug_hexdump(stdout, "ciphertext expected:",
5266 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5268 if (ut_params->obuf)
5269 digest = rte_pktmbuf_read(ut_params->obuf,
5270 (tdata->digest.offset_bytes == 0 ?
5271 plaintext_pad_len : tdata->digest.offset_bytes),
5272 tdata->digest.len, digest_buffer);
5274 digest = rte_pktmbuf_read(ut_params->ibuf,
5275 (tdata->digest.offset_bytes == 0 ?
5276 plaintext_pad_len : tdata->digest.offset_bytes),
5277 tdata->digest.len, digest_buffer);
5279 debug_hexdump(stdout, "digest:", digest,
5281 debug_hexdump(stdout, "digest expected:",
5282 tdata->digest.data, tdata->digest.len);
5287 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5289 tdata->plaintext.data,
5290 (tdata->plaintext.len - tdata->cipher.offset_bits -
5291 (tdata->digest.len << 3)),
5292 tdata->cipher.offset_bits,
5293 "SNOW 3G Plaintext data not as expected");
5295 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5297 tdata->ciphertext.data,
5298 (tdata->validDataLenInBits.len -
5299 tdata->cipher.offset_bits),
5300 tdata->cipher.offset_bits,
5301 "SNOW 3G Ciphertext data not as expected");
5303 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5306 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5307 "SNOW 3G Generated auth tag not as expected");
5313 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5314 uint8_t op_mode, uint8_t verify)
5316 struct crypto_testsuite_params *ts_params = &testsuite_params;
5317 struct crypto_unittest_params *ut_params = &unittest_params;
5321 uint8_t *plaintext = NULL, *ciphertext = NULL;
5322 unsigned int plaintext_pad_len;
5323 unsigned int plaintext_len;
5324 unsigned int ciphertext_pad_len;
5325 unsigned int ciphertext_len;
5327 struct rte_cryptodev_info dev_info;
5329 /* Verify the capabilities */
5330 struct rte_cryptodev_sym_capability_idx cap_idx;
5331 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5332 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5333 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5335 return TEST_SKIPPED;
5336 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5337 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5338 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5340 return TEST_SKIPPED;
5342 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5344 uint64_t feat_flags = dev_info.feature_flags;
5346 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5347 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5348 printf("Device doesn't support RAW data-path APIs.\n");
5349 return TEST_SKIPPED;
5352 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5353 return TEST_SKIPPED;
5355 if (op_mode == OUT_OF_PLACE) {
5356 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5357 return TEST_SKIPPED;
5358 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5359 printf("Device doesn't support digest encrypted.\n");
5360 return TEST_SKIPPED;
5364 /* Create KASUMI session */
5365 retval = create_wireless_algo_auth_cipher_session(
5366 ts_params->valid_devs[0],
5367 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5368 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5369 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5370 : RTE_CRYPTO_AUTH_OP_GENERATE),
5371 RTE_CRYPTO_AUTH_KASUMI_F9,
5372 RTE_CRYPTO_CIPHER_KASUMI_F8,
5373 tdata->key.data, tdata->key.len,
5374 0, tdata->digest.len,
5375 tdata->cipher_iv.len);
5380 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5381 if (op_mode == OUT_OF_PLACE)
5382 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5384 /* clear mbuf payload */
5385 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5386 rte_pktmbuf_tailroom(ut_params->ibuf));
5387 if (op_mode == OUT_OF_PLACE)
5388 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5389 rte_pktmbuf_tailroom(ut_params->obuf));
5391 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5392 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5393 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5394 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5397 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5398 ciphertext_pad_len);
5399 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5400 if (op_mode == OUT_OF_PLACE)
5401 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5402 debug_hexdump(stdout, "ciphertext:", ciphertext,
5405 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5407 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5408 if (op_mode == OUT_OF_PLACE)
5409 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5410 debug_hexdump(stdout, "plaintext:", plaintext,
5414 /* Create KASUMI operation */
5415 retval = create_wireless_algo_auth_cipher_operation(
5416 tdata->digest.data, tdata->digest.len,
5417 tdata->cipher_iv.data, tdata->cipher_iv.len,
5419 (tdata->digest.offset_bytes == 0 ?
5420 (verify ? ciphertext_pad_len : plaintext_pad_len)
5421 : tdata->digest.offset_bytes),
5422 tdata->validCipherLenInBits.len,
5423 tdata->validCipherOffsetInBits.len,
5424 tdata->validAuthLenInBits.len,
5426 op_mode, 0, verify);
5431 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5432 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5433 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5435 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5438 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5440 ut_params->obuf = (op_mode == IN_PLACE ?
5441 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5445 if (ut_params->obuf)
5446 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5449 plaintext = ciphertext;
5451 debug_hexdump(stdout, "plaintext:", plaintext,
5452 (tdata->plaintext.len >> 3) - tdata->digest.len);
5453 debug_hexdump(stdout, "plaintext expected:",
5454 tdata->plaintext.data,
5455 (tdata->plaintext.len >> 3) - tdata->digest.len);
5457 if (ut_params->obuf)
5458 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5461 ciphertext = plaintext;
5463 debug_hexdump(stdout, "ciphertext:", ciphertext,
5465 debug_hexdump(stdout, "ciphertext expected:",
5466 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5468 ut_params->digest = rte_pktmbuf_mtod(
5469 ut_params->obuf, uint8_t *) +
5470 (tdata->digest.offset_bytes == 0 ?
5471 plaintext_pad_len : tdata->digest.offset_bytes);
5473 debug_hexdump(stdout, "digest:", ut_params->digest,
5475 debug_hexdump(stdout, "digest expected:",
5476 tdata->digest.data, tdata->digest.len);
5481 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5483 tdata->plaintext.data,
5484 tdata->plaintext.len >> 3,
5485 "KASUMI Plaintext data not as expected");
5487 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5489 tdata->ciphertext.data,
5490 tdata->ciphertext.len >> 3,
5491 "KASUMI Ciphertext data not as expected");
5493 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5496 DIGEST_BYTE_LENGTH_KASUMI_F9,
5497 "KASUMI Generated auth tag not as expected");
5503 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5504 uint8_t op_mode, uint8_t verify)
5506 struct crypto_testsuite_params *ts_params = &testsuite_params;
5507 struct crypto_unittest_params *ut_params = &unittest_params;
5511 const uint8_t *plaintext = NULL;
5512 const uint8_t *ciphertext = NULL;
5513 const uint8_t *digest = NULL;
5514 unsigned int plaintext_pad_len;
5515 unsigned int plaintext_len;
5516 unsigned int ciphertext_pad_len;
5517 unsigned int ciphertext_len;
5518 uint8_t buffer[10000];
5519 uint8_t digest_buffer[10000];
5521 struct rte_cryptodev_info dev_info;
5523 /* Verify the capabilities */
5524 struct rte_cryptodev_sym_capability_idx cap_idx;
5525 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5526 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5527 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5529 return TEST_SKIPPED;
5530 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5531 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5532 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5534 return TEST_SKIPPED;
5536 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5537 return TEST_SKIPPED;
5539 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5541 uint64_t feat_flags = dev_info.feature_flags;
5543 if (op_mode == IN_PLACE) {
5544 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5545 printf("Device doesn't support in-place scatter-gather "
5546 "in both input and output mbufs.\n");
5547 return TEST_SKIPPED;
5549 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5550 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5551 printf("Device doesn't support RAW data-path APIs.\n");
5552 return TEST_SKIPPED;
5555 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5556 return TEST_SKIPPED;
5557 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5558 printf("Device doesn't support out-of-place scatter-gather "
5559 "in both input and output mbufs.\n");
5560 return TEST_SKIPPED;
5562 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5563 printf("Device doesn't support digest encrypted.\n");
5564 return TEST_SKIPPED;
5568 /* Create KASUMI session */
5569 retval = create_wireless_algo_auth_cipher_session(
5570 ts_params->valid_devs[0],
5571 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5572 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5573 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5574 : RTE_CRYPTO_AUTH_OP_GENERATE),
5575 RTE_CRYPTO_AUTH_KASUMI_F9,
5576 RTE_CRYPTO_CIPHER_KASUMI_F8,
5577 tdata->key.data, tdata->key.len,
5578 0, tdata->digest.len,
5579 tdata->cipher_iv.len);
5584 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5585 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5586 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5587 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5589 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5590 plaintext_pad_len, 15, 0);
5591 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5592 "Failed to allocate input buffer in mempool");
5594 if (op_mode == OUT_OF_PLACE) {
5595 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5596 plaintext_pad_len, 15, 0);
5597 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5598 "Failed to allocate output buffer in mempool");
5602 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5603 tdata->ciphertext.data);
5604 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5605 ciphertext_len, buffer);
5606 debug_hexdump(stdout, "ciphertext:", ciphertext,
5609 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5610 tdata->plaintext.data);
5611 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5612 plaintext_len, buffer);
5613 debug_hexdump(stdout, "plaintext:", plaintext,
5616 memset(buffer, 0, sizeof(buffer));
5618 /* Create KASUMI operation */
5619 retval = create_wireless_algo_auth_cipher_operation(
5620 tdata->digest.data, tdata->digest.len,
5621 tdata->cipher_iv.data, tdata->cipher_iv.len,
5623 (tdata->digest.offset_bytes == 0 ?
5624 (verify ? ciphertext_pad_len : plaintext_pad_len)
5625 : tdata->digest.offset_bytes),
5626 tdata->validCipherLenInBits.len,
5627 tdata->validCipherOffsetInBits.len,
5628 tdata->validAuthLenInBits.len,
5630 op_mode, 1, verify);
5635 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5636 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5637 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5639 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5642 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5644 ut_params->obuf = (op_mode == IN_PLACE ?
5645 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5648 if (ut_params->obuf)
5649 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5650 plaintext_len, buffer);
5652 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5653 plaintext_len, buffer);
5655 debug_hexdump(stdout, "plaintext:", plaintext,
5656 (tdata->plaintext.len >> 3) - tdata->digest.len);
5657 debug_hexdump(stdout, "plaintext expected:",
5658 tdata->plaintext.data,
5659 (tdata->plaintext.len >> 3) - tdata->digest.len);
5661 if (ut_params->obuf)
5662 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5663 ciphertext_len, buffer);
5665 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5666 ciphertext_len, buffer);
5668 debug_hexdump(stdout, "ciphertext:", ciphertext,
5670 debug_hexdump(stdout, "ciphertext expected:",
5671 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5673 if (ut_params->obuf)
5674 digest = rte_pktmbuf_read(ut_params->obuf,
5675 (tdata->digest.offset_bytes == 0 ?
5676 plaintext_pad_len : tdata->digest.offset_bytes),
5677 tdata->digest.len, digest_buffer);
5679 digest = rte_pktmbuf_read(ut_params->ibuf,
5680 (tdata->digest.offset_bytes == 0 ?
5681 plaintext_pad_len : tdata->digest.offset_bytes),
5682 tdata->digest.len, digest_buffer);
5684 debug_hexdump(stdout, "digest:", digest,
5686 debug_hexdump(stdout, "digest expected:",
5687 tdata->digest.data, tdata->digest.len);
5692 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5694 tdata->plaintext.data,
5695 tdata->plaintext.len >> 3,
5696 "KASUMI Plaintext data not as expected");
5698 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5700 tdata->ciphertext.data,
5701 tdata->validDataLenInBits.len,
5702 "KASUMI Ciphertext data not as expected");
5704 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5707 DIGEST_BYTE_LENGTH_KASUMI_F9,
5708 "KASUMI Generated auth tag not as expected");
5714 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5716 struct crypto_testsuite_params *ts_params = &testsuite_params;
5717 struct crypto_unittest_params *ut_params = &unittest_params;
5721 uint8_t *plaintext, *ciphertext;
5722 unsigned plaintext_pad_len;
5723 unsigned plaintext_len;
5724 struct rte_cryptodev_info dev_info;
5726 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5727 uint64_t feat_flags = dev_info.feature_flags;
5729 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5730 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5731 printf("Device doesn't support RAW data-path APIs.\n");
5732 return TEST_SKIPPED;
5735 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5736 return TEST_SKIPPED;
5738 /* Verify the capabilities */
5739 struct rte_cryptodev_sym_capability_idx cap_idx;
5740 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5741 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5742 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5744 return TEST_SKIPPED;
5745 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5746 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5747 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5749 return TEST_SKIPPED;
5751 /* Create KASUMI session */
5752 retval = create_wireless_algo_cipher_auth_session(
5753 ts_params->valid_devs[0],
5754 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5755 RTE_CRYPTO_AUTH_OP_GENERATE,
5756 RTE_CRYPTO_AUTH_KASUMI_F9,
5757 RTE_CRYPTO_CIPHER_KASUMI_F8,
5758 tdata->key.data, tdata->key.len,
5759 0, tdata->digest.len,
5760 tdata->cipher_iv.len);
5764 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5766 /* clear mbuf payload */
5767 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5768 rte_pktmbuf_tailroom(ut_params->ibuf));
5770 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5771 /* Append data which is padded to a multiple of */
5772 /* the algorithms block size */
5773 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5774 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5776 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5778 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5780 /* Create KASUMI operation */
5781 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5782 tdata->digest.len, NULL, 0,
5783 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5784 tdata->cipher_iv.data, tdata->cipher_iv.len,
5785 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5786 tdata->validCipherOffsetInBits.len,
5787 tdata->validAuthLenInBits.len,
5793 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5794 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5795 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5797 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5799 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5801 if (ut_params->op->sym->m_dst)
5802 ut_params->obuf = ut_params->op->sym->m_dst;
5804 ut_params->obuf = ut_params->op->sym->m_src;
5806 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5807 tdata->validCipherOffsetInBits.len >> 3);
5809 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5810 + plaintext_pad_len;
5812 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5813 (tdata->validCipherOffsetInBits.len >> 3);
5815 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5817 reference_ciphertext,
5818 tdata->validCipherLenInBits.len,
5819 "KASUMI Ciphertext data not as expected");
5822 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5825 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5826 "KASUMI Generated auth tag not as expected");
5831 test_zuc_encryption(const struct wireless_test_data *tdata)
5833 struct crypto_testsuite_params *ts_params = &testsuite_params;
5834 struct crypto_unittest_params *ut_params = &unittest_params;
5837 uint8_t *plaintext, *ciphertext;
5838 unsigned plaintext_pad_len;
5839 unsigned plaintext_len;
5840 struct rte_cryptodev_info dev_info;
5842 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5843 uint64_t feat_flags = dev_info.feature_flags;
5845 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5846 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5847 printf("Device doesn't support RAW data-path APIs.\n");
5848 return TEST_SKIPPED;
5851 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5852 return TEST_SKIPPED;
5854 struct rte_cryptodev_sym_capability_idx cap_idx;
5856 /* Check if device supports ZUC EEA3 */
5857 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5858 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5860 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5862 return TEST_SKIPPED;
5864 /* Create ZUC session */
5865 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5866 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5867 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5868 tdata->key.data, tdata->key.len,
5869 tdata->cipher_iv.len);
5873 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5875 /* Clear mbuf payload */
5876 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5877 rte_pktmbuf_tailroom(ut_params->ibuf));
5879 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5880 /* Append data which is padded to a multiple */
5881 /* of the algorithms block size */
5882 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5883 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5885 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5887 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5889 /* Create ZUC operation */
5890 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5891 tdata->cipher_iv.len,
5892 tdata->plaintext.len,
5897 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5898 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5899 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5901 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5903 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5905 ut_params->obuf = ut_params->op->sym->m_dst;
5906 if (ut_params->obuf)
5907 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5909 ciphertext = plaintext;
5911 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5914 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5916 tdata->ciphertext.data,
5917 tdata->validCipherLenInBits.len,
5918 "ZUC Ciphertext data not as expected");
5923 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5925 struct crypto_testsuite_params *ts_params = &testsuite_params;
5926 struct crypto_unittest_params *ut_params = &unittest_params;
5930 unsigned int plaintext_pad_len;
5931 unsigned int plaintext_len;
5932 const uint8_t *ciphertext;
5933 uint8_t ciphertext_buffer[2048];
5934 struct rte_cryptodev_info dev_info;
5936 struct rte_cryptodev_sym_capability_idx cap_idx;
5938 /* Check if device supports ZUC EEA3 */
5939 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5940 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5942 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5944 return TEST_SKIPPED;
5946 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5947 return TEST_SKIPPED;
5949 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5951 uint64_t feat_flags = dev_info.feature_flags;
5953 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5954 printf("Device doesn't support in-place scatter-gather. "
5956 return TEST_SKIPPED;
5959 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5960 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5961 printf("Device doesn't support RAW data-path APIs.\n");
5962 return TEST_SKIPPED;
5965 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5967 /* Append data which is padded to a multiple */
5968 /* of the algorithms block size */
5969 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5971 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5972 plaintext_pad_len, 10, 0);
5974 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5975 tdata->plaintext.data);
5977 /* Create ZUC session */
5978 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5979 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5980 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5981 tdata->key.data, tdata->key.len,
5982 tdata->cipher_iv.len);
5986 /* Clear mbuf payload */
5988 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5990 /* Create ZUC operation */
5991 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5992 tdata->cipher_iv.len, tdata->plaintext.len,
5997 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5998 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5999 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6001 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6003 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6005 ut_params->obuf = ut_params->op->sym->m_dst;
6006 if (ut_params->obuf)
6007 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6008 0, plaintext_len, ciphertext_buffer);
6010 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6011 0, plaintext_len, ciphertext_buffer);
6014 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6017 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6019 tdata->ciphertext.data,
6020 tdata->validCipherLenInBits.len,
6021 "ZUC Ciphertext data not as expected");
6027 test_zuc_authentication(const struct wireless_test_data *tdata)
6029 struct crypto_testsuite_params *ts_params = &testsuite_params;
6030 struct crypto_unittest_params *ut_params = &unittest_params;
6033 unsigned plaintext_pad_len;
6034 unsigned plaintext_len;
6037 struct rte_cryptodev_sym_capability_idx cap_idx;
6038 struct rte_cryptodev_info dev_info;
6040 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6041 uint64_t feat_flags = dev_info.feature_flags;
6043 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6044 (tdata->validAuthLenInBits.len % 8 != 0)) {
6045 printf("Device doesn't support NON-Byte Aligned Data.\n");
6046 return TEST_SKIPPED;
6049 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6050 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6051 printf("Device doesn't support RAW data-path APIs.\n");
6052 return TEST_SKIPPED;
6055 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6056 return TEST_SKIPPED;
6058 /* Check if device supports ZUC EIA3 */
6059 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6060 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6062 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6064 return TEST_SKIPPED;
6066 /* Create ZUC session */
6067 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6068 tdata->key.data, tdata->key.len,
6069 tdata->auth_iv.len, tdata->digest.len,
6070 RTE_CRYPTO_AUTH_OP_GENERATE,
6071 RTE_CRYPTO_AUTH_ZUC_EIA3);
6075 /* alloc mbuf and set payload */
6076 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6078 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6079 rte_pktmbuf_tailroom(ut_params->ibuf));
6081 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6082 /* Append data which is padded to a multiple of */
6083 /* the algorithms block size */
6084 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6085 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6087 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6089 /* Create ZUC operation */
6090 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6091 tdata->auth_iv.data, tdata->auth_iv.len,
6092 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6093 tdata->validAuthLenInBits.len,
6098 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6099 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6100 ut_params->op, 0, 1, 1, 0);
6102 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6104 ut_params->obuf = ut_params->op->sym->m_src;
6105 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6106 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6107 + plaintext_pad_len;
6110 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6114 "ZUC Generated auth tag not as expected");
6120 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6121 uint8_t op_mode, uint8_t verify)
6123 struct crypto_testsuite_params *ts_params = &testsuite_params;
6124 struct crypto_unittest_params *ut_params = &unittest_params;
6128 uint8_t *plaintext = NULL, *ciphertext = NULL;
6129 unsigned int plaintext_pad_len;
6130 unsigned int plaintext_len;
6131 unsigned int ciphertext_pad_len;
6132 unsigned int ciphertext_len;
6134 struct rte_cryptodev_info dev_info;
6135 struct rte_cryptodev_sym_capability_idx cap_idx;
6137 /* Check if device supports ZUC EIA3 */
6138 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6139 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6141 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6143 return TEST_SKIPPED;
6145 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6147 uint64_t feat_flags = dev_info.feature_flags;
6149 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6150 printf("Device doesn't support digest encrypted.\n");
6151 return TEST_SKIPPED;
6153 if (op_mode == IN_PLACE) {
6154 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6155 printf("Device doesn't support in-place scatter-gather "
6156 "in both input and output mbufs.\n");
6157 return TEST_SKIPPED;
6160 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6161 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6162 printf("Device doesn't support RAW data-path APIs.\n");
6163 return TEST_SKIPPED;
6166 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6167 return TEST_SKIPPED;
6168 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6169 printf("Device doesn't support out-of-place scatter-gather "
6170 "in both input and output mbufs.\n");
6171 return TEST_SKIPPED;
6175 /* Create ZUC session */
6176 retval = create_wireless_algo_auth_cipher_session(
6177 ts_params->valid_devs[0],
6178 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6179 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6180 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6181 : RTE_CRYPTO_AUTH_OP_GENERATE),
6182 RTE_CRYPTO_AUTH_ZUC_EIA3,
6183 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6184 tdata->key.data, tdata->key.len,
6185 tdata->auth_iv.len, tdata->digest.len,
6186 tdata->cipher_iv.len);
6191 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6192 if (op_mode == OUT_OF_PLACE)
6193 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6195 /* clear mbuf payload */
6196 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6197 rte_pktmbuf_tailroom(ut_params->ibuf));
6198 if (op_mode == OUT_OF_PLACE)
6199 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6200 rte_pktmbuf_tailroom(ut_params->obuf));
6202 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6203 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6204 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6205 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6208 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6209 ciphertext_pad_len);
6210 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6211 if (op_mode == OUT_OF_PLACE)
6212 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6213 debug_hexdump(stdout, "ciphertext:", ciphertext,
6216 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6218 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6219 if (op_mode == OUT_OF_PLACE)
6220 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6221 debug_hexdump(stdout, "plaintext:", plaintext,
6225 /* Create ZUC operation */
6226 retval = create_wireless_algo_auth_cipher_operation(
6227 tdata->digest.data, tdata->digest.len,
6228 tdata->cipher_iv.data, tdata->cipher_iv.len,
6229 tdata->auth_iv.data, tdata->auth_iv.len,
6230 (tdata->digest.offset_bytes == 0 ?
6231 (verify ? ciphertext_pad_len : plaintext_pad_len)
6232 : tdata->digest.offset_bytes),
6233 tdata->validCipherLenInBits.len,
6234 tdata->validCipherOffsetInBits.len,
6235 tdata->validAuthLenInBits.len,
6237 op_mode, 0, verify);
6242 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6243 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6244 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6246 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6249 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6251 ut_params->obuf = (op_mode == IN_PLACE ?
6252 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6256 if (ut_params->obuf)
6257 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6260 plaintext = ciphertext;
6262 debug_hexdump(stdout, "plaintext:", plaintext,
6263 (tdata->plaintext.len >> 3) - tdata->digest.len);
6264 debug_hexdump(stdout, "plaintext expected:",
6265 tdata->plaintext.data,
6266 (tdata->plaintext.len >> 3) - tdata->digest.len);
6268 if (ut_params->obuf)
6269 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6272 ciphertext = plaintext;
6274 debug_hexdump(stdout, "ciphertext:", ciphertext,
6276 debug_hexdump(stdout, "ciphertext expected:",
6277 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6279 ut_params->digest = rte_pktmbuf_mtod(
6280 ut_params->obuf, uint8_t *) +
6281 (tdata->digest.offset_bytes == 0 ?
6282 plaintext_pad_len : tdata->digest.offset_bytes);
6284 debug_hexdump(stdout, "digest:", ut_params->digest,
6286 debug_hexdump(stdout, "digest expected:",
6287 tdata->digest.data, tdata->digest.len);
6292 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6294 tdata->plaintext.data,
6295 tdata->plaintext.len >> 3,
6296 "ZUC Plaintext data not as expected");
6298 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6300 tdata->ciphertext.data,
6301 tdata->ciphertext.len >> 3,
6302 "ZUC Ciphertext data not as expected");
6304 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6307 DIGEST_BYTE_LENGTH_KASUMI_F9,
6308 "ZUC Generated auth tag not as expected");
6314 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6315 uint8_t op_mode, uint8_t verify)
6317 struct crypto_testsuite_params *ts_params = &testsuite_params;
6318 struct crypto_unittest_params *ut_params = &unittest_params;
6322 const uint8_t *plaintext = NULL;
6323 const uint8_t *ciphertext = NULL;
6324 const uint8_t *digest = NULL;
6325 unsigned int plaintext_pad_len;
6326 unsigned int plaintext_len;
6327 unsigned int ciphertext_pad_len;
6328 unsigned int ciphertext_len;
6329 uint8_t buffer[10000];
6330 uint8_t digest_buffer[10000];
6332 struct rte_cryptodev_info dev_info;
6333 struct rte_cryptodev_sym_capability_idx cap_idx;
6335 /* Check if device supports ZUC EIA3 */
6336 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6337 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6339 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6341 return TEST_SKIPPED;
6343 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6345 uint64_t feat_flags = dev_info.feature_flags;
6347 if (op_mode == IN_PLACE) {
6348 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6349 printf("Device doesn't support in-place scatter-gather "
6350 "in both input and output mbufs.\n");
6351 return TEST_SKIPPED;
6354 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6355 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6356 printf("Device doesn't support RAW data-path APIs.\n");
6357 return TEST_SKIPPED;
6360 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6361 return TEST_SKIPPED;
6362 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6363 printf("Device doesn't support out-of-place scatter-gather "
6364 "in both input and output mbufs.\n");
6365 return TEST_SKIPPED;
6367 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6368 printf("Device doesn't support digest encrypted.\n");
6369 return TEST_SKIPPED;
6373 /* Create ZUC session */
6374 retval = create_wireless_algo_auth_cipher_session(
6375 ts_params->valid_devs[0],
6376 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6377 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6378 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6379 : RTE_CRYPTO_AUTH_OP_GENERATE),
6380 RTE_CRYPTO_AUTH_ZUC_EIA3,
6381 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6382 tdata->key.data, tdata->key.len,
6383 tdata->auth_iv.len, tdata->digest.len,
6384 tdata->cipher_iv.len);
6389 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6390 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6391 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6392 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6394 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6395 plaintext_pad_len, 15, 0);
6396 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6397 "Failed to allocate input buffer in mempool");
6399 if (op_mode == OUT_OF_PLACE) {
6400 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6401 plaintext_pad_len, 15, 0);
6402 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6403 "Failed to allocate output buffer in mempool");
6407 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6408 tdata->ciphertext.data);
6409 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6410 ciphertext_len, buffer);
6411 debug_hexdump(stdout, "ciphertext:", ciphertext,
6414 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6415 tdata->plaintext.data);
6416 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6417 plaintext_len, buffer);
6418 debug_hexdump(stdout, "plaintext:", plaintext,
6421 memset(buffer, 0, sizeof(buffer));
6423 /* Create ZUC operation */
6424 retval = create_wireless_algo_auth_cipher_operation(
6425 tdata->digest.data, tdata->digest.len,
6426 tdata->cipher_iv.data, tdata->cipher_iv.len,
6428 (tdata->digest.offset_bytes == 0 ?
6429 (verify ? ciphertext_pad_len : plaintext_pad_len)
6430 : tdata->digest.offset_bytes),
6431 tdata->validCipherLenInBits.len,
6432 tdata->validCipherOffsetInBits.len,
6433 tdata->validAuthLenInBits.len,
6435 op_mode, 1, verify);
6440 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6441 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6442 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6444 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6447 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6449 ut_params->obuf = (op_mode == IN_PLACE ?
6450 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6453 if (ut_params->obuf)
6454 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6455 plaintext_len, buffer);
6457 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6458 plaintext_len, buffer);
6460 debug_hexdump(stdout, "plaintext:", plaintext,
6461 (tdata->plaintext.len >> 3) - tdata->digest.len);
6462 debug_hexdump(stdout, "plaintext expected:",
6463 tdata->plaintext.data,
6464 (tdata->plaintext.len >> 3) - tdata->digest.len);
6466 if (ut_params->obuf)
6467 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6468 ciphertext_len, buffer);
6470 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6471 ciphertext_len, buffer);
6473 debug_hexdump(stdout, "ciphertext:", ciphertext,
6475 debug_hexdump(stdout, "ciphertext expected:",
6476 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6478 if (ut_params->obuf)
6479 digest = rte_pktmbuf_read(ut_params->obuf,
6480 (tdata->digest.offset_bytes == 0 ?
6481 plaintext_pad_len : tdata->digest.offset_bytes),
6482 tdata->digest.len, digest_buffer);
6484 digest = rte_pktmbuf_read(ut_params->ibuf,
6485 (tdata->digest.offset_bytes == 0 ?
6486 plaintext_pad_len : tdata->digest.offset_bytes),
6487 tdata->digest.len, digest_buffer);
6489 debug_hexdump(stdout, "digest:", digest,
6491 debug_hexdump(stdout, "digest expected:",
6492 tdata->digest.data, tdata->digest.len);
6497 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6499 tdata->plaintext.data,
6500 tdata->plaintext.len >> 3,
6501 "ZUC Plaintext data not as expected");
6503 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6505 tdata->ciphertext.data,
6506 tdata->validDataLenInBits.len,
6507 "ZUC Ciphertext data not as expected");
6509 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6512 DIGEST_BYTE_LENGTH_KASUMI_F9,
6513 "ZUC Generated auth tag not as expected");
6519 test_kasumi_encryption_test_case_1(void)
6521 return test_kasumi_encryption(&kasumi_test_case_1);
6525 test_kasumi_encryption_test_case_1_sgl(void)
6527 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6531 test_kasumi_encryption_test_case_1_oop(void)
6533 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6537 test_kasumi_encryption_test_case_1_oop_sgl(void)
6539 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6543 test_kasumi_encryption_test_case_2(void)
6545 return test_kasumi_encryption(&kasumi_test_case_2);
6549 test_kasumi_encryption_test_case_3(void)
6551 return test_kasumi_encryption(&kasumi_test_case_3);
6555 test_kasumi_encryption_test_case_4(void)
6557 return test_kasumi_encryption(&kasumi_test_case_4);
6561 test_kasumi_encryption_test_case_5(void)
6563 return test_kasumi_encryption(&kasumi_test_case_5);
6567 test_kasumi_decryption_test_case_1(void)
6569 return test_kasumi_decryption(&kasumi_test_case_1);
6573 test_kasumi_decryption_test_case_1_oop(void)
6575 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6579 test_kasumi_decryption_test_case_2(void)
6581 return test_kasumi_decryption(&kasumi_test_case_2);
6585 test_kasumi_decryption_test_case_3(void)
6587 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6588 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6589 return TEST_SKIPPED;
6590 return test_kasumi_decryption(&kasumi_test_case_3);
6594 test_kasumi_decryption_test_case_4(void)
6596 return test_kasumi_decryption(&kasumi_test_case_4);
6600 test_kasumi_decryption_test_case_5(void)
6602 return test_kasumi_decryption(&kasumi_test_case_5);
6605 test_snow3g_encryption_test_case_1(void)
6607 return test_snow3g_encryption(&snow3g_test_case_1);
6611 test_snow3g_encryption_test_case_1_oop(void)
6613 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6617 test_snow3g_encryption_test_case_1_oop_sgl(void)
6619 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6624 test_snow3g_encryption_test_case_1_offset_oop(void)
6626 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6630 test_snow3g_encryption_test_case_2(void)
6632 return test_snow3g_encryption(&snow3g_test_case_2);
6636 test_snow3g_encryption_test_case_3(void)
6638 return test_snow3g_encryption(&snow3g_test_case_3);
6642 test_snow3g_encryption_test_case_4(void)
6644 return test_snow3g_encryption(&snow3g_test_case_4);
6648 test_snow3g_encryption_test_case_5(void)
6650 return test_snow3g_encryption(&snow3g_test_case_5);
6654 test_snow3g_decryption_test_case_1(void)
6656 return test_snow3g_decryption(&snow3g_test_case_1);
6660 test_snow3g_decryption_test_case_1_oop(void)
6662 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6666 test_snow3g_decryption_test_case_2(void)
6668 return test_snow3g_decryption(&snow3g_test_case_2);
6672 test_snow3g_decryption_test_case_3(void)
6674 return test_snow3g_decryption(&snow3g_test_case_3);
6678 test_snow3g_decryption_test_case_4(void)
6680 return test_snow3g_decryption(&snow3g_test_case_4);
6684 test_snow3g_decryption_test_case_5(void)
6686 return test_snow3g_decryption(&snow3g_test_case_5);
6690 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6691 * Pattern digest from snow3g_test_data must be allocated as
6692 * 4 last bytes in plaintext.
6695 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6696 struct snow3g_hash_test_data *output)
6698 if ((pattern != NULL) && (output != NULL)) {
6699 output->key.len = pattern->key.len;
6701 memcpy(output->key.data,
6702 pattern->key.data, pattern->key.len);
6704 output->auth_iv.len = pattern->auth_iv.len;
6706 memcpy(output->auth_iv.data,
6707 pattern->auth_iv.data, pattern->auth_iv.len);
6709 output->plaintext.len = pattern->plaintext.len;
6711 memcpy(output->plaintext.data,
6712 pattern->plaintext.data, pattern->plaintext.len >> 3);
6714 output->digest.len = pattern->digest.len;
6716 memcpy(output->digest.data,
6717 &pattern->plaintext.data[pattern->digest.offset_bytes],
6718 pattern->digest.len);
6720 output->validAuthLenInBits.len =
6721 pattern->validAuthLenInBits.len;
6726 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6729 test_snow3g_decryption_with_digest_test_case_1(void)
6731 struct snow3g_hash_test_data snow3g_hash_data;
6732 struct rte_cryptodev_info dev_info;
6733 struct crypto_testsuite_params *ts_params = &testsuite_params;
6735 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6736 uint64_t feat_flags = dev_info.feature_flags;
6738 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6739 printf("Device doesn't support encrypted digest operations.\n");
6740 return TEST_SKIPPED;
6744 * Function prepare data for hash veryfication test case.
6745 * Digest is allocated in 4 last bytes in plaintext, pattern.
6747 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6749 return test_snow3g_decryption(&snow3g_test_case_7) &
6750 test_snow3g_authentication_verify(&snow3g_hash_data);
6754 test_snow3g_cipher_auth_test_case_1(void)
6756 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6760 test_snow3g_auth_cipher_test_case_1(void)
6762 return test_snow3g_auth_cipher(
6763 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6767 test_snow3g_auth_cipher_test_case_2(void)
6769 return test_snow3g_auth_cipher(
6770 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6774 test_snow3g_auth_cipher_test_case_2_oop(void)
6776 return test_snow3g_auth_cipher(
6777 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6781 test_snow3g_auth_cipher_part_digest_enc(void)
6783 return test_snow3g_auth_cipher(
6784 &snow3g_auth_cipher_partial_digest_encryption,
6789 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6791 return test_snow3g_auth_cipher(
6792 &snow3g_auth_cipher_partial_digest_encryption,
6797 test_snow3g_auth_cipher_test_case_3_sgl(void)
6799 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6800 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6801 return TEST_SKIPPED;
6802 return test_snow3g_auth_cipher_sgl(
6803 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6807 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6809 return test_snow3g_auth_cipher_sgl(
6810 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6814 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6816 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6817 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6818 return TEST_SKIPPED;
6819 return test_snow3g_auth_cipher_sgl(
6820 &snow3g_auth_cipher_partial_digest_encryption,
6825 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6827 return test_snow3g_auth_cipher_sgl(
6828 &snow3g_auth_cipher_partial_digest_encryption,
6833 test_snow3g_auth_cipher_verify_test_case_1(void)
6835 return test_snow3g_auth_cipher(
6836 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6840 test_snow3g_auth_cipher_verify_test_case_2(void)
6842 return test_snow3g_auth_cipher(
6843 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6847 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6849 return test_snow3g_auth_cipher(
6850 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6854 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6856 return test_snow3g_auth_cipher(
6857 &snow3g_auth_cipher_partial_digest_encryption,
6862 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6864 return test_snow3g_auth_cipher(
6865 &snow3g_auth_cipher_partial_digest_encryption,
6870 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6872 return test_snow3g_auth_cipher_sgl(
6873 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6877 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6879 return test_snow3g_auth_cipher_sgl(
6880 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6884 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6886 return test_snow3g_auth_cipher_sgl(
6887 &snow3g_auth_cipher_partial_digest_encryption,
6892 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6894 return test_snow3g_auth_cipher_sgl(
6895 &snow3g_auth_cipher_partial_digest_encryption,
6900 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6902 return test_snow3g_auth_cipher(
6903 &snow3g_test_case_7, IN_PLACE, 0);
6907 test_kasumi_auth_cipher_test_case_1(void)
6909 return test_kasumi_auth_cipher(
6910 &kasumi_test_case_3, IN_PLACE, 0);
6914 test_kasumi_auth_cipher_test_case_2(void)
6916 return test_kasumi_auth_cipher(
6917 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6921 test_kasumi_auth_cipher_test_case_2_oop(void)
6923 return test_kasumi_auth_cipher(
6924 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6928 test_kasumi_auth_cipher_test_case_2_sgl(void)
6930 return test_kasumi_auth_cipher_sgl(
6931 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6935 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6937 return test_kasumi_auth_cipher_sgl(
6938 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6942 test_kasumi_auth_cipher_verify_test_case_1(void)
6944 return test_kasumi_auth_cipher(
6945 &kasumi_test_case_3, IN_PLACE, 1);
6949 test_kasumi_auth_cipher_verify_test_case_2(void)
6951 return test_kasumi_auth_cipher(
6952 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6956 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6958 return test_kasumi_auth_cipher(
6959 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6963 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6965 return test_kasumi_auth_cipher_sgl(
6966 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6970 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6972 return test_kasumi_auth_cipher_sgl(
6973 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6977 test_kasumi_cipher_auth_test_case_1(void)
6979 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6983 test_zuc_encryption_test_case_1(void)
6985 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6989 test_zuc_encryption_test_case_2(void)
6991 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6995 test_zuc_encryption_test_case_3(void)
6997 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7001 test_zuc_encryption_test_case_4(void)
7003 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7007 test_zuc_encryption_test_case_5(void)
7009 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7013 test_zuc_encryption_test_case_6_sgl(void)
7015 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7019 test_zuc_encryption_test_case_7(void)
7021 return test_zuc_encryption(&zuc_test_case_cipher_800b_key_256b);
7025 test_zuc_hash_generate_test_case_1(void)
7027 return test_zuc_authentication(&zuc_test_case_auth_1b);
7031 test_zuc_hash_generate_test_case_2(void)
7033 return test_zuc_authentication(&zuc_test_case_auth_90b);
7037 test_zuc_hash_generate_test_case_3(void)
7039 return test_zuc_authentication(&zuc_test_case_auth_577b);
7043 test_zuc_hash_generate_test_case_4(void)
7045 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7049 test_zuc_hash_generate_test_case_5(void)
7051 return test_zuc_authentication(&zuc_test_auth_5670b);
7055 test_zuc_hash_generate_test_case_6(void)
7057 return test_zuc_authentication(&zuc_test_case_auth_128b);
7061 test_zuc_hash_generate_test_case_7(void)
7063 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7067 test_zuc_hash_generate_test_case_8(void)
7069 return test_zuc_authentication(&zuc_test_case_auth_584b);
7073 test_zuc_hash_generate_test_case_9(void)
7075 return test_zuc_authentication(&zuc_test_case_auth_584b_mac_64b);
7079 test_zuc_hash_generate_test_case_10(void)
7081 return test_zuc_authentication(&zuc_test_case_auth_2080b_mac_128b);
7085 test_zuc_cipher_auth_test_case_1(void)
7087 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7091 test_zuc_cipher_auth_test_case_2(void)
7093 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7097 test_zuc_auth_cipher_test_case_1(void)
7099 return test_zuc_auth_cipher(
7100 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7104 test_zuc_auth_cipher_test_case_1_oop(void)
7106 return test_zuc_auth_cipher(
7107 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7111 test_zuc_auth_cipher_test_case_1_sgl(void)
7113 return test_zuc_auth_cipher_sgl(
7114 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7118 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7120 return test_zuc_auth_cipher_sgl(
7121 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7125 test_zuc_auth_cipher_verify_test_case_1(void)
7127 return test_zuc_auth_cipher(
7128 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7132 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7134 return test_zuc_auth_cipher(
7135 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7139 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7141 return test_zuc_auth_cipher_sgl(
7142 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7146 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7148 return test_zuc_auth_cipher_sgl(
7149 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7153 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7155 uint8_t dev_id = testsuite_params.valid_devs[0];
7157 struct rte_cryptodev_sym_capability_idx cap_idx;
7159 /* Check if device supports particular cipher algorithm */
7160 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7161 cap_idx.algo.cipher = tdata->cipher_algo;
7162 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7163 return TEST_SKIPPED;
7165 /* Check if device supports particular hash algorithm */
7166 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7167 cap_idx.algo.auth = tdata->auth_algo;
7168 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7169 return TEST_SKIPPED;
7175 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7176 uint8_t op_mode, uint8_t verify)
7178 struct crypto_testsuite_params *ts_params = &testsuite_params;
7179 struct crypto_unittest_params *ut_params = &unittest_params;
7183 uint8_t *plaintext = NULL, *ciphertext = NULL;
7184 unsigned int plaintext_pad_len;
7185 unsigned int plaintext_len;
7186 unsigned int ciphertext_pad_len;
7187 unsigned int ciphertext_len;
7189 struct rte_cryptodev_info dev_info;
7190 struct rte_crypto_op *op;
7192 /* Check if device supports particular algorithms separately */
7193 if (test_mixed_check_if_unsupported(tdata))
7194 return TEST_SKIPPED;
7195 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7196 return TEST_SKIPPED;
7198 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7200 uint64_t feat_flags = dev_info.feature_flags;
7202 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7203 printf("Device doesn't support digest encrypted.\n");
7204 return TEST_SKIPPED;
7207 /* Create the session */
7209 retval = create_wireless_algo_cipher_auth_session(
7210 ts_params->valid_devs[0],
7211 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7212 RTE_CRYPTO_AUTH_OP_VERIFY,
7215 tdata->auth_key.data, tdata->auth_key.len,
7216 tdata->auth_iv.len, tdata->digest_enc.len,
7217 tdata->cipher_iv.len);
7219 retval = create_wireless_algo_auth_cipher_session(
7220 ts_params->valid_devs[0],
7221 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7222 RTE_CRYPTO_AUTH_OP_GENERATE,
7225 tdata->auth_key.data, tdata->auth_key.len,
7226 tdata->auth_iv.len, tdata->digest_enc.len,
7227 tdata->cipher_iv.len);
7231 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7232 if (op_mode == OUT_OF_PLACE)
7233 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7235 /* clear mbuf payload */
7236 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7237 rte_pktmbuf_tailroom(ut_params->ibuf));
7238 if (op_mode == OUT_OF_PLACE) {
7240 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7241 rte_pktmbuf_tailroom(ut_params->obuf));
7244 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7245 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7246 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7247 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7250 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7251 ciphertext_pad_len);
7252 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7253 if (op_mode == OUT_OF_PLACE)
7254 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7255 debug_hexdump(stdout, "ciphertext:", ciphertext,
7258 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7260 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7261 if (op_mode == OUT_OF_PLACE)
7262 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7263 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7266 /* Create the operation */
7267 retval = create_wireless_algo_auth_cipher_operation(
7268 tdata->digest_enc.data, tdata->digest_enc.len,
7269 tdata->cipher_iv.data, tdata->cipher_iv.len,
7270 tdata->auth_iv.data, tdata->auth_iv.len,
7271 (tdata->digest_enc.offset == 0 ?
7273 : tdata->digest_enc.offset),
7274 tdata->validCipherLen.len_bits,
7275 tdata->cipher.offset_bits,
7276 tdata->validAuthLen.len_bits,
7277 tdata->auth.offset_bits,
7278 op_mode, 0, verify);
7283 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7285 /* Check if the op failed because the device doesn't */
7286 /* support this particular combination of algorithms */
7287 if (op == NULL && ut_params->op->status ==
7288 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7289 printf("Device doesn't support this mixed combination. "
7291 return TEST_SKIPPED;
7295 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7297 ut_params->obuf = (op_mode == IN_PLACE ?
7298 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7301 if (ut_params->obuf)
7302 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7305 plaintext = ciphertext +
7306 (tdata->cipher.offset_bits >> 3);
7308 debug_hexdump(stdout, "plaintext:", plaintext,
7309 tdata->plaintext.len_bits >> 3);
7310 debug_hexdump(stdout, "plaintext expected:",
7311 tdata->plaintext.data,
7312 tdata->plaintext.len_bits >> 3);
7314 if (ut_params->obuf)
7315 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7318 ciphertext = plaintext;
7320 debug_hexdump(stdout, "ciphertext:", ciphertext,
7322 debug_hexdump(stdout, "ciphertext expected:",
7323 tdata->ciphertext.data,
7324 tdata->ciphertext.len_bits >> 3);
7326 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7327 + (tdata->digest_enc.offset == 0 ?
7328 plaintext_pad_len : tdata->digest_enc.offset);
7330 debug_hexdump(stdout, "digest:", ut_params->digest,
7331 tdata->digest_enc.len);
7332 debug_hexdump(stdout, "digest expected:",
7333 tdata->digest_enc.data,
7334 tdata->digest_enc.len);
7339 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7341 tdata->plaintext.data,
7342 tdata->plaintext.len_bits >> 3,
7343 "Plaintext data not as expected");
7345 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7347 tdata->ciphertext.data,
7348 tdata->validDataLen.len_bits,
7349 "Ciphertext data not as expected");
7351 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7353 tdata->digest_enc.data,
7354 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7355 "Generated auth tag not as expected");
7358 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7359 "crypto op processing failed");
7365 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7366 uint8_t op_mode, uint8_t verify)
7368 struct crypto_testsuite_params *ts_params = &testsuite_params;
7369 struct crypto_unittest_params *ut_params = &unittest_params;
7373 const uint8_t *plaintext = NULL;
7374 const uint8_t *ciphertext = NULL;
7375 const uint8_t *digest = NULL;
7376 unsigned int plaintext_pad_len;
7377 unsigned int plaintext_len;
7378 unsigned int ciphertext_pad_len;
7379 unsigned int ciphertext_len;
7380 uint8_t buffer[10000];
7381 uint8_t digest_buffer[10000];
7383 struct rte_cryptodev_info dev_info;
7384 struct rte_crypto_op *op;
7386 /* Check if device supports particular algorithms */
7387 if (test_mixed_check_if_unsupported(tdata))
7388 return TEST_SKIPPED;
7389 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7390 return TEST_SKIPPED;
7392 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7394 uint64_t feat_flags = dev_info.feature_flags;
7396 if (op_mode == IN_PLACE) {
7397 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7398 printf("Device doesn't support in-place scatter-gather "
7399 "in both input and output mbufs.\n");
7400 return TEST_SKIPPED;
7403 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7404 printf("Device doesn't support out-of-place scatter-gather "
7405 "in both input and output mbufs.\n");
7406 return TEST_SKIPPED;
7408 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7409 printf("Device doesn't support digest encrypted.\n");
7410 return TEST_SKIPPED;
7414 /* Create the session */
7416 retval = create_wireless_algo_cipher_auth_session(
7417 ts_params->valid_devs[0],
7418 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7419 RTE_CRYPTO_AUTH_OP_VERIFY,
7422 tdata->auth_key.data, tdata->auth_key.len,
7423 tdata->auth_iv.len, tdata->digest_enc.len,
7424 tdata->cipher_iv.len);
7426 retval = create_wireless_algo_auth_cipher_session(
7427 ts_params->valid_devs[0],
7428 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7429 RTE_CRYPTO_AUTH_OP_GENERATE,
7432 tdata->auth_key.data, tdata->auth_key.len,
7433 tdata->auth_iv.len, tdata->digest_enc.len,
7434 tdata->cipher_iv.len);
7438 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7439 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7440 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7441 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7443 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7444 ciphertext_pad_len, 15, 0);
7445 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7446 "Failed to allocate input buffer in mempool");
7448 if (op_mode == OUT_OF_PLACE) {
7449 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7450 plaintext_pad_len, 15, 0);
7451 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7452 "Failed to allocate output buffer in mempool");
7456 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7457 tdata->ciphertext.data);
7458 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7459 ciphertext_len, buffer);
7460 debug_hexdump(stdout, "ciphertext:", ciphertext,
7463 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7464 tdata->plaintext.data);
7465 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7466 plaintext_len, buffer);
7467 debug_hexdump(stdout, "plaintext:", plaintext,
7470 memset(buffer, 0, sizeof(buffer));
7472 /* Create the operation */
7473 retval = create_wireless_algo_auth_cipher_operation(
7474 tdata->digest_enc.data, tdata->digest_enc.len,
7475 tdata->cipher_iv.data, tdata->cipher_iv.len,
7476 tdata->auth_iv.data, tdata->auth_iv.len,
7477 (tdata->digest_enc.offset == 0 ?
7479 : tdata->digest_enc.offset),
7480 tdata->validCipherLen.len_bits,
7481 tdata->cipher.offset_bits,
7482 tdata->validAuthLen.len_bits,
7483 tdata->auth.offset_bits,
7484 op_mode, 1, verify);
7489 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7491 /* Check if the op failed because the device doesn't */
7492 /* support this particular combination of algorithms */
7493 if (op == NULL && ut_params->op->status ==
7494 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7495 printf("Device doesn't support this mixed combination. "
7497 return TEST_SKIPPED;
7501 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7503 ut_params->obuf = (op_mode == IN_PLACE ?
7504 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7507 if (ut_params->obuf)
7508 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7509 plaintext_len, buffer);
7511 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7512 plaintext_len, buffer);
7514 debug_hexdump(stdout, "plaintext:", plaintext,
7515 (tdata->plaintext.len_bits >> 3) -
7516 tdata->digest_enc.len);
7517 debug_hexdump(stdout, "plaintext expected:",
7518 tdata->plaintext.data,
7519 (tdata->plaintext.len_bits >> 3) -
7520 tdata->digest_enc.len);
7522 if (ut_params->obuf)
7523 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7524 ciphertext_len, buffer);
7526 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7527 ciphertext_len, buffer);
7529 debug_hexdump(stdout, "ciphertext:", ciphertext,
7531 debug_hexdump(stdout, "ciphertext expected:",
7532 tdata->ciphertext.data,
7533 tdata->ciphertext.len_bits >> 3);
7535 if (ut_params->obuf)
7536 digest = rte_pktmbuf_read(ut_params->obuf,
7537 (tdata->digest_enc.offset == 0 ?
7539 tdata->digest_enc.offset),
7540 tdata->digest_enc.len, digest_buffer);
7542 digest = rte_pktmbuf_read(ut_params->ibuf,
7543 (tdata->digest_enc.offset == 0 ?
7545 tdata->digest_enc.offset),
7546 tdata->digest_enc.len, digest_buffer);
7548 debug_hexdump(stdout, "digest:", digest,
7549 tdata->digest_enc.len);
7550 debug_hexdump(stdout, "digest expected:",
7551 tdata->digest_enc.data, tdata->digest_enc.len);
7556 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7558 tdata->plaintext.data,
7559 tdata->plaintext.len_bits >> 3,
7560 "Plaintext data not as expected");
7562 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7564 tdata->ciphertext.data,
7565 tdata->validDataLen.len_bits,
7566 "Ciphertext data not as expected");
7567 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7569 tdata->digest_enc.data,
7570 tdata->digest_enc.len,
7571 "Generated auth tag not as expected");
7574 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7575 "crypto op processing failed");
7580 /** AUTH AES CMAC + CIPHER AES CTR */
7583 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7585 return test_mixed_auth_cipher(
7586 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7590 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7592 return test_mixed_auth_cipher(
7593 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7597 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7599 return test_mixed_auth_cipher_sgl(
7600 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7604 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7606 return test_mixed_auth_cipher_sgl(
7607 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7611 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7613 return test_mixed_auth_cipher(
7614 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7618 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7620 return test_mixed_auth_cipher(
7621 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7625 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7627 return test_mixed_auth_cipher_sgl(
7628 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7632 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7634 return test_mixed_auth_cipher_sgl(
7635 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7638 /** MIXED AUTH + CIPHER */
7641 test_auth_zuc_cipher_snow_test_case_1(void)
7643 return test_mixed_auth_cipher(
7644 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7648 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7650 return test_mixed_auth_cipher(
7651 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7655 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7657 return test_mixed_auth_cipher(
7658 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7662 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7664 return test_mixed_auth_cipher(
7665 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7669 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7671 return test_mixed_auth_cipher(
7672 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7676 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7678 return test_mixed_auth_cipher(
7679 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7683 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7685 return test_mixed_auth_cipher(
7686 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7690 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7692 return test_mixed_auth_cipher(
7693 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7697 test_auth_snow_cipher_zuc_test_case_1(void)
7699 return test_mixed_auth_cipher(
7700 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7704 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7706 return test_mixed_auth_cipher(
7707 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7711 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7713 return test_mixed_auth_cipher(
7714 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7718 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7720 return test_mixed_auth_cipher(
7721 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7725 test_auth_null_cipher_snow_test_case_1(void)
7727 return test_mixed_auth_cipher(
7728 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7732 test_verify_auth_null_cipher_snow_test_case_1(void)
7734 return test_mixed_auth_cipher(
7735 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7739 test_auth_null_cipher_zuc_test_case_1(void)
7741 return test_mixed_auth_cipher(
7742 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7746 test_verify_auth_null_cipher_zuc_test_case_1(void)
7748 return test_mixed_auth_cipher(
7749 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7753 test_auth_snow_cipher_null_test_case_1(void)
7755 return test_mixed_auth_cipher(
7756 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7760 test_verify_auth_snow_cipher_null_test_case_1(void)
7762 return test_mixed_auth_cipher(
7763 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7767 test_auth_zuc_cipher_null_test_case_1(void)
7769 return test_mixed_auth_cipher(
7770 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7774 test_verify_auth_zuc_cipher_null_test_case_1(void)
7776 return test_mixed_auth_cipher(
7777 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7781 test_auth_null_cipher_aes_ctr_test_case_1(void)
7783 return test_mixed_auth_cipher(
7784 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7788 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7790 return test_mixed_auth_cipher(
7791 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7795 test_auth_aes_cmac_cipher_null_test_case_1(void)
7797 return test_mixed_auth_cipher(
7798 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7802 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7804 return test_mixed_auth_cipher(
7805 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7808 /* ***** AEAD algorithm Tests ***** */
7811 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7812 enum rte_crypto_aead_operation op,
7813 const uint8_t *key, const uint8_t key_len,
7814 const uint16_t aad_len, const uint8_t auth_len,
7817 uint8_t aead_key[key_len];
7819 struct crypto_testsuite_params *ts_params = &testsuite_params;
7820 struct crypto_unittest_params *ut_params = &unittest_params;
7822 memcpy(aead_key, key, key_len);
7824 /* Setup AEAD Parameters */
7825 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7826 ut_params->aead_xform.next = NULL;
7827 ut_params->aead_xform.aead.algo = algo;
7828 ut_params->aead_xform.aead.op = op;
7829 ut_params->aead_xform.aead.key.data = aead_key;
7830 ut_params->aead_xform.aead.key.length = key_len;
7831 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7832 ut_params->aead_xform.aead.iv.length = iv_len;
7833 ut_params->aead_xform.aead.digest_length = auth_len;
7834 ut_params->aead_xform.aead.aad_length = aad_len;
7836 debug_hexdump(stdout, "key:", key, key_len);
7838 /* Create Crypto session*/
7839 ut_params->sess = rte_cryptodev_sym_session_create(
7840 ts_params->session_mpool);
7842 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7843 &ut_params->aead_xform,
7844 ts_params->session_priv_mpool);
7846 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7852 create_aead_xform(struct rte_crypto_op *op,
7853 enum rte_crypto_aead_algorithm algo,
7854 enum rte_crypto_aead_operation aead_op,
7855 uint8_t *key, const uint8_t key_len,
7856 const uint8_t aad_len, const uint8_t auth_len,
7859 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7860 "failed to allocate space for crypto transform");
7862 struct rte_crypto_sym_op *sym_op = op->sym;
7864 /* Setup AEAD Parameters */
7865 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7866 sym_op->xform->next = NULL;
7867 sym_op->xform->aead.algo = algo;
7868 sym_op->xform->aead.op = aead_op;
7869 sym_op->xform->aead.key.data = key;
7870 sym_op->xform->aead.key.length = key_len;
7871 sym_op->xform->aead.iv.offset = IV_OFFSET;
7872 sym_op->xform->aead.iv.length = iv_len;
7873 sym_op->xform->aead.digest_length = auth_len;
7874 sym_op->xform->aead.aad_length = aad_len;
7876 debug_hexdump(stdout, "key:", key, key_len);
7882 create_aead_operation(enum rte_crypto_aead_operation op,
7883 const struct aead_test_data *tdata)
7885 struct crypto_testsuite_params *ts_params = &testsuite_params;
7886 struct crypto_unittest_params *ut_params = &unittest_params;
7888 uint8_t *plaintext, *ciphertext;
7889 unsigned int aad_pad_len, plaintext_pad_len;
7891 /* Generate Crypto op data structure */
7892 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7893 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7894 TEST_ASSERT_NOT_NULL(ut_params->op,
7895 "Failed to allocate symmetric crypto operation struct");
7897 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7899 /* Append aad data */
7900 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7901 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7902 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7904 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7905 "no room to append aad");
7907 sym_op->aead.aad.phys_addr =
7908 rte_pktmbuf_iova(ut_params->ibuf);
7909 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7910 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7911 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7914 /* Append IV at the end of the crypto operation*/
7915 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7916 uint8_t *, IV_OFFSET);
7918 /* Copy IV 1 byte after the IV pointer, according to the API */
7919 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7920 debug_hexdump(stdout, "iv:", iv_ptr,
7923 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7924 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7926 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7927 "no room to append aad");
7929 sym_op->aead.aad.phys_addr =
7930 rte_pktmbuf_iova(ut_params->ibuf);
7931 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7932 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7935 /* Append IV at the end of the crypto operation*/
7936 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7937 uint8_t *, IV_OFFSET);
7939 if (tdata->iv.len == 0) {
7940 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7941 debug_hexdump(stdout, "iv:", iv_ptr,
7944 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7945 debug_hexdump(stdout, "iv:", iv_ptr,
7950 /* Append plaintext/ciphertext */
7951 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7952 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7953 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7955 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7957 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7958 debug_hexdump(stdout, "plaintext:", plaintext,
7959 tdata->plaintext.len);
7961 if (ut_params->obuf) {
7962 ciphertext = (uint8_t *)rte_pktmbuf_append(
7964 plaintext_pad_len + aad_pad_len);
7965 TEST_ASSERT_NOT_NULL(ciphertext,
7966 "no room to append ciphertext");
7968 memset(ciphertext + aad_pad_len, 0,
7969 tdata->ciphertext.len);
7972 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7973 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7975 TEST_ASSERT_NOT_NULL(ciphertext,
7976 "no room to append ciphertext");
7978 memcpy(ciphertext, tdata->ciphertext.data,
7979 tdata->ciphertext.len);
7980 debug_hexdump(stdout, "ciphertext:", ciphertext,
7981 tdata->ciphertext.len);
7983 if (ut_params->obuf) {
7984 plaintext = (uint8_t *)rte_pktmbuf_append(
7986 plaintext_pad_len + aad_pad_len);
7987 TEST_ASSERT_NOT_NULL(plaintext,
7988 "no room to append plaintext");
7990 memset(plaintext + aad_pad_len, 0,
7991 tdata->plaintext.len);
7995 /* Append digest data */
7996 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7997 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7998 ut_params->obuf ? ut_params->obuf :
8000 tdata->auth_tag.len);
8001 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8002 "no room to append digest");
8003 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8004 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8005 ut_params->obuf ? ut_params->obuf :
8010 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8011 ut_params->ibuf, tdata->auth_tag.len);
8012 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8013 "no room to append digest");
8014 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8016 plaintext_pad_len + aad_pad_len);
8018 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8019 tdata->auth_tag.len);
8020 debug_hexdump(stdout, "digest:",
8021 sym_op->aead.digest.data,
8022 tdata->auth_tag.len);
8025 sym_op->aead.data.length = tdata->plaintext.len;
8026 sym_op->aead.data.offset = aad_pad_len;
8032 test_authenticated_encryption(const struct aead_test_data *tdata)
8034 struct crypto_testsuite_params *ts_params = &testsuite_params;
8035 struct crypto_unittest_params *ut_params = &unittest_params;
8038 uint8_t *ciphertext, *auth_tag;
8039 uint16_t plaintext_pad_len;
8041 struct rte_cryptodev_info dev_info;
8043 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8044 uint64_t feat_flags = dev_info.feature_flags;
8046 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8047 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8048 printf("Device doesn't support RAW data-path APIs.\n");
8049 return TEST_SKIPPED;
8052 /* Verify the capabilities */
8053 struct rte_cryptodev_sym_capability_idx cap_idx;
8054 const struct rte_cryptodev_symmetric_capability *capability;
8055 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8056 cap_idx.algo.aead = tdata->algo;
8057 capability = rte_cryptodev_sym_capability_get(
8058 ts_params->valid_devs[0], &cap_idx);
8059 if (capability == NULL)
8060 return TEST_SKIPPED;
8061 if (rte_cryptodev_sym_capability_check_aead(
8062 capability, tdata->key.len, tdata->auth_tag.len,
8063 tdata->aad.len, tdata->iv.len))
8064 return TEST_SKIPPED;
8066 /* Create AEAD session */
8067 retval = create_aead_session(ts_params->valid_devs[0],
8069 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8070 tdata->key.data, tdata->key.len,
8071 tdata->aad.len, tdata->auth_tag.len,
8076 if (tdata->aad.len > MBUF_SIZE) {
8077 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8078 /* Populate full size of add data */
8079 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8080 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8082 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8084 /* clear mbuf payload */
8085 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8086 rte_pktmbuf_tailroom(ut_params->ibuf));
8088 /* Create AEAD operation */
8089 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8093 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8095 ut_params->op->sym->m_src = ut_params->ibuf;
8097 /* Process crypto operation */
8098 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8099 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8100 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8101 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8102 ut_params->op, 0, 0, 0, 0);
8104 TEST_ASSERT_NOT_NULL(
8105 process_crypto_request(ts_params->valid_devs[0],
8106 ut_params->op), "failed to process sym crypto op");
8108 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8109 "crypto op processing failed");
8111 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8113 if (ut_params->op->sym->m_dst) {
8114 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8116 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8117 uint8_t *, plaintext_pad_len);
8119 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8121 ut_params->op->sym->cipher.data.offset);
8122 auth_tag = ciphertext + plaintext_pad_len;
8125 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8126 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8129 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8131 tdata->ciphertext.data,
8132 tdata->ciphertext.len,
8133 "Ciphertext data not as expected");
8135 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8137 tdata->auth_tag.data,
8138 tdata->auth_tag.len,
8139 "Generated auth tag not as expected");
8145 #ifdef RTE_LIB_SECURITY
8147 security_proto_supported(enum rte_security_session_action_type action,
8148 enum rte_security_session_protocol proto)
8150 struct crypto_testsuite_params *ts_params = &testsuite_params;
8152 const struct rte_security_capability *capabilities;
8153 const struct rte_security_capability *capability;
8156 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8157 rte_cryptodev_get_sec_ctx(
8158 ts_params->valid_devs[0]);
8161 capabilities = rte_security_capabilities_get(ctx);
8163 if (capabilities == NULL)
8166 while ((capability = &capabilities[i++])->action !=
8167 RTE_SECURITY_ACTION_TYPE_NONE) {
8168 if (capability->action == action &&
8169 capability->protocol == proto)
8176 /* Basic algorithm run function for async inplace mode.
8177 * Creates a session from input parameters and runs one operation
8178 * on input_vec. Checks the output of the crypto operation against
8181 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8182 enum rte_crypto_auth_operation opa,
8183 const uint8_t *input_vec, unsigned int input_vec_len,
8184 const uint8_t *output_vec,
8185 unsigned int output_vec_len,
8186 enum rte_crypto_cipher_algorithm cipher_alg,
8187 const uint8_t *cipher_key, uint32_t cipher_key_len,
8188 enum rte_crypto_auth_algorithm auth_alg,
8189 const uint8_t *auth_key, uint32_t auth_key_len,
8190 uint8_t bearer, enum rte_security_pdcp_domain domain,
8191 uint8_t packet_direction, uint8_t sn_size,
8192 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8194 struct crypto_testsuite_params *ts_params = &testsuite_params;
8195 struct crypto_unittest_params *ut_params = &unittest_params;
8197 int ret = TEST_SUCCESS;
8198 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8199 rte_cryptodev_get_sec_ctx(
8200 ts_params->valid_devs[0]);
8202 /* Verify the capabilities */
8203 struct rte_security_capability_idx sec_cap_idx;
8205 sec_cap_idx.action = ut_params->type;
8206 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8207 sec_cap_idx.pdcp.domain = domain;
8208 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8209 return TEST_SKIPPED;
8211 /* Generate test mbuf data */
8212 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8214 /* clear mbuf payload */
8215 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8216 rte_pktmbuf_tailroom(ut_params->ibuf));
8218 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8220 memcpy(plaintext, input_vec, input_vec_len);
8222 /* Out of place support */
8225 * For out-op-place we need to alloc another mbuf
8227 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8228 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8231 /* Setup Cipher Parameters */
8232 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8233 ut_params->cipher_xform.cipher.algo = cipher_alg;
8234 ut_params->cipher_xform.cipher.op = opc;
8235 ut_params->cipher_xform.cipher.key.data = cipher_key;
8236 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8237 ut_params->cipher_xform.cipher.iv.length =
8238 packet_direction ? 4 : 0;
8239 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8241 /* Setup HMAC Parameters if ICV header is required */
8242 if (auth_alg != 0) {
8243 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8244 ut_params->auth_xform.next = NULL;
8245 ut_params->auth_xform.auth.algo = auth_alg;
8246 ut_params->auth_xform.auth.op = opa;
8247 ut_params->auth_xform.auth.key.data = auth_key;
8248 ut_params->auth_xform.auth.key.length = auth_key_len;
8250 ut_params->cipher_xform.next = &ut_params->auth_xform;
8252 ut_params->cipher_xform.next = NULL;
8255 struct rte_security_session_conf sess_conf = {
8256 .action_type = ut_params->type,
8257 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8261 .pkt_dir = packet_direction,
8263 .hfn = packet_direction ? 0 : hfn,
8265 * hfn can be set as pdcp_test_hfn[i]
8266 * if hfn_ovrd is not set. Here, PDCP
8267 * packet direction is just used to
8268 * run half of the cases with session
8269 * HFN and other half with per packet
8272 .hfn_threshold = hfn_threshold,
8273 .hfn_ovrd = packet_direction ? 1 : 0,
8274 .sdap_enabled = sdap,
8276 .crypto_xform = &ut_params->cipher_xform
8279 /* Create security session */
8280 ut_params->sec_session = rte_security_session_create(ctx,
8281 &sess_conf, ts_params->session_mpool,
8282 ts_params->session_priv_mpool);
8284 if (!ut_params->sec_session) {
8285 printf("TestCase %s()-%d line %d failed %s: ",
8286 __func__, i, __LINE__, "Failed to allocate session");
8291 /* Generate crypto op data structure */
8292 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8293 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8294 if (!ut_params->op) {
8295 printf("TestCase %s()-%d line %d failed %s: ",
8296 __func__, i, __LINE__,
8297 "Failed to allocate symmetric crypto operation struct");
8302 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8303 uint32_t *, IV_OFFSET);
8304 *per_pkt_hfn = packet_direction ? hfn : 0;
8306 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8308 /* set crypto operation source mbuf */
8309 ut_params->op->sym->m_src = ut_params->ibuf;
8311 ut_params->op->sym->m_dst = ut_params->obuf;
8313 /* Process crypto operation */
8314 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8316 printf("TestCase %s()-%d line %d failed %s: ",
8317 __func__, i, __LINE__,
8318 "failed to process sym crypto op");
8323 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8324 printf("TestCase %s()-%d line %d failed %s: ",
8325 __func__, i, __LINE__, "crypto op processing failed");
8331 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8334 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8338 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8339 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8340 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8341 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8347 rte_crypto_op_free(ut_params->op);
8348 ut_params->op = NULL;
8350 if (ut_params->sec_session)
8351 rte_security_session_destroy(ctx, ut_params->sec_session);
8352 ut_params->sec_session = NULL;
8354 rte_pktmbuf_free(ut_params->ibuf);
8355 ut_params->ibuf = NULL;
8357 rte_pktmbuf_free(ut_params->obuf);
8358 ut_params->obuf = NULL;
8365 test_pdcp_proto_SGL(int i, int oop,
8366 enum rte_crypto_cipher_operation opc,
8367 enum rte_crypto_auth_operation opa,
8369 unsigned int input_vec_len,
8370 uint8_t *output_vec,
8371 unsigned int output_vec_len,
8373 uint32_t fragsz_oop)
8375 struct crypto_testsuite_params *ts_params = &testsuite_params;
8376 struct crypto_unittest_params *ut_params = &unittest_params;
8378 struct rte_mbuf *buf, *buf_oop = NULL;
8379 int ret = TEST_SUCCESS;
8383 unsigned int trn_data = 0;
8384 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8385 rte_cryptodev_get_sec_ctx(
8386 ts_params->valid_devs[0]);
8388 /* Verify the capabilities */
8389 struct rte_security_capability_idx sec_cap_idx;
8391 sec_cap_idx.action = ut_params->type;
8392 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8393 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8394 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8395 return TEST_SKIPPED;
8397 if (fragsz > input_vec_len)
8398 fragsz = input_vec_len;
8400 uint16_t plaintext_len = fragsz;
8401 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8403 if (fragsz_oop > output_vec_len)
8404 frag_size_oop = output_vec_len;
8407 if (input_vec_len % fragsz != 0) {
8408 if (input_vec_len / fragsz + 1 > 16)
8410 } else if (input_vec_len / fragsz > 16)
8413 /* Out of place support */
8416 * For out-op-place we need to alloc another mbuf
8418 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8419 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8420 buf_oop = ut_params->obuf;
8423 /* Generate test mbuf data */
8424 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8426 /* clear mbuf payload */
8427 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8428 rte_pktmbuf_tailroom(ut_params->ibuf));
8430 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8432 memcpy(plaintext, input_vec, plaintext_len);
8433 trn_data += plaintext_len;
8435 buf = ut_params->ibuf;
8438 * Loop until no more fragments
8441 while (trn_data < input_vec_len) {
8443 to_trn = (input_vec_len - trn_data < fragsz) ?
8444 (input_vec_len - trn_data) : fragsz;
8446 to_trn_tbl[ecx++] = to_trn;
8448 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8451 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8452 rte_pktmbuf_tailroom(buf));
8455 if (oop && !fragsz_oop) {
8457 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8458 buf_oop = buf_oop->next;
8459 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8460 0, rte_pktmbuf_tailroom(buf_oop));
8461 rte_pktmbuf_append(buf_oop, to_trn);
8464 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8467 memcpy(plaintext, input_vec + trn_data, to_trn);
8471 ut_params->ibuf->nb_segs = segs;
8474 if (fragsz_oop && oop) {
8478 trn_data = frag_size_oop;
8479 while (trn_data < output_vec_len) {
8482 (output_vec_len - trn_data <
8484 (output_vec_len - trn_data) :
8487 to_trn_tbl[ecx++] = to_trn;
8490 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8491 buf_oop = buf_oop->next;
8492 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8493 0, rte_pktmbuf_tailroom(buf_oop));
8494 rte_pktmbuf_append(buf_oop, to_trn);
8498 ut_params->obuf->nb_segs = segs;
8501 /* Setup Cipher Parameters */
8502 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8503 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8504 ut_params->cipher_xform.cipher.op = opc;
8505 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8506 ut_params->cipher_xform.cipher.key.length =
8507 pdcp_test_params[i].cipher_key_len;
8508 ut_params->cipher_xform.cipher.iv.length = 0;
8510 /* Setup HMAC Parameters if ICV header is required */
8511 if (pdcp_test_params[i].auth_alg != 0) {
8512 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8513 ut_params->auth_xform.next = NULL;
8514 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8515 ut_params->auth_xform.auth.op = opa;
8516 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8517 ut_params->auth_xform.auth.key.length =
8518 pdcp_test_params[i].auth_key_len;
8520 ut_params->cipher_xform.next = &ut_params->auth_xform;
8522 ut_params->cipher_xform.next = NULL;
8525 struct rte_security_session_conf sess_conf = {
8526 .action_type = ut_params->type,
8527 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8529 .bearer = pdcp_test_bearer[i],
8530 .domain = pdcp_test_params[i].domain,
8531 .pkt_dir = pdcp_test_packet_direction[i],
8532 .sn_size = pdcp_test_data_sn_size[i],
8533 .hfn = pdcp_test_hfn[i],
8534 .hfn_threshold = pdcp_test_hfn_threshold[i],
8537 .crypto_xform = &ut_params->cipher_xform
8540 /* Create security session */
8541 ut_params->sec_session = rte_security_session_create(ctx,
8542 &sess_conf, ts_params->session_mpool,
8543 ts_params->session_priv_mpool);
8545 if (!ut_params->sec_session) {
8546 printf("TestCase %s()-%d line %d failed %s: ",
8547 __func__, i, __LINE__, "Failed to allocate session");
8552 /* Generate crypto op data structure */
8553 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8554 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8555 if (!ut_params->op) {
8556 printf("TestCase %s()-%d line %d failed %s: ",
8557 __func__, i, __LINE__,
8558 "Failed to allocate symmetric crypto operation struct");
8563 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8565 /* set crypto operation source mbuf */
8566 ut_params->op->sym->m_src = ut_params->ibuf;
8568 ut_params->op->sym->m_dst = ut_params->obuf;
8570 /* Process crypto operation */
8571 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8573 printf("TestCase %s()-%d line %d failed %s: ",
8574 __func__, i, __LINE__,
8575 "failed to process sym crypto op");
8580 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8581 printf("TestCase %s()-%d line %d failed %s: ",
8582 __func__, i, __LINE__, "crypto op processing failed");
8588 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8591 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8595 fragsz = frag_size_oop;
8596 if (memcmp(ciphertext, output_vec, fragsz)) {
8597 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8598 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8599 rte_hexdump(stdout, "reference", output_vec, fragsz);
8604 buf = ut_params->op->sym->m_src->next;
8606 buf = ut_params->op->sym->m_dst->next;
8608 unsigned int off = fragsz;
8612 ciphertext = rte_pktmbuf_mtod(buf,
8614 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8615 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8616 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8617 rte_hexdump(stdout, "reference", output_vec + off,
8622 off += to_trn_tbl[ecx++];
8626 rte_crypto_op_free(ut_params->op);
8627 ut_params->op = NULL;
8629 if (ut_params->sec_session)
8630 rte_security_session_destroy(ctx, ut_params->sec_session);
8631 ut_params->sec_session = NULL;
8633 rte_pktmbuf_free(ut_params->ibuf);
8634 ut_params->ibuf = NULL;
8636 rte_pktmbuf_free(ut_params->obuf);
8637 ut_params->obuf = NULL;
8644 test_pdcp_proto_cplane_encap(int i)
8646 return test_pdcp_proto(
8647 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8648 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8649 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8650 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8651 pdcp_test_params[i].cipher_key_len,
8652 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8653 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8654 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8655 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8656 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8660 test_pdcp_proto_uplane_encap(int i)
8662 return test_pdcp_proto(
8663 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8664 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8665 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8666 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8667 pdcp_test_params[i].cipher_key_len,
8668 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8669 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8670 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8671 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8672 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8676 test_pdcp_proto_uplane_encap_with_int(int i)
8678 return test_pdcp_proto(
8679 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8680 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8681 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8682 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8683 pdcp_test_params[i].cipher_key_len,
8684 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8685 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8686 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8687 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8688 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8692 test_pdcp_proto_cplane_decap(int i)
8694 return test_pdcp_proto(
8695 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8696 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8697 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8698 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8699 pdcp_test_params[i].cipher_key_len,
8700 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8701 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8702 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8703 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8704 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8708 test_pdcp_proto_uplane_decap(int i)
8710 return test_pdcp_proto(
8711 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8712 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8713 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8714 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8715 pdcp_test_params[i].cipher_key_len,
8716 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8717 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8718 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8719 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8720 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8724 test_pdcp_proto_uplane_decap_with_int(int i)
8726 return test_pdcp_proto(
8727 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8728 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8729 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8730 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8731 pdcp_test_params[i].cipher_key_len,
8732 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8733 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8734 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8735 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8736 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8740 test_PDCP_PROTO_SGL_in_place_32B(void)
8742 /* i can be used for running any PDCP case
8743 * In this case it is uplane 12-bit AES-SNOW DL encap
8745 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8746 return test_pdcp_proto_SGL(i, IN_PLACE,
8747 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8748 RTE_CRYPTO_AUTH_OP_GENERATE,
8749 pdcp_test_data_in[i],
8750 pdcp_test_data_in_len[i],
8751 pdcp_test_data_out[i],
8752 pdcp_test_data_in_len[i]+4,
8756 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8758 /* i can be used for running any PDCP case
8759 * In this case it is uplane 18-bit NULL-NULL DL encap
8761 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8762 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8763 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8764 RTE_CRYPTO_AUTH_OP_GENERATE,
8765 pdcp_test_data_in[i],
8766 pdcp_test_data_in_len[i],
8767 pdcp_test_data_out[i],
8768 pdcp_test_data_in_len[i]+4,
8772 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8774 /* i can be used for running any PDCP case
8775 * In this case it is uplane 18-bit AES DL encap
8777 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8779 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8780 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8781 RTE_CRYPTO_AUTH_OP_GENERATE,
8782 pdcp_test_data_in[i],
8783 pdcp_test_data_in_len[i],
8784 pdcp_test_data_out[i],
8785 pdcp_test_data_in_len[i],
8789 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8791 /* i can be used for running any PDCP case
8792 * In this case it is cplane 12-bit AES-ZUC DL encap
8794 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8795 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8796 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8797 RTE_CRYPTO_AUTH_OP_GENERATE,
8798 pdcp_test_data_in[i],
8799 pdcp_test_data_in_len[i],
8800 pdcp_test_data_out[i],
8801 pdcp_test_data_in_len[i]+4,
8806 test_PDCP_SDAP_PROTO_encap_all(void)
8808 int i = 0, size = 0;
8809 int err, all_err = TEST_SUCCESS;
8810 const struct pdcp_sdap_test *cur_test;
8812 size = RTE_DIM(list_pdcp_sdap_tests);
8814 for (i = 0; i < size; i++) {
8815 cur_test = &list_pdcp_sdap_tests[i];
8816 err = test_pdcp_proto(
8817 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8818 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8819 cur_test->in_len, cur_test->data_out,
8820 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8821 cur_test->param.cipher_alg, cur_test->cipher_key,
8822 cur_test->param.cipher_key_len,
8823 cur_test->param.auth_alg,
8824 cur_test->auth_key, cur_test->param.auth_key_len,
8825 cur_test->bearer, cur_test->param.domain,
8826 cur_test->packet_direction, cur_test->sn_size,
8828 cur_test->hfn_threshold, SDAP_ENABLED);
8830 printf("\t%d) %s: Encapsulation failed\n",
8832 cur_test->param.name);
8835 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8836 cur_test->param.name);
8842 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8844 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8848 test_PDCP_PROTO_short_mac(void)
8850 int i = 0, size = 0;
8851 int err, all_err = TEST_SUCCESS;
8852 const struct pdcp_short_mac_test *cur_test;
8854 size = RTE_DIM(list_pdcp_smac_tests);
8856 for (i = 0; i < size; i++) {
8857 cur_test = &list_pdcp_smac_tests[i];
8858 err = test_pdcp_proto(
8859 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8860 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8861 cur_test->in_len, cur_test->data_out,
8862 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8863 RTE_CRYPTO_CIPHER_NULL, NULL,
8864 0, cur_test->param.auth_alg,
8865 cur_test->auth_key, cur_test->param.auth_key_len,
8866 0, cur_test->param.domain, 0, 0,
8869 printf("\t%d) %s: Short MAC test failed\n",
8871 cur_test->param.name);
8874 printf("\t%d) %s: Short MAC test PASS\n",
8876 cur_test->param.name);
8877 rte_hexdump(stdout, "MAC I",
8878 cur_test->data_out + cur_test->in_len + 2,
8885 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8887 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8892 test_PDCP_SDAP_PROTO_decap_all(void)
8894 int i = 0, size = 0;
8895 int err, all_err = TEST_SUCCESS;
8896 const struct pdcp_sdap_test *cur_test;
8898 size = RTE_DIM(list_pdcp_sdap_tests);
8900 for (i = 0; i < size; i++) {
8901 cur_test = &list_pdcp_sdap_tests[i];
8902 err = test_pdcp_proto(
8903 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8904 RTE_CRYPTO_AUTH_OP_VERIFY,
8906 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8907 cur_test->data_in, cur_test->in_len,
8908 cur_test->param.cipher_alg,
8909 cur_test->cipher_key, cur_test->param.cipher_key_len,
8910 cur_test->param.auth_alg, cur_test->auth_key,
8911 cur_test->param.auth_key_len, cur_test->bearer,
8912 cur_test->param.domain, cur_test->packet_direction,
8913 cur_test->sn_size, cur_test->hfn,
8914 cur_test->hfn_threshold, SDAP_ENABLED);
8916 printf("\t%d) %s: Decapsulation failed\n",
8918 cur_test->param.name);
8921 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8922 cur_test->param.name);
8928 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8930 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8934 test_ipsec_proto_process(const struct ipsec_test_data td[],
8935 struct ipsec_test_data res_d[],
8938 const struct ipsec_test_flags *flags)
8940 struct crypto_testsuite_params *ts_params = &testsuite_params;
8941 struct crypto_unittest_params *ut_params = &unittest_params;
8942 struct rte_security_capability_idx sec_cap_idx;
8943 const struct rte_security_capability *sec_cap;
8944 struct rte_security_ipsec_xform ipsec_xform;
8945 uint8_t dev_id = ts_params->valid_devs[0];
8946 enum rte_security_ipsec_sa_direction dir;
8947 struct ipsec_test_data *res_d_tmp = NULL;
8948 uint32_t src = RTE_IPV4(192, 168, 1, 0);
8949 uint32_t dst = RTE_IPV4(192, 168, 1, 1);
8950 int salt_len, i, ret = TEST_SUCCESS;
8951 struct rte_security_ctx *ctx;
8952 uint8_t *input_text;
8955 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8956 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8958 /* Use first test data to create session */
8960 /* Copy IPsec xform */
8961 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
8963 dir = ipsec_xform.direction;
8964 verify = flags->tunnel_hdr_verify;
8966 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
8967 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
8969 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
8973 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src, sizeof(src));
8974 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst, sizeof(dst));
8976 ctx = rte_cryptodev_get_sec_ctx(dev_id);
8978 sec_cap_idx.action = ut_params->type;
8979 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
8980 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
8981 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
8982 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
8984 if (flags->udp_encap)
8985 ipsec_xform.options.udp_encap = 1;
8987 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8988 if (sec_cap == NULL)
8989 return TEST_SKIPPED;
8991 /* Copy cipher session parameters */
8993 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
8994 sizeof(ut_params->aead_xform));
8995 ut_params->aead_xform.aead.key.data = td[0].key.data;
8996 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8998 /* Verify crypto capabilities */
8999 if (test_ipsec_crypto_caps_aead_verify(
9001 &ut_params->aead_xform) != 0) {
9003 RTE_LOG(INFO, USER1,
9004 "Crypto capabilities not supported\n");
9005 return TEST_SKIPPED;
9008 /* Only AEAD supported now */
9009 return TEST_SKIPPED;
9012 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9013 return TEST_SKIPPED;
9015 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9016 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9018 struct rte_security_session_conf sess_conf = {
9019 .action_type = ut_params->type,
9020 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9021 .ipsec = ipsec_xform,
9022 .crypto_xform = &ut_params->aead_xform,
9025 /* Create security session */
9026 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9027 ts_params->session_mpool,
9028 ts_params->session_priv_mpool);
9030 if (ut_params->sec_session == NULL)
9031 return TEST_SKIPPED;
9033 for (i = 0; i < nb_td; i++) {
9034 /* Setup source mbuf payload */
9035 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9036 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9037 rte_pktmbuf_tailroom(ut_params->ibuf));
9039 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9040 td[i].input_text.len);
9042 memcpy(input_text, td[i].input_text.data,
9043 td[i].input_text.len);
9045 /* Generate crypto op data structure */
9046 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9047 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9048 if (!ut_params->op) {
9049 printf("TestCase %s line %d: %s\n",
9051 "failed to allocate crypto op");
9053 goto crypto_op_free;
9056 /* Attach session to operation */
9057 rte_security_attach_session(ut_params->op,
9058 ut_params->sec_session);
9060 /* Set crypto operation mbufs */
9061 ut_params->op->sym->m_src = ut_params->ibuf;
9062 ut_params->op->sym->m_dst = NULL;
9064 /* Copy IV in crypto operation when IV generation is disabled */
9065 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9066 ipsec_xform.options.iv_gen_disable == 1) {
9067 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9073 len = td[i].xform.aead.aead.iv.length;
9075 len = td[i].xform.chain.cipher.cipher.iv.length;
9077 memcpy(iv, td[i].iv.data, len);
9080 /* Process crypto operation */
9081 process_crypto_request(dev_id, ut_params->op);
9083 ret = test_ipsec_status_check(ut_params->op, flags, dir, i + 1);
9084 if (ret != TEST_SUCCESS)
9085 goto crypto_op_free;
9088 res_d_tmp = &res_d[i];
9090 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9091 res_d_tmp, silent, flags);
9092 if (ret != TEST_SUCCESS)
9093 goto crypto_op_free;
9095 rte_crypto_op_free(ut_params->op);
9096 ut_params->op = NULL;
9098 rte_pktmbuf_free(ut_params->ibuf);
9099 ut_params->ibuf = NULL;
9103 rte_crypto_op_free(ut_params->op);
9104 ut_params->op = NULL;
9106 rte_pktmbuf_free(ut_params->ibuf);
9107 ut_params->ibuf = NULL;
9109 if (ut_params->sec_session)
9110 rte_security_session_destroy(ctx, ut_params->sec_session);
9111 ut_params->sec_session = NULL;
9117 test_ipsec_proto_known_vec(const void *test_data)
9119 struct ipsec_test_data td_outb;
9120 struct ipsec_test_flags flags;
9122 memset(&flags, 0, sizeof(flags));
9124 memcpy(&td_outb, test_data, sizeof(td_outb));
9126 /* Disable IV gen to be able to test with known vectors */
9127 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9129 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9133 test_ipsec_proto_known_vec_inb(const void *td_outb)
9135 struct ipsec_test_flags flags;
9136 struct ipsec_test_data td_inb;
9138 memset(&flags, 0, sizeof(flags));
9140 test_ipsec_td_in_from_out(td_outb, &td_inb);
9142 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9146 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9148 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9149 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9150 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9153 if (flags->iv_gen ||
9154 flags->sa_expiry_pkts_soft ||
9155 flags->sa_expiry_pkts_hard)
9156 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9158 for (i = 0; i < RTE_DIM(aead_list); i++) {
9159 test_ipsec_td_prepare(&aead_list[i],
9165 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9167 if (ret == TEST_SKIPPED)
9170 if (ret == TEST_FAILED)
9173 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9175 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9177 if (ret == TEST_SKIPPED)
9180 if (ret == TEST_FAILED)
9183 if (flags->display_alg)
9184 test_ipsec_display_alg(&aead_list[i], NULL);
9190 return TEST_SUCCESS;
9192 return TEST_SKIPPED;
9196 test_ipsec_proto_display_list(const void *data __rte_unused)
9198 struct ipsec_test_flags flags;
9200 memset(&flags, 0, sizeof(flags));
9202 flags.display_alg = true;
9204 return test_ipsec_proto_all(&flags);
9208 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9210 struct ipsec_test_flags flags;
9212 memset(&flags, 0, sizeof(flags));
9214 flags.iv_gen = true;
9216 return test_ipsec_proto_all(&flags);
9220 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9222 struct ipsec_test_flags flags;
9224 memset(&flags, 0, sizeof(flags));
9226 flags.sa_expiry_pkts_soft = true;
9228 return test_ipsec_proto_all(&flags);
9232 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9234 struct ipsec_test_flags flags;
9236 memset(&flags, 0, sizeof(flags));
9238 flags.sa_expiry_pkts_hard = true;
9240 return test_ipsec_proto_all(&flags);
9244 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9246 struct ipsec_test_flags flags;
9248 memset(&flags, 0, sizeof(flags));
9250 flags.icv_corrupt = true;
9252 return test_ipsec_proto_all(&flags);
9256 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9258 struct ipsec_test_flags flags;
9260 memset(&flags, 0, sizeof(flags));
9262 flags.udp_encap = true;
9264 return test_ipsec_proto_all(&flags);
9268 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9270 struct ipsec_test_flags flags;
9272 memset(&flags, 0, sizeof(flags));
9274 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9276 return test_ipsec_proto_all(&flags);
9280 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9282 struct ipsec_test_flags flags;
9284 memset(&flags, 0, sizeof(flags));
9286 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9288 return test_ipsec_proto_all(&flags);
9292 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9294 struct ipsec_test_flags flags;
9296 memset(&flags, 0, sizeof(flags));
9298 flags.udp_encap = true;
9299 flags.udp_ports_verify = true;
9301 return test_ipsec_proto_all(&flags);
9305 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9307 struct ipsec_test_flags flags;
9309 memset(&flags, 0, sizeof(flags));
9311 flags.ip_csum = true;
9313 return test_ipsec_proto_all(&flags);
9317 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9319 struct ipsec_test_flags flags;
9321 memset(&flags, 0, sizeof(flags));
9323 flags.l4_csum = true;
9325 return test_ipsec_proto_all(&flags);
9329 test_PDCP_PROTO_all(void)
9331 struct crypto_testsuite_params *ts_params = &testsuite_params;
9332 struct crypto_unittest_params *ut_params = &unittest_params;
9333 struct rte_cryptodev_info dev_info;
9336 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9337 uint64_t feat_flags = dev_info.feature_flags;
9339 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9340 return TEST_SKIPPED;
9342 /* Set action type */
9343 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9344 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9347 if (security_proto_supported(ut_params->type,
9348 RTE_SECURITY_PROTOCOL_PDCP) < 0)
9349 return TEST_SKIPPED;
9351 status = test_PDCP_PROTO_cplane_encap_all();
9352 status += test_PDCP_PROTO_cplane_decap_all();
9353 status += test_PDCP_PROTO_uplane_encap_all();
9354 status += test_PDCP_PROTO_uplane_decap_all();
9355 status += test_PDCP_PROTO_SGL_in_place_32B();
9356 status += test_PDCP_PROTO_SGL_oop_32B_128B();
9357 status += test_PDCP_PROTO_SGL_oop_32B_40B();
9358 status += test_PDCP_PROTO_SGL_oop_128B_32B();
9359 status += test_PDCP_SDAP_PROTO_encap_all();
9360 status += test_PDCP_SDAP_PROTO_decap_all();
9361 status += test_PDCP_PROTO_short_mac();
9366 return TEST_SUCCESS;
9370 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
9372 struct crypto_testsuite_params *ts_params = &testsuite_params;
9373 struct crypto_unittest_params *ut_params = &unittest_params;
9374 uint8_t *plaintext, *ciphertext;
9376 int32_t cipher_len, crc_len;
9377 uint32_t crc_data_len;
9378 int ret = TEST_SUCCESS;
9380 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9381 rte_cryptodev_get_sec_ctx(
9382 ts_params->valid_devs[0]);
9384 /* Verify the capabilities */
9385 struct rte_security_capability_idx sec_cap_idx;
9386 const struct rte_security_capability *sec_cap;
9387 const struct rte_cryptodev_capabilities *crypto_cap;
9388 const struct rte_cryptodev_symmetric_capability *sym_cap;
9391 sec_cap_idx.action = ut_params->type;
9392 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9393 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9395 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9396 if (sec_cap == NULL)
9397 return TEST_SKIPPED;
9399 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9400 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9401 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9402 crypto_cap->sym.xform_type ==
9403 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9404 crypto_cap->sym.cipher.algo ==
9405 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9406 sym_cap = &crypto_cap->sym;
9407 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9414 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9415 return TEST_SKIPPED;
9417 /* Setup source mbuf payload */
9418 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9419 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9420 rte_pktmbuf_tailroom(ut_params->ibuf));
9422 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9423 d_td->ciphertext.len);
9425 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
9427 /* Setup cipher session parameters */
9428 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9429 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9430 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
9431 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9432 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9433 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9434 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9435 ut_params->cipher_xform.next = NULL;
9437 /* Setup DOCSIS session parameters */
9438 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9440 struct rte_security_session_conf sess_conf = {
9441 .action_type = ut_params->type,
9442 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9443 .docsis = ut_params->docsis_xform,
9444 .crypto_xform = &ut_params->cipher_xform,
9447 /* Create security session */
9448 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9449 ts_params->session_mpool,
9450 ts_params->session_priv_mpool);
9452 if (!ut_params->sec_session) {
9453 printf("TestCase %s(%d) line %d: %s\n",
9454 __func__, i, __LINE__, "failed to allocate session");
9459 /* Generate crypto op data structure */
9460 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9461 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9462 if (!ut_params->op) {
9463 printf("TestCase %s(%d) line %d: %s\n",
9464 __func__, i, __LINE__,
9465 "failed to allocate symmetric crypto operation");
9470 /* Setup CRC operation parameters */
9471 crc_len = d_td->ciphertext.no_crc == false ?
9472 (d_td->ciphertext.len -
9473 d_td->ciphertext.crc_offset -
9474 RTE_ETHER_CRC_LEN) :
9476 crc_len = crc_len > 0 ? crc_len : 0;
9477 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9478 ut_params->op->sym->auth.data.length = crc_len;
9479 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9481 /* Setup cipher operation parameters */
9482 cipher_len = d_td->ciphertext.no_cipher == false ?
9483 (d_td->ciphertext.len -
9484 d_td->ciphertext.cipher_offset) :
9486 cipher_len = cipher_len > 0 ? cipher_len : 0;
9487 ut_params->op->sym->cipher.data.length = cipher_len;
9488 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9490 /* Setup cipher IV */
9491 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9492 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9494 /* Attach session to operation */
9495 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9497 /* Set crypto operation mbufs */
9498 ut_params->op->sym->m_src = ut_params->ibuf;
9499 ut_params->op->sym->m_dst = NULL;
9501 /* Process crypto operation */
9502 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9504 printf("TestCase %s(%d) line %d: %s\n",
9505 __func__, i, __LINE__,
9506 "failed to process security crypto op");
9511 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9512 printf("TestCase %s(%d) line %d: %s\n",
9513 __func__, i, __LINE__, "crypto op processing failed");
9518 /* Validate plaintext */
9519 plaintext = ciphertext;
9521 if (memcmp(plaintext, d_td->plaintext.data,
9522 d_td->plaintext.len - crc_data_len)) {
9523 printf("TestCase %s(%d) line %d: %s\n",
9524 __func__, i, __LINE__, "plaintext not as expected\n");
9525 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9526 d_td->plaintext.len);
9527 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9533 rte_crypto_op_free(ut_params->op);
9534 ut_params->op = NULL;
9536 if (ut_params->sec_session)
9537 rte_security_session_destroy(ctx, ut_params->sec_session);
9538 ut_params->sec_session = NULL;
9540 rte_pktmbuf_free(ut_params->ibuf);
9541 ut_params->ibuf = NULL;
9547 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9549 struct crypto_testsuite_params *ts_params = &testsuite_params;
9550 struct crypto_unittest_params *ut_params = &unittest_params;
9551 uint8_t *plaintext, *ciphertext;
9553 int32_t cipher_len, crc_len;
9554 int ret = TEST_SUCCESS;
9556 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9557 rte_cryptodev_get_sec_ctx(
9558 ts_params->valid_devs[0]);
9560 /* Verify the capabilities */
9561 struct rte_security_capability_idx sec_cap_idx;
9562 const struct rte_security_capability *sec_cap;
9563 const struct rte_cryptodev_capabilities *crypto_cap;
9564 const struct rte_cryptodev_symmetric_capability *sym_cap;
9567 sec_cap_idx.action = ut_params->type;
9568 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9569 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9571 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9572 if (sec_cap == NULL)
9573 return TEST_SKIPPED;
9575 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9576 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9577 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9578 crypto_cap->sym.xform_type ==
9579 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9580 crypto_cap->sym.cipher.algo ==
9581 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9582 sym_cap = &crypto_cap->sym;
9583 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9590 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9591 return TEST_SKIPPED;
9593 /* Setup source mbuf payload */
9594 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9595 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9596 rte_pktmbuf_tailroom(ut_params->ibuf));
9598 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9599 d_td->plaintext.len);
9601 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9603 /* Setup cipher session parameters */
9604 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9605 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9606 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9607 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9608 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9609 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9610 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9611 ut_params->cipher_xform.next = NULL;
9613 /* Setup DOCSIS session parameters */
9614 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9616 struct rte_security_session_conf sess_conf = {
9617 .action_type = ut_params->type,
9618 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9619 .docsis = ut_params->docsis_xform,
9620 .crypto_xform = &ut_params->cipher_xform,
9623 /* Create security session */
9624 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9625 ts_params->session_mpool,
9626 ts_params->session_priv_mpool);
9628 if (!ut_params->sec_session) {
9629 printf("TestCase %s(%d) line %d: %s\n",
9630 __func__, i, __LINE__, "failed to allocate session");
9635 /* Generate crypto op data structure */
9636 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9637 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9638 if (!ut_params->op) {
9639 printf("TestCase %s(%d) line %d: %s\n",
9640 __func__, i, __LINE__,
9641 "failed to allocate security crypto operation");
9646 /* Setup CRC operation parameters */
9647 crc_len = d_td->plaintext.no_crc == false ?
9648 (d_td->plaintext.len -
9649 d_td->plaintext.crc_offset -
9650 RTE_ETHER_CRC_LEN) :
9652 crc_len = crc_len > 0 ? crc_len : 0;
9653 ut_params->op->sym->auth.data.length = crc_len;
9654 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9656 /* Setup cipher operation parameters */
9657 cipher_len = d_td->plaintext.no_cipher == false ?
9658 (d_td->plaintext.len -
9659 d_td->plaintext.cipher_offset) :
9661 cipher_len = cipher_len > 0 ? cipher_len : 0;
9662 ut_params->op->sym->cipher.data.length = cipher_len;
9663 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9665 /* Setup cipher IV */
9666 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9667 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9669 /* Attach session to operation */
9670 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9672 /* Set crypto operation mbufs */
9673 ut_params->op->sym->m_src = ut_params->ibuf;
9674 ut_params->op->sym->m_dst = NULL;
9676 /* Process crypto operation */
9677 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9679 printf("TestCase %s(%d) line %d: %s\n",
9680 __func__, i, __LINE__,
9681 "failed to process security crypto op");
9686 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9687 printf("TestCase %s(%d) line %d: %s\n",
9688 __func__, i, __LINE__, "crypto op processing failed");
9693 /* Validate ciphertext */
9694 ciphertext = plaintext;
9696 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9697 printf("TestCase %s(%d) line %d: %s\n",
9698 __func__, i, __LINE__, "ciphertext not as expected\n");
9699 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9700 d_td->ciphertext.len);
9701 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9707 rte_crypto_op_free(ut_params->op);
9708 ut_params->op = NULL;
9710 if (ut_params->sec_session)
9711 rte_security_session_destroy(ctx, ut_params->sec_session);
9712 ut_params->sec_session = NULL;
9714 rte_pktmbuf_free(ut_params->ibuf);
9715 ut_params->ibuf = NULL;
9720 #define TEST_DOCSIS_COUNT(func) do { \
9722 if (ret == TEST_SUCCESS) { \
9723 printf("\t%2d)", n++); \
9724 printf("+++++ PASSED:" #func"\n"); \
9726 } else if (ret == TEST_SKIPPED) { \
9727 printf("\t%2d)", n++); \
9728 printf("~~~~~ SKIPPED:" #func"\n"); \
9731 printf("\t%2d)", n++); \
9732 printf("----- FAILED:" #func"\n"); \
9738 test_DOCSIS_PROTO_uplink_all(void)
9740 int p = 0, s = 0, f = 0, n = 0;
9742 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9743 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9744 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9745 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9746 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9747 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9748 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9749 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9750 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9751 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9752 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9753 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9754 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9755 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9756 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9757 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9758 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9759 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9760 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9761 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9762 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9763 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9764 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9765 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9766 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9767 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9770 printf("## %s: %d passed out of %d (%d skipped)\n",
9777 test_DOCSIS_PROTO_downlink_all(void)
9779 int p = 0, s = 0, f = 0, n = 0;
9781 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9782 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9783 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9784 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9785 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9786 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9787 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9788 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9789 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9790 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9791 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9792 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9793 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9794 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9795 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9796 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9797 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9798 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9799 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9800 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9801 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9802 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9803 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9804 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9805 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9806 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9809 printf("## %s: %d passed out of %d (%d skipped)\n",
9816 test_DOCSIS_PROTO_all(void)
9818 struct crypto_testsuite_params *ts_params = &testsuite_params;
9819 struct crypto_unittest_params *ut_params = &unittest_params;
9820 struct rte_cryptodev_info dev_info;
9823 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9824 uint64_t feat_flags = dev_info.feature_flags;
9826 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9827 return TEST_SKIPPED;
9829 /* Set action type */
9830 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9831 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9834 if (security_proto_supported(ut_params->type,
9835 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9836 return TEST_SKIPPED;
9838 status = test_DOCSIS_PROTO_uplink_all();
9839 status += test_DOCSIS_PROTO_downlink_all();
9844 return TEST_SUCCESS;
9849 test_AES_GCM_authenticated_encryption_test_case_1(void)
9851 return test_authenticated_encryption(&gcm_test_case_1);
9855 test_AES_GCM_authenticated_encryption_test_case_2(void)
9857 return test_authenticated_encryption(&gcm_test_case_2);
9861 test_AES_GCM_authenticated_encryption_test_case_3(void)
9863 return test_authenticated_encryption(&gcm_test_case_3);
9867 test_AES_GCM_authenticated_encryption_test_case_4(void)
9869 return test_authenticated_encryption(&gcm_test_case_4);
9873 test_AES_GCM_authenticated_encryption_test_case_5(void)
9875 return test_authenticated_encryption(&gcm_test_case_5);
9879 test_AES_GCM_authenticated_encryption_test_case_6(void)
9881 return test_authenticated_encryption(&gcm_test_case_6);
9885 test_AES_GCM_authenticated_encryption_test_case_7(void)
9887 return test_authenticated_encryption(&gcm_test_case_7);
9891 test_AES_GCM_authenticated_encryption_test_case_8(void)
9893 return test_authenticated_encryption(&gcm_test_case_8);
9897 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9899 return test_authenticated_encryption(&gcm_J0_test_case_1);
9903 test_AES_GCM_auth_encryption_test_case_192_1(void)
9905 return test_authenticated_encryption(&gcm_test_case_192_1);
9909 test_AES_GCM_auth_encryption_test_case_192_2(void)
9911 return test_authenticated_encryption(&gcm_test_case_192_2);
9915 test_AES_GCM_auth_encryption_test_case_192_3(void)
9917 return test_authenticated_encryption(&gcm_test_case_192_3);
9921 test_AES_GCM_auth_encryption_test_case_192_4(void)
9923 return test_authenticated_encryption(&gcm_test_case_192_4);
9927 test_AES_GCM_auth_encryption_test_case_192_5(void)
9929 return test_authenticated_encryption(&gcm_test_case_192_5);
9933 test_AES_GCM_auth_encryption_test_case_192_6(void)
9935 return test_authenticated_encryption(&gcm_test_case_192_6);
9939 test_AES_GCM_auth_encryption_test_case_192_7(void)
9941 return test_authenticated_encryption(&gcm_test_case_192_7);
9945 test_AES_GCM_auth_encryption_test_case_256_1(void)
9947 return test_authenticated_encryption(&gcm_test_case_256_1);
9951 test_AES_GCM_auth_encryption_test_case_256_2(void)
9953 return test_authenticated_encryption(&gcm_test_case_256_2);
9957 test_AES_GCM_auth_encryption_test_case_256_3(void)
9959 return test_authenticated_encryption(&gcm_test_case_256_3);
9963 test_AES_GCM_auth_encryption_test_case_256_4(void)
9965 return test_authenticated_encryption(&gcm_test_case_256_4);
9969 test_AES_GCM_auth_encryption_test_case_256_5(void)
9971 return test_authenticated_encryption(&gcm_test_case_256_5);
9975 test_AES_GCM_auth_encryption_test_case_256_6(void)
9977 return test_authenticated_encryption(&gcm_test_case_256_6);
9981 test_AES_GCM_auth_encryption_test_case_256_7(void)
9983 return test_authenticated_encryption(&gcm_test_case_256_7);
9987 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9989 return test_authenticated_encryption(&gcm_test_case_aad_1);
9993 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9995 return test_authenticated_encryption(&gcm_test_case_aad_2);
9999 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10001 struct aead_test_data tdata;
10004 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10005 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10006 tdata.iv.data[0] += 1;
10007 res = test_authenticated_encryption(&tdata);
10008 if (res == TEST_SKIPPED)
10010 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10011 return TEST_SUCCESS;
10015 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10017 struct aead_test_data tdata;
10020 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10021 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10022 tdata.plaintext.data[0] += 1;
10023 res = test_authenticated_encryption(&tdata);
10024 if (res == TEST_SKIPPED)
10026 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10027 return TEST_SUCCESS;
10031 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10033 struct aead_test_data tdata;
10036 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10037 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10038 tdata.ciphertext.data[0] += 1;
10039 res = test_authenticated_encryption(&tdata);
10040 if (res == TEST_SKIPPED)
10042 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10043 return TEST_SUCCESS;
10047 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10049 struct aead_test_data tdata;
10052 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10053 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10054 tdata.aad.len += 1;
10055 res = test_authenticated_encryption(&tdata);
10056 if (res == TEST_SKIPPED)
10058 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10059 return TEST_SUCCESS;
10063 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10065 struct aead_test_data tdata;
10066 uint8_t aad[gcm_test_case_7.aad.len];
10069 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10070 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10071 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10073 tdata.aad.data = aad;
10074 res = test_authenticated_encryption(&tdata);
10075 if (res == TEST_SKIPPED)
10077 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10078 return TEST_SUCCESS;
10082 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10084 struct aead_test_data tdata;
10087 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10088 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10089 tdata.auth_tag.data[0] += 1;
10090 res = test_authenticated_encryption(&tdata);
10091 if (res == TEST_SKIPPED)
10093 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10094 return TEST_SUCCESS;
10098 test_authenticated_decryption(const struct aead_test_data *tdata)
10100 struct crypto_testsuite_params *ts_params = &testsuite_params;
10101 struct crypto_unittest_params *ut_params = &unittest_params;
10104 uint8_t *plaintext;
10106 struct rte_cryptodev_info dev_info;
10108 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10109 uint64_t feat_flags = dev_info.feature_flags;
10111 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10112 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10113 printf("Device doesn't support RAW data-path APIs.\n");
10114 return TEST_SKIPPED;
10117 /* Verify the capabilities */
10118 struct rte_cryptodev_sym_capability_idx cap_idx;
10119 const struct rte_cryptodev_symmetric_capability *capability;
10120 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10121 cap_idx.algo.aead = tdata->algo;
10122 capability = rte_cryptodev_sym_capability_get(
10123 ts_params->valid_devs[0], &cap_idx);
10124 if (capability == NULL)
10125 return TEST_SKIPPED;
10126 if (rte_cryptodev_sym_capability_check_aead(
10127 capability, tdata->key.len, tdata->auth_tag.len,
10128 tdata->aad.len, tdata->iv.len))
10129 return TEST_SKIPPED;
10131 /* Create AEAD session */
10132 retval = create_aead_session(ts_params->valid_devs[0],
10134 RTE_CRYPTO_AEAD_OP_DECRYPT,
10135 tdata->key.data, tdata->key.len,
10136 tdata->aad.len, tdata->auth_tag.len,
10141 /* alloc mbuf and set payload */
10142 if (tdata->aad.len > MBUF_SIZE) {
10143 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10144 /* Populate full size of add data */
10145 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10146 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10148 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10150 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10151 rte_pktmbuf_tailroom(ut_params->ibuf));
10153 /* Create AEAD operation */
10154 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10158 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10160 ut_params->op->sym->m_src = ut_params->ibuf;
10162 /* Process crypto operation */
10163 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10164 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10165 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10166 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10167 ut_params->op, 0, 0, 0, 0);
10169 TEST_ASSERT_NOT_NULL(
10170 process_crypto_request(ts_params->valid_devs[0],
10171 ut_params->op), "failed to process sym crypto op");
10173 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10174 "crypto op processing failed");
10176 if (ut_params->op->sym->m_dst)
10177 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10180 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10182 ut_params->op->sym->cipher.data.offset);
10184 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10186 /* Validate obuf */
10187 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10189 tdata->plaintext.data,
10190 tdata->plaintext.len,
10191 "Plaintext data not as expected");
10193 TEST_ASSERT_EQUAL(ut_params->op->status,
10194 RTE_CRYPTO_OP_STATUS_SUCCESS,
10195 "Authentication failed");
10201 test_AES_GCM_authenticated_decryption_test_case_1(void)
10203 return test_authenticated_decryption(&gcm_test_case_1);
10207 test_AES_GCM_authenticated_decryption_test_case_2(void)
10209 return test_authenticated_decryption(&gcm_test_case_2);
10213 test_AES_GCM_authenticated_decryption_test_case_3(void)
10215 return test_authenticated_decryption(&gcm_test_case_3);
10219 test_AES_GCM_authenticated_decryption_test_case_4(void)
10221 return test_authenticated_decryption(&gcm_test_case_4);
10225 test_AES_GCM_authenticated_decryption_test_case_5(void)
10227 return test_authenticated_decryption(&gcm_test_case_5);
10231 test_AES_GCM_authenticated_decryption_test_case_6(void)
10233 return test_authenticated_decryption(&gcm_test_case_6);
10237 test_AES_GCM_authenticated_decryption_test_case_7(void)
10239 return test_authenticated_decryption(&gcm_test_case_7);
10243 test_AES_GCM_authenticated_decryption_test_case_8(void)
10245 return test_authenticated_decryption(&gcm_test_case_8);
10249 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10251 return test_authenticated_decryption(&gcm_J0_test_case_1);
10255 test_AES_GCM_auth_decryption_test_case_192_1(void)
10257 return test_authenticated_decryption(&gcm_test_case_192_1);
10261 test_AES_GCM_auth_decryption_test_case_192_2(void)
10263 return test_authenticated_decryption(&gcm_test_case_192_2);
10267 test_AES_GCM_auth_decryption_test_case_192_3(void)
10269 return test_authenticated_decryption(&gcm_test_case_192_3);
10273 test_AES_GCM_auth_decryption_test_case_192_4(void)
10275 return test_authenticated_decryption(&gcm_test_case_192_4);
10279 test_AES_GCM_auth_decryption_test_case_192_5(void)
10281 return test_authenticated_decryption(&gcm_test_case_192_5);
10285 test_AES_GCM_auth_decryption_test_case_192_6(void)
10287 return test_authenticated_decryption(&gcm_test_case_192_6);
10291 test_AES_GCM_auth_decryption_test_case_192_7(void)
10293 return test_authenticated_decryption(&gcm_test_case_192_7);
10297 test_AES_GCM_auth_decryption_test_case_256_1(void)
10299 return test_authenticated_decryption(&gcm_test_case_256_1);
10303 test_AES_GCM_auth_decryption_test_case_256_2(void)
10305 return test_authenticated_decryption(&gcm_test_case_256_2);
10309 test_AES_GCM_auth_decryption_test_case_256_3(void)
10311 return test_authenticated_decryption(&gcm_test_case_256_3);
10315 test_AES_GCM_auth_decryption_test_case_256_4(void)
10317 return test_authenticated_decryption(&gcm_test_case_256_4);
10321 test_AES_GCM_auth_decryption_test_case_256_5(void)
10323 return test_authenticated_decryption(&gcm_test_case_256_5);
10327 test_AES_GCM_auth_decryption_test_case_256_6(void)
10329 return test_authenticated_decryption(&gcm_test_case_256_6);
10333 test_AES_GCM_auth_decryption_test_case_256_7(void)
10335 return test_authenticated_decryption(&gcm_test_case_256_7);
10339 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10341 return test_authenticated_decryption(&gcm_test_case_aad_1);
10345 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10347 return test_authenticated_decryption(&gcm_test_case_aad_2);
10351 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10353 struct aead_test_data tdata;
10356 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10357 tdata.iv.data[0] += 1;
10358 res = test_authenticated_decryption(&tdata);
10359 if (res == TEST_SKIPPED)
10361 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10362 return TEST_SUCCESS;
10366 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10368 struct aead_test_data tdata;
10371 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10372 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10373 tdata.plaintext.data[0] += 1;
10374 res = test_authenticated_decryption(&tdata);
10375 if (res == TEST_SKIPPED)
10377 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10378 return TEST_SUCCESS;
10382 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10384 struct aead_test_data tdata;
10387 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10388 tdata.ciphertext.data[0] += 1;
10389 res = test_authenticated_decryption(&tdata);
10390 if (res == TEST_SKIPPED)
10392 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10393 return TEST_SUCCESS;
10397 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10399 struct aead_test_data tdata;
10402 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10403 tdata.aad.len += 1;
10404 res = test_authenticated_decryption(&tdata);
10405 if (res == TEST_SKIPPED)
10407 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10408 return TEST_SUCCESS;
10412 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10414 struct aead_test_data tdata;
10415 uint8_t aad[gcm_test_case_7.aad.len];
10418 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10419 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10421 tdata.aad.data = aad;
10422 res = test_authenticated_decryption(&tdata);
10423 if (res == TEST_SKIPPED)
10425 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10426 return TEST_SUCCESS;
10430 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10432 struct aead_test_data tdata;
10435 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10436 tdata.auth_tag.data[0] += 1;
10437 res = test_authenticated_decryption(&tdata);
10438 if (res == TEST_SKIPPED)
10440 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10441 return TEST_SUCCESS;
10445 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10447 struct crypto_testsuite_params *ts_params = &testsuite_params;
10448 struct crypto_unittest_params *ut_params = &unittest_params;
10451 uint8_t *ciphertext, *auth_tag;
10452 uint16_t plaintext_pad_len;
10454 /* Verify the capabilities */
10455 struct rte_cryptodev_sym_capability_idx cap_idx;
10456 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10457 cap_idx.algo.aead = tdata->algo;
10458 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10460 return TEST_SKIPPED;
10462 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10463 return TEST_SKIPPED;
10465 /* not supported with CPU crypto */
10466 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10467 return TEST_SKIPPED;
10469 /* Create AEAD session */
10470 retval = create_aead_session(ts_params->valid_devs[0],
10472 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10473 tdata->key.data, tdata->key.len,
10474 tdata->aad.len, tdata->auth_tag.len,
10479 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10480 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10482 /* clear mbuf payload */
10483 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10484 rte_pktmbuf_tailroom(ut_params->ibuf));
10485 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10486 rte_pktmbuf_tailroom(ut_params->obuf));
10488 /* Create AEAD operation */
10489 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10493 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10495 ut_params->op->sym->m_src = ut_params->ibuf;
10496 ut_params->op->sym->m_dst = ut_params->obuf;
10498 /* Process crypto operation */
10499 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10500 ut_params->op), "failed to process sym crypto op");
10502 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10503 "crypto op processing failed");
10505 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10507 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10508 ut_params->op->sym->cipher.data.offset);
10509 auth_tag = ciphertext + plaintext_pad_len;
10511 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10512 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10514 /* Validate obuf */
10515 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10517 tdata->ciphertext.data,
10518 tdata->ciphertext.len,
10519 "Ciphertext data not as expected");
10521 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10523 tdata->auth_tag.data,
10524 tdata->auth_tag.len,
10525 "Generated auth tag not as expected");
10532 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10534 return test_authenticated_encryption_oop(&gcm_test_case_5);
10538 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10540 struct crypto_testsuite_params *ts_params = &testsuite_params;
10541 struct crypto_unittest_params *ut_params = &unittest_params;
10544 uint8_t *plaintext;
10546 /* Verify the capabilities */
10547 struct rte_cryptodev_sym_capability_idx cap_idx;
10548 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10549 cap_idx.algo.aead = tdata->algo;
10550 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10552 return TEST_SKIPPED;
10554 /* not supported with CPU crypto and raw data-path APIs*/
10555 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10556 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10557 return TEST_SKIPPED;
10559 /* Create AEAD session */
10560 retval = create_aead_session(ts_params->valid_devs[0],
10562 RTE_CRYPTO_AEAD_OP_DECRYPT,
10563 tdata->key.data, tdata->key.len,
10564 tdata->aad.len, tdata->auth_tag.len,
10569 /* alloc mbuf and set payload */
10570 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10571 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10573 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10574 rte_pktmbuf_tailroom(ut_params->ibuf));
10575 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10576 rte_pktmbuf_tailroom(ut_params->obuf));
10578 /* Create AEAD operation */
10579 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10583 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10585 ut_params->op->sym->m_src = ut_params->ibuf;
10586 ut_params->op->sym->m_dst = ut_params->obuf;
10588 /* Process crypto operation */
10589 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10590 ut_params->op), "failed to process sym crypto op");
10592 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10593 "crypto op processing failed");
10595 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10596 ut_params->op->sym->cipher.data.offset);
10598 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10600 /* Validate obuf */
10601 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10603 tdata->plaintext.data,
10604 tdata->plaintext.len,
10605 "Plaintext data not as expected");
10607 TEST_ASSERT_EQUAL(ut_params->op->status,
10608 RTE_CRYPTO_OP_STATUS_SUCCESS,
10609 "Authentication failed");
10614 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10616 return test_authenticated_decryption_oop(&gcm_test_case_5);
10620 test_authenticated_encryption_sessionless(
10621 const struct aead_test_data *tdata)
10623 struct crypto_testsuite_params *ts_params = &testsuite_params;
10624 struct crypto_unittest_params *ut_params = &unittest_params;
10627 uint8_t *ciphertext, *auth_tag;
10628 uint16_t plaintext_pad_len;
10629 uint8_t key[tdata->key.len + 1];
10630 struct rte_cryptodev_info dev_info;
10632 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10633 uint64_t feat_flags = dev_info.feature_flags;
10635 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10636 printf("Device doesn't support Sessionless ops.\n");
10637 return TEST_SKIPPED;
10640 /* not supported with CPU crypto */
10641 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10642 return TEST_SKIPPED;
10644 /* Verify the capabilities */
10645 struct rte_cryptodev_sym_capability_idx cap_idx;
10646 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10647 cap_idx.algo.aead = tdata->algo;
10648 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10650 return TEST_SKIPPED;
10652 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10654 /* clear mbuf payload */
10655 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10656 rte_pktmbuf_tailroom(ut_params->ibuf));
10658 /* Create AEAD operation */
10659 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10663 /* Create GCM xform */
10664 memcpy(key, tdata->key.data, tdata->key.len);
10665 retval = create_aead_xform(ut_params->op,
10667 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10668 key, tdata->key.len,
10669 tdata->aad.len, tdata->auth_tag.len,
10674 ut_params->op->sym->m_src = ut_params->ibuf;
10676 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10677 RTE_CRYPTO_OP_SESSIONLESS,
10678 "crypto op session type not sessionless");
10680 /* Process crypto operation */
10681 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10682 ut_params->op), "failed to process sym crypto op");
10684 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10686 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10687 "crypto op status not success");
10689 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10691 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10692 ut_params->op->sym->cipher.data.offset);
10693 auth_tag = ciphertext + plaintext_pad_len;
10695 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10696 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10698 /* Validate obuf */
10699 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10701 tdata->ciphertext.data,
10702 tdata->ciphertext.len,
10703 "Ciphertext data not as expected");
10705 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10707 tdata->auth_tag.data,
10708 tdata->auth_tag.len,
10709 "Generated auth tag not as expected");
10716 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10718 return test_authenticated_encryption_sessionless(
10723 test_authenticated_decryption_sessionless(
10724 const struct aead_test_data *tdata)
10726 struct crypto_testsuite_params *ts_params = &testsuite_params;
10727 struct crypto_unittest_params *ut_params = &unittest_params;
10730 uint8_t *plaintext;
10731 uint8_t key[tdata->key.len + 1];
10732 struct rte_cryptodev_info dev_info;
10734 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10735 uint64_t feat_flags = dev_info.feature_flags;
10737 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10738 printf("Device doesn't support Sessionless ops.\n");
10739 return TEST_SKIPPED;
10742 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10743 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10744 printf("Device doesn't support RAW data-path APIs.\n");
10745 return TEST_SKIPPED;
10748 /* not supported with CPU crypto */
10749 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10750 return TEST_SKIPPED;
10752 /* Verify the capabilities */
10753 struct rte_cryptodev_sym_capability_idx cap_idx;
10754 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10755 cap_idx.algo.aead = tdata->algo;
10756 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10758 return TEST_SKIPPED;
10760 /* alloc mbuf and set payload */
10761 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10763 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10764 rte_pktmbuf_tailroom(ut_params->ibuf));
10766 /* Create AEAD operation */
10767 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10771 /* Create AEAD xform */
10772 memcpy(key, tdata->key.data, tdata->key.len);
10773 retval = create_aead_xform(ut_params->op,
10775 RTE_CRYPTO_AEAD_OP_DECRYPT,
10776 key, tdata->key.len,
10777 tdata->aad.len, tdata->auth_tag.len,
10782 ut_params->op->sym->m_src = ut_params->ibuf;
10784 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10785 RTE_CRYPTO_OP_SESSIONLESS,
10786 "crypto op session type not sessionless");
10788 /* Process crypto operation */
10789 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10790 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10791 ut_params->op, 0, 0, 0, 0);
10793 TEST_ASSERT_NOT_NULL(process_crypto_request(
10794 ts_params->valid_devs[0], ut_params->op),
10795 "failed to process sym crypto op");
10797 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10799 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10800 "crypto op status not success");
10802 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10803 ut_params->op->sym->cipher.data.offset);
10805 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10807 /* Validate obuf */
10808 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10810 tdata->plaintext.data,
10811 tdata->plaintext.len,
10812 "Plaintext data not as expected");
10814 TEST_ASSERT_EQUAL(ut_params->op->status,
10815 RTE_CRYPTO_OP_STATUS_SUCCESS,
10816 "Authentication failed");
10821 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10823 return test_authenticated_decryption_sessionless(
10828 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10830 return test_authenticated_encryption(&ccm_test_case_128_1);
10834 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10836 return test_authenticated_encryption(&ccm_test_case_128_2);
10840 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10842 return test_authenticated_encryption(&ccm_test_case_128_3);
10846 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10848 return test_authenticated_decryption(&ccm_test_case_128_1);
10852 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10854 return test_authenticated_decryption(&ccm_test_case_128_2);
10858 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10860 return test_authenticated_decryption(&ccm_test_case_128_3);
10864 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10866 return test_authenticated_encryption(&ccm_test_case_192_1);
10870 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10872 return test_authenticated_encryption(&ccm_test_case_192_2);
10876 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10878 return test_authenticated_encryption(&ccm_test_case_192_3);
10882 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10884 return test_authenticated_decryption(&ccm_test_case_192_1);
10888 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10890 return test_authenticated_decryption(&ccm_test_case_192_2);
10894 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10896 return test_authenticated_decryption(&ccm_test_case_192_3);
10900 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10902 return test_authenticated_encryption(&ccm_test_case_256_1);
10906 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10908 return test_authenticated_encryption(&ccm_test_case_256_2);
10912 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10914 return test_authenticated_encryption(&ccm_test_case_256_3);
10918 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10920 return test_authenticated_decryption(&ccm_test_case_256_1);
10924 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10926 return test_authenticated_decryption(&ccm_test_case_256_2);
10930 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10932 return test_authenticated_decryption(&ccm_test_case_256_3);
10938 struct crypto_testsuite_params *ts_params = &testsuite_params;
10939 struct rte_cryptodev_stats stats;
10941 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10942 return TEST_SKIPPED;
10944 /* Verify the capabilities */
10945 struct rte_cryptodev_sym_capability_idx cap_idx;
10946 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10947 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10948 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10950 return TEST_SKIPPED;
10951 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10952 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10953 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10955 return TEST_SKIPPED;
10957 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10959 return TEST_SKIPPED;
10961 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10962 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10963 &stats) == -ENODEV),
10964 "rte_cryptodev_stats_get invalid dev failed");
10965 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10966 "rte_cryptodev_stats_get invalid Param failed");
10968 /* Test expected values */
10969 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10970 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10972 "rte_cryptodev_stats_get failed");
10973 TEST_ASSERT((stats.enqueued_count == 1),
10974 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10975 TEST_ASSERT((stats.dequeued_count == 1),
10976 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10977 TEST_ASSERT((stats.enqueue_err_count == 0),
10978 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10979 TEST_ASSERT((stats.dequeue_err_count == 0),
10980 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10982 /* invalid device but should ignore and not reset device stats*/
10983 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10984 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10986 "rte_cryptodev_stats_get failed");
10987 TEST_ASSERT((stats.enqueued_count == 1),
10988 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10990 /* check that a valid reset clears stats */
10991 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10992 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10994 "rte_cryptodev_stats_get failed");
10995 TEST_ASSERT((stats.enqueued_count == 0),
10996 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10997 TEST_ASSERT((stats.dequeued_count == 0),
10998 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11000 return TEST_SUCCESS;
11003 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11004 struct crypto_unittest_params *ut_params,
11005 enum rte_crypto_auth_operation op,
11006 const struct HMAC_MD5_vector *test_case)
11010 memcpy(key, test_case->key.data, test_case->key.len);
11012 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11013 ut_params->auth_xform.next = NULL;
11014 ut_params->auth_xform.auth.op = op;
11016 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11018 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11019 ut_params->auth_xform.auth.key.length = test_case->key.len;
11020 ut_params->auth_xform.auth.key.data = key;
11022 ut_params->sess = rte_cryptodev_sym_session_create(
11023 ts_params->session_mpool);
11025 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11026 ut_params->sess, &ut_params->auth_xform,
11027 ts_params->session_priv_mpool);
11029 if (ut_params->sess == NULL)
11030 return TEST_FAILED;
11032 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11034 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11035 rte_pktmbuf_tailroom(ut_params->ibuf));
11040 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11041 const struct HMAC_MD5_vector *test_case,
11042 uint8_t **plaintext)
11044 uint16_t plaintext_pad_len;
11046 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11048 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11051 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11052 plaintext_pad_len);
11053 memcpy(*plaintext, test_case->plaintext.data,
11054 test_case->plaintext.len);
11056 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11057 ut_params->ibuf, MD5_DIGEST_LEN);
11058 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11059 "no room to append digest");
11060 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11061 ut_params->ibuf, plaintext_pad_len);
11063 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11064 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11065 test_case->auth_tag.len);
11068 sym_op->auth.data.offset = 0;
11069 sym_op->auth.data.length = test_case->plaintext.len;
11071 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11072 ut_params->op->sym->m_src = ut_params->ibuf;
11078 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11080 uint16_t plaintext_pad_len;
11081 uint8_t *plaintext, *auth_tag;
11083 struct crypto_testsuite_params *ts_params = &testsuite_params;
11084 struct crypto_unittest_params *ut_params = &unittest_params;
11085 struct rte_cryptodev_info dev_info;
11087 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11088 uint64_t feat_flags = dev_info.feature_flags;
11090 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11091 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11092 printf("Device doesn't support RAW data-path APIs.\n");
11093 return TEST_SKIPPED;
11096 /* Verify the capabilities */
11097 struct rte_cryptodev_sym_capability_idx cap_idx;
11098 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11099 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11100 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11102 return TEST_SKIPPED;
11104 if (MD5_HMAC_create_session(ts_params, ut_params,
11105 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11106 return TEST_FAILED;
11108 /* Generate Crypto op data structure */
11109 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11110 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11111 TEST_ASSERT_NOT_NULL(ut_params->op,
11112 "Failed to allocate symmetric crypto operation struct");
11114 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11117 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11118 return TEST_FAILED;
11120 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11121 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11123 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11124 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11125 ut_params->op, 0, 1, 0, 0);
11127 TEST_ASSERT_NOT_NULL(
11128 process_crypto_request(ts_params->valid_devs[0],
11130 "failed to process sym crypto op");
11132 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11133 "crypto op processing failed");
11135 if (ut_params->op->sym->m_dst) {
11136 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11137 uint8_t *, plaintext_pad_len);
11139 auth_tag = plaintext + plaintext_pad_len;
11142 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11144 test_case->auth_tag.data,
11145 test_case->auth_tag.len,
11146 "HMAC_MD5 generated tag not as expected");
11148 return TEST_SUCCESS;
11152 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11154 uint8_t *plaintext;
11156 struct crypto_testsuite_params *ts_params = &testsuite_params;
11157 struct crypto_unittest_params *ut_params = &unittest_params;
11158 struct rte_cryptodev_info dev_info;
11160 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11161 uint64_t feat_flags = dev_info.feature_flags;
11163 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11164 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11165 printf("Device doesn't support RAW data-path APIs.\n");
11166 return TEST_SKIPPED;
11169 /* Verify the capabilities */
11170 struct rte_cryptodev_sym_capability_idx cap_idx;
11171 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11172 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11173 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11175 return TEST_SKIPPED;
11177 if (MD5_HMAC_create_session(ts_params, ut_params,
11178 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11179 return TEST_FAILED;
11182 /* Generate Crypto op data structure */
11183 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11184 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11185 TEST_ASSERT_NOT_NULL(ut_params->op,
11186 "Failed to allocate symmetric crypto operation struct");
11188 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11189 return TEST_FAILED;
11191 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11192 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11194 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11195 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11196 ut_params->op, 0, 1, 0, 0);
11198 TEST_ASSERT_NOT_NULL(
11199 process_crypto_request(ts_params->valid_devs[0],
11201 "failed to process sym crypto op");
11203 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11204 "HMAC_MD5 crypto op processing failed");
11206 return TEST_SUCCESS;
11210 test_MD5_HMAC_generate_case_1(void)
11212 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11216 test_MD5_HMAC_verify_case_1(void)
11218 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11222 test_MD5_HMAC_generate_case_2(void)
11224 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11228 test_MD5_HMAC_verify_case_2(void)
11230 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11234 test_multi_session(void)
11236 struct crypto_testsuite_params *ts_params = &testsuite_params;
11237 struct crypto_unittest_params *ut_params = &unittest_params;
11239 struct rte_cryptodev_info dev_info;
11240 struct rte_cryptodev_sym_session **sessions;
11244 /* Verify the capabilities */
11245 struct rte_cryptodev_sym_capability_idx cap_idx;
11246 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11247 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11248 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11250 return TEST_SKIPPED;
11251 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11252 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11253 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11255 return TEST_SKIPPED;
11257 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11258 aes_cbc_key, hmac_sha512_key);
11261 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11263 sessions = rte_malloc(NULL,
11264 sizeof(struct rte_cryptodev_sym_session *) *
11265 (MAX_NB_SESSIONS + 1), 0);
11267 /* Create multiple crypto sessions*/
11268 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11270 sessions[i] = rte_cryptodev_sym_session_create(
11271 ts_params->session_mpool);
11273 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11274 sessions[i], &ut_params->auth_xform,
11275 ts_params->session_priv_mpool);
11276 TEST_ASSERT_NOT_NULL(sessions[i],
11277 "Session creation failed at session number %u",
11280 /* Attempt to send a request on each session */
11281 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11285 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11286 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11288 "Failed to perform decrypt on request number %u.", i);
11289 /* free crypto operation structure */
11291 rte_crypto_op_free(ut_params->op);
11294 * free mbuf - both obuf and ibuf are usually the same,
11295 * so check if they point at the same address is necessary,
11296 * to avoid freeing the mbuf twice.
11298 if (ut_params->obuf) {
11299 rte_pktmbuf_free(ut_params->obuf);
11300 if (ut_params->ibuf == ut_params->obuf)
11301 ut_params->ibuf = 0;
11302 ut_params->obuf = 0;
11304 if (ut_params->ibuf) {
11305 rte_pktmbuf_free(ut_params->ibuf);
11306 ut_params->ibuf = 0;
11310 sessions[i] = NULL;
11311 /* Next session create should fail */
11312 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11313 sessions[i], &ut_params->auth_xform,
11314 ts_params->session_priv_mpool);
11315 TEST_ASSERT_NULL(sessions[i],
11316 "Session creation succeeded unexpectedly!");
11318 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11319 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11321 rte_cryptodev_sym_session_free(sessions[i]);
11324 rte_free(sessions);
11326 return TEST_SUCCESS;
11329 struct multi_session_params {
11330 struct crypto_unittest_params ut_params;
11331 uint8_t *cipher_key;
11333 const uint8_t *cipher;
11334 const uint8_t *digest;
11338 #define MB_SESSION_NUMBER 3
11341 test_multi_session_random_usage(void)
11343 struct crypto_testsuite_params *ts_params = &testsuite_params;
11344 struct rte_cryptodev_info dev_info;
11345 struct rte_cryptodev_sym_session **sessions;
11347 struct multi_session_params ut_paramz[] = {
11350 .cipher_key = ms_aes_cbc_key0,
11351 .hmac_key = ms_hmac_key0,
11352 .cipher = ms_aes_cbc_cipher0,
11353 .digest = ms_hmac_digest0,
11354 .iv = ms_aes_cbc_iv0
11357 .cipher_key = ms_aes_cbc_key1,
11358 .hmac_key = ms_hmac_key1,
11359 .cipher = ms_aes_cbc_cipher1,
11360 .digest = ms_hmac_digest1,
11361 .iv = ms_aes_cbc_iv1
11364 .cipher_key = ms_aes_cbc_key2,
11365 .hmac_key = ms_hmac_key2,
11366 .cipher = ms_aes_cbc_cipher2,
11367 .digest = ms_hmac_digest2,
11368 .iv = ms_aes_cbc_iv2
11373 /* Verify the capabilities */
11374 struct rte_cryptodev_sym_capability_idx cap_idx;
11375 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11376 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11377 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11379 return TEST_SKIPPED;
11380 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11381 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11382 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11384 return TEST_SKIPPED;
11386 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11388 sessions = rte_malloc(NULL,
11389 (sizeof(struct rte_cryptodev_sym_session *)
11390 * MAX_NB_SESSIONS) + 1, 0);
11392 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11393 sessions[i] = rte_cryptodev_sym_session_create(
11394 ts_params->session_mpool);
11396 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11397 sizeof(struct crypto_unittest_params));
11399 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11400 &ut_paramz[i].ut_params,
11401 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11403 /* Create multiple crypto sessions*/
11404 rte_cryptodev_sym_session_init(
11405 ts_params->valid_devs[0],
11407 &ut_paramz[i].ut_params.auth_xform,
11408 ts_params->session_priv_mpool);
11410 TEST_ASSERT_NOT_NULL(sessions[i],
11411 "Session creation failed at session number %u",
11417 for (i = 0; i < 40000; i++) {
11419 j = rand() % MB_SESSION_NUMBER;
11421 TEST_ASSERT_SUCCESS(
11422 test_AES_CBC_HMAC_SHA512_decrypt_perform(
11424 &ut_paramz[j].ut_params,
11425 ts_params, ut_paramz[j].cipher,
11426 ut_paramz[j].digest,
11428 "Failed to perform decrypt on request number %u.", i);
11430 if (ut_paramz[j].ut_params.op)
11431 rte_crypto_op_free(ut_paramz[j].ut_params.op);
11434 * free mbuf - both obuf and ibuf are usually the same,
11435 * so check if they point at the same address is necessary,
11436 * to avoid freeing the mbuf twice.
11438 if (ut_paramz[j].ut_params.obuf) {
11439 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11440 if (ut_paramz[j].ut_params.ibuf
11441 == ut_paramz[j].ut_params.obuf)
11442 ut_paramz[j].ut_params.ibuf = 0;
11443 ut_paramz[j].ut_params.obuf = 0;
11445 if (ut_paramz[j].ut_params.ibuf) {
11446 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11447 ut_paramz[j].ut_params.ibuf = 0;
11451 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11452 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11454 rte_cryptodev_sym_session_free(sessions[i]);
11457 rte_free(sessions);
11459 return TEST_SUCCESS;
11462 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11463 0xab, 0xab, 0xab, 0xab,
11464 0xab, 0xab, 0xab, 0xab,
11465 0xab, 0xab, 0xab, 0xab};
11468 test_null_invalid_operation(void)
11470 struct crypto_testsuite_params *ts_params = &testsuite_params;
11471 struct crypto_unittest_params *ut_params = &unittest_params;
11474 /* This test is for NULL PMD only */
11475 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11476 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11477 return TEST_SKIPPED;
11479 /* Setup Cipher Parameters */
11480 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11481 ut_params->cipher_xform.next = NULL;
11483 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11484 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11486 ut_params->sess = rte_cryptodev_sym_session_create(
11487 ts_params->session_mpool);
11489 /* Create Crypto session*/
11490 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11491 ut_params->sess, &ut_params->cipher_xform,
11492 ts_params->session_priv_mpool);
11493 TEST_ASSERT(ret < 0,
11494 "Session creation succeeded unexpectedly");
11497 /* Setup HMAC Parameters */
11498 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11499 ut_params->auth_xform.next = NULL;
11501 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11502 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11504 ut_params->sess = rte_cryptodev_sym_session_create(
11505 ts_params->session_mpool);
11507 /* Create Crypto session*/
11508 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11509 ut_params->sess, &ut_params->auth_xform,
11510 ts_params->session_priv_mpool);
11511 TEST_ASSERT(ret < 0,
11512 "Session creation succeeded unexpectedly");
11514 return TEST_SUCCESS;
11518 #define NULL_BURST_LENGTH (32)
11521 test_null_burst_operation(void)
11523 struct crypto_testsuite_params *ts_params = &testsuite_params;
11524 struct crypto_unittest_params *ut_params = &unittest_params;
11526 unsigned i, burst_len = NULL_BURST_LENGTH;
11528 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11529 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11531 /* This test is for NULL PMD only */
11532 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11533 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11534 return TEST_SKIPPED;
11536 /* Setup Cipher Parameters */
11537 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11538 ut_params->cipher_xform.next = &ut_params->auth_xform;
11540 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11541 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11543 /* Setup HMAC Parameters */
11544 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11545 ut_params->auth_xform.next = NULL;
11547 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11548 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11550 ut_params->sess = rte_cryptodev_sym_session_create(
11551 ts_params->session_mpool);
11553 /* Create Crypto session*/
11554 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11555 ut_params->sess, &ut_params->cipher_xform,
11556 ts_params->session_priv_mpool);
11557 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11559 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11560 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11561 burst_len, "failed to generate burst of crypto ops");
11563 /* Generate an operation for each mbuf in burst */
11564 for (i = 0; i < burst_len; i++) {
11565 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11567 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11569 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11573 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11575 burst[i]->sym->m_src = m;
11578 /* Process crypto operation */
11579 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11580 0, burst, burst_len),
11582 "Error enqueuing burst");
11584 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11585 0, burst_dequeued, burst_len),
11587 "Error dequeuing burst");
11590 for (i = 0; i < burst_len; i++) {
11592 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11593 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11595 "data not as expected");
11597 rte_pktmbuf_free(burst[i]->sym->m_src);
11598 rte_crypto_op_free(burst[i]);
11601 return TEST_SUCCESS;
11605 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11606 uint16_t nb_ops, void *user_param)
11608 RTE_SET_USED(dev_id);
11609 RTE_SET_USED(qp_id);
11611 RTE_SET_USED(user_param);
11613 printf("crypto enqueue callback called\n");
11618 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11619 uint16_t nb_ops, void *user_param)
11621 RTE_SET_USED(dev_id);
11622 RTE_SET_USED(qp_id);
11624 RTE_SET_USED(user_param);
11626 printf("crypto dequeue callback called\n");
11631 * Thread using enqueue/dequeue callback with RCU.
11634 test_enqdeq_callback_thread(void *arg)
11637 /* DP thread calls rte_cryptodev_enqueue_burst()/
11638 * rte_cryptodev_dequeue_burst() and invokes callback.
11640 test_null_burst_operation();
11645 test_enq_callback_setup(void)
11647 struct crypto_testsuite_params *ts_params = &testsuite_params;
11648 struct rte_cryptodev_info dev_info;
11649 struct rte_cryptodev_qp_conf qp_conf = {
11650 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11653 struct rte_cryptodev_cb *cb;
11654 uint16_t qp_id = 0;
11656 /* Stop the device in case it's started so it can be configured */
11657 rte_cryptodev_stop(ts_params->valid_devs[0]);
11659 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11661 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11663 "Failed to configure cryptodev %u",
11664 ts_params->valid_devs[0]);
11666 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11667 qp_conf.mp_session = ts_params->session_mpool;
11668 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11670 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11671 ts_params->valid_devs[0], qp_id, &qp_conf,
11672 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11674 "rte_cryptodev_queue_pair_setup: num_inflights "
11675 "%u on qp %u on cryptodev %u",
11676 qp_conf.nb_descriptors, qp_id,
11677 ts_params->valid_devs[0]);
11679 /* Test with invalid crypto device */
11680 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11681 qp_id, test_enq_callback, NULL);
11682 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11683 "cryptodev %u did not fail",
11684 qp_id, RTE_CRYPTO_MAX_DEVS);
11686 /* Test with invalid queue pair */
11687 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11688 dev_info.max_nb_queue_pairs + 1,
11689 test_enq_callback, NULL);
11690 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11691 "cryptodev %u did not fail",
11692 dev_info.max_nb_queue_pairs + 1,
11693 ts_params->valid_devs[0]);
11695 /* Test with NULL callback */
11696 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11697 qp_id, NULL, NULL);
11698 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11699 "cryptodev %u did not fail",
11700 qp_id, ts_params->valid_devs[0]);
11702 /* Test with valid configuration */
11703 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11704 qp_id, test_enq_callback, NULL);
11705 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11706 "qp %u on cryptodev %u",
11707 qp_id, ts_params->valid_devs[0]);
11709 rte_cryptodev_start(ts_params->valid_devs[0]);
11711 /* Launch a thread */
11712 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11713 rte_get_next_lcore(-1, 1, 0));
11715 /* Wait until reader exited. */
11716 rte_eal_mp_wait_lcore();
11718 /* Test with invalid crypto device */
11719 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11720 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11721 "Expected call to fail as crypto device is invalid");
11723 /* Test with invalid queue pair */
11724 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11725 ts_params->valid_devs[0],
11726 dev_info.max_nb_queue_pairs + 1, cb),
11727 "Expected call to fail as queue pair is invalid");
11729 /* Test with NULL callback */
11730 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11731 ts_params->valid_devs[0], qp_id, NULL),
11732 "Expected call to fail as callback is NULL");
11734 /* Test with valid configuration */
11735 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11736 ts_params->valid_devs[0], qp_id, cb),
11737 "Failed test to remove callback on "
11738 "qp %u on cryptodev %u",
11739 qp_id, ts_params->valid_devs[0]);
11741 return TEST_SUCCESS;
11745 test_deq_callback_setup(void)
11747 struct crypto_testsuite_params *ts_params = &testsuite_params;
11748 struct rte_cryptodev_info dev_info;
11749 struct rte_cryptodev_qp_conf qp_conf = {
11750 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11753 struct rte_cryptodev_cb *cb;
11754 uint16_t qp_id = 0;
11756 /* Stop the device in case it's started so it can be configured */
11757 rte_cryptodev_stop(ts_params->valid_devs[0]);
11759 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11761 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11763 "Failed to configure cryptodev %u",
11764 ts_params->valid_devs[0]);
11766 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11767 qp_conf.mp_session = ts_params->session_mpool;
11768 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11770 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11771 ts_params->valid_devs[0], qp_id, &qp_conf,
11772 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11774 "rte_cryptodev_queue_pair_setup: num_inflights "
11775 "%u on qp %u on cryptodev %u",
11776 qp_conf.nb_descriptors, qp_id,
11777 ts_params->valid_devs[0]);
11779 /* Test with invalid crypto device */
11780 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11781 qp_id, test_deq_callback, NULL);
11782 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11783 "cryptodev %u did not fail",
11784 qp_id, RTE_CRYPTO_MAX_DEVS);
11786 /* Test with invalid queue pair */
11787 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11788 dev_info.max_nb_queue_pairs + 1,
11789 test_deq_callback, NULL);
11790 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11791 "cryptodev %u did not fail",
11792 dev_info.max_nb_queue_pairs + 1,
11793 ts_params->valid_devs[0]);
11795 /* Test with NULL callback */
11796 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11797 qp_id, NULL, NULL);
11798 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11799 "cryptodev %u did not fail",
11800 qp_id, ts_params->valid_devs[0]);
11802 /* Test with valid configuration */
11803 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11804 qp_id, test_deq_callback, NULL);
11805 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11806 "qp %u on cryptodev %u",
11807 qp_id, ts_params->valid_devs[0]);
11809 rte_cryptodev_start(ts_params->valid_devs[0]);
11811 /* Launch a thread */
11812 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11813 rte_get_next_lcore(-1, 1, 0));
11815 /* Wait until reader exited. */
11816 rte_eal_mp_wait_lcore();
11818 /* Test with invalid crypto device */
11819 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11820 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11821 "Expected call to fail as crypto device is invalid");
11823 /* Test with invalid queue pair */
11824 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11825 ts_params->valid_devs[0],
11826 dev_info.max_nb_queue_pairs + 1, cb),
11827 "Expected call to fail as queue pair is invalid");
11829 /* Test with NULL callback */
11830 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11831 ts_params->valid_devs[0], qp_id, NULL),
11832 "Expected call to fail as callback is NULL");
11834 /* Test with valid configuration */
11835 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11836 ts_params->valid_devs[0], qp_id, cb),
11837 "Failed test to remove callback on "
11838 "qp %u on cryptodev %u",
11839 qp_id, ts_params->valid_devs[0]);
11841 return TEST_SUCCESS;
11845 generate_gmac_large_plaintext(uint8_t *data)
11849 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11850 memcpy(&data[i], &data[0], 32);
11854 create_gmac_operation(enum rte_crypto_auth_operation op,
11855 const struct gmac_test_data *tdata)
11857 struct crypto_testsuite_params *ts_params = &testsuite_params;
11858 struct crypto_unittest_params *ut_params = &unittest_params;
11859 struct rte_crypto_sym_op *sym_op;
11861 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11863 /* Generate Crypto op data structure */
11864 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11865 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11866 TEST_ASSERT_NOT_NULL(ut_params->op,
11867 "Failed to allocate symmetric crypto operation struct");
11869 sym_op = ut_params->op->sym;
11871 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11872 ut_params->ibuf, tdata->gmac_tag.len);
11873 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11874 "no room to append digest");
11876 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11877 ut_params->ibuf, plaintext_pad_len);
11879 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11880 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11881 tdata->gmac_tag.len);
11882 debug_hexdump(stdout, "digest:",
11883 sym_op->auth.digest.data,
11884 tdata->gmac_tag.len);
11887 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11888 uint8_t *, IV_OFFSET);
11890 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11892 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11894 sym_op->cipher.data.length = 0;
11895 sym_op->cipher.data.offset = 0;
11897 sym_op->auth.data.offset = 0;
11898 sym_op->auth.data.length = tdata->plaintext.len;
11904 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11905 const struct gmac_test_data *tdata,
11906 void *digest_mem, uint64_t digest_phys)
11908 struct crypto_testsuite_params *ts_params = &testsuite_params;
11909 struct crypto_unittest_params *ut_params = &unittest_params;
11910 struct rte_crypto_sym_op *sym_op;
11912 /* Generate Crypto op data structure */
11913 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11914 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11915 TEST_ASSERT_NOT_NULL(ut_params->op,
11916 "Failed to allocate symmetric crypto operation struct");
11918 sym_op = ut_params->op->sym;
11920 sym_op->auth.digest.data = digest_mem;
11921 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11922 "no room to append digest");
11924 sym_op->auth.digest.phys_addr = digest_phys;
11926 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11927 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11928 tdata->gmac_tag.len);
11929 debug_hexdump(stdout, "digest:",
11930 sym_op->auth.digest.data,
11931 tdata->gmac_tag.len);
11934 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11935 uint8_t *, IV_OFFSET);
11937 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11939 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11941 sym_op->cipher.data.length = 0;
11942 sym_op->cipher.data.offset = 0;
11944 sym_op->auth.data.offset = 0;
11945 sym_op->auth.data.length = tdata->plaintext.len;
11950 static int create_gmac_session(uint8_t dev_id,
11951 const struct gmac_test_data *tdata,
11952 enum rte_crypto_auth_operation auth_op)
11954 uint8_t auth_key[tdata->key.len];
11956 struct crypto_testsuite_params *ts_params = &testsuite_params;
11957 struct crypto_unittest_params *ut_params = &unittest_params;
11959 memcpy(auth_key, tdata->key.data, tdata->key.len);
11961 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11962 ut_params->auth_xform.next = NULL;
11964 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11965 ut_params->auth_xform.auth.op = auth_op;
11966 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11967 ut_params->auth_xform.auth.key.length = tdata->key.len;
11968 ut_params->auth_xform.auth.key.data = auth_key;
11969 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11970 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11973 ut_params->sess = rte_cryptodev_sym_session_create(
11974 ts_params->session_mpool);
11976 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11977 &ut_params->auth_xform,
11978 ts_params->session_priv_mpool);
11980 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11986 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11988 struct crypto_testsuite_params *ts_params = &testsuite_params;
11989 struct crypto_unittest_params *ut_params = &unittest_params;
11990 struct rte_cryptodev_info dev_info;
11992 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11993 uint64_t feat_flags = dev_info.feature_flags;
11995 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11996 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11997 printf("Device doesn't support RAW data-path APIs.\n");
11998 return TEST_SKIPPED;
12003 uint8_t *auth_tag, *plaintext;
12004 uint16_t plaintext_pad_len;
12006 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12007 "No GMAC length in the source data");
12009 /* Verify the capabilities */
12010 struct rte_cryptodev_sym_capability_idx cap_idx;
12011 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12012 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12013 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12015 return TEST_SKIPPED;
12017 retval = create_gmac_session(ts_params->valid_devs[0],
12018 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12023 if (tdata->plaintext.len > MBUF_SIZE)
12024 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12026 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12027 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12028 "Failed to allocate input buffer in mempool");
12030 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12031 rte_pktmbuf_tailroom(ut_params->ibuf));
12033 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12035 * Runtime generate the large plain text instead of use hard code
12036 * plain text vector. It is done to avoid create huge source file
12037 * with the test vector.
12039 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12040 generate_gmac_large_plaintext(tdata->plaintext.data);
12042 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12043 plaintext_pad_len);
12044 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12046 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12047 debug_hexdump(stdout, "plaintext:", plaintext,
12048 tdata->plaintext.len);
12050 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12056 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12058 ut_params->op->sym->m_src = ut_params->ibuf;
12060 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12061 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12063 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12064 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12065 ut_params->op, 0, 1, 0, 0);
12067 TEST_ASSERT_NOT_NULL(
12068 process_crypto_request(ts_params->valid_devs[0],
12069 ut_params->op), "failed to process sym crypto op");
12071 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12072 "crypto op processing failed");
12074 if (ut_params->op->sym->m_dst) {
12075 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12076 uint8_t *, plaintext_pad_len);
12078 auth_tag = plaintext + plaintext_pad_len;
12081 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12083 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12085 tdata->gmac_tag.data,
12086 tdata->gmac_tag.len,
12087 "GMAC Generated auth tag not as expected");
12093 test_AES_GMAC_authentication_test_case_1(void)
12095 return test_AES_GMAC_authentication(&gmac_test_case_1);
12099 test_AES_GMAC_authentication_test_case_2(void)
12101 return test_AES_GMAC_authentication(&gmac_test_case_2);
12105 test_AES_GMAC_authentication_test_case_3(void)
12107 return test_AES_GMAC_authentication(&gmac_test_case_3);
12111 test_AES_GMAC_authentication_test_case_4(void)
12113 return test_AES_GMAC_authentication(&gmac_test_case_4);
12117 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12119 struct crypto_testsuite_params *ts_params = &testsuite_params;
12120 struct crypto_unittest_params *ut_params = &unittest_params;
12122 uint32_t plaintext_pad_len;
12123 uint8_t *plaintext;
12124 struct rte_cryptodev_info dev_info;
12126 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12127 uint64_t feat_flags = dev_info.feature_flags;
12129 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12130 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12131 printf("Device doesn't support RAW data-path APIs.\n");
12132 return TEST_SKIPPED;
12135 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12136 "No GMAC length in the source data");
12138 /* Verify the capabilities */
12139 struct rte_cryptodev_sym_capability_idx cap_idx;
12140 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12141 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12142 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12144 return TEST_SKIPPED;
12146 retval = create_gmac_session(ts_params->valid_devs[0],
12147 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12152 if (tdata->plaintext.len > MBUF_SIZE)
12153 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12155 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12156 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12157 "Failed to allocate input buffer in mempool");
12159 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12160 rte_pktmbuf_tailroom(ut_params->ibuf));
12162 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12165 * Runtime generate the large plain text instead of use hard code
12166 * plain text vector. It is done to avoid create huge source file
12167 * with the test vector.
12169 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12170 generate_gmac_large_plaintext(tdata->plaintext.data);
12172 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12173 plaintext_pad_len);
12174 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12176 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12177 debug_hexdump(stdout, "plaintext:", plaintext,
12178 tdata->plaintext.len);
12180 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
12186 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12188 ut_params->op->sym->m_src = ut_params->ibuf;
12190 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12191 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12193 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12194 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12195 ut_params->op, 0, 1, 0, 0);
12197 TEST_ASSERT_NOT_NULL(
12198 process_crypto_request(ts_params->valid_devs[0],
12199 ut_params->op), "failed to process sym crypto op");
12201 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12202 "crypto op processing failed");
12209 test_AES_GMAC_authentication_verify_test_case_1(void)
12211 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12215 test_AES_GMAC_authentication_verify_test_case_2(void)
12217 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12221 test_AES_GMAC_authentication_verify_test_case_3(void)
12223 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12227 test_AES_GMAC_authentication_verify_test_case_4(void)
12229 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12233 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12236 struct crypto_testsuite_params *ts_params = &testsuite_params;
12237 struct crypto_unittest_params *ut_params = &unittest_params;
12238 struct rte_cryptodev_info dev_info;
12239 uint64_t feature_flags;
12240 unsigned int trn_data = 0;
12241 void *digest_mem = NULL;
12243 unsigned int to_trn = 0;
12244 struct rte_mbuf *buf = NULL;
12245 uint8_t *auth_tag, *plaintext;
12248 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12249 "No GMAC length in the source data");
12251 /* Verify the capabilities */
12252 struct rte_cryptodev_sym_capability_idx cap_idx;
12253 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12254 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12255 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12257 return TEST_SKIPPED;
12259 /* Check for any input SGL support */
12260 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12261 feature_flags = dev_info.feature_flags;
12263 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12264 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12265 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12266 return TEST_SKIPPED;
12268 if (fragsz > tdata->plaintext.len)
12269 fragsz = tdata->plaintext.len;
12271 uint16_t plaintext_len = fragsz;
12273 retval = create_gmac_session(ts_params->valid_devs[0],
12274 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12279 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12280 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12281 "Failed to allocate input buffer in mempool");
12283 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12284 rte_pktmbuf_tailroom(ut_params->ibuf));
12286 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12288 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12290 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12292 trn_data += plaintext_len;
12294 buf = ut_params->ibuf;
12297 * Loop until no more fragments
12300 while (trn_data < tdata->plaintext.len) {
12302 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12303 (tdata->plaintext.len - trn_data) : fragsz;
12305 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12308 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12309 rte_pktmbuf_tailroom(buf));
12311 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12314 memcpy(plaintext, tdata->plaintext.data + trn_data,
12316 trn_data += to_trn;
12317 if (trn_data == tdata->plaintext.len)
12318 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12319 tdata->gmac_tag.len);
12321 ut_params->ibuf->nb_segs = segs;
12324 * Place digest at the end of the last buffer
12326 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12329 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12330 + tdata->gmac_tag.len);
12331 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12332 tdata->plaintext.len);
12335 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12336 tdata, digest_mem, digest_phys);
12341 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12343 ut_params->op->sym->m_src = ut_params->ibuf;
12345 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12346 return TEST_SKIPPED;
12348 TEST_ASSERT_NOT_NULL(
12349 process_crypto_request(ts_params->valid_devs[0],
12350 ut_params->op), "failed to process sym crypto op");
12352 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12353 "crypto op processing failed");
12355 auth_tag = digest_mem;
12356 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12357 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12359 tdata->gmac_tag.data,
12360 tdata->gmac_tag.len,
12361 "GMAC Generated auth tag not as expected");
12366 /* Segment size not multiple of block size (16B) */
12368 test_AES_GMAC_authentication_SGL_40B(void)
12370 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12374 test_AES_GMAC_authentication_SGL_80B(void)
12376 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12380 test_AES_GMAC_authentication_SGL_2048B(void)
12382 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12385 /* Segment size not multiple of block size (16B) */
12387 test_AES_GMAC_authentication_SGL_2047B(void)
12389 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12392 struct test_crypto_vector {
12393 enum rte_crypto_cipher_algorithm crypto_algo;
12394 unsigned int cipher_offset;
12395 unsigned int cipher_len;
12408 const uint8_t *data;
12413 const uint8_t *data;
12417 enum rte_crypto_auth_algorithm auth_algo;
12418 unsigned int auth_offset;
12426 const uint8_t *data;
12436 static const struct test_crypto_vector
12437 hmac_sha1_test_crypto_vector = {
12438 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12440 .data = plaintext_hash,
12445 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12446 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12447 0xDE, 0xF4, 0xDE, 0xAD
12453 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12454 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12455 0x3F, 0x91, 0x64, 0x59
12461 static const struct test_crypto_vector
12462 aes128_gmac_test_vector = {
12463 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12465 .data = plaintext_hash,
12470 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12471 0x08, 0x09, 0x0A, 0x0B
12477 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12478 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12484 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12485 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12491 static const struct test_crypto_vector
12492 aes128cbc_hmac_sha1_test_vector = {
12493 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12494 .cipher_offset = 0,
12498 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12499 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12505 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12506 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12511 .data = plaintext_hash,
12515 .data = ciphertext512_aes128cbc,
12518 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12522 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12523 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12524 0xDE, 0xF4, 0xDE, 0xAD
12530 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12531 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12532 0x18, 0x8C, 0x1D, 0x32
12538 static const struct test_crypto_vector
12539 aes128cbc_hmac_sha1_aad_test_vector = {
12540 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12541 .cipher_offset = 8,
12545 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12546 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12552 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12553 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12558 .data = plaintext_hash,
12562 .data = ciphertext512_aes128cbc_aad,
12565 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12569 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12570 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12571 0xDE, 0xF4, 0xDE, 0xAD
12577 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12578 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12579 0x62, 0x0F, 0xFB, 0x10
12586 data_corruption(uint8_t *data)
12592 tag_corruption(uint8_t *data, unsigned int tag_offset)
12594 data[tag_offset] += 1;
12598 create_auth_session(struct crypto_unittest_params *ut_params,
12600 const struct test_crypto_vector *reference,
12601 enum rte_crypto_auth_operation auth_op)
12603 struct crypto_testsuite_params *ts_params = &testsuite_params;
12604 uint8_t auth_key[reference->auth_key.len + 1];
12606 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12608 /* Setup Authentication Parameters */
12609 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12610 ut_params->auth_xform.auth.op = auth_op;
12611 ut_params->auth_xform.next = NULL;
12612 ut_params->auth_xform.auth.algo = reference->auth_algo;
12613 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12614 ut_params->auth_xform.auth.key.data = auth_key;
12615 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12617 /* Create Crypto session*/
12618 ut_params->sess = rte_cryptodev_sym_session_create(
12619 ts_params->session_mpool);
12621 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12622 &ut_params->auth_xform,
12623 ts_params->session_priv_mpool);
12625 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12631 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12633 const struct test_crypto_vector *reference,
12634 enum rte_crypto_auth_operation auth_op,
12635 enum rte_crypto_cipher_operation cipher_op)
12637 struct crypto_testsuite_params *ts_params = &testsuite_params;
12638 uint8_t cipher_key[reference->cipher_key.len + 1];
12639 uint8_t auth_key[reference->auth_key.len + 1];
12641 memcpy(cipher_key, reference->cipher_key.data,
12642 reference->cipher_key.len);
12643 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12645 /* Setup Authentication Parameters */
12646 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12647 ut_params->auth_xform.auth.op = auth_op;
12648 ut_params->auth_xform.auth.algo = reference->auth_algo;
12649 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12650 ut_params->auth_xform.auth.key.data = auth_key;
12651 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12653 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12654 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12655 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12657 ut_params->auth_xform.next = &ut_params->cipher_xform;
12659 /* Setup Cipher Parameters */
12660 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12661 ut_params->cipher_xform.next = NULL;
12662 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12663 ut_params->cipher_xform.cipher.op = cipher_op;
12664 ut_params->cipher_xform.cipher.key.data = cipher_key;
12665 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12666 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12667 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12670 /* Create Crypto session*/
12671 ut_params->sess = rte_cryptodev_sym_session_create(
12672 ts_params->session_mpool);
12674 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12675 &ut_params->auth_xform,
12676 ts_params->session_priv_mpool);
12678 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12684 create_auth_operation(struct crypto_testsuite_params *ts_params,
12685 struct crypto_unittest_params *ut_params,
12686 const struct test_crypto_vector *reference,
12687 unsigned int auth_generate)
12689 /* Generate Crypto op data structure */
12690 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12691 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12692 TEST_ASSERT_NOT_NULL(ut_params->op,
12693 "Failed to allocate pktmbuf offload");
12695 /* Set crypto operation data parameters */
12696 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12698 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12700 /* set crypto operation source mbuf */
12701 sym_op->m_src = ut_params->ibuf;
12704 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12705 ut_params->ibuf, reference->digest.len);
12707 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12708 "no room to append auth tag");
12710 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12711 ut_params->ibuf, reference->plaintext.len);
12714 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12716 memcpy(sym_op->auth.digest.data,
12717 reference->digest.data,
12718 reference->digest.len);
12720 debug_hexdump(stdout, "digest:",
12721 sym_op->auth.digest.data,
12722 reference->digest.len);
12724 sym_op->auth.data.length = reference->plaintext.len;
12725 sym_op->auth.data.offset = 0;
12731 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12732 struct crypto_unittest_params *ut_params,
12733 const struct test_crypto_vector *reference,
12734 unsigned int auth_generate)
12736 /* Generate Crypto op data structure */
12737 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12738 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12739 TEST_ASSERT_NOT_NULL(ut_params->op,
12740 "Failed to allocate pktmbuf offload");
12742 /* Set crypto operation data parameters */
12743 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12745 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12747 /* set crypto operation source mbuf */
12748 sym_op->m_src = ut_params->ibuf;
12751 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12752 ut_params->ibuf, reference->digest.len);
12754 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12755 "no room to append auth tag");
12757 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12758 ut_params->ibuf, reference->ciphertext.len);
12761 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12763 memcpy(sym_op->auth.digest.data,
12764 reference->digest.data,
12765 reference->digest.len);
12767 debug_hexdump(stdout, "digest:",
12768 sym_op->auth.digest.data,
12769 reference->digest.len);
12771 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12772 reference->iv.data, reference->iv.len);
12774 sym_op->cipher.data.length = 0;
12775 sym_op->cipher.data.offset = 0;
12777 sym_op->auth.data.length = reference->plaintext.len;
12778 sym_op->auth.data.offset = 0;
12784 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12785 struct crypto_unittest_params *ut_params,
12786 const struct test_crypto_vector *reference,
12787 unsigned int auth_generate)
12789 /* Generate Crypto op data structure */
12790 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12791 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12792 TEST_ASSERT_NOT_NULL(ut_params->op,
12793 "Failed to allocate pktmbuf offload");
12795 /* Set crypto operation data parameters */
12796 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12798 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12800 /* set crypto operation source mbuf */
12801 sym_op->m_src = ut_params->ibuf;
12804 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12805 ut_params->ibuf, reference->digest.len);
12807 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12808 "no room to append auth tag");
12810 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12811 ut_params->ibuf, reference->ciphertext.len);
12814 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12816 memcpy(sym_op->auth.digest.data,
12817 reference->digest.data,
12818 reference->digest.len);
12820 debug_hexdump(stdout, "digest:",
12821 sym_op->auth.digest.data,
12822 reference->digest.len);
12824 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12825 reference->iv.data, reference->iv.len);
12827 sym_op->cipher.data.length = reference->cipher_len;
12828 sym_op->cipher.data.offset = reference->cipher_offset;
12830 sym_op->auth.data.length = reference->plaintext.len;
12831 sym_op->auth.data.offset = reference->auth_offset;
12837 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12838 struct crypto_unittest_params *ut_params,
12839 const struct test_crypto_vector *reference)
12841 return create_auth_operation(ts_params, ut_params, reference, 0);
12845 create_auth_verify_GMAC_operation(
12846 struct crypto_testsuite_params *ts_params,
12847 struct crypto_unittest_params *ut_params,
12848 const struct test_crypto_vector *reference)
12850 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12854 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12855 struct crypto_unittest_params *ut_params,
12856 const struct test_crypto_vector *reference)
12858 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12862 test_authentication_verify_fail_when_data_corruption(
12863 struct crypto_testsuite_params *ts_params,
12864 struct crypto_unittest_params *ut_params,
12865 const struct test_crypto_vector *reference,
12866 unsigned int data_corrupted)
12870 uint8_t *plaintext;
12871 struct rte_cryptodev_info dev_info;
12873 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12874 uint64_t feat_flags = dev_info.feature_flags;
12876 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12877 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12878 printf("Device doesn't support RAW data-path APIs.\n");
12879 return TEST_SKIPPED;
12882 /* Verify the capabilities */
12883 struct rte_cryptodev_sym_capability_idx cap_idx;
12884 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12885 cap_idx.algo.auth = reference->auth_algo;
12886 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12888 return TEST_SKIPPED;
12891 /* Create session */
12892 retval = create_auth_session(ut_params,
12893 ts_params->valid_devs[0],
12895 RTE_CRYPTO_AUTH_OP_VERIFY);
12899 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12900 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12901 "Failed to allocate input buffer in mempool");
12903 /* clear mbuf payload */
12904 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12905 rte_pktmbuf_tailroom(ut_params->ibuf));
12907 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12908 reference->plaintext.len);
12909 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12910 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12912 debug_hexdump(stdout, "plaintext:", plaintext,
12913 reference->plaintext.len);
12915 /* Create operation */
12916 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12921 if (data_corrupted)
12922 data_corruption(plaintext);
12924 tag_corruption(plaintext, reference->plaintext.len);
12926 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12927 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12929 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12930 RTE_CRYPTO_OP_STATUS_SUCCESS,
12931 "authentication not failed");
12932 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12933 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12934 ut_params->op, 0, 1, 0, 0);
12936 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12938 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12945 test_authentication_verify_GMAC_fail_when_corruption(
12946 struct crypto_testsuite_params *ts_params,
12947 struct crypto_unittest_params *ut_params,
12948 const struct test_crypto_vector *reference,
12949 unsigned int data_corrupted)
12952 uint8_t *plaintext;
12953 struct rte_cryptodev_info dev_info;
12955 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12956 uint64_t feat_flags = dev_info.feature_flags;
12958 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12959 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12960 printf("Device doesn't support RAW data-path APIs.\n");
12961 return TEST_SKIPPED;
12964 /* Verify the capabilities */
12965 struct rte_cryptodev_sym_capability_idx cap_idx;
12966 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12967 cap_idx.algo.auth = reference->auth_algo;
12968 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12970 return TEST_SKIPPED;
12972 /* Create session */
12973 retval = create_auth_cipher_session(ut_params,
12974 ts_params->valid_devs[0],
12976 RTE_CRYPTO_AUTH_OP_VERIFY,
12977 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12981 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12982 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12983 "Failed to allocate input buffer in mempool");
12985 /* clear mbuf payload */
12986 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12987 rte_pktmbuf_tailroom(ut_params->ibuf));
12989 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12990 reference->plaintext.len);
12991 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12992 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12994 debug_hexdump(stdout, "plaintext:", plaintext,
12995 reference->plaintext.len);
12997 /* Create operation */
12998 retval = create_auth_verify_GMAC_operation(ts_params,
13005 if (data_corrupted)
13006 data_corruption(plaintext);
13008 tag_corruption(plaintext, reference->aad.len);
13010 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13011 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13013 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13014 RTE_CRYPTO_OP_STATUS_SUCCESS,
13015 "authentication not failed");
13016 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13017 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13018 ut_params->op, 0, 1, 0, 0);
13020 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13022 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13029 test_authenticated_decryption_fail_when_corruption(
13030 struct crypto_testsuite_params *ts_params,
13031 struct crypto_unittest_params *ut_params,
13032 const struct test_crypto_vector *reference,
13033 unsigned int data_corrupted)
13037 uint8_t *ciphertext;
13038 struct rte_cryptodev_info dev_info;
13040 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13041 uint64_t feat_flags = dev_info.feature_flags;
13043 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13044 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13045 printf("Device doesn't support RAW data-path APIs.\n");
13046 return TEST_SKIPPED;
13049 /* Verify the capabilities */
13050 struct rte_cryptodev_sym_capability_idx cap_idx;
13051 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13052 cap_idx.algo.auth = reference->auth_algo;
13053 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13055 return TEST_SKIPPED;
13056 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13057 cap_idx.algo.cipher = reference->crypto_algo;
13058 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13060 return TEST_SKIPPED;
13062 /* Create session */
13063 retval = create_auth_cipher_session(ut_params,
13064 ts_params->valid_devs[0],
13066 RTE_CRYPTO_AUTH_OP_VERIFY,
13067 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13071 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13072 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13073 "Failed to allocate input buffer in mempool");
13075 /* clear mbuf payload */
13076 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13077 rte_pktmbuf_tailroom(ut_params->ibuf));
13079 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13080 reference->ciphertext.len);
13081 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13082 memcpy(ciphertext, reference->ciphertext.data,
13083 reference->ciphertext.len);
13085 /* Create operation */
13086 retval = create_cipher_auth_verify_operation(ts_params,
13093 if (data_corrupted)
13094 data_corruption(ciphertext);
13096 tag_corruption(ciphertext, reference->ciphertext.len);
13098 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13099 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13101 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13102 RTE_CRYPTO_OP_STATUS_SUCCESS,
13103 "authentication not failed");
13104 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13105 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13106 ut_params->op, 1, 1, 0, 0);
13108 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13110 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13117 test_authenticated_encrypt_with_esn(
13118 struct crypto_testsuite_params *ts_params,
13119 struct crypto_unittest_params *ut_params,
13120 const struct test_crypto_vector *reference)
13124 uint8_t *authciphertext, *plaintext, *auth_tag;
13125 uint16_t plaintext_pad_len;
13126 uint8_t cipher_key[reference->cipher_key.len + 1];
13127 uint8_t auth_key[reference->auth_key.len + 1];
13128 struct rte_cryptodev_info dev_info;
13130 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13131 uint64_t feat_flags = dev_info.feature_flags;
13133 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13134 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13135 printf("Device doesn't support RAW data-path APIs.\n");
13136 return TEST_SKIPPED;
13139 /* Verify the capabilities */
13140 struct rte_cryptodev_sym_capability_idx cap_idx;
13141 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13142 cap_idx.algo.auth = reference->auth_algo;
13143 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13145 return TEST_SKIPPED;
13146 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13147 cap_idx.algo.cipher = reference->crypto_algo;
13148 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13150 return TEST_SKIPPED;
13152 /* Create session */
13153 memcpy(cipher_key, reference->cipher_key.data,
13154 reference->cipher_key.len);
13155 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13157 /* Setup Cipher Parameters */
13158 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13159 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13160 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13161 ut_params->cipher_xform.cipher.key.data = cipher_key;
13162 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13163 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13164 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13166 ut_params->cipher_xform.next = &ut_params->auth_xform;
13168 /* Setup Authentication Parameters */
13169 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13170 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13171 ut_params->auth_xform.auth.algo = reference->auth_algo;
13172 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13173 ut_params->auth_xform.auth.key.data = auth_key;
13174 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13175 ut_params->auth_xform.next = NULL;
13177 /* Create Crypto session*/
13178 ut_params->sess = rte_cryptodev_sym_session_create(
13179 ts_params->session_mpool);
13181 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13183 &ut_params->cipher_xform,
13184 ts_params->session_priv_mpool);
13186 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13188 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13189 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13190 "Failed to allocate input buffer in mempool");
13192 /* clear mbuf payload */
13193 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13194 rte_pktmbuf_tailroom(ut_params->ibuf));
13196 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13197 reference->plaintext.len);
13198 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13199 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13201 /* Create operation */
13202 retval = create_cipher_auth_operation(ts_params,
13209 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13210 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13212 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13213 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13214 ut_params->op, 1, 1, 0, 0);
13216 ut_params->op = process_crypto_request(
13217 ts_params->valid_devs[0], ut_params->op);
13219 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13221 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13222 "crypto op processing failed");
13224 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13226 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13227 ut_params->op->sym->auth.data.offset);
13228 auth_tag = authciphertext + plaintext_pad_len;
13229 debug_hexdump(stdout, "ciphertext:", authciphertext,
13230 reference->ciphertext.len);
13231 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13233 /* Validate obuf */
13234 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13236 reference->ciphertext.data,
13237 reference->ciphertext.len,
13238 "Ciphertext data not as expected");
13240 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13242 reference->digest.data,
13243 reference->digest.len,
13244 "Generated digest not as expected");
13246 return TEST_SUCCESS;
13251 test_authenticated_decrypt_with_esn(
13252 struct crypto_testsuite_params *ts_params,
13253 struct crypto_unittest_params *ut_params,
13254 const struct test_crypto_vector *reference)
13258 uint8_t *ciphertext;
13259 uint8_t cipher_key[reference->cipher_key.len + 1];
13260 uint8_t auth_key[reference->auth_key.len + 1];
13261 struct rte_cryptodev_info dev_info;
13263 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13264 uint64_t feat_flags = dev_info.feature_flags;
13266 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13267 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13268 printf("Device doesn't support RAW data-path APIs.\n");
13269 return TEST_SKIPPED;
13272 /* Verify the capabilities */
13273 struct rte_cryptodev_sym_capability_idx cap_idx;
13274 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13275 cap_idx.algo.auth = reference->auth_algo;
13276 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13278 return TEST_SKIPPED;
13279 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13280 cap_idx.algo.cipher = reference->crypto_algo;
13281 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13283 return TEST_SKIPPED;
13285 /* Create session */
13286 memcpy(cipher_key, reference->cipher_key.data,
13287 reference->cipher_key.len);
13288 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13290 /* Setup Authentication Parameters */
13291 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13292 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13293 ut_params->auth_xform.auth.algo = reference->auth_algo;
13294 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13295 ut_params->auth_xform.auth.key.data = auth_key;
13296 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13297 ut_params->auth_xform.next = &ut_params->cipher_xform;
13299 /* Setup Cipher Parameters */
13300 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13301 ut_params->cipher_xform.next = NULL;
13302 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13303 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13304 ut_params->cipher_xform.cipher.key.data = cipher_key;
13305 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13306 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13307 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13309 /* Create Crypto session*/
13310 ut_params->sess = rte_cryptodev_sym_session_create(
13311 ts_params->session_mpool);
13313 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13315 &ut_params->auth_xform,
13316 ts_params->session_priv_mpool);
13318 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13320 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13321 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13322 "Failed to allocate input buffer in mempool");
13324 /* clear mbuf payload */
13325 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13326 rte_pktmbuf_tailroom(ut_params->ibuf));
13328 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13329 reference->ciphertext.len);
13330 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13331 memcpy(ciphertext, reference->ciphertext.data,
13332 reference->ciphertext.len);
13334 /* Create operation */
13335 retval = create_cipher_auth_verify_operation(ts_params,
13342 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13343 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13345 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13346 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13347 ut_params->op, 1, 1, 0, 0);
13349 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13352 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13353 TEST_ASSERT_EQUAL(ut_params->op->status,
13354 RTE_CRYPTO_OP_STATUS_SUCCESS,
13355 "crypto op processing passed");
13357 ut_params->obuf = ut_params->op->sym->m_src;
13358 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13364 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13365 const struct aead_test_data *tdata,
13366 void *digest_mem, uint64_t digest_phys)
13368 struct crypto_testsuite_params *ts_params = &testsuite_params;
13369 struct crypto_unittest_params *ut_params = &unittest_params;
13371 const unsigned int auth_tag_len = tdata->auth_tag.len;
13372 const unsigned int iv_len = tdata->iv.len;
13373 unsigned int aad_len = tdata->aad.len;
13374 unsigned int aad_len_pad = 0;
13376 /* Generate Crypto op data structure */
13377 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13378 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13379 TEST_ASSERT_NOT_NULL(ut_params->op,
13380 "Failed to allocate symmetric crypto operation struct");
13382 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13384 sym_op->aead.digest.data = digest_mem;
13386 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13387 "no room to append digest");
13389 sym_op->aead.digest.phys_addr = digest_phys;
13391 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13392 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13394 debug_hexdump(stdout, "digest:",
13395 sym_op->aead.digest.data,
13399 /* Append aad data */
13400 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13401 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13402 uint8_t *, IV_OFFSET);
13404 /* Copy IV 1 byte after the IV pointer, according to the API */
13405 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13407 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13409 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13410 ut_params->ibuf, aad_len);
13411 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13412 "no room to prepend aad");
13413 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13416 memset(sym_op->aead.aad.data, 0, aad_len);
13417 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
13418 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13420 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13421 debug_hexdump(stdout, "aad:",
13422 sym_op->aead.aad.data, aad_len);
13424 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13425 uint8_t *, IV_OFFSET);
13427 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13429 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13431 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13432 ut_params->ibuf, aad_len_pad);
13433 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13434 "no room to prepend aad");
13435 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13438 memset(sym_op->aead.aad.data, 0, aad_len);
13439 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13441 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13442 debug_hexdump(stdout, "aad:",
13443 sym_op->aead.aad.data, aad_len);
13446 sym_op->aead.data.length = tdata->plaintext.len;
13447 sym_op->aead.data.offset = aad_len_pad;
13452 #define SGL_MAX_NO 16
13455 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13456 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13458 struct crypto_testsuite_params *ts_params = &testsuite_params;
13459 struct crypto_unittest_params *ut_params = &unittest_params;
13460 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13463 int to_trn_tbl[SGL_MAX_NO];
13465 unsigned int trn_data = 0;
13466 uint8_t *plaintext, *ciphertext, *auth_tag;
13467 struct rte_cryptodev_info dev_info;
13469 /* Verify the capabilities */
13470 struct rte_cryptodev_sym_capability_idx cap_idx;
13471 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13472 cap_idx.algo.aead = tdata->algo;
13473 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13475 return TEST_SKIPPED;
13477 /* OOP not supported with CPU crypto */
13478 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13479 return TEST_SKIPPED;
13481 /* Detailed check for the particular SGL support flag */
13482 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13484 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13485 if (sgl_in && (!(dev_info.feature_flags &
13486 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13487 return TEST_SKIPPED;
13489 uint64_t feat_flags = dev_info.feature_flags;
13491 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13492 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13493 printf("Device doesn't support RAW data-path APIs.\n");
13494 return TEST_SKIPPED;
13497 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13498 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13499 tdata->plaintext.len;
13500 /* Raw data path API does not support OOP */
13501 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13502 return TEST_SKIPPED;
13503 if (sgl_in && !sgl_out) {
13504 if (!(dev_info.feature_flags &
13505 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13506 return TEST_SKIPPED;
13507 } else if (!sgl_in && sgl_out) {
13508 if (!(dev_info.feature_flags &
13509 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13510 return TEST_SKIPPED;
13511 } else if (sgl_in && sgl_out) {
13512 if (!(dev_info.feature_flags &
13513 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13514 return TEST_SKIPPED;
13518 if (fragsz > tdata->plaintext.len)
13519 fragsz = tdata->plaintext.len;
13521 uint16_t plaintext_len = fragsz;
13522 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13524 if (fragsz_oop > tdata->plaintext.len)
13525 frag_size_oop = tdata->plaintext.len;
13528 void *digest_mem = NULL;
13530 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13532 if (tdata->plaintext.len % fragsz != 0) {
13533 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13536 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13541 * For out-op-place we need to alloc another mbuf
13544 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13545 rte_pktmbuf_append(ut_params->obuf,
13546 frag_size_oop + prepend_len);
13547 buf_oop = ut_params->obuf;
13550 /* Create AEAD session */
13551 retval = create_aead_session(ts_params->valid_devs[0],
13553 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13554 tdata->key.data, tdata->key.len,
13555 tdata->aad.len, tdata->auth_tag.len,
13560 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13562 /* clear mbuf payload */
13563 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13564 rte_pktmbuf_tailroom(ut_params->ibuf));
13566 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13569 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13571 trn_data += plaintext_len;
13573 buf = ut_params->ibuf;
13576 * Loop until no more fragments
13579 while (trn_data < tdata->plaintext.len) {
13581 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13582 (tdata->plaintext.len - trn_data) : fragsz;
13584 to_trn_tbl[ecx++] = to_trn;
13586 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13589 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13590 rte_pktmbuf_tailroom(buf));
13593 if (oop && !fragsz_oop) {
13594 buf_last_oop = buf_oop->next =
13595 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13596 buf_oop = buf_oop->next;
13597 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13598 0, rte_pktmbuf_tailroom(buf_oop));
13599 rte_pktmbuf_append(buf_oop, to_trn);
13602 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13605 memcpy(plaintext, tdata->plaintext.data + trn_data,
13607 trn_data += to_trn;
13608 if (trn_data == tdata->plaintext.len) {
13611 digest_mem = rte_pktmbuf_append(buf_oop,
13612 tdata->auth_tag.len);
13614 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13615 tdata->auth_tag.len);
13619 uint64_t digest_phys = 0;
13621 ut_params->ibuf->nb_segs = segs;
13624 if (fragsz_oop && oop) {
13628 if (frag_size_oop == tdata->plaintext.len) {
13629 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13630 tdata->auth_tag.len);
13632 digest_phys = rte_pktmbuf_iova_offset(
13634 tdata->plaintext.len + prepend_len);
13637 trn_data = frag_size_oop;
13638 while (trn_data < tdata->plaintext.len) {
13641 (tdata->plaintext.len - trn_data <
13643 (tdata->plaintext.len - trn_data) :
13646 to_trn_tbl[ecx++] = to_trn;
13648 buf_last_oop = buf_oop->next =
13649 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13650 buf_oop = buf_oop->next;
13651 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13652 0, rte_pktmbuf_tailroom(buf_oop));
13653 rte_pktmbuf_append(buf_oop, to_trn);
13655 trn_data += to_trn;
13657 if (trn_data == tdata->plaintext.len) {
13658 digest_mem = rte_pktmbuf_append(buf_oop,
13659 tdata->auth_tag.len);
13663 ut_params->obuf->nb_segs = segs;
13667 * Place digest at the end of the last buffer
13670 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13671 if (oop && buf_last_oop)
13672 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13674 if (!digest_mem && !oop) {
13675 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13676 + tdata->auth_tag.len);
13677 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13678 tdata->plaintext.len);
13681 /* Create AEAD operation */
13682 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13683 tdata, digest_mem, digest_phys);
13688 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13690 ut_params->op->sym->m_src = ut_params->ibuf;
13692 ut_params->op->sym->m_dst = ut_params->obuf;
13694 /* Process crypto operation */
13695 if (oop == IN_PLACE &&
13696 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13697 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13698 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13699 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13700 ut_params->op, 0, 0, 0, 0);
13702 TEST_ASSERT_NOT_NULL(
13703 process_crypto_request(ts_params->valid_devs[0],
13704 ut_params->op), "failed to process sym crypto op");
13706 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13707 "crypto op processing failed");
13710 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13711 uint8_t *, prepend_len);
13713 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13714 uint8_t *, prepend_len);
13718 fragsz = fragsz_oop;
13720 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13722 tdata->ciphertext.data,
13724 "Ciphertext data not as expected");
13726 buf = ut_params->op->sym->m_src->next;
13728 buf = ut_params->op->sym->m_dst->next;
13730 unsigned int off = fragsz;
13734 ciphertext = rte_pktmbuf_mtod(buf,
13737 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13739 tdata->ciphertext.data + off,
13741 "Ciphertext data not as expected");
13743 off += to_trn_tbl[ecx++];
13747 auth_tag = digest_mem;
13748 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13750 tdata->auth_tag.data,
13751 tdata->auth_tag.len,
13752 "Generated auth tag not as expected");
13758 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13760 return test_authenticated_encryption_SGL(
13761 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13765 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13767 return test_authenticated_encryption_SGL(
13768 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13772 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13774 return test_authenticated_encryption_SGL(
13775 &gcm_test_case_8, OUT_OF_PLACE, 400,
13776 gcm_test_case_8.plaintext.len);
13780 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13782 /* This test is not for OPENSSL PMD */
13783 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13784 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13785 return TEST_SKIPPED;
13787 return test_authenticated_encryption_SGL(
13788 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13792 test_authentication_verify_fail_when_data_corrupted(
13793 struct crypto_testsuite_params *ts_params,
13794 struct crypto_unittest_params *ut_params,
13795 const struct test_crypto_vector *reference)
13797 return test_authentication_verify_fail_when_data_corruption(
13798 ts_params, ut_params, reference, 1);
13802 test_authentication_verify_fail_when_tag_corrupted(
13803 struct crypto_testsuite_params *ts_params,
13804 struct crypto_unittest_params *ut_params,
13805 const struct test_crypto_vector *reference)
13807 return test_authentication_verify_fail_when_data_corruption(
13808 ts_params, ut_params, reference, 0);
13812 test_authentication_verify_GMAC_fail_when_data_corrupted(
13813 struct crypto_testsuite_params *ts_params,
13814 struct crypto_unittest_params *ut_params,
13815 const struct test_crypto_vector *reference)
13817 return test_authentication_verify_GMAC_fail_when_corruption(
13818 ts_params, ut_params, reference, 1);
13822 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13823 struct crypto_testsuite_params *ts_params,
13824 struct crypto_unittest_params *ut_params,
13825 const struct test_crypto_vector *reference)
13827 return test_authentication_verify_GMAC_fail_when_corruption(
13828 ts_params, ut_params, reference, 0);
13832 test_authenticated_decryption_fail_when_data_corrupted(
13833 struct crypto_testsuite_params *ts_params,
13834 struct crypto_unittest_params *ut_params,
13835 const struct test_crypto_vector *reference)
13837 return test_authenticated_decryption_fail_when_corruption(
13838 ts_params, ut_params, reference, 1);
13842 test_authenticated_decryption_fail_when_tag_corrupted(
13843 struct crypto_testsuite_params *ts_params,
13844 struct crypto_unittest_params *ut_params,
13845 const struct test_crypto_vector *reference)
13847 return test_authenticated_decryption_fail_when_corruption(
13848 ts_params, ut_params, reference, 0);
13852 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13854 return test_authentication_verify_fail_when_data_corrupted(
13855 &testsuite_params, &unittest_params,
13856 &hmac_sha1_test_crypto_vector);
13860 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13862 return test_authentication_verify_fail_when_tag_corrupted(
13863 &testsuite_params, &unittest_params,
13864 &hmac_sha1_test_crypto_vector);
13868 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13870 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13871 &testsuite_params, &unittest_params,
13872 &aes128_gmac_test_vector);
13876 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13878 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13879 &testsuite_params, &unittest_params,
13880 &aes128_gmac_test_vector);
13884 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13886 return test_authenticated_decryption_fail_when_data_corrupted(
13889 &aes128cbc_hmac_sha1_test_vector);
13893 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13895 return test_authenticated_decryption_fail_when_tag_corrupted(
13898 &aes128cbc_hmac_sha1_test_vector);
13902 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13904 return test_authenticated_encrypt_with_esn(
13907 &aes128cbc_hmac_sha1_aad_test_vector);
13911 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13913 return test_authenticated_decrypt_with_esn(
13916 &aes128cbc_hmac_sha1_aad_test_vector);
13920 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13922 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13926 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13928 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13931 #ifdef RTE_CRYPTO_SCHEDULER
13933 /* global AESNI worker IDs for the scheduler test */
13934 uint8_t aesni_ids[2];
13937 scheduler_testsuite_setup(void)
13940 int32_t nb_devs, ret;
13941 char vdev_args[VDEV_ARGS_SIZE] = {""};
13942 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
13943 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
13944 uint16_t worker_core_count = 0;
13945 uint16_t socket_id = 0;
13947 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13948 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
13950 /* Identify the Worker Cores
13951 * Use 2 worker cores for the device args
13953 RTE_LCORE_FOREACH_WORKER(i) {
13954 if (worker_core_count > 1)
13956 snprintf(vdev_args, sizeof(vdev_args),
13957 "%s%d", temp_str, i);
13958 strcpy(temp_str, vdev_args);
13959 strlcat(temp_str, ";", sizeof(temp_str));
13960 worker_core_count++;
13961 socket_id = rte_lcore_to_socket_id(i);
13963 if (worker_core_count != 2) {
13964 RTE_LOG(ERR, USER1,
13965 "Cryptodev scheduler test require at least "
13966 "two worker cores to run. "
13967 "Please use the correct coremask.\n");
13968 return TEST_FAILED;
13970 strcpy(temp_str, vdev_args);
13971 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
13972 temp_str, socket_id);
13973 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
13974 nb_devs = rte_cryptodev_device_count_by_driver(
13975 rte_cryptodev_driver_id_get(
13976 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
13978 ret = rte_vdev_init(
13979 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
13981 TEST_ASSERT(ret == 0,
13982 "Failed to create instance %u of pmd : %s",
13983 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13986 return testsuite_setup();
13990 test_scheduler_attach_worker_op(void)
13992 struct crypto_testsuite_params *ts_params = &testsuite_params;
13993 uint8_t sched_id = ts_params->valid_devs[0];
13994 uint32_t i, nb_devs_attached = 0;
13996 char vdev_name[32];
13997 unsigned int count = rte_cryptodev_count();
13999 /* create 2 AESNI_MB vdevs on top of existing devices */
14000 for (i = count; i < count + 2; i++) {
14001 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14002 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14004 ret = rte_vdev_init(vdev_name, NULL);
14006 TEST_ASSERT(ret == 0,
14007 "Failed to create instance %u of"
14009 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14012 RTE_LOG(ERR, USER1,
14013 "Failed to create 2 AESNI MB PMDs.\n");
14014 return TEST_SKIPPED;
14018 /* attach 2 AESNI_MB cdevs */
14019 for (i = count; i < count + 2; i++) {
14020 struct rte_cryptodev_info info;
14021 unsigned int session_size;
14023 rte_cryptodev_info_get(i, &info);
14024 if (info.driver_id != rte_cryptodev_driver_id_get(
14025 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14028 session_size = rte_cryptodev_sym_get_private_session_size(i);
14030 * Create the session mempool again, since now there are new devices
14031 * to use the mempool.
14033 if (ts_params->session_mpool) {
14034 rte_mempool_free(ts_params->session_mpool);
14035 ts_params->session_mpool = NULL;
14037 if (ts_params->session_priv_mpool) {
14038 rte_mempool_free(ts_params->session_priv_mpool);
14039 ts_params->session_priv_mpool = NULL;
14042 if (info.sym.max_nb_sessions != 0 &&
14043 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14044 RTE_LOG(ERR, USER1,
14045 "Device does not support "
14046 "at least %u sessions\n",
14048 return TEST_FAILED;
14051 * Create mempool with maximum number of sessions,
14052 * to include the session headers
14054 if (ts_params->session_mpool == NULL) {
14055 ts_params->session_mpool =
14056 rte_cryptodev_sym_session_pool_create(
14058 MAX_NB_SESSIONS, 0, 0, 0,
14060 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14061 "session mempool allocation failed");
14065 * Create mempool with maximum number of sessions,
14066 * to include device specific session private data
14068 if (ts_params->session_priv_mpool == NULL) {
14069 ts_params->session_priv_mpool = rte_mempool_create(
14070 "test_sess_mp_priv",
14073 0, 0, NULL, NULL, NULL,
14074 NULL, SOCKET_ID_ANY,
14077 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14078 "session mempool allocation failed");
14081 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14082 ts_params->qp_conf.mp_session_private =
14083 ts_params->session_priv_mpool;
14085 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14088 TEST_ASSERT(ret == 0,
14089 "Failed to attach device %u of pmd : %s", i,
14090 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14092 aesni_ids[nb_devs_attached] = (uint8_t)i;
14094 nb_devs_attached++;
14101 test_scheduler_detach_worker_op(void)
14103 struct crypto_testsuite_params *ts_params = &testsuite_params;
14104 uint8_t sched_id = ts_params->valid_devs[0];
14108 for (i = 0; i < 2; i++) {
14109 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14111 TEST_ASSERT(ret == 0,
14112 "Failed to detach device %u", aesni_ids[i]);
14119 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14121 struct crypto_testsuite_params *ts_params = &testsuite_params;
14122 uint8_t sched_id = ts_params->valid_devs[0];
14124 return rte_cryptodev_scheduler_mode_set(sched_id,
14129 test_scheduler_mode_roundrobin_op(void)
14131 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14132 0, "Failed to set roundrobin mode");
14138 test_scheduler_mode_multicore_op(void)
14140 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14141 0, "Failed to set multicore mode");
14147 test_scheduler_mode_failover_op(void)
14149 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
14150 0, "Failed to set failover mode");
14156 test_scheduler_mode_pkt_size_distr_op(void)
14158 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
14159 0, "Failed to set pktsize mode");
14165 scheduler_multicore_testsuite_setup(void)
14167 if (test_scheduler_attach_worker_op() < 0)
14168 return TEST_SKIPPED;
14169 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
14170 return TEST_SKIPPED;
14175 scheduler_roundrobin_testsuite_setup(void)
14177 if (test_scheduler_attach_worker_op() < 0)
14178 return TEST_SKIPPED;
14179 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
14180 return TEST_SKIPPED;
14185 scheduler_failover_testsuite_setup(void)
14187 if (test_scheduler_attach_worker_op() < 0)
14188 return TEST_SKIPPED;
14189 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
14190 return TEST_SKIPPED;
14195 scheduler_pkt_size_distr_testsuite_setup(void)
14197 if (test_scheduler_attach_worker_op() < 0)
14198 return TEST_SKIPPED;
14199 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14200 return TEST_SKIPPED;
14205 scheduler_mode_testsuite_teardown(void)
14207 test_scheduler_detach_worker_op();
14210 #endif /* RTE_CRYPTO_SCHEDULER */
14212 static struct unit_test_suite end_testsuite = {
14213 .suite_name = NULL,
14216 .unit_test_suites = NULL
14219 #ifdef RTE_LIB_SECURITY
14220 static struct unit_test_suite ipsec_proto_testsuite = {
14221 .suite_name = "IPsec Proto Unit Test Suite",
14222 .setup = ipsec_proto_testsuite_setup,
14223 .unit_test_cases = {
14224 TEST_CASE_NAMED_WITH_DATA(
14225 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14226 ut_setup_security, ut_teardown,
14227 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
14228 TEST_CASE_NAMED_WITH_DATA(
14229 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14230 ut_setup_security, ut_teardown,
14231 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
14232 TEST_CASE_NAMED_WITH_DATA(
14233 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14234 ut_setup_security, ut_teardown,
14235 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
14236 TEST_CASE_NAMED_WITH_DATA(
14237 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14238 ut_setup_security, ut_teardown,
14239 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14240 TEST_CASE_NAMED_WITH_DATA(
14241 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14242 ut_setup_security, ut_teardown,
14243 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14244 TEST_CASE_NAMED_WITH_DATA(
14245 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14246 ut_setup_security, ut_teardown,
14247 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14248 TEST_CASE_NAMED_ST(
14249 "Combined test alg list",
14250 ut_setup_security, ut_teardown,
14251 test_ipsec_proto_display_list),
14252 TEST_CASE_NAMED_ST(
14254 ut_setup_security, ut_teardown,
14255 test_ipsec_proto_iv_gen),
14256 TEST_CASE_NAMED_ST(
14257 "UDP encapsulation",
14258 ut_setup_security, ut_teardown,
14259 test_ipsec_proto_udp_encap),
14260 TEST_CASE_NAMED_ST(
14261 "UDP encapsulation ports verification test",
14262 ut_setup_security, ut_teardown,
14263 test_ipsec_proto_udp_ports_verify),
14264 TEST_CASE_NAMED_ST(
14265 "SA expiry packets soft",
14266 ut_setup_security, ut_teardown,
14267 test_ipsec_proto_sa_exp_pkts_soft),
14268 TEST_CASE_NAMED_ST(
14269 "SA expiry packets hard",
14270 ut_setup_security, ut_teardown,
14271 test_ipsec_proto_sa_exp_pkts_hard),
14272 TEST_CASE_NAMED_ST(
14273 "Negative test: ICV corruption",
14274 ut_setup_security, ut_teardown,
14275 test_ipsec_proto_err_icv_corrupt),
14276 TEST_CASE_NAMED_ST(
14277 "Tunnel dst addr verification",
14278 ut_setup_security, ut_teardown,
14279 test_ipsec_proto_tunnel_dst_addr_verify),
14280 TEST_CASE_NAMED_ST(
14281 "Tunnel src and dst addr verification",
14282 ut_setup_security, ut_teardown,
14283 test_ipsec_proto_tunnel_src_dst_addr_verify),
14284 TEST_CASE_NAMED_ST(
14285 "Inner IP checksum",
14286 ut_setup_security, ut_teardown,
14287 test_ipsec_proto_inner_ip_csum),
14288 TEST_CASE_NAMED_ST(
14289 "Inner L4 checksum",
14290 ut_setup_security, ut_teardown,
14291 test_ipsec_proto_inner_l4_csum),
14292 TEST_CASES_END() /**< NULL terminate unit test array */
14296 static struct unit_test_suite pdcp_proto_testsuite = {
14297 .suite_name = "PDCP Proto Unit Test Suite",
14298 .setup = pdcp_proto_testsuite_setup,
14299 .unit_test_cases = {
14300 TEST_CASE_ST(ut_setup_security, ut_teardown,
14301 test_PDCP_PROTO_all),
14302 TEST_CASES_END() /**< NULL terminate unit test array */
14306 static struct unit_test_suite docsis_proto_testsuite = {
14307 .suite_name = "Docsis Proto Unit Test Suite",
14308 .setup = docsis_proto_testsuite_setup,
14309 .unit_test_cases = {
14310 TEST_CASE_ST(ut_setup_security, ut_teardown,
14311 test_DOCSIS_PROTO_all),
14312 TEST_CASES_END() /**< NULL terminate unit test array */
14317 static struct unit_test_suite cryptodev_gen_testsuite = {
14318 .suite_name = "Crypto General Unit Test Suite",
14319 .setup = crypto_gen_testsuite_setup,
14320 .unit_test_cases = {
14321 TEST_CASE_ST(ut_setup, ut_teardown,
14322 test_device_configure_invalid_dev_id),
14323 TEST_CASE_ST(ut_setup, ut_teardown,
14324 test_queue_pair_descriptor_setup),
14325 TEST_CASE_ST(ut_setup, ut_teardown,
14326 test_device_configure_invalid_queue_pair_ids),
14327 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
14328 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
14329 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
14330 TEST_CASES_END() /**< NULL terminate unit test array */
14334 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
14335 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
14336 .setup = negative_hmac_sha1_testsuite_setup,
14337 .unit_test_cases = {
14338 /** Negative tests */
14339 TEST_CASE_ST(ut_setup, ut_teardown,
14340 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14341 TEST_CASE_ST(ut_setup, ut_teardown,
14342 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14343 TEST_CASE_ST(ut_setup, ut_teardown,
14344 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14345 TEST_CASE_ST(ut_setup, ut_teardown,
14346 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14348 TEST_CASES_END() /**< NULL terminate unit test array */
14352 static struct unit_test_suite cryptodev_multi_session_testsuite = {
14353 .suite_name = "Multi Session Unit Test Suite",
14354 .setup = multi_session_testsuite_setup,
14355 .unit_test_cases = {
14356 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14357 TEST_CASE_ST(ut_setup, ut_teardown,
14358 test_multi_session_random_usage),
14360 TEST_CASES_END() /**< NULL terminate unit test array */
14364 static struct unit_test_suite cryptodev_null_testsuite = {
14365 .suite_name = "NULL Test Suite",
14366 .setup = null_testsuite_setup,
14367 .unit_test_cases = {
14368 TEST_CASE_ST(ut_setup, ut_teardown,
14369 test_null_invalid_operation),
14370 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
14375 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
14376 .suite_name = "AES CCM Authenticated Test Suite",
14377 .setup = aes_ccm_auth_testsuite_setup,
14378 .unit_test_cases = {
14379 /** AES CCM Authenticated Encryption 128 bits key*/
14380 TEST_CASE_ST(ut_setup, ut_teardown,
14381 test_AES_CCM_authenticated_encryption_test_case_128_1),
14382 TEST_CASE_ST(ut_setup, ut_teardown,
14383 test_AES_CCM_authenticated_encryption_test_case_128_2),
14384 TEST_CASE_ST(ut_setup, ut_teardown,
14385 test_AES_CCM_authenticated_encryption_test_case_128_3),
14387 /** AES CCM Authenticated Decryption 128 bits key*/
14388 TEST_CASE_ST(ut_setup, ut_teardown,
14389 test_AES_CCM_authenticated_decryption_test_case_128_1),
14390 TEST_CASE_ST(ut_setup, ut_teardown,
14391 test_AES_CCM_authenticated_decryption_test_case_128_2),
14392 TEST_CASE_ST(ut_setup, ut_teardown,
14393 test_AES_CCM_authenticated_decryption_test_case_128_3),
14395 /** AES CCM Authenticated Encryption 192 bits key */
14396 TEST_CASE_ST(ut_setup, ut_teardown,
14397 test_AES_CCM_authenticated_encryption_test_case_192_1),
14398 TEST_CASE_ST(ut_setup, ut_teardown,
14399 test_AES_CCM_authenticated_encryption_test_case_192_2),
14400 TEST_CASE_ST(ut_setup, ut_teardown,
14401 test_AES_CCM_authenticated_encryption_test_case_192_3),
14403 /** AES CCM Authenticated Decryption 192 bits key*/
14404 TEST_CASE_ST(ut_setup, ut_teardown,
14405 test_AES_CCM_authenticated_decryption_test_case_192_1),
14406 TEST_CASE_ST(ut_setup, ut_teardown,
14407 test_AES_CCM_authenticated_decryption_test_case_192_2),
14408 TEST_CASE_ST(ut_setup, ut_teardown,
14409 test_AES_CCM_authenticated_decryption_test_case_192_3),
14411 /** AES CCM Authenticated Encryption 256 bits key */
14412 TEST_CASE_ST(ut_setup, ut_teardown,
14413 test_AES_CCM_authenticated_encryption_test_case_256_1),
14414 TEST_CASE_ST(ut_setup, ut_teardown,
14415 test_AES_CCM_authenticated_encryption_test_case_256_2),
14416 TEST_CASE_ST(ut_setup, ut_teardown,
14417 test_AES_CCM_authenticated_encryption_test_case_256_3),
14419 /** AES CCM Authenticated Decryption 256 bits key*/
14420 TEST_CASE_ST(ut_setup, ut_teardown,
14421 test_AES_CCM_authenticated_decryption_test_case_256_1),
14422 TEST_CASE_ST(ut_setup, ut_teardown,
14423 test_AES_CCM_authenticated_decryption_test_case_256_2),
14424 TEST_CASE_ST(ut_setup, ut_teardown,
14425 test_AES_CCM_authenticated_decryption_test_case_256_3),
14430 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
14431 .suite_name = "AES GCM Authenticated Test Suite",
14432 .setup = aes_gcm_auth_testsuite_setup,
14433 .unit_test_cases = {
14434 /** AES GCM Authenticated Encryption */
14435 TEST_CASE_ST(ut_setup, ut_teardown,
14436 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
14437 TEST_CASE_ST(ut_setup, ut_teardown,
14438 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
14439 TEST_CASE_ST(ut_setup, ut_teardown,
14440 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
14441 TEST_CASE_ST(ut_setup, ut_teardown,
14442 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
14443 TEST_CASE_ST(ut_setup, ut_teardown,
14444 test_AES_GCM_authenticated_encryption_test_case_1),
14445 TEST_CASE_ST(ut_setup, ut_teardown,
14446 test_AES_GCM_authenticated_encryption_test_case_2),
14447 TEST_CASE_ST(ut_setup, ut_teardown,
14448 test_AES_GCM_authenticated_encryption_test_case_3),
14449 TEST_CASE_ST(ut_setup, ut_teardown,
14450 test_AES_GCM_authenticated_encryption_test_case_4),
14451 TEST_CASE_ST(ut_setup, ut_teardown,
14452 test_AES_GCM_authenticated_encryption_test_case_5),
14453 TEST_CASE_ST(ut_setup, ut_teardown,
14454 test_AES_GCM_authenticated_encryption_test_case_6),
14455 TEST_CASE_ST(ut_setup, ut_teardown,
14456 test_AES_GCM_authenticated_encryption_test_case_7),
14457 TEST_CASE_ST(ut_setup, ut_teardown,
14458 test_AES_GCM_authenticated_encryption_test_case_8),
14459 TEST_CASE_ST(ut_setup, ut_teardown,
14460 test_AES_GCM_J0_authenticated_encryption_test_case_1),
14462 /** AES GCM Authenticated Decryption */
14463 TEST_CASE_ST(ut_setup, ut_teardown,
14464 test_AES_GCM_authenticated_decryption_test_case_1),
14465 TEST_CASE_ST(ut_setup, ut_teardown,
14466 test_AES_GCM_authenticated_decryption_test_case_2),
14467 TEST_CASE_ST(ut_setup, ut_teardown,
14468 test_AES_GCM_authenticated_decryption_test_case_3),
14469 TEST_CASE_ST(ut_setup, ut_teardown,
14470 test_AES_GCM_authenticated_decryption_test_case_4),
14471 TEST_CASE_ST(ut_setup, ut_teardown,
14472 test_AES_GCM_authenticated_decryption_test_case_5),
14473 TEST_CASE_ST(ut_setup, ut_teardown,
14474 test_AES_GCM_authenticated_decryption_test_case_6),
14475 TEST_CASE_ST(ut_setup, ut_teardown,
14476 test_AES_GCM_authenticated_decryption_test_case_7),
14477 TEST_CASE_ST(ut_setup, ut_teardown,
14478 test_AES_GCM_authenticated_decryption_test_case_8),
14479 TEST_CASE_ST(ut_setup, ut_teardown,
14480 test_AES_GCM_J0_authenticated_decryption_test_case_1),
14482 /** AES GCM Authenticated Encryption 192 bits key */
14483 TEST_CASE_ST(ut_setup, ut_teardown,
14484 test_AES_GCM_auth_encryption_test_case_192_1),
14485 TEST_CASE_ST(ut_setup, ut_teardown,
14486 test_AES_GCM_auth_encryption_test_case_192_2),
14487 TEST_CASE_ST(ut_setup, ut_teardown,
14488 test_AES_GCM_auth_encryption_test_case_192_3),
14489 TEST_CASE_ST(ut_setup, ut_teardown,
14490 test_AES_GCM_auth_encryption_test_case_192_4),
14491 TEST_CASE_ST(ut_setup, ut_teardown,
14492 test_AES_GCM_auth_encryption_test_case_192_5),
14493 TEST_CASE_ST(ut_setup, ut_teardown,
14494 test_AES_GCM_auth_encryption_test_case_192_6),
14495 TEST_CASE_ST(ut_setup, ut_teardown,
14496 test_AES_GCM_auth_encryption_test_case_192_7),
14498 /** AES GCM Authenticated Decryption 192 bits key */
14499 TEST_CASE_ST(ut_setup, ut_teardown,
14500 test_AES_GCM_auth_decryption_test_case_192_1),
14501 TEST_CASE_ST(ut_setup, ut_teardown,
14502 test_AES_GCM_auth_decryption_test_case_192_2),
14503 TEST_CASE_ST(ut_setup, ut_teardown,
14504 test_AES_GCM_auth_decryption_test_case_192_3),
14505 TEST_CASE_ST(ut_setup, ut_teardown,
14506 test_AES_GCM_auth_decryption_test_case_192_4),
14507 TEST_CASE_ST(ut_setup, ut_teardown,
14508 test_AES_GCM_auth_decryption_test_case_192_5),
14509 TEST_CASE_ST(ut_setup, ut_teardown,
14510 test_AES_GCM_auth_decryption_test_case_192_6),
14511 TEST_CASE_ST(ut_setup, ut_teardown,
14512 test_AES_GCM_auth_decryption_test_case_192_7),
14514 /** AES GCM Authenticated Encryption 256 bits key */
14515 TEST_CASE_ST(ut_setup, ut_teardown,
14516 test_AES_GCM_auth_encryption_test_case_256_1),
14517 TEST_CASE_ST(ut_setup, ut_teardown,
14518 test_AES_GCM_auth_encryption_test_case_256_2),
14519 TEST_CASE_ST(ut_setup, ut_teardown,
14520 test_AES_GCM_auth_encryption_test_case_256_3),
14521 TEST_CASE_ST(ut_setup, ut_teardown,
14522 test_AES_GCM_auth_encryption_test_case_256_4),
14523 TEST_CASE_ST(ut_setup, ut_teardown,
14524 test_AES_GCM_auth_encryption_test_case_256_5),
14525 TEST_CASE_ST(ut_setup, ut_teardown,
14526 test_AES_GCM_auth_encryption_test_case_256_6),
14527 TEST_CASE_ST(ut_setup, ut_teardown,
14528 test_AES_GCM_auth_encryption_test_case_256_7),
14530 /** AES GCM Authenticated Decryption 256 bits key */
14531 TEST_CASE_ST(ut_setup, ut_teardown,
14532 test_AES_GCM_auth_decryption_test_case_256_1),
14533 TEST_CASE_ST(ut_setup, ut_teardown,
14534 test_AES_GCM_auth_decryption_test_case_256_2),
14535 TEST_CASE_ST(ut_setup, ut_teardown,
14536 test_AES_GCM_auth_decryption_test_case_256_3),
14537 TEST_CASE_ST(ut_setup, ut_teardown,
14538 test_AES_GCM_auth_decryption_test_case_256_4),
14539 TEST_CASE_ST(ut_setup, ut_teardown,
14540 test_AES_GCM_auth_decryption_test_case_256_5),
14541 TEST_CASE_ST(ut_setup, ut_teardown,
14542 test_AES_GCM_auth_decryption_test_case_256_6),
14543 TEST_CASE_ST(ut_setup, ut_teardown,
14544 test_AES_GCM_auth_decryption_test_case_256_7),
14546 /** AES GCM Authenticated Encryption big aad size */
14547 TEST_CASE_ST(ut_setup, ut_teardown,
14548 test_AES_GCM_auth_encryption_test_case_aad_1),
14549 TEST_CASE_ST(ut_setup, ut_teardown,
14550 test_AES_GCM_auth_encryption_test_case_aad_2),
14552 /** AES GCM Authenticated Decryption big aad size */
14553 TEST_CASE_ST(ut_setup, ut_teardown,
14554 test_AES_GCM_auth_decryption_test_case_aad_1),
14555 TEST_CASE_ST(ut_setup, ut_teardown,
14556 test_AES_GCM_auth_decryption_test_case_aad_2),
14558 /** Out of place tests */
14559 TEST_CASE_ST(ut_setup, ut_teardown,
14560 test_AES_GCM_authenticated_encryption_oop_test_case_1),
14561 TEST_CASE_ST(ut_setup, ut_teardown,
14562 test_AES_GCM_authenticated_decryption_oop_test_case_1),
14564 /** Session-less tests */
14565 TEST_CASE_ST(ut_setup, ut_teardown,
14566 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
14567 TEST_CASE_ST(ut_setup, ut_teardown,
14568 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
14574 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
14575 .suite_name = "AES GMAC Authentication Test Suite",
14576 .setup = aes_gmac_auth_testsuite_setup,
14577 .unit_test_cases = {
14578 TEST_CASE_ST(ut_setup, ut_teardown,
14579 test_AES_GMAC_authentication_test_case_1),
14580 TEST_CASE_ST(ut_setup, ut_teardown,
14581 test_AES_GMAC_authentication_verify_test_case_1),
14582 TEST_CASE_ST(ut_setup, ut_teardown,
14583 test_AES_GMAC_authentication_test_case_2),
14584 TEST_CASE_ST(ut_setup, ut_teardown,
14585 test_AES_GMAC_authentication_verify_test_case_2),
14586 TEST_CASE_ST(ut_setup, ut_teardown,
14587 test_AES_GMAC_authentication_test_case_3),
14588 TEST_CASE_ST(ut_setup, ut_teardown,
14589 test_AES_GMAC_authentication_verify_test_case_3),
14590 TEST_CASE_ST(ut_setup, ut_teardown,
14591 test_AES_GMAC_authentication_test_case_4),
14592 TEST_CASE_ST(ut_setup, ut_teardown,
14593 test_AES_GMAC_authentication_verify_test_case_4),
14594 TEST_CASE_ST(ut_setup, ut_teardown,
14595 test_AES_GMAC_authentication_SGL_40B),
14596 TEST_CASE_ST(ut_setup, ut_teardown,
14597 test_AES_GMAC_authentication_SGL_80B),
14598 TEST_CASE_ST(ut_setup, ut_teardown,
14599 test_AES_GMAC_authentication_SGL_2048B),
14600 TEST_CASE_ST(ut_setup, ut_teardown,
14601 test_AES_GMAC_authentication_SGL_2047B),
14607 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14608 .suite_name = "Chacha20-Poly1305 Test Suite",
14609 .setup = chacha20_poly1305_testsuite_setup,
14610 .unit_test_cases = {
14611 TEST_CASE_ST(ut_setup, ut_teardown,
14612 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14613 TEST_CASE_ST(ut_setup, ut_teardown,
14614 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14619 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14620 .suite_name = "SNOW 3G Test Suite",
14621 .setup = snow3g_testsuite_setup,
14622 .unit_test_cases = {
14623 /** SNOW 3G encrypt only (UEA2) */
14624 TEST_CASE_ST(ut_setup, ut_teardown,
14625 test_snow3g_encryption_test_case_1),
14626 TEST_CASE_ST(ut_setup, ut_teardown,
14627 test_snow3g_encryption_test_case_2),
14628 TEST_CASE_ST(ut_setup, ut_teardown,
14629 test_snow3g_encryption_test_case_3),
14630 TEST_CASE_ST(ut_setup, ut_teardown,
14631 test_snow3g_encryption_test_case_4),
14632 TEST_CASE_ST(ut_setup, ut_teardown,
14633 test_snow3g_encryption_test_case_5),
14635 TEST_CASE_ST(ut_setup, ut_teardown,
14636 test_snow3g_encryption_test_case_1_oop),
14637 TEST_CASE_ST(ut_setup, ut_teardown,
14638 test_snow3g_encryption_test_case_1_oop_sgl),
14639 TEST_CASE_ST(ut_setup, ut_teardown,
14640 test_snow3g_encryption_test_case_1_offset_oop),
14641 TEST_CASE_ST(ut_setup, ut_teardown,
14642 test_snow3g_decryption_test_case_1_oop),
14644 /** SNOW 3G generate auth, then encrypt (UEA2) */
14645 TEST_CASE_ST(ut_setup, ut_teardown,
14646 test_snow3g_auth_cipher_test_case_1),
14647 TEST_CASE_ST(ut_setup, ut_teardown,
14648 test_snow3g_auth_cipher_test_case_2),
14649 TEST_CASE_ST(ut_setup, ut_teardown,
14650 test_snow3g_auth_cipher_test_case_2_oop),
14651 TEST_CASE_ST(ut_setup, ut_teardown,
14652 test_snow3g_auth_cipher_part_digest_enc),
14653 TEST_CASE_ST(ut_setup, ut_teardown,
14654 test_snow3g_auth_cipher_part_digest_enc_oop),
14655 TEST_CASE_ST(ut_setup, ut_teardown,
14656 test_snow3g_auth_cipher_test_case_3_sgl),
14657 TEST_CASE_ST(ut_setup, ut_teardown,
14658 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14659 TEST_CASE_ST(ut_setup, ut_teardown,
14660 test_snow3g_auth_cipher_part_digest_enc_sgl),
14661 TEST_CASE_ST(ut_setup, ut_teardown,
14662 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14664 /** SNOW 3G decrypt (UEA2), then verify auth */
14665 TEST_CASE_ST(ut_setup, ut_teardown,
14666 test_snow3g_auth_cipher_verify_test_case_1),
14667 TEST_CASE_ST(ut_setup, ut_teardown,
14668 test_snow3g_auth_cipher_verify_test_case_2),
14669 TEST_CASE_ST(ut_setup, ut_teardown,
14670 test_snow3g_auth_cipher_verify_test_case_2_oop),
14671 TEST_CASE_ST(ut_setup, ut_teardown,
14672 test_snow3g_auth_cipher_verify_part_digest_enc),
14673 TEST_CASE_ST(ut_setup, ut_teardown,
14674 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14675 TEST_CASE_ST(ut_setup, ut_teardown,
14676 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14677 TEST_CASE_ST(ut_setup, ut_teardown,
14678 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14679 TEST_CASE_ST(ut_setup, ut_teardown,
14680 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14681 TEST_CASE_ST(ut_setup, ut_teardown,
14682 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14684 /** SNOW 3G decrypt only (UEA2) */
14685 TEST_CASE_ST(ut_setup, ut_teardown,
14686 test_snow3g_decryption_test_case_1),
14687 TEST_CASE_ST(ut_setup, ut_teardown,
14688 test_snow3g_decryption_test_case_2),
14689 TEST_CASE_ST(ut_setup, ut_teardown,
14690 test_snow3g_decryption_test_case_3),
14691 TEST_CASE_ST(ut_setup, ut_teardown,
14692 test_snow3g_decryption_test_case_4),
14693 TEST_CASE_ST(ut_setup, ut_teardown,
14694 test_snow3g_decryption_test_case_5),
14695 TEST_CASE_ST(ut_setup, ut_teardown,
14696 test_snow3g_decryption_with_digest_test_case_1),
14697 TEST_CASE_ST(ut_setup, ut_teardown,
14698 test_snow3g_hash_generate_test_case_1),
14699 TEST_CASE_ST(ut_setup, ut_teardown,
14700 test_snow3g_hash_generate_test_case_2),
14701 TEST_CASE_ST(ut_setup, ut_teardown,
14702 test_snow3g_hash_generate_test_case_3),
14704 /* Tests with buffers which length is not byte-aligned */
14705 TEST_CASE_ST(ut_setup, ut_teardown,
14706 test_snow3g_hash_generate_test_case_4),
14707 TEST_CASE_ST(ut_setup, ut_teardown,
14708 test_snow3g_hash_generate_test_case_5),
14709 TEST_CASE_ST(ut_setup, ut_teardown,
14710 test_snow3g_hash_generate_test_case_6),
14711 TEST_CASE_ST(ut_setup, ut_teardown,
14712 test_snow3g_hash_verify_test_case_1),
14713 TEST_CASE_ST(ut_setup, ut_teardown,
14714 test_snow3g_hash_verify_test_case_2),
14715 TEST_CASE_ST(ut_setup, ut_teardown,
14716 test_snow3g_hash_verify_test_case_3),
14718 /* Tests with buffers which length is not byte-aligned */
14719 TEST_CASE_ST(ut_setup, ut_teardown,
14720 test_snow3g_hash_verify_test_case_4),
14721 TEST_CASE_ST(ut_setup, ut_teardown,
14722 test_snow3g_hash_verify_test_case_5),
14723 TEST_CASE_ST(ut_setup, ut_teardown,
14724 test_snow3g_hash_verify_test_case_6),
14725 TEST_CASE_ST(ut_setup, ut_teardown,
14726 test_snow3g_cipher_auth_test_case_1),
14727 TEST_CASE_ST(ut_setup, ut_teardown,
14728 test_snow3g_auth_cipher_with_digest_test_case_1),
14733 static struct unit_test_suite cryptodev_zuc_testsuite = {
14734 .suite_name = "ZUC Test Suite",
14735 .setup = zuc_testsuite_setup,
14736 .unit_test_cases = {
14737 /** ZUC encrypt only (EEA3) */
14738 TEST_CASE_ST(ut_setup, ut_teardown,
14739 test_zuc_encryption_test_case_1),
14740 TEST_CASE_ST(ut_setup, ut_teardown,
14741 test_zuc_encryption_test_case_2),
14742 TEST_CASE_ST(ut_setup, ut_teardown,
14743 test_zuc_encryption_test_case_3),
14744 TEST_CASE_ST(ut_setup, ut_teardown,
14745 test_zuc_encryption_test_case_4),
14746 TEST_CASE_ST(ut_setup, ut_teardown,
14747 test_zuc_encryption_test_case_5),
14748 TEST_CASE_ST(ut_setup, ut_teardown,
14749 test_zuc_encryption_test_case_6_sgl),
14750 TEST_CASE_ST(ut_setup, ut_teardown,
14751 test_zuc_encryption_test_case_7),
14753 /** ZUC authenticate (EIA3) */
14754 TEST_CASE_ST(ut_setup, ut_teardown,
14755 test_zuc_hash_generate_test_case_1),
14756 TEST_CASE_ST(ut_setup, ut_teardown,
14757 test_zuc_hash_generate_test_case_2),
14758 TEST_CASE_ST(ut_setup, ut_teardown,
14759 test_zuc_hash_generate_test_case_3),
14760 TEST_CASE_ST(ut_setup, ut_teardown,
14761 test_zuc_hash_generate_test_case_4),
14762 TEST_CASE_ST(ut_setup, ut_teardown,
14763 test_zuc_hash_generate_test_case_5),
14764 TEST_CASE_ST(ut_setup, ut_teardown,
14765 test_zuc_hash_generate_test_case_6),
14766 TEST_CASE_ST(ut_setup, ut_teardown,
14767 test_zuc_hash_generate_test_case_7),
14768 TEST_CASE_ST(ut_setup, ut_teardown,
14769 test_zuc_hash_generate_test_case_8),
14770 TEST_CASE_ST(ut_setup, ut_teardown,
14771 test_zuc_hash_generate_test_case_9),
14772 TEST_CASE_ST(ut_setup, ut_teardown,
14773 test_zuc_hash_generate_test_case_10),
14776 /** ZUC alg-chain (EEA3/EIA3) */
14777 TEST_CASE_ST(ut_setup, ut_teardown,
14778 test_zuc_cipher_auth_test_case_1),
14779 TEST_CASE_ST(ut_setup, ut_teardown,
14780 test_zuc_cipher_auth_test_case_2),
14782 /** ZUC generate auth, then encrypt (EEA3) */
14783 TEST_CASE_ST(ut_setup, ut_teardown,
14784 test_zuc_auth_cipher_test_case_1),
14785 TEST_CASE_ST(ut_setup, ut_teardown,
14786 test_zuc_auth_cipher_test_case_1_oop),
14787 TEST_CASE_ST(ut_setup, ut_teardown,
14788 test_zuc_auth_cipher_test_case_1_sgl),
14789 TEST_CASE_ST(ut_setup, ut_teardown,
14790 test_zuc_auth_cipher_test_case_1_oop_sgl),
14792 /** ZUC decrypt (EEA3), then verify auth */
14793 TEST_CASE_ST(ut_setup, ut_teardown,
14794 test_zuc_auth_cipher_verify_test_case_1),
14795 TEST_CASE_ST(ut_setup, ut_teardown,
14796 test_zuc_auth_cipher_verify_test_case_1_oop),
14797 TEST_CASE_ST(ut_setup, ut_teardown,
14798 test_zuc_auth_cipher_verify_test_case_1_sgl),
14799 TEST_CASE_ST(ut_setup, ut_teardown,
14800 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14805 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14806 .suite_name = "HMAC_MD5 Authentication Test Suite",
14807 .setup = hmac_md5_auth_testsuite_setup,
14808 .unit_test_cases = {
14809 TEST_CASE_ST(ut_setup, ut_teardown,
14810 test_MD5_HMAC_generate_case_1),
14811 TEST_CASE_ST(ut_setup, ut_teardown,
14812 test_MD5_HMAC_verify_case_1),
14813 TEST_CASE_ST(ut_setup, ut_teardown,
14814 test_MD5_HMAC_generate_case_2),
14815 TEST_CASE_ST(ut_setup, ut_teardown,
14816 test_MD5_HMAC_verify_case_2),
14821 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14822 .suite_name = "Kasumi Test Suite",
14823 .setup = kasumi_testsuite_setup,
14824 .unit_test_cases = {
14825 /** KASUMI hash only (UIA1) */
14826 TEST_CASE_ST(ut_setup, ut_teardown,
14827 test_kasumi_hash_generate_test_case_1),
14828 TEST_CASE_ST(ut_setup, ut_teardown,
14829 test_kasumi_hash_generate_test_case_2),
14830 TEST_CASE_ST(ut_setup, ut_teardown,
14831 test_kasumi_hash_generate_test_case_3),
14832 TEST_CASE_ST(ut_setup, ut_teardown,
14833 test_kasumi_hash_generate_test_case_4),
14834 TEST_CASE_ST(ut_setup, ut_teardown,
14835 test_kasumi_hash_generate_test_case_5),
14836 TEST_CASE_ST(ut_setup, ut_teardown,
14837 test_kasumi_hash_generate_test_case_6),
14839 TEST_CASE_ST(ut_setup, ut_teardown,
14840 test_kasumi_hash_verify_test_case_1),
14841 TEST_CASE_ST(ut_setup, ut_teardown,
14842 test_kasumi_hash_verify_test_case_2),
14843 TEST_CASE_ST(ut_setup, ut_teardown,
14844 test_kasumi_hash_verify_test_case_3),
14845 TEST_CASE_ST(ut_setup, ut_teardown,
14846 test_kasumi_hash_verify_test_case_4),
14847 TEST_CASE_ST(ut_setup, ut_teardown,
14848 test_kasumi_hash_verify_test_case_5),
14850 /** KASUMI encrypt only (UEA1) */
14851 TEST_CASE_ST(ut_setup, ut_teardown,
14852 test_kasumi_encryption_test_case_1),
14853 TEST_CASE_ST(ut_setup, ut_teardown,
14854 test_kasumi_encryption_test_case_1_sgl),
14855 TEST_CASE_ST(ut_setup, ut_teardown,
14856 test_kasumi_encryption_test_case_1_oop),
14857 TEST_CASE_ST(ut_setup, ut_teardown,
14858 test_kasumi_encryption_test_case_1_oop_sgl),
14859 TEST_CASE_ST(ut_setup, ut_teardown,
14860 test_kasumi_encryption_test_case_2),
14861 TEST_CASE_ST(ut_setup, ut_teardown,
14862 test_kasumi_encryption_test_case_3),
14863 TEST_CASE_ST(ut_setup, ut_teardown,
14864 test_kasumi_encryption_test_case_4),
14865 TEST_CASE_ST(ut_setup, ut_teardown,
14866 test_kasumi_encryption_test_case_5),
14868 /** KASUMI decrypt only (UEA1) */
14869 TEST_CASE_ST(ut_setup, ut_teardown,
14870 test_kasumi_decryption_test_case_1),
14871 TEST_CASE_ST(ut_setup, ut_teardown,
14872 test_kasumi_decryption_test_case_2),
14873 TEST_CASE_ST(ut_setup, ut_teardown,
14874 test_kasumi_decryption_test_case_3),
14875 TEST_CASE_ST(ut_setup, ut_teardown,
14876 test_kasumi_decryption_test_case_4),
14877 TEST_CASE_ST(ut_setup, ut_teardown,
14878 test_kasumi_decryption_test_case_5),
14879 TEST_CASE_ST(ut_setup, ut_teardown,
14880 test_kasumi_decryption_test_case_1_oop),
14881 TEST_CASE_ST(ut_setup, ut_teardown,
14882 test_kasumi_cipher_auth_test_case_1),
14884 /** KASUMI generate auth, then encrypt (F8) */
14885 TEST_CASE_ST(ut_setup, ut_teardown,
14886 test_kasumi_auth_cipher_test_case_1),
14887 TEST_CASE_ST(ut_setup, ut_teardown,
14888 test_kasumi_auth_cipher_test_case_2),
14889 TEST_CASE_ST(ut_setup, ut_teardown,
14890 test_kasumi_auth_cipher_test_case_2_oop),
14891 TEST_CASE_ST(ut_setup, ut_teardown,
14892 test_kasumi_auth_cipher_test_case_2_sgl),
14893 TEST_CASE_ST(ut_setup, ut_teardown,
14894 test_kasumi_auth_cipher_test_case_2_oop_sgl),
14896 /** KASUMI decrypt (F8), then verify auth */
14897 TEST_CASE_ST(ut_setup, ut_teardown,
14898 test_kasumi_auth_cipher_verify_test_case_1),
14899 TEST_CASE_ST(ut_setup, ut_teardown,
14900 test_kasumi_auth_cipher_verify_test_case_2),
14901 TEST_CASE_ST(ut_setup, ut_teardown,
14902 test_kasumi_auth_cipher_verify_test_case_2_oop),
14903 TEST_CASE_ST(ut_setup, ut_teardown,
14904 test_kasumi_auth_cipher_verify_test_case_2_sgl),
14905 TEST_CASE_ST(ut_setup, ut_teardown,
14906 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14912 static struct unit_test_suite cryptodev_esn_testsuite = {
14913 .suite_name = "ESN Test Suite",
14914 .setup = esn_testsuite_setup,
14915 .unit_test_cases = {
14916 TEST_CASE_ST(ut_setup, ut_teardown,
14917 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14918 TEST_CASE_ST(ut_setup, ut_teardown,
14919 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14924 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
14925 .suite_name = "Negative AES GCM Test Suite",
14926 .setup = negative_aes_gcm_testsuite_setup,
14927 .unit_test_cases = {
14928 TEST_CASE_ST(ut_setup, ut_teardown,
14929 test_AES_GCM_auth_encryption_fail_iv_corrupt),
14930 TEST_CASE_ST(ut_setup, ut_teardown,
14931 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14932 TEST_CASE_ST(ut_setup, ut_teardown,
14933 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14934 TEST_CASE_ST(ut_setup, ut_teardown,
14935 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14936 TEST_CASE_ST(ut_setup, ut_teardown,
14937 test_AES_GCM_auth_encryption_fail_aad_corrupt),
14938 TEST_CASE_ST(ut_setup, ut_teardown,
14939 test_AES_GCM_auth_encryption_fail_tag_corrupt),
14940 TEST_CASE_ST(ut_setup, ut_teardown,
14941 test_AES_GCM_auth_decryption_fail_iv_corrupt),
14942 TEST_CASE_ST(ut_setup, ut_teardown,
14943 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
14944 TEST_CASE_ST(ut_setup, ut_teardown,
14945 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
14946 TEST_CASE_ST(ut_setup, ut_teardown,
14947 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
14948 TEST_CASE_ST(ut_setup, ut_teardown,
14949 test_AES_GCM_auth_decryption_fail_aad_corrupt),
14950 TEST_CASE_ST(ut_setup, ut_teardown,
14951 test_AES_GCM_auth_decryption_fail_tag_corrupt),
14957 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
14958 .suite_name = "Negative AES GMAC Test Suite",
14959 .setup = negative_aes_gmac_testsuite_setup,
14960 .unit_test_cases = {
14961 TEST_CASE_ST(ut_setup, ut_teardown,
14962 authentication_verify_AES128_GMAC_fail_data_corrupt),
14963 TEST_CASE_ST(ut_setup, ut_teardown,
14964 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14970 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
14971 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
14972 .setup = mixed_cipher_hash_testsuite_setup,
14973 .unit_test_cases = {
14974 /** AUTH AES CMAC + CIPHER AES CTR */
14975 TEST_CASE_ST(ut_setup, ut_teardown,
14976 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
14977 TEST_CASE_ST(ut_setup, ut_teardown,
14978 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14979 TEST_CASE_ST(ut_setup, ut_teardown,
14980 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14981 TEST_CASE_ST(ut_setup, ut_teardown,
14982 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14983 TEST_CASE_ST(ut_setup, ut_teardown,
14984 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
14985 TEST_CASE_ST(ut_setup, ut_teardown,
14986 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14987 TEST_CASE_ST(ut_setup, ut_teardown,
14988 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14989 TEST_CASE_ST(ut_setup, ut_teardown,
14990 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14992 /** AUTH ZUC + CIPHER SNOW3G */
14993 TEST_CASE_ST(ut_setup, ut_teardown,
14994 test_auth_zuc_cipher_snow_test_case_1),
14995 TEST_CASE_ST(ut_setup, ut_teardown,
14996 test_verify_auth_zuc_cipher_snow_test_case_1),
14997 /** AUTH AES CMAC + CIPHER SNOW3G */
14998 TEST_CASE_ST(ut_setup, ut_teardown,
14999 test_auth_aes_cmac_cipher_snow_test_case_1),
15000 TEST_CASE_ST(ut_setup, ut_teardown,
15001 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
15002 /** AUTH ZUC + CIPHER AES CTR */
15003 TEST_CASE_ST(ut_setup, ut_teardown,
15004 test_auth_zuc_cipher_aes_ctr_test_case_1),
15005 TEST_CASE_ST(ut_setup, ut_teardown,
15006 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
15007 /** AUTH SNOW3G + CIPHER AES CTR */
15008 TEST_CASE_ST(ut_setup, ut_teardown,
15009 test_auth_snow_cipher_aes_ctr_test_case_1),
15010 TEST_CASE_ST(ut_setup, ut_teardown,
15011 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
15012 /** AUTH SNOW3G + CIPHER ZUC */
15013 TEST_CASE_ST(ut_setup, ut_teardown,
15014 test_auth_snow_cipher_zuc_test_case_1),
15015 TEST_CASE_ST(ut_setup, ut_teardown,
15016 test_verify_auth_snow_cipher_zuc_test_case_1),
15017 /** AUTH AES CMAC + CIPHER ZUC */
15018 TEST_CASE_ST(ut_setup, ut_teardown,
15019 test_auth_aes_cmac_cipher_zuc_test_case_1),
15020 TEST_CASE_ST(ut_setup, ut_teardown,
15021 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
15023 /** AUTH NULL + CIPHER SNOW3G */
15024 TEST_CASE_ST(ut_setup, ut_teardown,
15025 test_auth_null_cipher_snow_test_case_1),
15026 TEST_CASE_ST(ut_setup, ut_teardown,
15027 test_verify_auth_null_cipher_snow_test_case_1),
15028 /** AUTH NULL + CIPHER ZUC */
15029 TEST_CASE_ST(ut_setup, ut_teardown,
15030 test_auth_null_cipher_zuc_test_case_1),
15031 TEST_CASE_ST(ut_setup, ut_teardown,
15032 test_verify_auth_null_cipher_zuc_test_case_1),
15033 /** AUTH SNOW3G + CIPHER NULL */
15034 TEST_CASE_ST(ut_setup, ut_teardown,
15035 test_auth_snow_cipher_null_test_case_1),
15036 TEST_CASE_ST(ut_setup, ut_teardown,
15037 test_verify_auth_snow_cipher_null_test_case_1),
15038 /** AUTH ZUC + CIPHER NULL */
15039 TEST_CASE_ST(ut_setup, ut_teardown,
15040 test_auth_zuc_cipher_null_test_case_1),
15041 TEST_CASE_ST(ut_setup, ut_teardown,
15042 test_verify_auth_zuc_cipher_null_test_case_1),
15043 /** AUTH NULL + CIPHER AES CTR */
15044 TEST_CASE_ST(ut_setup, ut_teardown,
15045 test_auth_null_cipher_aes_ctr_test_case_1),
15046 TEST_CASE_ST(ut_setup, ut_teardown,
15047 test_verify_auth_null_cipher_aes_ctr_test_case_1),
15048 /** AUTH AES CMAC + CIPHER NULL */
15049 TEST_CASE_ST(ut_setup, ut_teardown,
15050 test_auth_aes_cmac_cipher_null_test_case_1),
15051 TEST_CASE_ST(ut_setup, ut_teardown,
15052 test_verify_auth_aes_cmac_cipher_null_test_case_1),
15058 run_cryptodev_testsuite(const char *pmd_name)
15060 uint8_t ret, j, i = 0, blk_start_idx = 0;
15061 const enum blockcipher_test_type blk_suites[] = {
15062 BLKCIPHER_AES_CHAIN_TYPE,
15063 BLKCIPHER_AES_CIPHERONLY_TYPE,
15064 BLKCIPHER_AES_DOCSIS_TYPE,
15065 BLKCIPHER_3DES_CHAIN_TYPE,
15066 BLKCIPHER_3DES_CIPHERONLY_TYPE,
15067 BLKCIPHER_DES_CIPHERONLY_TYPE,
15068 BLKCIPHER_DES_DOCSIS_TYPE,
15069 BLKCIPHER_AUTHONLY_TYPE};
15070 struct unit_test_suite *static_suites[] = {
15071 &cryptodev_multi_session_testsuite,
15072 &cryptodev_null_testsuite,
15073 &cryptodev_aes_ccm_auth_testsuite,
15074 &cryptodev_aes_gcm_auth_testsuite,
15075 &cryptodev_aes_gmac_auth_testsuite,
15076 &cryptodev_snow3g_testsuite,
15077 &cryptodev_chacha20_poly1305_testsuite,
15078 &cryptodev_zuc_testsuite,
15079 &cryptodev_hmac_md5_auth_testsuite,
15080 &cryptodev_kasumi_testsuite,
15081 &cryptodev_esn_testsuite,
15082 &cryptodev_negative_aes_gcm_testsuite,
15083 &cryptodev_negative_aes_gmac_testsuite,
15084 &cryptodev_mixed_cipher_hash_testsuite,
15085 &cryptodev_negative_hmac_sha1_testsuite,
15086 &cryptodev_gen_testsuite,
15087 #ifdef RTE_LIB_SECURITY
15088 &ipsec_proto_testsuite,
15089 &pdcp_proto_testsuite,
15090 &docsis_proto_testsuite,
15094 static struct unit_test_suite ts = {
15095 .suite_name = "Cryptodev Unit Test Suite",
15096 .setup = testsuite_setup,
15097 .teardown = testsuite_teardown,
15098 .unit_test_cases = {TEST_CASES_END()}
15101 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
15103 if (gbl_driver_id == -1) {
15104 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
15105 return TEST_SKIPPED;
15108 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15109 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
15111 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
15112 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15113 ret = unit_test_suite_runner(&ts);
15115 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
15116 free(ts.unit_test_suites);
15121 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
15123 struct rte_cryptodev_info dev_info;
15124 uint8_t i, nb_devs;
15127 driver_id = rte_cryptodev_driver_id_get(pmd_name);
15128 if (driver_id == -1) {
15129 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
15130 return TEST_SKIPPED;
15133 nb_devs = rte_cryptodev_count();
15135 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
15136 return TEST_SKIPPED;
15139 for (i = 0; i < nb_devs; i++) {
15140 rte_cryptodev_info_get(i, &dev_info);
15141 if (dev_info.driver_id == driver_id) {
15142 if (!(dev_info.feature_flags & flag)) {
15143 RTE_LOG(INFO, USER1, "%s not supported\n",
15145 return TEST_SKIPPED;
15147 return 0; /* found */
15151 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
15152 return TEST_SKIPPED;
15156 test_cryptodev_qat(void)
15158 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
15162 test_cryptodev_virtio(void)
15164 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
15168 test_cryptodev_aesni_mb(void)
15170 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15174 test_cryptodev_cpu_aesni_mb(void)
15177 enum rte_security_session_action_type at = gbl_action_type;
15178 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15179 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15180 gbl_action_type = at;
15185 test_cryptodev_openssl(void)
15187 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
15191 test_cryptodev_aesni_gcm(void)
15193 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15197 test_cryptodev_cpu_aesni_gcm(void)
15200 enum rte_security_session_action_type at = gbl_action_type;
15201 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15202 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15203 gbl_action_type = at;
15208 test_cryptodev_mlx5(void)
15210 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
15214 test_cryptodev_null(void)
15216 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
15220 test_cryptodev_sw_snow3g(void)
15222 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
15226 test_cryptodev_sw_kasumi(void)
15228 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
15232 test_cryptodev_sw_zuc(void)
15234 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
15238 test_cryptodev_armv8(void)
15240 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
15244 test_cryptodev_mrvl(void)
15246 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
15249 #ifdef RTE_CRYPTO_SCHEDULER
15252 test_cryptodev_scheduler(void)
15254 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
15255 const enum blockcipher_test_type blk_suites[] = {
15256 BLKCIPHER_AES_CHAIN_TYPE,
15257 BLKCIPHER_AES_CIPHERONLY_TYPE,
15258 BLKCIPHER_AUTHONLY_TYPE
15260 static struct unit_test_suite scheduler_multicore = {
15261 .suite_name = "Scheduler Multicore Unit Test Suite",
15262 .setup = scheduler_multicore_testsuite_setup,
15263 .teardown = scheduler_mode_testsuite_teardown,
15264 .unit_test_cases = {TEST_CASES_END()}
15266 static struct unit_test_suite scheduler_round_robin = {
15267 .suite_name = "Scheduler Round Robin Unit Test Suite",
15268 .setup = scheduler_roundrobin_testsuite_setup,
15269 .teardown = scheduler_mode_testsuite_teardown,
15270 .unit_test_cases = {TEST_CASES_END()}
15272 static struct unit_test_suite scheduler_failover = {
15273 .suite_name = "Scheduler Failover Unit Test Suite",
15274 .setup = scheduler_failover_testsuite_setup,
15275 .teardown = scheduler_mode_testsuite_teardown,
15276 .unit_test_cases = {TEST_CASES_END()}
15278 static struct unit_test_suite scheduler_pkt_size_distr = {
15279 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
15280 .setup = scheduler_pkt_size_distr_testsuite_setup,
15281 .teardown = scheduler_mode_testsuite_teardown,
15282 .unit_test_cases = {TEST_CASES_END()}
15284 struct unit_test_suite *sched_mode_suites[] = {
15285 &scheduler_multicore,
15286 &scheduler_round_robin,
15287 &scheduler_failover,
15288 &scheduler_pkt_size_distr
15290 static struct unit_test_suite scheduler_config = {
15291 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
15292 .unit_test_cases = {
15293 TEST_CASE(test_scheduler_attach_worker_op),
15294 TEST_CASE(test_scheduler_mode_multicore_op),
15295 TEST_CASE(test_scheduler_mode_roundrobin_op),
15296 TEST_CASE(test_scheduler_mode_failover_op),
15297 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
15298 TEST_CASE(test_scheduler_detach_worker_op),
15300 TEST_CASES_END() /**< NULL terminate array */
15303 struct unit_test_suite *static_suites[] = {
15307 static struct unit_test_suite ts = {
15308 .suite_name = "Scheduler Unit Test Suite",
15309 .setup = scheduler_testsuite_setup,
15310 .teardown = testsuite_teardown,
15311 .unit_test_cases = {TEST_CASES_END()}
15314 gbl_driver_id = rte_cryptodev_driver_id_get(
15315 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15317 if (gbl_driver_id == -1) {
15318 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
15319 return TEST_SKIPPED;
15322 if (rte_cryptodev_driver_id_get(
15323 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
15324 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
15325 return TEST_SKIPPED;
15328 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15330 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
15331 (struct unit_test_suite *) *
15332 (RTE_DIM(blk_suites) + 1));
15333 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
15334 blk_suites, RTE_DIM(blk_suites));
15335 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
15338 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15339 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
15340 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
15341 RTE_DIM(sched_mode_suites));
15342 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15343 ret = unit_test_suite_runner(&ts);
15345 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15346 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
15347 (*sched_mode_suites[sched_i]),
15348 RTE_DIM(blk_suites));
15349 free(sched_mode_suites[sched_i]->unit_test_suites);
15351 free(ts.unit_test_suites);
15355 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
15360 test_cryptodev_dpaa2_sec(void)
15362 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
15366 test_cryptodev_dpaa_sec(void)
15368 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
15372 test_cryptodev_ccp(void)
15374 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
15378 test_cryptodev_octeontx(void)
15380 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
15384 test_cryptodev_octeontx2(void)
15386 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
15390 test_cryptodev_caam_jr(void)
15392 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
15396 test_cryptodev_nitrox(void)
15398 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
15402 test_cryptodev_bcmfs(void)
15404 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
15408 test_cryptodev_qat_raw_api(void)
15410 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
15413 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15418 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15419 ret = run_cryptodev_testsuite(pmd_name);
15420 global_api_test_type = CRYPTODEV_API_TEST;
15426 test_cryptodev_cn9k(void)
15428 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
15432 test_cryptodev_cn10k(void)
15434 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
15437 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
15438 test_cryptodev_qat_raw_api);
15439 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
15440 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
15441 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
15442 test_cryptodev_cpu_aesni_mb);
15443 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
15444 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
15445 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
15446 test_cryptodev_cpu_aesni_gcm);
15447 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
15448 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
15449 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
15450 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
15451 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
15452 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
15453 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
15454 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
15455 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
15456 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
15457 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
15458 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
15459 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
15460 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
15461 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
15462 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
15463 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
15464 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);