1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
20 #include <rte_string_fns.h>
24 #ifdef RTE_CRYPTO_SCHEDULER
25 #include <rte_cryptodev_scheduler.h>
26 #include <rte_cryptodev_scheduler_operations.h>
29 #include <rte_lcore.h>
32 #include "test_cryptodev.h"
34 #include "test_cryptodev_blockcipher.h"
35 #include "test_cryptodev_aes_test_vectors.h"
36 #include "test_cryptodev_des_test_vectors.h"
37 #include "test_cryptodev_hash_test_vectors.h"
38 #include "test_cryptodev_kasumi_test_vectors.h"
39 #include "test_cryptodev_kasumi_hash_test_vectors.h"
40 #include "test_cryptodev_snow3g_test_vectors.h"
41 #include "test_cryptodev_snow3g_hash_test_vectors.h"
42 #include "test_cryptodev_zuc_test_vectors.h"
43 #include "test_cryptodev_aead_test_vectors.h"
44 #include "test_cryptodev_hmac_test_vectors.h"
45 #include "test_cryptodev_mixed_test_vectors.h"
46 #ifdef RTE_LIB_SECURITY
47 #include "test_cryptodev_security_ipsec.h"
48 #include "test_cryptodev_security_ipsec_test_vectors.h"
49 #include "test_cryptodev_security_pdcp_test_vectors.h"
50 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
51 #include "test_cryptodev_security_pdcp_test_func.h"
52 #include "test_cryptodev_security_docsis_test_vectors.h"
54 #define SDAP_DISABLED 0
55 #define SDAP_ENABLED 1
58 #define VDEV_ARGS_SIZE 100
59 #define MAX_NB_SESSIONS 4
61 #define MAX_DRV_SERVICE_CTX_SIZE 256
63 #define MAX_RAW_DEQUEUE_COUNT 65535
66 #define OUT_OF_PLACE 1
68 static int gbl_driver_id;
70 static enum rte_security_session_action_type gbl_action_type =
71 RTE_SECURITY_ACTION_TYPE_NONE;
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 struct crypto_unittest_params {
76 struct rte_crypto_sym_xform cipher_xform;
77 struct rte_crypto_sym_xform auth_xform;
78 struct rte_crypto_sym_xform aead_xform;
79 #ifdef RTE_LIB_SECURITY
80 struct rte_security_docsis_xform docsis_xform;
84 struct rte_cryptodev_sym_session *sess;
85 #ifdef RTE_LIB_SECURITY
86 struct rte_security_session *sec_session;
89 #ifdef RTE_LIB_SECURITY
90 enum rte_security_session_action_type type;
92 struct rte_crypto_op *op;
94 struct rte_mbuf *obuf, *ibuf;
99 #define ALIGN_POW2_ROUNDUP(num, align) \
100 (((num) + (align) - 1) & ~((align) - 1))
102 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
103 for (j = 0; j < num_child_ts; index++, j++) \
104 parent_ts.unit_test_suites[index] = child_ts[j]
106 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
107 for (j = 0; j < num_blk_types; index++, j++) \
108 parent_ts.unit_test_suites[index] = \
109 build_blockcipher_test_suite(blk_types[j])
111 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
112 for (j = index; j < index + num_blk_types; j++) \
113 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
116 * Forward declarations.
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 struct crypto_unittest_params *ut_params,
126 struct crypto_testsuite_params *ts_param,
127 const uint8_t *cipher,
128 const uint8_t *digest,
132 security_proto_supported(enum rte_security_session_action_type action,
133 enum rte_security_session_protocol proto);
136 dev_configure_and_start(uint64_t ff_disable);
138 static struct rte_mbuf *
139 setup_test_string(struct rte_mempool *mpool,
140 const char *string, size_t len, uint8_t blocksize)
142 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
143 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
148 memset(m->buf_addr, 0, m->buf_len);
149 dst = rte_pktmbuf_append(m, t_len);
155 rte_memcpy(dst, string, t_len);
157 memset(dst, 0, t_len);
163 /* Get number of bytes in X bits (rounding up) */
165 ceil_byte_length(uint32_t num_bits)
168 return ((num_bits >> 3) + 1);
170 return (num_bits >> 3);
174 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
175 uint8_t is_op_success)
177 struct rte_crypto_op *op = user_data;
178 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
179 RTE_CRYPTO_OP_STATUS_ERROR;
183 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
184 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
185 uint8_t len_in_bits, uint8_t cipher_iv_len)
187 struct rte_crypto_sym_op *sop = op->sym;
188 struct rte_crypto_op *ret_op = NULL;
189 struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
190 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
191 union rte_crypto_sym_ofs ofs;
192 struct rte_crypto_sym_vec vec;
193 struct rte_crypto_sgl sgl, dest_sgl;
195 union rte_cryptodev_session_ctx sess;
197 struct rte_crypto_raw_dp_ctx *ctx;
198 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
202 int ctx_service_size;
204 int enqueue_status, dequeue_status;
206 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
207 if (ctx_service_size < 0) {
208 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
212 ctx = malloc(ctx_service_size);
214 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
218 /* Both are enums, setting crypto_sess will suit any session type */
219 sess.crypto_sess = op->sym->session;
221 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
222 op->sess_type, sess, 0) < 0) {
223 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
229 aad_auth_iv.iova = 0;
230 aad_auth_iv.va = NULL;
237 vec.digest = &digest;
238 vec.aad = &aad_auth_iv;
239 vec.status = &status;
243 if (is_cipher && is_auth) {
244 cipher_offset = sop->cipher.data.offset;
245 cipher_len = sop->cipher.data.length;
246 auth_offset = sop->auth.data.offset;
247 auth_len = sop->auth.data.length;
248 max_len = RTE_MAX(cipher_offset + cipher_len,
249 auth_offset + auth_len);
251 max_len = max_len >> 3;
252 cipher_offset = cipher_offset >> 3;
253 auth_offset = auth_offset >> 3;
254 cipher_len = cipher_len >> 3;
255 auth_len = auth_len >> 3;
257 ofs.ofs.cipher.head = cipher_offset;
258 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
259 ofs.ofs.auth.head = auth_offset;
260 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
261 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
262 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
263 aad_auth_iv.va = rte_crypto_op_ctod_offset(
264 op, void *, IV_OFFSET + cipher_iv_len);
265 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
267 digest.va = (void *)sop->auth.digest.data;
268 digest.iova = sop->auth.digest.phys_addr;
270 } else if (is_cipher) {
271 cipher_offset = sop->cipher.data.offset;
272 cipher_len = sop->cipher.data.length;
273 max_len = cipher_len + cipher_offset;
275 max_len = max_len >> 3;
276 cipher_offset = cipher_offset >> 3;
277 cipher_len = cipher_len >> 3;
279 ofs.ofs.cipher.head = cipher_offset;
280 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
281 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
282 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
284 } else if (is_auth) {
285 auth_offset = sop->auth.data.offset;
286 auth_len = sop->auth.data.length;
287 max_len = auth_len + auth_offset;
289 max_len = max_len >> 3;
290 auth_offset = auth_offset >> 3;
291 auth_len = auth_len >> 3;
293 ofs.ofs.auth.head = auth_offset;
294 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
295 aad_auth_iv.va = rte_crypto_op_ctod_offset(
296 op, void *, IV_OFFSET + cipher_iv_len);
297 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
299 digest.va = (void *)sop->auth.digest.data;
300 digest.iova = sop->auth.digest.phys_addr;
303 cipher_offset = sop->aead.data.offset;
304 cipher_len = sop->aead.data.length;
305 max_len = cipher_len + cipher_offset;
307 max_len = max_len >> 3;
308 cipher_offset = cipher_offset >> 3;
309 cipher_len = cipher_len >> 3;
311 ofs.ofs.cipher.head = cipher_offset;
312 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
313 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
314 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
315 aad_auth_iv.va = (void *)sop->aead.aad.data;
316 aad_auth_iv.iova = sop->aead.aad.phys_addr;
317 digest.va = (void *)sop->aead.digest.data;
318 digest.iova = sop->aead.digest.phys_addr;
321 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
322 data_vec, RTE_DIM(data_vec));
323 if (n < 0 || n > sop->m_src->nb_segs) {
324 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
330 if (sop->m_dst != NULL) {
331 dest_sgl.vec = dest_data_vec;
332 vec.dest_sgl = &dest_sgl;
333 n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
334 dest_data_vec, RTE_DIM(dest_data_vec));
335 if (n < 0 || n > sop->m_dst->nb_segs) {
336 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
343 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
344 &enqueue_status) < 1) {
345 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
349 if (enqueue_status == 0) {
350 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
352 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
355 } else if (enqueue_status < 0) {
356 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
361 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
362 n = rte_cryptodev_raw_dequeue_burst(ctx,
363 NULL, 1, post_process_raw_dp_op,
364 (void **)&ret_op, 0, &n_success,
366 if (dequeue_status < 0) {
367 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
374 if (n == 1 && dequeue_status == 0) {
375 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
376 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
381 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
382 ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
383 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
384 RTE_CRYPTO_OP_STATUS_SUCCESS;
391 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
394 struct rte_crypto_sym_op *sop;
395 union rte_crypto_sym_ofs ofs;
396 struct rte_crypto_sgl sgl;
397 struct rte_crypto_sym_vec symvec;
398 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
399 struct rte_crypto_vec vec[UINT8_MAX];
403 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
404 sop->aead.data.length, vec, RTE_DIM(vec));
406 if (n < 0 || n != sop->m_src->nb_segs) {
407 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
413 symvec.src_sgl = &sgl;
415 symvec.digest = &digest_ptr;
416 symvec.aad = &aad_ptr;
420 /* for CPU crypto the IOVA address is not required */
421 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
422 digest_ptr.va = (void *)sop->aead.digest.data;
423 aad_ptr.va = (void *)sop->aead.aad.data;
427 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
431 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
433 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
437 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
440 struct rte_crypto_sym_op *sop;
441 union rte_crypto_sym_ofs ofs;
442 struct rte_crypto_sgl sgl;
443 struct rte_crypto_sym_vec symvec;
444 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
445 struct rte_crypto_vec vec[UINT8_MAX];
449 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
450 sop->auth.data.length, vec, RTE_DIM(vec));
452 if (n < 0 || n != sop->m_src->nb_segs) {
453 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
459 symvec.src_sgl = &sgl;
461 symvec.digest = &digest_ptr;
465 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
466 digest_ptr.va = (void *)sop->auth.digest.data;
469 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
470 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
471 (sop->cipher.data.offset + sop->cipher.data.length);
473 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
477 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
479 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
482 static struct rte_crypto_op *
483 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
486 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
488 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
489 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
495 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
498 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
499 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
506 static struct crypto_testsuite_params testsuite_params = { NULL };
507 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
508 static struct crypto_unittest_params unittest_params;
511 testsuite_setup(void)
513 struct crypto_testsuite_params *ts_params = &testsuite_params;
514 struct rte_cryptodev_info info;
515 uint32_t i = 0, nb_devs, dev_id;
518 memset(ts_params, 0, sizeof(*ts_params));
520 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
521 if (ts_params->mbuf_pool == NULL) {
522 /* Not already created so create */
523 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
525 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
527 if (ts_params->mbuf_pool == NULL) {
528 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
533 ts_params->large_mbuf_pool = rte_mempool_lookup(
534 "CRYPTO_LARGE_MBUFPOOL");
535 if (ts_params->large_mbuf_pool == NULL) {
536 /* Not already created so create */
537 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
538 "CRYPTO_LARGE_MBUFPOOL",
541 if (ts_params->large_mbuf_pool == NULL) {
543 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
548 ts_params->op_mpool = rte_crypto_op_pool_create(
549 "MBUF_CRYPTO_SYM_OP_POOL",
550 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
551 NUM_MBUFS, MBUF_CACHE_SIZE,
553 sizeof(struct rte_crypto_sym_xform) +
556 if (ts_params->op_mpool == NULL) {
557 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
561 nb_devs = rte_cryptodev_count();
563 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
567 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
568 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
569 rte_cryptodev_driver_name_get(gbl_driver_id));
573 /* Create list of valid crypto devs */
574 for (i = 0; i < nb_devs; i++) {
575 rte_cryptodev_info_get(i, &info);
576 if (info.driver_id == gbl_driver_id)
577 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
580 if (ts_params->valid_dev_count < 1)
583 /* Set up all the qps on the first of the valid devices found */
585 dev_id = ts_params->valid_devs[0];
587 rte_cryptodev_info_get(dev_id, &info);
589 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
590 ts_params->conf.socket_id = SOCKET_ID_ANY;
591 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
593 unsigned int session_size =
594 rte_cryptodev_sym_get_private_session_size(dev_id);
596 #ifdef RTE_LIB_SECURITY
597 unsigned int security_session_size = rte_security_session_get_size(
598 rte_cryptodev_get_sec_ctx(dev_id));
600 if (session_size < security_session_size)
601 session_size = security_session_size;
604 * Create mempool with maximum number of sessions.
606 if (info.sym.max_nb_sessions != 0 &&
607 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
608 RTE_LOG(ERR, USER1, "Device does not support "
609 "at least %u sessions\n",
614 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
615 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
617 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
618 "session mempool allocation failed");
620 ts_params->session_priv_mpool = rte_mempool_create(
624 0, 0, NULL, NULL, NULL,
627 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
628 "session mempool allocation failed");
632 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
634 "Failed to configure cryptodev %u with %u qps",
635 dev_id, ts_params->conf.nb_queue_pairs);
637 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
638 ts_params->qp_conf.mp_session = ts_params->session_mpool;
639 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
641 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
642 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
643 dev_id, qp_id, &ts_params->qp_conf,
644 rte_cryptodev_socket_id(dev_id)),
645 "Failed to setup queue pair %u on cryptodev %u",
653 testsuite_teardown(void)
655 struct crypto_testsuite_params *ts_params = &testsuite_params;
658 if (ts_params->mbuf_pool != NULL) {
659 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
660 rte_mempool_avail_count(ts_params->mbuf_pool));
663 if (ts_params->op_mpool != NULL) {
664 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
665 rte_mempool_avail_count(ts_params->op_mpool));
668 /* Free session mempools */
669 if (ts_params->session_priv_mpool != NULL) {
670 rte_mempool_free(ts_params->session_priv_mpool);
671 ts_params->session_priv_mpool = NULL;
674 if (ts_params->session_mpool != NULL) {
675 rte_mempool_free(ts_params->session_mpool);
676 ts_params->session_mpool = NULL;
679 res = rte_cryptodev_close(ts_params->valid_devs[0]);
681 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
685 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
686 const int *algs, uint16_t num_algs)
688 uint8_t dev_id = testsuite_params.valid_devs[0];
689 bool some_alg_supported = FALSE;
692 for (i = 0; i < num_algs && !some_alg_supported; i++) {
693 struct rte_cryptodev_sym_capability_idx alg = {
696 if (rte_cryptodev_sym_capability_get(dev_id,
698 some_alg_supported = TRUE;
700 if (!some_alg_supported)
707 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
708 uint16_t num_ciphers)
710 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
711 (const int *) ciphers, num_ciphers);
715 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
718 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
719 (const int *) auths, num_auths);
723 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
726 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
727 (const int *) aeads, num_aeads);
731 null_testsuite_setup(void)
733 struct crypto_testsuite_params *ts_params = &testsuite_params;
734 uint8_t dev_id = ts_params->valid_devs[0];
735 struct rte_cryptodev_info dev_info;
736 const enum rte_crypto_cipher_algorithm ciphers[] = {
737 RTE_CRYPTO_CIPHER_NULL
739 const enum rte_crypto_auth_algorithm auths[] = {
743 rte_cryptodev_info_get(dev_id, &dev_info);
745 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
746 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
747 "testsuite not met\n");
751 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
752 && check_auth_capabilities_supported(auths,
753 RTE_DIM(auths)) != 0) {
754 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
755 "testsuite not met\n");
763 crypto_gen_testsuite_setup(void)
765 struct crypto_testsuite_params *ts_params = &testsuite_params;
766 uint8_t dev_id = ts_params->valid_devs[0];
767 struct rte_cryptodev_info dev_info;
769 rte_cryptodev_info_get(dev_id, &dev_info);
771 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
772 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
773 "testsuite not met\n");
780 #ifdef RTE_LIB_SECURITY
782 ipsec_proto_testsuite_setup(void)
784 struct crypto_testsuite_params *ts_params = &testsuite_params;
785 struct crypto_unittest_params *ut_params = &unittest_params;
786 struct rte_cryptodev_info dev_info;
789 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
791 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
792 RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
793 "testsuite not met\n");
797 /* Reconfigure to enable security */
798 ret = dev_configure_and_start(0);
799 if (ret != TEST_SUCCESS)
802 /* Set action type */
803 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
805 if (security_proto_supported(
806 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
807 RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
808 RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
814 * Stop the device. Device would be started again by individual test
815 * case setup routine.
817 rte_cryptodev_stop(ts_params->valid_devs[0]);
823 pdcp_proto_testsuite_setup(void)
825 struct crypto_testsuite_params *ts_params = &testsuite_params;
826 uint8_t dev_id = ts_params->valid_devs[0];
827 struct rte_cryptodev_info dev_info;
828 const enum rte_crypto_cipher_algorithm ciphers[] = {
829 RTE_CRYPTO_CIPHER_NULL,
830 RTE_CRYPTO_CIPHER_AES_CTR,
831 RTE_CRYPTO_CIPHER_ZUC_EEA3,
832 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
834 const enum rte_crypto_auth_algorithm auths[] = {
835 RTE_CRYPTO_AUTH_NULL,
836 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
837 RTE_CRYPTO_AUTH_AES_CMAC,
838 RTE_CRYPTO_AUTH_ZUC_EIA3
841 rte_cryptodev_info_get(dev_id, &dev_info);
843 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
844 !(dev_info.feature_flags &
845 RTE_CRYPTODEV_FF_SECURITY)) {
846 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
847 "testsuite not met\n");
851 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
852 && check_auth_capabilities_supported(auths,
853 RTE_DIM(auths)) != 0) {
854 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
855 "testsuite not met\n");
863 docsis_proto_testsuite_setup(void)
865 struct crypto_testsuite_params *ts_params = &testsuite_params;
866 uint8_t dev_id = ts_params->valid_devs[0];
867 struct rte_cryptodev_info dev_info;
868 const enum rte_crypto_cipher_algorithm ciphers[] = {
869 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
872 rte_cryptodev_info_get(dev_id, &dev_info);
874 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
875 !(dev_info.feature_flags &
876 RTE_CRYPTODEV_FF_SECURITY)) {
877 RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
878 "Proto testsuite not met\n");
882 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
883 RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
884 "testsuite not met\n");
893 aes_ccm_auth_testsuite_setup(void)
895 struct crypto_testsuite_params *ts_params = &testsuite_params;
896 uint8_t dev_id = ts_params->valid_devs[0];
897 struct rte_cryptodev_info dev_info;
898 const enum rte_crypto_aead_algorithm aeads[] = {
899 RTE_CRYPTO_AEAD_AES_CCM
902 rte_cryptodev_info_get(dev_id, &dev_info);
904 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
905 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
906 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
907 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
908 "testsuite not met\n");
912 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
913 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
914 "testsuite not met\n");
922 aes_gcm_auth_testsuite_setup(void)
924 struct crypto_testsuite_params *ts_params = &testsuite_params;
925 uint8_t dev_id = ts_params->valid_devs[0];
926 struct rte_cryptodev_info dev_info;
927 const enum rte_crypto_aead_algorithm aeads[] = {
928 RTE_CRYPTO_AEAD_AES_GCM
931 rte_cryptodev_info_get(dev_id, &dev_info);
933 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
934 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
935 "testsuite not met\n");
939 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
940 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
941 "testsuite not met\n");
949 aes_gmac_auth_testsuite_setup(void)
951 struct crypto_testsuite_params *ts_params = &testsuite_params;
952 uint8_t dev_id = ts_params->valid_devs[0];
953 struct rte_cryptodev_info dev_info;
954 const enum rte_crypto_auth_algorithm auths[] = {
955 RTE_CRYPTO_AUTH_AES_GMAC
958 rte_cryptodev_info_get(dev_id, &dev_info);
960 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
961 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
962 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
963 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
964 "testsuite not met\n");
968 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
969 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
970 "testsuite not met\n");
978 chacha20_poly1305_testsuite_setup(void)
980 struct crypto_testsuite_params *ts_params = &testsuite_params;
981 uint8_t dev_id = ts_params->valid_devs[0];
982 struct rte_cryptodev_info dev_info;
983 const enum rte_crypto_aead_algorithm aeads[] = {
984 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
987 rte_cryptodev_info_get(dev_id, &dev_info);
989 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
990 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
991 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
992 RTE_LOG(INFO, USER1, "Feature flag requirements for "
993 "Chacha20-Poly1305 testsuite not met\n");
997 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
998 RTE_LOG(INFO, USER1, "Capability requirements for "
999 "Chacha20-Poly1305 testsuite not met\n");
1000 return TEST_SKIPPED;
1007 snow3g_testsuite_setup(void)
1009 struct crypto_testsuite_params *ts_params = &testsuite_params;
1010 uint8_t dev_id = ts_params->valid_devs[0];
1011 struct rte_cryptodev_info dev_info;
1012 const enum rte_crypto_cipher_algorithm ciphers[] = {
1013 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1016 const enum rte_crypto_auth_algorithm auths[] = {
1017 RTE_CRYPTO_AUTH_SNOW3G_UIA2
1020 rte_cryptodev_info_get(dev_id, &dev_info);
1022 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1023 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1024 "testsuite not met\n");
1025 return TEST_SKIPPED;
1028 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1029 && check_auth_capabilities_supported(auths,
1030 RTE_DIM(auths)) != 0) {
1031 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1032 "testsuite not met\n");
1033 return TEST_SKIPPED;
1040 zuc_testsuite_setup(void)
1042 struct crypto_testsuite_params *ts_params = &testsuite_params;
1043 uint8_t dev_id = ts_params->valid_devs[0];
1044 struct rte_cryptodev_info dev_info;
1045 const enum rte_crypto_cipher_algorithm ciphers[] = {
1046 RTE_CRYPTO_CIPHER_ZUC_EEA3
1048 const enum rte_crypto_auth_algorithm auths[] = {
1049 RTE_CRYPTO_AUTH_ZUC_EIA3
1052 rte_cryptodev_info_get(dev_id, &dev_info);
1054 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1055 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1056 "testsuite not met\n");
1057 return TEST_SKIPPED;
1060 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1061 && check_auth_capabilities_supported(auths,
1062 RTE_DIM(auths)) != 0) {
1063 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1064 "testsuite not met\n");
1065 return TEST_SKIPPED;
1072 hmac_md5_auth_testsuite_setup(void)
1074 struct crypto_testsuite_params *ts_params = &testsuite_params;
1075 uint8_t dev_id = ts_params->valid_devs[0];
1076 struct rte_cryptodev_info dev_info;
1077 const enum rte_crypto_auth_algorithm auths[] = {
1078 RTE_CRYPTO_AUTH_MD5_HMAC
1081 rte_cryptodev_info_get(dev_id, &dev_info);
1083 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1084 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1085 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1086 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1087 "Auth testsuite not met\n");
1088 return TEST_SKIPPED;
1091 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1092 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1093 "testsuite not met\n");
1094 return TEST_SKIPPED;
1101 kasumi_testsuite_setup(void)
1103 struct crypto_testsuite_params *ts_params = &testsuite_params;
1104 uint8_t dev_id = ts_params->valid_devs[0];
1105 struct rte_cryptodev_info dev_info;
1106 const enum rte_crypto_cipher_algorithm ciphers[] = {
1107 RTE_CRYPTO_CIPHER_KASUMI_F8
1109 const enum rte_crypto_auth_algorithm auths[] = {
1110 RTE_CRYPTO_AUTH_KASUMI_F9
1113 rte_cryptodev_info_get(dev_id, &dev_info);
1115 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1116 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1117 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1118 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1119 "testsuite not met\n");
1120 return TEST_SKIPPED;
1123 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1124 && check_auth_capabilities_supported(auths,
1125 RTE_DIM(auths)) != 0) {
1126 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1127 "testsuite not met\n");
1128 return TEST_SKIPPED;
1135 negative_aes_gcm_testsuite_setup(void)
1137 struct crypto_testsuite_params *ts_params = &testsuite_params;
1138 uint8_t dev_id = ts_params->valid_devs[0];
1139 struct rte_cryptodev_info dev_info;
1140 const enum rte_crypto_aead_algorithm aeads[] = {
1141 RTE_CRYPTO_AEAD_AES_GCM
1144 rte_cryptodev_info_get(dev_id, &dev_info);
1146 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1147 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1148 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1149 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1150 "AES GCM testsuite not met\n");
1151 return TEST_SKIPPED;
1154 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1155 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1156 "AES GCM testsuite not met\n");
1157 return TEST_SKIPPED;
1164 negative_aes_gmac_testsuite_setup(void)
1166 struct crypto_testsuite_params *ts_params = &testsuite_params;
1167 uint8_t dev_id = ts_params->valid_devs[0];
1168 struct rte_cryptodev_info dev_info;
1169 const enum rte_crypto_auth_algorithm auths[] = {
1170 RTE_CRYPTO_AUTH_AES_GMAC
1173 rte_cryptodev_info_get(dev_id, &dev_info);
1175 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1176 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1177 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1178 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1179 "AES GMAC testsuite not met\n");
1180 return TEST_SKIPPED;
1183 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1184 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1185 "AES GMAC testsuite not met\n");
1186 return TEST_SKIPPED;
1193 mixed_cipher_hash_testsuite_setup(void)
1195 struct crypto_testsuite_params *ts_params = &testsuite_params;
1196 uint8_t dev_id = ts_params->valid_devs[0];
1197 struct rte_cryptodev_info dev_info;
1198 uint64_t feat_flags;
1199 const enum rte_crypto_cipher_algorithm ciphers[] = {
1200 RTE_CRYPTO_CIPHER_NULL,
1201 RTE_CRYPTO_CIPHER_AES_CTR,
1202 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1203 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1205 const enum rte_crypto_auth_algorithm auths[] = {
1206 RTE_CRYPTO_AUTH_NULL,
1207 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1208 RTE_CRYPTO_AUTH_AES_CMAC,
1209 RTE_CRYPTO_AUTH_ZUC_EIA3
1212 rte_cryptodev_info_get(dev_id, &dev_info);
1213 feat_flags = dev_info.feature_flags;
1215 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1216 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1217 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1218 "Cipher Hash testsuite not met\n");
1219 return TEST_SKIPPED;
1222 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1223 && check_auth_capabilities_supported(auths,
1224 RTE_DIM(auths)) != 0) {
1225 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1226 "Cipher Hash testsuite not met\n");
1227 return TEST_SKIPPED;
1234 esn_testsuite_setup(void)
1236 struct crypto_testsuite_params *ts_params = &testsuite_params;
1237 uint8_t dev_id = ts_params->valid_devs[0];
1238 struct rte_cryptodev_info dev_info;
1239 const enum rte_crypto_cipher_algorithm ciphers[] = {
1240 RTE_CRYPTO_CIPHER_AES_CBC
1242 const enum rte_crypto_auth_algorithm auths[] = {
1243 RTE_CRYPTO_AUTH_SHA1_HMAC
1246 rte_cryptodev_info_get(dev_id, &dev_info);
1248 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1249 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1250 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1251 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1252 "testsuite not met\n");
1253 return TEST_SKIPPED;
1256 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1257 && check_auth_capabilities_supported(auths,
1258 RTE_DIM(auths)) != 0) {
1259 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1260 "testsuite not met\n");
1261 return TEST_SKIPPED;
1268 multi_session_testsuite_setup(void)
1270 struct crypto_testsuite_params *ts_params = &testsuite_params;
1271 uint8_t dev_id = ts_params->valid_devs[0];
1272 struct rte_cryptodev_info dev_info;
1273 const enum rte_crypto_cipher_algorithm ciphers[] = {
1274 RTE_CRYPTO_CIPHER_AES_CBC
1276 const enum rte_crypto_auth_algorithm auths[] = {
1277 RTE_CRYPTO_AUTH_SHA512_HMAC
1280 rte_cryptodev_info_get(dev_id, &dev_info);
1282 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1283 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1284 "Session testsuite not met\n");
1285 return TEST_SKIPPED;
1288 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1289 && check_auth_capabilities_supported(auths,
1290 RTE_DIM(auths)) != 0) {
1291 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1292 "Session testsuite not met\n");
1293 return TEST_SKIPPED;
1300 negative_hmac_sha1_testsuite_setup(void)
1302 struct crypto_testsuite_params *ts_params = &testsuite_params;
1303 uint8_t dev_id = ts_params->valid_devs[0];
1304 struct rte_cryptodev_info dev_info;
1305 const enum rte_crypto_cipher_algorithm ciphers[] = {
1306 RTE_CRYPTO_CIPHER_AES_CBC
1308 const enum rte_crypto_auth_algorithm auths[] = {
1309 RTE_CRYPTO_AUTH_SHA1_HMAC
1312 rte_cryptodev_info_get(dev_id, &dev_info);
1314 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1315 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1316 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1317 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1318 "HMAC SHA1 testsuite not met\n");
1319 return TEST_SKIPPED;
1322 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1323 && check_auth_capabilities_supported(auths,
1324 RTE_DIM(auths)) != 0) {
1325 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1326 "HMAC SHA1 testsuite not met\n");
1327 return TEST_SKIPPED;
1334 dev_configure_and_start(uint64_t ff_disable)
1336 struct crypto_testsuite_params *ts_params = &testsuite_params;
1337 struct crypto_unittest_params *ut_params = &unittest_params;
1341 /* Clear unit test parameters before running test */
1342 memset(ut_params, 0, sizeof(*ut_params));
1344 /* Reconfigure device to default parameters */
1345 ts_params->conf.socket_id = SOCKET_ID_ANY;
1346 ts_params->conf.ff_disable = ff_disable;
1347 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1348 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1349 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1351 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1353 "Failed to configure cryptodev %u",
1354 ts_params->valid_devs[0]);
1356 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1357 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1358 ts_params->valid_devs[0], qp_id,
1359 &ts_params->qp_conf,
1360 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1361 "Failed to setup queue pair %u on cryptodev %u",
1362 qp_id, ts_params->valid_devs[0]);
1366 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1368 /* Start the device */
1369 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1370 "Failed to start cryptodev %u",
1371 ts_params->valid_devs[0]);
1373 return TEST_SUCCESS;
1379 /* Configure and start the device with security feature disabled */
1380 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1384 ut_setup_security(void)
1386 /* Configure and start the device with no features disabled */
1387 return dev_configure_and_start(0);
1393 struct crypto_testsuite_params *ts_params = &testsuite_params;
1394 struct crypto_unittest_params *ut_params = &unittest_params;
1395 struct rte_cryptodev_stats stats;
1397 /* free crypto session structure */
1398 #ifdef RTE_LIB_SECURITY
1399 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1400 if (ut_params->sec_session) {
1401 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1402 (ts_params->valid_devs[0]),
1403 ut_params->sec_session);
1404 ut_params->sec_session = NULL;
1409 if (ut_params->sess) {
1410 rte_cryptodev_sym_session_clear(
1411 ts_params->valid_devs[0],
1413 rte_cryptodev_sym_session_free(ut_params->sess);
1414 ut_params->sess = NULL;
1418 /* free crypto operation structure */
1420 rte_crypto_op_free(ut_params->op);
1423 * free mbuf - both obuf and ibuf are usually the same,
1424 * so check if they point at the same address is necessary,
1425 * to avoid freeing the mbuf twice.
1427 if (ut_params->obuf) {
1428 rte_pktmbuf_free(ut_params->obuf);
1429 if (ut_params->ibuf == ut_params->obuf)
1430 ut_params->ibuf = 0;
1431 ut_params->obuf = 0;
1433 if (ut_params->ibuf) {
1434 rte_pktmbuf_free(ut_params->ibuf);
1435 ut_params->ibuf = 0;
1438 if (ts_params->mbuf_pool != NULL)
1439 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1440 rte_mempool_avail_count(ts_params->mbuf_pool));
1442 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1444 /* Stop the device */
1445 rte_cryptodev_stop(ts_params->valid_devs[0]);
1449 test_device_configure_invalid_dev_id(void)
1451 struct crypto_testsuite_params *ts_params = &testsuite_params;
1452 uint16_t dev_id, num_devs = 0;
1454 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1455 "Need at least %d devices for test", 1);
1457 /* valid dev_id values */
1458 dev_id = ts_params->valid_devs[0];
1460 /* Stop the device in case it's started so it can be configured */
1461 rte_cryptodev_stop(dev_id);
1463 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1464 "Failed test for rte_cryptodev_configure: "
1465 "invalid dev_num %u", dev_id);
1467 /* invalid dev_id values */
1470 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1471 "Failed test for rte_cryptodev_configure: "
1472 "invalid dev_num %u", dev_id);
1476 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1477 "Failed test for rte_cryptodev_configure:"
1478 "invalid dev_num %u", dev_id);
1480 return TEST_SUCCESS;
1484 test_device_configure_invalid_queue_pair_ids(void)
1486 struct crypto_testsuite_params *ts_params = &testsuite_params;
1487 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1489 /* Stop the device in case it's started so it can be configured */
1490 rte_cryptodev_stop(ts_params->valid_devs[0]);
1492 /* valid - max value queue pairs */
1493 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1495 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1497 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1498 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1500 /* valid - one queue pairs */
1501 ts_params->conf.nb_queue_pairs = 1;
1503 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1505 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1506 ts_params->valid_devs[0],
1507 ts_params->conf.nb_queue_pairs);
1510 /* invalid - zero queue pairs */
1511 ts_params->conf.nb_queue_pairs = 0;
1513 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1515 "Failed test for rte_cryptodev_configure, dev_id %u,"
1517 ts_params->valid_devs[0],
1518 ts_params->conf.nb_queue_pairs);
1521 /* invalid - max value supported by field queue pairs */
1522 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1524 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1526 "Failed test for rte_cryptodev_configure, dev_id %u,"
1528 ts_params->valid_devs[0],
1529 ts_params->conf.nb_queue_pairs);
1532 /* invalid - max value + 1 queue pairs */
1533 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1535 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1537 "Failed test for rte_cryptodev_configure, dev_id %u,"
1539 ts_params->valid_devs[0],
1540 ts_params->conf.nb_queue_pairs);
1542 /* revert to original testsuite value */
1543 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1545 return TEST_SUCCESS;
1549 test_queue_pair_descriptor_setup(void)
1551 struct crypto_testsuite_params *ts_params = &testsuite_params;
1552 struct rte_cryptodev_qp_conf qp_conf = {
1553 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1557 /* Stop the device in case it's started so it can be configured */
1558 rte_cryptodev_stop(ts_params->valid_devs[0]);
1560 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1562 "Failed to configure cryptodev %u",
1563 ts_params->valid_devs[0]);
1566 * Test various ring sizes on this device. memzones can't be
1567 * freed so are re-used if ring is released and re-created.
1569 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1570 qp_conf.mp_session = ts_params->session_mpool;
1571 qp_conf.mp_session_private = ts_params->session_priv_mpool;
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 = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
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 = MAX_NUM_OPS_INFLIGHT; /* valid */
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: num_inflights"
1608 " %u on qp %u on cryptodev %u",
1609 qp_conf.nb_descriptors, qp_id,
1610 ts_params->valid_devs[0]);
1613 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1615 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1616 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1617 ts_params->valid_devs[0], qp_id, &qp_conf,
1618 rte_cryptodev_socket_id(
1619 ts_params->valid_devs[0])),
1621 " rte_cryptodev_queue_pair_setup:"
1622 "num_inflights %u on qp %u on cryptodev %u",
1623 qp_conf.nb_descriptors, qp_id,
1624 ts_params->valid_devs[0]);
1627 /* test invalid queue pair id */
1628 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1630 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1632 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1633 ts_params->valid_devs[0],
1635 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1636 "Failed test for rte_cryptodev_queue_pair_setup:"
1637 "invalid qp %u on cryptodev %u",
1638 qp_id, ts_params->valid_devs[0]);
1640 qp_id = 0xffff; /*invalid*/
1642 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1643 ts_params->valid_devs[0],
1645 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1646 "Failed test for rte_cryptodev_queue_pair_setup:"
1647 "invalid qp %u on cryptodev %u",
1648 qp_id, ts_params->valid_devs[0]);
1650 return TEST_SUCCESS;
1653 /* ***** Plaintext data for tests ***** */
1655 const char catch_22_quote_1[] =
1656 "There was only one catch and that was Catch-22, which "
1657 "specified that a concern for one's safety in the face of "
1658 "dangers that were real and immediate was the process of a "
1659 "rational mind. Orr was crazy and could be grounded. All he "
1660 "had to do was ask; and as soon as he did, he would no longer "
1661 "be crazy and would have to fly more missions. Orr would be "
1662 "crazy to fly more missions and sane if he didn't, but if he "
1663 "was sane he had to fly them. If he flew them he was crazy "
1664 "and didn't have to; but if he didn't want to he was sane and "
1665 "had to. Yossarian was moved very deeply by the absolute "
1666 "simplicity of this clause of Catch-22 and let out a "
1667 "respectful whistle. \"That's some catch, that Catch-22\", he "
1668 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1670 const char catch_22_quote[] =
1671 "What a lousy earth! He wondered how many people were "
1672 "destitute that same night even in his own prosperous country, "
1673 "how many homes were shanties, how many husbands were drunk "
1674 "and wives socked, and how many children were bullied, abused, "
1675 "or abandoned. How many families hungered for food they could "
1676 "not afford to buy? How many hearts were broken? How many "
1677 "suicides would take place that same night, how many people "
1678 "would go insane? How many cockroaches and landlords would "
1679 "triumph? How many winners were losers, successes failures, "
1680 "and rich men poor men? How many wise guys were stupid? How "
1681 "many happy endings were unhappy endings? How many honest men "
1682 "were liars, brave men cowards, loyal men traitors, how many "
1683 "sainted men were corrupt, how many people in positions of "
1684 "trust had sold their souls to bodyguards, how many had never "
1685 "had souls? How many straight-and-narrow paths were crooked "
1686 "paths? How many best families were worst families and how "
1687 "many good people were bad people? When you added them all up "
1688 "and then subtracted, you might be left with only the children, "
1689 "and perhaps with Albert Einstein and an old violinist or "
1690 "sculptor somewhere.";
1692 #define QUOTE_480_BYTES (480)
1693 #define QUOTE_512_BYTES (512)
1694 #define QUOTE_768_BYTES (768)
1695 #define QUOTE_1024_BYTES (1024)
1699 /* ***** SHA1 Hash Tests ***** */
1701 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1703 static uint8_t hmac_sha1_key[] = {
1704 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1705 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1706 0xDE, 0xF4, 0xDE, 0xAD };
1708 /* ***** SHA224 Hash Tests ***** */
1710 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1713 /* ***** AES-CBC Cipher Tests ***** */
1715 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1716 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1718 static uint8_t aes_cbc_key[] = {
1719 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1720 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1722 static uint8_t aes_cbc_iv[] = {
1723 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1724 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1727 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1729 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1730 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1731 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1732 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1733 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1734 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1735 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1736 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1737 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1738 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1739 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1740 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1741 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1742 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1743 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1744 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1745 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1746 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1747 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1748 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1749 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1750 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1751 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1752 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1753 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1754 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1755 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1756 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1757 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1758 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1759 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1760 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1761 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1762 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1763 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1764 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1765 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1766 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1767 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1768 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1769 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1770 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1771 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1772 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1773 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1774 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1775 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1776 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1777 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1778 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1779 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1780 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1781 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1782 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1783 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1784 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1785 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1786 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1787 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1788 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1789 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1790 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1791 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1792 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1793 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1796 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1797 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1798 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1799 0x18, 0x8c, 0x1d, 0x32
1803 /* Multisession Vector context Test */
1804 /*Begin Session 0 */
1805 static uint8_t ms_aes_cbc_key0[] = {
1806 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1807 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1810 static uint8_t ms_aes_cbc_iv0[] = {
1811 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1812 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1815 static const uint8_t ms_aes_cbc_cipher0[] = {
1816 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1817 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1818 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1819 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1820 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1821 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1822 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1823 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1824 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1825 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1826 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1827 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1828 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1829 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1830 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1831 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1832 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1833 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1834 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1835 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1836 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1837 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1838 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1839 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1840 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1841 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1842 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1843 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1844 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1845 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1846 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1847 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1848 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1849 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1850 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1851 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1852 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1853 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1854 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1855 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1856 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1857 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1858 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1859 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1860 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1861 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1862 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1863 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1864 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1865 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1866 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1867 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1868 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1869 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1870 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1871 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1872 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1873 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1874 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1875 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1876 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1877 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1878 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1879 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1883 static uint8_t ms_hmac_key0[] = {
1884 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1885 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1886 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1887 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1888 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1889 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1890 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1891 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1894 static const uint8_t ms_hmac_digest0[] = {
1895 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1896 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1897 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1898 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1899 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1900 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1901 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1902 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1906 /* Begin session 1 */
1908 static uint8_t ms_aes_cbc_key1[] = {
1909 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1910 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1913 static uint8_t ms_aes_cbc_iv1[] = {
1914 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1915 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1918 static const uint8_t ms_aes_cbc_cipher1[] = {
1919 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1920 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1921 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1922 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1923 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1924 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1925 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1926 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1927 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1928 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1929 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1930 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1931 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1932 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1933 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1934 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1935 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1936 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1937 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1938 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1939 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1940 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1941 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1942 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1943 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1944 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1945 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1946 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1947 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1948 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1949 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1950 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1951 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1952 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1953 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1954 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1955 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1956 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1957 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1958 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1959 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1960 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1961 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1962 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1963 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1964 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1965 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1966 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1967 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1968 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1969 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1970 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1971 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1972 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1973 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1974 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1975 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1976 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1977 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1978 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1979 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1980 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1981 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1982 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1986 static uint8_t ms_hmac_key1[] = {
1987 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1988 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1989 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1990 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1991 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1992 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1993 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1994 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1997 static const uint8_t ms_hmac_digest1[] = {
1998 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1999 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2000 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2001 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2002 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2003 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2004 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2005 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2008 /* Begin Session 2 */
2009 static uint8_t ms_aes_cbc_key2[] = {
2010 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2011 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2014 static uint8_t ms_aes_cbc_iv2[] = {
2015 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2016 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2019 static const uint8_t ms_aes_cbc_cipher2[] = {
2020 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2021 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2022 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2023 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2024 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2025 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2026 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2027 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2028 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2029 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2030 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2031 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2032 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2033 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2034 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2035 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2036 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2037 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2038 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2039 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2040 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2041 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2042 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2043 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2044 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2045 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2046 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2047 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2048 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2049 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2050 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2051 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2052 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2053 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2054 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2055 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2056 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2057 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2058 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2059 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2060 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2061 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2062 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2063 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2064 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2065 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2066 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2067 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2068 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2069 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2070 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2071 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2072 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2073 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2074 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2075 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2076 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2077 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2078 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2079 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2080 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2081 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2082 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2083 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2086 static uint8_t ms_hmac_key2[] = {
2087 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2088 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2089 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2090 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2091 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2092 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2093 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2094 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2097 static const uint8_t ms_hmac_digest2[] = {
2098 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2099 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2100 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2101 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2102 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2103 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2104 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2105 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2112 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2114 struct crypto_testsuite_params *ts_params = &testsuite_params;
2115 struct crypto_unittest_params *ut_params = &unittest_params;
2117 /* Verify the capabilities */
2118 struct rte_cryptodev_sym_capability_idx cap_idx;
2119 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2120 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2121 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2123 return TEST_SKIPPED;
2124 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2125 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2126 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2128 return TEST_SKIPPED;
2130 /* Generate test mbuf data and space for digest */
2131 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2132 catch_22_quote, QUOTE_512_BYTES, 0);
2134 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2135 DIGEST_BYTE_LENGTH_SHA1);
2136 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2138 /* Setup Cipher Parameters */
2139 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2140 ut_params->cipher_xform.next = &ut_params->auth_xform;
2142 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2143 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2144 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2145 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2146 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2147 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2149 /* Setup HMAC Parameters */
2150 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2152 ut_params->auth_xform.next = NULL;
2154 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2155 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2156 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2157 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2158 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2160 ut_params->sess = rte_cryptodev_sym_session_create(
2161 ts_params->session_mpool);
2163 /* Create crypto session*/
2164 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2165 ut_params->sess, &ut_params->cipher_xform,
2166 ts_params->session_priv_mpool);
2167 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2169 /* Generate crypto op data structure */
2170 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2171 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2172 TEST_ASSERT_NOT_NULL(ut_params->op,
2173 "Failed to allocate symmetric crypto operation struct");
2175 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2177 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2179 /* set crypto operation source mbuf */
2180 sym_op->m_src = ut_params->ibuf;
2182 /* Set crypto operation authentication parameters */
2183 sym_op->auth.digest.data = ut_params->digest;
2184 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2185 ut_params->ibuf, QUOTE_512_BYTES);
2187 sym_op->auth.data.offset = 0;
2188 sym_op->auth.data.length = QUOTE_512_BYTES;
2190 /* Copy IV at the end of the crypto operation */
2191 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2192 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2194 /* Set crypto operation cipher parameters */
2195 sym_op->cipher.data.offset = 0;
2196 sym_op->cipher.data.length = QUOTE_512_BYTES;
2198 /* Process crypto operation */
2199 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2200 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2203 TEST_ASSERT_NOT_NULL(
2204 process_crypto_request(ts_params->valid_devs[0],
2206 "failed to process sym crypto op");
2208 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2209 "crypto op processing failed");
2212 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2215 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2216 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2218 "ciphertext data not as expected");
2220 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2222 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2223 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2224 gbl_driver_id == rte_cryptodev_driver_id_get(
2225 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2226 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2227 DIGEST_BYTE_LENGTH_SHA1,
2228 "Generated digest data not as expected");
2230 return TEST_SUCCESS;
2233 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2235 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2237 static uint8_t hmac_sha512_key[] = {
2238 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2239 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2240 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2241 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2242 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2243 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2244 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2245 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2247 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2248 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2249 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2250 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2251 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2252 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2253 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2254 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2255 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2260 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2261 struct crypto_unittest_params *ut_params,
2262 uint8_t *cipher_key,
2266 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2267 struct crypto_unittest_params *ut_params,
2268 struct crypto_testsuite_params *ts_params,
2269 const uint8_t *cipher,
2270 const uint8_t *digest,
2275 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2276 struct crypto_unittest_params *ut_params,
2277 uint8_t *cipher_key,
2281 /* Setup Cipher Parameters */
2282 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2283 ut_params->cipher_xform.next = NULL;
2285 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2286 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2287 ut_params->cipher_xform.cipher.key.data = cipher_key;
2288 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2289 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2290 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2292 /* Setup HMAC Parameters */
2293 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2294 ut_params->auth_xform.next = &ut_params->cipher_xform;
2296 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2297 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2298 ut_params->auth_xform.auth.key.data = hmac_key;
2299 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2300 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2302 return TEST_SUCCESS;
2307 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2308 struct crypto_unittest_params *ut_params,
2309 struct crypto_testsuite_params *ts_params,
2310 const uint8_t *cipher,
2311 const uint8_t *digest,
2314 /* Generate test mbuf data and digest */
2315 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2318 QUOTE_512_BYTES, 0);
2320 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2321 DIGEST_BYTE_LENGTH_SHA512);
2322 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2324 rte_memcpy(ut_params->digest,
2326 DIGEST_BYTE_LENGTH_SHA512);
2328 /* Generate Crypto op data structure */
2329 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2330 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2331 TEST_ASSERT_NOT_NULL(ut_params->op,
2332 "Failed to allocate symmetric crypto operation struct");
2334 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2336 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2338 /* set crypto operation source mbuf */
2339 sym_op->m_src = ut_params->ibuf;
2341 sym_op->auth.digest.data = ut_params->digest;
2342 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2343 ut_params->ibuf, QUOTE_512_BYTES);
2345 sym_op->auth.data.offset = 0;
2346 sym_op->auth.data.length = QUOTE_512_BYTES;
2348 /* Copy IV at the end of the crypto operation */
2349 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2350 iv, CIPHER_IV_LENGTH_AES_CBC);
2352 sym_op->cipher.data.offset = 0;
2353 sym_op->cipher.data.length = QUOTE_512_BYTES;
2355 /* Process crypto operation */
2356 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2357 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2359 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2360 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2361 ut_params->op, 1, 1, 0, 0);
2363 TEST_ASSERT_NOT_NULL(
2364 process_crypto_request(ts_params->valid_devs[0],
2366 "failed to process sym crypto op");
2368 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2369 "crypto op processing failed");
2371 ut_params->obuf = ut_params->op->sym->m_src;
2374 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2375 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2378 "Plaintext data not as expected");
2381 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2382 "Digest verification failed");
2384 return TEST_SUCCESS;
2387 /* ***** SNOW 3G Tests ***** */
2389 create_wireless_algo_hash_session(uint8_t dev_id,
2390 const uint8_t *key, const uint8_t key_len,
2391 const uint8_t iv_len, const uint8_t auth_len,
2392 enum rte_crypto_auth_operation op,
2393 enum rte_crypto_auth_algorithm algo)
2395 uint8_t hash_key[key_len];
2398 struct crypto_testsuite_params *ts_params = &testsuite_params;
2399 struct crypto_unittest_params *ut_params = &unittest_params;
2401 memcpy(hash_key, key, key_len);
2403 debug_hexdump(stdout, "key:", key, key_len);
2405 /* Setup Authentication Parameters */
2406 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2407 ut_params->auth_xform.next = NULL;
2409 ut_params->auth_xform.auth.op = op;
2410 ut_params->auth_xform.auth.algo = algo;
2411 ut_params->auth_xform.auth.key.length = key_len;
2412 ut_params->auth_xform.auth.key.data = hash_key;
2413 ut_params->auth_xform.auth.digest_length = auth_len;
2414 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2415 ut_params->auth_xform.auth.iv.length = iv_len;
2416 ut_params->sess = rte_cryptodev_sym_session_create(
2417 ts_params->session_mpool);
2419 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2420 &ut_params->auth_xform,
2421 ts_params->session_priv_mpool);
2422 if (status == -ENOTSUP)
2423 return TEST_SKIPPED;
2425 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2426 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2431 create_wireless_algo_cipher_session(uint8_t dev_id,
2432 enum rte_crypto_cipher_operation op,
2433 enum rte_crypto_cipher_algorithm algo,
2434 const uint8_t *key, const uint8_t key_len,
2437 uint8_t cipher_key[key_len];
2439 struct crypto_testsuite_params *ts_params = &testsuite_params;
2440 struct crypto_unittest_params *ut_params = &unittest_params;
2442 memcpy(cipher_key, key, key_len);
2444 /* Setup Cipher Parameters */
2445 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2446 ut_params->cipher_xform.next = NULL;
2448 ut_params->cipher_xform.cipher.algo = algo;
2449 ut_params->cipher_xform.cipher.op = op;
2450 ut_params->cipher_xform.cipher.key.data = cipher_key;
2451 ut_params->cipher_xform.cipher.key.length = key_len;
2452 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2453 ut_params->cipher_xform.cipher.iv.length = iv_len;
2455 debug_hexdump(stdout, "key:", key, key_len);
2457 /* Create Crypto session */
2458 ut_params->sess = rte_cryptodev_sym_session_create(
2459 ts_params->session_mpool);
2461 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2462 &ut_params->cipher_xform,
2463 ts_params->session_priv_mpool);
2464 if (status == -ENOTSUP)
2465 return TEST_SKIPPED;
2467 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2468 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2473 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2474 unsigned int cipher_len,
2475 unsigned int cipher_offset)
2477 struct crypto_testsuite_params *ts_params = &testsuite_params;
2478 struct crypto_unittest_params *ut_params = &unittest_params;
2480 /* Generate Crypto op data structure */
2481 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2482 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2483 TEST_ASSERT_NOT_NULL(ut_params->op,
2484 "Failed to allocate pktmbuf offload");
2486 /* Set crypto operation data parameters */
2487 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2489 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2491 /* set crypto operation source mbuf */
2492 sym_op->m_src = ut_params->ibuf;
2495 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2497 sym_op->cipher.data.length = cipher_len;
2498 sym_op->cipher.data.offset = cipher_offset;
2503 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2504 unsigned int cipher_len,
2505 unsigned int cipher_offset)
2507 struct crypto_testsuite_params *ts_params = &testsuite_params;
2508 struct crypto_unittest_params *ut_params = &unittest_params;
2510 /* Generate Crypto op data structure */
2511 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2512 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2513 TEST_ASSERT_NOT_NULL(ut_params->op,
2514 "Failed to allocate pktmbuf offload");
2516 /* Set crypto operation data parameters */
2517 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2519 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2521 /* set crypto operation source mbuf */
2522 sym_op->m_src = ut_params->ibuf;
2523 sym_op->m_dst = ut_params->obuf;
2526 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2528 sym_op->cipher.data.length = cipher_len;
2529 sym_op->cipher.data.offset = cipher_offset;
2534 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2535 enum rte_crypto_cipher_operation cipher_op,
2536 enum rte_crypto_auth_operation auth_op,
2537 enum rte_crypto_auth_algorithm auth_algo,
2538 enum rte_crypto_cipher_algorithm cipher_algo,
2539 const uint8_t *key, uint8_t key_len,
2540 uint8_t auth_iv_len, uint8_t auth_len,
2541 uint8_t cipher_iv_len)
2544 uint8_t cipher_auth_key[key_len];
2547 struct crypto_testsuite_params *ts_params = &testsuite_params;
2548 struct crypto_unittest_params *ut_params = &unittest_params;
2550 memcpy(cipher_auth_key, key, key_len);
2552 /* Setup Authentication Parameters */
2553 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2554 ut_params->auth_xform.next = NULL;
2556 ut_params->auth_xform.auth.op = auth_op;
2557 ut_params->auth_xform.auth.algo = auth_algo;
2558 ut_params->auth_xform.auth.key.length = key_len;
2559 /* Hash key = cipher key */
2560 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2561 ut_params->auth_xform.auth.digest_length = auth_len;
2562 /* Auth IV will be after cipher IV */
2563 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2564 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2566 /* Setup Cipher Parameters */
2567 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2568 ut_params->cipher_xform.next = &ut_params->auth_xform;
2570 ut_params->cipher_xform.cipher.algo = cipher_algo;
2571 ut_params->cipher_xform.cipher.op = cipher_op;
2572 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2573 ut_params->cipher_xform.cipher.key.length = key_len;
2574 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2575 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2577 debug_hexdump(stdout, "key:", key, key_len);
2579 /* Create Crypto session*/
2580 ut_params->sess = rte_cryptodev_sym_session_create(
2581 ts_params->session_mpool);
2582 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2584 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2585 &ut_params->cipher_xform,
2586 ts_params->session_priv_mpool);
2587 if (status == -ENOTSUP)
2588 return TEST_SKIPPED;
2590 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2595 create_wireless_cipher_auth_session(uint8_t dev_id,
2596 enum rte_crypto_cipher_operation cipher_op,
2597 enum rte_crypto_auth_operation auth_op,
2598 enum rte_crypto_auth_algorithm auth_algo,
2599 enum rte_crypto_cipher_algorithm cipher_algo,
2600 const struct wireless_test_data *tdata)
2602 const uint8_t key_len = tdata->key.len;
2603 uint8_t cipher_auth_key[key_len];
2606 struct crypto_testsuite_params *ts_params = &testsuite_params;
2607 struct crypto_unittest_params *ut_params = &unittest_params;
2608 const uint8_t *key = tdata->key.data;
2609 const uint8_t auth_len = tdata->digest.len;
2610 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2611 uint8_t auth_iv_len = tdata->auth_iv.len;
2613 memcpy(cipher_auth_key, key, key_len);
2615 /* Setup Authentication Parameters */
2616 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2617 ut_params->auth_xform.next = NULL;
2619 ut_params->auth_xform.auth.op = auth_op;
2620 ut_params->auth_xform.auth.algo = auth_algo;
2621 ut_params->auth_xform.auth.key.length = key_len;
2622 /* Hash key = cipher key */
2623 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2624 ut_params->auth_xform.auth.digest_length = auth_len;
2625 /* Auth IV will be after cipher IV */
2626 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2627 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2629 /* Setup Cipher Parameters */
2630 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2631 ut_params->cipher_xform.next = &ut_params->auth_xform;
2633 ut_params->cipher_xform.cipher.algo = cipher_algo;
2634 ut_params->cipher_xform.cipher.op = cipher_op;
2635 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2636 ut_params->cipher_xform.cipher.key.length = key_len;
2637 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2638 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2641 debug_hexdump(stdout, "key:", key, key_len);
2643 /* Create Crypto session*/
2644 ut_params->sess = rte_cryptodev_sym_session_create(
2645 ts_params->session_mpool);
2647 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2648 &ut_params->cipher_xform,
2649 ts_params->session_priv_mpool);
2650 if (status == -ENOTSUP)
2651 return TEST_SKIPPED;
2653 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2654 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2659 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2660 const struct wireless_test_data *tdata)
2662 return create_wireless_cipher_auth_session(dev_id,
2663 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2664 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2665 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2669 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2670 enum rte_crypto_cipher_operation cipher_op,
2671 enum rte_crypto_auth_operation auth_op,
2672 enum rte_crypto_auth_algorithm auth_algo,
2673 enum rte_crypto_cipher_algorithm cipher_algo,
2674 const uint8_t *key, const uint8_t key_len,
2675 uint8_t auth_iv_len, uint8_t auth_len,
2676 uint8_t cipher_iv_len)
2678 uint8_t auth_cipher_key[key_len];
2680 struct crypto_testsuite_params *ts_params = &testsuite_params;
2681 struct crypto_unittest_params *ut_params = &unittest_params;
2683 memcpy(auth_cipher_key, key, key_len);
2685 /* Setup Authentication Parameters */
2686 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2687 ut_params->auth_xform.auth.op = auth_op;
2688 ut_params->auth_xform.next = &ut_params->cipher_xform;
2689 ut_params->auth_xform.auth.algo = auth_algo;
2690 ut_params->auth_xform.auth.key.length = key_len;
2691 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2692 ut_params->auth_xform.auth.digest_length = auth_len;
2693 /* Auth IV will be after cipher IV */
2694 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2695 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2697 /* Setup Cipher Parameters */
2698 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2699 ut_params->cipher_xform.next = NULL;
2700 ut_params->cipher_xform.cipher.algo = cipher_algo;
2701 ut_params->cipher_xform.cipher.op = cipher_op;
2702 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2703 ut_params->cipher_xform.cipher.key.length = key_len;
2704 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2705 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2707 debug_hexdump(stdout, "key:", key, key_len);
2709 /* Create Crypto session*/
2710 ut_params->sess = rte_cryptodev_sym_session_create(
2711 ts_params->session_mpool);
2712 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2714 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2715 ut_params->auth_xform.next = NULL;
2716 ut_params->cipher_xform.next = &ut_params->auth_xform;
2717 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2718 &ut_params->cipher_xform,
2719 ts_params->session_priv_mpool);
2722 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2723 &ut_params->auth_xform,
2724 ts_params->session_priv_mpool);
2726 if (status == -ENOTSUP)
2727 return TEST_SKIPPED;
2729 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2735 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2736 unsigned int auth_tag_len,
2737 const uint8_t *iv, unsigned int iv_len,
2738 unsigned int data_pad_len,
2739 enum rte_crypto_auth_operation op,
2740 unsigned int auth_len, unsigned int auth_offset)
2742 struct crypto_testsuite_params *ts_params = &testsuite_params;
2744 struct crypto_unittest_params *ut_params = &unittest_params;
2746 /* Generate Crypto op data structure */
2747 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2748 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2749 TEST_ASSERT_NOT_NULL(ut_params->op,
2750 "Failed to allocate pktmbuf offload");
2752 /* Set crypto operation data parameters */
2753 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2755 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2757 /* set crypto operation source mbuf */
2758 sym_op->m_src = ut_params->ibuf;
2761 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2764 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2765 ut_params->ibuf, auth_tag_len);
2767 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2768 "no room to append auth tag");
2769 ut_params->digest = sym_op->auth.digest.data;
2770 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2771 ut_params->ibuf, data_pad_len);
2772 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2773 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2775 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2777 debug_hexdump(stdout, "digest:",
2778 sym_op->auth.digest.data,
2781 sym_op->auth.data.length = auth_len;
2782 sym_op->auth.data.offset = auth_offset;
2788 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2789 enum rte_crypto_auth_operation op)
2791 struct crypto_testsuite_params *ts_params = &testsuite_params;
2792 struct crypto_unittest_params *ut_params = &unittest_params;
2794 const uint8_t *auth_tag = tdata->digest.data;
2795 const unsigned int auth_tag_len = tdata->digest.len;
2796 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2797 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2799 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2800 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2801 const uint8_t *auth_iv = tdata->auth_iv.data;
2802 const uint8_t auth_iv_len = tdata->auth_iv.len;
2803 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2804 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2806 /* Generate Crypto op data structure */
2807 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2808 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2809 TEST_ASSERT_NOT_NULL(ut_params->op,
2810 "Failed to allocate pktmbuf offload");
2811 /* Set crypto operation data parameters */
2812 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2814 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2816 /* set crypto operation source mbuf */
2817 sym_op->m_src = ut_params->ibuf;
2820 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2821 ut_params->ibuf, auth_tag_len);
2823 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2824 "no room to append auth tag");
2825 ut_params->digest = sym_op->auth.digest.data;
2826 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2827 ut_params->ibuf, data_pad_len);
2828 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2829 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2831 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2833 debug_hexdump(stdout, "digest:",
2834 sym_op->auth.digest.data,
2837 /* Copy cipher and auth IVs at the end of the crypto operation */
2838 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2840 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2841 iv_ptr += cipher_iv_len;
2842 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2844 sym_op->cipher.data.length = cipher_len;
2845 sym_op->cipher.data.offset = 0;
2846 sym_op->auth.data.length = auth_len;
2847 sym_op->auth.data.offset = 0;
2853 create_zuc_cipher_hash_generate_operation(
2854 const struct wireless_test_data *tdata)
2856 return create_wireless_cipher_hash_operation(tdata,
2857 RTE_CRYPTO_AUTH_OP_GENERATE);
2861 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2862 const unsigned auth_tag_len,
2863 const uint8_t *auth_iv, uint8_t auth_iv_len,
2864 unsigned data_pad_len,
2865 enum rte_crypto_auth_operation op,
2866 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2867 const unsigned cipher_len, const unsigned cipher_offset,
2868 const unsigned auth_len, const unsigned auth_offset)
2870 struct crypto_testsuite_params *ts_params = &testsuite_params;
2871 struct crypto_unittest_params *ut_params = &unittest_params;
2873 enum rte_crypto_cipher_algorithm cipher_algo =
2874 ut_params->cipher_xform.cipher.algo;
2875 enum rte_crypto_auth_algorithm auth_algo =
2876 ut_params->auth_xform.auth.algo;
2878 /* Generate Crypto op data structure */
2879 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2880 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2881 TEST_ASSERT_NOT_NULL(ut_params->op,
2882 "Failed to allocate pktmbuf offload");
2883 /* Set crypto operation data parameters */
2884 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2886 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2888 /* set crypto operation source mbuf */
2889 sym_op->m_src = ut_params->ibuf;
2892 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2893 ut_params->ibuf, auth_tag_len);
2895 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2896 "no room to append auth tag");
2897 ut_params->digest = sym_op->auth.digest.data;
2899 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2900 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2901 ut_params->ibuf, data_pad_len);
2903 struct rte_mbuf *m = ut_params->ibuf;
2904 unsigned int offset = data_pad_len;
2906 while (offset > m->data_len && m->next != NULL) {
2907 offset -= m->data_len;
2910 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2914 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2915 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2917 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2919 debug_hexdump(stdout, "digest:",
2920 sym_op->auth.digest.data,
2923 /* Copy cipher and auth IVs at the end of the crypto operation */
2924 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2926 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2927 iv_ptr += cipher_iv_len;
2928 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2930 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2931 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2932 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2933 sym_op->cipher.data.length = cipher_len;
2934 sym_op->cipher.data.offset = cipher_offset;
2936 sym_op->cipher.data.length = cipher_len >> 3;
2937 sym_op->cipher.data.offset = cipher_offset >> 3;
2940 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2941 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2942 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2943 sym_op->auth.data.length = auth_len;
2944 sym_op->auth.data.offset = auth_offset;
2946 sym_op->auth.data.length = auth_len >> 3;
2947 sym_op->auth.data.offset = auth_offset >> 3;
2954 create_wireless_algo_auth_cipher_operation(
2955 const uint8_t *auth_tag, unsigned int auth_tag_len,
2956 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2957 const uint8_t *auth_iv, uint8_t auth_iv_len,
2958 unsigned int data_pad_len,
2959 unsigned int cipher_len, unsigned int cipher_offset,
2960 unsigned int auth_len, unsigned int auth_offset,
2961 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2963 struct crypto_testsuite_params *ts_params = &testsuite_params;
2964 struct crypto_unittest_params *ut_params = &unittest_params;
2966 enum rte_crypto_cipher_algorithm cipher_algo =
2967 ut_params->cipher_xform.cipher.algo;
2968 enum rte_crypto_auth_algorithm auth_algo =
2969 ut_params->auth_xform.auth.algo;
2971 /* Generate Crypto op data structure */
2972 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2973 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2974 TEST_ASSERT_NOT_NULL(ut_params->op,
2975 "Failed to allocate pktmbuf offload");
2977 /* Set crypto operation data parameters */
2978 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2980 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2982 /* set crypto operation mbufs */
2983 sym_op->m_src = ut_params->ibuf;
2984 if (op_mode == OUT_OF_PLACE)
2985 sym_op->m_dst = ut_params->obuf;
2989 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2990 (op_mode == IN_PLACE ?
2991 ut_params->ibuf : ut_params->obuf),
2992 uint8_t *, data_pad_len);
2993 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2994 (op_mode == IN_PLACE ?
2995 ut_params->ibuf : ut_params->obuf),
2997 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2999 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3000 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3001 sym_op->m_src : sym_op->m_dst);
3002 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3003 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3004 sgl_buf = sgl_buf->next;
3006 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3007 uint8_t *, remaining_off);
3008 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3010 memset(sym_op->auth.digest.data, 0, remaining_off);
3011 while (sgl_buf->next != NULL) {
3012 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3013 0, rte_pktmbuf_data_len(sgl_buf));
3014 sgl_buf = sgl_buf->next;
3018 /* Copy digest for the verification */
3020 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3022 /* Copy cipher and auth IVs at the end of the crypto operation */
3023 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3024 ut_params->op, uint8_t *, IV_OFFSET);
3026 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3027 iv_ptr += cipher_iv_len;
3028 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3030 /* Only copy over the offset data needed from src to dst in OOP,
3031 * if the auth and cipher offsets are not aligned
3033 if (op_mode == OUT_OF_PLACE) {
3034 if (cipher_offset > auth_offset)
3036 rte_pktmbuf_mtod_offset(
3038 uint8_t *, auth_offset >> 3),
3039 rte_pktmbuf_mtod_offset(
3041 uint8_t *, auth_offset >> 3),
3042 ((cipher_offset >> 3) - (auth_offset >> 3)));
3045 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3046 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3047 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3048 sym_op->cipher.data.length = cipher_len;
3049 sym_op->cipher.data.offset = cipher_offset;
3051 sym_op->cipher.data.length = cipher_len >> 3;
3052 sym_op->cipher.data.offset = cipher_offset >> 3;
3055 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3056 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3057 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3058 sym_op->auth.data.length = auth_len;
3059 sym_op->auth.data.offset = auth_offset;
3061 sym_op->auth.data.length = auth_len >> 3;
3062 sym_op->auth.data.offset = auth_offset >> 3;
3069 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3071 struct crypto_testsuite_params *ts_params = &testsuite_params;
3072 struct crypto_unittest_params *ut_params = &unittest_params;
3075 unsigned plaintext_pad_len;
3076 unsigned plaintext_len;
3078 struct rte_cryptodev_info dev_info;
3080 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3081 uint64_t feat_flags = dev_info.feature_flags;
3083 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3084 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3085 printf("Device doesn't support NON-Byte Aligned Data.\n");
3086 return TEST_SKIPPED;
3089 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3090 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3091 printf("Device doesn't support RAW data-path APIs.\n");
3092 return TEST_SKIPPED;
3095 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3096 return TEST_SKIPPED;
3098 /* Verify the capabilities */
3099 struct rte_cryptodev_sym_capability_idx cap_idx;
3100 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3101 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3102 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3104 return TEST_SKIPPED;
3106 /* Create SNOW 3G session */
3107 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3108 tdata->key.data, tdata->key.len,
3109 tdata->auth_iv.len, tdata->digest.len,
3110 RTE_CRYPTO_AUTH_OP_GENERATE,
3111 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3115 /* alloc mbuf and set payload */
3116 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3118 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3119 rte_pktmbuf_tailroom(ut_params->ibuf));
3121 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3122 /* Append data which is padded to a multiple of */
3123 /* the algorithms block size */
3124 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3125 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3127 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3129 /* Create SNOW 3G operation */
3130 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3131 tdata->auth_iv.data, tdata->auth_iv.len,
3132 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3133 tdata->validAuthLenInBits.len,
3138 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3139 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3140 ut_params->op, 0, 1, 1, 0);
3142 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3144 ut_params->obuf = ut_params->op->sym->m_src;
3145 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3146 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3147 + plaintext_pad_len;
3150 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3153 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3154 "SNOW 3G Generated auth tag not as expected");
3160 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3162 struct crypto_testsuite_params *ts_params = &testsuite_params;
3163 struct crypto_unittest_params *ut_params = &unittest_params;
3166 unsigned plaintext_pad_len;
3167 unsigned plaintext_len;
3169 struct rte_cryptodev_info dev_info;
3171 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3172 uint64_t feat_flags = dev_info.feature_flags;
3174 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3175 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3176 printf("Device doesn't support NON-Byte Aligned Data.\n");
3177 return TEST_SKIPPED;
3180 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3181 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3182 printf("Device doesn't support RAW data-path APIs.\n");
3183 return TEST_SKIPPED;
3186 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3187 return TEST_SKIPPED;
3189 /* Verify the capabilities */
3190 struct rte_cryptodev_sym_capability_idx cap_idx;
3191 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3192 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3193 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3195 return TEST_SKIPPED;
3197 /* Create SNOW 3G session */
3198 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3199 tdata->key.data, tdata->key.len,
3200 tdata->auth_iv.len, tdata->digest.len,
3201 RTE_CRYPTO_AUTH_OP_VERIFY,
3202 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3205 /* alloc mbuf and set payload */
3206 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3208 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3209 rte_pktmbuf_tailroom(ut_params->ibuf));
3211 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3212 /* Append data which is padded to a multiple of */
3213 /* the algorithms block size */
3214 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3215 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3217 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3219 /* Create SNOW 3G operation */
3220 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3222 tdata->auth_iv.data, tdata->auth_iv.len,
3224 RTE_CRYPTO_AUTH_OP_VERIFY,
3225 tdata->validAuthLenInBits.len,
3230 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3231 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3232 ut_params->op, 0, 1, 1, 0);
3234 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3236 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3237 ut_params->obuf = ut_params->op->sym->m_src;
3238 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3239 + plaintext_pad_len;
3242 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3251 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3253 struct crypto_testsuite_params *ts_params = &testsuite_params;
3254 struct crypto_unittest_params *ut_params = &unittest_params;
3257 unsigned plaintext_pad_len;
3258 unsigned plaintext_len;
3260 struct rte_cryptodev_info dev_info;
3262 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3263 uint64_t feat_flags = dev_info.feature_flags;
3265 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3266 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3267 printf("Device doesn't support RAW data-path APIs.\n");
3268 return TEST_SKIPPED;
3271 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3272 return TEST_SKIPPED;
3274 /* Verify the capabilities */
3275 struct rte_cryptodev_sym_capability_idx cap_idx;
3276 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3277 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3278 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3280 return TEST_SKIPPED;
3282 /* Create KASUMI session */
3283 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3284 tdata->key.data, tdata->key.len,
3285 0, tdata->digest.len,
3286 RTE_CRYPTO_AUTH_OP_GENERATE,
3287 RTE_CRYPTO_AUTH_KASUMI_F9);
3291 /* alloc mbuf and set payload */
3292 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3294 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3295 rte_pktmbuf_tailroom(ut_params->ibuf));
3297 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3298 /* Append data which is padded to a multiple of */
3299 /* the algorithms block size */
3300 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3301 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3303 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3305 /* Create KASUMI operation */
3306 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3308 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3309 tdata->plaintext.len,
3314 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3315 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3317 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3318 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3319 ut_params->op, 0, 1, 1, 0);
3321 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3324 ut_params->obuf = ut_params->op->sym->m_src;
3325 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3326 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3327 + plaintext_pad_len;
3330 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3333 DIGEST_BYTE_LENGTH_KASUMI_F9,
3334 "KASUMI Generated auth tag not as expected");
3340 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3342 struct crypto_testsuite_params *ts_params = &testsuite_params;
3343 struct crypto_unittest_params *ut_params = &unittest_params;
3346 unsigned plaintext_pad_len;
3347 unsigned plaintext_len;
3349 struct rte_cryptodev_info dev_info;
3351 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3352 uint64_t feat_flags = dev_info.feature_flags;
3354 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3355 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3356 printf("Device doesn't support RAW data-path APIs.\n");
3357 return TEST_SKIPPED;
3360 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3361 return TEST_SKIPPED;
3363 /* Verify the capabilities */
3364 struct rte_cryptodev_sym_capability_idx cap_idx;
3365 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3366 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3367 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3369 return TEST_SKIPPED;
3371 /* Create KASUMI session */
3372 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3373 tdata->key.data, tdata->key.len,
3374 0, tdata->digest.len,
3375 RTE_CRYPTO_AUTH_OP_VERIFY,
3376 RTE_CRYPTO_AUTH_KASUMI_F9);
3379 /* alloc mbuf and set payload */
3380 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3382 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3383 rte_pktmbuf_tailroom(ut_params->ibuf));
3385 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3386 /* Append data which is padded to a multiple */
3387 /* of the algorithms block size */
3388 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3389 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3391 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3393 /* Create KASUMI operation */
3394 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3398 RTE_CRYPTO_AUTH_OP_VERIFY,
3399 tdata->plaintext.len,
3404 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3405 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3406 ut_params->op, 0, 1, 1, 0);
3408 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3410 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3411 ut_params->obuf = ut_params->op->sym->m_src;
3412 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3413 + plaintext_pad_len;
3416 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3425 test_snow3g_hash_generate_test_case_1(void)
3427 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3431 test_snow3g_hash_generate_test_case_2(void)
3433 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3437 test_snow3g_hash_generate_test_case_3(void)
3439 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3443 test_snow3g_hash_generate_test_case_4(void)
3445 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3449 test_snow3g_hash_generate_test_case_5(void)
3451 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3455 test_snow3g_hash_generate_test_case_6(void)
3457 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3461 test_snow3g_hash_verify_test_case_1(void)
3463 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3468 test_snow3g_hash_verify_test_case_2(void)
3470 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3474 test_snow3g_hash_verify_test_case_3(void)
3476 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3480 test_snow3g_hash_verify_test_case_4(void)
3482 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3486 test_snow3g_hash_verify_test_case_5(void)
3488 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3492 test_snow3g_hash_verify_test_case_6(void)
3494 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3498 test_kasumi_hash_generate_test_case_1(void)
3500 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3504 test_kasumi_hash_generate_test_case_2(void)
3506 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3510 test_kasumi_hash_generate_test_case_3(void)
3512 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3516 test_kasumi_hash_generate_test_case_4(void)
3518 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3522 test_kasumi_hash_generate_test_case_5(void)
3524 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3528 test_kasumi_hash_generate_test_case_6(void)
3530 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3534 test_kasumi_hash_verify_test_case_1(void)
3536 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3540 test_kasumi_hash_verify_test_case_2(void)
3542 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3546 test_kasumi_hash_verify_test_case_3(void)
3548 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3552 test_kasumi_hash_verify_test_case_4(void)
3554 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3558 test_kasumi_hash_verify_test_case_5(void)
3560 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3564 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3566 struct crypto_testsuite_params *ts_params = &testsuite_params;
3567 struct crypto_unittest_params *ut_params = &unittest_params;
3570 uint8_t *plaintext, *ciphertext;
3571 unsigned plaintext_pad_len;
3572 unsigned plaintext_len;
3573 struct rte_cryptodev_info dev_info;
3575 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3576 uint64_t feat_flags = dev_info.feature_flags;
3578 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3579 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3580 printf("Device doesn't support RAW data-path APIs.\n");
3581 return TEST_SKIPPED;
3584 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3585 return TEST_SKIPPED;
3587 /* Verify the capabilities */
3588 struct rte_cryptodev_sym_capability_idx cap_idx;
3589 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3590 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3591 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3593 return TEST_SKIPPED;
3595 /* Create KASUMI session */
3596 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3597 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3598 RTE_CRYPTO_CIPHER_KASUMI_F8,
3599 tdata->key.data, tdata->key.len,
3600 tdata->cipher_iv.len);
3604 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3606 /* Clear mbuf payload */
3607 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3608 rte_pktmbuf_tailroom(ut_params->ibuf));
3610 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3611 /* Append data which is padded to a multiple */
3612 /* of the algorithms block size */
3613 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3614 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3616 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3618 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3620 /* Create KASUMI operation */
3621 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3622 tdata->cipher_iv.len,
3623 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3624 tdata->validCipherOffsetInBits.len);
3628 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3629 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3630 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3632 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3634 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3636 ut_params->obuf = ut_params->op->sym->m_dst;
3637 if (ut_params->obuf)
3638 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3640 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3642 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3644 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3645 (tdata->validCipherOffsetInBits.len >> 3);
3647 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3649 reference_ciphertext,
3650 tdata->validCipherLenInBits.len,
3651 "KASUMI Ciphertext data not as expected");
3656 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3658 struct crypto_testsuite_params *ts_params = &testsuite_params;
3659 struct crypto_unittest_params *ut_params = &unittest_params;
3663 unsigned int plaintext_pad_len;
3664 unsigned int plaintext_len;
3666 uint8_t buffer[10000];
3667 const uint8_t *ciphertext;
3669 struct rte_cryptodev_info dev_info;
3671 /* Verify the capabilities */
3672 struct rte_cryptodev_sym_capability_idx cap_idx;
3673 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3674 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3675 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3677 return TEST_SKIPPED;
3679 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3681 uint64_t feat_flags = dev_info.feature_flags;
3683 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3684 printf("Device doesn't support in-place scatter-gather. "
3686 return TEST_SKIPPED;
3689 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3690 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3691 printf("Device doesn't support RAW data-path APIs.\n");
3692 return TEST_SKIPPED;
3695 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3696 return TEST_SKIPPED;
3698 /* Create KASUMI session */
3699 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3700 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3701 RTE_CRYPTO_CIPHER_KASUMI_F8,
3702 tdata->key.data, tdata->key.len,
3703 tdata->cipher_iv.len);
3707 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3710 /* Append data which is padded to a multiple */
3711 /* of the algorithms block size */
3712 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3714 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3715 plaintext_pad_len, 10, 0);
3717 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3719 /* Create KASUMI operation */
3720 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3721 tdata->cipher_iv.len,
3722 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3723 tdata->validCipherOffsetInBits.len);
3727 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3728 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3729 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3731 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3733 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3735 ut_params->obuf = ut_params->op->sym->m_dst;
3737 if (ut_params->obuf)
3738 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3739 plaintext_len, buffer);
3741 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3742 tdata->validCipherOffsetInBits.len >> 3,
3743 plaintext_len, buffer);
3746 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3748 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3749 (tdata->validCipherOffsetInBits.len >> 3);
3751 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3753 reference_ciphertext,
3754 tdata->validCipherLenInBits.len,
3755 "KASUMI Ciphertext data not as expected");
3760 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3762 struct crypto_testsuite_params *ts_params = &testsuite_params;
3763 struct crypto_unittest_params *ut_params = &unittest_params;
3766 uint8_t *plaintext, *ciphertext;
3767 unsigned plaintext_pad_len;
3768 unsigned plaintext_len;
3770 /* Verify the capabilities */
3771 struct rte_cryptodev_sym_capability_idx cap_idx;
3772 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3773 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3774 /* Data-path service does not support OOP */
3775 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3777 return TEST_SKIPPED;
3779 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3780 return TEST_SKIPPED;
3782 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3783 return TEST_SKIPPED;
3785 /* Create KASUMI session */
3786 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3787 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3788 RTE_CRYPTO_CIPHER_KASUMI_F8,
3789 tdata->key.data, tdata->key.len,
3790 tdata->cipher_iv.len);
3794 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3795 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3797 /* Clear mbuf payload */
3798 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3799 rte_pktmbuf_tailroom(ut_params->ibuf));
3801 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3802 /* Append data which is padded to a multiple */
3803 /* of the algorithms block size */
3804 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3805 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3807 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3808 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3810 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3812 /* Create KASUMI operation */
3813 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3814 tdata->cipher_iv.len,
3815 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3816 tdata->validCipherOffsetInBits.len);
3820 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3822 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3824 ut_params->obuf = ut_params->op->sym->m_dst;
3825 if (ut_params->obuf)
3826 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3828 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3830 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3832 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3833 (tdata->validCipherOffsetInBits.len >> 3);
3835 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3837 reference_ciphertext,
3838 tdata->validCipherLenInBits.len,
3839 "KASUMI Ciphertext data not as expected");
3844 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3846 struct crypto_testsuite_params *ts_params = &testsuite_params;
3847 struct crypto_unittest_params *ut_params = &unittest_params;
3850 unsigned int plaintext_pad_len;
3851 unsigned int plaintext_len;
3853 const uint8_t *ciphertext;
3854 uint8_t buffer[2048];
3856 struct rte_cryptodev_info dev_info;
3858 /* Verify the capabilities */
3859 struct rte_cryptodev_sym_capability_idx cap_idx;
3860 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3861 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3862 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3864 return TEST_SKIPPED;
3866 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3867 return TEST_SKIPPED;
3869 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3870 return TEST_SKIPPED;
3872 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3874 uint64_t feat_flags = dev_info.feature_flags;
3875 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3876 printf("Device doesn't support out-of-place scatter-gather "
3877 "in both input and output mbufs. "
3879 return TEST_SKIPPED;
3882 /* Create KASUMI session */
3883 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3884 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3885 RTE_CRYPTO_CIPHER_KASUMI_F8,
3886 tdata->key.data, tdata->key.len,
3887 tdata->cipher_iv.len);
3891 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3892 /* Append data which is padded to a multiple */
3893 /* of the algorithms block size */
3894 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3896 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3897 plaintext_pad_len, 10, 0);
3898 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3899 plaintext_pad_len, 3, 0);
3901 /* Append data which is padded to a multiple */
3902 /* of the algorithms block size */
3903 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3905 /* Create KASUMI operation */
3906 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3907 tdata->cipher_iv.len,
3908 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3909 tdata->validCipherOffsetInBits.len);
3913 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3915 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3917 ut_params->obuf = ut_params->op->sym->m_dst;
3918 if (ut_params->obuf)
3919 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3920 plaintext_pad_len, buffer);
3922 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3923 tdata->validCipherOffsetInBits.len >> 3,
3924 plaintext_pad_len, buffer);
3926 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3927 (tdata->validCipherOffsetInBits.len >> 3);
3929 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3931 reference_ciphertext,
3932 tdata->validCipherLenInBits.len,
3933 "KASUMI Ciphertext data not as expected");
3939 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3941 struct crypto_testsuite_params *ts_params = &testsuite_params;
3942 struct crypto_unittest_params *ut_params = &unittest_params;
3945 uint8_t *ciphertext, *plaintext;
3946 unsigned ciphertext_pad_len;
3947 unsigned ciphertext_len;
3949 /* Verify the capabilities */
3950 struct rte_cryptodev_sym_capability_idx cap_idx;
3951 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3952 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3953 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3955 return TEST_SKIPPED;
3957 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3958 return TEST_SKIPPED;
3960 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3961 return TEST_SKIPPED;
3963 /* Create KASUMI session */
3964 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3965 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3966 RTE_CRYPTO_CIPHER_KASUMI_F8,
3967 tdata->key.data, tdata->key.len,
3968 tdata->cipher_iv.len);
3972 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3973 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3975 /* Clear mbuf payload */
3976 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3977 rte_pktmbuf_tailroom(ut_params->ibuf));
3979 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3980 /* Append data which is padded to a multiple */
3981 /* of the algorithms block size */
3982 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3983 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3984 ciphertext_pad_len);
3985 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3986 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3988 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3990 /* Create KASUMI operation */
3991 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3992 tdata->cipher_iv.len,
3993 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3994 tdata->validCipherOffsetInBits.len);
3998 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4000 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4002 ut_params->obuf = ut_params->op->sym->m_dst;
4003 if (ut_params->obuf)
4004 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4006 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4008 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4010 const uint8_t *reference_plaintext = tdata->plaintext.data +
4011 (tdata->validCipherOffsetInBits.len >> 3);
4013 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4015 reference_plaintext,
4016 tdata->validCipherLenInBits.len,
4017 "KASUMI Plaintext data not as expected");
4022 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4024 struct crypto_testsuite_params *ts_params = &testsuite_params;
4025 struct crypto_unittest_params *ut_params = &unittest_params;
4028 uint8_t *ciphertext, *plaintext;
4029 unsigned ciphertext_pad_len;
4030 unsigned ciphertext_len;
4031 struct rte_cryptodev_info dev_info;
4033 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4034 uint64_t feat_flags = dev_info.feature_flags;
4036 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4037 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4038 printf("Device doesn't support RAW data-path APIs.\n");
4039 return TEST_SKIPPED;
4042 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4043 return TEST_SKIPPED;
4045 /* Verify the capabilities */
4046 struct rte_cryptodev_sym_capability_idx cap_idx;
4047 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4048 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4049 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4051 return TEST_SKIPPED;
4053 /* Create KASUMI session */
4054 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4055 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4056 RTE_CRYPTO_CIPHER_KASUMI_F8,
4057 tdata->key.data, tdata->key.len,
4058 tdata->cipher_iv.len);
4062 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4064 /* Clear mbuf payload */
4065 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4066 rte_pktmbuf_tailroom(ut_params->ibuf));
4068 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4069 /* Append data which is padded to a multiple */
4070 /* of the algorithms block size */
4071 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4072 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4073 ciphertext_pad_len);
4074 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4076 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4078 /* Create KASUMI operation */
4079 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4080 tdata->cipher_iv.len,
4081 tdata->ciphertext.len,
4082 tdata->validCipherOffsetInBits.len);
4086 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4087 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4088 ut_params->op, 1, 0, 1, 0);
4090 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4092 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4094 ut_params->obuf = ut_params->op->sym->m_dst;
4095 if (ut_params->obuf)
4096 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4098 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4100 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4102 const uint8_t *reference_plaintext = tdata->plaintext.data +
4103 (tdata->validCipherOffsetInBits.len >> 3);
4105 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4107 reference_plaintext,
4108 tdata->validCipherLenInBits.len,
4109 "KASUMI Plaintext data not as expected");
4114 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4116 struct crypto_testsuite_params *ts_params = &testsuite_params;
4117 struct crypto_unittest_params *ut_params = &unittest_params;
4120 uint8_t *plaintext, *ciphertext;
4121 unsigned plaintext_pad_len;
4122 unsigned plaintext_len;
4123 struct rte_cryptodev_info dev_info;
4125 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4126 uint64_t feat_flags = dev_info.feature_flags;
4128 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4129 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4130 printf("Device doesn't support RAW data-path APIs.\n");
4131 return TEST_SKIPPED;
4134 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4135 return TEST_SKIPPED;
4137 /* Verify the capabilities */
4138 struct rte_cryptodev_sym_capability_idx cap_idx;
4139 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4140 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4141 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4143 return TEST_SKIPPED;
4145 /* Create SNOW 3G session */
4146 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4147 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4148 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4149 tdata->key.data, tdata->key.len,
4150 tdata->cipher_iv.len);
4154 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4156 /* Clear mbuf payload */
4157 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4158 rte_pktmbuf_tailroom(ut_params->ibuf));
4160 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4161 /* Append data which is padded to a multiple of */
4162 /* the algorithms block size */
4163 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4164 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4166 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4168 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4170 /* Create SNOW 3G operation */
4171 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4172 tdata->cipher_iv.len,
4173 tdata->validCipherLenInBits.len,
4178 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4179 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4180 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4182 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4184 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4186 ut_params->obuf = ut_params->op->sym->m_dst;
4187 if (ut_params->obuf)
4188 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4190 ciphertext = plaintext;
4192 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4195 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4197 tdata->ciphertext.data,
4198 tdata->validDataLenInBits.len,
4199 "SNOW 3G Ciphertext data not as expected");
4205 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4207 struct crypto_testsuite_params *ts_params = &testsuite_params;
4208 struct crypto_unittest_params *ut_params = &unittest_params;
4209 uint8_t *plaintext, *ciphertext;
4212 unsigned plaintext_pad_len;
4213 unsigned plaintext_len;
4214 struct rte_cryptodev_info dev_info;
4216 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4217 uint64_t feat_flags = dev_info.feature_flags;
4219 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4220 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4221 printf("Device does not support RAW data-path APIs.\n");
4225 /* Verify the capabilities */
4226 struct rte_cryptodev_sym_capability_idx cap_idx;
4227 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4228 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4229 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4231 return TEST_SKIPPED;
4233 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4234 return TEST_SKIPPED;
4236 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4237 return TEST_SKIPPED;
4239 /* Create SNOW 3G session */
4240 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4241 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4242 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4243 tdata->key.data, tdata->key.len,
4244 tdata->cipher_iv.len);
4248 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4249 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4251 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4252 "Failed to allocate input buffer in mempool");
4253 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4254 "Failed to allocate output buffer in mempool");
4256 /* Clear mbuf payload */
4257 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4258 rte_pktmbuf_tailroom(ut_params->ibuf));
4260 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4261 /* Append data which is padded to a multiple of */
4262 /* the algorithms block size */
4263 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4264 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4266 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4267 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4269 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4271 /* Create SNOW 3G operation */
4272 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4273 tdata->cipher_iv.len,
4274 tdata->validCipherLenInBits.len,
4279 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4280 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4281 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4283 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4285 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4287 ut_params->obuf = ut_params->op->sym->m_dst;
4288 if (ut_params->obuf)
4289 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4291 ciphertext = plaintext;
4293 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4296 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4298 tdata->ciphertext.data,
4299 tdata->validDataLenInBits.len,
4300 "SNOW 3G Ciphertext data not as expected");
4305 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4307 struct crypto_testsuite_params *ts_params = &testsuite_params;
4308 struct crypto_unittest_params *ut_params = &unittest_params;
4311 unsigned int plaintext_pad_len;
4312 unsigned int plaintext_len;
4313 uint8_t buffer[10000];
4314 const uint8_t *ciphertext;
4316 struct rte_cryptodev_info dev_info;
4318 /* Verify the capabilities */
4319 struct rte_cryptodev_sym_capability_idx cap_idx;
4320 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4321 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4322 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4324 return TEST_SKIPPED;
4326 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4327 return TEST_SKIPPED;
4329 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4330 return TEST_SKIPPED;
4332 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4334 uint64_t feat_flags = dev_info.feature_flags;
4336 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4337 printf("Device doesn't support out-of-place scatter-gather "
4338 "in both input and output mbufs. "
4340 return TEST_SKIPPED;
4343 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4344 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4345 printf("Device does not support RAW data-path APIs.\n");
4349 /* Create SNOW 3G session */
4350 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4351 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4352 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4353 tdata->key.data, tdata->key.len,
4354 tdata->cipher_iv.len);
4358 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4359 /* Append data which is padded to a multiple of */
4360 /* the algorithms block size */
4361 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4363 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4364 plaintext_pad_len, 10, 0);
4365 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4366 plaintext_pad_len, 3, 0);
4368 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4369 "Failed to allocate input buffer in mempool");
4370 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4371 "Failed to allocate output buffer in mempool");
4373 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4375 /* Create SNOW 3G operation */
4376 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4377 tdata->cipher_iv.len,
4378 tdata->validCipherLenInBits.len,
4383 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4384 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4385 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4387 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4389 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4391 ut_params->obuf = ut_params->op->sym->m_dst;
4392 if (ut_params->obuf)
4393 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4394 plaintext_len, buffer);
4396 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4397 plaintext_len, buffer);
4399 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4402 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4404 tdata->ciphertext.data,
4405 tdata->validDataLenInBits.len,
4406 "SNOW 3G Ciphertext data not as expected");
4411 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4413 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4415 uint8_t curr_byte, prev_byte;
4416 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4417 uint8_t lower_byte_mask = (1 << offset) - 1;
4420 prev_byte = buffer[0];
4421 buffer[0] >>= offset;
4423 for (i = 1; i < length_in_bytes; i++) {
4424 curr_byte = buffer[i];
4425 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4426 (curr_byte >> offset);
4427 prev_byte = curr_byte;
4432 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4434 struct crypto_testsuite_params *ts_params = &testsuite_params;
4435 struct crypto_unittest_params *ut_params = &unittest_params;
4436 uint8_t *plaintext, *ciphertext;
4438 uint32_t plaintext_len;
4439 uint32_t plaintext_pad_len;
4440 uint8_t extra_offset = 4;
4441 uint8_t *expected_ciphertext_shifted;
4442 struct rte_cryptodev_info dev_info;
4444 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4445 uint64_t feat_flags = dev_info.feature_flags;
4447 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4448 ((tdata->validDataLenInBits.len % 8) != 0)) {
4449 printf("Device doesn't support NON-Byte Aligned Data.\n");
4450 return TEST_SKIPPED;
4453 /* Verify the capabilities */
4454 struct rte_cryptodev_sym_capability_idx cap_idx;
4455 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4456 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4457 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4459 return TEST_SKIPPED;
4461 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4462 return TEST_SKIPPED;
4464 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4465 return TEST_SKIPPED;
4467 /* Create SNOW 3G session */
4468 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4469 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4470 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4471 tdata->key.data, tdata->key.len,
4472 tdata->cipher_iv.len);
4476 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4477 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4479 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4480 "Failed to allocate input buffer in mempool");
4481 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4482 "Failed to allocate output buffer in mempool");
4484 /* Clear mbuf payload */
4485 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4486 rte_pktmbuf_tailroom(ut_params->ibuf));
4488 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4490 * Append data which is padded to a
4491 * multiple of the algorithms block size
4493 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4495 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4498 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4500 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4501 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4503 #ifdef RTE_APP_TEST_DEBUG
4504 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4506 /* Create SNOW 3G operation */
4507 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4508 tdata->cipher_iv.len,
4509 tdata->validCipherLenInBits.len,
4514 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4515 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4516 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4518 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4520 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4522 ut_params->obuf = ut_params->op->sym->m_dst;
4523 if (ut_params->obuf)
4524 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4526 ciphertext = plaintext;
4528 #ifdef RTE_APP_TEST_DEBUG
4529 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4532 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4534 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4535 "failed to reserve memory for ciphertext shifted\n");
4537 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4538 ceil_byte_length(tdata->ciphertext.len));
4539 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4542 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4544 expected_ciphertext_shifted,
4545 tdata->validDataLenInBits.len,
4547 "SNOW 3G Ciphertext data not as expected");
4551 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4553 struct crypto_testsuite_params *ts_params = &testsuite_params;
4554 struct crypto_unittest_params *ut_params = &unittest_params;
4558 uint8_t *plaintext, *ciphertext;
4559 unsigned ciphertext_pad_len;
4560 unsigned ciphertext_len;
4561 struct rte_cryptodev_info dev_info;
4563 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4564 uint64_t feat_flags = dev_info.feature_flags;
4566 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4567 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4568 printf("Device doesn't support RAW data-path APIs.\n");
4569 return TEST_SKIPPED;
4572 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4573 return TEST_SKIPPED;
4575 /* Verify the capabilities */
4576 struct rte_cryptodev_sym_capability_idx cap_idx;
4577 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4578 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4579 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4581 return TEST_SKIPPED;
4583 /* Create SNOW 3G session */
4584 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4585 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4586 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4587 tdata->key.data, tdata->key.len,
4588 tdata->cipher_iv.len);
4592 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4594 /* Clear mbuf payload */
4595 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4596 rte_pktmbuf_tailroom(ut_params->ibuf));
4598 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4599 /* Append data which is padded to a multiple of */
4600 /* the algorithms block size */
4601 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4602 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4603 ciphertext_pad_len);
4604 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4606 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4608 /* Create SNOW 3G operation */
4609 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4610 tdata->cipher_iv.len,
4611 tdata->validCipherLenInBits.len,
4612 tdata->cipher.offset_bits);
4616 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4617 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4618 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4620 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4622 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4623 ut_params->obuf = ut_params->op->sym->m_dst;
4624 if (ut_params->obuf)
4625 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4627 plaintext = ciphertext;
4629 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4632 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4633 tdata->plaintext.data,
4634 tdata->validDataLenInBits.len,
4635 "SNOW 3G Plaintext data not as expected");
4639 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4641 struct crypto_testsuite_params *ts_params = &testsuite_params;
4642 struct crypto_unittest_params *ut_params = &unittest_params;
4646 uint8_t *plaintext, *ciphertext;
4647 unsigned ciphertext_pad_len;
4648 unsigned ciphertext_len;
4649 struct rte_cryptodev_info dev_info;
4651 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4652 uint64_t feat_flags = dev_info.feature_flags;
4654 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4655 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4656 printf("Device does not support RAW data-path APIs.\n");
4659 /* Verify the capabilities */
4660 struct rte_cryptodev_sym_capability_idx cap_idx;
4661 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4662 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4663 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4665 return TEST_SKIPPED;
4667 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4668 return TEST_SKIPPED;
4670 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4671 return TEST_SKIPPED;
4673 /* Create SNOW 3G session */
4674 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4675 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4676 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4677 tdata->key.data, tdata->key.len,
4678 tdata->cipher_iv.len);
4682 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4683 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4685 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4686 "Failed to allocate input buffer");
4687 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4688 "Failed to allocate output buffer");
4690 /* Clear mbuf payload */
4691 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4692 rte_pktmbuf_tailroom(ut_params->ibuf));
4694 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4695 rte_pktmbuf_tailroom(ut_params->obuf));
4697 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4698 /* Append data which is padded to a multiple of */
4699 /* the algorithms block size */
4700 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4701 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4702 ciphertext_pad_len);
4703 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4704 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4706 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4708 /* Create SNOW 3G operation */
4709 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4710 tdata->cipher_iv.len,
4711 tdata->validCipherLenInBits.len,
4716 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4717 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4718 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4720 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4722 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4723 ut_params->obuf = ut_params->op->sym->m_dst;
4724 if (ut_params->obuf)
4725 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4727 plaintext = ciphertext;
4729 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4732 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4733 tdata->plaintext.data,
4734 tdata->validDataLenInBits.len,
4735 "SNOW 3G Plaintext data not as expected");
4740 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4742 struct crypto_testsuite_params *ts_params = &testsuite_params;
4743 struct crypto_unittest_params *ut_params = &unittest_params;
4747 uint8_t *plaintext, *ciphertext;
4748 unsigned int plaintext_pad_len;
4749 unsigned int plaintext_len;
4751 struct rte_cryptodev_info dev_info;
4752 struct rte_cryptodev_sym_capability_idx cap_idx;
4754 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4755 uint64_t feat_flags = dev_info.feature_flags;
4757 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4758 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4759 (tdata->validDataLenInBits.len % 8 != 0))) {
4760 printf("Device doesn't support NON-Byte Aligned Data.\n");
4761 return TEST_SKIPPED;
4764 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4765 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4766 printf("Device doesn't support RAW data-path APIs.\n");
4767 return TEST_SKIPPED;
4770 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4771 return TEST_SKIPPED;
4773 /* Check if device supports ZUC EEA3 */
4774 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4775 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4777 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4779 return TEST_SKIPPED;
4781 /* Check if device supports ZUC EIA3 */
4782 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4783 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4785 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4787 return TEST_SKIPPED;
4789 /* Create ZUC session */
4790 retval = create_zuc_cipher_auth_encrypt_generate_session(
4791 ts_params->valid_devs[0],
4795 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4797 /* clear mbuf payload */
4798 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4799 rte_pktmbuf_tailroom(ut_params->ibuf));
4801 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4802 /* Append data which is padded to a multiple of */
4803 /* the algorithms block size */
4804 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4805 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4807 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4809 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4811 /* Create ZUC operation */
4812 retval = create_zuc_cipher_hash_generate_operation(tdata);
4816 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4817 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4818 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4820 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4822 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4823 ut_params->obuf = ut_params->op->sym->m_src;
4824 if (ut_params->obuf)
4825 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4827 ciphertext = plaintext;
4829 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4831 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4833 tdata->ciphertext.data,
4834 tdata->validDataLenInBits.len,
4835 "ZUC Ciphertext data not as expected");
4837 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4838 + plaintext_pad_len;
4841 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4845 "ZUC Generated auth tag not as expected");
4850 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4852 struct crypto_testsuite_params *ts_params = &testsuite_params;
4853 struct crypto_unittest_params *ut_params = &unittest_params;
4857 uint8_t *plaintext, *ciphertext;
4858 unsigned plaintext_pad_len;
4859 unsigned plaintext_len;
4860 struct rte_cryptodev_info dev_info;
4862 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4863 uint64_t feat_flags = dev_info.feature_flags;
4865 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4866 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4867 printf("Device doesn't support RAW data-path APIs.\n");
4868 return TEST_SKIPPED;
4871 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4872 return TEST_SKIPPED;
4874 /* Verify the capabilities */
4875 struct rte_cryptodev_sym_capability_idx cap_idx;
4876 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4877 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4878 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4880 return TEST_SKIPPED;
4881 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4882 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4883 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4885 return TEST_SKIPPED;
4887 /* Create SNOW 3G session */
4888 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4889 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4890 RTE_CRYPTO_AUTH_OP_GENERATE,
4891 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4892 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4893 tdata->key.data, tdata->key.len,
4894 tdata->auth_iv.len, tdata->digest.len,
4895 tdata->cipher_iv.len);
4898 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4900 /* clear mbuf payload */
4901 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4902 rte_pktmbuf_tailroom(ut_params->ibuf));
4904 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4905 /* Append data which is padded to a multiple of */
4906 /* the algorithms block size */
4907 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4908 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4910 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4912 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4914 /* Create SNOW 3G operation */
4915 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4916 tdata->digest.len, tdata->auth_iv.data,
4918 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4919 tdata->cipher_iv.data, tdata->cipher_iv.len,
4920 tdata->validCipherLenInBits.len,
4922 tdata->validAuthLenInBits.len,
4928 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4929 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4930 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4932 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4934 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4935 ut_params->obuf = ut_params->op->sym->m_src;
4936 if (ut_params->obuf)
4937 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4939 ciphertext = plaintext;
4941 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4943 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4945 tdata->ciphertext.data,
4946 tdata->validDataLenInBits.len,
4947 "SNOW 3G Ciphertext data not as expected");
4949 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4950 + plaintext_pad_len;
4953 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4956 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4957 "SNOW 3G Generated auth tag not as expected");
4962 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4963 uint8_t op_mode, uint8_t verify)
4965 struct crypto_testsuite_params *ts_params = &testsuite_params;
4966 struct crypto_unittest_params *ut_params = &unittest_params;
4970 uint8_t *plaintext = NULL, *ciphertext = NULL;
4971 unsigned int plaintext_pad_len;
4972 unsigned int plaintext_len;
4973 unsigned int ciphertext_pad_len;
4974 unsigned int ciphertext_len;
4976 struct rte_cryptodev_info dev_info;
4978 /* Verify the capabilities */
4979 struct rte_cryptodev_sym_capability_idx cap_idx;
4980 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4981 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4982 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4984 return TEST_SKIPPED;
4985 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4986 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4987 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4989 return TEST_SKIPPED;
4991 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4992 return TEST_SKIPPED;
4994 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4996 uint64_t feat_flags = dev_info.feature_flags;
4998 if (op_mode == OUT_OF_PLACE) {
4999 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5000 printf("Device doesn't support digest encrypted.\n");
5001 return TEST_SKIPPED;
5003 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5004 return TEST_SKIPPED;
5007 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5008 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5009 printf("Device doesn't support RAW data-path APIs.\n");
5010 return TEST_SKIPPED;
5013 /* Create SNOW 3G session */
5014 retval = create_wireless_algo_auth_cipher_session(
5015 ts_params->valid_devs[0],
5016 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5017 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5018 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5019 : RTE_CRYPTO_AUTH_OP_GENERATE),
5020 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5021 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5022 tdata->key.data, tdata->key.len,
5023 tdata->auth_iv.len, tdata->digest.len,
5024 tdata->cipher_iv.len);
5028 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5029 if (op_mode == OUT_OF_PLACE)
5030 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5032 /* clear mbuf payload */
5033 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5034 rte_pktmbuf_tailroom(ut_params->ibuf));
5035 if (op_mode == OUT_OF_PLACE)
5036 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5037 rte_pktmbuf_tailroom(ut_params->obuf));
5039 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5040 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5041 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5042 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5045 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5046 ciphertext_pad_len);
5047 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5048 if (op_mode == OUT_OF_PLACE)
5049 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5050 debug_hexdump(stdout, "ciphertext:", ciphertext,
5053 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5055 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5056 if (op_mode == OUT_OF_PLACE)
5057 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5058 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5061 /* Create SNOW 3G operation */
5062 retval = create_wireless_algo_auth_cipher_operation(
5063 tdata->digest.data, tdata->digest.len,
5064 tdata->cipher_iv.data, tdata->cipher_iv.len,
5065 tdata->auth_iv.data, tdata->auth_iv.len,
5066 (tdata->digest.offset_bytes == 0 ?
5067 (verify ? ciphertext_pad_len : plaintext_pad_len)
5068 : tdata->digest.offset_bytes),
5069 tdata->validCipherLenInBits.len,
5070 tdata->cipher.offset_bits,
5071 tdata->validAuthLenInBits.len,
5072 tdata->auth.offset_bits,
5073 op_mode, 0, verify);
5078 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5079 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5080 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5082 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5085 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5087 ut_params->obuf = (op_mode == IN_PLACE ?
5088 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5091 if (ut_params->obuf)
5092 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5095 plaintext = ciphertext +
5096 (tdata->cipher.offset_bits >> 3);
5098 debug_hexdump(stdout, "plaintext:", plaintext,
5099 (tdata->plaintext.len >> 3) - tdata->digest.len);
5100 debug_hexdump(stdout, "plaintext expected:",
5101 tdata->plaintext.data,
5102 (tdata->plaintext.len >> 3) - tdata->digest.len);
5104 if (ut_params->obuf)
5105 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5108 ciphertext = plaintext;
5110 debug_hexdump(stdout, "ciphertext:", ciphertext,
5112 debug_hexdump(stdout, "ciphertext expected:",
5113 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5115 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5116 + (tdata->digest.offset_bytes == 0 ?
5117 plaintext_pad_len : tdata->digest.offset_bytes);
5119 debug_hexdump(stdout, "digest:", ut_params->digest,
5121 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5127 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5129 tdata->plaintext.data,
5130 (tdata->plaintext.len - tdata->cipher.offset_bits -
5131 (tdata->digest.len << 3)),
5132 tdata->cipher.offset_bits,
5133 "SNOW 3G Plaintext data not as expected");
5135 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5137 tdata->ciphertext.data,
5138 (tdata->validDataLenInBits.len -
5139 tdata->cipher.offset_bits),
5140 tdata->cipher.offset_bits,
5141 "SNOW 3G Ciphertext data not as expected");
5143 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5146 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5147 "SNOW 3G Generated auth tag not as expected");
5153 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5154 uint8_t op_mode, uint8_t verify)
5156 struct crypto_testsuite_params *ts_params = &testsuite_params;
5157 struct crypto_unittest_params *ut_params = &unittest_params;
5161 const uint8_t *plaintext = NULL;
5162 const uint8_t *ciphertext = NULL;
5163 const uint8_t *digest = NULL;
5164 unsigned int plaintext_pad_len;
5165 unsigned int plaintext_len;
5166 unsigned int ciphertext_pad_len;
5167 unsigned int ciphertext_len;
5168 uint8_t buffer[10000];
5169 uint8_t digest_buffer[10000];
5171 struct rte_cryptodev_info dev_info;
5173 /* Verify the capabilities */
5174 struct rte_cryptodev_sym_capability_idx cap_idx;
5175 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5176 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5177 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5179 return TEST_SKIPPED;
5180 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5181 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5182 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5184 return TEST_SKIPPED;
5186 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5187 return TEST_SKIPPED;
5189 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5191 uint64_t feat_flags = dev_info.feature_flags;
5193 if (op_mode == IN_PLACE) {
5194 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5195 printf("Device doesn't support in-place scatter-gather "
5196 "in both input and output mbufs.\n");
5197 return TEST_SKIPPED;
5199 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5200 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5201 printf("Device doesn't support RAW data-path APIs.\n");
5202 return TEST_SKIPPED;
5205 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5206 return TEST_SKIPPED;
5207 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5208 printf("Device doesn't support out-of-place scatter-gather "
5209 "in both input and output mbufs.\n");
5210 return TEST_SKIPPED;
5212 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5213 printf("Device doesn't support digest encrypted.\n");
5214 return TEST_SKIPPED;
5218 /* Create SNOW 3G session */
5219 retval = create_wireless_algo_auth_cipher_session(
5220 ts_params->valid_devs[0],
5221 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5222 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5223 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5224 : RTE_CRYPTO_AUTH_OP_GENERATE),
5225 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5226 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5227 tdata->key.data, tdata->key.len,
5228 tdata->auth_iv.len, tdata->digest.len,
5229 tdata->cipher_iv.len);
5234 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5235 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5236 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5237 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5239 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5240 plaintext_pad_len, 15, 0);
5241 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5242 "Failed to allocate input buffer in mempool");
5244 if (op_mode == OUT_OF_PLACE) {
5245 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5246 plaintext_pad_len, 15, 0);
5247 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5248 "Failed to allocate output buffer in mempool");
5252 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5253 tdata->ciphertext.data);
5254 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5255 ciphertext_len, buffer);
5256 debug_hexdump(stdout, "ciphertext:", ciphertext,
5259 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5260 tdata->plaintext.data);
5261 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5262 plaintext_len, buffer);
5263 debug_hexdump(stdout, "plaintext:", plaintext,
5266 memset(buffer, 0, sizeof(buffer));
5268 /* Create SNOW 3G operation */
5269 retval = create_wireless_algo_auth_cipher_operation(
5270 tdata->digest.data, tdata->digest.len,
5271 tdata->cipher_iv.data, tdata->cipher_iv.len,
5272 tdata->auth_iv.data, tdata->auth_iv.len,
5273 (tdata->digest.offset_bytes == 0 ?
5274 (verify ? ciphertext_pad_len : plaintext_pad_len)
5275 : tdata->digest.offset_bytes),
5276 tdata->validCipherLenInBits.len,
5277 tdata->cipher.offset_bits,
5278 tdata->validAuthLenInBits.len,
5279 tdata->auth.offset_bits,
5280 op_mode, 1, verify);
5285 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5286 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5287 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5289 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5292 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5294 ut_params->obuf = (op_mode == IN_PLACE ?
5295 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5298 if (ut_params->obuf)
5299 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5300 plaintext_len, buffer);
5302 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5303 plaintext_len, buffer);
5305 debug_hexdump(stdout, "plaintext:", plaintext,
5306 (tdata->plaintext.len >> 3) - tdata->digest.len);
5307 debug_hexdump(stdout, "plaintext expected:",
5308 tdata->plaintext.data,
5309 (tdata->plaintext.len >> 3) - tdata->digest.len);
5311 if (ut_params->obuf)
5312 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5313 ciphertext_len, buffer);
5315 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5316 ciphertext_len, buffer);
5318 debug_hexdump(stdout, "ciphertext:", ciphertext,
5320 debug_hexdump(stdout, "ciphertext expected:",
5321 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5323 if (ut_params->obuf)
5324 digest = rte_pktmbuf_read(ut_params->obuf,
5325 (tdata->digest.offset_bytes == 0 ?
5326 plaintext_pad_len : tdata->digest.offset_bytes),
5327 tdata->digest.len, digest_buffer);
5329 digest = rte_pktmbuf_read(ut_params->ibuf,
5330 (tdata->digest.offset_bytes == 0 ?
5331 plaintext_pad_len : tdata->digest.offset_bytes),
5332 tdata->digest.len, digest_buffer);
5334 debug_hexdump(stdout, "digest:", digest,
5336 debug_hexdump(stdout, "digest expected:",
5337 tdata->digest.data, tdata->digest.len);
5342 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5344 tdata->plaintext.data,
5345 (tdata->plaintext.len - tdata->cipher.offset_bits -
5346 (tdata->digest.len << 3)),
5347 tdata->cipher.offset_bits,
5348 "SNOW 3G Plaintext data not as expected");
5350 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5352 tdata->ciphertext.data,
5353 (tdata->validDataLenInBits.len -
5354 tdata->cipher.offset_bits),
5355 tdata->cipher.offset_bits,
5356 "SNOW 3G Ciphertext data not as expected");
5358 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5361 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5362 "SNOW 3G Generated auth tag not as expected");
5368 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5369 uint8_t op_mode, uint8_t verify)
5371 struct crypto_testsuite_params *ts_params = &testsuite_params;
5372 struct crypto_unittest_params *ut_params = &unittest_params;
5376 uint8_t *plaintext = NULL, *ciphertext = NULL;
5377 unsigned int plaintext_pad_len;
5378 unsigned int plaintext_len;
5379 unsigned int ciphertext_pad_len;
5380 unsigned int ciphertext_len;
5382 struct rte_cryptodev_info dev_info;
5384 /* Verify the capabilities */
5385 struct rte_cryptodev_sym_capability_idx cap_idx;
5386 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5387 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5388 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5390 return TEST_SKIPPED;
5391 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5392 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5393 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5395 return TEST_SKIPPED;
5397 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5399 uint64_t feat_flags = dev_info.feature_flags;
5401 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5402 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5403 printf("Device doesn't support RAW data-path APIs.\n");
5404 return TEST_SKIPPED;
5407 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5408 return TEST_SKIPPED;
5410 if (op_mode == OUT_OF_PLACE) {
5411 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5412 return TEST_SKIPPED;
5413 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5414 printf("Device doesn't support digest encrypted.\n");
5415 return TEST_SKIPPED;
5419 /* Create KASUMI session */
5420 retval = create_wireless_algo_auth_cipher_session(
5421 ts_params->valid_devs[0],
5422 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5423 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5424 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5425 : RTE_CRYPTO_AUTH_OP_GENERATE),
5426 RTE_CRYPTO_AUTH_KASUMI_F9,
5427 RTE_CRYPTO_CIPHER_KASUMI_F8,
5428 tdata->key.data, tdata->key.len,
5429 0, tdata->digest.len,
5430 tdata->cipher_iv.len);
5435 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5436 if (op_mode == OUT_OF_PLACE)
5437 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5439 /* clear mbuf payload */
5440 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5441 rte_pktmbuf_tailroom(ut_params->ibuf));
5442 if (op_mode == OUT_OF_PLACE)
5443 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5444 rte_pktmbuf_tailroom(ut_params->obuf));
5446 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5447 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5448 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5449 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5452 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5453 ciphertext_pad_len);
5454 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5455 if (op_mode == OUT_OF_PLACE)
5456 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5457 debug_hexdump(stdout, "ciphertext:", ciphertext,
5460 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5462 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5463 if (op_mode == OUT_OF_PLACE)
5464 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5465 debug_hexdump(stdout, "plaintext:", plaintext,
5469 /* Create KASUMI operation */
5470 retval = create_wireless_algo_auth_cipher_operation(
5471 tdata->digest.data, tdata->digest.len,
5472 tdata->cipher_iv.data, tdata->cipher_iv.len,
5474 (tdata->digest.offset_bytes == 0 ?
5475 (verify ? ciphertext_pad_len : plaintext_pad_len)
5476 : tdata->digest.offset_bytes),
5477 tdata->validCipherLenInBits.len,
5478 tdata->validCipherOffsetInBits.len,
5479 tdata->validAuthLenInBits.len,
5481 op_mode, 0, verify);
5486 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5487 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5488 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5490 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5493 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5495 ut_params->obuf = (op_mode == IN_PLACE ?
5496 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5500 if (ut_params->obuf)
5501 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5504 plaintext = ciphertext;
5506 debug_hexdump(stdout, "plaintext:", plaintext,
5507 (tdata->plaintext.len >> 3) - tdata->digest.len);
5508 debug_hexdump(stdout, "plaintext expected:",
5509 tdata->plaintext.data,
5510 (tdata->plaintext.len >> 3) - tdata->digest.len);
5512 if (ut_params->obuf)
5513 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5516 ciphertext = plaintext;
5518 debug_hexdump(stdout, "ciphertext:", ciphertext,
5520 debug_hexdump(stdout, "ciphertext expected:",
5521 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5523 ut_params->digest = rte_pktmbuf_mtod(
5524 ut_params->obuf, uint8_t *) +
5525 (tdata->digest.offset_bytes == 0 ?
5526 plaintext_pad_len : tdata->digest.offset_bytes);
5528 debug_hexdump(stdout, "digest:", ut_params->digest,
5530 debug_hexdump(stdout, "digest expected:",
5531 tdata->digest.data, tdata->digest.len);
5536 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5538 tdata->plaintext.data,
5539 tdata->plaintext.len >> 3,
5540 "KASUMI Plaintext data not as expected");
5542 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5544 tdata->ciphertext.data,
5545 tdata->ciphertext.len >> 3,
5546 "KASUMI Ciphertext data not as expected");
5548 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5551 DIGEST_BYTE_LENGTH_KASUMI_F9,
5552 "KASUMI Generated auth tag not as expected");
5558 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5559 uint8_t op_mode, uint8_t verify)
5561 struct crypto_testsuite_params *ts_params = &testsuite_params;
5562 struct crypto_unittest_params *ut_params = &unittest_params;
5566 const uint8_t *plaintext = NULL;
5567 const uint8_t *ciphertext = NULL;
5568 const uint8_t *digest = NULL;
5569 unsigned int plaintext_pad_len;
5570 unsigned int plaintext_len;
5571 unsigned int ciphertext_pad_len;
5572 unsigned int ciphertext_len;
5573 uint8_t buffer[10000];
5574 uint8_t digest_buffer[10000];
5576 struct rte_cryptodev_info dev_info;
5578 /* Verify the capabilities */
5579 struct rte_cryptodev_sym_capability_idx cap_idx;
5580 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5581 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5582 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5584 return TEST_SKIPPED;
5585 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5586 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5587 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5589 return TEST_SKIPPED;
5591 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5592 return TEST_SKIPPED;
5594 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5596 uint64_t feat_flags = dev_info.feature_flags;
5598 if (op_mode == IN_PLACE) {
5599 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5600 printf("Device doesn't support in-place scatter-gather "
5601 "in both input and output mbufs.\n");
5602 return TEST_SKIPPED;
5604 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5605 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5606 printf("Device doesn't support RAW data-path APIs.\n");
5607 return TEST_SKIPPED;
5610 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5611 return TEST_SKIPPED;
5612 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5613 printf("Device doesn't support out-of-place scatter-gather "
5614 "in both input and output mbufs.\n");
5615 return TEST_SKIPPED;
5617 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5618 printf("Device doesn't support digest encrypted.\n");
5619 return TEST_SKIPPED;
5623 /* Create KASUMI session */
5624 retval = create_wireless_algo_auth_cipher_session(
5625 ts_params->valid_devs[0],
5626 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5627 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5628 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5629 : RTE_CRYPTO_AUTH_OP_GENERATE),
5630 RTE_CRYPTO_AUTH_KASUMI_F9,
5631 RTE_CRYPTO_CIPHER_KASUMI_F8,
5632 tdata->key.data, tdata->key.len,
5633 0, tdata->digest.len,
5634 tdata->cipher_iv.len);
5639 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5640 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5641 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5642 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5644 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5645 plaintext_pad_len, 15, 0);
5646 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5647 "Failed to allocate input buffer in mempool");
5649 if (op_mode == OUT_OF_PLACE) {
5650 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5651 plaintext_pad_len, 15, 0);
5652 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5653 "Failed to allocate output buffer in mempool");
5657 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5658 tdata->ciphertext.data);
5659 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5660 ciphertext_len, buffer);
5661 debug_hexdump(stdout, "ciphertext:", ciphertext,
5664 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5665 tdata->plaintext.data);
5666 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5667 plaintext_len, buffer);
5668 debug_hexdump(stdout, "plaintext:", plaintext,
5671 memset(buffer, 0, sizeof(buffer));
5673 /* Create KASUMI operation */
5674 retval = create_wireless_algo_auth_cipher_operation(
5675 tdata->digest.data, tdata->digest.len,
5676 tdata->cipher_iv.data, tdata->cipher_iv.len,
5678 (tdata->digest.offset_bytes == 0 ?
5679 (verify ? ciphertext_pad_len : plaintext_pad_len)
5680 : tdata->digest.offset_bytes),
5681 tdata->validCipherLenInBits.len,
5682 tdata->validCipherOffsetInBits.len,
5683 tdata->validAuthLenInBits.len,
5685 op_mode, 1, verify);
5690 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5691 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5692 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5694 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5697 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5699 ut_params->obuf = (op_mode == IN_PLACE ?
5700 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5703 if (ut_params->obuf)
5704 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5705 plaintext_len, buffer);
5707 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5708 plaintext_len, buffer);
5710 debug_hexdump(stdout, "plaintext:", plaintext,
5711 (tdata->plaintext.len >> 3) - tdata->digest.len);
5712 debug_hexdump(stdout, "plaintext expected:",
5713 tdata->plaintext.data,
5714 (tdata->plaintext.len >> 3) - tdata->digest.len);
5716 if (ut_params->obuf)
5717 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5718 ciphertext_len, buffer);
5720 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5721 ciphertext_len, buffer);
5723 debug_hexdump(stdout, "ciphertext:", ciphertext,
5725 debug_hexdump(stdout, "ciphertext expected:",
5726 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5728 if (ut_params->obuf)
5729 digest = rte_pktmbuf_read(ut_params->obuf,
5730 (tdata->digest.offset_bytes == 0 ?
5731 plaintext_pad_len : tdata->digest.offset_bytes),
5732 tdata->digest.len, digest_buffer);
5734 digest = rte_pktmbuf_read(ut_params->ibuf,
5735 (tdata->digest.offset_bytes == 0 ?
5736 plaintext_pad_len : tdata->digest.offset_bytes),
5737 tdata->digest.len, digest_buffer);
5739 debug_hexdump(stdout, "digest:", digest,
5741 debug_hexdump(stdout, "digest expected:",
5742 tdata->digest.data, tdata->digest.len);
5747 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5749 tdata->plaintext.data,
5750 tdata->plaintext.len >> 3,
5751 "KASUMI Plaintext data not as expected");
5753 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5755 tdata->ciphertext.data,
5756 tdata->validDataLenInBits.len,
5757 "KASUMI Ciphertext data not as expected");
5759 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5762 DIGEST_BYTE_LENGTH_KASUMI_F9,
5763 "KASUMI Generated auth tag not as expected");
5769 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5771 struct crypto_testsuite_params *ts_params = &testsuite_params;
5772 struct crypto_unittest_params *ut_params = &unittest_params;
5776 uint8_t *plaintext, *ciphertext;
5777 unsigned plaintext_pad_len;
5778 unsigned plaintext_len;
5779 struct rte_cryptodev_info dev_info;
5781 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5782 uint64_t feat_flags = dev_info.feature_flags;
5784 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5785 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5786 printf("Device doesn't support RAW data-path APIs.\n");
5787 return TEST_SKIPPED;
5790 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5791 return TEST_SKIPPED;
5793 /* Verify the capabilities */
5794 struct rte_cryptodev_sym_capability_idx cap_idx;
5795 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5796 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5797 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5799 return TEST_SKIPPED;
5800 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5801 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5802 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5804 return TEST_SKIPPED;
5806 /* Create KASUMI session */
5807 retval = create_wireless_algo_cipher_auth_session(
5808 ts_params->valid_devs[0],
5809 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5810 RTE_CRYPTO_AUTH_OP_GENERATE,
5811 RTE_CRYPTO_AUTH_KASUMI_F9,
5812 RTE_CRYPTO_CIPHER_KASUMI_F8,
5813 tdata->key.data, tdata->key.len,
5814 0, tdata->digest.len,
5815 tdata->cipher_iv.len);
5819 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5821 /* clear mbuf payload */
5822 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5823 rte_pktmbuf_tailroom(ut_params->ibuf));
5825 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5826 /* Append data which is padded to a multiple of */
5827 /* the algorithms block size */
5828 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5829 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5831 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5833 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5835 /* Create KASUMI operation */
5836 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5837 tdata->digest.len, NULL, 0,
5838 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5839 tdata->cipher_iv.data, tdata->cipher_iv.len,
5840 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5841 tdata->validCipherOffsetInBits.len,
5842 tdata->validAuthLenInBits.len,
5848 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5849 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5850 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5852 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5854 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5856 if (ut_params->op->sym->m_dst)
5857 ut_params->obuf = ut_params->op->sym->m_dst;
5859 ut_params->obuf = ut_params->op->sym->m_src;
5861 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5862 tdata->validCipherOffsetInBits.len >> 3);
5864 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5865 + plaintext_pad_len;
5867 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5868 (tdata->validCipherOffsetInBits.len >> 3);
5870 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5872 reference_ciphertext,
5873 tdata->validCipherLenInBits.len,
5874 "KASUMI Ciphertext data not as expected");
5877 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5880 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5881 "KASUMI Generated auth tag not as expected");
5886 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
5887 const enum rte_crypto_cipher_algorithm cipher_algo,
5888 const uint16_t key_size, const uint16_t iv_size)
5890 struct rte_cryptodev_sym_capability_idx cap_idx;
5891 const struct rte_cryptodev_symmetric_capability *cap;
5893 /* Check if device supports the algorithm */
5894 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5895 cap_idx.algo.cipher = cipher_algo;
5897 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5903 /* Check if device supports key size and IV size */
5904 if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
5913 check_auth_capability(const struct crypto_testsuite_params *ts_params,
5914 const enum rte_crypto_auth_algorithm auth_algo,
5915 const uint16_t key_size, const uint16_t iv_size,
5916 const uint16_t tag_size)
5918 struct rte_cryptodev_sym_capability_idx cap_idx;
5919 const struct rte_cryptodev_symmetric_capability *cap;
5921 /* Check if device supports the algorithm */
5922 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5923 cap_idx.algo.auth = auth_algo;
5925 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5931 /* Check if device supports key size and IV size */
5932 if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
5933 tag_size, iv_size) < 0) {
5941 test_zuc_encryption(const struct wireless_test_data *tdata)
5943 struct crypto_testsuite_params *ts_params = &testsuite_params;
5944 struct crypto_unittest_params *ut_params = &unittest_params;
5947 uint8_t *plaintext, *ciphertext;
5948 unsigned plaintext_pad_len;
5949 unsigned plaintext_len;
5950 struct rte_cryptodev_info dev_info;
5952 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5953 uint64_t feat_flags = dev_info.feature_flags;
5955 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5956 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5957 printf("Device doesn't support RAW data-path APIs.\n");
5958 return TEST_SKIPPED;
5961 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5962 return TEST_SKIPPED;
5964 /* Check if device supports ZUC EEA3 */
5965 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5966 tdata->key.len, tdata->cipher_iv.len) < 0)
5967 return TEST_SKIPPED;
5969 /* Create ZUC session */
5970 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5971 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5972 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5973 tdata->key.data, tdata->key.len,
5974 tdata->cipher_iv.len);
5978 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5980 /* Clear mbuf payload */
5981 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5982 rte_pktmbuf_tailroom(ut_params->ibuf));
5984 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5985 /* Append data which is padded to a multiple */
5986 /* of the algorithms block size */
5987 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5988 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5990 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5992 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5994 /* Create ZUC operation */
5995 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5996 tdata->cipher_iv.len,
5997 tdata->plaintext.len,
6002 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6003 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6004 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6006 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6008 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6010 ut_params->obuf = ut_params->op->sym->m_dst;
6011 if (ut_params->obuf)
6012 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6014 ciphertext = plaintext;
6016 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6019 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6021 tdata->ciphertext.data,
6022 tdata->validCipherLenInBits.len,
6023 "ZUC Ciphertext data not as expected");
6028 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
6030 struct crypto_testsuite_params *ts_params = &testsuite_params;
6031 struct crypto_unittest_params *ut_params = &unittest_params;
6035 unsigned int plaintext_pad_len;
6036 unsigned int plaintext_len;
6037 const uint8_t *ciphertext;
6038 uint8_t ciphertext_buffer[2048];
6039 struct rte_cryptodev_info dev_info;
6041 /* Check if device supports ZUC EEA3 */
6042 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6043 tdata->key.len, tdata->cipher_iv.len) < 0)
6044 return TEST_SKIPPED;
6046 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6047 return TEST_SKIPPED;
6049 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6051 uint64_t feat_flags = dev_info.feature_flags;
6053 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6054 printf("Device doesn't support in-place scatter-gather. "
6056 return TEST_SKIPPED;
6059 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6060 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6061 printf("Device doesn't support RAW data-path APIs.\n");
6062 return TEST_SKIPPED;
6065 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6067 /* Append data which is padded to a multiple */
6068 /* of the algorithms block size */
6069 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6071 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6072 plaintext_pad_len, 10, 0);
6074 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6075 tdata->plaintext.data);
6077 /* Create ZUC session */
6078 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6079 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6080 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6081 tdata->key.data, tdata->key.len,
6082 tdata->cipher_iv.len);
6086 /* Clear mbuf payload */
6088 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6090 /* Create ZUC operation */
6091 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6092 tdata->cipher_iv.len, tdata->plaintext.len,
6097 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6098 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6099 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6101 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6103 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6105 ut_params->obuf = ut_params->op->sym->m_dst;
6106 if (ut_params->obuf)
6107 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6108 0, plaintext_len, ciphertext_buffer);
6110 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6111 0, plaintext_len, ciphertext_buffer);
6114 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6117 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6119 tdata->ciphertext.data,
6120 tdata->validCipherLenInBits.len,
6121 "ZUC Ciphertext data not as expected");
6127 test_zuc_authentication(const struct wireless_test_data *tdata)
6129 struct crypto_testsuite_params *ts_params = &testsuite_params;
6130 struct crypto_unittest_params *ut_params = &unittest_params;
6133 unsigned plaintext_pad_len;
6134 unsigned plaintext_len;
6137 struct rte_cryptodev_info dev_info;
6139 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6140 uint64_t feat_flags = dev_info.feature_flags;
6142 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6143 (tdata->validAuthLenInBits.len % 8 != 0)) {
6144 printf("Device doesn't support NON-Byte Aligned Data.\n");
6145 return TEST_SKIPPED;
6148 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6149 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6150 printf("Device doesn't support RAW data-path APIs.\n");
6151 return TEST_SKIPPED;
6154 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6155 return TEST_SKIPPED;
6157 /* Check if device supports ZUC EIA3 */
6158 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6159 tdata->key.len, tdata->auth_iv.len,
6160 tdata->digest.len) < 0)
6161 return TEST_SKIPPED;
6163 /* Create ZUC session */
6164 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6165 tdata->key.data, tdata->key.len,
6166 tdata->auth_iv.len, tdata->digest.len,
6167 RTE_CRYPTO_AUTH_OP_GENERATE,
6168 RTE_CRYPTO_AUTH_ZUC_EIA3);
6172 /* alloc mbuf and set payload */
6173 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6175 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6176 rte_pktmbuf_tailroom(ut_params->ibuf));
6178 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6179 /* Append data which is padded to a multiple of */
6180 /* the algorithms block size */
6181 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6182 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6184 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6186 /* Create ZUC operation */
6187 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6188 tdata->auth_iv.data, tdata->auth_iv.len,
6189 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6190 tdata->validAuthLenInBits.len,
6195 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6196 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6197 ut_params->op, 0, 1, 1, 0);
6199 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6201 ut_params->obuf = ut_params->op->sym->m_src;
6202 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6203 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6204 + plaintext_pad_len;
6207 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6211 "ZUC Generated auth tag not as expected");
6217 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6218 uint8_t op_mode, uint8_t verify)
6220 struct crypto_testsuite_params *ts_params = &testsuite_params;
6221 struct crypto_unittest_params *ut_params = &unittest_params;
6225 uint8_t *plaintext = NULL, *ciphertext = NULL;
6226 unsigned int plaintext_pad_len;
6227 unsigned int plaintext_len;
6228 unsigned int ciphertext_pad_len;
6229 unsigned int ciphertext_len;
6231 struct rte_cryptodev_info dev_info;
6233 /* Check if device supports ZUC EEA3 */
6234 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6235 tdata->key.len, tdata->cipher_iv.len) < 0)
6236 return TEST_SKIPPED;
6238 /* Check if device supports ZUC EIA3 */
6239 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6240 tdata->key.len, tdata->auth_iv.len,
6241 tdata->digest.len) < 0)
6242 return TEST_SKIPPED;
6244 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6246 uint64_t feat_flags = dev_info.feature_flags;
6248 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6249 printf("Device doesn't support digest encrypted.\n");
6250 return TEST_SKIPPED;
6252 if (op_mode == IN_PLACE) {
6253 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6254 printf("Device doesn't support in-place scatter-gather "
6255 "in both input and output mbufs.\n");
6256 return TEST_SKIPPED;
6259 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6260 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6261 printf("Device doesn't support RAW data-path APIs.\n");
6262 return TEST_SKIPPED;
6265 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6266 return TEST_SKIPPED;
6267 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6268 printf("Device doesn't support out-of-place scatter-gather "
6269 "in both input and output mbufs.\n");
6270 return TEST_SKIPPED;
6274 /* Create ZUC session */
6275 retval = create_wireless_algo_auth_cipher_session(
6276 ts_params->valid_devs[0],
6277 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6278 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6279 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6280 : RTE_CRYPTO_AUTH_OP_GENERATE),
6281 RTE_CRYPTO_AUTH_ZUC_EIA3,
6282 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6283 tdata->key.data, tdata->key.len,
6284 tdata->auth_iv.len, tdata->digest.len,
6285 tdata->cipher_iv.len);
6290 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6291 if (op_mode == OUT_OF_PLACE)
6292 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6294 /* clear mbuf payload */
6295 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6296 rte_pktmbuf_tailroom(ut_params->ibuf));
6297 if (op_mode == OUT_OF_PLACE)
6298 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6299 rte_pktmbuf_tailroom(ut_params->obuf));
6301 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6302 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6303 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6304 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6307 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6308 ciphertext_pad_len);
6309 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6310 if (op_mode == OUT_OF_PLACE)
6311 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6312 debug_hexdump(stdout, "ciphertext:", ciphertext,
6315 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6317 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6318 if (op_mode == OUT_OF_PLACE)
6319 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6320 debug_hexdump(stdout, "plaintext:", plaintext,
6324 /* Create ZUC operation */
6325 retval = create_wireless_algo_auth_cipher_operation(
6326 tdata->digest.data, tdata->digest.len,
6327 tdata->cipher_iv.data, tdata->cipher_iv.len,
6328 tdata->auth_iv.data, tdata->auth_iv.len,
6329 (tdata->digest.offset_bytes == 0 ?
6330 (verify ? ciphertext_pad_len : plaintext_pad_len)
6331 : tdata->digest.offset_bytes),
6332 tdata->validCipherLenInBits.len,
6333 tdata->validCipherOffsetInBits.len,
6334 tdata->validAuthLenInBits.len,
6336 op_mode, 0, verify);
6341 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6342 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6343 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6345 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6348 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6350 ut_params->obuf = (op_mode == IN_PLACE ?
6351 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6355 if (ut_params->obuf)
6356 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6359 plaintext = ciphertext;
6361 debug_hexdump(stdout, "plaintext:", plaintext,
6362 (tdata->plaintext.len >> 3) - tdata->digest.len);
6363 debug_hexdump(stdout, "plaintext expected:",
6364 tdata->plaintext.data,
6365 (tdata->plaintext.len >> 3) - tdata->digest.len);
6367 if (ut_params->obuf)
6368 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6371 ciphertext = plaintext;
6373 debug_hexdump(stdout, "ciphertext:", ciphertext,
6375 debug_hexdump(stdout, "ciphertext expected:",
6376 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6378 ut_params->digest = rte_pktmbuf_mtod(
6379 ut_params->obuf, uint8_t *) +
6380 (tdata->digest.offset_bytes == 0 ?
6381 plaintext_pad_len : tdata->digest.offset_bytes);
6383 debug_hexdump(stdout, "digest:", ut_params->digest,
6385 debug_hexdump(stdout, "digest expected:",
6386 tdata->digest.data, tdata->digest.len);
6391 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6393 tdata->plaintext.data,
6394 tdata->plaintext.len >> 3,
6395 "ZUC Plaintext data not as expected");
6397 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6399 tdata->ciphertext.data,
6400 tdata->ciphertext.len >> 3,
6401 "ZUC Ciphertext data not as expected");
6403 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6406 DIGEST_BYTE_LENGTH_KASUMI_F9,
6407 "ZUC Generated auth tag not as expected");
6413 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6414 uint8_t op_mode, uint8_t verify)
6416 struct crypto_testsuite_params *ts_params = &testsuite_params;
6417 struct crypto_unittest_params *ut_params = &unittest_params;
6421 const uint8_t *plaintext = NULL;
6422 const uint8_t *ciphertext = NULL;
6423 const uint8_t *digest = NULL;
6424 unsigned int plaintext_pad_len;
6425 unsigned int plaintext_len;
6426 unsigned int ciphertext_pad_len;
6427 unsigned int ciphertext_len;
6428 uint8_t buffer[10000];
6429 uint8_t digest_buffer[10000];
6431 struct rte_cryptodev_info dev_info;
6433 /* Check if device supports ZUC EEA3 */
6434 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6435 tdata->key.len, tdata->cipher_iv.len) < 0)
6436 return TEST_SKIPPED;
6438 /* Check if device supports ZUC EIA3 */
6439 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6440 tdata->key.len, tdata->auth_iv.len,
6441 tdata->digest.len) < 0)
6442 return TEST_SKIPPED;
6444 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6446 uint64_t feat_flags = dev_info.feature_flags;
6448 if (op_mode == IN_PLACE) {
6449 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6450 printf("Device doesn't support in-place scatter-gather "
6451 "in both input and output mbufs.\n");
6452 return TEST_SKIPPED;
6455 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6456 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6457 printf("Device doesn't support RAW data-path APIs.\n");
6458 return TEST_SKIPPED;
6461 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6462 return TEST_SKIPPED;
6463 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6464 printf("Device doesn't support out-of-place scatter-gather "
6465 "in both input and output mbufs.\n");
6466 return TEST_SKIPPED;
6468 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6469 printf("Device doesn't support digest encrypted.\n");
6470 return TEST_SKIPPED;
6474 /* Create ZUC session */
6475 retval = create_wireless_algo_auth_cipher_session(
6476 ts_params->valid_devs[0],
6477 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6478 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6479 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6480 : RTE_CRYPTO_AUTH_OP_GENERATE),
6481 RTE_CRYPTO_AUTH_ZUC_EIA3,
6482 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6483 tdata->key.data, tdata->key.len,
6484 tdata->auth_iv.len, tdata->digest.len,
6485 tdata->cipher_iv.len);
6490 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6491 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6492 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6493 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6495 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6496 plaintext_pad_len, 15, 0);
6497 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6498 "Failed to allocate input buffer in mempool");
6500 if (op_mode == OUT_OF_PLACE) {
6501 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6502 plaintext_pad_len, 15, 0);
6503 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6504 "Failed to allocate output buffer in mempool");
6508 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6509 tdata->ciphertext.data);
6510 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6511 ciphertext_len, buffer);
6512 debug_hexdump(stdout, "ciphertext:", ciphertext,
6515 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6516 tdata->plaintext.data);
6517 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6518 plaintext_len, buffer);
6519 debug_hexdump(stdout, "plaintext:", plaintext,
6522 memset(buffer, 0, sizeof(buffer));
6524 /* Create ZUC operation */
6525 retval = create_wireless_algo_auth_cipher_operation(
6526 tdata->digest.data, tdata->digest.len,
6527 tdata->cipher_iv.data, tdata->cipher_iv.len,
6529 (tdata->digest.offset_bytes == 0 ?
6530 (verify ? ciphertext_pad_len : plaintext_pad_len)
6531 : tdata->digest.offset_bytes),
6532 tdata->validCipherLenInBits.len,
6533 tdata->validCipherOffsetInBits.len,
6534 tdata->validAuthLenInBits.len,
6536 op_mode, 1, verify);
6541 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6542 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6543 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6545 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6548 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6550 ut_params->obuf = (op_mode == IN_PLACE ?
6551 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6554 if (ut_params->obuf)
6555 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6556 plaintext_len, buffer);
6558 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6559 plaintext_len, buffer);
6561 debug_hexdump(stdout, "plaintext:", plaintext,
6562 (tdata->plaintext.len >> 3) - tdata->digest.len);
6563 debug_hexdump(stdout, "plaintext expected:",
6564 tdata->plaintext.data,
6565 (tdata->plaintext.len >> 3) - tdata->digest.len);
6567 if (ut_params->obuf)
6568 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6569 ciphertext_len, buffer);
6571 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6572 ciphertext_len, buffer);
6574 debug_hexdump(stdout, "ciphertext:", ciphertext,
6576 debug_hexdump(stdout, "ciphertext expected:",
6577 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6579 if (ut_params->obuf)
6580 digest = rte_pktmbuf_read(ut_params->obuf,
6581 (tdata->digest.offset_bytes == 0 ?
6582 plaintext_pad_len : tdata->digest.offset_bytes),
6583 tdata->digest.len, digest_buffer);
6585 digest = rte_pktmbuf_read(ut_params->ibuf,
6586 (tdata->digest.offset_bytes == 0 ?
6587 plaintext_pad_len : tdata->digest.offset_bytes),
6588 tdata->digest.len, digest_buffer);
6590 debug_hexdump(stdout, "digest:", digest,
6592 debug_hexdump(stdout, "digest expected:",
6593 tdata->digest.data, tdata->digest.len);
6598 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6600 tdata->plaintext.data,
6601 tdata->plaintext.len >> 3,
6602 "ZUC Plaintext data not as expected");
6604 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6606 tdata->ciphertext.data,
6607 tdata->validDataLenInBits.len,
6608 "ZUC Ciphertext data not as expected");
6610 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6613 DIGEST_BYTE_LENGTH_KASUMI_F9,
6614 "ZUC Generated auth tag not as expected");
6620 test_kasumi_encryption_test_case_1(void)
6622 return test_kasumi_encryption(&kasumi_test_case_1);
6626 test_kasumi_encryption_test_case_1_sgl(void)
6628 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6632 test_kasumi_encryption_test_case_1_oop(void)
6634 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6638 test_kasumi_encryption_test_case_1_oop_sgl(void)
6640 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6644 test_kasumi_encryption_test_case_2(void)
6646 return test_kasumi_encryption(&kasumi_test_case_2);
6650 test_kasumi_encryption_test_case_3(void)
6652 return test_kasumi_encryption(&kasumi_test_case_3);
6656 test_kasumi_encryption_test_case_4(void)
6658 return test_kasumi_encryption(&kasumi_test_case_4);
6662 test_kasumi_encryption_test_case_5(void)
6664 return test_kasumi_encryption(&kasumi_test_case_5);
6668 test_kasumi_decryption_test_case_1(void)
6670 return test_kasumi_decryption(&kasumi_test_case_1);
6674 test_kasumi_decryption_test_case_1_oop(void)
6676 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6680 test_kasumi_decryption_test_case_2(void)
6682 return test_kasumi_decryption(&kasumi_test_case_2);
6686 test_kasumi_decryption_test_case_3(void)
6688 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6689 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6690 return TEST_SKIPPED;
6691 return test_kasumi_decryption(&kasumi_test_case_3);
6695 test_kasumi_decryption_test_case_4(void)
6697 return test_kasumi_decryption(&kasumi_test_case_4);
6701 test_kasumi_decryption_test_case_5(void)
6703 return test_kasumi_decryption(&kasumi_test_case_5);
6706 test_snow3g_encryption_test_case_1(void)
6708 return test_snow3g_encryption(&snow3g_test_case_1);
6712 test_snow3g_encryption_test_case_1_oop(void)
6714 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6718 test_snow3g_encryption_test_case_1_oop_sgl(void)
6720 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6725 test_snow3g_encryption_test_case_1_offset_oop(void)
6727 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6731 test_snow3g_encryption_test_case_2(void)
6733 return test_snow3g_encryption(&snow3g_test_case_2);
6737 test_snow3g_encryption_test_case_3(void)
6739 return test_snow3g_encryption(&snow3g_test_case_3);
6743 test_snow3g_encryption_test_case_4(void)
6745 return test_snow3g_encryption(&snow3g_test_case_4);
6749 test_snow3g_encryption_test_case_5(void)
6751 return test_snow3g_encryption(&snow3g_test_case_5);
6755 test_snow3g_decryption_test_case_1(void)
6757 return test_snow3g_decryption(&snow3g_test_case_1);
6761 test_snow3g_decryption_test_case_1_oop(void)
6763 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6767 test_snow3g_decryption_test_case_2(void)
6769 return test_snow3g_decryption(&snow3g_test_case_2);
6773 test_snow3g_decryption_test_case_3(void)
6775 return test_snow3g_decryption(&snow3g_test_case_3);
6779 test_snow3g_decryption_test_case_4(void)
6781 return test_snow3g_decryption(&snow3g_test_case_4);
6785 test_snow3g_decryption_test_case_5(void)
6787 return test_snow3g_decryption(&snow3g_test_case_5);
6791 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6792 * Pattern digest from snow3g_test_data must be allocated as
6793 * 4 last bytes in plaintext.
6796 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6797 struct snow3g_hash_test_data *output)
6799 if ((pattern != NULL) && (output != NULL)) {
6800 output->key.len = pattern->key.len;
6802 memcpy(output->key.data,
6803 pattern->key.data, pattern->key.len);
6805 output->auth_iv.len = pattern->auth_iv.len;
6807 memcpy(output->auth_iv.data,
6808 pattern->auth_iv.data, pattern->auth_iv.len);
6810 output->plaintext.len = pattern->plaintext.len;
6812 memcpy(output->plaintext.data,
6813 pattern->plaintext.data, pattern->plaintext.len >> 3);
6815 output->digest.len = pattern->digest.len;
6817 memcpy(output->digest.data,
6818 &pattern->plaintext.data[pattern->digest.offset_bytes],
6819 pattern->digest.len);
6821 output->validAuthLenInBits.len =
6822 pattern->validAuthLenInBits.len;
6827 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6830 test_snow3g_decryption_with_digest_test_case_1(void)
6832 struct snow3g_hash_test_data snow3g_hash_data;
6833 struct rte_cryptodev_info dev_info;
6834 struct crypto_testsuite_params *ts_params = &testsuite_params;
6836 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6837 uint64_t feat_flags = dev_info.feature_flags;
6839 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6840 printf("Device doesn't support encrypted digest operations.\n");
6841 return TEST_SKIPPED;
6845 * Function prepare data for hash veryfication test case.
6846 * Digest is allocated in 4 last bytes in plaintext, pattern.
6848 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6850 return test_snow3g_decryption(&snow3g_test_case_7) &
6851 test_snow3g_authentication_verify(&snow3g_hash_data);
6855 test_snow3g_cipher_auth_test_case_1(void)
6857 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6861 test_snow3g_auth_cipher_test_case_1(void)
6863 return test_snow3g_auth_cipher(
6864 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6868 test_snow3g_auth_cipher_test_case_2(void)
6870 return test_snow3g_auth_cipher(
6871 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6875 test_snow3g_auth_cipher_test_case_2_oop(void)
6877 return test_snow3g_auth_cipher(
6878 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6882 test_snow3g_auth_cipher_part_digest_enc(void)
6884 return test_snow3g_auth_cipher(
6885 &snow3g_auth_cipher_partial_digest_encryption,
6890 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6892 return test_snow3g_auth_cipher(
6893 &snow3g_auth_cipher_partial_digest_encryption,
6898 test_snow3g_auth_cipher_test_case_3_sgl(void)
6900 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6901 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6902 return TEST_SKIPPED;
6903 return test_snow3g_auth_cipher_sgl(
6904 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6908 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6910 return test_snow3g_auth_cipher_sgl(
6911 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6915 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6917 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6918 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6919 return TEST_SKIPPED;
6920 return test_snow3g_auth_cipher_sgl(
6921 &snow3g_auth_cipher_partial_digest_encryption,
6926 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6928 return test_snow3g_auth_cipher_sgl(
6929 &snow3g_auth_cipher_partial_digest_encryption,
6934 test_snow3g_auth_cipher_verify_test_case_1(void)
6936 return test_snow3g_auth_cipher(
6937 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6941 test_snow3g_auth_cipher_verify_test_case_2(void)
6943 return test_snow3g_auth_cipher(
6944 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6948 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6950 return test_snow3g_auth_cipher(
6951 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6955 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6957 return test_snow3g_auth_cipher(
6958 &snow3g_auth_cipher_partial_digest_encryption,
6963 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6965 return test_snow3g_auth_cipher(
6966 &snow3g_auth_cipher_partial_digest_encryption,
6971 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6973 return test_snow3g_auth_cipher_sgl(
6974 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6978 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6980 return test_snow3g_auth_cipher_sgl(
6981 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6985 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6987 return test_snow3g_auth_cipher_sgl(
6988 &snow3g_auth_cipher_partial_digest_encryption,
6993 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6995 return test_snow3g_auth_cipher_sgl(
6996 &snow3g_auth_cipher_partial_digest_encryption,
7001 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7003 return test_snow3g_auth_cipher(
7004 &snow3g_test_case_7, IN_PLACE, 0);
7008 test_kasumi_auth_cipher_test_case_1(void)
7010 return test_kasumi_auth_cipher(
7011 &kasumi_test_case_3, IN_PLACE, 0);
7015 test_kasumi_auth_cipher_test_case_2(void)
7017 return test_kasumi_auth_cipher(
7018 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7022 test_kasumi_auth_cipher_test_case_2_oop(void)
7024 return test_kasumi_auth_cipher(
7025 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7029 test_kasumi_auth_cipher_test_case_2_sgl(void)
7031 return test_kasumi_auth_cipher_sgl(
7032 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7036 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7038 return test_kasumi_auth_cipher_sgl(
7039 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7043 test_kasumi_auth_cipher_verify_test_case_1(void)
7045 return test_kasumi_auth_cipher(
7046 &kasumi_test_case_3, IN_PLACE, 1);
7050 test_kasumi_auth_cipher_verify_test_case_2(void)
7052 return test_kasumi_auth_cipher(
7053 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7057 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7059 return test_kasumi_auth_cipher(
7060 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7064 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7066 return test_kasumi_auth_cipher_sgl(
7067 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7071 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7073 return test_kasumi_auth_cipher_sgl(
7074 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7078 test_kasumi_cipher_auth_test_case_1(void)
7080 return test_kasumi_cipher_auth(&kasumi_test_case_6);
7084 test_zuc_encryption_test_case_1(void)
7086 return test_zuc_encryption(&zuc_test_case_cipher_193b);
7090 test_zuc_encryption_test_case_2(void)
7092 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7096 test_zuc_encryption_test_case_3(void)
7098 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7102 test_zuc_encryption_test_case_4(void)
7104 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7108 test_zuc_encryption_test_case_5(void)
7110 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7114 test_zuc_encryption_test_case_6_sgl(void)
7116 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7120 test_zuc_encryption_test_case_7(void)
7122 return test_zuc_encryption(&zuc_test_case_cipher_800b_key_256b);
7126 test_zuc_hash_generate_test_case_1(void)
7128 return test_zuc_authentication(&zuc_test_case_auth_1b);
7132 test_zuc_hash_generate_test_case_2(void)
7134 return test_zuc_authentication(&zuc_test_case_auth_90b);
7138 test_zuc_hash_generate_test_case_3(void)
7140 return test_zuc_authentication(&zuc_test_case_auth_577b);
7144 test_zuc_hash_generate_test_case_4(void)
7146 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7150 test_zuc_hash_generate_test_case_5(void)
7152 return test_zuc_authentication(&zuc_test_auth_5670b);
7156 test_zuc_hash_generate_test_case_6(void)
7158 return test_zuc_authentication(&zuc_test_case_auth_128b);
7162 test_zuc_hash_generate_test_case_7(void)
7164 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7168 test_zuc_hash_generate_test_case_8(void)
7170 return test_zuc_authentication(&zuc_test_case_auth_584b);
7174 test_zuc_hash_generate_test_case_9(void)
7176 return test_zuc_authentication(&zuc_test_case_auth_584b_mac_64b);
7180 test_zuc_hash_generate_test_case_10(void)
7182 return test_zuc_authentication(&zuc_test_case_auth_2080b_mac_128b);
7186 test_zuc_cipher_auth_test_case_1(void)
7188 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7192 test_zuc_cipher_auth_test_case_2(void)
7194 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7198 test_zuc_auth_cipher_test_case_1(void)
7200 return test_zuc_auth_cipher(
7201 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7205 test_zuc_auth_cipher_test_case_1_oop(void)
7207 return test_zuc_auth_cipher(
7208 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7212 test_zuc_auth_cipher_test_case_1_sgl(void)
7214 return test_zuc_auth_cipher_sgl(
7215 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7219 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7221 return test_zuc_auth_cipher_sgl(
7222 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7226 test_zuc_auth_cipher_verify_test_case_1(void)
7228 return test_zuc_auth_cipher(
7229 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7233 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7235 return test_zuc_auth_cipher(
7236 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7240 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7242 return test_zuc_auth_cipher_sgl(
7243 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7247 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7249 return test_zuc_auth_cipher_sgl(
7250 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7254 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7256 uint8_t dev_id = testsuite_params.valid_devs[0];
7258 struct rte_cryptodev_sym_capability_idx cap_idx;
7260 /* Check if device supports particular cipher algorithm */
7261 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7262 cap_idx.algo.cipher = tdata->cipher_algo;
7263 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7264 return TEST_SKIPPED;
7266 /* Check if device supports particular hash algorithm */
7267 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7268 cap_idx.algo.auth = tdata->auth_algo;
7269 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7270 return TEST_SKIPPED;
7276 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7277 uint8_t op_mode, uint8_t verify)
7279 struct crypto_testsuite_params *ts_params = &testsuite_params;
7280 struct crypto_unittest_params *ut_params = &unittest_params;
7284 uint8_t *plaintext = NULL, *ciphertext = NULL;
7285 unsigned int plaintext_pad_len;
7286 unsigned int plaintext_len;
7287 unsigned int ciphertext_pad_len;
7288 unsigned int ciphertext_len;
7290 struct rte_cryptodev_info dev_info;
7291 struct rte_crypto_op *op;
7293 /* Check if device supports particular algorithms separately */
7294 if (test_mixed_check_if_unsupported(tdata))
7295 return TEST_SKIPPED;
7296 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7297 return TEST_SKIPPED;
7299 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7301 uint64_t feat_flags = dev_info.feature_flags;
7303 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7304 printf("Device doesn't support digest encrypted.\n");
7305 return TEST_SKIPPED;
7308 /* Create the session */
7310 retval = create_wireless_algo_cipher_auth_session(
7311 ts_params->valid_devs[0],
7312 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7313 RTE_CRYPTO_AUTH_OP_VERIFY,
7316 tdata->auth_key.data, tdata->auth_key.len,
7317 tdata->auth_iv.len, tdata->digest_enc.len,
7318 tdata->cipher_iv.len);
7320 retval = create_wireless_algo_auth_cipher_session(
7321 ts_params->valid_devs[0],
7322 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7323 RTE_CRYPTO_AUTH_OP_GENERATE,
7326 tdata->auth_key.data, tdata->auth_key.len,
7327 tdata->auth_iv.len, tdata->digest_enc.len,
7328 tdata->cipher_iv.len);
7332 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7333 if (op_mode == OUT_OF_PLACE)
7334 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7336 /* clear mbuf payload */
7337 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7338 rte_pktmbuf_tailroom(ut_params->ibuf));
7339 if (op_mode == OUT_OF_PLACE) {
7341 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7342 rte_pktmbuf_tailroom(ut_params->obuf));
7345 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7346 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7347 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7348 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7351 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7352 ciphertext_pad_len);
7353 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7354 if (op_mode == OUT_OF_PLACE)
7355 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7356 debug_hexdump(stdout, "ciphertext:", ciphertext,
7359 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7361 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7362 if (op_mode == OUT_OF_PLACE)
7363 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7364 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7367 /* Create the operation */
7368 retval = create_wireless_algo_auth_cipher_operation(
7369 tdata->digest_enc.data, tdata->digest_enc.len,
7370 tdata->cipher_iv.data, tdata->cipher_iv.len,
7371 tdata->auth_iv.data, tdata->auth_iv.len,
7372 (tdata->digest_enc.offset == 0 ?
7374 : tdata->digest_enc.offset),
7375 tdata->validCipherLen.len_bits,
7376 tdata->cipher.offset_bits,
7377 tdata->validAuthLen.len_bits,
7378 tdata->auth.offset_bits,
7379 op_mode, 0, verify);
7384 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7386 /* Check if the op failed because the device doesn't */
7387 /* support this particular combination of algorithms */
7388 if (op == NULL && ut_params->op->status ==
7389 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7390 printf("Device doesn't support this mixed combination. "
7392 return TEST_SKIPPED;
7396 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7398 ut_params->obuf = (op_mode == IN_PLACE ?
7399 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7402 if (ut_params->obuf)
7403 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7406 plaintext = ciphertext +
7407 (tdata->cipher.offset_bits >> 3);
7409 debug_hexdump(stdout, "plaintext:", plaintext,
7410 tdata->plaintext.len_bits >> 3);
7411 debug_hexdump(stdout, "plaintext expected:",
7412 tdata->plaintext.data,
7413 tdata->plaintext.len_bits >> 3);
7415 if (ut_params->obuf)
7416 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7419 ciphertext = plaintext;
7421 debug_hexdump(stdout, "ciphertext:", ciphertext,
7423 debug_hexdump(stdout, "ciphertext expected:",
7424 tdata->ciphertext.data,
7425 tdata->ciphertext.len_bits >> 3);
7427 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7428 + (tdata->digest_enc.offset == 0 ?
7429 plaintext_pad_len : tdata->digest_enc.offset);
7431 debug_hexdump(stdout, "digest:", ut_params->digest,
7432 tdata->digest_enc.len);
7433 debug_hexdump(stdout, "digest expected:",
7434 tdata->digest_enc.data,
7435 tdata->digest_enc.len);
7440 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7442 tdata->plaintext.data,
7443 tdata->plaintext.len_bits >> 3,
7444 "Plaintext data not as expected");
7446 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7448 tdata->ciphertext.data,
7449 tdata->validDataLen.len_bits,
7450 "Ciphertext data not as expected");
7452 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7454 tdata->digest_enc.data,
7455 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7456 "Generated auth tag not as expected");
7459 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7460 "crypto op processing failed");
7466 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7467 uint8_t op_mode, uint8_t verify)
7469 struct crypto_testsuite_params *ts_params = &testsuite_params;
7470 struct crypto_unittest_params *ut_params = &unittest_params;
7474 const uint8_t *plaintext = NULL;
7475 const uint8_t *ciphertext = NULL;
7476 const uint8_t *digest = NULL;
7477 unsigned int plaintext_pad_len;
7478 unsigned int plaintext_len;
7479 unsigned int ciphertext_pad_len;
7480 unsigned int ciphertext_len;
7481 uint8_t buffer[10000];
7482 uint8_t digest_buffer[10000];
7484 struct rte_cryptodev_info dev_info;
7485 struct rte_crypto_op *op;
7487 /* Check if device supports particular algorithms */
7488 if (test_mixed_check_if_unsupported(tdata))
7489 return TEST_SKIPPED;
7490 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7491 return TEST_SKIPPED;
7493 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7495 uint64_t feat_flags = dev_info.feature_flags;
7497 if (op_mode == IN_PLACE) {
7498 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7499 printf("Device doesn't support in-place scatter-gather "
7500 "in both input and output mbufs.\n");
7501 return TEST_SKIPPED;
7504 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7505 printf("Device doesn't support out-of-place scatter-gather "
7506 "in both input and output mbufs.\n");
7507 return TEST_SKIPPED;
7509 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7510 printf("Device doesn't support digest encrypted.\n");
7511 return TEST_SKIPPED;
7515 /* Create the session */
7517 retval = create_wireless_algo_cipher_auth_session(
7518 ts_params->valid_devs[0],
7519 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7520 RTE_CRYPTO_AUTH_OP_VERIFY,
7523 tdata->auth_key.data, tdata->auth_key.len,
7524 tdata->auth_iv.len, tdata->digest_enc.len,
7525 tdata->cipher_iv.len);
7527 retval = create_wireless_algo_auth_cipher_session(
7528 ts_params->valid_devs[0],
7529 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7530 RTE_CRYPTO_AUTH_OP_GENERATE,
7533 tdata->auth_key.data, tdata->auth_key.len,
7534 tdata->auth_iv.len, tdata->digest_enc.len,
7535 tdata->cipher_iv.len);
7539 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7540 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7541 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7542 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7544 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7545 ciphertext_pad_len, 15, 0);
7546 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7547 "Failed to allocate input buffer in mempool");
7549 if (op_mode == OUT_OF_PLACE) {
7550 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7551 plaintext_pad_len, 15, 0);
7552 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7553 "Failed to allocate output buffer in mempool");
7557 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7558 tdata->ciphertext.data);
7559 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7560 ciphertext_len, buffer);
7561 debug_hexdump(stdout, "ciphertext:", ciphertext,
7564 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7565 tdata->plaintext.data);
7566 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7567 plaintext_len, buffer);
7568 debug_hexdump(stdout, "plaintext:", plaintext,
7571 memset(buffer, 0, sizeof(buffer));
7573 /* Create the operation */
7574 retval = create_wireless_algo_auth_cipher_operation(
7575 tdata->digest_enc.data, tdata->digest_enc.len,
7576 tdata->cipher_iv.data, tdata->cipher_iv.len,
7577 tdata->auth_iv.data, tdata->auth_iv.len,
7578 (tdata->digest_enc.offset == 0 ?
7580 : tdata->digest_enc.offset),
7581 tdata->validCipherLen.len_bits,
7582 tdata->cipher.offset_bits,
7583 tdata->validAuthLen.len_bits,
7584 tdata->auth.offset_bits,
7585 op_mode, 1, verify);
7590 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7592 /* Check if the op failed because the device doesn't */
7593 /* support this particular combination of algorithms */
7594 if (op == NULL && ut_params->op->status ==
7595 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7596 printf("Device doesn't support this mixed combination. "
7598 return TEST_SKIPPED;
7602 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7604 ut_params->obuf = (op_mode == IN_PLACE ?
7605 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7608 if (ut_params->obuf)
7609 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7610 plaintext_len, buffer);
7612 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7613 plaintext_len, buffer);
7615 debug_hexdump(stdout, "plaintext:", plaintext,
7616 (tdata->plaintext.len_bits >> 3) -
7617 tdata->digest_enc.len);
7618 debug_hexdump(stdout, "plaintext expected:",
7619 tdata->plaintext.data,
7620 (tdata->plaintext.len_bits >> 3) -
7621 tdata->digest_enc.len);
7623 if (ut_params->obuf)
7624 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7625 ciphertext_len, buffer);
7627 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7628 ciphertext_len, buffer);
7630 debug_hexdump(stdout, "ciphertext:", ciphertext,
7632 debug_hexdump(stdout, "ciphertext expected:",
7633 tdata->ciphertext.data,
7634 tdata->ciphertext.len_bits >> 3);
7636 if (ut_params->obuf)
7637 digest = rte_pktmbuf_read(ut_params->obuf,
7638 (tdata->digest_enc.offset == 0 ?
7640 tdata->digest_enc.offset),
7641 tdata->digest_enc.len, digest_buffer);
7643 digest = rte_pktmbuf_read(ut_params->ibuf,
7644 (tdata->digest_enc.offset == 0 ?
7646 tdata->digest_enc.offset),
7647 tdata->digest_enc.len, digest_buffer);
7649 debug_hexdump(stdout, "digest:", digest,
7650 tdata->digest_enc.len);
7651 debug_hexdump(stdout, "digest expected:",
7652 tdata->digest_enc.data, tdata->digest_enc.len);
7657 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7659 tdata->plaintext.data,
7660 tdata->plaintext.len_bits >> 3,
7661 "Plaintext data not as expected");
7663 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7665 tdata->ciphertext.data,
7666 tdata->validDataLen.len_bits,
7667 "Ciphertext data not as expected");
7668 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7670 tdata->digest_enc.data,
7671 tdata->digest_enc.len,
7672 "Generated auth tag not as expected");
7675 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7676 "crypto op processing failed");
7681 /** AUTH AES CMAC + CIPHER AES CTR */
7684 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7686 return test_mixed_auth_cipher(
7687 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7691 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7693 return test_mixed_auth_cipher(
7694 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7698 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7700 return test_mixed_auth_cipher_sgl(
7701 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7705 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7707 return test_mixed_auth_cipher_sgl(
7708 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7712 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7714 return test_mixed_auth_cipher(
7715 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7719 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7721 return test_mixed_auth_cipher(
7722 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7726 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7728 return test_mixed_auth_cipher_sgl(
7729 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7733 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7735 return test_mixed_auth_cipher_sgl(
7736 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7739 /** MIXED AUTH + CIPHER */
7742 test_auth_zuc_cipher_snow_test_case_1(void)
7744 return test_mixed_auth_cipher(
7745 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7749 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7751 return test_mixed_auth_cipher(
7752 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7756 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7758 return test_mixed_auth_cipher(
7759 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7763 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7765 return test_mixed_auth_cipher(
7766 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7770 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7772 return test_mixed_auth_cipher(
7773 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7777 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7779 return test_mixed_auth_cipher(
7780 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7784 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7786 return test_mixed_auth_cipher(
7787 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7791 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7793 return test_mixed_auth_cipher(
7794 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7798 test_auth_snow_cipher_zuc_test_case_1(void)
7800 return test_mixed_auth_cipher(
7801 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7805 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7807 return test_mixed_auth_cipher(
7808 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7812 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7814 return test_mixed_auth_cipher(
7815 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7819 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7821 return test_mixed_auth_cipher(
7822 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7826 test_auth_null_cipher_snow_test_case_1(void)
7828 return test_mixed_auth_cipher(
7829 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7833 test_verify_auth_null_cipher_snow_test_case_1(void)
7835 return test_mixed_auth_cipher(
7836 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7840 test_auth_null_cipher_zuc_test_case_1(void)
7842 return test_mixed_auth_cipher(
7843 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7847 test_verify_auth_null_cipher_zuc_test_case_1(void)
7849 return test_mixed_auth_cipher(
7850 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7854 test_auth_snow_cipher_null_test_case_1(void)
7856 return test_mixed_auth_cipher(
7857 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7861 test_verify_auth_snow_cipher_null_test_case_1(void)
7863 return test_mixed_auth_cipher(
7864 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7868 test_auth_zuc_cipher_null_test_case_1(void)
7870 return test_mixed_auth_cipher(
7871 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7875 test_verify_auth_zuc_cipher_null_test_case_1(void)
7877 return test_mixed_auth_cipher(
7878 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7882 test_auth_null_cipher_aes_ctr_test_case_1(void)
7884 return test_mixed_auth_cipher(
7885 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7889 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7891 return test_mixed_auth_cipher(
7892 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7896 test_auth_aes_cmac_cipher_null_test_case_1(void)
7898 return test_mixed_auth_cipher(
7899 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7903 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7905 return test_mixed_auth_cipher(
7906 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7909 /* ***** AEAD algorithm Tests ***** */
7912 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7913 enum rte_crypto_aead_operation op,
7914 const uint8_t *key, const uint8_t key_len,
7915 const uint16_t aad_len, const uint8_t auth_len,
7918 uint8_t aead_key[key_len];
7920 struct crypto_testsuite_params *ts_params = &testsuite_params;
7921 struct crypto_unittest_params *ut_params = &unittest_params;
7923 memcpy(aead_key, key, key_len);
7925 /* Setup AEAD Parameters */
7926 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7927 ut_params->aead_xform.next = NULL;
7928 ut_params->aead_xform.aead.algo = algo;
7929 ut_params->aead_xform.aead.op = op;
7930 ut_params->aead_xform.aead.key.data = aead_key;
7931 ut_params->aead_xform.aead.key.length = key_len;
7932 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7933 ut_params->aead_xform.aead.iv.length = iv_len;
7934 ut_params->aead_xform.aead.digest_length = auth_len;
7935 ut_params->aead_xform.aead.aad_length = aad_len;
7937 debug_hexdump(stdout, "key:", key, key_len);
7939 /* Create Crypto session*/
7940 ut_params->sess = rte_cryptodev_sym_session_create(
7941 ts_params->session_mpool);
7943 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7944 &ut_params->aead_xform,
7945 ts_params->session_priv_mpool);
7947 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7953 create_aead_xform(struct rte_crypto_op *op,
7954 enum rte_crypto_aead_algorithm algo,
7955 enum rte_crypto_aead_operation aead_op,
7956 uint8_t *key, const uint8_t key_len,
7957 const uint8_t aad_len, const uint8_t auth_len,
7960 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7961 "failed to allocate space for crypto transform");
7963 struct rte_crypto_sym_op *sym_op = op->sym;
7965 /* Setup AEAD Parameters */
7966 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7967 sym_op->xform->next = NULL;
7968 sym_op->xform->aead.algo = algo;
7969 sym_op->xform->aead.op = aead_op;
7970 sym_op->xform->aead.key.data = key;
7971 sym_op->xform->aead.key.length = key_len;
7972 sym_op->xform->aead.iv.offset = IV_OFFSET;
7973 sym_op->xform->aead.iv.length = iv_len;
7974 sym_op->xform->aead.digest_length = auth_len;
7975 sym_op->xform->aead.aad_length = aad_len;
7977 debug_hexdump(stdout, "key:", key, key_len);
7983 create_aead_operation(enum rte_crypto_aead_operation op,
7984 const struct aead_test_data *tdata)
7986 struct crypto_testsuite_params *ts_params = &testsuite_params;
7987 struct crypto_unittest_params *ut_params = &unittest_params;
7989 uint8_t *plaintext, *ciphertext;
7990 unsigned int aad_pad_len, plaintext_pad_len;
7992 /* Generate Crypto op data structure */
7993 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7994 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7995 TEST_ASSERT_NOT_NULL(ut_params->op,
7996 "Failed to allocate symmetric crypto operation struct");
7998 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8000 /* Append aad data */
8001 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8002 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8003 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8005 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8006 "no room to append aad");
8008 sym_op->aead.aad.phys_addr =
8009 rte_pktmbuf_iova(ut_params->ibuf);
8010 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8011 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8012 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8015 /* Append IV at the end of the crypto operation*/
8016 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8017 uint8_t *, IV_OFFSET);
8019 /* Copy IV 1 byte after the IV pointer, according to the API */
8020 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8021 debug_hexdump(stdout, "iv:", iv_ptr,
8024 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8025 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8027 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8028 "no room to append aad");
8030 sym_op->aead.aad.phys_addr =
8031 rte_pktmbuf_iova(ut_params->ibuf);
8032 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8033 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8036 /* Append IV at the end of the crypto operation*/
8037 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8038 uint8_t *, IV_OFFSET);
8040 if (tdata->iv.len == 0) {
8041 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8042 debug_hexdump(stdout, "iv:", iv_ptr,
8045 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8046 debug_hexdump(stdout, "iv:", iv_ptr,
8051 /* Append plaintext/ciphertext */
8052 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8053 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8054 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8056 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8058 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8059 debug_hexdump(stdout, "plaintext:", plaintext,
8060 tdata->plaintext.len);
8062 if (ut_params->obuf) {
8063 ciphertext = (uint8_t *)rte_pktmbuf_append(
8065 plaintext_pad_len + aad_pad_len);
8066 TEST_ASSERT_NOT_NULL(ciphertext,
8067 "no room to append ciphertext");
8069 memset(ciphertext + aad_pad_len, 0,
8070 tdata->ciphertext.len);
8073 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8074 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8076 TEST_ASSERT_NOT_NULL(ciphertext,
8077 "no room to append ciphertext");
8079 memcpy(ciphertext, tdata->ciphertext.data,
8080 tdata->ciphertext.len);
8081 debug_hexdump(stdout, "ciphertext:", ciphertext,
8082 tdata->ciphertext.len);
8084 if (ut_params->obuf) {
8085 plaintext = (uint8_t *)rte_pktmbuf_append(
8087 plaintext_pad_len + aad_pad_len);
8088 TEST_ASSERT_NOT_NULL(plaintext,
8089 "no room to append plaintext");
8091 memset(plaintext + aad_pad_len, 0,
8092 tdata->plaintext.len);
8096 /* Append digest data */
8097 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8098 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8099 ut_params->obuf ? ut_params->obuf :
8101 tdata->auth_tag.len);
8102 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8103 "no room to append digest");
8104 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8105 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8106 ut_params->obuf ? ut_params->obuf :
8111 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8112 ut_params->ibuf, tdata->auth_tag.len);
8113 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8114 "no room to append digest");
8115 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8117 plaintext_pad_len + aad_pad_len);
8119 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8120 tdata->auth_tag.len);
8121 debug_hexdump(stdout, "digest:",
8122 sym_op->aead.digest.data,
8123 tdata->auth_tag.len);
8126 sym_op->aead.data.length = tdata->plaintext.len;
8127 sym_op->aead.data.offset = aad_pad_len;
8133 test_authenticated_encryption(const struct aead_test_data *tdata)
8135 struct crypto_testsuite_params *ts_params = &testsuite_params;
8136 struct crypto_unittest_params *ut_params = &unittest_params;
8139 uint8_t *ciphertext, *auth_tag;
8140 uint16_t plaintext_pad_len;
8142 struct rte_cryptodev_info dev_info;
8144 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8145 uint64_t feat_flags = dev_info.feature_flags;
8147 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8148 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8149 printf("Device doesn't support RAW data-path APIs.\n");
8150 return TEST_SKIPPED;
8153 /* Verify the capabilities */
8154 struct rte_cryptodev_sym_capability_idx cap_idx;
8155 const struct rte_cryptodev_symmetric_capability *capability;
8156 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8157 cap_idx.algo.aead = tdata->algo;
8158 capability = rte_cryptodev_sym_capability_get(
8159 ts_params->valid_devs[0], &cap_idx);
8160 if (capability == NULL)
8161 return TEST_SKIPPED;
8162 if (rte_cryptodev_sym_capability_check_aead(
8163 capability, tdata->key.len, tdata->auth_tag.len,
8164 tdata->aad.len, tdata->iv.len))
8165 return TEST_SKIPPED;
8167 /* Create AEAD session */
8168 retval = create_aead_session(ts_params->valid_devs[0],
8170 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8171 tdata->key.data, tdata->key.len,
8172 tdata->aad.len, tdata->auth_tag.len,
8177 if (tdata->aad.len > MBUF_SIZE) {
8178 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8179 /* Populate full size of add data */
8180 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8181 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8183 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8185 /* clear mbuf payload */
8186 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8187 rte_pktmbuf_tailroom(ut_params->ibuf));
8189 /* Create AEAD operation */
8190 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8194 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8196 ut_params->op->sym->m_src = ut_params->ibuf;
8198 /* Process crypto operation */
8199 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8200 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8201 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8202 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8203 ut_params->op, 0, 0, 0, 0);
8205 TEST_ASSERT_NOT_NULL(
8206 process_crypto_request(ts_params->valid_devs[0],
8207 ut_params->op), "failed to process sym crypto op");
8209 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8210 "crypto op processing failed");
8212 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8214 if (ut_params->op->sym->m_dst) {
8215 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8217 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8218 uint8_t *, plaintext_pad_len);
8220 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8222 ut_params->op->sym->cipher.data.offset);
8223 auth_tag = ciphertext + plaintext_pad_len;
8226 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8227 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8230 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8232 tdata->ciphertext.data,
8233 tdata->ciphertext.len,
8234 "Ciphertext data not as expected");
8236 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8238 tdata->auth_tag.data,
8239 tdata->auth_tag.len,
8240 "Generated auth tag not as expected");
8246 #ifdef RTE_LIB_SECURITY
8248 security_proto_supported(enum rte_security_session_action_type action,
8249 enum rte_security_session_protocol proto)
8251 struct crypto_testsuite_params *ts_params = &testsuite_params;
8253 const struct rte_security_capability *capabilities;
8254 const struct rte_security_capability *capability;
8257 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8258 rte_cryptodev_get_sec_ctx(
8259 ts_params->valid_devs[0]);
8262 capabilities = rte_security_capabilities_get(ctx);
8264 if (capabilities == NULL)
8267 while ((capability = &capabilities[i++])->action !=
8268 RTE_SECURITY_ACTION_TYPE_NONE) {
8269 if (capability->action == action &&
8270 capability->protocol == proto)
8277 /* Basic algorithm run function for async inplace mode.
8278 * Creates a session from input parameters and runs one operation
8279 * on input_vec. Checks the output of the crypto operation against
8282 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8283 enum rte_crypto_auth_operation opa,
8284 const uint8_t *input_vec, unsigned int input_vec_len,
8285 const uint8_t *output_vec,
8286 unsigned int output_vec_len,
8287 enum rte_crypto_cipher_algorithm cipher_alg,
8288 const uint8_t *cipher_key, uint32_t cipher_key_len,
8289 enum rte_crypto_auth_algorithm auth_alg,
8290 const uint8_t *auth_key, uint32_t auth_key_len,
8291 uint8_t bearer, enum rte_security_pdcp_domain domain,
8292 uint8_t packet_direction, uint8_t sn_size,
8293 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8295 struct crypto_testsuite_params *ts_params = &testsuite_params;
8296 struct crypto_unittest_params *ut_params = &unittest_params;
8298 int ret = TEST_SUCCESS;
8299 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8300 rte_cryptodev_get_sec_ctx(
8301 ts_params->valid_devs[0]);
8303 /* Verify the capabilities */
8304 struct rte_security_capability_idx sec_cap_idx;
8306 sec_cap_idx.action = ut_params->type;
8307 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8308 sec_cap_idx.pdcp.domain = domain;
8309 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8310 return TEST_SKIPPED;
8312 /* Generate test mbuf data */
8313 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8315 /* clear mbuf payload */
8316 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8317 rte_pktmbuf_tailroom(ut_params->ibuf));
8319 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8321 memcpy(plaintext, input_vec, input_vec_len);
8323 /* Out of place support */
8326 * For out-op-place we need to alloc another mbuf
8328 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8329 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8332 /* Setup Cipher Parameters */
8333 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8334 ut_params->cipher_xform.cipher.algo = cipher_alg;
8335 ut_params->cipher_xform.cipher.op = opc;
8336 ut_params->cipher_xform.cipher.key.data = cipher_key;
8337 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8338 ut_params->cipher_xform.cipher.iv.length =
8339 packet_direction ? 4 : 0;
8340 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8342 /* Setup HMAC Parameters if ICV header is required */
8343 if (auth_alg != 0) {
8344 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8345 ut_params->auth_xform.next = NULL;
8346 ut_params->auth_xform.auth.algo = auth_alg;
8347 ut_params->auth_xform.auth.op = opa;
8348 ut_params->auth_xform.auth.key.data = auth_key;
8349 ut_params->auth_xform.auth.key.length = auth_key_len;
8351 ut_params->cipher_xform.next = &ut_params->auth_xform;
8353 ut_params->cipher_xform.next = NULL;
8356 struct rte_security_session_conf sess_conf = {
8357 .action_type = ut_params->type,
8358 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8362 .pkt_dir = packet_direction,
8364 .hfn = packet_direction ? 0 : hfn,
8366 * hfn can be set as pdcp_test_hfn[i]
8367 * if hfn_ovrd is not set. Here, PDCP
8368 * packet direction is just used to
8369 * run half of the cases with session
8370 * HFN and other half with per packet
8373 .hfn_threshold = hfn_threshold,
8374 .hfn_ovrd = packet_direction ? 1 : 0,
8375 .sdap_enabled = sdap,
8377 .crypto_xform = &ut_params->cipher_xform
8380 /* Create security session */
8381 ut_params->sec_session = rte_security_session_create(ctx,
8382 &sess_conf, ts_params->session_mpool,
8383 ts_params->session_priv_mpool);
8385 if (!ut_params->sec_session) {
8386 printf("TestCase %s()-%d line %d failed %s: ",
8387 __func__, i, __LINE__, "Failed to allocate session");
8392 /* Generate crypto op data structure */
8393 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8394 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8395 if (!ut_params->op) {
8396 printf("TestCase %s()-%d line %d failed %s: ",
8397 __func__, i, __LINE__,
8398 "Failed to allocate symmetric crypto operation struct");
8403 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8404 uint32_t *, IV_OFFSET);
8405 *per_pkt_hfn = packet_direction ? hfn : 0;
8407 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8409 /* set crypto operation source mbuf */
8410 ut_params->op->sym->m_src = ut_params->ibuf;
8412 ut_params->op->sym->m_dst = ut_params->obuf;
8414 /* Process crypto operation */
8415 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8417 printf("TestCase %s()-%d line %d failed %s: ",
8418 __func__, i, __LINE__,
8419 "failed to process sym crypto op");
8424 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8425 printf("TestCase %s()-%d line %d failed %s: ",
8426 __func__, i, __LINE__, "crypto op processing failed");
8432 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8435 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8439 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8440 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8441 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8442 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8448 rte_crypto_op_free(ut_params->op);
8449 ut_params->op = NULL;
8451 if (ut_params->sec_session)
8452 rte_security_session_destroy(ctx, ut_params->sec_session);
8453 ut_params->sec_session = NULL;
8455 rte_pktmbuf_free(ut_params->ibuf);
8456 ut_params->ibuf = NULL;
8458 rte_pktmbuf_free(ut_params->obuf);
8459 ut_params->obuf = NULL;
8466 test_pdcp_proto_SGL(int i, int oop,
8467 enum rte_crypto_cipher_operation opc,
8468 enum rte_crypto_auth_operation opa,
8470 unsigned int input_vec_len,
8471 uint8_t *output_vec,
8472 unsigned int output_vec_len,
8474 uint32_t fragsz_oop)
8476 struct crypto_testsuite_params *ts_params = &testsuite_params;
8477 struct crypto_unittest_params *ut_params = &unittest_params;
8479 struct rte_mbuf *buf, *buf_oop = NULL;
8480 int ret = TEST_SUCCESS;
8484 unsigned int trn_data = 0;
8485 struct rte_cryptodev_info dev_info;
8486 uint64_t feat_flags;
8487 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8488 rte_cryptodev_get_sec_ctx(
8489 ts_params->valid_devs[0]);
8490 struct rte_mbuf *temp_mbuf;
8492 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8493 feat_flags = dev_info.feature_flags;
8495 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8496 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8497 printf("Device does not support RAW data-path APIs.\n");
8500 /* Verify the capabilities */
8501 struct rte_security_capability_idx sec_cap_idx;
8503 sec_cap_idx.action = ut_params->type;
8504 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8505 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8506 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8507 return TEST_SKIPPED;
8509 if (fragsz > input_vec_len)
8510 fragsz = input_vec_len;
8512 uint16_t plaintext_len = fragsz;
8513 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8515 if (fragsz_oop > output_vec_len)
8516 frag_size_oop = output_vec_len;
8519 if (input_vec_len % fragsz != 0) {
8520 if (input_vec_len / fragsz + 1 > 16)
8522 } else if (input_vec_len / fragsz > 16)
8525 /* Out of place support */
8528 * For out-op-place we need to alloc another mbuf
8530 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8531 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8532 buf_oop = ut_params->obuf;
8535 /* Generate test mbuf data */
8536 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8538 /* clear mbuf payload */
8539 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8540 rte_pktmbuf_tailroom(ut_params->ibuf));
8542 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8544 memcpy(plaintext, input_vec, plaintext_len);
8545 trn_data += plaintext_len;
8547 buf = ut_params->ibuf;
8550 * Loop until no more fragments
8553 while (trn_data < input_vec_len) {
8555 to_trn = (input_vec_len - trn_data < fragsz) ?
8556 (input_vec_len - trn_data) : fragsz;
8558 to_trn_tbl[ecx++] = to_trn;
8560 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8563 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8564 rte_pktmbuf_tailroom(buf));
8567 if (oop && !fragsz_oop) {
8569 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8570 buf_oop = buf_oop->next;
8571 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8572 0, rte_pktmbuf_tailroom(buf_oop));
8573 rte_pktmbuf_append(buf_oop, to_trn);
8576 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8579 memcpy(plaintext, input_vec + trn_data, to_trn);
8583 ut_params->ibuf->nb_segs = segs;
8586 if (fragsz_oop && oop) {
8590 trn_data = frag_size_oop;
8591 while (trn_data < output_vec_len) {
8594 (output_vec_len - trn_data <
8596 (output_vec_len - trn_data) :
8599 to_trn_tbl[ecx++] = to_trn;
8602 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8603 buf_oop = buf_oop->next;
8604 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8605 0, rte_pktmbuf_tailroom(buf_oop));
8606 rte_pktmbuf_append(buf_oop, to_trn);
8610 ut_params->obuf->nb_segs = segs;
8613 /* Setup Cipher Parameters */
8614 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8615 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8616 ut_params->cipher_xform.cipher.op = opc;
8617 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8618 ut_params->cipher_xform.cipher.key.length =
8619 pdcp_test_params[i].cipher_key_len;
8620 ut_params->cipher_xform.cipher.iv.length = 0;
8622 /* Setup HMAC Parameters if ICV header is required */
8623 if (pdcp_test_params[i].auth_alg != 0) {
8624 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8625 ut_params->auth_xform.next = NULL;
8626 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8627 ut_params->auth_xform.auth.op = opa;
8628 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8629 ut_params->auth_xform.auth.key.length =
8630 pdcp_test_params[i].auth_key_len;
8632 ut_params->cipher_xform.next = &ut_params->auth_xform;
8634 ut_params->cipher_xform.next = NULL;
8637 struct rte_security_session_conf sess_conf = {
8638 .action_type = ut_params->type,
8639 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8641 .bearer = pdcp_test_bearer[i],
8642 .domain = pdcp_test_params[i].domain,
8643 .pkt_dir = pdcp_test_packet_direction[i],
8644 .sn_size = pdcp_test_data_sn_size[i],
8645 .hfn = pdcp_test_hfn[i],
8646 .hfn_threshold = pdcp_test_hfn_threshold[i],
8649 .crypto_xform = &ut_params->cipher_xform
8652 /* Create security session */
8653 ut_params->sec_session = rte_security_session_create(ctx,
8654 &sess_conf, ts_params->session_mpool,
8655 ts_params->session_priv_mpool);
8657 if (!ut_params->sec_session) {
8658 printf("TestCase %s()-%d line %d failed %s: ",
8659 __func__, i, __LINE__, "Failed to allocate session");
8664 /* Generate crypto op data structure */
8665 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8666 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8667 if (!ut_params->op) {
8668 printf("TestCase %s()-%d line %d failed %s: ",
8669 __func__, i, __LINE__,
8670 "Failed to allocate symmetric crypto operation struct");
8675 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8677 /* set crypto operation source mbuf */
8678 ut_params->op->sym->m_src = ut_params->ibuf;
8680 ut_params->op->sym->m_dst = ut_params->obuf;
8682 /* Process crypto operation */
8683 temp_mbuf = ut_params->op->sym->m_src;
8684 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8685 /* filling lengths */
8687 ut_params->op->sym->cipher.data.length
8688 += temp_mbuf->pkt_len;
8689 ut_params->op->sym->auth.data.length
8690 += temp_mbuf->pkt_len;
8691 temp_mbuf = temp_mbuf->next;
8693 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8694 ut_params->op, 1, 1, 0, 0);
8696 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8699 if (ut_params->op == NULL) {
8700 printf("TestCase %s()-%d line %d failed %s: ",
8701 __func__, i, __LINE__,
8702 "failed to process sym crypto op");
8707 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8708 printf("TestCase %s()-%d line %d failed %s: ",
8709 __func__, i, __LINE__, "crypto op processing failed");
8715 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8718 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8722 fragsz = frag_size_oop;
8723 if (memcmp(ciphertext, output_vec, fragsz)) {
8724 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8725 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8726 rte_hexdump(stdout, "reference", output_vec, fragsz);
8731 buf = ut_params->op->sym->m_src->next;
8733 buf = ut_params->op->sym->m_dst->next;
8735 unsigned int off = fragsz;
8739 ciphertext = rte_pktmbuf_mtod(buf,
8741 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8742 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8743 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8744 rte_hexdump(stdout, "reference", output_vec + off,
8749 off += to_trn_tbl[ecx++];
8753 rte_crypto_op_free(ut_params->op);
8754 ut_params->op = NULL;
8756 if (ut_params->sec_session)
8757 rte_security_session_destroy(ctx, ut_params->sec_session);
8758 ut_params->sec_session = NULL;
8760 rte_pktmbuf_free(ut_params->ibuf);
8761 ut_params->ibuf = NULL;
8763 rte_pktmbuf_free(ut_params->obuf);
8764 ut_params->obuf = NULL;
8771 test_pdcp_proto_cplane_encap(int i)
8773 return test_pdcp_proto(
8774 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8775 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8776 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8777 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8778 pdcp_test_params[i].cipher_key_len,
8779 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8780 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8781 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8782 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8783 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8787 test_pdcp_proto_uplane_encap(int i)
8789 return test_pdcp_proto(
8790 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8791 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8792 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8793 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8794 pdcp_test_params[i].cipher_key_len,
8795 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8796 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8797 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8798 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8799 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8803 test_pdcp_proto_uplane_encap_with_int(int i)
8805 return test_pdcp_proto(
8806 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8807 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8808 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8809 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8810 pdcp_test_params[i].cipher_key_len,
8811 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8812 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8813 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8814 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8815 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8819 test_pdcp_proto_cplane_decap(int i)
8821 return test_pdcp_proto(
8822 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8823 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8824 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8825 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8826 pdcp_test_params[i].cipher_key_len,
8827 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8828 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8829 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8830 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8831 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8835 test_pdcp_proto_uplane_decap(int i)
8837 return test_pdcp_proto(
8838 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8839 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8840 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8841 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8842 pdcp_test_params[i].cipher_key_len,
8843 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8844 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8845 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8846 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8847 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8851 test_pdcp_proto_uplane_decap_with_int(int i)
8853 return test_pdcp_proto(
8854 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8855 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8856 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8857 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8858 pdcp_test_params[i].cipher_key_len,
8859 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8860 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8861 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8862 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8863 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8867 test_PDCP_PROTO_SGL_in_place_32B(void)
8869 /* i can be used for running any PDCP case
8870 * In this case it is uplane 12-bit AES-SNOW DL encap
8872 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8873 return test_pdcp_proto_SGL(i, IN_PLACE,
8874 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8875 RTE_CRYPTO_AUTH_OP_GENERATE,
8876 pdcp_test_data_in[i],
8877 pdcp_test_data_in_len[i],
8878 pdcp_test_data_out[i],
8879 pdcp_test_data_in_len[i]+4,
8883 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8885 /* i can be used for running any PDCP case
8886 * In this case it is uplane 18-bit NULL-NULL DL encap
8888 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8889 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8890 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8891 RTE_CRYPTO_AUTH_OP_GENERATE,
8892 pdcp_test_data_in[i],
8893 pdcp_test_data_in_len[i],
8894 pdcp_test_data_out[i],
8895 pdcp_test_data_in_len[i]+4,
8899 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8901 /* i can be used for running any PDCP case
8902 * In this case it is uplane 18-bit AES DL encap
8904 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8906 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8907 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8908 RTE_CRYPTO_AUTH_OP_GENERATE,
8909 pdcp_test_data_in[i],
8910 pdcp_test_data_in_len[i],
8911 pdcp_test_data_out[i],
8912 pdcp_test_data_in_len[i],
8916 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8918 /* i can be used for running any PDCP case
8919 * In this case it is cplane 12-bit AES-ZUC DL encap
8921 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8922 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8923 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8924 RTE_CRYPTO_AUTH_OP_GENERATE,
8925 pdcp_test_data_in[i],
8926 pdcp_test_data_in_len[i],
8927 pdcp_test_data_out[i],
8928 pdcp_test_data_in_len[i]+4,
8933 test_PDCP_SDAP_PROTO_encap_all(void)
8935 int i = 0, size = 0;
8936 int err, all_err = TEST_SUCCESS;
8937 const struct pdcp_sdap_test *cur_test;
8939 size = RTE_DIM(list_pdcp_sdap_tests);
8941 for (i = 0; i < size; i++) {
8942 cur_test = &list_pdcp_sdap_tests[i];
8943 err = test_pdcp_proto(
8944 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8945 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8946 cur_test->in_len, cur_test->data_out,
8947 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8948 cur_test->param.cipher_alg, cur_test->cipher_key,
8949 cur_test->param.cipher_key_len,
8950 cur_test->param.auth_alg,
8951 cur_test->auth_key, cur_test->param.auth_key_len,
8952 cur_test->bearer, cur_test->param.domain,
8953 cur_test->packet_direction, cur_test->sn_size,
8955 cur_test->hfn_threshold, SDAP_ENABLED);
8957 printf("\t%d) %s: Encapsulation failed\n",
8959 cur_test->param.name);
8962 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8963 cur_test->param.name);
8969 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8971 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8975 test_PDCP_PROTO_short_mac(void)
8977 int i = 0, size = 0;
8978 int err, all_err = TEST_SUCCESS;
8979 const struct pdcp_short_mac_test *cur_test;
8981 size = RTE_DIM(list_pdcp_smac_tests);
8983 for (i = 0; i < size; i++) {
8984 cur_test = &list_pdcp_smac_tests[i];
8985 err = test_pdcp_proto(
8986 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8987 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8988 cur_test->in_len, cur_test->data_out,
8989 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8990 RTE_CRYPTO_CIPHER_NULL, NULL,
8991 0, cur_test->param.auth_alg,
8992 cur_test->auth_key, cur_test->param.auth_key_len,
8993 0, cur_test->param.domain, 0, 0,
8996 printf("\t%d) %s: Short MAC test failed\n",
8998 cur_test->param.name);
9001 printf("\t%d) %s: Short MAC test PASS\n",
9003 cur_test->param.name);
9004 rte_hexdump(stdout, "MAC I",
9005 cur_test->data_out + cur_test->in_len + 2,
9012 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9014 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9019 test_PDCP_SDAP_PROTO_decap_all(void)
9021 int i = 0, size = 0;
9022 int err, all_err = TEST_SUCCESS;
9023 const struct pdcp_sdap_test *cur_test;
9025 size = RTE_DIM(list_pdcp_sdap_tests);
9027 for (i = 0; i < size; i++) {
9028 cur_test = &list_pdcp_sdap_tests[i];
9029 err = test_pdcp_proto(
9030 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9031 RTE_CRYPTO_AUTH_OP_VERIFY,
9033 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9034 cur_test->data_in, cur_test->in_len,
9035 cur_test->param.cipher_alg,
9036 cur_test->cipher_key, cur_test->param.cipher_key_len,
9037 cur_test->param.auth_alg, cur_test->auth_key,
9038 cur_test->param.auth_key_len, cur_test->bearer,
9039 cur_test->param.domain, cur_test->packet_direction,
9040 cur_test->sn_size, cur_test->hfn,
9041 cur_test->hfn_threshold, SDAP_ENABLED);
9043 printf("\t%d) %s: Decapsulation failed\n",
9045 cur_test->param.name);
9048 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9049 cur_test->param.name);
9055 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9057 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9061 test_ipsec_proto_process(const struct ipsec_test_data td[],
9062 struct ipsec_test_data res_d[],
9065 const struct ipsec_test_flags *flags)
9067 struct crypto_testsuite_params *ts_params = &testsuite_params;
9068 struct crypto_unittest_params *ut_params = &unittest_params;
9069 struct rte_security_capability_idx sec_cap_idx;
9070 const struct rte_security_capability *sec_cap;
9071 struct rte_security_ipsec_xform ipsec_xform;
9072 uint8_t dev_id = ts_params->valid_devs[0];
9073 enum rte_security_ipsec_sa_direction dir;
9074 struct ipsec_test_data *res_d_tmp = NULL;
9075 uint32_t src = RTE_IPV4(192, 168, 1, 0);
9076 uint32_t dst = RTE_IPV4(192, 168, 1, 1);
9077 int salt_len, i, ret = TEST_SUCCESS;
9078 struct rte_security_ctx *ctx;
9079 uint8_t *input_text;
9082 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9083 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9085 /* Use first test data to create session */
9087 /* Copy IPsec xform */
9088 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9090 dir = ipsec_xform.direction;
9091 verify = flags->tunnel_hdr_verify;
9093 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9094 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9096 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9100 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src, sizeof(src));
9101 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst, sizeof(dst));
9103 ctx = rte_cryptodev_get_sec_ctx(dev_id);
9105 sec_cap_idx.action = ut_params->type;
9106 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9107 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9108 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9109 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9111 if (flags->udp_encap)
9112 ipsec_xform.options.udp_encap = 1;
9114 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9115 if (sec_cap == NULL)
9116 return TEST_SKIPPED;
9118 /* Copy cipher session parameters */
9120 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9121 sizeof(ut_params->aead_xform));
9122 ut_params->aead_xform.aead.key.data = td[0].key.data;
9123 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9125 /* Verify crypto capabilities */
9126 if (test_ipsec_crypto_caps_aead_verify(
9128 &ut_params->aead_xform) != 0) {
9130 RTE_LOG(INFO, USER1,
9131 "Crypto capabilities not supported\n");
9132 return TEST_SKIPPED;
9135 /* Only AEAD supported now */
9136 return TEST_SKIPPED;
9139 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9140 return TEST_SKIPPED;
9142 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9143 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9145 struct rte_security_session_conf sess_conf = {
9146 .action_type = ut_params->type,
9147 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9148 .ipsec = ipsec_xform,
9149 .crypto_xform = &ut_params->aead_xform,
9152 /* Create security session */
9153 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9154 ts_params->session_mpool,
9155 ts_params->session_priv_mpool);
9157 if (ut_params->sec_session == NULL)
9158 return TEST_SKIPPED;
9160 for (i = 0; i < nb_td; i++) {
9161 /* Setup source mbuf payload */
9162 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9163 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9164 rte_pktmbuf_tailroom(ut_params->ibuf));
9166 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9167 td[i].input_text.len);
9169 memcpy(input_text, td[i].input_text.data,
9170 td[i].input_text.len);
9172 /* Generate crypto op data structure */
9173 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9174 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9175 if (!ut_params->op) {
9176 printf("TestCase %s line %d: %s\n",
9178 "failed to allocate crypto op");
9180 goto crypto_op_free;
9183 /* Attach session to operation */
9184 rte_security_attach_session(ut_params->op,
9185 ut_params->sec_session);
9187 /* Set crypto operation mbufs */
9188 ut_params->op->sym->m_src = ut_params->ibuf;
9189 ut_params->op->sym->m_dst = NULL;
9191 /* Copy IV in crypto operation when IV generation is disabled */
9192 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9193 ipsec_xform.options.iv_gen_disable == 1) {
9194 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9200 len = td[i].xform.aead.aead.iv.length;
9202 len = td[i].xform.chain.cipher.cipher.iv.length;
9204 memcpy(iv, td[i].iv.data, len);
9207 /* Process crypto operation */
9208 process_crypto_request(dev_id, ut_params->op);
9210 ret = test_ipsec_status_check(ut_params->op, flags, dir, i + 1);
9211 if (ret != TEST_SUCCESS)
9212 goto crypto_op_free;
9215 res_d_tmp = &res_d[i];
9217 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9218 res_d_tmp, silent, flags);
9219 if (ret != TEST_SUCCESS)
9220 goto crypto_op_free;
9222 rte_crypto_op_free(ut_params->op);
9223 ut_params->op = NULL;
9225 rte_pktmbuf_free(ut_params->ibuf);
9226 ut_params->ibuf = NULL;
9230 rte_crypto_op_free(ut_params->op);
9231 ut_params->op = NULL;
9233 rte_pktmbuf_free(ut_params->ibuf);
9234 ut_params->ibuf = NULL;
9236 if (ut_params->sec_session)
9237 rte_security_session_destroy(ctx, ut_params->sec_session);
9238 ut_params->sec_session = NULL;
9244 test_ipsec_proto_known_vec(const void *test_data)
9246 struct ipsec_test_data td_outb;
9247 struct ipsec_test_flags flags;
9249 memset(&flags, 0, sizeof(flags));
9251 memcpy(&td_outb, test_data, sizeof(td_outb));
9253 /* Disable IV gen to be able to test with known vectors */
9254 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9256 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9260 test_ipsec_proto_known_vec_inb(const void *td_outb)
9262 struct ipsec_test_flags flags;
9263 struct ipsec_test_data td_inb;
9265 memset(&flags, 0, sizeof(flags));
9267 test_ipsec_td_in_from_out(td_outb, &td_inb);
9269 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9273 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9275 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9276 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9277 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9280 if (flags->iv_gen ||
9281 flags->sa_expiry_pkts_soft ||
9282 flags->sa_expiry_pkts_hard)
9283 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9285 for (i = 0; i < RTE_DIM(aead_list); i++) {
9286 test_ipsec_td_prepare(&aead_list[i],
9292 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9294 if (ret == TEST_SKIPPED)
9297 if (ret == TEST_FAILED)
9300 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9302 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9304 if (ret == TEST_SKIPPED)
9307 if (ret == TEST_FAILED)
9310 if (flags->display_alg)
9311 test_ipsec_display_alg(&aead_list[i], NULL);
9317 return TEST_SUCCESS;
9319 return TEST_SKIPPED;
9323 test_ipsec_proto_display_list(const void *data __rte_unused)
9325 struct ipsec_test_flags flags;
9327 memset(&flags, 0, sizeof(flags));
9329 flags.display_alg = true;
9331 return test_ipsec_proto_all(&flags);
9335 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9337 struct ipsec_test_flags flags;
9339 memset(&flags, 0, sizeof(flags));
9341 flags.iv_gen = true;
9343 return test_ipsec_proto_all(&flags);
9347 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9349 struct ipsec_test_flags flags;
9351 memset(&flags, 0, sizeof(flags));
9353 flags.sa_expiry_pkts_soft = true;
9355 return test_ipsec_proto_all(&flags);
9359 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9361 struct ipsec_test_flags flags;
9363 memset(&flags, 0, sizeof(flags));
9365 flags.sa_expiry_pkts_hard = true;
9367 return test_ipsec_proto_all(&flags);
9371 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9373 struct ipsec_test_flags flags;
9375 memset(&flags, 0, sizeof(flags));
9377 flags.icv_corrupt = true;
9379 return test_ipsec_proto_all(&flags);
9383 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9385 struct ipsec_test_flags flags;
9387 memset(&flags, 0, sizeof(flags));
9389 flags.udp_encap = true;
9391 return test_ipsec_proto_all(&flags);
9395 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9397 struct ipsec_test_flags flags;
9399 memset(&flags, 0, sizeof(flags));
9401 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9403 return test_ipsec_proto_all(&flags);
9407 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9409 struct ipsec_test_flags flags;
9411 memset(&flags, 0, sizeof(flags));
9413 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9415 return test_ipsec_proto_all(&flags);
9419 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9421 struct ipsec_test_flags flags;
9423 memset(&flags, 0, sizeof(flags));
9425 flags.udp_encap = true;
9426 flags.udp_ports_verify = true;
9428 return test_ipsec_proto_all(&flags);
9432 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9434 struct ipsec_test_flags flags;
9436 memset(&flags, 0, sizeof(flags));
9438 flags.ip_csum = true;
9440 return test_ipsec_proto_all(&flags);
9444 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9446 struct ipsec_test_flags flags;
9448 memset(&flags, 0, sizeof(flags));
9450 flags.l4_csum = true;
9452 return test_ipsec_proto_all(&flags);
9456 test_PDCP_PROTO_all(void)
9458 struct crypto_testsuite_params *ts_params = &testsuite_params;
9459 struct crypto_unittest_params *ut_params = &unittest_params;
9460 struct rte_cryptodev_info dev_info;
9463 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9464 uint64_t feat_flags = dev_info.feature_flags;
9466 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9467 return TEST_SKIPPED;
9469 /* Set action type */
9470 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9471 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9474 if (security_proto_supported(ut_params->type,
9475 RTE_SECURITY_PROTOCOL_PDCP) < 0)
9476 return TEST_SKIPPED;
9478 status = test_PDCP_PROTO_cplane_encap_all();
9479 status += test_PDCP_PROTO_cplane_decap_all();
9480 status += test_PDCP_PROTO_uplane_encap_all();
9481 status += test_PDCP_PROTO_uplane_decap_all();
9482 status += test_PDCP_PROTO_SGL_in_place_32B();
9483 status += test_PDCP_PROTO_SGL_oop_32B_128B();
9484 status += test_PDCP_PROTO_SGL_oop_32B_40B();
9485 status += test_PDCP_PROTO_SGL_oop_128B_32B();
9486 status += test_PDCP_SDAP_PROTO_encap_all();
9487 status += test_PDCP_SDAP_PROTO_decap_all();
9488 status += test_PDCP_PROTO_short_mac();
9493 return TEST_SUCCESS;
9497 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
9499 struct crypto_testsuite_params *ts_params = &testsuite_params;
9500 struct crypto_unittest_params *ut_params = &unittest_params;
9501 uint8_t *plaintext, *ciphertext;
9503 int32_t cipher_len, crc_len;
9504 uint32_t crc_data_len;
9505 int ret = TEST_SUCCESS;
9507 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9508 rte_cryptodev_get_sec_ctx(
9509 ts_params->valid_devs[0]);
9511 /* Verify the capabilities */
9512 struct rte_security_capability_idx sec_cap_idx;
9513 const struct rte_security_capability *sec_cap;
9514 const struct rte_cryptodev_capabilities *crypto_cap;
9515 const struct rte_cryptodev_symmetric_capability *sym_cap;
9518 sec_cap_idx.action = ut_params->type;
9519 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9520 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9522 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9523 if (sec_cap == NULL)
9524 return TEST_SKIPPED;
9526 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9527 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9528 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9529 crypto_cap->sym.xform_type ==
9530 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9531 crypto_cap->sym.cipher.algo ==
9532 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9533 sym_cap = &crypto_cap->sym;
9534 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9541 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9542 return TEST_SKIPPED;
9544 /* Setup source mbuf payload */
9545 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9546 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9547 rte_pktmbuf_tailroom(ut_params->ibuf));
9549 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9550 d_td->ciphertext.len);
9552 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
9554 /* Setup cipher session parameters */
9555 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9556 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9557 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
9558 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9559 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9560 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9561 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9562 ut_params->cipher_xform.next = NULL;
9564 /* Setup DOCSIS session parameters */
9565 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9567 struct rte_security_session_conf sess_conf = {
9568 .action_type = ut_params->type,
9569 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9570 .docsis = ut_params->docsis_xform,
9571 .crypto_xform = &ut_params->cipher_xform,
9574 /* Create security session */
9575 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9576 ts_params->session_mpool,
9577 ts_params->session_priv_mpool);
9579 if (!ut_params->sec_session) {
9580 printf("TestCase %s(%d) line %d: %s\n",
9581 __func__, i, __LINE__, "failed to allocate session");
9586 /* Generate crypto op data structure */
9587 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9588 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9589 if (!ut_params->op) {
9590 printf("TestCase %s(%d) line %d: %s\n",
9591 __func__, i, __LINE__,
9592 "failed to allocate symmetric crypto operation");
9597 /* Setup CRC operation parameters */
9598 crc_len = d_td->ciphertext.no_crc == false ?
9599 (d_td->ciphertext.len -
9600 d_td->ciphertext.crc_offset -
9601 RTE_ETHER_CRC_LEN) :
9603 crc_len = crc_len > 0 ? crc_len : 0;
9604 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9605 ut_params->op->sym->auth.data.length = crc_len;
9606 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9608 /* Setup cipher operation parameters */
9609 cipher_len = d_td->ciphertext.no_cipher == false ?
9610 (d_td->ciphertext.len -
9611 d_td->ciphertext.cipher_offset) :
9613 cipher_len = cipher_len > 0 ? cipher_len : 0;
9614 ut_params->op->sym->cipher.data.length = cipher_len;
9615 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9617 /* Setup cipher IV */
9618 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9619 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9621 /* Attach session to operation */
9622 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9624 /* Set crypto operation mbufs */
9625 ut_params->op->sym->m_src = ut_params->ibuf;
9626 ut_params->op->sym->m_dst = NULL;
9628 /* Process crypto operation */
9629 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9631 printf("TestCase %s(%d) line %d: %s\n",
9632 __func__, i, __LINE__,
9633 "failed to process security crypto op");
9638 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9639 printf("TestCase %s(%d) line %d: %s\n",
9640 __func__, i, __LINE__, "crypto op processing failed");
9645 /* Validate plaintext */
9646 plaintext = ciphertext;
9648 if (memcmp(plaintext, d_td->plaintext.data,
9649 d_td->plaintext.len - crc_data_len)) {
9650 printf("TestCase %s(%d) line %d: %s\n",
9651 __func__, i, __LINE__, "plaintext not as expected\n");
9652 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9653 d_td->plaintext.len);
9654 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9660 rte_crypto_op_free(ut_params->op);
9661 ut_params->op = NULL;
9663 if (ut_params->sec_session)
9664 rte_security_session_destroy(ctx, ut_params->sec_session);
9665 ut_params->sec_session = NULL;
9667 rte_pktmbuf_free(ut_params->ibuf);
9668 ut_params->ibuf = NULL;
9674 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9676 struct crypto_testsuite_params *ts_params = &testsuite_params;
9677 struct crypto_unittest_params *ut_params = &unittest_params;
9678 uint8_t *plaintext, *ciphertext;
9680 int32_t cipher_len, crc_len;
9681 int ret = TEST_SUCCESS;
9683 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9684 rte_cryptodev_get_sec_ctx(
9685 ts_params->valid_devs[0]);
9687 /* Verify the capabilities */
9688 struct rte_security_capability_idx sec_cap_idx;
9689 const struct rte_security_capability *sec_cap;
9690 const struct rte_cryptodev_capabilities *crypto_cap;
9691 const struct rte_cryptodev_symmetric_capability *sym_cap;
9694 sec_cap_idx.action = ut_params->type;
9695 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9696 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9698 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9699 if (sec_cap == NULL)
9700 return TEST_SKIPPED;
9702 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9703 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9704 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9705 crypto_cap->sym.xform_type ==
9706 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9707 crypto_cap->sym.cipher.algo ==
9708 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9709 sym_cap = &crypto_cap->sym;
9710 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9717 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9718 return TEST_SKIPPED;
9720 /* Setup source mbuf payload */
9721 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9722 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9723 rte_pktmbuf_tailroom(ut_params->ibuf));
9725 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9726 d_td->plaintext.len);
9728 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9730 /* Setup cipher session parameters */
9731 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9732 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9733 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9734 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9735 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9736 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9737 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9738 ut_params->cipher_xform.next = NULL;
9740 /* Setup DOCSIS session parameters */
9741 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9743 struct rte_security_session_conf sess_conf = {
9744 .action_type = ut_params->type,
9745 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9746 .docsis = ut_params->docsis_xform,
9747 .crypto_xform = &ut_params->cipher_xform,
9750 /* Create security session */
9751 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9752 ts_params->session_mpool,
9753 ts_params->session_priv_mpool);
9755 if (!ut_params->sec_session) {
9756 printf("TestCase %s(%d) line %d: %s\n",
9757 __func__, i, __LINE__, "failed to allocate session");
9762 /* Generate crypto op data structure */
9763 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9764 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9765 if (!ut_params->op) {
9766 printf("TestCase %s(%d) line %d: %s\n",
9767 __func__, i, __LINE__,
9768 "failed to allocate security crypto operation");
9773 /* Setup CRC operation parameters */
9774 crc_len = d_td->plaintext.no_crc == false ?
9775 (d_td->plaintext.len -
9776 d_td->plaintext.crc_offset -
9777 RTE_ETHER_CRC_LEN) :
9779 crc_len = crc_len > 0 ? crc_len : 0;
9780 ut_params->op->sym->auth.data.length = crc_len;
9781 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9783 /* Setup cipher operation parameters */
9784 cipher_len = d_td->plaintext.no_cipher == false ?
9785 (d_td->plaintext.len -
9786 d_td->plaintext.cipher_offset) :
9788 cipher_len = cipher_len > 0 ? cipher_len : 0;
9789 ut_params->op->sym->cipher.data.length = cipher_len;
9790 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9792 /* Setup cipher IV */
9793 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9794 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9796 /* Attach session to operation */
9797 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9799 /* Set crypto operation mbufs */
9800 ut_params->op->sym->m_src = ut_params->ibuf;
9801 ut_params->op->sym->m_dst = NULL;
9803 /* Process crypto operation */
9804 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9806 printf("TestCase %s(%d) line %d: %s\n",
9807 __func__, i, __LINE__,
9808 "failed to process security crypto op");
9813 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9814 printf("TestCase %s(%d) line %d: %s\n",
9815 __func__, i, __LINE__, "crypto op processing failed");
9820 /* Validate ciphertext */
9821 ciphertext = plaintext;
9823 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9824 printf("TestCase %s(%d) line %d: %s\n",
9825 __func__, i, __LINE__, "ciphertext not as expected\n");
9826 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9827 d_td->ciphertext.len);
9828 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9834 rte_crypto_op_free(ut_params->op);
9835 ut_params->op = NULL;
9837 if (ut_params->sec_session)
9838 rte_security_session_destroy(ctx, ut_params->sec_session);
9839 ut_params->sec_session = NULL;
9841 rte_pktmbuf_free(ut_params->ibuf);
9842 ut_params->ibuf = NULL;
9847 #define TEST_DOCSIS_COUNT(func) do { \
9849 if (ret == TEST_SUCCESS) { \
9850 printf("\t%2d)", n++); \
9851 printf("+++++ PASSED:" #func"\n"); \
9853 } else if (ret == TEST_SKIPPED) { \
9854 printf("\t%2d)", n++); \
9855 printf("~~~~~ SKIPPED:" #func"\n"); \
9858 printf("\t%2d)", n++); \
9859 printf("----- FAILED:" #func"\n"); \
9865 test_DOCSIS_PROTO_uplink_all(void)
9867 int p = 0, s = 0, f = 0, n = 0;
9869 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9870 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9871 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9872 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9873 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9874 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9875 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9876 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9877 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9878 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9879 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9880 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9881 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9882 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9883 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9884 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9885 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9886 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9887 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9888 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9889 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9890 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9891 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9892 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9893 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9894 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9897 printf("## %s: %d passed out of %d (%d skipped)\n",
9904 test_DOCSIS_PROTO_downlink_all(void)
9906 int p = 0, s = 0, f = 0, n = 0;
9908 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9909 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9910 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9911 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9912 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9913 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9914 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9915 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9916 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9917 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9918 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9919 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9920 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9921 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9922 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9923 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9924 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9925 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9926 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9927 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9928 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9929 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9930 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9931 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9932 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9933 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9936 printf("## %s: %d passed out of %d (%d skipped)\n",
9943 test_DOCSIS_PROTO_all(void)
9945 struct crypto_testsuite_params *ts_params = &testsuite_params;
9946 struct crypto_unittest_params *ut_params = &unittest_params;
9947 struct rte_cryptodev_info dev_info;
9950 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9951 uint64_t feat_flags = dev_info.feature_flags;
9953 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9954 return TEST_SKIPPED;
9956 /* Set action type */
9957 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9958 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9961 if (security_proto_supported(ut_params->type,
9962 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9963 return TEST_SKIPPED;
9965 status = test_DOCSIS_PROTO_uplink_all();
9966 status += test_DOCSIS_PROTO_downlink_all();
9971 return TEST_SUCCESS;
9976 test_AES_GCM_authenticated_encryption_test_case_1(void)
9978 return test_authenticated_encryption(&gcm_test_case_1);
9982 test_AES_GCM_authenticated_encryption_test_case_2(void)
9984 return test_authenticated_encryption(&gcm_test_case_2);
9988 test_AES_GCM_authenticated_encryption_test_case_3(void)
9990 return test_authenticated_encryption(&gcm_test_case_3);
9994 test_AES_GCM_authenticated_encryption_test_case_4(void)
9996 return test_authenticated_encryption(&gcm_test_case_4);
10000 test_AES_GCM_authenticated_encryption_test_case_5(void)
10002 return test_authenticated_encryption(&gcm_test_case_5);
10006 test_AES_GCM_authenticated_encryption_test_case_6(void)
10008 return test_authenticated_encryption(&gcm_test_case_6);
10012 test_AES_GCM_authenticated_encryption_test_case_7(void)
10014 return test_authenticated_encryption(&gcm_test_case_7);
10018 test_AES_GCM_authenticated_encryption_test_case_8(void)
10020 return test_authenticated_encryption(&gcm_test_case_8);
10024 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
10026 return test_authenticated_encryption(&gcm_J0_test_case_1);
10030 test_AES_GCM_auth_encryption_test_case_192_1(void)
10032 return test_authenticated_encryption(&gcm_test_case_192_1);
10036 test_AES_GCM_auth_encryption_test_case_192_2(void)
10038 return test_authenticated_encryption(&gcm_test_case_192_2);
10042 test_AES_GCM_auth_encryption_test_case_192_3(void)
10044 return test_authenticated_encryption(&gcm_test_case_192_3);
10048 test_AES_GCM_auth_encryption_test_case_192_4(void)
10050 return test_authenticated_encryption(&gcm_test_case_192_4);
10054 test_AES_GCM_auth_encryption_test_case_192_5(void)
10056 return test_authenticated_encryption(&gcm_test_case_192_5);
10060 test_AES_GCM_auth_encryption_test_case_192_6(void)
10062 return test_authenticated_encryption(&gcm_test_case_192_6);
10066 test_AES_GCM_auth_encryption_test_case_192_7(void)
10068 return test_authenticated_encryption(&gcm_test_case_192_7);
10072 test_AES_GCM_auth_encryption_test_case_256_1(void)
10074 return test_authenticated_encryption(&gcm_test_case_256_1);
10078 test_AES_GCM_auth_encryption_test_case_256_2(void)
10080 return test_authenticated_encryption(&gcm_test_case_256_2);
10084 test_AES_GCM_auth_encryption_test_case_256_3(void)
10086 return test_authenticated_encryption(&gcm_test_case_256_3);
10090 test_AES_GCM_auth_encryption_test_case_256_4(void)
10092 return test_authenticated_encryption(&gcm_test_case_256_4);
10096 test_AES_GCM_auth_encryption_test_case_256_5(void)
10098 return test_authenticated_encryption(&gcm_test_case_256_5);
10102 test_AES_GCM_auth_encryption_test_case_256_6(void)
10104 return test_authenticated_encryption(&gcm_test_case_256_6);
10108 test_AES_GCM_auth_encryption_test_case_256_7(void)
10110 return test_authenticated_encryption(&gcm_test_case_256_7);
10114 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10116 return test_authenticated_encryption(&gcm_test_case_aad_1);
10120 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10122 return test_authenticated_encryption(&gcm_test_case_aad_2);
10126 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10128 struct aead_test_data tdata;
10131 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10132 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10133 tdata.iv.data[0] += 1;
10134 res = test_authenticated_encryption(&tdata);
10135 if (res == TEST_SKIPPED)
10137 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10138 return TEST_SUCCESS;
10142 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10144 struct aead_test_data tdata;
10147 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10148 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10149 tdata.plaintext.data[0] += 1;
10150 res = test_authenticated_encryption(&tdata);
10151 if (res == TEST_SKIPPED)
10153 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10154 return TEST_SUCCESS;
10158 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10160 struct aead_test_data tdata;
10163 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10164 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10165 tdata.ciphertext.data[0] += 1;
10166 res = test_authenticated_encryption(&tdata);
10167 if (res == TEST_SKIPPED)
10169 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10170 return TEST_SUCCESS;
10174 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10176 struct aead_test_data tdata;
10179 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10180 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10181 tdata.aad.len += 1;
10182 res = test_authenticated_encryption(&tdata);
10183 if (res == TEST_SKIPPED)
10185 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10186 return TEST_SUCCESS;
10190 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10192 struct aead_test_data tdata;
10193 uint8_t aad[gcm_test_case_7.aad.len];
10196 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10197 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10198 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10200 tdata.aad.data = aad;
10201 res = test_authenticated_encryption(&tdata);
10202 if (res == TEST_SKIPPED)
10204 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10205 return TEST_SUCCESS;
10209 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10211 struct aead_test_data tdata;
10214 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10215 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10216 tdata.auth_tag.data[0] += 1;
10217 res = test_authenticated_encryption(&tdata);
10218 if (res == TEST_SKIPPED)
10220 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10221 return TEST_SUCCESS;
10225 test_authenticated_decryption(const struct aead_test_data *tdata)
10227 struct crypto_testsuite_params *ts_params = &testsuite_params;
10228 struct crypto_unittest_params *ut_params = &unittest_params;
10231 uint8_t *plaintext;
10233 struct rte_cryptodev_info dev_info;
10235 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10236 uint64_t feat_flags = dev_info.feature_flags;
10238 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10239 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10240 printf("Device doesn't support RAW data-path APIs.\n");
10241 return TEST_SKIPPED;
10244 /* Verify the capabilities */
10245 struct rte_cryptodev_sym_capability_idx cap_idx;
10246 const struct rte_cryptodev_symmetric_capability *capability;
10247 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10248 cap_idx.algo.aead = tdata->algo;
10249 capability = rte_cryptodev_sym_capability_get(
10250 ts_params->valid_devs[0], &cap_idx);
10251 if (capability == NULL)
10252 return TEST_SKIPPED;
10253 if (rte_cryptodev_sym_capability_check_aead(
10254 capability, tdata->key.len, tdata->auth_tag.len,
10255 tdata->aad.len, tdata->iv.len))
10256 return TEST_SKIPPED;
10258 /* Create AEAD session */
10259 retval = create_aead_session(ts_params->valid_devs[0],
10261 RTE_CRYPTO_AEAD_OP_DECRYPT,
10262 tdata->key.data, tdata->key.len,
10263 tdata->aad.len, tdata->auth_tag.len,
10268 /* alloc mbuf and set payload */
10269 if (tdata->aad.len > MBUF_SIZE) {
10270 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10271 /* Populate full size of add data */
10272 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10273 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10275 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10277 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10278 rte_pktmbuf_tailroom(ut_params->ibuf));
10280 /* Create AEAD operation */
10281 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10285 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10287 ut_params->op->sym->m_src = ut_params->ibuf;
10289 /* Process crypto operation */
10290 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10291 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10292 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10293 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10294 ut_params->op, 0, 0, 0, 0);
10296 TEST_ASSERT_NOT_NULL(
10297 process_crypto_request(ts_params->valid_devs[0],
10298 ut_params->op), "failed to process sym crypto op");
10300 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10301 "crypto op processing failed");
10303 if (ut_params->op->sym->m_dst)
10304 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10307 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10309 ut_params->op->sym->cipher.data.offset);
10311 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10313 /* Validate obuf */
10314 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10316 tdata->plaintext.data,
10317 tdata->plaintext.len,
10318 "Plaintext data not as expected");
10320 TEST_ASSERT_EQUAL(ut_params->op->status,
10321 RTE_CRYPTO_OP_STATUS_SUCCESS,
10322 "Authentication failed");
10328 test_AES_GCM_authenticated_decryption_test_case_1(void)
10330 return test_authenticated_decryption(&gcm_test_case_1);
10334 test_AES_GCM_authenticated_decryption_test_case_2(void)
10336 return test_authenticated_decryption(&gcm_test_case_2);
10340 test_AES_GCM_authenticated_decryption_test_case_3(void)
10342 return test_authenticated_decryption(&gcm_test_case_3);
10346 test_AES_GCM_authenticated_decryption_test_case_4(void)
10348 return test_authenticated_decryption(&gcm_test_case_4);
10352 test_AES_GCM_authenticated_decryption_test_case_5(void)
10354 return test_authenticated_decryption(&gcm_test_case_5);
10358 test_AES_GCM_authenticated_decryption_test_case_6(void)
10360 return test_authenticated_decryption(&gcm_test_case_6);
10364 test_AES_GCM_authenticated_decryption_test_case_7(void)
10366 return test_authenticated_decryption(&gcm_test_case_7);
10370 test_AES_GCM_authenticated_decryption_test_case_8(void)
10372 return test_authenticated_decryption(&gcm_test_case_8);
10376 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10378 return test_authenticated_decryption(&gcm_J0_test_case_1);
10382 test_AES_GCM_auth_decryption_test_case_192_1(void)
10384 return test_authenticated_decryption(&gcm_test_case_192_1);
10388 test_AES_GCM_auth_decryption_test_case_192_2(void)
10390 return test_authenticated_decryption(&gcm_test_case_192_2);
10394 test_AES_GCM_auth_decryption_test_case_192_3(void)
10396 return test_authenticated_decryption(&gcm_test_case_192_3);
10400 test_AES_GCM_auth_decryption_test_case_192_4(void)
10402 return test_authenticated_decryption(&gcm_test_case_192_4);
10406 test_AES_GCM_auth_decryption_test_case_192_5(void)
10408 return test_authenticated_decryption(&gcm_test_case_192_5);
10412 test_AES_GCM_auth_decryption_test_case_192_6(void)
10414 return test_authenticated_decryption(&gcm_test_case_192_6);
10418 test_AES_GCM_auth_decryption_test_case_192_7(void)
10420 return test_authenticated_decryption(&gcm_test_case_192_7);
10424 test_AES_GCM_auth_decryption_test_case_256_1(void)
10426 return test_authenticated_decryption(&gcm_test_case_256_1);
10430 test_AES_GCM_auth_decryption_test_case_256_2(void)
10432 return test_authenticated_decryption(&gcm_test_case_256_2);
10436 test_AES_GCM_auth_decryption_test_case_256_3(void)
10438 return test_authenticated_decryption(&gcm_test_case_256_3);
10442 test_AES_GCM_auth_decryption_test_case_256_4(void)
10444 return test_authenticated_decryption(&gcm_test_case_256_4);
10448 test_AES_GCM_auth_decryption_test_case_256_5(void)
10450 return test_authenticated_decryption(&gcm_test_case_256_5);
10454 test_AES_GCM_auth_decryption_test_case_256_6(void)
10456 return test_authenticated_decryption(&gcm_test_case_256_6);
10460 test_AES_GCM_auth_decryption_test_case_256_7(void)
10462 return test_authenticated_decryption(&gcm_test_case_256_7);
10466 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10468 return test_authenticated_decryption(&gcm_test_case_aad_1);
10472 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10474 return test_authenticated_decryption(&gcm_test_case_aad_2);
10478 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10480 struct aead_test_data tdata;
10483 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10484 tdata.iv.data[0] += 1;
10485 res = test_authenticated_decryption(&tdata);
10486 if (res == TEST_SKIPPED)
10488 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10489 return TEST_SUCCESS;
10493 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10495 struct aead_test_data tdata;
10498 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10499 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10500 tdata.plaintext.data[0] += 1;
10501 res = test_authenticated_decryption(&tdata);
10502 if (res == TEST_SKIPPED)
10504 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10505 return TEST_SUCCESS;
10509 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10511 struct aead_test_data tdata;
10514 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10515 tdata.ciphertext.data[0] += 1;
10516 res = test_authenticated_decryption(&tdata);
10517 if (res == TEST_SKIPPED)
10519 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10520 return TEST_SUCCESS;
10524 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10526 struct aead_test_data tdata;
10529 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10530 tdata.aad.len += 1;
10531 res = test_authenticated_decryption(&tdata);
10532 if (res == TEST_SKIPPED)
10534 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10535 return TEST_SUCCESS;
10539 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10541 struct aead_test_data tdata;
10542 uint8_t aad[gcm_test_case_7.aad.len];
10545 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10546 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10548 tdata.aad.data = aad;
10549 res = test_authenticated_decryption(&tdata);
10550 if (res == TEST_SKIPPED)
10552 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10553 return TEST_SUCCESS;
10557 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10559 struct aead_test_data tdata;
10562 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10563 tdata.auth_tag.data[0] += 1;
10564 res = test_authenticated_decryption(&tdata);
10565 if (res == TEST_SKIPPED)
10567 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10568 return TEST_SUCCESS;
10572 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10574 struct crypto_testsuite_params *ts_params = &testsuite_params;
10575 struct crypto_unittest_params *ut_params = &unittest_params;
10578 uint8_t *ciphertext, *auth_tag;
10579 uint16_t plaintext_pad_len;
10580 struct rte_cryptodev_info dev_info;
10582 /* Verify the capabilities */
10583 struct rte_cryptodev_sym_capability_idx cap_idx;
10584 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10585 cap_idx.algo.aead = tdata->algo;
10586 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10588 return TEST_SKIPPED;
10590 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10591 uint64_t feat_flags = dev_info.feature_flags;
10593 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10594 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
10595 return TEST_SKIPPED;
10597 /* not supported with CPU crypto */
10598 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10599 return TEST_SKIPPED;
10601 /* Create AEAD session */
10602 retval = create_aead_session(ts_params->valid_devs[0],
10604 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10605 tdata->key.data, tdata->key.len,
10606 tdata->aad.len, tdata->auth_tag.len,
10611 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10612 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10614 /* clear mbuf payload */
10615 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10616 rte_pktmbuf_tailroom(ut_params->ibuf));
10617 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10618 rte_pktmbuf_tailroom(ut_params->obuf));
10620 /* Create AEAD operation */
10621 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10625 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10627 ut_params->op->sym->m_src = ut_params->ibuf;
10628 ut_params->op->sym->m_dst = ut_params->obuf;
10630 /* Process crypto operation */
10631 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10632 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10633 ut_params->op, 0, 0, 0, 0);
10635 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10636 ut_params->op), "failed to process sym crypto op");
10638 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10639 "crypto op processing failed");
10641 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10643 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10644 ut_params->op->sym->cipher.data.offset);
10645 auth_tag = ciphertext + plaintext_pad_len;
10647 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10648 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10650 /* Validate obuf */
10651 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10653 tdata->ciphertext.data,
10654 tdata->ciphertext.len,
10655 "Ciphertext data not as expected");
10657 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10659 tdata->auth_tag.data,
10660 tdata->auth_tag.len,
10661 "Generated auth tag not as expected");
10668 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10670 return test_authenticated_encryption_oop(&gcm_test_case_5);
10674 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10676 struct crypto_testsuite_params *ts_params = &testsuite_params;
10677 struct crypto_unittest_params *ut_params = &unittest_params;
10680 uint8_t *plaintext;
10681 struct rte_cryptodev_info dev_info;
10683 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10684 uint64_t feat_flags = dev_info.feature_flags;
10686 /* Verify the capabilities */
10687 struct rte_cryptodev_sym_capability_idx cap_idx;
10688 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10689 cap_idx.algo.aead = tdata->algo;
10690 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10692 return TEST_SKIPPED;
10694 /* not supported with CPU crypto and raw data-path APIs*/
10695 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10696 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10697 return TEST_SKIPPED;
10699 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10700 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10701 printf("Device does not support RAW data-path APIs.\n");
10702 return TEST_SKIPPED;
10705 /* Create AEAD session */
10706 retval = create_aead_session(ts_params->valid_devs[0],
10708 RTE_CRYPTO_AEAD_OP_DECRYPT,
10709 tdata->key.data, tdata->key.len,
10710 tdata->aad.len, tdata->auth_tag.len,
10715 /* alloc mbuf and set payload */
10716 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10717 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10719 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10720 rte_pktmbuf_tailroom(ut_params->ibuf));
10721 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10722 rte_pktmbuf_tailroom(ut_params->obuf));
10724 /* Create AEAD operation */
10725 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10729 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10731 ut_params->op->sym->m_src = ut_params->ibuf;
10732 ut_params->op->sym->m_dst = ut_params->obuf;
10734 /* Process crypto operation */
10735 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10736 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10737 ut_params->op, 0, 0, 0, 0);
10739 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10740 ut_params->op), "failed to process sym crypto op");
10742 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10743 "crypto op processing failed");
10745 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10746 ut_params->op->sym->cipher.data.offset);
10748 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10750 /* Validate obuf */
10751 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10753 tdata->plaintext.data,
10754 tdata->plaintext.len,
10755 "Plaintext data not as expected");
10757 TEST_ASSERT_EQUAL(ut_params->op->status,
10758 RTE_CRYPTO_OP_STATUS_SUCCESS,
10759 "Authentication failed");
10764 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10766 return test_authenticated_decryption_oop(&gcm_test_case_5);
10770 test_authenticated_encryption_sessionless(
10771 const struct aead_test_data *tdata)
10773 struct crypto_testsuite_params *ts_params = &testsuite_params;
10774 struct crypto_unittest_params *ut_params = &unittest_params;
10777 uint8_t *ciphertext, *auth_tag;
10778 uint16_t plaintext_pad_len;
10779 uint8_t key[tdata->key.len + 1];
10780 struct rte_cryptodev_info dev_info;
10782 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10783 uint64_t feat_flags = dev_info.feature_flags;
10785 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10786 printf("Device doesn't support Sessionless ops.\n");
10787 return TEST_SKIPPED;
10790 /* not supported with CPU crypto */
10791 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10792 return TEST_SKIPPED;
10794 /* Verify the capabilities */
10795 struct rte_cryptodev_sym_capability_idx cap_idx;
10796 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10797 cap_idx.algo.aead = tdata->algo;
10798 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10800 return TEST_SKIPPED;
10802 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10804 /* clear mbuf payload */
10805 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10806 rte_pktmbuf_tailroom(ut_params->ibuf));
10808 /* Create AEAD operation */
10809 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10813 /* Create GCM xform */
10814 memcpy(key, tdata->key.data, tdata->key.len);
10815 retval = create_aead_xform(ut_params->op,
10817 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10818 key, tdata->key.len,
10819 tdata->aad.len, tdata->auth_tag.len,
10824 ut_params->op->sym->m_src = ut_params->ibuf;
10826 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10827 RTE_CRYPTO_OP_SESSIONLESS,
10828 "crypto op session type not sessionless");
10830 /* Process crypto operation */
10831 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10832 ut_params->op), "failed to process sym crypto op");
10834 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10836 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10837 "crypto op status not success");
10839 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10841 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10842 ut_params->op->sym->cipher.data.offset);
10843 auth_tag = ciphertext + plaintext_pad_len;
10845 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10846 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10848 /* Validate obuf */
10849 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10851 tdata->ciphertext.data,
10852 tdata->ciphertext.len,
10853 "Ciphertext data not as expected");
10855 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10857 tdata->auth_tag.data,
10858 tdata->auth_tag.len,
10859 "Generated auth tag not as expected");
10866 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10868 return test_authenticated_encryption_sessionless(
10873 test_authenticated_decryption_sessionless(
10874 const struct aead_test_data *tdata)
10876 struct crypto_testsuite_params *ts_params = &testsuite_params;
10877 struct crypto_unittest_params *ut_params = &unittest_params;
10880 uint8_t *plaintext;
10881 uint8_t key[tdata->key.len + 1];
10882 struct rte_cryptodev_info dev_info;
10884 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10885 uint64_t feat_flags = dev_info.feature_flags;
10887 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10888 printf("Device doesn't support Sessionless ops.\n");
10889 return TEST_SKIPPED;
10892 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10893 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10894 printf("Device doesn't support RAW data-path APIs.\n");
10895 return TEST_SKIPPED;
10898 /* not supported with CPU crypto */
10899 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10900 return TEST_SKIPPED;
10902 /* Verify the capabilities */
10903 struct rte_cryptodev_sym_capability_idx cap_idx;
10904 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10905 cap_idx.algo.aead = tdata->algo;
10906 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10908 return TEST_SKIPPED;
10910 /* alloc mbuf and set payload */
10911 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10913 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10914 rte_pktmbuf_tailroom(ut_params->ibuf));
10916 /* Create AEAD operation */
10917 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10921 /* Create AEAD xform */
10922 memcpy(key, tdata->key.data, tdata->key.len);
10923 retval = create_aead_xform(ut_params->op,
10925 RTE_CRYPTO_AEAD_OP_DECRYPT,
10926 key, tdata->key.len,
10927 tdata->aad.len, tdata->auth_tag.len,
10932 ut_params->op->sym->m_src = ut_params->ibuf;
10934 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10935 RTE_CRYPTO_OP_SESSIONLESS,
10936 "crypto op session type not sessionless");
10938 /* Process crypto operation */
10939 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10940 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10941 ut_params->op, 0, 0, 0, 0);
10943 TEST_ASSERT_NOT_NULL(process_crypto_request(
10944 ts_params->valid_devs[0], ut_params->op),
10945 "failed to process sym crypto op");
10947 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10949 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10950 "crypto op status not success");
10952 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10953 ut_params->op->sym->cipher.data.offset);
10955 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10957 /* Validate obuf */
10958 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10960 tdata->plaintext.data,
10961 tdata->plaintext.len,
10962 "Plaintext data not as expected");
10964 TEST_ASSERT_EQUAL(ut_params->op->status,
10965 RTE_CRYPTO_OP_STATUS_SUCCESS,
10966 "Authentication failed");
10971 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10973 return test_authenticated_decryption_sessionless(
10978 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10980 return test_authenticated_encryption(&ccm_test_case_128_1);
10984 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10986 return test_authenticated_encryption(&ccm_test_case_128_2);
10990 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10992 return test_authenticated_encryption(&ccm_test_case_128_3);
10996 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10998 return test_authenticated_decryption(&ccm_test_case_128_1);
11002 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
11004 return test_authenticated_decryption(&ccm_test_case_128_2);
11008 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
11010 return test_authenticated_decryption(&ccm_test_case_128_3);
11014 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
11016 return test_authenticated_encryption(&ccm_test_case_192_1);
11020 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
11022 return test_authenticated_encryption(&ccm_test_case_192_2);
11026 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
11028 return test_authenticated_encryption(&ccm_test_case_192_3);
11032 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
11034 return test_authenticated_decryption(&ccm_test_case_192_1);
11038 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
11040 return test_authenticated_decryption(&ccm_test_case_192_2);
11044 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
11046 return test_authenticated_decryption(&ccm_test_case_192_3);
11050 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
11052 return test_authenticated_encryption(&ccm_test_case_256_1);
11056 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
11058 return test_authenticated_encryption(&ccm_test_case_256_2);
11062 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
11064 return test_authenticated_encryption(&ccm_test_case_256_3);
11068 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
11070 return test_authenticated_decryption(&ccm_test_case_256_1);
11074 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
11076 return test_authenticated_decryption(&ccm_test_case_256_2);
11080 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
11082 return test_authenticated_decryption(&ccm_test_case_256_3);
11088 struct crypto_testsuite_params *ts_params = &testsuite_params;
11089 struct rte_cryptodev_stats stats;
11091 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11092 return TEST_SKIPPED;
11094 /* Verify the capabilities */
11095 struct rte_cryptodev_sym_capability_idx cap_idx;
11096 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11097 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11098 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11100 return TEST_SKIPPED;
11101 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11102 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11103 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11105 return TEST_SKIPPED;
11107 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11109 return TEST_SKIPPED;
11111 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11112 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11113 &stats) == -ENODEV),
11114 "rte_cryptodev_stats_get invalid dev failed");
11115 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11116 "rte_cryptodev_stats_get invalid Param failed");
11118 /* Test expected values */
11119 test_AES_CBC_HMAC_SHA1_encrypt_digest();
11120 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11122 "rte_cryptodev_stats_get failed");
11123 TEST_ASSERT((stats.enqueued_count == 1),
11124 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11125 TEST_ASSERT((stats.dequeued_count == 1),
11126 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11127 TEST_ASSERT((stats.enqueue_err_count == 0),
11128 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11129 TEST_ASSERT((stats.dequeue_err_count == 0),
11130 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11132 /* invalid device but should ignore and not reset device stats*/
11133 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11134 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11136 "rte_cryptodev_stats_get failed");
11137 TEST_ASSERT((stats.enqueued_count == 1),
11138 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11140 /* check that a valid reset clears stats */
11141 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11142 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11144 "rte_cryptodev_stats_get failed");
11145 TEST_ASSERT((stats.enqueued_count == 0),
11146 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11147 TEST_ASSERT((stats.dequeued_count == 0),
11148 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11150 return TEST_SUCCESS;
11153 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11154 struct crypto_unittest_params *ut_params,
11155 enum rte_crypto_auth_operation op,
11156 const struct HMAC_MD5_vector *test_case)
11160 memcpy(key, test_case->key.data, test_case->key.len);
11162 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11163 ut_params->auth_xform.next = NULL;
11164 ut_params->auth_xform.auth.op = op;
11166 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11168 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11169 ut_params->auth_xform.auth.key.length = test_case->key.len;
11170 ut_params->auth_xform.auth.key.data = key;
11172 ut_params->sess = rte_cryptodev_sym_session_create(
11173 ts_params->session_mpool);
11175 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11176 ut_params->sess, &ut_params->auth_xform,
11177 ts_params->session_priv_mpool);
11179 if (ut_params->sess == NULL)
11180 return TEST_FAILED;
11182 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11184 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11185 rte_pktmbuf_tailroom(ut_params->ibuf));
11190 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11191 const struct HMAC_MD5_vector *test_case,
11192 uint8_t **plaintext)
11194 uint16_t plaintext_pad_len;
11196 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11198 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11201 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11202 plaintext_pad_len);
11203 memcpy(*plaintext, test_case->plaintext.data,
11204 test_case->plaintext.len);
11206 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11207 ut_params->ibuf, MD5_DIGEST_LEN);
11208 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11209 "no room to append digest");
11210 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11211 ut_params->ibuf, plaintext_pad_len);
11213 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11214 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11215 test_case->auth_tag.len);
11218 sym_op->auth.data.offset = 0;
11219 sym_op->auth.data.length = test_case->plaintext.len;
11221 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11222 ut_params->op->sym->m_src = ut_params->ibuf;
11228 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11230 uint16_t plaintext_pad_len;
11231 uint8_t *plaintext, *auth_tag;
11233 struct crypto_testsuite_params *ts_params = &testsuite_params;
11234 struct crypto_unittest_params *ut_params = &unittest_params;
11235 struct rte_cryptodev_info dev_info;
11237 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11238 uint64_t feat_flags = dev_info.feature_flags;
11240 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11241 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11242 printf("Device doesn't support RAW data-path APIs.\n");
11243 return TEST_SKIPPED;
11246 /* Verify the capabilities */
11247 struct rte_cryptodev_sym_capability_idx cap_idx;
11248 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11249 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11250 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11252 return TEST_SKIPPED;
11254 if (MD5_HMAC_create_session(ts_params, ut_params,
11255 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11256 return TEST_FAILED;
11258 /* Generate Crypto op data structure */
11259 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11260 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11261 TEST_ASSERT_NOT_NULL(ut_params->op,
11262 "Failed to allocate symmetric crypto operation struct");
11264 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11267 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11268 return TEST_FAILED;
11270 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11271 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11273 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11274 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11275 ut_params->op, 0, 1, 0, 0);
11277 TEST_ASSERT_NOT_NULL(
11278 process_crypto_request(ts_params->valid_devs[0],
11280 "failed to process sym crypto op");
11282 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11283 "crypto op processing failed");
11285 if (ut_params->op->sym->m_dst) {
11286 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11287 uint8_t *, plaintext_pad_len);
11289 auth_tag = plaintext + plaintext_pad_len;
11292 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11294 test_case->auth_tag.data,
11295 test_case->auth_tag.len,
11296 "HMAC_MD5 generated tag not as expected");
11298 return TEST_SUCCESS;
11302 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11304 uint8_t *plaintext;
11306 struct crypto_testsuite_params *ts_params = &testsuite_params;
11307 struct crypto_unittest_params *ut_params = &unittest_params;
11308 struct rte_cryptodev_info dev_info;
11310 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11311 uint64_t feat_flags = dev_info.feature_flags;
11313 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11314 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11315 printf("Device doesn't support RAW data-path APIs.\n");
11316 return TEST_SKIPPED;
11319 /* Verify the capabilities */
11320 struct rte_cryptodev_sym_capability_idx cap_idx;
11321 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11322 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11323 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11325 return TEST_SKIPPED;
11327 if (MD5_HMAC_create_session(ts_params, ut_params,
11328 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11329 return TEST_FAILED;
11332 /* Generate Crypto op data structure */
11333 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11334 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11335 TEST_ASSERT_NOT_NULL(ut_params->op,
11336 "Failed to allocate symmetric crypto operation struct");
11338 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11339 return TEST_FAILED;
11341 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11342 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11344 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11345 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11346 ut_params->op, 0, 1, 0, 0);
11348 TEST_ASSERT_NOT_NULL(
11349 process_crypto_request(ts_params->valid_devs[0],
11351 "failed to process sym crypto op");
11353 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11354 "HMAC_MD5 crypto op processing failed");
11356 return TEST_SUCCESS;
11360 test_MD5_HMAC_generate_case_1(void)
11362 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11366 test_MD5_HMAC_verify_case_1(void)
11368 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11372 test_MD5_HMAC_generate_case_2(void)
11374 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11378 test_MD5_HMAC_verify_case_2(void)
11380 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11384 test_multi_session(void)
11386 struct crypto_testsuite_params *ts_params = &testsuite_params;
11387 struct crypto_unittest_params *ut_params = &unittest_params;
11389 struct rte_cryptodev_info dev_info;
11390 struct rte_cryptodev_sym_session **sessions;
11394 /* Verify the capabilities */
11395 struct rte_cryptodev_sym_capability_idx cap_idx;
11396 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11397 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11398 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11400 return TEST_SKIPPED;
11401 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11402 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11403 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11405 return TEST_SKIPPED;
11407 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11408 aes_cbc_key, hmac_sha512_key);
11411 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11413 sessions = rte_malloc(NULL,
11414 sizeof(struct rte_cryptodev_sym_session *) *
11415 (MAX_NB_SESSIONS + 1), 0);
11417 /* Create multiple crypto sessions*/
11418 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11420 sessions[i] = rte_cryptodev_sym_session_create(
11421 ts_params->session_mpool);
11423 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11424 sessions[i], &ut_params->auth_xform,
11425 ts_params->session_priv_mpool);
11426 TEST_ASSERT_NOT_NULL(sessions[i],
11427 "Session creation failed at session number %u",
11430 /* Attempt to send a request on each session */
11431 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11435 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11436 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11438 "Failed to perform decrypt on request number %u.", i);
11439 /* free crypto operation structure */
11441 rte_crypto_op_free(ut_params->op);
11444 * free mbuf - both obuf and ibuf are usually the same,
11445 * so check if they point at the same address is necessary,
11446 * to avoid freeing the mbuf twice.
11448 if (ut_params->obuf) {
11449 rte_pktmbuf_free(ut_params->obuf);
11450 if (ut_params->ibuf == ut_params->obuf)
11451 ut_params->ibuf = 0;
11452 ut_params->obuf = 0;
11454 if (ut_params->ibuf) {
11455 rte_pktmbuf_free(ut_params->ibuf);
11456 ut_params->ibuf = 0;
11460 sessions[i] = NULL;
11461 /* Next session create should fail */
11462 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11463 sessions[i], &ut_params->auth_xform,
11464 ts_params->session_priv_mpool);
11465 TEST_ASSERT_NULL(sessions[i],
11466 "Session creation succeeded unexpectedly!");
11468 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11469 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11471 rte_cryptodev_sym_session_free(sessions[i]);
11474 rte_free(sessions);
11476 return TEST_SUCCESS;
11479 struct multi_session_params {
11480 struct crypto_unittest_params ut_params;
11481 uint8_t *cipher_key;
11483 const uint8_t *cipher;
11484 const uint8_t *digest;
11488 #define MB_SESSION_NUMBER 3
11491 test_multi_session_random_usage(void)
11493 struct crypto_testsuite_params *ts_params = &testsuite_params;
11494 struct rte_cryptodev_info dev_info;
11495 struct rte_cryptodev_sym_session **sessions;
11497 struct multi_session_params ut_paramz[] = {
11500 .cipher_key = ms_aes_cbc_key0,
11501 .hmac_key = ms_hmac_key0,
11502 .cipher = ms_aes_cbc_cipher0,
11503 .digest = ms_hmac_digest0,
11504 .iv = ms_aes_cbc_iv0
11507 .cipher_key = ms_aes_cbc_key1,
11508 .hmac_key = ms_hmac_key1,
11509 .cipher = ms_aes_cbc_cipher1,
11510 .digest = ms_hmac_digest1,
11511 .iv = ms_aes_cbc_iv1
11514 .cipher_key = ms_aes_cbc_key2,
11515 .hmac_key = ms_hmac_key2,
11516 .cipher = ms_aes_cbc_cipher2,
11517 .digest = ms_hmac_digest2,
11518 .iv = ms_aes_cbc_iv2
11523 /* Verify the capabilities */
11524 struct rte_cryptodev_sym_capability_idx cap_idx;
11525 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11526 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11527 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11529 return TEST_SKIPPED;
11530 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11531 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11532 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11534 return TEST_SKIPPED;
11536 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11538 sessions = rte_malloc(NULL,
11539 (sizeof(struct rte_cryptodev_sym_session *)
11540 * MAX_NB_SESSIONS) + 1, 0);
11542 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11543 sessions[i] = rte_cryptodev_sym_session_create(
11544 ts_params->session_mpool);
11546 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11547 sizeof(struct crypto_unittest_params));
11549 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11550 &ut_paramz[i].ut_params,
11551 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11553 /* Create multiple crypto sessions*/
11554 rte_cryptodev_sym_session_init(
11555 ts_params->valid_devs[0],
11557 &ut_paramz[i].ut_params.auth_xform,
11558 ts_params->session_priv_mpool);
11560 TEST_ASSERT_NOT_NULL(sessions[i],
11561 "Session creation failed at session number %u",
11567 for (i = 0; i < 40000; i++) {
11569 j = rand() % MB_SESSION_NUMBER;
11571 TEST_ASSERT_SUCCESS(
11572 test_AES_CBC_HMAC_SHA512_decrypt_perform(
11574 &ut_paramz[j].ut_params,
11575 ts_params, ut_paramz[j].cipher,
11576 ut_paramz[j].digest,
11578 "Failed to perform decrypt on request number %u.", i);
11580 if (ut_paramz[j].ut_params.op)
11581 rte_crypto_op_free(ut_paramz[j].ut_params.op);
11584 * free mbuf - both obuf and ibuf are usually the same,
11585 * so check if they point at the same address is necessary,
11586 * to avoid freeing the mbuf twice.
11588 if (ut_paramz[j].ut_params.obuf) {
11589 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11590 if (ut_paramz[j].ut_params.ibuf
11591 == ut_paramz[j].ut_params.obuf)
11592 ut_paramz[j].ut_params.ibuf = 0;
11593 ut_paramz[j].ut_params.obuf = 0;
11595 if (ut_paramz[j].ut_params.ibuf) {
11596 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11597 ut_paramz[j].ut_params.ibuf = 0;
11601 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11602 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11604 rte_cryptodev_sym_session_free(sessions[i]);
11607 rte_free(sessions);
11609 return TEST_SUCCESS;
11612 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11613 0xab, 0xab, 0xab, 0xab,
11614 0xab, 0xab, 0xab, 0xab,
11615 0xab, 0xab, 0xab, 0xab};
11618 test_null_invalid_operation(void)
11620 struct crypto_testsuite_params *ts_params = &testsuite_params;
11621 struct crypto_unittest_params *ut_params = &unittest_params;
11624 /* This test is for NULL PMD only */
11625 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11626 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11627 return TEST_SKIPPED;
11629 /* Setup Cipher Parameters */
11630 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11631 ut_params->cipher_xform.next = NULL;
11633 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11634 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11636 ut_params->sess = rte_cryptodev_sym_session_create(
11637 ts_params->session_mpool);
11639 /* Create Crypto session*/
11640 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11641 ut_params->sess, &ut_params->cipher_xform,
11642 ts_params->session_priv_mpool);
11643 TEST_ASSERT(ret < 0,
11644 "Session creation succeeded unexpectedly");
11647 /* Setup HMAC Parameters */
11648 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11649 ut_params->auth_xform.next = NULL;
11651 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11652 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11654 ut_params->sess = rte_cryptodev_sym_session_create(
11655 ts_params->session_mpool);
11657 /* Create Crypto session*/
11658 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11659 ut_params->sess, &ut_params->auth_xform,
11660 ts_params->session_priv_mpool);
11661 TEST_ASSERT(ret < 0,
11662 "Session creation succeeded unexpectedly");
11664 return TEST_SUCCESS;
11668 #define NULL_BURST_LENGTH (32)
11671 test_null_burst_operation(void)
11673 struct crypto_testsuite_params *ts_params = &testsuite_params;
11674 struct crypto_unittest_params *ut_params = &unittest_params;
11676 unsigned i, burst_len = NULL_BURST_LENGTH;
11678 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11679 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11681 /* This test is for NULL PMD only */
11682 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11683 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11684 return TEST_SKIPPED;
11686 /* Setup Cipher Parameters */
11687 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11688 ut_params->cipher_xform.next = &ut_params->auth_xform;
11690 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11691 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11693 /* Setup HMAC Parameters */
11694 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11695 ut_params->auth_xform.next = NULL;
11697 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11698 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11700 ut_params->sess = rte_cryptodev_sym_session_create(
11701 ts_params->session_mpool);
11703 /* Create Crypto session*/
11704 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11705 ut_params->sess, &ut_params->cipher_xform,
11706 ts_params->session_priv_mpool);
11707 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11709 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11710 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11711 burst_len, "failed to generate burst of crypto ops");
11713 /* Generate an operation for each mbuf in burst */
11714 for (i = 0; i < burst_len; i++) {
11715 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11717 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11719 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11723 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11725 burst[i]->sym->m_src = m;
11728 /* Process crypto operation */
11729 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11730 0, burst, burst_len),
11732 "Error enqueuing burst");
11734 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11735 0, burst_dequeued, burst_len),
11737 "Error dequeuing burst");
11740 for (i = 0; i < burst_len; i++) {
11742 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11743 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11745 "data not as expected");
11747 rte_pktmbuf_free(burst[i]->sym->m_src);
11748 rte_crypto_op_free(burst[i]);
11751 return TEST_SUCCESS;
11755 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11756 uint16_t nb_ops, void *user_param)
11758 RTE_SET_USED(dev_id);
11759 RTE_SET_USED(qp_id);
11761 RTE_SET_USED(user_param);
11763 printf("crypto enqueue callback called\n");
11768 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11769 uint16_t nb_ops, void *user_param)
11771 RTE_SET_USED(dev_id);
11772 RTE_SET_USED(qp_id);
11774 RTE_SET_USED(user_param);
11776 printf("crypto dequeue callback called\n");
11781 * Thread using enqueue/dequeue callback with RCU.
11784 test_enqdeq_callback_thread(void *arg)
11787 /* DP thread calls rte_cryptodev_enqueue_burst()/
11788 * rte_cryptodev_dequeue_burst() and invokes callback.
11790 test_null_burst_operation();
11795 test_enq_callback_setup(void)
11797 struct crypto_testsuite_params *ts_params = &testsuite_params;
11798 struct rte_cryptodev_info dev_info;
11799 struct rte_cryptodev_qp_conf qp_conf = {
11800 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11803 struct rte_cryptodev_cb *cb;
11804 uint16_t qp_id = 0;
11806 /* Stop the device in case it's started so it can be configured */
11807 rte_cryptodev_stop(ts_params->valid_devs[0]);
11809 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11811 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11813 "Failed to configure cryptodev %u",
11814 ts_params->valid_devs[0]);
11816 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11817 qp_conf.mp_session = ts_params->session_mpool;
11818 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11820 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11821 ts_params->valid_devs[0], qp_id, &qp_conf,
11822 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11824 "rte_cryptodev_queue_pair_setup: num_inflights "
11825 "%u on qp %u on cryptodev %u",
11826 qp_conf.nb_descriptors, qp_id,
11827 ts_params->valid_devs[0]);
11829 /* Test with invalid crypto device */
11830 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11831 qp_id, test_enq_callback, NULL);
11832 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11833 "cryptodev %u did not fail",
11834 qp_id, RTE_CRYPTO_MAX_DEVS);
11836 /* Test with invalid queue pair */
11837 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11838 dev_info.max_nb_queue_pairs + 1,
11839 test_enq_callback, NULL);
11840 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11841 "cryptodev %u did not fail",
11842 dev_info.max_nb_queue_pairs + 1,
11843 ts_params->valid_devs[0]);
11845 /* Test with NULL callback */
11846 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11847 qp_id, NULL, NULL);
11848 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11849 "cryptodev %u did not fail",
11850 qp_id, ts_params->valid_devs[0]);
11852 /* Test with valid configuration */
11853 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11854 qp_id, test_enq_callback, NULL);
11855 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11856 "qp %u on cryptodev %u",
11857 qp_id, ts_params->valid_devs[0]);
11859 rte_cryptodev_start(ts_params->valid_devs[0]);
11861 /* Launch a thread */
11862 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11863 rte_get_next_lcore(-1, 1, 0));
11865 /* Wait until reader exited. */
11866 rte_eal_mp_wait_lcore();
11868 /* Test with invalid crypto device */
11869 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11870 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11871 "Expected call to fail as crypto device is invalid");
11873 /* Test with invalid queue pair */
11874 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11875 ts_params->valid_devs[0],
11876 dev_info.max_nb_queue_pairs + 1, cb),
11877 "Expected call to fail as queue pair is invalid");
11879 /* Test with NULL callback */
11880 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11881 ts_params->valid_devs[0], qp_id, NULL),
11882 "Expected call to fail as callback is NULL");
11884 /* Test with valid configuration */
11885 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11886 ts_params->valid_devs[0], qp_id, cb),
11887 "Failed test to remove callback on "
11888 "qp %u on cryptodev %u",
11889 qp_id, ts_params->valid_devs[0]);
11891 return TEST_SUCCESS;
11895 test_deq_callback_setup(void)
11897 struct crypto_testsuite_params *ts_params = &testsuite_params;
11898 struct rte_cryptodev_info dev_info;
11899 struct rte_cryptodev_qp_conf qp_conf = {
11900 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11903 struct rte_cryptodev_cb *cb;
11904 uint16_t qp_id = 0;
11906 /* Stop the device in case it's started so it can be configured */
11907 rte_cryptodev_stop(ts_params->valid_devs[0]);
11909 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11911 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11913 "Failed to configure cryptodev %u",
11914 ts_params->valid_devs[0]);
11916 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11917 qp_conf.mp_session = ts_params->session_mpool;
11918 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11920 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11921 ts_params->valid_devs[0], qp_id, &qp_conf,
11922 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11924 "rte_cryptodev_queue_pair_setup: num_inflights "
11925 "%u on qp %u on cryptodev %u",
11926 qp_conf.nb_descriptors, qp_id,
11927 ts_params->valid_devs[0]);
11929 /* Test with invalid crypto device */
11930 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11931 qp_id, test_deq_callback, NULL);
11932 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11933 "cryptodev %u did not fail",
11934 qp_id, RTE_CRYPTO_MAX_DEVS);
11936 /* Test with invalid queue pair */
11937 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11938 dev_info.max_nb_queue_pairs + 1,
11939 test_deq_callback, NULL);
11940 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11941 "cryptodev %u did not fail",
11942 dev_info.max_nb_queue_pairs + 1,
11943 ts_params->valid_devs[0]);
11945 /* Test with NULL callback */
11946 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11947 qp_id, NULL, NULL);
11948 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11949 "cryptodev %u did not fail",
11950 qp_id, ts_params->valid_devs[0]);
11952 /* Test with valid configuration */
11953 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11954 qp_id, test_deq_callback, NULL);
11955 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11956 "qp %u on cryptodev %u",
11957 qp_id, ts_params->valid_devs[0]);
11959 rte_cryptodev_start(ts_params->valid_devs[0]);
11961 /* Launch a thread */
11962 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11963 rte_get_next_lcore(-1, 1, 0));
11965 /* Wait until reader exited. */
11966 rte_eal_mp_wait_lcore();
11968 /* Test with invalid crypto device */
11969 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11970 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11971 "Expected call to fail as crypto device is invalid");
11973 /* Test with invalid queue pair */
11974 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11975 ts_params->valid_devs[0],
11976 dev_info.max_nb_queue_pairs + 1, cb),
11977 "Expected call to fail as queue pair is invalid");
11979 /* Test with NULL callback */
11980 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11981 ts_params->valid_devs[0], qp_id, NULL),
11982 "Expected call to fail as callback is NULL");
11984 /* Test with valid configuration */
11985 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11986 ts_params->valid_devs[0], qp_id, cb),
11987 "Failed test to remove callback on "
11988 "qp %u on cryptodev %u",
11989 qp_id, ts_params->valid_devs[0]);
11991 return TEST_SUCCESS;
11995 generate_gmac_large_plaintext(uint8_t *data)
11999 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
12000 memcpy(&data[i], &data[0], 32);
12004 create_gmac_operation(enum rte_crypto_auth_operation op,
12005 const struct gmac_test_data *tdata)
12007 struct crypto_testsuite_params *ts_params = &testsuite_params;
12008 struct crypto_unittest_params *ut_params = &unittest_params;
12009 struct rte_crypto_sym_op *sym_op;
12011 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12013 /* Generate Crypto op data structure */
12014 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12015 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12016 TEST_ASSERT_NOT_NULL(ut_params->op,
12017 "Failed to allocate symmetric crypto operation struct");
12019 sym_op = ut_params->op->sym;
12021 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12022 ut_params->ibuf, tdata->gmac_tag.len);
12023 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12024 "no room to append digest");
12026 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12027 ut_params->ibuf, plaintext_pad_len);
12029 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12030 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12031 tdata->gmac_tag.len);
12032 debug_hexdump(stdout, "digest:",
12033 sym_op->auth.digest.data,
12034 tdata->gmac_tag.len);
12037 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12038 uint8_t *, IV_OFFSET);
12040 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12042 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12044 sym_op->cipher.data.length = 0;
12045 sym_op->cipher.data.offset = 0;
12047 sym_op->auth.data.offset = 0;
12048 sym_op->auth.data.length = tdata->plaintext.len;
12054 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
12055 const struct gmac_test_data *tdata,
12056 void *digest_mem, uint64_t digest_phys)
12058 struct crypto_testsuite_params *ts_params = &testsuite_params;
12059 struct crypto_unittest_params *ut_params = &unittest_params;
12060 struct rte_crypto_sym_op *sym_op;
12062 /* Generate Crypto op data structure */
12063 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12064 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12065 TEST_ASSERT_NOT_NULL(ut_params->op,
12066 "Failed to allocate symmetric crypto operation struct");
12068 sym_op = ut_params->op->sym;
12070 sym_op->auth.digest.data = digest_mem;
12071 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12072 "no room to append digest");
12074 sym_op->auth.digest.phys_addr = digest_phys;
12076 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12077 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12078 tdata->gmac_tag.len);
12079 debug_hexdump(stdout, "digest:",
12080 sym_op->auth.digest.data,
12081 tdata->gmac_tag.len);
12084 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12085 uint8_t *, IV_OFFSET);
12087 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12089 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12091 sym_op->cipher.data.length = 0;
12092 sym_op->cipher.data.offset = 0;
12094 sym_op->auth.data.offset = 0;
12095 sym_op->auth.data.length = tdata->plaintext.len;
12100 static int create_gmac_session(uint8_t dev_id,
12101 const struct gmac_test_data *tdata,
12102 enum rte_crypto_auth_operation auth_op)
12104 uint8_t auth_key[tdata->key.len];
12106 struct crypto_testsuite_params *ts_params = &testsuite_params;
12107 struct crypto_unittest_params *ut_params = &unittest_params;
12109 memcpy(auth_key, tdata->key.data, tdata->key.len);
12111 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12112 ut_params->auth_xform.next = NULL;
12114 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12115 ut_params->auth_xform.auth.op = auth_op;
12116 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12117 ut_params->auth_xform.auth.key.length = tdata->key.len;
12118 ut_params->auth_xform.auth.key.data = auth_key;
12119 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12120 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12123 ut_params->sess = rte_cryptodev_sym_session_create(
12124 ts_params->session_mpool);
12126 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12127 &ut_params->auth_xform,
12128 ts_params->session_priv_mpool);
12130 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12136 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12138 struct crypto_testsuite_params *ts_params = &testsuite_params;
12139 struct crypto_unittest_params *ut_params = &unittest_params;
12140 struct rte_cryptodev_info dev_info;
12142 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12143 uint64_t feat_flags = dev_info.feature_flags;
12145 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12146 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12147 printf("Device doesn't support RAW data-path APIs.\n");
12148 return TEST_SKIPPED;
12153 uint8_t *auth_tag, *plaintext;
12154 uint16_t plaintext_pad_len;
12156 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12157 "No GMAC length in the source data");
12159 /* Verify the capabilities */
12160 struct rte_cryptodev_sym_capability_idx cap_idx;
12161 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12162 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12163 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12165 return TEST_SKIPPED;
12167 retval = create_gmac_session(ts_params->valid_devs[0],
12168 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12173 if (tdata->plaintext.len > MBUF_SIZE)
12174 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12177 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12178 "Failed to allocate input buffer in mempool");
12180 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12181 rte_pktmbuf_tailroom(ut_params->ibuf));
12183 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12185 * Runtime generate the large plain text instead of use hard code
12186 * plain text vector. It is done to avoid create huge source file
12187 * with the test vector.
12189 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12190 generate_gmac_large_plaintext(tdata->plaintext.data);
12192 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12193 plaintext_pad_len);
12194 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12196 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12197 debug_hexdump(stdout, "plaintext:", plaintext,
12198 tdata->plaintext.len);
12200 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12206 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12208 ut_params->op->sym->m_src = ut_params->ibuf;
12210 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12211 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12213 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12214 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12215 ut_params->op, 0, 1, 0, 0);
12217 TEST_ASSERT_NOT_NULL(
12218 process_crypto_request(ts_params->valid_devs[0],
12219 ut_params->op), "failed to process sym crypto op");
12221 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12222 "crypto op processing failed");
12224 if (ut_params->op->sym->m_dst) {
12225 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12226 uint8_t *, plaintext_pad_len);
12228 auth_tag = plaintext + plaintext_pad_len;
12231 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12233 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12235 tdata->gmac_tag.data,
12236 tdata->gmac_tag.len,
12237 "GMAC Generated auth tag not as expected");
12243 test_AES_GMAC_authentication_test_case_1(void)
12245 return test_AES_GMAC_authentication(&gmac_test_case_1);
12249 test_AES_GMAC_authentication_test_case_2(void)
12251 return test_AES_GMAC_authentication(&gmac_test_case_2);
12255 test_AES_GMAC_authentication_test_case_3(void)
12257 return test_AES_GMAC_authentication(&gmac_test_case_3);
12261 test_AES_GMAC_authentication_test_case_4(void)
12263 return test_AES_GMAC_authentication(&gmac_test_case_4);
12267 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12269 struct crypto_testsuite_params *ts_params = &testsuite_params;
12270 struct crypto_unittest_params *ut_params = &unittest_params;
12272 uint32_t plaintext_pad_len;
12273 uint8_t *plaintext;
12274 struct rte_cryptodev_info dev_info;
12276 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12277 uint64_t feat_flags = dev_info.feature_flags;
12279 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12280 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12281 printf("Device doesn't support RAW data-path APIs.\n");
12282 return TEST_SKIPPED;
12285 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12286 "No GMAC length in the source data");
12288 /* Verify the capabilities */
12289 struct rte_cryptodev_sym_capability_idx cap_idx;
12290 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12291 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12292 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12294 return TEST_SKIPPED;
12296 retval = create_gmac_session(ts_params->valid_devs[0],
12297 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12302 if (tdata->plaintext.len > MBUF_SIZE)
12303 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12305 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12306 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12307 "Failed to allocate input buffer in mempool");
12309 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12310 rte_pktmbuf_tailroom(ut_params->ibuf));
12312 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12315 * Runtime generate the large plain text instead of use hard code
12316 * plain text vector. It is done to avoid create huge source file
12317 * with the test vector.
12319 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12320 generate_gmac_large_plaintext(tdata->plaintext.data);
12322 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12323 plaintext_pad_len);
12324 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12326 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12327 debug_hexdump(stdout, "plaintext:", plaintext,
12328 tdata->plaintext.len);
12330 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
12336 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12338 ut_params->op->sym->m_src = ut_params->ibuf;
12340 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12341 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12343 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12344 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12345 ut_params->op, 0, 1, 0, 0);
12347 TEST_ASSERT_NOT_NULL(
12348 process_crypto_request(ts_params->valid_devs[0],
12349 ut_params->op), "failed to process sym crypto op");
12351 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12352 "crypto op processing failed");
12359 test_AES_GMAC_authentication_verify_test_case_1(void)
12361 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12365 test_AES_GMAC_authentication_verify_test_case_2(void)
12367 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12371 test_AES_GMAC_authentication_verify_test_case_3(void)
12373 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12377 test_AES_GMAC_authentication_verify_test_case_4(void)
12379 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12383 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12386 struct crypto_testsuite_params *ts_params = &testsuite_params;
12387 struct crypto_unittest_params *ut_params = &unittest_params;
12388 struct rte_cryptodev_info dev_info;
12389 uint64_t feature_flags;
12390 unsigned int trn_data = 0;
12391 void *digest_mem = NULL;
12393 unsigned int to_trn = 0;
12394 struct rte_mbuf *buf = NULL;
12395 uint8_t *auth_tag, *plaintext;
12398 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12399 "No GMAC length in the source data");
12401 /* Verify the capabilities */
12402 struct rte_cryptodev_sym_capability_idx cap_idx;
12403 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12404 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12405 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12407 return TEST_SKIPPED;
12409 /* Check for any input SGL support */
12410 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12411 feature_flags = dev_info.feature_flags;
12413 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12414 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12415 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12416 return TEST_SKIPPED;
12418 if (fragsz > tdata->plaintext.len)
12419 fragsz = tdata->plaintext.len;
12421 uint16_t plaintext_len = fragsz;
12423 retval = create_gmac_session(ts_params->valid_devs[0],
12424 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12429 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12430 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12431 "Failed to allocate input buffer in mempool");
12433 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12434 rte_pktmbuf_tailroom(ut_params->ibuf));
12436 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12438 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12440 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12442 trn_data += plaintext_len;
12444 buf = ut_params->ibuf;
12447 * Loop until no more fragments
12450 while (trn_data < tdata->plaintext.len) {
12452 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12453 (tdata->plaintext.len - trn_data) : fragsz;
12455 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12458 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12459 rte_pktmbuf_tailroom(buf));
12461 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12464 memcpy(plaintext, tdata->plaintext.data + trn_data,
12466 trn_data += to_trn;
12467 if (trn_data == tdata->plaintext.len)
12468 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12469 tdata->gmac_tag.len);
12471 ut_params->ibuf->nb_segs = segs;
12474 * Place digest at the end of the last buffer
12476 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12479 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12480 + tdata->gmac_tag.len);
12481 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12482 tdata->plaintext.len);
12485 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12486 tdata, digest_mem, digest_phys);
12491 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12493 ut_params->op->sym->m_src = ut_params->ibuf;
12495 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12496 return TEST_SKIPPED;
12498 TEST_ASSERT_NOT_NULL(
12499 process_crypto_request(ts_params->valid_devs[0],
12500 ut_params->op), "failed to process sym crypto op");
12502 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12503 "crypto op processing failed");
12505 auth_tag = digest_mem;
12506 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12507 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12509 tdata->gmac_tag.data,
12510 tdata->gmac_tag.len,
12511 "GMAC Generated auth tag not as expected");
12516 /* Segment size not multiple of block size (16B) */
12518 test_AES_GMAC_authentication_SGL_40B(void)
12520 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12524 test_AES_GMAC_authentication_SGL_80B(void)
12526 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12530 test_AES_GMAC_authentication_SGL_2048B(void)
12532 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12535 /* Segment size not multiple of block size (16B) */
12537 test_AES_GMAC_authentication_SGL_2047B(void)
12539 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12542 struct test_crypto_vector {
12543 enum rte_crypto_cipher_algorithm crypto_algo;
12544 unsigned int cipher_offset;
12545 unsigned int cipher_len;
12558 const uint8_t *data;
12563 const uint8_t *data;
12567 enum rte_crypto_auth_algorithm auth_algo;
12568 unsigned int auth_offset;
12576 const uint8_t *data;
12586 static const struct test_crypto_vector
12587 hmac_sha1_test_crypto_vector = {
12588 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12590 .data = plaintext_hash,
12595 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12596 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12597 0xDE, 0xF4, 0xDE, 0xAD
12603 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12604 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12605 0x3F, 0x91, 0x64, 0x59
12611 static const struct test_crypto_vector
12612 aes128_gmac_test_vector = {
12613 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12615 .data = plaintext_hash,
12620 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12621 0x08, 0x09, 0x0A, 0x0B
12627 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12628 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12634 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12635 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12641 static const struct test_crypto_vector
12642 aes128cbc_hmac_sha1_test_vector = {
12643 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12644 .cipher_offset = 0,
12648 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12649 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12655 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12656 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12661 .data = plaintext_hash,
12665 .data = ciphertext512_aes128cbc,
12668 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12672 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12673 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12674 0xDE, 0xF4, 0xDE, 0xAD
12680 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12681 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12682 0x18, 0x8C, 0x1D, 0x32
12688 static const struct test_crypto_vector
12689 aes128cbc_hmac_sha1_aad_test_vector = {
12690 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12691 .cipher_offset = 8,
12695 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12696 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12702 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12703 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12708 .data = plaintext_hash,
12712 .data = ciphertext512_aes128cbc_aad,
12715 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12719 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12720 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12721 0xDE, 0xF4, 0xDE, 0xAD
12727 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12728 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12729 0x62, 0x0F, 0xFB, 0x10
12736 data_corruption(uint8_t *data)
12742 tag_corruption(uint8_t *data, unsigned int tag_offset)
12744 data[tag_offset] += 1;
12748 create_auth_session(struct crypto_unittest_params *ut_params,
12750 const struct test_crypto_vector *reference,
12751 enum rte_crypto_auth_operation auth_op)
12753 struct crypto_testsuite_params *ts_params = &testsuite_params;
12754 uint8_t auth_key[reference->auth_key.len + 1];
12756 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12758 /* Setup Authentication Parameters */
12759 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12760 ut_params->auth_xform.auth.op = auth_op;
12761 ut_params->auth_xform.next = NULL;
12762 ut_params->auth_xform.auth.algo = reference->auth_algo;
12763 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12764 ut_params->auth_xform.auth.key.data = auth_key;
12765 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12767 /* Create Crypto session*/
12768 ut_params->sess = rte_cryptodev_sym_session_create(
12769 ts_params->session_mpool);
12771 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12772 &ut_params->auth_xform,
12773 ts_params->session_priv_mpool);
12775 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12781 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12783 const struct test_crypto_vector *reference,
12784 enum rte_crypto_auth_operation auth_op,
12785 enum rte_crypto_cipher_operation cipher_op)
12787 struct crypto_testsuite_params *ts_params = &testsuite_params;
12788 uint8_t cipher_key[reference->cipher_key.len + 1];
12789 uint8_t auth_key[reference->auth_key.len + 1];
12791 memcpy(cipher_key, reference->cipher_key.data,
12792 reference->cipher_key.len);
12793 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12795 /* Setup Authentication Parameters */
12796 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12797 ut_params->auth_xform.auth.op = auth_op;
12798 ut_params->auth_xform.auth.algo = reference->auth_algo;
12799 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12800 ut_params->auth_xform.auth.key.data = auth_key;
12801 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12803 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12804 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12805 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12807 ut_params->auth_xform.next = &ut_params->cipher_xform;
12809 /* Setup Cipher Parameters */
12810 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12811 ut_params->cipher_xform.next = NULL;
12812 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12813 ut_params->cipher_xform.cipher.op = cipher_op;
12814 ut_params->cipher_xform.cipher.key.data = cipher_key;
12815 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12816 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12817 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12820 /* Create Crypto session*/
12821 ut_params->sess = rte_cryptodev_sym_session_create(
12822 ts_params->session_mpool);
12824 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12825 &ut_params->auth_xform,
12826 ts_params->session_priv_mpool);
12828 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12834 create_auth_operation(struct crypto_testsuite_params *ts_params,
12835 struct crypto_unittest_params *ut_params,
12836 const struct test_crypto_vector *reference,
12837 unsigned int auth_generate)
12839 /* Generate Crypto op data structure */
12840 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12841 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12842 TEST_ASSERT_NOT_NULL(ut_params->op,
12843 "Failed to allocate pktmbuf offload");
12845 /* Set crypto operation data parameters */
12846 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12848 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12850 /* set crypto operation source mbuf */
12851 sym_op->m_src = ut_params->ibuf;
12854 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12855 ut_params->ibuf, reference->digest.len);
12857 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12858 "no room to append auth tag");
12860 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12861 ut_params->ibuf, reference->plaintext.len);
12864 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12866 memcpy(sym_op->auth.digest.data,
12867 reference->digest.data,
12868 reference->digest.len);
12870 debug_hexdump(stdout, "digest:",
12871 sym_op->auth.digest.data,
12872 reference->digest.len);
12874 sym_op->auth.data.length = reference->plaintext.len;
12875 sym_op->auth.data.offset = 0;
12881 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12882 struct crypto_unittest_params *ut_params,
12883 const struct test_crypto_vector *reference,
12884 unsigned int auth_generate)
12886 /* Generate Crypto op data structure */
12887 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12888 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12889 TEST_ASSERT_NOT_NULL(ut_params->op,
12890 "Failed to allocate pktmbuf offload");
12892 /* Set crypto operation data parameters */
12893 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12895 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12897 /* set crypto operation source mbuf */
12898 sym_op->m_src = ut_params->ibuf;
12901 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12902 ut_params->ibuf, reference->digest.len);
12904 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12905 "no room to append auth tag");
12907 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12908 ut_params->ibuf, reference->ciphertext.len);
12911 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12913 memcpy(sym_op->auth.digest.data,
12914 reference->digest.data,
12915 reference->digest.len);
12917 debug_hexdump(stdout, "digest:",
12918 sym_op->auth.digest.data,
12919 reference->digest.len);
12921 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12922 reference->iv.data, reference->iv.len);
12924 sym_op->cipher.data.length = 0;
12925 sym_op->cipher.data.offset = 0;
12927 sym_op->auth.data.length = reference->plaintext.len;
12928 sym_op->auth.data.offset = 0;
12934 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12935 struct crypto_unittest_params *ut_params,
12936 const struct test_crypto_vector *reference,
12937 unsigned int auth_generate)
12939 /* Generate Crypto op data structure */
12940 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12941 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12942 TEST_ASSERT_NOT_NULL(ut_params->op,
12943 "Failed to allocate pktmbuf offload");
12945 /* Set crypto operation data parameters */
12946 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12948 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12950 /* set crypto operation source mbuf */
12951 sym_op->m_src = ut_params->ibuf;
12954 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12955 ut_params->ibuf, reference->digest.len);
12957 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12958 "no room to append auth tag");
12960 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12961 ut_params->ibuf, reference->ciphertext.len);
12964 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12966 memcpy(sym_op->auth.digest.data,
12967 reference->digest.data,
12968 reference->digest.len);
12970 debug_hexdump(stdout, "digest:",
12971 sym_op->auth.digest.data,
12972 reference->digest.len);
12974 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12975 reference->iv.data, reference->iv.len);
12977 sym_op->cipher.data.length = reference->cipher_len;
12978 sym_op->cipher.data.offset = reference->cipher_offset;
12980 sym_op->auth.data.length = reference->plaintext.len;
12981 sym_op->auth.data.offset = reference->auth_offset;
12987 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12988 struct crypto_unittest_params *ut_params,
12989 const struct test_crypto_vector *reference)
12991 return create_auth_operation(ts_params, ut_params, reference, 0);
12995 create_auth_verify_GMAC_operation(
12996 struct crypto_testsuite_params *ts_params,
12997 struct crypto_unittest_params *ut_params,
12998 const struct test_crypto_vector *reference)
13000 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
13004 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13005 struct crypto_unittest_params *ut_params,
13006 const struct test_crypto_vector *reference)
13008 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
13012 test_authentication_verify_fail_when_data_corruption(
13013 struct crypto_testsuite_params *ts_params,
13014 struct crypto_unittest_params *ut_params,
13015 const struct test_crypto_vector *reference,
13016 unsigned int data_corrupted)
13020 uint8_t *plaintext;
13021 struct rte_cryptodev_info dev_info;
13023 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13024 uint64_t feat_flags = dev_info.feature_flags;
13026 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13027 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13028 printf("Device doesn't support RAW data-path APIs.\n");
13029 return TEST_SKIPPED;
13032 /* Verify the capabilities */
13033 struct rte_cryptodev_sym_capability_idx cap_idx;
13034 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13035 cap_idx.algo.auth = reference->auth_algo;
13036 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13038 return TEST_SKIPPED;
13041 /* Create session */
13042 retval = create_auth_session(ut_params,
13043 ts_params->valid_devs[0],
13045 RTE_CRYPTO_AUTH_OP_VERIFY);
13049 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13050 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13051 "Failed to allocate input buffer in mempool");
13053 /* clear mbuf payload */
13054 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13055 rte_pktmbuf_tailroom(ut_params->ibuf));
13057 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13058 reference->plaintext.len);
13059 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13060 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13062 debug_hexdump(stdout, "plaintext:", plaintext,
13063 reference->plaintext.len);
13065 /* Create operation */
13066 retval = create_auth_verify_operation(ts_params, ut_params, reference);
13071 if (data_corrupted)
13072 data_corruption(plaintext);
13074 tag_corruption(plaintext, reference->plaintext.len);
13076 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13077 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13079 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13080 RTE_CRYPTO_OP_STATUS_SUCCESS,
13081 "authentication not failed");
13082 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13083 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13084 ut_params->op, 0, 1, 0, 0);
13086 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13089 if (ut_params->op == NULL)
13091 else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
13098 test_authentication_verify_GMAC_fail_when_corruption(
13099 struct crypto_testsuite_params *ts_params,
13100 struct crypto_unittest_params *ut_params,
13101 const struct test_crypto_vector *reference,
13102 unsigned int data_corrupted)
13105 uint8_t *plaintext;
13106 struct rte_cryptodev_info dev_info;
13108 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13109 uint64_t feat_flags = dev_info.feature_flags;
13111 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13112 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13113 printf("Device doesn't support RAW data-path APIs.\n");
13114 return TEST_SKIPPED;
13117 /* Verify the capabilities */
13118 struct rte_cryptodev_sym_capability_idx cap_idx;
13119 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13120 cap_idx.algo.auth = reference->auth_algo;
13121 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13123 return TEST_SKIPPED;
13125 /* Create session */
13126 retval = create_auth_cipher_session(ut_params,
13127 ts_params->valid_devs[0],
13129 RTE_CRYPTO_AUTH_OP_VERIFY,
13130 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13134 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13135 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13136 "Failed to allocate input buffer in mempool");
13138 /* clear mbuf payload */
13139 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13140 rte_pktmbuf_tailroom(ut_params->ibuf));
13142 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13143 reference->plaintext.len);
13144 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13145 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13147 debug_hexdump(stdout, "plaintext:", plaintext,
13148 reference->plaintext.len);
13150 /* Create operation */
13151 retval = create_auth_verify_GMAC_operation(ts_params,
13158 if (data_corrupted)
13159 data_corruption(plaintext);
13161 tag_corruption(plaintext, reference->aad.len);
13163 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13164 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13166 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13167 RTE_CRYPTO_OP_STATUS_SUCCESS,
13168 "authentication not failed");
13169 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13170 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13171 ut_params->op, 0, 1, 0, 0);
13173 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13175 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13182 test_authenticated_decryption_fail_when_corruption(
13183 struct crypto_testsuite_params *ts_params,
13184 struct crypto_unittest_params *ut_params,
13185 const struct test_crypto_vector *reference,
13186 unsigned int data_corrupted)
13190 uint8_t *ciphertext;
13191 struct rte_cryptodev_info dev_info;
13193 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13194 uint64_t feat_flags = dev_info.feature_flags;
13196 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13197 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13198 printf("Device doesn't support RAW data-path APIs.\n");
13199 return TEST_SKIPPED;
13202 /* Verify the capabilities */
13203 struct rte_cryptodev_sym_capability_idx cap_idx;
13204 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13205 cap_idx.algo.auth = reference->auth_algo;
13206 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13208 return TEST_SKIPPED;
13209 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13210 cap_idx.algo.cipher = reference->crypto_algo;
13211 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13213 return TEST_SKIPPED;
13215 /* Create session */
13216 retval = create_auth_cipher_session(ut_params,
13217 ts_params->valid_devs[0],
13219 RTE_CRYPTO_AUTH_OP_VERIFY,
13220 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13224 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13225 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13226 "Failed to allocate input buffer in mempool");
13228 /* clear mbuf payload */
13229 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13230 rte_pktmbuf_tailroom(ut_params->ibuf));
13232 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13233 reference->ciphertext.len);
13234 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13235 memcpy(ciphertext, reference->ciphertext.data,
13236 reference->ciphertext.len);
13238 /* Create operation */
13239 retval = create_cipher_auth_verify_operation(ts_params,
13246 if (data_corrupted)
13247 data_corruption(ciphertext);
13249 tag_corruption(ciphertext, reference->ciphertext.len);
13251 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13252 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13254 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13255 RTE_CRYPTO_OP_STATUS_SUCCESS,
13256 "authentication not failed");
13257 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13258 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13259 ut_params->op, 1, 1, 0, 0);
13261 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13263 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13270 test_authenticated_encrypt_with_esn(
13271 struct crypto_testsuite_params *ts_params,
13272 struct crypto_unittest_params *ut_params,
13273 const struct test_crypto_vector *reference)
13277 uint8_t *authciphertext, *plaintext, *auth_tag;
13278 uint16_t plaintext_pad_len;
13279 uint8_t cipher_key[reference->cipher_key.len + 1];
13280 uint8_t auth_key[reference->auth_key.len + 1];
13281 struct rte_cryptodev_info dev_info;
13283 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13284 uint64_t feat_flags = dev_info.feature_flags;
13286 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13287 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13288 printf("Device doesn't support RAW data-path APIs.\n");
13289 return TEST_SKIPPED;
13292 /* Verify the capabilities */
13293 struct rte_cryptodev_sym_capability_idx cap_idx;
13294 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13295 cap_idx.algo.auth = reference->auth_algo;
13296 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13298 return TEST_SKIPPED;
13299 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13300 cap_idx.algo.cipher = reference->crypto_algo;
13301 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13303 return TEST_SKIPPED;
13305 /* Create session */
13306 memcpy(cipher_key, reference->cipher_key.data,
13307 reference->cipher_key.len);
13308 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13310 /* Setup Cipher Parameters */
13311 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13312 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13313 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13314 ut_params->cipher_xform.cipher.key.data = cipher_key;
13315 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13316 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13317 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13319 ut_params->cipher_xform.next = &ut_params->auth_xform;
13321 /* Setup Authentication Parameters */
13322 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13323 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13324 ut_params->auth_xform.auth.algo = reference->auth_algo;
13325 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13326 ut_params->auth_xform.auth.key.data = auth_key;
13327 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13328 ut_params->auth_xform.next = NULL;
13330 /* Create Crypto session*/
13331 ut_params->sess = rte_cryptodev_sym_session_create(
13332 ts_params->session_mpool);
13334 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13336 &ut_params->cipher_xform,
13337 ts_params->session_priv_mpool);
13339 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13341 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13342 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13343 "Failed to allocate input buffer in mempool");
13345 /* clear mbuf payload */
13346 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13347 rte_pktmbuf_tailroom(ut_params->ibuf));
13349 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13350 reference->plaintext.len);
13351 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13352 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13354 /* Create operation */
13355 retval = create_cipher_auth_operation(ts_params,
13362 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13363 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13365 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13366 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13367 ut_params->op, 1, 1, 0, 0);
13369 ut_params->op = process_crypto_request(
13370 ts_params->valid_devs[0], ut_params->op);
13372 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13374 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13375 "crypto op processing failed");
13377 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13379 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13380 ut_params->op->sym->auth.data.offset);
13381 auth_tag = authciphertext + plaintext_pad_len;
13382 debug_hexdump(stdout, "ciphertext:", authciphertext,
13383 reference->ciphertext.len);
13384 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13386 /* Validate obuf */
13387 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13389 reference->ciphertext.data,
13390 reference->ciphertext.len,
13391 "Ciphertext data not as expected");
13393 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13395 reference->digest.data,
13396 reference->digest.len,
13397 "Generated digest not as expected");
13399 return TEST_SUCCESS;
13404 test_authenticated_decrypt_with_esn(
13405 struct crypto_testsuite_params *ts_params,
13406 struct crypto_unittest_params *ut_params,
13407 const struct test_crypto_vector *reference)
13411 uint8_t *ciphertext;
13412 uint8_t cipher_key[reference->cipher_key.len + 1];
13413 uint8_t auth_key[reference->auth_key.len + 1];
13414 struct rte_cryptodev_info dev_info;
13416 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13417 uint64_t feat_flags = dev_info.feature_flags;
13419 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13420 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13421 printf("Device doesn't support RAW data-path APIs.\n");
13422 return TEST_SKIPPED;
13425 /* Verify the capabilities */
13426 struct rte_cryptodev_sym_capability_idx cap_idx;
13427 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13428 cap_idx.algo.auth = reference->auth_algo;
13429 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13431 return TEST_SKIPPED;
13432 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13433 cap_idx.algo.cipher = reference->crypto_algo;
13434 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13436 return TEST_SKIPPED;
13438 /* Create session */
13439 memcpy(cipher_key, reference->cipher_key.data,
13440 reference->cipher_key.len);
13441 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13443 /* Setup Authentication Parameters */
13444 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13445 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13446 ut_params->auth_xform.auth.algo = reference->auth_algo;
13447 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13448 ut_params->auth_xform.auth.key.data = auth_key;
13449 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13450 ut_params->auth_xform.next = &ut_params->cipher_xform;
13452 /* Setup Cipher Parameters */
13453 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13454 ut_params->cipher_xform.next = NULL;
13455 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13456 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13457 ut_params->cipher_xform.cipher.key.data = cipher_key;
13458 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13459 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13460 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13462 /* Create Crypto session*/
13463 ut_params->sess = rte_cryptodev_sym_session_create(
13464 ts_params->session_mpool);
13466 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13468 &ut_params->auth_xform,
13469 ts_params->session_priv_mpool);
13471 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13473 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13474 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13475 "Failed to allocate input buffer in mempool");
13477 /* clear mbuf payload */
13478 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13479 rte_pktmbuf_tailroom(ut_params->ibuf));
13481 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13482 reference->ciphertext.len);
13483 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13484 memcpy(ciphertext, reference->ciphertext.data,
13485 reference->ciphertext.len);
13487 /* Create operation */
13488 retval = create_cipher_auth_verify_operation(ts_params,
13495 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13496 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13498 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13499 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13500 ut_params->op, 1, 1, 0, 0);
13502 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13505 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13506 TEST_ASSERT_EQUAL(ut_params->op->status,
13507 RTE_CRYPTO_OP_STATUS_SUCCESS,
13508 "crypto op processing passed");
13510 ut_params->obuf = ut_params->op->sym->m_src;
13511 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13517 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13518 const struct aead_test_data *tdata,
13519 void *digest_mem, uint64_t digest_phys)
13521 struct crypto_testsuite_params *ts_params = &testsuite_params;
13522 struct crypto_unittest_params *ut_params = &unittest_params;
13524 const unsigned int auth_tag_len = tdata->auth_tag.len;
13525 const unsigned int iv_len = tdata->iv.len;
13526 unsigned int aad_len = tdata->aad.len;
13527 unsigned int aad_len_pad = 0;
13529 /* Generate Crypto op data structure */
13530 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13531 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13532 TEST_ASSERT_NOT_NULL(ut_params->op,
13533 "Failed to allocate symmetric crypto operation struct");
13535 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13537 sym_op->aead.digest.data = digest_mem;
13539 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13540 "no room to append digest");
13542 sym_op->aead.digest.phys_addr = digest_phys;
13544 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13545 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13547 debug_hexdump(stdout, "digest:",
13548 sym_op->aead.digest.data,
13552 /* Append aad data */
13553 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13554 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13555 uint8_t *, IV_OFFSET);
13557 /* Copy IV 1 byte after the IV pointer, according to the API */
13558 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13560 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13562 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13563 ut_params->ibuf, aad_len);
13564 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13565 "no room to prepend aad");
13566 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13569 memset(sym_op->aead.aad.data, 0, aad_len);
13570 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
13571 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13573 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13574 debug_hexdump(stdout, "aad:",
13575 sym_op->aead.aad.data, aad_len);
13577 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13578 uint8_t *, IV_OFFSET);
13580 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13582 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13584 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13585 ut_params->ibuf, aad_len_pad);
13586 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13587 "no room to prepend aad");
13588 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13591 memset(sym_op->aead.aad.data, 0, aad_len);
13592 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13594 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13595 debug_hexdump(stdout, "aad:",
13596 sym_op->aead.aad.data, aad_len);
13599 sym_op->aead.data.length = tdata->plaintext.len;
13600 sym_op->aead.data.offset = aad_len_pad;
13605 #define SGL_MAX_NO 16
13608 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13609 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13611 struct crypto_testsuite_params *ts_params = &testsuite_params;
13612 struct crypto_unittest_params *ut_params = &unittest_params;
13613 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13616 int to_trn_tbl[SGL_MAX_NO];
13618 unsigned int trn_data = 0;
13619 uint8_t *plaintext, *ciphertext, *auth_tag;
13620 struct rte_cryptodev_info dev_info;
13622 /* Verify the capabilities */
13623 struct rte_cryptodev_sym_capability_idx cap_idx;
13624 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13625 cap_idx.algo.aead = tdata->algo;
13626 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13628 return TEST_SKIPPED;
13630 /* OOP not supported with CPU crypto */
13631 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13632 return TEST_SKIPPED;
13634 /* Detailed check for the particular SGL support flag */
13635 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13637 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13638 if (sgl_in && (!(dev_info.feature_flags &
13639 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13640 return TEST_SKIPPED;
13642 uint64_t feat_flags = dev_info.feature_flags;
13644 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13645 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13646 printf("Device doesn't support RAW data-path APIs.\n");
13647 return TEST_SKIPPED;
13650 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13651 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13652 tdata->plaintext.len;
13653 /* Raw data path API does not support OOP */
13654 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13655 return TEST_SKIPPED;
13656 if (sgl_in && !sgl_out) {
13657 if (!(dev_info.feature_flags &
13658 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13659 return TEST_SKIPPED;
13660 } else if (!sgl_in && sgl_out) {
13661 if (!(dev_info.feature_flags &
13662 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13663 return TEST_SKIPPED;
13664 } else if (sgl_in && sgl_out) {
13665 if (!(dev_info.feature_flags &
13666 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13667 return TEST_SKIPPED;
13671 if (fragsz > tdata->plaintext.len)
13672 fragsz = tdata->plaintext.len;
13674 uint16_t plaintext_len = fragsz;
13675 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13677 if (fragsz_oop > tdata->plaintext.len)
13678 frag_size_oop = tdata->plaintext.len;
13681 void *digest_mem = NULL;
13683 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13685 if (tdata->plaintext.len % fragsz != 0) {
13686 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13689 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13694 * For out-op-place we need to alloc another mbuf
13697 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13698 rte_pktmbuf_append(ut_params->obuf,
13699 frag_size_oop + prepend_len);
13700 buf_oop = ut_params->obuf;
13703 /* Create AEAD session */
13704 retval = create_aead_session(ts_params->valid_devs[0],
13706 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13707 tdata->key.data, tdata->key.len,
13708 tdata->aad.len, tdata->auth_tag.len,
13713 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13715 /* clear mbuf payload */
13716 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13717 rte_pktmbuf_tailroom(ut_params->ibuf));
13719 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13722 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13724 trn_data += plaintext_len;
13726 buf = ut_params->ibuf;
13729 * Loop until no more fragments
13732 while (trn_data < tdata->plaintext.len) {
13734 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13735 (tdata->plaintext.len - trn_data) : fragsz;
13737 to_trn_tbl[ecx++] = to_trn;
13739 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13742 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13743 rte_pktmbuf_tailroom(buf));
13746 if (oop && !fragsz_oop) {
13747 buf_last_oop = buf_oop->next =
13748 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13749 buf_oop = buf_oop->next;
13750 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13751 0, rte_pktmbuf_tailroom(buf_oop));
13752 rte_pktmbuf_append(buf_oop, to_trn);
13755 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13758 memcpy(plaintext, tdata->plaintext.data + trn_data,
13760 trn_data += to_trn;
13761 if (trn_data == tdata->plaintext.len) {
13764 digest_mem = rte_pktmbuf_append(buf_oop,
13765 tdata->auth_tag.len);
13767 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13768 tdata->auth_tag.len);
13772 uint64_t digest_phys = 0;
13774 ut_params->ibuf->nb_segs = segs;
13777 if (fragsz_oop && oop) {
13781 if (frag_size_oop == tdata->plaintext.len) {
13782 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13783 tdata->auth_tag.len);
13785 digest_phys = rte_pktmbuf_iova_offset(
13787 tdata->plaintext.len + prepend_len);
13790 trn_data = frag_size_oop;
13791 while (trn_data < tdata->plaintext.len) {
13794 (tdata->plaintext.len - trn_data <
13796 (tdata->plaintext.len - trn_data) :
13799 to_trn_tbl[ecx++] = to_trn;
13801 buf_last_oop = buf_oop->next =
13802 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13803 buf_oop = buf_oop->next;
13804 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13805 0, rte_pktmbuf_tailroom(buf_oop));
13806 rte_pktmbuf_append(buf_oop, to_trn);
13808 trn_data += to_trn;
13810 if (trn_data == tdata->plaintext.len) {
13811 digest_mem = rte_pktmbuf_append(buf_oop,
13812 tdata->auth_tag.len);
13816 ut_params->obuf->nb_segs = segs;
13820 * Place digest at the end of the last buffer
13823 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13824 if (oop && buf_last_oop)
13825 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13827 if (!digest_mem && !oop) {
13828 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13829 + tdata->auth_tag.len);
13830 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13831 tdata->plaintext.len);
13834 /* Create AEAD operation */
13835 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13836 tdata, digest_mem, digest_phys);
13841 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13843 ut_params->op->sym->m_src = ut_params->ibuf;
13845 ut_params->op->sym->m_dst = ut_params->obuf;
13847 /* Process crypto operation */
13848 if (oop == IN_PLACE &&
13849 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13850 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13851 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13852 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13853 ut_params->op, 0, 0, 0, 0);
13855 TEST_ASSERT_NOT_NULL(
13856 process_crypto_request(ts_params->valid_devs[0],
13857 ut_params->op), "failed to process sym crypto op");
13859 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13860 "crypto op processing failed");
13863 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13864 uint8_t *, prepend_len);
13866 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13867 uint8_t *, prepend_len);
13871 fragsz = fragsz_oop;
13873 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13875 tdata->ciphertext.data,
13877 "Ciphertext data not as expected");
13879 buf = ut_params->op->sym->m_src->next;
13881 buf = ut_params->op->sym->m_dst->next;
13883 unsigned int off = fragsz;
13887 ciphertext = rte_pktmbuf_mtod(buf,
13890 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13892 tdata->ciphertext.data + off,
13894 "Ciphertext data not as expected");
13896 off += to_trn_tbl[ecx++];
13900 auth_tag = digest_mem;
13901 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13903 tdata->auth_tag.data,
13904 tdata->auth_tag.len,
13905 "Generated auth tag not as expected");
13911 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13913 return test_authenticated_encryption_SGL(
13914 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13918 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13920 return test_authenticated_encryption_SGL(
13921 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13925 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13927 return test_authenticated_encryption_SGL(
13928 &gcm_test_case_8, OUT_OF_PLACE, 400,
13929 gcm_test_case_8.plaintext.len);
13933 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13935 /* This test is not for OPENSSL PMD */
13936 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13937 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13938 return TEST_SKIPPED;
13940 return test_authenticated_encryption_SGL(
13941 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13945 test_authentication_verify_fail_when_data_corrupted(
13946 struct crypto_testsuite_params *ts_params,
13947 struct crypto_unittest_params *ut_params,
13948 const struct test_crypto_vector *reference)
13950 return test_authentication_verify_fail_when_data_corruption(
13951 ts_params, ut_params, reference, 1);
13955 test_authentication_verify_fail_when_tag_corrupted(
13956 struct crypto_testsuite_params *ts_params,
13957 struct crypto_unittest_params *ut_params,
13958 const struct test_crypto_vector *reference)
13960 return test_authentication_verify_fail_when_data_corruption(
13961 ts_params, ut_params, reference, 0);
13965 test_authentication_verify_GMAC_fail_when_data_corrupted(
13966 struct crypto_testsuite_params *ts_params,
13967 struct crypto_unittest_params *ut_params,
13968 const struct test_crypto_vector *reference)
13970 return test_authentication_verify_GMAC_fail_when_corruption(
13971 ts_params, ut_params, reference, 1);
13975 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13976 struct crypto_testsuite_params *ts_params,
13977 struct crypto_unittest_params *ut_params,
13978 const struct test_crypto_vector *reference)
13980 return test_authentication_verify_GMAC_fail_when_corruption(
13981 ts_params, ut_params, reference, 0);
13985 test_authenticated_decryption_fail_when_data_corrupted(
13986 struct crypto_testsuite_params *ts_params,
13987 struct crypto_unittest_params *ut_params,
13988 const struct test_crypto_vector *reference)
13990 return test_authenticated_decryption_fail_when_corruption(
13991 ts_params, ut_params, reference, 1);
13995 test_authenticated_decryption_fail_when_tag_corrupted(
13996 struct crypto_testsuite_params *ts_params,
13997 struct crypto_unittest_params *ut_params,
13998 const struct test_crypto_vector *reference)
14000 return test_authenticated_decryption_fail_when_corruption(
14001 ts_params, ut_params, reference, 0);
14005 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
14007 return test_authentication_verify_fail_when_data_corrupted(
14008 &testsuite_params, &unittest_params,
14009 &hmac_sha1_test_crypto_vector);
14013 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
14015 return test_authentication_verify_fail_when_tag_corrupted(
14016 &testsuite_params, &unittest_params,
14017 &hmac_sha1_test_crypto_vector);
14021 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
14023 return test_authentication_verify_GMAC_fail_when_data_corrupted(
14024 &testsuite_params, &unittest_params,
14025 &aes128_gmac_test_vector);
14029 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
14031 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
14032 &testsuite_params, &unittest_params,
14033 &aes128_gmac_test_vector);
14037 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
14039 return test_authenticated_decryption_fail_when_data_corrupted(
14042 &aes128cbc_hmac_sha1_test_vector);
14046 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
14048 return test_authenticated_decryption_fail_when_tag_corrupted(
14051 &aes128cbc_hmac_sha1_test_vector);
14055 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14057 return test_authenticated_encrypt_with_esn(
14060 &aes128cbc_hmac_sha1_aad_test_vector);
14064 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14066 return test_authenticated_decrypt_with_esn(
14069 &aes128cbc_hmac_sha1_aad_test_vector);
14073 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
14075 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
14079 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
14081 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
14084 #ifdef RTE_CRYPTO_SCHEDULER
14086 /* global AESNI worker IDs for the scheduler test */
14087 uint8_t aesni_ids[2];
14090 scheduler_testsuite_setup(void)
14093 int32_t nb_devs, ret;
14094 char vdev_args[VDEV_ARGS_SIZE] = {""};
14095 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14096 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
14097 uint16_t worker_core_count = 0;
14098 uint16_t socket_id = 0;
14100 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14101 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14103 /* Identify the Worker Cores
14104 * Use 2 worker cores for the device args
14106 RTE_LCORE_FOREACH_WORKER(i) {
14107 if (worker_core_count > 1)
14109 snprintf(vdev_args, sizeof(vdev_args),
14110 "%s%d", temp_str, i);
14111 strcpy(temp_str, vdev_args);
14112 strlcat(temp_str, ";", sizeof(temp_str));
14113 worker_core_count++;
14114 socket_id = rte_lcore_to_socket_id(i);
14116 if (worker_core_count != 2) {
14117 RTE_LOG(ERR, USER1,
14118 "Cryptodev scheduler test require at least "
14119 "two worker cores to run. "
14120 "Please use the correct coremask.\n");
14121 return TEST_FAILED;
14123 strcpy(temp_str, vdev_args);
14124 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14125 temp_str, socket_id);
14126 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14127 nb_devs = rte_cryptodev_device_count_by_driver(
14128 rte_cryptodev_driver_id_get(
14129 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14131 ret = rte_vdev_init(
14132 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14134 TEST_ASSERT(ret == 0,
14135 "Failed to create instance %u of pmd : %s",
14136 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14139 return testsuite_setup();
14143 test_scheduler_attach_worker_op(void)
14145 struct crypto_testsuite_params *ts_params = &testsuite_params;
14146 uint8_t sched_id = ts_params->valid_devs[0];
14147 uint32_t i, nb_devs_attached = 0;
14149 char vdev_name[32];
14150 unsigned int count = rte_cryptodev_count();
14152 /* create 2 AESNI_MB vdevs on top of existing devices */
14153 for (i = count; i < count + 2; i++) {
14154 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14155 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14157 ret = rte_vdev_init(vdev_name, NULL);
14159 TEST_ASSERT(ret == 0,
14160 "Failed to create instance %u of"
14162 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14165 RTE_LOG(ERR, USER1,
14166 "Failed to create 2 AESNI MB PMDs.\n");
14167 return TEST_SKIPPED;
14171 /* attach 2 AESNI_MB cdevs */
14172 for (i = count; i < count + 2; i++) {
14173 struct rte_cryptodev_info info;
14174 unsigned int session_size;
14176 rte_cryptodev_info_get(i, &info);
14177 if (info.driver_id != rte_cryptodev_driver_id_get(
14178 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14181 session_size = rte_cryptodev_sym_get_private_session_size(i);
14183 * Create the session mempool again, since now there are new devices
14184 * to use the mempool.
14186 if (ts_params->session_mpool) {
14187 rte_mempool_free(ts_params->session_mpool);
14188 ts_params->session_mpool = NULL;
14190 if (ts_params->session_priv_mpool) {
14191 rte_mempool_free(ts_params->session_priv_mpool);
14192 ts_params->session_priv_mpool = NULL;
14195 if (info.sym.max_nb_sessions != 0 &&
14196 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14197 RTE_LOG(ERR, USER1,
14198 "Device does not support "
14199 "at least %u sessions\n",
14201 return TEST_FAILED;
14204 * Create mempool with maximum number of sessions,
14205 * to include the session headers
14207 if (ts_params->session_mpool == NULL) {
14208 ts_params->session_mpool =
14209 rte_cryptodev_sym_session_pool_create(
14211 MAX_NB_SESSIONS, 0, 0, 0,
14213 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14214 "session mempool allocation failed");
14218 * Create mempool with maximum number of sessions,
14219 * to include device specific session private data
14221 if (ts_params->session_priv_mpool == NULL) {
14222 ts_params->session_priv_mpool = rte_mempool_create(
14223 "test_sess_mp_priv",
14226 0, 0, NULL, NULL, NULL,
14227 NULL, SOCKET_ID_ANY,
14230 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14231 "session mempool allocation failed");
14234 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14235 ts_params->qp_conf.mp_session_private =
14236 ts_params->session_priv_mpool;
14238 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14241 TEST_ASSERT(ret == 0,
14242 "Failed to attach device %u of pmd : %s", i,
14243 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14245 aesni_ids[nb_devs_attached] = (uint8_t)i;
14247 nb_devs_attached++;
14254 test_scheduler_detach_worker_op(void)
14256 struct crypto_testsuite_params *ts_params = &testsuite_params;
14257 uint8_t sched_id = ts_params->valid_devs[0];
14261 for (i = 0; i < 2; i++) {
14262 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14264 TEST_ASSERT(ret == 0,
14265 "Failed to detach device %u", aesni_ids[i]);
14272 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14274 struct crypto_testsuite_params *ts_params = &testsuite_params;
14275 uint8_t sched_id = ts_params->valid_devs[0];
14277 return rte_cryptodev_scheduler_mode_set(sched_id,
14282 test_scheduler_mode_roundrobin_op(void)
14284 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14285 0, "Failed to set roundrobin mode");
14291 test_scheduler_mode_multicore_op(void)
14293 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14294 0, "Failed to set multicore mode");
14300 test_scheduler_mode_failover_op(void)
14302 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
14303 0, "Failed to set failover mode");
14309 test_scheduler_mode_pkt_size_distr_op(void)
14311 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
14312 0, "Failed to set pktsize mode");
14318 scheduler_multicore_testsuite_setup(void)
14320 if (test_scheduler_attach_worker_op() < 0)
14321 return TEST_SKIPPED;
14322 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
14323 return TEST_SKIPPED;
14328 scheduler_roundrobin_testsuite_setup(void)
14330 if (test_scheduler_attach_worker_op() < 0)
14331 return TEST_SKIPPED;
14332 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
14333 return TEST_SKIPPED;
14338 scheduler_failover_testsuite_setup(void)
14340 if (test_scheduler_attach_worker_op() < 0)
14341 return TEST_SKIPPED;
14342 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
14343 return TEST_SKIPPED;
14348 scheduler_pkt_size_distr_testsuite_setup(void)
14350 if (test_scheduler_attach_worker_op() < 0)
14351 return TEST_SKIPPED;
14352 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14353 return TEST_SKIPPED;
14358 scheduler_mode_testsuite_teardown(void)
14360 test_scheduler_detach_worker_op();
14363 #endif /* RTE_CRYPTO_SCHEDULER */
14365 static struct unit_test_suite end_testsuite = {
14366 .suite_name = NULL,
14369 .unit_test_suites = NULL
14372 #ifdef RTE_LIB_SECURITY
14373 static struct unit_test_suite ipsec_proto_testsuite = {
14374 .suite_name = "IPsec Proto Unit Test Suite",
14375 .setup = ipsec_proto_testsuite_setup,
14376 .unit_test_cases = {
14377 TEST_CASE_NAMED_WITH_DATA(
14378 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14379 ut_setup_security, ut_teardown,
14380 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
14381 TEST_CASE_NAMED_WITH_DATA(
14382 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14383 ut_setup_security, ut_teardown,
14384 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
14385 TEST_CASE_NAMED_WITH_DATA(
14386 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14387 ut_setup_security, ut_teardown,
14388 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
14389 TEST_CASE_NAMED_WITH_DATA(
14390 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14391 ut_setup_security, ut_teardown,
14392 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14393 TEST_CASE_NAMED_WITH_DATA(
14394 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14395 ut_setup_security, ut_teardown,
14396 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14397 TEST_CASE_NAMED_WITH_DATA(
14398 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14399 ut_setup_security, ut_teardown,
14400 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14401 TEST_CASE_NAMED_ST(
14402 "Combined test alg list",
14403 ut_setup_security, ut_teardown,
14404 test_ipsec_proto_display_list),
14405 TEST_CASE_NAMED_ST(
14407 ut_setup_security, ut_teardown,
14408 test_ipsec_proto_iv_gen),
14409 TEST_CASE_NAMED_ST(
14410 "UDP encapsulation",
14411 ut_setup_security, ut_teardown,
14412 test_ipsec_proto_udp_encap),
14413 TEST_CASE_NAMED_ST(
14414 "UDP encapsulation ports verification test",
14415 ut_setup_security, ut_teardown,
14416 test_ipsec_proto_udp_ports_verify),
14417 TEST_CASE_NAMED_ST(
14418 "SA expiry packets soft",
14419 ut_setup_security, ut_teardown,
14420 test_ipsec_proto_sa_exp_pkts_soft),
14421 TEST_CASE_NAMED_ST(
14422 "SA expiry packets hard",
14423 ut_setup_security, ut_teardown,
14424 test_ipsec_proto_sa_exp_pkts_hard),
14425 TEST_CASE_NAMED_ST(
14426 "Negative test: ICV corruption",
14427 ut_setup_security, ut_teardown,
14428 test_ipsec_proto_err_icv_corrupt),
14429 TEST_CASE_NAMED_ST(
14430 "Tunnel dst addr verification",
14431 ut_setup_security, ut_teardown,
14432 test_ipsec_proto_tunnel_dst_addr_verify),
14433 TEST_CASE_NAMED_ST(
14434 "Tunnel src and dst addr verification",
14435 ut_setup_security, ut_teardown,
14436 test_ipsec_proto_tunnel_src_dst_addr_verify),
14437 TEST_CASE_NAMED_ST(
14438 "Inner IP checksum",
14439 ut_setup_security, ut_teardown,
14440 test_ipsec_proto_inner_ip_csum),
14441 TEST_CASE_NAMED_ST(
14442 "Inner L4 checksum",
14443 ut_setup_security, ut_teardown,
14444 test_ipsec_proto_inner_l4_csum),
14445 TEST_CASES_END() /**< NULL terminate unit test array */
14449 static struct unit_test_suite pdcp_proto_testsuite = {
14450 .suite_name = "PDCP Proto Unit Test Suite",
14451 .setup = pdcp_proto_testsuite_setup,
14452 .unit_test_cases = {
14453 TEST_CASE_ST(ut_setup_security, ut_teardown,
14454 test_PDCP_PROTO_all),
14455 TEST_CASES_END() /**< NULL terminate unit test array */
14459 static struct unit_test_suite docsis_proto_testsuite = {
14460 .suite_name = "Docsis Proto Unit Test Suite",
14461 .setup = docsis_proto_testsuite_setup,
14462 .unit_test_cases = {
14463 TEST_CASE_ST(ut_setup_security, ut_teardown,
14464 test_DOCSIS_PROTO_all),
14465 TEST_CASES_END() /**< NULL terminate unit test array */
14470 static struct unit_test_suite cryptodev_gen_testsuite = {
14471 .suite_name = "Crypto General Unit Test Suite",
14472 .setup = crypto_gen_testsuite_setup,
14473 .unit_test_cases = {
14474 TEST_CASE_ST(ut_setup, ut_teardown,
14475 test_device_configure_invalid_dev_id),
14476 TEST_CASE_ST(ut_setup, ut_teardown,
14477 test_queue_pair_descriptor_setup),
14478 TEST_CASE_ST(ut_setup, ut_teardown,
14479 test_device_configure_invalid_queue_pair_ids),
14480 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
14481 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
14482 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
14483 TEST_CASES_END() /**< NULL terminate unit test array */
14487 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
14488 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
14489 .setup = negative_hmac_sha1_testsuite_setup,
14490 .unit_test_cases = {
14491 /** Negative tests */
14492 TEST_CASE_ST(ut_setup, ut_teardown,
14493 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14494 TEST_CASE_ST(ut_setup, ut_teardown,
14495 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14496 TEST_CASE_ST(ut_setup, ut_teardown,
14497 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14498 TEST_CASE_ST(ut_setup, ut_teardown,
14499 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14501 TEST_CASES_END() /**< NULL terminate unit test array */
14505 static struct unit_test_suite cryptodev_multi_session_testsuite = {
14506 .suite_name = "Multi Session Unit Test Suite",
14507 .setup = multi_session_testsuite_setup,
14508 .unit_test_cases = {
14509 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14510 TEST_CASE_ST(ut_setup, ut_teardown,
14511 test_multi_session_random_usage),
14513 TEST_CASES_END() /**< NULL terminate unit test array */
14517 static struct unit_test_suite cryptodev_null_testsuite = {
14518 .suite_name = "NULL Test Suite",
14519 .setup = null_testsuite_setup,
14520 .unit_test_cases = {
14521 TEST_CASE_ST(ut_setup, ut_teardown,
14522 test_null_invalid_operation),
14523 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
14528 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
14529 .suite_name = "AES CCM Authenticated Test Suite",
14530 .setup = aes_ccm_auth_testsuite_setup,
14531 .unit_test_cases = {
14532 /** AES CCM Authenticated Encryption 128 bits key*/
14533 TEST_CASE_ST(ut_setup, ut_teardown,
14534 test_AES_CCM_authenticated_encryption_test_case_128_1),
14535 TEST_CASE_ST(ut_setup, ut_teardown,
14536 test_AES_CCM_authenticated_encryption_test_case_128_2),
14537 TEST_CASE_ST(ut_setup, ut_teardown,
14538 test_AES_CCM_authenticated_encryption_test_case_128_3),
14540 /** AES CCM Authenticated Decryption 128 bits key*/
14541 TEST_CASE_ST(ut_setup, ut_teardown,
14542 test_AES_CCM_authenticated_decryption_test_case_128_1),
14543 TEST_CASE_ST(ut_setup, ut_teardown,
14544 test_AES_CCM_authenticated_decryption_test_case_128_2),
14545 TEST_CASE_ST(ut_setup, ut_teardown,
14546 test_AES_CCM_authenticated_decryption_test_case_128_3),
14548 /** AES CCM Authenticated Encryption 192 bits key */
14549 TEST_CASE_ST(ut_setup, ut_teardown,
14550 test_AES_CCM_authenticated_encryption_test_case_192_1),
14551 TEST_CASE_ST(ut_setup, ut_teardown,
14552 test_AES_CCM_authenticated_encryption_test_case_192_2),
14553 TEST_CASE_ST(ut_setup, ut_teardown,
14554 test_AES_CCM_authenticated_encryption_test_case_192_3),
14556 /** AES CCM Authenticated Decryption 192 bits key*/
14557 TEST_CASE_ST(ut_setup, ut_teardown,
14558 test_AES_CCM_authenticated_decryption_test_case_192_1),
14559 TEST_CASE_ST(ut_setup, ut_teardown,
14560 test_AES_CCM_authenticated_decryption_test_case_192_2),
14561 TEST_CASE_ST(ut_setup, ut_teardown,
14562 test_AES_CCM_authenticated_decryption_test_case_192_3),
14564 /** AES CCM Authenticated Encryption 256 bits key */
14565 TEST_CASE_ST(ut_setup, ut_teardown,
14566 test_AES_CCM_authenticated_encryption_test_case_256_1),
14567 TEST_CASE_ST(ut_setup, ut_teardown,
14568 test_AES_CCM_authenticated_encryption_test_case_256_2),
14569 TEST_CASE_ST(ut_setup, ut_teardown,
14570 test_AES_CCM_authenticated_encryption_test_case_256_3),
14572 /** AES CCM Authenticated Decryption 256 bits key*/
14573 TEST_CASE_ST(ut_setup, ut_teardown,
14574 test_AES_CCM_authenticated_decryption_test_case_256_1),
14575 TEST_CASE_ST(ut_setup, ut_teardown,
14576 test_AES_CCM_authenticated_decryption_test_case_256_2),
14577 TEST_CASE_ST(ut_setup, ut_teardown,
14578 test_AES_CCM_authenticated_decryption_test_case_256_3),
14583 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
14584 .suite_name = "AES GCM Authenticated Test Suite",
14585 .setup = aes_gcm_auth_testsuite_setup,
14586 .unit_test_cases = {
14587 /** AES GCM Authenticated Encryption */
14588 TEST_CASE_ST(ut_setup, ut_teardown,
14589 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
14590 TEST_CASE_ST(ut_setup, ut_teardown,
14591 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
14592 TEST_CASE_ST(ut_setup, ut_teardown,
14593 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
14594 TEST_CASE_ST(ut_setup, ut_teardown,
14595 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
14596 TEST_CASE_ST(ut_setup, ut_teardown,
14597 test_AES_GCM_authenticated_encryption_test_case_1),
14598 TEST_CASE_ST(ut_setup, ut_teardown,
14599 test_AES_GCM_authenticated_encryption_test_case_2),
14600 TEST_CASE_ST(ut_setup, ut_teardown,
14601 test_AES_GCM_authenticated_encryption_test_case_3),
14602 TEST_CASE_ST(ut_setup, ut_teardown,
14603 test_AES_GCM_authenticated_encryption_test_case_4),
14604 TEST_CASE_ST(ut_setup, ut_teardown,
14605 test_AES_GCM_authenticated_encryption_test_case_5),
14606 TEST_CASE_ST(ut_setup, ut_teardown,
14607 test_AES_GCM_authenticated_encryption_test_case_6),
14608 TEST_CASE_ST(ut_setup, ut_teardown,
14609 test_AES_GCM_authenticated_encryption_test_case_7),
14610 TEST_CASE_ST(ut_setup, ut_teardown,
14611 test_AES_GCM_authenticated_encryption_test_case_8),
14612 TEST_CASE_ST(ut_setup, ut_teardown,
14613 test_AES_GCM_J0_authenticated_encryption_test_case_1),
14615 /** AES GCM Authenticated Decryption */
14616 TEST_CASE_ST(ut_setup, ut_teardown,
14617 test_AES_GCM_authenticated_decryption_test_case_1),
14618 TEST_CASE_ST(ut_setup, ut_teardown,
14619 test_AES_GCM_authenticated_decryption_test_case_2),
14620 TEST_CASE_ST(ut_setup, ut_teardown,
14621 test_AES_GCM_authenticated_decryption_test_case_3),
14622 TEST_CASE_ST(ut_setup, ut_teardown,
14623 test_AES_GCM_authenticated_decryption_test_case_4),
14624 TEST_CASE_ST(ut_setup, ut_teardown,
14625 test_AES_GCM_authenticated_decryption_test_case_5),
14626 TEST_CASE_ST(ut_setup, ut_teardown,
14627 test_AES_GCM_authenticated_decryption_test_case_6),
14628 TEST_CASE_ST(ut_setup, ut_teardown,
14629 test_AES_GCM_authenticated_decryption_test_case_7),
14630 TEST_CASE_ST(ut_setup, ut_teardown,
14631 test_AES_GCM_authenticated_decryption_test_case_8),
14632 TEST_CASE_ST(ut_setup, ut_teardown,
14633 test_AES_GCM_J0_authenticated_decryption_test_case_1),
14635 /** AES GCM Authenticated Encryption 192 bits key */
14636 TEST_CASE_ST(ut_setup, ut_teardown,
14637 test_AES_GCM_auth_encryption_test_case_192_1),
14638 TEST_CASE_ST(ut_setup, ut_teardown,
14639 test_AES_GCM_auth_encryption_test_case_192_2),
14640 TEST_CASE_ST(ut_setup, ut_teardown,
14641 test_AES_GCM_auth_encryption_test_case_192_3),
14642 TEST_CASE_ST(ut_setup, ut_teardown,
14643 test_AES_GCM_auth_encryption_test_case_192_4),
14644 TEST_CASE_ST(ut_setup, ut_teardown,
14645 test_AES_GCM_auth_encryption_test_case_192_5),
14646 TEST_CASE_ST(ut_setup, ut_teardown,
14647 test_AES_GCM_auth_encryption_test_case_192_6),
14648 TEST_CASE_ST(ut_setup, ut_teardown,
14649 test_AES_GCM_auth_encryption_test_case_192_7),
14651 /** AES GCM Authenticated Decryption 192 bits key */
14652 TEST_CASE_ST(ut_setup, ut_teardown,
14653 test_AES_GCM_auth_decryption_test_case_192_1),
14654 TEST_CASE_ST(ut_setup, ut_teardown,
14655 test_AES_GCM_auth_decryption_test_case_192_2),
14656 TEST_CASE_ST(ut_setup, ut_teardown,
14657 test_AES_GCM_auth_decryption_test_case_192_3),
14658 TEST_CASE_ST(ut_setup, ut_teardown,
14659 test_AES_GCM_auth_decryption_test_case_192_4),
14660 TEST_CASE_ST(ut_setup, ut_teardown,
14661 test_AES_GCM_auth_decryption_test_case_192_5),
14662 TEST_CASE_ST(ut_setup, ut_teardown,
14663 test_AES_GCM_auth_decryption_test_case_192_6),
14664 TEST_CASE_ST(ut_setup, ut_teardown,
14665 test_AES_GCM_auth_decryption_test_case_192_7),
14667 /** AES GCM Authenticated Encryption 256 bits key */
14668 TEST_CASE_ST(ut_setup, ut_teardown,
14669 test_AES_GCM_auth_encryption_test_case_256_1),
14670 TEST_CASE_ST(ut_setup, ut_teardown,
14671 test_AES_GCM_auth_encryption_test_case_256_2),
14672 TEST_CASE_ST(ut_setup, ut_teardown,
14673 test_AES_GCM_auth_encryption_test_case_256_3),
14674 TEST_CASE_ST(ut_setup, ut_teardown,
14675 test_AES_GCM_auth_encryption_test_case_256_4),
14676 TEST_CASE_ST(ut_setup, ut_teardown,
14677 test_AES_GCM_auth_encryption_test_case_256_5),
14678 TEST_CASE_ST(ut_setup, ut_teardown,
14679 test_AES_GCM_auth_encryption_test_case_256_6),
14680 TEST_CASE_ST(ut_setup, ut_teardown,
14681 test_AES_GCM_auth_encryption_test_case_256_7),
14683 /** AES GCM Authenticated Decryption 256 bits key */
14684 TEST_CASE_ST(ut_setup, ut_teardown,
14685 test_AES_GCM_auth_decryption_test_case_256_1),
14686 TEST_CASE_ST(ut_setup, ut_teardown,
14687 test_AES_GCM_auth_decryption_test_case_256_2),
14688 TEST_CASE_ST(ut_setup, ut_teardown,
14689 test_AES_GCM_auth_decryption_test_case_256_3),
14690 TEST_CASE_ST(ut_setup, ut_teardown,
14691 test_AES_GCM_auth_decryption_test_case_256_4),
14692 TEST_CASE_ST(ut_setup, ut_teardown,
14693 test_AES_GCM_auth_decryption_test_case_256_5),
14694 TEST_CASE_ST(ut_setup, ut_teardown,
14695 test_AES_GCM_auth_decryption_test_case_256_6),
14696 TEST_CASE_ST(ut_setup, ut_teardown,
14697 test_AES_GCM_auth_decryption_test_case_256_7),
14699 /** AES GCM Authenticated Encryption big aad size */
14700 TEST_CASE_ST(ut_setup, ut_teardown,
14701 test_AES_GCM_auth_encryption_test_case_aad_1),
14702 TEST_CASE_ST(ut_setup, ut_teardown,
14703 test_AES_GCM_auth_encryption_test_case_aad_2),
14705 /** AES GCM Authenticated Decryption big aad size */
14706 TEST_CASE_ST(ut_setup, ut_teardown,
14707 test_AES_GCM_auth_decryption_test_case_aad_1),
14708 TEST_CASE_ST(ut_setup, ut_teardown,
14709 test_AES_GCM_auth_decryption_test_case_aad_2),
14711 /** Out of place tests */
14712 TEST_CASE_ST(ut_setup, ut_teardown,
14713 test_AES_GCM_authenticated_encryption_oop_test_case_1),
14714 TEST_CASE_ST(ut_setup, ut_teardown,
14715 test_AES_GCM_authenticated_decryption_oop_test_case_1),
14717 /** Session-less tests */
14718 TEST_CASE_ST(ut_setup, ut_teardown,
14719 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
14720 TEST_CASE_ST(ut_setup, ut_teardown,
14721 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
14727 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
14728 .suite_name = "AES GMAC Authentication Test Suite",
14729 .setup = aes_gmac_auth_testsuite_setup,
14730 .unit_test_cases = {
14731 TEST_CASE_ST(ut_setup, ut_teardown,
14732 test_AES_GMAC_authentication_test_case_1),
14733 TEST_CASE_ST(ut_setup, ut_teardown,
14734 test_AES_GMAC_authentication_verify_test_case_1),
14735 TEST_CASE_ST(ut_setup, ut_teardown,
14736 test_AES_GMAC_authentication_test_case_2),
14737 TEST_CASE_ST(ut_setup, ut_teardown,
14738 test_AES_GMAC_authentication_verify_test_case_2),
14739 TEST_CASE_ST(ut_setup, ut_teardown,
14740 test_AES_GMAC_authentication_test_case_3),
14741 TEST_CASE_ST(ut_setup, ut_teardown,
14742 test_AES_GMAC_authentication_verify_test_case_3),
14743 TEST_CASE_ST(ut_setup, ut_teardown,
14744 test_AES_GMAC_authentication_test_case_4),
14745 TEST_CASE_ST(ut_setup, ut_teardown,
14746 test_AES_GMAC_authentication_verify_test_case_4),
14747 TEST_CASE_ST(ut_setup, ut_teardown,
14748 test_AES_GMAC_authentication_SGL_40B),
14749 TEST_CASE_ST(ut_setup, ut_teardown,
14750 test_AES_GMAC_authentication_SGL_80B),
14751 TEST_CASE_ST(ut_setup, ut_teardown,
14752 test_AES_GMAC_authentication_SGL_2048B),
14753 TEST_CASE_ST(ut_setup, ut_teardown,
14754 test_AES_GMAC_authentication_SGL_2047B),
14760 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14761 .suite_name = "Chacha20-Poly1305 Test Suite",
14762 .setup = chacha20_poly1305_testsuite_setup,
14763 .unit_test_cases = {
14764 TEST_CASE_ST(ut_setup, ut_teardown,
14765 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14766 TEST_CASE_ST(ut_setup, ut_teardown,
14767 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14772 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14773 .suite_name = "SNOW 3G Test Suite",
14774 .setup = snow3g_testsuite_setup,
14775 .unit_test_cases = {
14776 /** SNOW 3G encrypt only (UEA2) */
14777 TEST_CASE_ST(ut_setup, ut_teardown,
14778 test_snow3g_encryption_test_case_1),
14779 TEST_CASE_ST(ut_setup, ut_teardown,
14780 test_snow3g_encryption_test_case_2),
14781 TEST_CASE_ST(ut_setup, ut_teardown,
14782 test_snow3g_encryption_test_case_3),
14783 TEST_CASE_ST(ut_setup, ut_teardown,
14784 test_snow3g_encryption_test_case_4),
14785 TEST_CASE_ST(ut_setup, ut_teardown,
14786 test_snow3g_encryption_test_case_5),
14788 TEST_CASE_ST(ut_setup, ut_teardown,
14789 test_snow3g_encryption_test_case_1_oop),
14790 TEST_CASE_ST(ut_setup, ut_teardown,
14791 test_snow3g_encryption_test_case_1_oop_sgl),
14792 TEST_CASE_ST(ut_setup, ut_teardown,
14793 test_snow3g_encryption_test_case_1_offset_oop),
14794 TEST_CASE_ST(ut_setup, ut_teardown,
14795 test_snow3g_decryption_test_case_1_oop),
14797 /** SNOW 3G generate auth, then encrypt (UEA2) */
14798 TEST_CASE_ST(ut_setup, ut_teardown,
14799 test_snow3g_auth_cipher_test_case_1),
14800 TEST_CASE_ST(ut_setup, ut_teardown,
14801 test_snow3g_auth_cipher_test_case_2),
14802 TEST_CASE_ST(ut_setup, ut_teardown,
14803 test_snow3g_auth_cipher_test_case_2_oop),
14804 TEST_CASE_ST(ut_setup, ut_teardown,
14805 test_snow3g_auth_cipher_part_digest_enc),
14806 TEST_CASE_ST(ut_setup, ut_teardown,
14807 test_snow3g_auth_cipher_part_digest_enc_oop),
14808 TEST_CASE_ST(ut_setup, ut_teardown,
14809 test_snow3g_auth_cipher_test_case_3_sgl),
14810 TEST_CASE_ST(ut_setup, ut_teardown,
14811 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14812 TEST_CASE_ST(ut_setup, ut_teardown,
14813 test_snow3g_auth_cipher_part_digest_enc_sgl),
14814 TEST_CASE_ST(ut_setup, ut_teardown,
14815 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14817 /** SNOW 3G decrypt (UEA2), then verify auth */
14818 TEST_CASE_ST(ut_setup, ut_teardown,
14819 test_snow3g_auth_cipher_verify_test_case_1),
14820 TEST_CASE_ST(ut_setup, ut_teardown,
14821 test_snow3g_auth_cipher_verify_test_case_2),
14822 TEST_CASE_ST(ut_setup, ut_teardown,
14823 test_snow3g_auth_cipher_verify_test_case_2_oop),
14824 TEST_CASE_ST(ut_setup, ut_teardown,
14825 test_snow3g_auth_cipher_verify_part_digest_enc),
14826 TEST_CASE_ST(ut_setup, ut_teardown,
14827 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14828 TEST_CASE_ST(ut_setup, ut_teardown,
14829 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14830 TEST_CASE_ST(ut_setup, ut_teardown,
14831 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14832 TEST_CASE_ST(ut_setup, ut_teardown,
14833 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14834 TEST_CASE_ST(ut_setup, ut_teardown,
14835 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14837 /** SNOW 3G decrypt only (UEA2) */
14838 TEST_CASE_ST(ut_setup, ut_teardown,
14839 test_snow3g_decryption_test_case_1),
14840 TEST_CASE_ST(ut_setup, ut_teardown,
14841 test_snow3g_decryption_test_case_2),
14842 TEST_CASE_ST(ut_setup, ut_teardown,
14843 test_snow3g_decryption_test_case_3),
14844 TEST_CASE_ST(ut_setup, ut_teardown,
14845 test_snow3g_decryption_test_case_4),
14846 TEST_CASE_ST(ut_setup, ut_teardown,
14847 test_snow3g_decryption_test_case_5),
14848 TEST_CASE_ST(ut_setup, ut_teardown,
14849 test_snow3g_decryption_with_digest_test_case_1),
14850 TEST_CASE_ST(ut_setup, ut_teardown,
14851 test_snow3g_hash_generate_test_case_1),
14852 TEST_CASE_ST(ut_setup, ut_teardown,
14853 test_snow3g_hash_generate_test_case_2),
14854 TEST_CASE_ST(ut_setup, ut_teardown,
14855 test_snow3g_hash_generate_test_case_3),
14857 /* Tests with buffers which length is not byte-aligned */
14858 TEST_CASE_ST(ut_setup, ut_teardown,
14859 test_snow3g_hash_generate_test_case_4),
14860 TEST_CASE_ST(ut_setup, ut_teardown,
14861 test_snow3g_hash_generate_test_case_5),
14862 TEST_CASE_ST(ut_setup, ut_teardown,
14863 test_snow3g_hash_generate_test_case_6),
14864 TEST_CASE_ST(ut_setup, ut_teardown,
14865 test_snow3g_hash_verify_test_case_1),
14866 TEST_CASE_ST(ut_setup, ut_teardown,
14867 test_snow3g_hash_verify_test_case_2),
14868 TEST_CASE_ST(ut_setup, ut_teardown,
14869 test_snow3g_hash_verify_test_case_3),
14871 /* Tests with buffers which length is not byte-aligned */
14872 TEST_CASE_ST(ut_setup, ut_teardown,
14873 test_snow3g_hash_verify_test_case_4),
14874 TEST_CASE_ST(ut_setup, ut_teardown,
14875 test_snow3g_hash_verify_test_case_5),
14876 TEST_CASE_ST(ut_setup, ut_teardown,
14877 test_snow3g_hash_verify_test_case_6),
14878 TEST_CASE_ST(ut_setup, ut_teardown,
14879 test_snow3g_cipher_auth_test_case_1),
14880 TEST_CASE_ST(ut_setup, ut_teardown,
14881 test_snow3g_auth_cipher_with_digest_test_case_1),
14886 static struct unit_test_suite cryptodev_zuc_testsuite = {
14887 .suite_name = "ZUC Test Suite",
14888 .setup = zuc_testsuite_setup,
14889 .unit_test_cases = {
14890 /** ZUC encrypt only (EEA3) */
14891 TEST_CASE_ST(ut_setup, ut_teardown,
14892 test_zuc_encryption_test_case_1),
14893 TEST_CASE_ST(ut_setup, ut_teardown,
14894 test_zuc_encryption_test_case_2),
14895 TEST_CASE_ST(ut_setup, ut_teardown,
14896 test_zuc_encryption_test_case_3),
14897 TEST_CASE_ST(ut_setup, ut_teardown,
14898 test_zuc_encryption_test_case_4),
14899 TEST_CASE_ST(ut_setup, ut_teardown,
14900 test_zuc_encryption_test_case_5),
14901 TEST_CASE_ST(ut_setup, ut_teardown,
14902 test_zuc_encryption_test_case_6_sgl),
14903 TEST_CASE_ST(ut_setup, ut_teardown,
14904 test_zuc_encryption_test_case_7),
14906 /** ZUC authenticate (EIA3) */
14907 TEST_CASE_ST(ut_setup, ut_teardown,
14908 test_zuc_hash_generate_test_case_1),
14909 TEST_CASE_ST(ut_setup, ut_teardown,
14910 test_zuc_hash_generate_test_case_2),
14911 TEST_CASE_ST(ut_setup, ut_teardown,
14912 test_zuc_hash_generate_test_case_3),
14913 TEST_CASE_ST(ut_setup, ut_teardown,
14914 test_zuc_hash_generate_test_case_4),
14915 TEST_CASE_ST(ut_setup, ut_teardown,
14916 test_zuc_hash_generate_test_case_5),
14917 TEST_CASE_ST(ut_setup, ut_teardown,
14918 test_zuc_hash_generate_test_case_6),
14919 TEST_CASE_ST(ut_setup, ut_teardown,
14920 test_zuc_hash_generate_test_case_7),
14921 TEST_CASE_ST(ut_setup, ut_teardown,
14922 test_zuc_hash_generate_test_case_8),
14923 TEST_CASE_ST(ut_setup, ut_teardown,
14924 test_zuc_hash_generate_test_case_9),
14925 TEST_CASE_ST(ut_setup, ut_teardown,
14926 test_zuc_hash_generate_test_case_10),
14929 /** ZUC alg-chain (EEA3/EIA3) */
14930 TEST_CASE_ST(ut_setup, ut_teardown,
14931 test_zuc_cipher_auth_test_case_1),
14932 TEST_CASE_ST(ut_setup, ut_teardown,
14933 test_zuc_cipher_auth_test_case_2),
14935 /** ZUC generate auth, then encrypt (EEA3) */
14936 TEST_CASE_ST(ut_setup, ut_teardown,
14937 test_zuc_auth_cipher_test_case_1),
14938 TEST_CASE_ST(ut_setup, ut_teardown,
14939 test_zuc_auth_cipher_test_case_1_oop),
14940 TEST_CASE_ST(ut_setup, ut_teardown,
14941 test_zuc_auth_cipher_test_case_1_sgl),
14942 TEST_CASE_ST(ut_setup, ut_teardown,
14943 test_zuc_auth_cipher_test_case_1_oop_sgl),
14945 /** ZUC decrypt (EEA3), then verify auth */
14946 TEST_CASE_ST(ut_setup, ut_teardown,
14947 test_zuc_auth_cipher_verify_test_case_1),
14948 TEST_CASE_ST(ut_setup, ut_teardown,
14949 test_zuc_auth_cipher_verify_test_case_1_oop),
14950 TEST_CASE_ST(ut_setup, ut_teardown,
14951 test_zuc_auth_cipher_verify_test_case_1_sgl),
14952 TEST_CASE_ST(ut_setup, ut_teardown,
14953 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14958 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14959 .suite_name = "HMAC_MD5 Authentication Test Suite",
14960 .setup = hmac_md5_auth_testsuite_setup,
14961 .unit_test_cases = {
14962 TEST_CASE_ST(ut_setup, ut_teardown,
14963 test_MD5_HMAC_generate_case_1),
14964 TEST_CASE_ST(ut_setup, ut_teardown,
14965 test_MD5_HMAC_verify_case_1),
14966 TEST_CASE_ST(ut_setup, ut_teardown,
14967 test_MD5_HMAC_generate_case_2),
14968 TEST_CASE_ST(ut_setup, ut_teardown,
14969 test_MD5_HMAC_verify_case_2),
14974 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14975 .suite_name = "Kasumi Test Suite",
14976 .setup = kasumi_testsuite_setup,
14977 .unit_test_cases = {
14978 /** KASUMI hash only (UIA1) */
14979 TEST_CASE_ST(ut_setup, ut_teardown,
14980 test_kasumi_hash_generate_test_case_1),
14981 TEST_CASE_ST(ut_setup, ut_teardown,
14982 test_kasumi_hash_generate_test_case_2),
14983 TEST_CASE_ST(ut_setup, ut_teardown,
14984 test_kasumi_hash_generate_test_case_3),
14985 TEST_CASE_ST(ut_setup, ut_teardown,
14986 test_kasumi_hash_generate_test_case_4),
14987 TEST_CASE_ST(ut_setup, ut_teardown,
14988 test_kasumi_hash_generate_test_case_5),
14989 TEST_CASE_ST(ut_setup, ut_teardown,
14990 test_kasumi_hash_generate_test_case_6),
14992 TEST_CASE_ST(ut_setup, ut_teardown,
14993 test_kasumi_hash_verify_test_case_1),
14994 TEST_CASE_ST(ut_setup, ut_teardown,
14995 test_kasumi_hash_verify_test_case_2),
14996 TEST_CASE_ST(ut_setup, ut_teardown,
14997 test_kasumi_hash_verify_test_case_3),
14998 TEST_CASE_ST(ut_setup, ut_teardown,
14999 test_kasumi_hash_verify_test_case_4),
15000 TEST_CASE_ST(ut_setup, ut_teardown,
15001 test_kasumi_hash_verify_test_case_5),
15003 /** KASUMI encrypt only (UEA1) */
15004 TEST_CASE_ST(ut_setup, ut_teardown,
15005 test_kasumi_encryption_test_case_1),
15006 TEST_CASE_ST(ut_setup, ut_teardown,
15007 test_kasumi_encryption_test_case_1_sgl),
15008 TEST_CASE_ST(ut_setup, ut_teardown,
15009 test_kasumi_encryption_test_case_1_oop),
15010 TEST_CASE_ST(ut_setup, ut_teardown,
15011 test_kasumi_encryption_test_case_1_oop_sgl),
15012 TEST_CASE_ST(ut_setup, ut_teardown,
15013 test_kasumi_encryption_test_case_2),
15014 TEST_CASE_ST(ut_setup, ut_teardown,
15015 test_kasumi_encryption_test_case_3),
15016 TEST_CASE_ST(ut_setup, ut_teardown,
15017 test_kasumi_encryption_test_case_4),
15018 TEST_CASE_ST(ut_setup, ut_teardown,
15019 test_kasumi_encryption_test_case_5),
15021 /** KASUMI decrypt only (UEA1) */
15022 TEST_CASE_ST(ut_setup, ut_teardown,
15023 test_kasumi_decryption_test_case_1),
15024 TEST_CASE_ST(ut_setup, ut_teardown,
15025 test_kasumi_decryption_test_case_2),
15026 TEST_CASE_ST(ut_setup, ut_teardown,
15027 test_kasumi_decryption_test_case_3),
15028 TEST_CASE_ST(ut_setup, ut_teardown,
15029 test_kasumi_decryption_test_case_4),
15030 TEST_CASE_ST(ut_setup, ut_teardown,
15031 test_kasumi_decryption_test_case_5),
15032 TEST_CASE_ST(ut_setup, ut_teardown,
15033 test_kasumi_decryption_test_case_1_oop),
15034 TEST_CASE_ST(ut_setup, ut_teardown,
15035 test_kasumi_cipher_auth_test_case_1),
15037 /** KASUMI generate auth, then encrypt (F8) */
15038 TEST_CASE_ST(ut_setup, ut_teardown,
15039 test_kasumi_auth_cipher_test_case_1),
15040 TEST_CASE_ST(ut_setup, ut_teardown,
15041 test_kasumi_auth_cipher_test_case_2),
15042 TEST_CASE_ST(ut_setup, ut_teardown,
15043 test_kasumi_auth_cipher_test_case_2_oop),
15044 TEST_CASE_ST(ut_setup, ut_teardown,
15045 test_kasumi_auth_cipher_test_case_2_sgl),
15046 TEST_CASE_ST(ut_setup, ut_teardown,
15047 test_kasumi_auth_cipher_test_case_2_oop_sgl),
15049 /** KASUMI decrypt (F8), then verify auth */
15050 TEST_CASE_ST(ut_setup, ut_teardown,
15051 test_kasumi_auth_cipher_verify_test_case_1),
15052 TEST_CASE_ST(ut_setup, ut_teardown,
15053 test_kasumi_auth_cipher_verify_test_case_2),
15054 TEST_CASE_ST(ut_setup, ut_teardown,
15055 test_kasumi_auth_cipher_verify_test_case_2_oop),
15056 TEST_CASE_ST(ut_setup, ut_teardown,
15057 test_kasumi_auth_cipher_verify_test_case_2_sgl),
15058 TEST_CASE_ST(ut_setup, ut_teardown,
15059 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
15065 static struct unit_test_suite cryptodev_esn_testsuite = {
15066 .suite_name = "ESN Test Suite",
15067 .setup = esn_testsuite_setup,
15068 .unit_test_cases = {
15069 TEST_CASE_ST(ut_setup, ut_teardown,
15070 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
15071 TEST_CASE_ST(ut_setup, ut_teardown,
15072 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
15077 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
15078 .suite_name = "Negative AES GCM Test Suite",
15079 .setup = negative_aes_gcm_testsuite_setup,
15080 .unit_test_cases = {
15081 TEST_CASE_ST(ut_setup, ut_teardown,
15082 test_AES_GCM_auth_encryption_fail_iv_corrupt),
15083 TEST_CASE_ST(ut_setup, ut_teardown,
15084 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
15085 TEST_CASE_ST(ut_setup, ut_teardown,
15086 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
15087 TEST_CASE_ST(ut_setup, ut_teardown,
15088 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
15089 TEST_CASE_ST(ut_setup, ut_teardown,
15090 test_AES_GCM_auth_encryption_fail_aad_corrupt),
15091 TEST_CASE_ST(ut_setup, ut_teardown,
15092 test_AES_GCM_auth_encryption_fail_tag_corrupt),
15093 TEST_CASE_ST(ut_setup, ut_teardown,
15094 test_AES_GCM_auth_decryption_fail_iv_corrupt),
15095 TEST_CASE_ST(ut_setup, ut_teardown,
15096 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
15097 TEST_CASE_ST(ut_setup, ut_teardown,
15098 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
15099 TEST_CASE_ST(ut_setup, ut_teardown,
15100 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
15101 TEST_CASE_ST(ut_setup, ut_teardown,
15102 test_AES_GCM_auth_decryption_fail_aad_corrupt),
15103 TEST_CASE_ST(ut_setup, ut_teardown,
15104 test_AES_GCM_auth_decryption_fail_tag_corrupt),
15110 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
15111 .suite_name = "Negative AES GMAC Test Suite",
15112 .setup = negative_aes_gmac_testsuite_setup,
15113 .unit_test_cases = {
15114 TEST_CASE_ST(ut_setup, ut_teardown,
15115 authentication_verify_AES128_GMAC_fail_data_corrupt),
15116 TEST_CASE_ST(ut_setup, ut_teardown,
15117 authentication_verify_AES128_GMAC_fail_tag_corrupt),
15123 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
15124 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
15125 .setup = mixed_cipher_hash_testsuite_setup,
15126 .unit_test_cases = {
15127 /** AUTH AES CMAC + CIPHER AES CTR */
15128 TEST_CASE_ST(ut_setup, ut_teardown,
15129 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
15130 TEST_CASE_ST(ut_setup, ut_teardown,
15131 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15132 TEST_CASE_ST(ut_setup, ut_teardown,
15133 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15134 TEST_CASE_ST(ut_setup, ut_teardown,
15135 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15136 TEST_CASE_ST(ut_setup, ut_teardown,
15137 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
15138 TEST_CASE_ST(ut_setup, ut_teardown,
15139 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15140 TEST_CASE_ST(ut_setup, ut_teardown,
15141 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15142 TEST_CASE_ST(ut_setup, ut_teardown,
15143 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15145 /** AUTH ZUC + CIPHER SNOW3G */
15146 TEST_CASE_ST(ut_setup, ut_teardown,
15147 test_auth_zuc_cipher_snow_test_case_1),
15148 TEST_CASE_ST(ut_setup, ut_teardown,
15149 test_verify_auth_zuc_cipher_snow_test_case_1),
15150 /** AUTH AES CMAC + CIPHER SNOW3G */
15151 TEST_CASE_ST(ut_setup, ut_teardown,
15152 test_auth_aes_cmac_cipher_snow_test_case_1),
15153 TEST_CASE_ST(ut_setup, ut_teardown,
15154 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
15155 /** AUTH ZUC + CIPHER AES CTR */
15156 TEST_CASE_ST(ut_setup, ut_teardown,
15157 test_auth_zuc_cipher_aes_ctr_test_case_1),
15158 TEST_CASE_ST(ut_setup, ut_teardown,
15159 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
15160 /** AUTH SNOW3G + CIPHER AES CTR */
15161 TEST_CASE_ST(ut_setup, ut_teardown,
15162 test_auth_snow_cipher_aes_ctr_test_case_1),
15163 TEST_CASE_ST(ut_setup, ut_teardown,
15164 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
15165 /** AUTH SNOW3G + CIPHER ZUC */
15166 TEST_CASE_ST(ut_setup, ut_teardown,
15167 test_auth_snow_cipher_zuc_test_case_1),
15168 TEST_CASE_ST(ut_setup, ut_teardown,
15169 test_verify_auth_snow_cipher_zuc_test_case_1),
15170 /** AUTH AES CMAC + CIPHER ZUC */
15171 TEST_CASE_ST(ut_setup, ut_teardown,
15172 test_auth_aes_cmac_cipher_zuc_test_case_1),
15173 TEST_CASE_ST(ut_setup, ut_teardown,
15174 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
15176 /** AUTH NULL + CIPHER SNOW3G */
15177 TEST_CASE_ST(ut_setup, ut_teardown,
15178 test_auth_null_cipher_snow_test_case_1),
15179 TEST_CASE_ST(ut_setup, ut_teardown,
15180 test_verify_auth_null_cipher_snow_test_case_1),
15181 /** AUTH NULL + CIPHER ZUC */
15182 TEST_CASE_ST(ut_setup, ut_teardown,
15183 test_auth_null_cipher_zuc_test_case_1),
15184 TEST_CASE_ST(ut_setup, ut_teardown,
15185 test_verify_auth_null_cipher_zuc_test_case_1),
15186 /** AUTH SNOW3G + CIPHER NULL */
15187 TEST_CASE_ST(ut_setup, ut_teardown,
15188 test_auth_snow_cipher_null_test_case_1),
15189 TEST_CASE_ST(ut_setup, ut_teardown,
15190 test_verify_auth_snow_cipher_null_test_case_1),
15191 /** AUTH ZUC + CIPHER NULL */
15192 TEST_CASE_ST(ut_setup, ut_teardown,
15193 test_auth_zuc_cipher_null_test_case_1),
15194 TEST_CASE_ST(ut_setup, ut_teardown,
15195 test_verify_auth_zuc_cipher_null_test_case_1),
15196 /** AUTH NULL + CIPHER AES CTR */
15197 TEST_CASE_ST(ut_setup, ut_teardown,
15198 test_auth_null_cipher_aes_ctr_test_case_1),
15199 TEST_CASE_ST(ut_setup, ut_teardown,
15200 test_verify_auth_null_cipher_aes_ctr_test_case_1),
15201 /** AUTH AES CMAC + CIPHER NULL */
15202 TEST_CASE_ST(ut_setup, ut_teardown,
15203 test_auth_aes_cmac_cipher_null_test_case_1),
15204 TEST_CASE_ST(ut_setup, ut_teardown,
15205 test_verify_auth_aes_cmac_cipher_null_test_case_1),
15211 run_cryptodev_testsuite(const char *pmd_name)
15213 uint8_t ret, j, i = 0, blk_start_idx = 0;
15214 const enum blockcipher_test_type blk_suites[] = {
15215 BLKCIPHER_AES_CHAIN_TYPE,
15216 BLKCIPHER_AES_CIPHERONLY_TYPE,
15217 BLKCIPHER_AES_DOCSIS_TYPE,
15218 BLKCIPHER_3DES_CHAIN_TYPE,
15219 BLKCIPHER_3DES_CIPHERONLY_TYPE,
15220 BLKCIPHER_DES_CIPHERONLY_TYPE,
15221 BLKCIPHER_DES_DOCSIS_TYPE,
15222 BLKCIPHER_AUTHONLY_TYPE};
15223 struct unit_test_suite *static_suites[] = {
15224 &cryptodev_multi_session_testsuite,
15225 &cryptodev_null_testsuite,
15226 &cryptodev_aes_ccm_auth_testsuite,
15227 &cryptodev_aes_gcm_auth_testsuite,
15228 &cryptodev_aes_gmac_auth_testsuite,
15229 &cryptodev_snow3g_testsuite,
15230 &cryptodev_chacha20_poly1305_testsuite,
15231 &cryptodev_zuc_testsuite,
15232 &cryptodev_hmac_md5_auth_testsuite,
15233 &cryptodev_kasumi_testsuite,
15234 &cryptodev_esn_testsuite,
15235 &cryptodev_negative_aes_gcm_testsuite,
15236 &cryptodev_negative_aes_gmac_testsuite,
15237 &cryptodev_mixed_cipher_hash_testsuite,
15238 &cryptodev_negative_hmac_sha1_testsuite,
15239 &cryptodev_gen_testsuite,
15240 #ifdef RTE_LIB_SECURITY
15241 &ipsec_proto_testsuite,
15242 &pdcp_proto_testsuite,
15243 &docsis_proto_testsuite,
15247 static struct unit_test_suite ts = {
15248 .suite_name = "Cryptodev Unit Test Suite",
15249 .setup = testsuite_setup,
15250 .teardown = testsuite_teardown,
15251 .unit_test_cases = {TEST_CASES_END()}
15254 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
15256 if (gbl_driver_id == -1) {
15257 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
15258 return TEST_SKIPPED;
15261 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15262 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
15264 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
15265 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15266 ret = unit_test_suite_runner(&ts);
15268 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
15269 free(ts.unit_test_suites);
15274 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
15276 struct rte_cryptodev_info dev_info;
15277 uint8_t i, nb_devs;
15280 driver_id = rte_cryptodev_driver_id_get(pmd_name);
15281 if (driver_id == -1) {
15282 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
15283 return TEST_SKIPPED;
15286 nb_devs = rte_cryptodev_count();
15288 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
15289 return TEST_SKIPPED;
15292 for (i = 0; i < nb_devs; i++) {
15293 rte_cryptodev_info_get(i, &dev_info);
15294 if (dev_info.driver_id == driver_id) {
15295 if (!(dev_info.feature_flags & flag)) {
15296 RTE_LOG(INFO, USER1, "%s not supported\n",
15298 return TEST_SKIPPED;
15300 return 0; /* found */
15304 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
15305 return TEST_SKIPPED;
15309 test_cryptodev_qat(void)
15311 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
15315 test_cryptodev_virtio(void)
15317 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
15321 test_cryptodev_aesni_mb(void)
15323 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15327 test_cryptodev_cpu_aesni_mb(void)
15330 enum rte_security_session_action_type at = gbl_action_type;
15331 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15332 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15333 gbl_action_type = at;
15338 test_cryptodev_openssl(void)
15340 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
15344 test_cryptodev_aesni_gcm(void)
15346 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15350 test_cryptodev_cpu_aesni_gcm(void)
15353 enum rte_security_session_action_type at = gbl_action_type;
15354 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15355 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15356 gbl_action_type = at;
15361 test_cryptodev_mlx5(void)
15363 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
15367 test_cryptodev_null(void)
15369 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
15373 test_cryptodev_sw_snow3g(void)
15375 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
15379 test_cryptodev_sw_kasumi(void)
15381 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
15385 test_cryptodev_sw_zuc(void)
15387 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
15391 test_cryptodev_armv8(void)
15393 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
15397 test_cryptodev_mrvl(void)
15399 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
15402 #ifdef RTE_CRYPTO_SCHEDULER
15405 test_cryptodev_scheduler(void)
15407 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
15408 const enum blockcipher_test_type blk_suites[] = {
15409 BLKCIPHER_AES_CHAIN_TYPE,
15410 BLKCIPHER_AES_CIPHERONLY_TYPE,
15411 BLKCIPHER_AUTHONLY_TYPE
15413 static struct unit_test_suite scheduler_multicore = {
15414 .suite_name = "Scheduler Multicore Unit Test Suite",
15415 .setup = scheduler_multicore_testsuite_setup,
15416 .teardown = scheduler_mode_testsuite_teardown,
15417 .unit_test_cases = {TEST_CASES_END()}
15419 static struct unit_test_suite scheduler_round_robin = {
15420 .suite_name = "Scheduler Round Robin Unit Test Suite",
15421 .setup = scheduler_roundrobin_testsuite_setup,
15422 .teardown = scheduler_mode_testsuite_teardown,
15423 .unit_test_cases = {TEST_CASES_END()}
15425 static struct unit_test_suite scheduler_failover = {
15426 .suite_name = "Scheduler Failover Unit Test Suite",
15427 .setup = scheduler_failover_testsuite_setup,
15428 .teardown = scheduler_mode_testsuite_teardown,
15429 .unit_test_cases = {TEST_CASES_END()}
15431 static struct unit_test_suite scheduler_pkt_size_distr = {
15432 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
15433 .setup = scheduler_pkt_size_distr_testsuite_setup,
15434 .teardown = scheduler_mode_testsuite_teardown,
15435 .unit_test_cases = {TEST_CASES_END()}
15437 struct unit_test_suite *sched_mode_suites[] = {
15438 &scheduler_multicore,
15439 &scheduler_round_robin,
15440 &scheduler_failover,
15441 &scheduler_pkt_size_distr
15443 static struct unit_test_suite scheduler_config = {
15444 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
15445 .unit_test_cases = {
15446 TEST_CASE(test_scheduler_attach_worker_op),
15447 TEST_CASE(test_scheduler_mode_multicore_op),
15448 TEST_CASE(test_scheduler_mode_roundrobin_op),
15449 TEST_CASE(test_scheduler_mode_failover_op),
15450 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
15451 TEST_CASE(test_scheduler_detach_worker_op),
15453 TEST_CASES_END() /**< NULL terminate array */
15456 struct unit_test_suite *static_suites[] = {
15460 static struct unit_test_suite ts = {
15461 .suite_name = "Scheduler Unit Test Suite",
15462 .setup = scheduler_testsuite_setup,
15463 .teardown = testsuite_teardown,
15464 .unit_test_cases = {TEST_CASES_END()}
15467 gbl_driver_id = rte_cryptodev_driver_id_get(
15468 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15470 if (gbl_driver_id == -1) {
15471 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
15472 return TEST_SKIPPED;
15475 if (rte_cryptodev_driver_id_get(
15476 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
15477 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
15478 return TEST_SKIPPED;
15481 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15483 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
15484 (struct unit_test_suite *) *
15485 (RTE_DIM(blk_suites) + 1));
15486 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
15487 blk_suites, RTE_DIM(blk_suites));
15488 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
15491 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15492 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
15493 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
15494 RTE_DIM(sched_mode_suites));
15495 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15496 ret = unit_test_suite_runner(&ts);
15498 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15499 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
15500 (*sched_mode_suites[sched_i]),
15501 RTE_DIM(blk_suites));
15502 free(sched_mode_suites[sched_i]->unit_test_suites);
15504 free(ts.unit_test_suites);
15508 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
15513 test_cryptodev_dpaa2_sec(void)
15515 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
15519 test_cryptodev_dpaa_sec(void)
15521 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
15525 test_cryptodev_ccp(void)
15527 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
15531 test_cryptodev_octeontx(void)
15533 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
15537 test_cryptodev_octeontx2(void)
15539 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
15543 test_cryptodev_caam_jr(void)
15545 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
15549 test_cryptodev_nitrox(void)
15551 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
15555 test_cryptodev_bcmfs(void)
15557 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
15561 test_cryptodev_qat_raw_api(void)
15563 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
15566 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15571 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15572 ret = run_cryptodev_testsuite(pmd_name);
15573 global_api_test_type = CRYPTODEV_API_TEST;
15579 test_cryptodev_cn9k(void)
15581 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
15585 test_cryptodev_cn10k(void)
15587 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
15591 test_cryptodev_dpaa2_sec_raw_api(void)
15593 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
15596 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15601 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15602 ret = run_cryptodev_testsuite(pmd_name);
15603 global_api_test_type = CRYPTODEV_API_TEST;
15609 test_cryptodev_dpaa_sec_raw_api(void)
15611 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
15614 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15619 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15620 ret = run_cryptodev_testsuite(pmd_name);
15621 global_api_test_type = CRYPTODEV_API_TEST;
15626 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
15627 test_cryptodev_dpaa2_sec_raw_api);
15628 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
15629 test_cryptodev_dpaa_sec_raw_api);
15630 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
15631 test_cryptodev_qat_raw_api);
15632 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
15633 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
15634 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
15635 test_cryptodev_cpu_aesni_mb);
15636 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
15637 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
15638 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
15639 test_cryptodev_cpu_aesni_gcm);
15640 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
15641 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
15642 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
15643 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
15644 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
15645 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
15646 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
15647 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
15648 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
15649 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
15650 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
15651 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
15652 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
15653 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
15654 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
15655 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
15656 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
15657 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);