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>
22 #ifdef RTE_CRYPTO_SCHEDULER
23 #include <rte_cryptodev_scheduler.h>
24 #include <rte_cryptodev_scheduler_operations.h>
27 #include <rte_lcore.h>
30 #include "test_cryptodev.h"
32 #include "test_cryptodev_blockcipher.h"
33 #include "test_cryptodev_aes_test_vectors.h"
34 #include "test_cryptodev_des_test_vectors.h"
35 #include "test_cryptodev_hash_test_vectors.h"
36 #include "test_cryptodev_kasumi_test_vectors.h"
37 #include "test_cryptodev_kasumi_hash_test_vectors.h"
38 #include "test_cryptodev_snow3g_test_vectors.h"
39 #include "test_cryptodev_snow3g_hash_test_vectors.h"
40 #include "test_cryptodev_zuc_test_vectors.h"
41 #include "test_cryptodev_aead_test_vectors.h"
42 #include "test_cryptodev_hmac_test_vectors.h"
43 #include "test_cryptodev_mixed_test_vectors.h"
44 #ifdef RTE_LIB_SECURITY
45 #include "test_cryptodev_security_ipsec.h"
46 #include "test_cryptodev_security_ipsec_test_vectors.h"
47 #include "test_cryptodev_security_pdcp_test_vectors.h"
48 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
49 #include "test_cryptodev_security_pdcp_test_func.h"
50 #include "test_cryptodev_security_docsis_test_vectors.h"
52 #define SDAP_DISABLED 0
53 #define SDAP_ENABLED 1
56 #define VDEV_ARGS_SIZE 100
57 #define MAX_NB_SESSIONS 4
59 #define MAX_DRV_SERVICE_CTX_SIZE 256
61 #define MAX_RAW_DEQUEUE_COUNT 65535
64 #define OUT_OF_PLACE 1
66 static int gbl_driver_id;
68 static enum rte_security_session_action_type gbl_action_type =
69 RTE_SECURITY_ACTION_TYPE_NONE;
71 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
73 struct crypto_unittest_params {
74 struct rte_crypto_sym_xform cipher_xform;
75 struct rte_crypto_sym_xform auth_xform;
76 struct rte_crypto_sym_xform aead_xform;
77 #ifdef RTE_LIB_SECURITY
78 struct rte_security_docsis_xform docsis_xform;
82 struct rte_cryptodev_sym_session *sess;
83 #ifdef RTE_LIB_SECURITY
84 struct rte_security_session *sec_session;
87 #ifdef RTE_LIB_SECURITY
88 enum rte_security_session_action_type type;
90 struct rte_crypto_op *op;
92 struct rte_mbuf *obuf, *ibuf;
97 #define ALIGN_POW2_ROUNDUP(num, align) \
98 (((num) + (align) - 1) & ~((align) - 1))
100 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
101 for (j = 0; j < num_child_ts; index++, j++) \
102 parent_ts.unit_test_suites[index] = child_ts[j]
104 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
105 for (j = 0; j < num_blk_types; index++, j++) \
106 parent_ts.unit_test_suites[index] = \
107 build_blockcipher_test_suite(blk_types[j])
109 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
110 for (j = index; j < index + num_blk_types; j++) \
111 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
114 * Forward declarations.
117 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
118 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
122 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
123 struct crypto_unittest_params *ut_params,
124 struct crypto_testsuite_params *ts_param,
125 const uint8_t *cipher,
126 const uint8_t *digest,
130 security_proto_supported(enum rte_security_session_action_type action,
131 enum rte_security_session_protocol proto);
134 dev_configure_and_start(uint64_t ff_disable);
136 static struct rte_mbuf *
137 setup_test_string(struct rte_mempool *mpool,
138 const char *string, size_t len, uint8_t blocksize)
140 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
141 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
146 memset(m->buf_addr, 0, m->buf_len);
147 dst = rte_pktmbuf_append(m, t_len);
153 rte_memcpy(dst, string, t_len);
155 memset(dst, 0, t_len);
161 /* Get number of bytes in X bits (rounding up) */
163 ceil_byte_length(uint32_t num_bits)
166 return ((num_bits >> 3) + 1);
168 return (num_bits >> 3);
172 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
173 uint8_t is_op_success)
175 struct rte_crypto_op *op = user_data;
176 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
177 RTE_CRYPTO_OP_STATUS_ERROR;
181 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
182 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
183 uint8_t len_in_bits, uint8_t cipher_iv_len)
185 struct rte_crypto_sym_op *sop = op->sym;
186 struct rte_crypto_op *ret_op = NULL;
187 struct rte_crypto_vec data_vec[UINT8_MAX];
188 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
189 union rte_crypto_sym_ofs ofs;
190 struct rte_crypto_sym_vec vec;
191 struct rte_crypto_sgl sgl;
193 union rte_cryptodev_session_ctx sess;
195 struct rte_crypto_raw_dp_ctx *ctx;
196 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
200 int ctx_service_size;
202 int enqueue_status, dequeue_status;
204 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
205 if (ctx_service_size < 0) {
206 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
210 ctx = malloc(ctx_service_size);
212 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
216 /* Both are enums, setting crypto_sess will suit any session type */
217 sess.crypto_sess = op->sym->session;
219 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
220 op->sess_type, sess, 0) < 0) {
221 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
227 aad_auth_iv.iova = 0;
228 aad_auth_iv.va = NULL;
235 vec.digest = &digest;
236 vec.aad = &aad_auth_iv;
237 vec.status = &status;
241 if (is_cipher && is_auth) {
242 cipher_offset = sop->cipher.data.offset;
243 cipher_len = sop->cipher.data.length;
244 auth_offset = sop->auth.data.offset;
245 auth_len = sop->auth.data.length;
246 max_len = RTE_MAX(cipher_offset + cipher_len,
247 auth_offset + auth_len);
249 max_len = max_len >> 3;
250 cipher_offset = cipher_offset >> 3;
251 auth_offset = auth_offset >> 3;
252 cipher_len = cipher_len >> 3;
253 auth_len = auth_len >> 3;
255 ofs.ofs.cipher.head = cipher_offset;
256 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
257 ofs.ofs.auth.head = auth_offset;
258 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
259 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
260 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
261 aad_auth_iv.va = rte_crypto_op_ctod_offset(
262 op, void *, IV_OFFSET + cipher_iv_len);
263 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
265 digest.va = (void *)sop->auth.digest.data;
266 digest.iova = sop->auth.digest.phys_addr;
268 } else if (is_cipher) {
269 cipher_offset = sop->cipher.data.offset;
270 cipher_len = sop->cipher.data.length;
271 max_len = cipher_len + cipher_offset;
273 max_len = max_len >> 3;
274 cipher_offset = cipher_offset >> 3;
275 cipher_len = cipher_len >> 3;
277 ofs.ofs.cipher.head = cipher_offset;
278 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
279 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
280 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
282 } else if (is_auth) {
283 auth_offset = sop->auth.data.offset;
284 auth_len = sop->auth.data.length;
285 max_len = auth_len + auth_offset;
287 max_len = max_len >> 3;
288 auth_offset = auth_offset >> 3;
289 auth_len = auth_len >> 3;
291 ofs.ofs.auth.head = auth_offset;
292 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
293 aad_auth_iv.va = rte_crypto_op_ctod_offset(
294 op, void *, IV_OFFSET + cipher_iv_len);
295 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
297 digest.va = (void *)sop->auth.digest.data;
298 digest.iova = sop->auth.digest.phys_addr;
301 cipher_offset = sop->aead.data.offset;
302 cipher_len = sop->aead.data.length;
303 max_len = cipher_len + cipher_offset;
305 max_len = max_len >> 3;
306 cipher_offset = cipher_offset >> 3;
307 cipher_len = cipher_len >> 3;
309 ofs.ofs.cipher.head = cipher_offset;
310 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
311 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
312 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
313 aad_auth_iv.va = (void *)sop->aead.aad.data;
314 aad_auth_iv.iova = sop->aead.aad.phys_addr;
315 digest.va = (void *)sop->aead.digest.data;
316 digest.iova = sop->aead.digest.phys_addr;
319 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
320 data_vec, RTE_DIM(data_vec));
321 if (n < 0 || n > sop->m_src->nb_segs) {
322 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
328 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
329 &enqueue_status) < 1) {
330 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
334 if (enqueue_status == 0) {
335 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
337 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
340 } else if (enqueue_status < 0) {
341 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
346 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
347 n = rte_cryptodev_raw_dequeue_burst(ctx,
348 NULL, 1, post_process_raw_dp_op,
349 (void **)&ret_op, 0, &n_success,
351 if (dequeue_status < 0) {
352 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
359 if (n == 1 && dequeue_status == 0) {
360 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
361 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
366 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
367 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
368 RTE_CRYPTO_OP_STATUS_SUCCESS;
375 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
378 struct rte_crypto_sym_op *sop;
379 union rte_crypto_sym_ofs ofs;
380 struct rte_crypto_sgl sgl;
381 struct rte_crypto_sym_vec symvec;
382 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
383 struct rte_crypto_vec vec[UINT8_MAX];
387 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
388 sop->aead.data.length, vec, RTE_DIM(vec));
390 if (n < 0 || n != sop->m_src->nb_segs) {
391 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
399 symvec.digest = &digest_ptr;
400 symvec.aad = &aad_ptr;
404 /* for CPU crypto the IOVA address is not required */
405 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
406 digest_ptr.va = (void *)sop->aead.digest.data;
407 aad_ptr.va = (void *)sop->aead.aad.data;
411 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
415 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
417 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
421 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
424 struct rte_crypto_sym_op *sop;
425 union rte_crypto_sym_ofs ofs;
426 struct rte_crypto_sgl sgl;
427 struct rte_crypto_sym_vec symvec;
428 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
429 struct rte_crypto_vec vec[UINT8_MAX];
433 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
434 sop->auth.data.length, vec, RTE_DIM(vec));
436 if (n < 0 || n != sop->m_src->nb_segs) {
437 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
445 symvec.digest = &digest_ptr;
449 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
450 digest_ptr.va = (void *)sop->auth.digest.data;
453 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
454 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
455 (sop->cipher.data.offset + sop->cipher.data.length);
457 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
461 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
463 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
466 static struct rte_crypto_op *
467 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
470 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
472 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
473 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
479 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
482 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
483 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
490 static struct crypto_testsuite_params testsuite_params = { NULL };
491 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
492 static struct crypto_unittest_params unittest_params;
495 testsuite_setup(void)
497 struct crypto_testsuite_params *ts_params = &testsuite_params;
498 struct rte_cryptodev_info info;
499 uint32_t i = 0, nb_devs, dev_id;
502 memset(ts_params, 0, sizeof(*ts_params));
504 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
505 if (ts_params->mbuf_pool == NULL) {
506 /* Not already created so create */
507 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
509 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
511 if (ts_params->mbuf_pool == NULL) {
512 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
517 ts_params->large_mbuf_pool = rte_mempool_lookup(
518 "CRYPTO_LARGE_MBUFPOOL");
519 if (ts_params->large_mbuf_pool == NULL) {
520 /* Not already created so create */
521 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
522 "CRYPTO_LARGE_MBUFPOOL",
525 if (ts_params->large_mbuf_pool == NULL) {
527 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
532 ts_params->op_mpool = rte_crypto_op_pool_create(
533 "MBUF_CRYPTO_SYM_OP_POOL",
534 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
535 NUM_MBUFS, MBUF_CACHE_SIZE,
537 sizeof(struct rte_crypto_sym_xform) +
540 if (ts_params->op_mpool == NULL) {
541 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
545 nb_devs = rte_cryptodev_count();
547 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
551 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
552 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
553 rte_cryptodev_driver_name_get(gbl_driver_id));
557 /* Create list of valid crypto devs */
558 for (i = 0; i < nb_devs; i++) {
559 rte_cryptodev_info_get(i, &info);
560 if (info.driver_id == gbl_driver_id)
561 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
564 if (ts_params->valid_dev_count < 1)
567 /* Set up all the qps on the first of the valid devices found */
569 dev_id = ts_params->valid_devs[0];
571 rte_cryptodev_info_get(dev_id, &info);
573 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
574 ts_params->conf.socket_id = SOCKET_ID_ANY;
575 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
577 unsigned int session_size =
578 rte_cryptodev_sym_get_private_session_size(dev_id);
580 #ifdef RTE_LIB_SECURITY
581 unsigned int security_session_size = rte_security_session_get_size(
582 rte_cryptodev_get_sec_ctx(dev_id));
584 if (session_size < security_session_size)
585 session_size = security_session_size;
588 * Create mempool with maximum number of sessions.
590 if (info.sym.max_nb_sessions != 0 &&
591 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
592 RTE_LOG(ERR, USER1, "Device does not support "
593 "at least %u sessions\n",
598 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
599 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
601 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
602 "session mempool allocation failed");
604 ts_params->session_priv_mpool = rte_mempool_create(
608 0, 0, NULL, NULL, NULL,
611 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
612 "session mempool allocation failed");
616 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
618 "Failed to configure cryptodev %u with %u qps",
619 dev_id, ts_params->conf.nb_queue_pairs);
621 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
622 ts_params->qp_conf.mp_session = ts_params->session_mpool;
623 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
625 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
626 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
627 dev_id, qp_id, &ts_params->qp_conf,
628 rte_cryptodev_socket_id(dev_id)),
629 "Failed to setup queue pair %u on cryptodev %u",
637 testsuite_teardown(void)
639 struct crypto_testsuite_params *ts_params = &testsuite_params;
642 if (ts_params->mbuf_pool != NULL) {
643 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
644 rte_mempool_avail_count(ts_params->mbuf_pool));
647 if (ts_params->op_mpool != NULL) {
648 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
649 rte_mempool_avail_count(ts_params->op_mpool));
652 /* Free session mempools */
653 if (ts_params->session_priv_mpool != NULL) {
654 rte_mempool_free(ts_params->session_priv_mpool);
655 ts_params->session_priv_mpool = NULL;
658 if (ts_params->session_mpool != NULL) {
659 rte_mempool_free(ts_params->session_mpool);
660 ts_params->session_mpool = NULL;
663 res = rte_cryptodev_close(ts_params->valid_devs[0]);
665 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
669 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
670 const int *algs, uint16_t num_algs)
672 uint8_t dev_id = testsuite_params.valid_devs[0];
673 bool some_alg_supported = FALSE;
676 for (i = 0; i < num_algs && !some_alg_supported; i++) {
677 struct rte_cryptodev_sym_capability_idx alg = {
680 if (rte_cryptodev_sym_capability_get(dev_id,
682 some_alg_supported = TRUE;
684 if (!some_alg_supported)
691 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
692 uint16_t num_ciphers)
694 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
695 (const int *) ciphers, num_ciphers);
699 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
702 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
703 (const int *) auths, num_auths);
707 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
710 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
711 (const int *) aeads, num_aeads);
715 null_testsuite_setup(void)
717 struct crypto_testsuite_params *ts_params = &testsuite_params;
718 uint8_t dev_id = ts_params->valid_devs[0];
719 struct rte_cryptodev_info dev_info;
720 const enum rte_crypto_cipher_algorithm ciphers[] = {
721 RTE_CRYPTO_CIPHER_NULL
723 const enum rte_crypto_auth_algorithm auths[] = {
727 rte_cryptodev_info_get(dev_id, &dev_info);
729 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
730 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
731 "testsuite not met\n");
735 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
736 && check_auth_capabilities_supported(auths,
737 RTE_DIM(auths)) != 0) {
738 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
739 "testsuite not met\n");
747 crypto_gen_testsuite_setup(void)
749 struct crypto_testsuite_params *ts_params = &testsuite_params;
750 uint8_t dev_id = ts_params->valid_devs[0];
751 struct rte_cryptodev_info dev_info;
753 rte_cryptodev_info_get(dev_id, &dev_info);
755 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
756 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
757 "testsuite not met\n");
764 #ifdef RTE_LIB_SECURITY
766 ipsec_proto_testsuite_setup(void)
768 struct crypto_testsuite_params *ts_params = &testsuite_params;
769 struct crypto_unittest_params *ut_params = &unittest_params;
770 struct rte_cryptodev_info dev_info;
773 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
775 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
776 RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
777 "testsuite not met\n");
781 /* Reconfigure to enable security */
782 ret = dev_configure_and_start(0);
783 if (ret != TEST_SUCCESS)
786 /* Set action type */
787 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
789 if (security_proto_supported(
790 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
791 RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
792 RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
798 * Stop the device. Device would be started again by individual test
799 * case setup routine.
801 rte_cryptodev_stop(ts_params->valid_devs[0]);
807 pdcp_proto_testsuite_setup(void)
809 struct crypto_testsuite_params *ts_params = &testsuite_params;
810 uint8_t dev_id = ts_params->valid_devs[0];
811 struct rte_cryptodev_info dev_info;
812 const enum rte_crypto_cipher_algorithm ciphers[] = {
813 RTE_CRYPTO_CIPHER_NULL,
814 RTE_CRYPTO_CIPHER_AES_CTR,
815 RTE_CRYPTO_CIPHER_ZUC_EEA3,
816 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
818 const enum rte_crypto_auth_algorithm auths[] = {
819 RTE_CRYPTO_AUTH_NULL,
820 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
821 RTE_CRYPTO_AUTH_AES_CMAC,
822 RTE_CRYPTO_AUTH_ZUC_EIA3
825 rte_cryptodev_info_get(dev_id, &dev_info);
827 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
828 !(dev_info.feature_flags &
829 RTE_CRYPTODEV_FF_SECURITY)) {
830 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
831 "testsuite not met\n");
835 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
836 && check_auth_capabilities_supported(auths,
837 RTE_DIM(auths)) != 0) {
838 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
839 "testsuite not met\n");
847 docsis_proto_testsuite_setup(void)
849 struct crypto_testsuite_params *ts_params = &testsuite_params;
850 uint8_t dev_id = ts_params->valid_devs[0];
851 struct rte_cryptodev_info dev_info;
852 const enum rte_crypto_cipher_algorithm ciphers[] = {
853 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
856 rte_cryptodev_info_get(dev_id, &dev_info);
858 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
859 !(dev_info.feature_flags &
860 RTE_CRYPTODEV_FF_SECURITY)) {
861 RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
862 "Proto testsuite not met\n");
866 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
867 RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
868 "testsuite not met\n");
877 aes_ccm_auth_testsuite_setup(void)
879 struct crypto_testsuite_params *ts_params = &testsuite_params;
880 uint8_t dev_id = ts_params->valid_devs[0];
881 struct rte_cryptodev_info dev_info;
882 const enum rte_crypto_aead_algorithm aeads[] = {
883 RTE_CRYPTO_AEAD_AES_CCM
886 rte_cryptodev_info_get(dev_id, &dev_info);
888 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
889 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
890 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
891 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
892 "testsuite not met\n");
896 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
897 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
898 "testsuite not met\n");
906 aes_gcm_auth_testsuite_setup(void)
908 struct crypto_testsuite_params *ts_params = &testsuite_params;
909 uint8_t dev_id = ts_params->valid_devs[0];
910 struct rte_cryptodev_info dev_info;
911 const enum rte_crypto_aead_algorithm aeads[] = {
912 RTE_CRYPTO_AEAD_AES_GCM
915 rte_cryptodev_info_get(dev_id, &dev_info);
917 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
918 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
919 "testsuite not met\n");
923 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
924 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
925 "testsuite not met\n");
933 aes_gmac_auth_testsuite_setup(void)
935 struct crypto_testsuite_params *ts_params = &testsuite_params;
936 uint8_t dev_id = ts_params->valid_devs[0];
937 struct rte_cryptodev_info dev_info;
938 const enum rte_crypto_auth_algorithm auths[] = {
939 RTE_CRYPTO_AUTH_AES_GMAC
942 rte_cryptodev_info_get(dev_id, &dev_info);
944 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
945 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
946 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
947 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
948 "testsuite not met\n");
952 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
953 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
954 "testsuite not met\n");
962 chacha20_poly1305_testsuite_setup(void)
964 struct crypto_testsuite_params *ts_params = &testsuite_params;
965 uint8_t dev_id = ts_params->valid_devs[0];
966 struct rte_cryptodev_info dev_info;
967 const enum rte_crypto_aead_algorithm aeads[] = {
968 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
971 rte_cryptodev_info_get(dev_id, &dev_info);
973 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
974 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
975 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
976 RTE_LOG(INFO, USER1, "Feature flag requirements for "
977 "Chacha20-Poly1305 testsuite not met\n");
981 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
982 RTE_LOG(INFO, USER1, "Capability requirements for "
983 "Chacha20-Poly1305 testsuite not met\n");
991 snow3g_testsuite_setup(void)
993 struct crypto_testsuite_params *ts_params = &testsuite_params;
994 uint8_t dev_id = ts_params->valid_devs[0];
995 struct rte_cryptodev_info dev_info;
996 const enum rte_crypto_cipher_algorithm ciphers[] = {
997 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1000 const enum rte_crypto_auth_algorithm auths[] = {
1001 RTE_CRYPTO_AUTH_SNOW3G_UIA2
1004 rte_cryptodev_info_get(dev_id, &dev_info);
1006 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1007 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1008 "testsuite not met\n");
1009 return TEST_SKIPPED;
1012 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1013 && check_auth_capabilities_supported(auths,
1014 RTE_DIM(auths)) != 0) {
1015 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1016 "testsuite not met\n");
1017 return TEST_SKIPPED;
1024 zuc_testsuite_setup(void)
1026 struct crypto_testsuite_params *ts_params = &testsuite_params;
1027 uint8_t dev_id = ts_params->valid_devs[0];
1028 struct rte_cryptodev_info dev_info;
1029 const enum rte_crypto_cipher_algorithm ciphers[] = {
1030 RTE_CRYPTO_CIPHER_ZUC_EEA3
1032 const enum rte_crypto_auth_algorithm auths[] = {
1033 RTE_CRYPTO_AUTH_ZUC_EIA3
1036 rte_cryptodev_info_get(dev_id, &dev_info);
1038 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1039 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1040 "testsuite not met\n");
1041 return TEST_SKIPPED;
1044 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1045 && check_auth_capabilities_supported(auths,
1046 RTE_DIM(auths)) != 0) {
1047 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1048 "testsuite not met\n");
1049 return TEST_SKIPPED;
1056 hmac_md5_auth_testsuite_setup(void)
1058 struct crypto_testsuite_params *ts_params = &testsuite_params;
1059 uint8_t dev_id = ts_params->valid_devs[0];
1060 struct rte_cryptodev_info dev_info;
1061 const enum rte_crypto_auth_algorithm auths[] = {
1062 RTE_CRYPTO_AUTH_MD5_HMAC
1065 rte_cryptodev_info_get(dev_id, &dev_info);
1067 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1068 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1069 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1070 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1071 "Auth testsuite not met\n");
1072 return TEST_SKIPPED;
1075 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1076 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1077 "testsuite not met\n");
1078 return TEST_SKIPPED;
1085 kasumi_testsuite_setup(void)
1087 struct crypto_testsuite_params *ts_params = &testsuite_params;
1088 uint8_t dev_id = ts_params->valid_devs[0];
1089 struct rte_cryptodev_info dev_info;
1090 const enum rte_crypto_cipher_algorithm ciphers[] = {
1091 RTE_CRYPTO_CIPHER_KASUMI_F8
1093 const enum rte_crypto_auth_algorithm auths[] = {
1094 RTE_CRYPTO_AUTH_KASUMI_F9
1097 rte_cryptodev_info_get(dev_id, &dev_info);
1099 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1100 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1101 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1102 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1103 "testsuite not met\n");
1104 return TEST_SKIPPED;
1107 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1108 && check_auth_capabilities_supported(auths,
1109 RTE_DIM(auths)) != 0) {
1110 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1111 "testsuite not met\n");
1112 return TEST_SKIPPED;
1119 negative_aes_gcm_testsuite_setup(void)
1121 struct crypto_testsuite_params *ts_params = &testsuite_params;
1122 uint8_t dev_id = ts_params->valid_devs[0];
1123 struct rte_cryptodev_info dev_info;
1124 const enum rte_crypto_aead_algorithm aeads[] = {
1125 RTE_CRYPTO_AEAD_AES_GCM
1128 rte_cryptodev_info_get(dev_id, &dev_info);
1130 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1131 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1132 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1133 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1134 "AES GCM testsuite not met\n");
1135 return TEST_SKIPPED;
1138 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1139 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1140 "AES GCM testsuite not met\n");
1141 return TEST_SKIPPED;
1148 negative_aes_gmac_testsuite_setup(void)
1150 struct crypto_testsuite_params *ts_params = &testsuite_params;
1151 uint8_t dev_id = ts_params->valid_devs[0];
1152 struct rte_cryptodev_info dev_info;
1153 const enum rte_crypto_auth_algorithm auths[] = {
1154 RTE_CRYPTO_AUTH_AES_GMAC
1157 rte_cryptodev_info_get(dev_id, &dev_info);
1159 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1160 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1161 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1162 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1163 "AES GMAC testsuite not met\n");
1164 return TEST_SKIPPED;
1167 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1168 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1169 "AES GMAC testsuite not met\n");
1170 return TEST_SKIPPED;
1177 mixed_cipher_hash_testsuite_setup(void)
1179 struct crypto_testsuite_params *ts_params = &testsuite_params;
1180 uint8_t dev_id = ts_params->valid_devs[0];
1181 struct rte_cryptodev_info dev_info;
1182 uint64_t feat_flags;
1183 const enum rte_crypto_cipher_algorithm ciphers[] = {
1184 RTE_CRYPTO_CIPHER_NULL,
1185 RTE_CRYPTO_CIPHER_AES_CTR,
1186 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1187 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1189 const enum rte_crypto_auth_algorithm auths[] = {
1190 RTE_CRYPTO_AUTH_NULL,
1191 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1192 RTE_CRYPTO_AUTH_AES_CMAC,
1193 RTE_CRYPTO_AUTH_ZUC_EIA3
1196 rte_cryptodev_info_get(dev_id, &dev_info);
1197 feat_flags = dev_info.feature_flags;
1199 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1200 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1201 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1202 "Cipher Hash testsuite not met\n");
1203 return TEST_SKIPPED;
1206 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1207 && check_auth_capabilities_supported(auths,
1208 RTE_DIM(auths)) != 0) {
1209 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1210 "Cipher Hash testsuite not met\n");
1211 return TEST_SKIPPED;
1218 esn_testsuite_setup(void)
1220 struct crypto_testsuite_params *ts_params = &testsuite_params;
1221 uint8_t dev_id = ts_params->valid_devs[0];
1222 struct rte_cryptodev_info dev_info;
1223 const enum rte_crypto_cipher_algorithm ciphers[] = {
1224 RTE_CRYPTO_CIPHER_AES_CBC
1226 const enum rte_crypto_auth_algorithm auths[] = {
1227 RTE_CRYPTO_AUTH_SHA1_HMAC
1230 rte_cryptodev_info_get(dev_id, &dev_info);
1232 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1233 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1234 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1235 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1236 "testsuite not met\n");
1237 return TEST_SKIPPED;
1240 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1241 && check_auth_capabilities_supported(auths,
1242 RTE_DIM(auths)) != 0) {
1243 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1244 "testsuite not met\n");
1245 return TEST_SKIPPED;
1252 multi_session_testsuite_setup(void)
1254 struct crypto_testsuite_params *ts_params = &testsuite_params;
1255 uint8_t dev_id = ts_params->valid_devs[0];
1256 struct rte_cryptodev_info dev_info;
1257 const enum rte_crypto_cipher_algorithm ciphers[] = {
1258 RTE_CRYPTO_CIPHER_AES_CBC
1260 const enum rte_crypto_auth_algorithm auths[] = {
1261 RTE_CRYPTO_AUTH_SHA512_HMAC
1264 rte_cryptodev_info_get(dev_id, &dev_info);
1266 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1267 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1268 "Session testsuite not met\n");
1269 return TEST_SKIPPED;
1272 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1273 && check_auth_capabilities_supported(auths,
1274 RTE_DIM(auths)) != 0) {
1275 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1276 "Session testsuite not met\n");
1277 return TEST_SKIPPED;
1284 negative_hmac_sha1_testsuite_setup(void)
1286 struct crypto_testsuite_params *ts_params = &testsuite_params;
1287 uint8_t dev_id = ts_params->valid_devs[0];
1288 struct rte_cryptodev_info dev_info;
1289 const enum rte_crypto_cipher_algorithm ciphers[] = {
1290 RTE_CRYPTO_CIPHER_AES_CBC
1292 const enum rte_crypto_auth_algorithm auths[] = {
1293 RTE_CRYPTO_AUTH_SHA1_HMAC
1296 rte_cryptodev_info_get(dev_id, &dev_info);
1298 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1299 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1300 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1301 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1302 "HMAC SHA1 testsuite not met\n");
1303 return TEST_SKIPPED;
1306 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1307 && check_auth_capabilities_supported(auths,
1308 RTE_DIM(auths)) != 0) {
1309 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1310 "HMAC SHA1 testsuite not met\n");
1311 return TEST_SKIPPED;
1318 dev_configure_and_start(uint64_t ff_disable)
1320 struct crypto_testsuite_params *ts_params = &testsuite_params;
1321 struct crypto_unittest_params *ut_params = &unittest_params;
1325 /* Clear unit test parameters before running test */
1326 memset(ut_params, 0, sizeof(*ut_params));
1328 /* Reconfigure device to default parameters */
1329 ts_params->conf.socket_id = SOCKET_ID_ANY;
1330 ts_params->conf.ff_disable = ff_disable;
1331 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1332 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1333 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1335 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1337 "Failed to configure cryptodev %u",
1338 ts_params->valid_devs[0]);
1340 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1341 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1342 ts_params->valid_devs[0], qp_id,
1343 &ts_params->qp_conf,
1344 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1345 "Failed to setup queue pair %u on cryptodev %u",
1346 qp_id, ts_params->valid_devs[0]);
1350 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1352 /* Start the device */
1353 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1354 "Failed to start cryptodev %u",
1355 ts_params->valid_devs[0]);
1357 return TEST_SUCCESS;
1363 /* Configure and start the device with security feature disabled */
1364 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1368 ut_setup_security(void)
1370 /* Configure and start the device with no features disabled */
1371 return dev_configure_and_start(0);
1377 struct crypto_testsuite_params *ts_params = &testsuite_params;
1378 struct crypto_unittest_params *ut_params = &unittest_params;
1379 struct rte_cryptodev_stats stats;
1381 /* free crypto session structure */
1382 #ifdef RTE_LIB_SECURITY
1383 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1384 if (ut_params->sec_session) {
1385 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1386 (ts_params->valid_devs[0]),
1387 ut_params->sec_session);
1388 ut_params->sec_session = NULL;
1393 if (ut_params->sess) {
1394 rte_cryptodev_sym_session_clear(
1395 ts_params->valid_devs[0],
1397 rte_cryptodev_sym_session_free(ut_params->sess);
1398 ut_params->sess = NULL;
1402 /* free crypto operation structure */
1404 rte_crypto_op_free(ut_params->op);
1407 * free mbuf - both obuf and ibuf are usually the same,
1408 * so check if they point at the same address is necessary,
1409 * to avoid freeing the mbuf twice.
1411 if (ut_params->obuf) {
1412 rte_pktmbuf_free(ut_params->obuf);
1413 if (ut_params->ibuf == ut_params->obuf)
1414 ut_params->ibuf = 0;
1415 ut_params->obuf = 0;
1417 if (ut_params->ibuf) {
1418 rte_pktmbuf_free(ut_params->ibuf);
1419 ut_params->ibuf = 0;
1422 if (ts_params->mbuf_pool != NULL)
1423 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1424 rte_mempool_avail_count(ts_params->mbuf_pool));
1426 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1428 /* Stop the device */
1429 rte_cryptodev_stop(ts_params->valid_devs[0]);
1433 test_device_configure_invalid_dev_id(void)
1435 struct crypto_testsuite_params *ts_params = &testsuite_params;
1436 uint16_t dev_id, num_devs = 0;
1438 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1439 "Need at least %d devices for test", 1);
1441 /* valid dev_id values */
1442 dev_id = ts_params->valid_devs[0];
1444 /* Stop the device in case it's started so it can be configured */
1445 rte_cryptodev_stop(dev_id);
1447 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1448 "Failed test for rte_cryptodev_configure: "
1449 "invalid dev_num %u", dev_id);
1451 /* invalid dev_id values */
1454 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1455 "Failed test for rte_cryptodev_configure: "
1456 "invalid dev_num %u", dev_id);
1460 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1461 "Failed test for rte_cryptodev_configure:"
1462 "invalid dev_num %u", dev_id);
1464 return TEST_SUCCESS;
1468 test_device_configure_invalid_queue_pair_ids(void)
1470 struct crypto_testsuite_params *ts_params = &testsuite_params;
1471 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1473 /* Stop the device in case it's started so it can be configured */
1474 rte_cryptodev_stop(ts_params->valid_devs[0]);
1476 /* valid - max value queue pairs */
1477 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1479 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1481 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1482 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1484 /* valid - one queue pairs */
1485 ts_params->conf.nb_queue_pairs = 1;
1487 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1489 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1490 ts_params->valid_devs[0],
1491 ts_params->conf.nb_queue_pairs);
1494 /* invalid - zero queue pairs */
1495 ts_params->conf.nb_queue_pairs = 0;
1497 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1499 "Failed test for rte_cryptodev_configure, dev_id %u,"
1501 ts_params->valid_devs[0],
1502 ts_params->conf.nb_queue_pairs);
1505 /* invalid - max value supported by field queue pairs */
1506 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1508 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1510 "Failed test for rte_cryptodev_configure, dev_id %u,"
1512 ts_params->valid_devs[0],
1513 ts_params->conf.nb_queue_pairs);
1516 /* invalid - max value + 1 queue pairs */
1517 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1519 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1521 "Failed test for rte_cryptodev_configure, dev_id %u,"
1523 ts_params->valid_devs[0],
1524 ts_params->conf.nb_queue_pairs);
1526 /* revert to original testsuite value */
1527 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1529 return TEST_SUCCESS;
1533 test_queue_pair_descriptor_setup(void)
1535 struct crypto_testsuite_params *ts_params = &testsuite_params;
1536 struct rte_cryptodev_qp_conf qp_conf = {
1537 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1541 /* Stop the device in case it's started so it can be configured */
1542 rte_cryptodev_stop(ts_params->valid_devs[0]);
1544 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1546 "Failed to configure cryptodev %u",
1547 ts_params->valid_devs[0]);
1550 * Test various ring sizes on this device. memzones can't be
1551 * freed so are re-used if ring is released and re-created.
1553 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1554 qp_conf.mp_session = ts_params->session_mpool;
1555 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1557 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1558 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1559 ts_params->valid_devs[0], qp_id, &qp_conf,
1560 rte_cryptodev_socket_id(
1561 ts_params->valid_devs[0])),
1563 "rte_cryptodev_queue_pair_setup: num_inflights "
1564 "%u on qp %u on cryptodev %u",
1565 qp_conf.nb_descriptors, qp_id,
1566 ts_params->valid_devs[0]);
1569 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1571 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1572 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1573 ts_params->valid_devs[0], qp_id, &qp_conf,
1574 rte_cryptodev_socket_id(
1575 ts_params->valid_devs[0])),
1577 " rte_cryptodev_queue_pair_setup: num_inflights"
1578 " %u on qp %u on cryptodev %u",
1579 qp_conf.nb_descriptors, qp_id,
1580 ts_params->valid_devs[0]);
1583 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1585 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1586 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1587 ts_params->valid_devs[0], qp_id, &qp_conf,
1588 rte_cryptodev_socket_id(
1589 ts_params->valid_devs[0])),
1591 "rte_cryptodev_queue_pair_setup: num_inflights"
1592 " %u on qp %u on cryptodev %u",
1593 qp_conf.nb_descriptors, qp_id,
1594 ts_params->valid_devs[0]);
1597 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1599 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1600 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1601 ts_params->valid_devs[0], qp_id, &qp_conf,
1602 rte_cryptodev_socket_id(
1603 ts_params->valid_devs[0])),
1605 " rte_cryptodev_queue_pair_setup:"
1606 "num_inflights %u on qp %u on cryptodev %u",
1607 qp_conf.nb_descriptors, qp_id,
1608 ts_params->valid_devs[0]);
1611 /* test invalid queue pair id */
1612 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1614 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1616 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1617 ts_params->valid_devs[0],
1619 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1620 "Failed test for rte_cryptodev_queue_pair_setup:"
1621 "invalid qp %u on cryptodev %u",
1622 qp_id, ts_params->valid_devs[0]);
1624 qp_id = 0xffff; /*invalid*/
1626 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1627 ts_params->valid_devs[0],
1629 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1630 "Failed test for rte_cryptodev_queue_pair_setup:"
1631 "invalid qp %u on cryptodev %u",
1632 qp_id, ts_params->valid_devs[0]);
1634 return TEST_SUCCESS;
1637 /* ***** Plaintext data for tests ***** */
1639 const char catch_22_quote_1[] =
1640 "There was only one catch and that was Catch-22, which "
1641 "specified that a concern for one's safety in the face of "
1642 "dangers that were real and immediate was the process of a "
1643 "rational mind. Orr was crazy and could be grounded. All he "
1644 "had to do was ask; and as soon as he did, he would no longer "
1645 "be crazy and would have to fly more missions. Orr would be "
1646 "crazy to fly more missions and sane if he didn't, but if he "
1647 "was sane he had to fly them. If he flew them he was crazy "
1648 "and didn't have to; but if he didn't want to he was sane and "
1649 "had to. Yossarian was moved very deeply by the absolute "
1650 "simplicity of this clause of Catch-22 and let out a "
1651 "respectful whistle. \"That's some catch, that Catch-22\", he "
1652 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1654 const char catch_22_quote[] =
1655 "What a lousy earth! He wondered how many people were "
1656 "destitute that same night even in his own prosperous country, "
1657 "how many homes were shanties, how many husbands were drunk "
1658 "and wives socked, and how many children were bullied, abused, "
1659 "or abandoned. How many families hungered for food they could "
1660 "not afford to buy? How many hearts were broken? How many "
1661 "suicides would take place that same night, how many people "
1662 "would go insane? How many cockroaches and landlords would "
1663 "triumph? How many winners were losers, successes failures, "
1664 "and rich men poor men? How many wise guys were stupid? How "
1665 "many happy endings were unhappy endings? How many honest men "
1666 "were liars, brave men cowards, loyal men traitors, how many "
1667 "sainted men were corrupt, how many people in positions of "
1668 "trust had sold their souls to bodyguards, how many had never "
1669 "had souls? How many straight-and-narrow paths were crooked "
1670 "paths? How many best families were worst families and how "
1671 "many good people were bad people? When you added them all up "
1672 "and then subtracted, you might be left with only the children, "
1673 "and perhaps with Albert Einstein and an old violinist or "
1674 "sculptor somewhere.";
1676 #define QUOTE_480_BYTES (480)
1677 #define QUOTE_512_BYTES (512)
1678 #define QUOTE_768_BYTES (768)
1679 #define QUOTE_1024_BYTES (1024)
1683 /* ***** SHA1 Hash Tests ***** */
1685 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1687 static uint8_t hmac_sha1_key[] = {
1688 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1689 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1690 0xDE, 0xF4, 0xDE, 0xAD };
1692 /* ***** SHA224 Hash Tests ***** */
1694 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1697 /* ***** AES-CBC Cipher Tests ***** */
1699 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1700 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1702 static uint8_t aes_cbc_key[] = {
1703 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1704 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1706 static uint8_t aes_cbc_iv[] = {
1707 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1708 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1711 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1713 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1714 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1715 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1716 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1717 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1718 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1719 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1720 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1721 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1722 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1723 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1724 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1725 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1726 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1727 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1728 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1729 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1730 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1731 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1732 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1733 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1734 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1735 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1736 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1737 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1738 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1739 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1740 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1741 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1742 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1743 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1744 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1745 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1746 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1747 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1748 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1749 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1750 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1751 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1752 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1753 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1754 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1755 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1756 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1757 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1758 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1759 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1760 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1761 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1762 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1763 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1764 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1765 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1766 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1767 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1768 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1769 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1770 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1771 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1772 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1773 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1774 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1775 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1776 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1777 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1780 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1781 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1782 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1783 0x18, 0x8c, 0x1d, 0x32
1787 /* Multisession Vector context Test */
1788 /*Begin Session 0 */
1789 static uint8_t ms_aes_cbc_key0[] = {
1790 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1791 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1794 static uint8_t ms_aes_cbc_iv0[] = {
1795 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1796 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1799 static const uint8_t ms_aes_cbc_cipher0[] = {
1800 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1801 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1802 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1803 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1804 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1805 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1806 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1807 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1808 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1809 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1810 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1811 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1812 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1813 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1814 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1815 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1816 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1817 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1818 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1819 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1820 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1821 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1822 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1823 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1824 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1825 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1826 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1827 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1828 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1829 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1830 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1831 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1832 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1833 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1834 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1835 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1836 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1837 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1838 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1839 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1840 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1841 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1842 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1843 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1844 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1845 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1846 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1847 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1848 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1849 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1850 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1851 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1852 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1853 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1854 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1855 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1856 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1857 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1858 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1859 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1860 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1861 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1862 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1863 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1867 static uint8_t ms_hmac_key0[] = {
1868 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1869 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1870 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1871 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1872 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1873 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1874 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1875 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1878 static const uint8_t ms_hmac_digest0[] = {
1879 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1880 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1881 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1882 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1883 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1884 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1885 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1886 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1890 /* Begin session 1 */
1892 static uint8_t ms_aes_cbc_key1[] = {
1893 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1894 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1897 static uint8_t ms_aes_cbc_iv1[] = {
1898 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1899 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1902 static const uint8_t ms_aes_cbc_cipher1[] = {
1903 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1904 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1905 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1906 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1907 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1908 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1909 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1910 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1911 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1912 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1913 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1914 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1915 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1916 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1917 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1918 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1919 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1920 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1921 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1922 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1923 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1924 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1925 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1926 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1927 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1928 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1929 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1930 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1931 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1932 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1933 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1934 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1935 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1936 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1937 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1938 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1939 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1940 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1941 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1942 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1943 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1944 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1945 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1946 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1947 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1948 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1949 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1950 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1951 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1952 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1953 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1954 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1955 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1956 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1957 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1958 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1959 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1960 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1961 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1962 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1963 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1964 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1965 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1966 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1970 static uint8_t ms_hmac_key1[] = {
1971 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1972 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1973 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1974 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1975 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1976 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1977 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1978 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1981 static const uint8_t ms_hmac_digest1[] = {
1982 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1983 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1984 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1985 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1986 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1987 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1988 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1989 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1992 /* Begin Session 2 */
1993 static uint8_t ms_aes_cbc_key2[] = {
1994 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1995 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1998 static uint8_t ms_aes_cbc_iv2[] = {
1999 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2000 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2003 static const uint8_t ms_aes_cbc_cipher2[] = {
2004 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2005 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2006 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2007 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2008 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2009 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2010 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2011 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2012 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2013 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2014 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2015 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2016 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2017 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2018 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2019 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2020 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2021 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2022 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2023 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2024 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2025 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2026 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2027 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2028 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2029 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2030 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2031 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2032 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2033 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2034 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2035 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2036 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2037 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2038 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2039 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2040 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2041 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2042 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2043 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2044 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2045 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2046 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2047 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2048 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2049 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2050 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2051 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2052 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2053 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2054 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2055 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2056 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2057 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2058 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2059 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2060 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2061 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2062 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2063 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2064 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2065 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2066 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2067 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2070 static uint8_t ms_hmac_key2[] = {
2071 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2072 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2073 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2074 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2075 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2076 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2077 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2078 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2081 static const uint8_t ms_hmac_digest2[] = {
2082 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2083 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2084 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2085 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2086 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2087 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2088 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2089 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2096 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2098 struct crypto_testsuite_params *ts_params = &testsuite_params;
2099 struct crypto_unittest_params *ut_params = &unittest_params;
2101 /* Verify the capabilities */
2102 struct rte_cryptodev_sym_capability_idx cap_idx;
2103 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2104 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2105 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2107 return TEST_SKIPPED;
2108 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2109 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2110 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2112 return TEST_SKIPPED;
2114 /* Generate test mbuf data and space for digest */
2115 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2116 catch_22_quote, QUOTE_512_BYTES, 0);
2118 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2119 DIGEST_BYTE_LENGTH_SHA1);
2120 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2122 /* Setup Cipher Parameters */
2123 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2124 ut_params->cipher_xform.next = &ut_params->auth_xform;
2126 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2127 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2128 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2129 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2130 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2131 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2133 /* Setup HMAC Parameters */
2134 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2136 ut_params->auth_xform.next = NULL;
2138 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2139 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2140 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2141 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2142 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2144 ut_params->sess = rte_cryptodev_sym_session_create(
2145 ts_params->session_mpool);
2147 /* Create crypto session*/
2148 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2149 ut_params->sess, &ut_params->cipher_xform,
2150 ts_params->session_priv_mpool);
2151 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2153 /* Generate crypto op data structure */
2154 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2155 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2156 TEST_ASSERT_NOT_NULL(ut_params->op,
2157 "Failed to allocate symmetric crypto operation struct");
2159 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2161 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2163 /* set crypto operation source mbuf */
2164 sym_op->m_src = ut_params->ibuf;
2166 /* Set crypto operation authentication parameters */
2167 sym_op->auth.digest.data = ut_params->digest;
2168 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2169 ut_params->ibuf, QUOTE_512_BYTES);
2171 sym_op->auth.data.offset = 0;
2172 sym_op->auth.data.length = QUOTE_512_BYTES;
2174 /* Copy IV at the end of the crypto operation */
2175 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2176 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2178 /* Set crypto operation cipher parameters */
2179 sym_op->cipher.data.offset = 0;
2180 sym_op->cipher.data.length = QUOTE_512_BYTES;
2182 /* Process crypto operation */
2183 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2184 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2187 TEST_ASSERT_NOT_NULL(
2188 process_crypto_request(ts_params->valid_devs[0],
2190 "failed to process sym crypto op");
2192 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2193 "crypto op processing failed");
2196 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2199 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2200 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2202 "ciphertext data not as expected");
2204 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2206 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2207 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2208 gbl_driver_id == rte_cryptodev_driver_id_get(
2209 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2210 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2211 DIGEST_BYTE_LENGTH_SHA1,
2212 "Generated digest data not as expected");
2214 return TEST_SUCCESS;
2217 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2219 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2221 static uint8_t hmac_sha512_key[] = {
2222 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2223 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2224 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2225 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2226 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2227 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2228 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2229 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2231 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2232 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2233 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2234 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2235 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2236 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2237 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2238 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2239 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2244 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2245 struct crypto_unittest_params *ut_params,
2246 uint8_t *cipher_key,
2250 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2251 struct crypto_unittest_params *ut_params,
2252 struct crypto_testsuite_params *ts_params,
2253 const uint8_t *cipher,
2254 const uint8_t *digest,
2259 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2260 struct crypto_unittest_params *ut_params,
2261 uint8_t *cipher_key,
2265 /* Setup Cipher Parameters */
2266 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2267 ut_params->cipher_xform.next = NULL;
2269 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2270 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2271 ut_params->cipher_xform.cipher.key.data = cipher_key;
2272 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2273 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2274 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2276 /* Setup HMAC Parameters */
2277 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2278 ut_params->auth_xform.next = &ut_params->cipher_xform;
2280 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2281 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2282 ut_params->auth_xform.auth.key.data = hmac_key;
2283 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2284 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2286 return TEST_SUCCESS;
2291 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2292 struct crypto_unittest_params *ut_params,
2293 struct crypto_testsuite_params *ts_params,
2294 const uint8_t *cipher,
2295 const uint8_t *digest,
2298 /* Generate test mbuf data and digest */
2299 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2302 QUOTE_512_BYTES, 0);
2304 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2305 DIGEST_BYTE_LENGTH_SHA512);
2306 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2308 rte_memcpy(ut_params->digest,
2310 DIGEST_BYTE_LENGTH_SHA512);
2312 /* Generate Crypto op data structure */
2313 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2314 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2315 TEST_ASSERT_NOT_NULL(ut_params->op,
2316 "Failed to allocate symmetric crypto operation struct");
2318 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2320 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2322 /* set crypto operation source mbuf */
2323 sym_op->m_src = ut_params->ibuf;
2325 sym_op->auth.digest.data = ut_params->digest;
2326 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2327 ut_params->ibuf, QUOTE_512_BYTES);
2329 sym_op->auth.data.offset = 0;
2330 sym_op->auth.data.length = QUOTE_512_BYTES;
2332 /* Copy IV at the end of the crypto operation */
2333 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2334 iv, CIPHER_IV_LENGTH_AES_CBC);
2336 sym_op->cipher.data.offset = 0;
2337 sym_op->cipher.data.length = QUOTE_512_BYTES;
2339 /* Process crypto operation */
2340 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2341 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2343 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2344 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2345 ut_params->op, 1, 1, 0, 0);
2347 TEST_ASSERT_NOT_NULL(
2348 process_crypto_request(ts_params->valid_devs[0],
2350 "failed to process sym crypto op");
2352 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2353 "crypto op processing failed");
2355 ut_params->obuf = ut_params->op->sym->m_src;
2358 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2359 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2362 "Plaintext data not as expected");
2365 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2366 "Digest verification failed");
2368 return TEST_SUCCESS;
2371 /* ***** SNOW 3G Tests ***** */
2373 create_wireless_algo_hash_session(uint8_t dev_id,
2374 const uint8_t *key, const uint8_t key_len,
2375 const uint8_t iv_len, const uint8_t auth_len,
2376 enum rte_crypto_auth_operation op,
2377 enum rte_crypto_auth_algorithm algo)
2379 uint8_t hash_key[key_len];
2382 struct crypto_testsuite_params *ts_params = &testsuite_params;
2383 struct crypto_unittest_params *ut_params = &unittest_params;
2385 memcpy(hash_key, key, key_len);
2387 debug_hexdump(stdout, "key:", key, key_len);
2389 /* Setup Authentication Parameters */
2390 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2391 ut_params->auth_xform.next = NULL;
2393 ut_params->auth_xform.auth.op = op;
2394 ut_params->auth_xform.auth.algo = algo;
2395 ut_params->auth_xform.auth.key.length = key_len;
2396 ut_params->auth_xform.auth.key.data = hash_key;
2397 ut_params->auth_xform.auth.digest_length = auth_len;
2398 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2399 ut_params->auth_xform.auth.iv.length = iv_len;
2400 ut_params->sess = rte_cryptodev_sym_session_create(
2401 ts_params->session_mpool);
2403 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2404 &ut_params->auth_xform,
2405 ts_params->session_priv_mpool);
2406 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2407 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2412 create_wireless_algo_cipher_session(uint8_t dev_id,
2413 enum rte_crypto_cipher_operation op,
2414 enum rte_crypto_cipher_algorithm algo,
2415 const uint8_t *key, const uint8_t key_len,
2418 uint8_t cipher_key[key_len];
2420 struct crypto_testsuite_params *ts_params = &testsuite_params;
2421 struct crypto_unittest_params *ut_params = &unittest_params;
2423 memcpy(cipher_key, key, key_len);
2425 /* Setup Cipher Parameters */
2426 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2427 ut_params->cipher_xform.next = NULL;
2429 ut_params->cipher_xform.cipher.algo = algo;
2430 ut_params->cipher_xform.cipher.op = op;
2431 ut_params->cipher_xform.cipher.key.data = cipher_key;
2432 ut_params->cipher_xform.cipher.key.length = key_len;
2433 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2434 ut_params->cipher_xform.cipher.iv.length = iv_len;
2436 debug_hexdump(stdout, "key:", key, key_len);
2438 /* Create Crypto session */
2439 ut_params->sess = rte_cryptodev_sym_session_create(
2440 ts_params->session_mpool);
2442 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2443 &ut_params->cipher_xform,
2444 ts_params->session_priv_mpool);
2445 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2446 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2451 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2452 unsigned int cipher_len,
2453 unsigned int cipher_offset)
2455 struct crypto_testsuite_params *ts_params = &testsuite_params;
2456 struct crypto_unittest_params *ut_params = &unittest_params;
2458 /* Generate Crypto op data structure */
2459 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2460 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2461 TEST_ASSERT_NOT_NULL(ut_params->op,
2462 "Failed to allocate pktmbuf offload");
2464 /* Set crypto operation data parameters */
2465 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2467 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2469 /* set crypto operation source mbuf */
2470 sym_op->m_src = ut_params->ibuf;
2473 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2475 sym_op->cipher.data.length = cipher_len;
2476 sym_op->cipher.data.offset = cipher_offset;
2481 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2482 unsigned int cipher_len,
2483 unsigned int cipher_offset)
2485 struct crypto_testsuite_params *ts_params = &testsuite_params;
2486 struct crypto_unittest_params *ut_params = &unittest_params;
2488 /* Generate Crypto op data structure */
2489 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2490 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2491 TEST_ASSERT_NOT_NULL(ut_params->op,
2492 "Failed to allocate pktmbuf offload");
2494 /* Set crypto operation data parameters */
2495 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2497 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2499 /* set crypto operation source mbuf */
2500 sym_op->m_src = ut_params->ibuf;
2501 sym_op->m_dst = ut_params->obuf;
2504 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2506 sym_op->cipher.data.length = cipher_len;
2507 sym_op->cipher.data.offset = cipher_offset;
2512 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2513 enum rte_crypto_cipher_operation cipher_op,
2514 enum rte_crypto_auth_operation auth_op,
2515 enum rte_crypto_auth_algorithm auth_algo,
2516 enum rte_crypto_cipher_algorithm cipher_algo,
2517 const uint8_t *key, uint8_t key_len,
2518 uint8_t auth_iv_len, uint8_t auth_len,
2519 uint8_t cipher_iv_len)
2522 uint8_t cipher_auth_key[key_len];
2525 struct crypto_testsuite_params *ts_params = &testsuite_params;
2526 struct crypto_unittest_params *ut_params = &unittest_params;
2528 memcpy(cipher_auth_key, key, key_len);
2530 /* Setup Authentication Parameters */
2531 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2532 ut_params->auth_xform.next = NULL;
2534 ut_params->auth_xform.auth.op = auth_op;
2535 ut_params->auth_xform.auth.algo = auth_algo;
2536 ut_params->auth_xform.auth.key.length = key_len;
2537 /* Hash key = cipher key */
2538 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2539 ut_params->auth_xform.auth.digest_length = auth_len;
2540 /* Auth IV will be after cipher IV */
2541 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2542 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2544 /* Setup Cipher Parameters */
2545 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2546 ut_params->cipher_xform.next = &ut_params->auth_xform;
2548 ut_params->cipher_xform.cipher.algo = cipher_algo;
2549 ut_params->cipher_xform.cipher.op = cipher_op;
2550 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2551 ut_params->cipher_xform.cipher.key.length = key_len;
2552 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2553 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2555 debug_hexdump(stdout, "key:", key, key_len);
2557 /* Create Crypto session*/
2558 ut_params->sess = rte_cryptodev_sym_session_create(
2559 ts_params->session_mpool);
2560 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2562 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2563 &ut_params->cipher_xform,
2564 ts_params->session_priv_mpool);
2565 if (status == -ENOTSUP)
2566 return TEST_SKIPPED;
2568 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2573 create_wireless_cipher_auth_session(uint8_t dev_id,
2574 enum rte_crypto_cipher_operation cipher_op,
2575 enum rte_crypto_auth_operation auth_op,
2576 enum rte_crypto_auth_algorithm auth_algo,
2577 enum rte_crypto_cipher_algorithm cipher_algo,
2578 const struct wireless_test_data *tdata)
2580 const uint8_t key_len = tdata->key.len;
2581 uint8_t cipher_auth_key[key_len];
2584 struct crypto_testsuite_params *ts_params = &testsuite_params;
2585 struct crypto_unittest_params *ut_params = &unittest_params;
2586 const uint8_t *key = tdata->key.data;
2587 const uint8_t auth_len = tdata->digest.len;
2588 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2589 uint8_t auth_iv_len = tdata->auth_iv.len;
2591 memcpy(cipher_auth_key, key, key_len);
2593 /* Setup Authentication Parameters */
2594 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2595 ut_params->auth_xform.next = NULL;
2597 ut_params->auth_xform.auth.op = auth_op;
2598 ut_params->auth_xform.auth.algo = auth_algo;
2599 ut_params->auth_xform.auth.key.length = key_len;
2600 /* Hash key = cipher key */
2601 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2602 ut_params->auth_xform.auth.digest_length = auth_len;
2603 /* Auth IV will be after cipher IV */
2604 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2605 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2607 /* Setup Cipher Parameters */
2608 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2609 ut_params->cipher_xform.next = &ut_params->auth_xform;
2611 ut_params->cipher_xform.cipher.algo = cipher_algo;
2612 ut_params->cipher_xform.cipher.op = cipher_op;
2613 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2614 ut_params->cipher_xform.cipher.key.length = key_len;
2615 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2616 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2619 debug_hexdump(stdout, "key:", key, key_len);
2621 /* Create Crypto session*/
2622 ut_params->sess = rte_cryptodev_sym_session_create(
2623 ts_params->session_mpool);
2625 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2626 &ut_params->cipher_xform,
2627 ts_params->session_priv_mpool);
2628 if (status == -ENOTSUP)
2629 return TEST_SKIPPED;
2631 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2632 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2637 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2638 const struct wireless_test_data *tdata)
2640 return create_wireless_cipher_auth_session(dev_id,
2641 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2642 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2643 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2647 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2648 enum rte_crypto_cipher_operation cipher_op,
2649 enum rte_crypto_auth_operation auth_op,
2650 enum rte_crypto_auth_algorithm auth_algo,
2651 enum rte_crypto_cipher_algorithm cipher_algo,
2652 const uint8_t *key, const uint8_t key_len,
2653 uint8_t auth_iv_len, uint8_t auth_len,
2654 uint8_t cipher_iv_len)
2656 uint8_t auth_cipher_key[key_len];
2658 struct crypto_testsuite_params *ts_params = &testsuite_params;
2659 struct crypto_unittest_params *ut_params = &unittest_params;
2661 memcpy(auth_cipher_key, key, key_len);
2663 /* Setup Authentication Parameters */
2664 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2665 ut_params->auth_xform.auth.op = auth_op;
2666 ut_params->auth_xform.next = &ut_params->cipher_xform;
2667 ut_params->auth_xform.auth.algo = auth_algo;
2668 ut_params->auth_xform.auth.key.length = key_len;
2669 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2670 ut_params->auth_xform.auth.digest_length = auth_len;
2671 /* Auth IV will be after cipher IV */
2672 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2673 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2675 /* Setup Cipher Parameters */
2676 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2677 ut_params->cipher_xform.next = NULL;
2678 ut_params->cipher_xform.cipher.algo = cipher_algo;
2679 ut_params->cipher_xform.cipher.op = cipher_op;
2680 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2681 ut_params->cipher_xform.cipher.key.length = key_len;
2682 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2683 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2685 debug_hexdump(stdout, "key:", key, key_len);
2687 /* Create Crypto session*/
2688 ut_params->sess = rte_cryptodev_sym_session_create(
2689 ts_params->session_mpool);
2690 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2692 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2693 ut_params->auth_xform.next = NULL;
2694 ut_params->cipher_xform.next = &ut_params->auth_xform;
2695 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2696 &ut_params->cipher_xform,
2697 ts_params->session_priv_mpool);
2700 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2701 &ut_params->auth_xform,
2702 ts_params->session_priv_mpool);
2704 if (status == -ENOTSUP)
2705 return TEST_SKIPPED;
2707 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2713 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2714 unsigned int auth_tag_len,
2715 const uint8_t *iv, unsigned int iv_len,
2716 unsigned int data_pad_len,
2717 enum rte_crypto_auth_operation op,
2718 unsigned int auth_len, unsigned int auth_offset)
2720 struct crypto_testsuite_params *ts_params = &testsuite_params;
2722 struct crypto_unittest_params *ut_params = &unittest_params;
2724 /* Generate Crypto op data structure */
2725 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2726 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2727 TEST_ASSERT_NOT_NULL(ut_params->op,
2728 "Failed to allocate pktmbuf offload");
2730 /* Set crypto operation data parameters */
2731 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2733 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2735 /* set crypto operation source mbuf */
2736 sym_op->m_src = ut_params->ibuf;
2739 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2742 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2743 ut_params->ibuf, auth_tag_len);
2745 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2746 "no room to append auth tag");
2747 ut_params->digest = sym_op->auth.digest.data;
2748 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2749 ut_params->ibuf, data_pad_len);
2750 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2751 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2753 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2755 debug_hexdump(stdout, "digest:",
2756 sym_op->auth.digest.data,
2759 sym_op->auth.data.length = auth_len;
2760 sym_op->auth.data.offset = auth_offset;
2766 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2767 enum rte_crypto_auth_operation op)
2769 struct crypto_testsuite_params *ts_params = &testsuite_params;
2770 struct crypto_unittest_params *ut_params = &unittest_params;
2772 const uint8_t *auth_tag = tdata->digest.data;
2773 const unsigned int auth_tag_len = tdata->digest.len;
2774 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2775 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2777 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2778 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2779 const uint8_t *auth_iv = tdata->auth_iv.data;
2780 const uint8_t auth_iv_len = tdata->auth_iv.len;
2781 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2782 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2784 /* Generate Crypto op data structure */
2785 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2786 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2787 TEST_ASSERT_NOT_NULL(ut_params->op,
2788 "Failed to allocate pktmbuf offload");
2789 /* Set crypto operation data parameters */
2790 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2792 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2794 /* set crypto operation source mbuf */
2795 sym_op->m_src = ut_params->ibuf;
2798 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2799 ut_params->ibuf, auth_tag_len);
2801 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2802 "no room to append auth tag");
2803 ut_params->digest = sym_op->auth.digest.data;
2804 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2805 ut_params->ibuf, data_pad_len);
2806 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2807 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2809 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2811 debug_hexdump(stdout, "digest:",
2812 sym_op->auth.digest.data,
2815 /* Copy cipher and auth IVs at the end of the crypto operation */
2816 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2818 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2819 iv_ptr += cipher_iv_len;
2820 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2822 sym_op->cipher.data.length = cipher_len;
2823 sym_op->cipher.data.offset = 0;
2824 sym_op->auth.data.length = auth_len;
2825 sym_op->auth.data.offset = 0;
2831 create_zuc_cipher_hash_generate_operation(
2832 const struct wireless_test_data *tdata)
2834 return create_wireless_cipher_hash_operation(tdata,
2835 RTE_CRYPTO_AUTH_OP_GENERATE);
2839 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2840 const unsigned auth_tag_len,
2841 const uint8_t *auth_iv, uint8_t auth_iv_len,
2842 unsigned data_pad_len,
2843 enum rte_crypto_auth_operation op,
2844 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2845 const unsigned cipher_len, const unsigned cipher_offset,
2846 const unsigned auth_len, const unsigned auth_offset)
2848 struct crypto_testsuite_params *ts_params = &testsuite_params;
2849 struct crypto_unittest_params *ut_params = &unittest_params;
2851 enum rte_crypto_cipher_algorithm cipher_algo =
2852 ut_params->cipher_xform.cipher.algo;
2853 enum rte_crypto_auth_algorithm auth_algo =
2854 ut_params->auth_xform.auth.algo;
2856 /* Generate Crypto op data structure */
2857 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2858 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2859 TEST_ASSERT_NOT_NULL(ut_params->op,
2860 "Failed to allocate pktmbuf offload");
2861 /* Set crypto operation data parameters */
2862 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2864 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2866 /* set crypto operation source mbuf */
2867 sym_op->m_src = ut_params->ibuf;
2870 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2871 ut_params->ibuf, auth_tag_len);
2873 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2874 "no room to append auth tag");
2875 ut_params->digest = sym_op->auth.digest.data;
2877 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2878 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2879 ut_params->ibuf, data_pad_len);
2881 struct rte_mbuf *m = ut_params->ibuf;
2882 unsigned int offset = data_pad_len;
2884 while (offset > m->data_len && m->next != NULL) {
2885 offset -= m->data_len;
2888 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2892 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2893 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2895 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2897 debug_hexdump(stdout, "digest:",
2898 sym_op->auth.digest.data,
2901 /* Copy cipher and auth IVs at the end of the crypto operation */
2902 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2904 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2905 iv_ptr += cipher_iv_len;
2906 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2908 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2909 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2910 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2911 sym_op->cipher.data.length = cipher_len;
2912 sym_op->cipher.data.offset = cipher_offset;
2914 sym_op->cipher.data.length = cipher_len >> 3;
2915 sym_op->cipher.data.offset = cipher_offset >> 3;
2918 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2919 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2920 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2921 sym_op->auth.data.length = auth_len;
2922 sym_op->auth.data.offset = auth_offset;
2924 sym_op->auth.data.length = auth_len >> 3;
2925 sym_op->auth.data.offset = auth_offset >> 3;
2932 create_wireless_algo_auth_cipher_operation(
2933 const uint8_t *auth_tag, unsigned int auth_tag_len,
2934 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2935 const uint8_t *auth_iv, uint8_t auth_iv_len,
2936 unsigned int data_pad_len,
2937 unsigned int cipher_len, unsigned int cipher_offset,
2938 unsigned int auth_len, unsigned int auth_offset,
2939 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2941 struct crypto_testsuite_params *ts_params = &testsuite_params;
2942 struct crypto_unittest_params *ut_params = &unittest_params;
2944 enum rte_crypto_cipher_algorithm cipher_algo =
2945 ut_params->cipher_xform.cipher.algo;
2946 enum rte_crypto_auth_algorithm auth_algo =
2947 ut_params->auth_xform.auth.algo;
2949 /* Generate Crypto op data structure */
2950 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2951 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2952 TEST_ASSERT_NOT_NULL(ut_params->op,
2953 "Failed to allocate pktmbuf offload");
2955 /* Set crypto operation data parameters */
2956 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2958 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2960 /* set crypto operation mbufs */
2961 sym_op->m_src = ut_params->ibuf;
2962 if (op_mode == OUT_OF_PLACE)
2963 sym_op->m_dst = ut_params->obuf;
2967 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2968 (op_mode == IN_PLACE ?
2969 ut_params->ibuf : ut_params->obuf),
2970 uint8_t *, data_pad_len);
2971 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2972 (op_mode == IN_PLACE ?
2973 ut_params->ibuf : ut_params->obuf),
2975 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2977 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2978 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2979 sym_op->m_src : sym_op->m_dst);
2980 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2981 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2982 sgl_buf = sgl_buf->next;
2984 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2985 uint8_t *, remaining_off);
2986 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2988 memset(sym_op->auth.digest.data, 0, remaining_off);
2989 while (sgl_buf->next != NULL) {
2990 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2991 0, rte_pktmbuf_data_len(sgl_buf));
2992 sgl_buf = sgl_buf->next;
2996 /* Copy digest for the verification */
2998 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3000 /* Copy cipher and auth IVs at the end of the crypto operation */
3001 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3002 ut_params->op, uint8_t *, IV_OFFSET);
3004 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3005 iv_ptr += cipher_iv_len;
3006 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3008 /* Only copy over the offset data needed from src to dst in OOP,
3009 * if the auth and cipher offsets are not aligned
3011 if (op_mode == OUT_OF_PLACE) {
3012 if (cipher_offset > auth_offset)
3014 rte_pktmbuf_mtod_offset(
3016 uint8_t *, auth_offset >> 3),
3017 rte_pktmbuf_mtod_offset(
3019 uint8_t *, auth_offset >> 3),
3020 ((cipher_offset >> 3) - (auth_offset >> 3)));
3023 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3024 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3025 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3026 sym_op->cipher.data.length = cipher_len;
3027 sym_op->cipher.data.offset = cipher_offset;
3029 sym_op->cipher.data.length = cipher_len >> 3;
3030 sym_op->cipher.data.offset = cipher_offset >> 3;
3033 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3034 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3035 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3036 sym_op->auth.data.length = auth_len;
3037 sym_op->auth.data.offset = auth_offset;
3039 sym_op->auth.data.length = auth_len >> 3;
3040 sym_op->auth.data.offset = auth_offset >> 3;
3047 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3049 struct crypto_testsuite_params *ts_params = &testsuite_params;
3050 struct crypto_unittest_params *ut_params = &unittest_params;
3053 unsigned plaintext_pad_len;
3054 unsigned plaintext_len;
3056 struct rte_cryptodev_info dev_info;
3058 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3059 uint64_t feat_flags = dev_info.feature_flags;
3061 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3062 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3063 printf("Device doesn't support NON-Byte Aligned Data.\n");
3064 return TEST_SKIPPED;
3067 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3068 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3069 printf("Device doesn't support RAW data-path APIs.\n");
3070 return TEST_SKIPPED;
3073 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3074 return TEST_SKIPPED;
3076 /* Verify the capabilities */
3077 struct rte_cryptodev_sym_capability_idx cap_idx;
3078 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3079 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3080 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3082 return TEST_SKIPPED;
3084 /* Create SNOW 3G session */
3085 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3086 tdata->key.data, tdata->key.len,
3087 tdata->auth_iv.len, tdata->digest.len,
3088 RTE_CRYPTO_AUTH_OP_GENERATE,
3089 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3093 /* alloc mbuf and set payload */
3094 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3096 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3097 rte_pktmbuf_tailroom(ut_params->ibuf));
3099 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3100 /* Append data which is padded to a multiple of */
3101 /* the algorithms block size */
3102 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3103 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3105 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3107 /* Create SNOW 3G operation */
3108 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3109 tdata->auth_iv.data, tdata->auth_iv.len,
3110 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3111 tdata->validAuthLenInBits.len,
3116 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3117 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3118 ut_params->op, 0, 1, 1, 0);
3120 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3122 ut_params->obuf = ut_params->op->sym->m_src;
3123 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3124 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3125 + plaintext_pad_len;
3128 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3131 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3132 "SNOW 3G Generated auth tag not as expected");
3138 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3140 struct crypto_testsuite_params *ts_params = &testsuite_params;
3141 struct crypto_unittest_params *ut_params = &unittest_params;
3144 unsigned plaintext_pad_len;
3145 unsigned plaintext_len;
3147 struct rte_cryptodev_info dev_info;
3149 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3150 uint64_t feat_flags = dev_info.feature_flags;
3152 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3153 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3154 printf("Device doesn't support NON-Byte Aligned Data.\n");
3155 return TEST_SKIPPED;
3158 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3159 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3160 printf("Device doesn't support RAW data-path APIs.\n");
3161 return TEST_SKIPPED;
3164 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3165 return TEST_SKIPPED;
3167 /* Verify the capabilities */
3168 struct rte_cryptodev_sym_capability_idx cap_idx;
3169 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3170 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3171 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3173 return TEST_SKIPPED;
3175 /* Create SNOW 3G session */
3176 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3177 tdata->key.data, tdata->key.len,
3178 tdata->auth_iv.len, tdata->digest.len,
3179 RTE_CRYPTO_AUTH_OP_VERIFY,
3180 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3183 /* alloc mbuf and set payload */
3184 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3186 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3187 rte_pktmbuf_tailroom(ut_params->ibuf));
3189 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3190 /* Append data which is padded to a multiple of */
3191 /* the algorithms block size */
3192 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3193 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3195 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3197 /* Create SNOW 3G operation */
3198 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3200 tdata->auth_iv.data, tdata->auth_iv.len,
3202 RTE_CRYPTO_AUTH_OP_VERIFY,
3203 tdata->validAuthLenInBits.len,
3208 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3209 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3210 ut_params->op, 0, 1, 1, 0);
3212 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3214 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3215 ut_params->obuf = ut_params->op->sym->m_src;
3216 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3217 + plaintext_pad_len;
3220 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3229 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3231 struct crypto_testsuite_params *ts_params = &testsuite_params;
3232 struct crypto_unittest_params *ut_params = &unittest_params;
3235 unsigned plaintext_pad_len;
3236 unsigned plaintext_len;
3238 struct rte_cryptodev_info dev_info;
3240 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3241 uint64_t feat_flags = dev_info.feature_flags;
3243 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3244 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3245 printf("Device doesn't support RAW data-path APIs.\n");
3246 return TEST_SKIPPED;
3249 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3250 return TEST_SKIPPED;
3252 /* Verify the capabilities */
3253 struct rte_cryptodev_sym_capability_idx cap_idx;
3254 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3255 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3256 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3258 return TEST_SKIPPED;
3260 /* Create KASUMI session */
3261 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3262 tdata->key.data, tdata->key.len,
3263 0, tdata->digest.len,
3264 RTE_CRYPTO_AUTH_OP_GENERATE,
3265 RTE_CRYPTO_AUTH_KASUMI_F9);
3269 /* alloc mbuf and set payload */
3270 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3272 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3273 rte_pktmbuf_tailroom(ut_params->ibuf));
3275 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3276 /* Append data which is padded to a multiple of */
3277 /* the algorithms block size */
3278 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3279 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3281 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3283 /* Create KASUMI operation */
3284 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3286 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3287 tdata->plaintext.len,
3292 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3293 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3295 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3296 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3297 ut_params->op, 0, 1, 1, 0);
3299 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3302 ut_params->obuf = ut_params->op->sym->m_src;
3303 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3304 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3305 + plaintext_pad_len;
3308 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3311 DIGEST_BYTE_LENGTH_KASUMI_F9,
3312 "KASUMI Generated auth tag not as expected");
3318 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3320 struct crypto_testsuite_params *ts_params = &testsuite_params;
3321 struct crypto_unittest_params *ut_params = &unittest_params;
3324 unsigned plaintext_pad_len;
3325 unsigned plaintext_len;
3327 struct rte_cryptodev_info dev_info;
3329 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3330 uint64_t feat_flags = dev_info.feature_flags;
3332 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3333 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3334 printf("Device doesn't support RAW data-path APIs.\n");
3335 return TEST_SKIPPED;
3338 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3339 return TEST_SKIPPED;
3341 /* Verify the capabilities */
3342 struct rte_cryptodev_sym_capability_idx cap_idx;
3343 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3344 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3345 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3347 return TEST_SKIPPED;
3349 /* Create KASUMI session */
3350 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3351 tdata->key.data, tdata->key.len,
3352 0, tdata->digest.len,
3353 RTE_CRYPTO_AUTH_OP_VERIFY,
3354 RTE_CRYPTO_AUTH_KASUMI_F9);
3357 /* alloc mbuf and set payload */
3358 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3360 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3361 rte_pktmbuf_tailroom(ut_params->ibuf));
3363 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3364 /* Append data which is padded to a multiple */
3365 /* of the algorithms block size */
3366 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3367 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3369 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3371 /* Create KASUMI operation */
3372 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3376 RTE_CRYPTO_AUTH_OP_VERIFY,
3377 tdata->plaintext.len,
3382 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3383 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3384 ut_params->op, 0, 1, 1, 0);
3386 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3388 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3389 ut_params->obuf = ut_params->op->sym->m_src;
3390 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3391 + plaintext_pad_len;
3394 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3403 test_snow3g_hash_generate_test_case_1(void)
3405 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3409 test_snow3g_hash_generate_test_case_2(void)
3411 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3415 test_snow3g_hash_generate_test_case_3(void)
3417 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3421 test_snow3g_hash_generate_test_case_4(void)
3423 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3427 test_snow3g_hash_generate_test_case_5(void)
3429 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3433 test_snow3g_hash_generate_test_case_6(void)
3435 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3439 test_snow3g_hash_verify_test_case_1(void)
3441 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3446 test_snow3g_hash_verify_test_case_2(void)
3448 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3452 test_snow3g_hash_verify_test_case_3(void)
3454 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3458 test_snow3g_hash_verify_test_case_4(void)
3460 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3464 test_snow3g_hash_verify_test_case_5(void)
3466 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3470 test_snow3g_hash_verify_test_case_6(void)
3472 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3476 test_kasumi_hash_generate_test_case_1(void)
3478 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3482 test_kasumi_hash_generate_test_case_2(void)
3484 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3488 test_kasumi_hash_generate_test_case_3(void)
3490 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3494 test_kasumi_hash_generate_test_case_4(void)
3496 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3500 test_kasumi_hash_generate_test_case_5(void)
3502 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3506 test_kasumi_hash_generate_test_case_6(void)
3508 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3512 test_kasumi_hash_verify_test_case_1(void)
3514 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3518 test_kasumi_hash_verify_test_case_2(void)
3520 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3524 test_kasumi_hash_verify_test_case_3(void)
3526 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3530 test_kasumi_hash_verify_test_case_4(void)
3532 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3536 test_kasumi_hash_verify_test_case_5(void)
3538 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3542 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3544 struct crypto_testsuite_params *ts_params = &testsuite_params;
3545 struct crypto_unittest_params *ut_params = &unittest_params;
3548 uint8_t *plaintext, *ciphertext;
3549 unsigned plaintext_pad_len;
3550 unsigned plaintext_len;
3551 struct rte_cryptodev_info dev_info;
3553 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3554 uint64_t feat_flags = dev_info.feature_flags;
3556 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3557 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3558 printf("Device doesn't support RAW data-path APIs.\n");
3559 return TEST_SKIPPED;
3562 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3563 return TEST_SKIPPED;
3565 /* Verify the capabilities */
3566 struct rte_cryptodev_sym_capability_idx cap_idx;
3567 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3568 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3569 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3571 return TEST_SKIPPED;
3573 /* Create KASUMI session */
3574 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3575 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3576 RTE_CRYPTO_CIPHER_KASUMI_F8,
3577 tdata->key.data, tdata->key.len,
3578 tdata->cipher_iv.len);
3582 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3584 /* Clear mbuf payload */
3585 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3586 rte_pktmbuf_tailroom(ut_params->ibuf));
3588 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3589 /* Append data which is padded to a multiple */
3590 /* of the algorithms block size */
3591 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3592 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3594 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3596 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3598 /* Create KASUMI operation */
3599 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3600 tdata->cipher_iv.len,
3601 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3602 tdata->validCipherOffsetInBits.len);
3606 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3607 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3608 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3610 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3612 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3614 ut_params->obuf = ut_params->op->sym->m_dst;
3615 if (ut_params->obuf)
3616 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3618 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3620 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3622 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3623 (tdata->validCipherOffsetInBits.len >> 3);
3625 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3627 reference_ciphertext,
3628 tdata->validCipherLenInBits.len,
3629 "KASUMI Ciphertext data not as expected");
3634 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3636 struct crypto_testsuite_params *ts_params = &testsuite_params;
3637 struct crypto_unittest_params *ut_params = &unittest_params;
3641 unsigned int plaintext_pad_len;
3642 unsigned int plaintext_len;
3644 uint8_t buffer[10000];
3645 const uint8_t *ciphertext;
3647 struct rte_cryptodev_info dev_info;
3649 /* Verify the capabilities */
3650 struct rte_cryptodev_sym_capability_idx cap_idx;
3651 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3652 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3653 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3655 return TEST_SKIPPED;
3657 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3659 uint64_t feat_flags = dev_info.feature_flags;
3661 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3662 printf("Device doesn't support in-place scatter-gather. "
3664 return TEST_SKIPPED;
3667 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3668 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3669 printf("Device doesn't support RAW data-path APIs.\n");
3670 return TEST_SKIPPED;
3673 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3674 return TEST_SKIPPED;
3676 /* Create KASUMI session */
3677 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3678 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3679 RTE_CRYPTO_CIPHER_KASUMI_F8,
3680 tdata->key.data, tdata->key.len,
3681 tdata->cipher_iv.len);
3685 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3688 /* Append data which is padded to a multiple */
3689 /* of the algorithms block size */
3690 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3692 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3693 plaintext_pad_len, 10, 0);
3695 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3697 /* Create KASUMI operation */
3698 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3699 tdata->cipher_iv.len,
3700 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3701 tdata->validCipherOffsetInBits.len);
3705 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3706 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3707 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3709 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3711 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3713 ut_params->obuf = ut_params->op->sym->m_dst;
3715 if (ut_params->obuf)
3716 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3717 plaintext_len, buffer);
3719 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3720 tdata->validCipherOffsetInBits.len >> 3,
3721 plaintext_len, buffer);
3724 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3726 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3727 (tdata->validCipherOffsetInBits.len >> 3);
3729 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3731 reference_ciphertext,
3732 tdata->validCipherLenInBits.len,
3733 "KASUMI Ciphertext data not as expected");
3738 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3740 struct crypto_testsuite_params *ts_params = &testsuite_params;
3741 struct crypto_unittest_params *ut_params = &unittest_params;
3744 uint8_t *plaintext, *ciphertext;
3745 unsigned plaintext_pad_len;
3746 unsigned plaintext_len;
3748 /* Verify the capabilities */
3749 struct rte_cryptodev_sym_capability_idx cap_idx;
3750 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3751 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3752 /* Data-path service does not support OOP */
3753 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3755 return TEST_SKIPPED;
3757 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3758 return TEST_SKIPPED;
3760 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3761 return TEST_SKIPPED;
3763 /* Create KASUMI session */
3764 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3765 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3766 RTE_CRYPTO_CIPHER_KASUMI_F8,
3767 tdata->key.data, tdata->key.len,
3768 tdata->cipher_iv.len);
3772 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3773 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3775 /* Clear mbuf payload */
3776 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3777 rte_pktmbuf_tailroom(ut_params->ibuf));
3779 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3780 /* Append data which is padded to a multiple */
3781 /* of the algorithms block size */
3782 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3783 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3785 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3786 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3788 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3790 /* Create KASUMI operation */
3791 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3792 tdata->cipher_iv.len,
3793 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3794 tdata->validCipherOffsetInBits.len);
3798 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3800 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3802 ut_params->obuf = ut_params->op->sym->m_dst;
3803 if (ut_params->obuf)
3804 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3806 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3808 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3810 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3811 (tdata->validCipherOffsetInBits.len >> 3);
3813 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3815 reference_ciphertext,
3816 tdata->validCipherLenInBits.len,
3817 "KASUMI Ciphertext data not as expected");
3822 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3824 struct crypto_testsuite_params *ts_params = &testsuite_params;
3825 struct crypto_unittest_params *ut_params = &unittest_params;
3828 unsigned int plaintext_pad_len;
3829 unsigned int plaintext_len;
3831 const uint8_t *ciphertext;
3832 uint8_t buffer[2048];
3834 struct rte_cryptodev_info dev_info;
3836 /* Verify the capabilities */
3837 struct rte_cryptodev_sym_capability_idx cap_idx;
3838 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3839 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3840 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3842 return TEST_SKIPPED;
3844 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3845 return TEST_SKIPPED;
3847 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3848 return TEST_SKIPPED;
3850 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3852 uint64_t feat_flags = dev_info.feature_flags;
3853 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3854 printf("Device doesn't support out-of-place scatter-gather "
3855 "in both input and output mbufs. "
3857 return TEST_SKIPPED;
3860 /* Create KASUMI session */
3861 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3862 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3863 RTE_CRYPTO_CIPHER_KASUMI_F8,
3864 tdata->key.data, tdata->key.len,
3865 tdata->cipher_iv.len);
3869 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3870 /* Append data which is padded to a multiple */
3871 /* of the algorithms block size */
3872 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3874 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3875 plaintext_pad_len, 10, 0);
3876 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3877 plaintext_pad_len, 3, 0);
3879 /* Append data which is padded to a multiple */
3880 /* of the algorithms block size */
3881 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3883 /* Create KASUMI operation */
3884 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3885 tdata->cipher_iv.len,
3886 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3887 tdata->validCipherOffsetInBits.len);
3891 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3893 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3895 ut_params->obuf = ut_params->op->sym->m_dst;
3896 if (ut_params->obuf)
3897 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3898 plaintext_pad_len, buffer);
3900 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3901 tdata->validCipherOffsetInBits.len >> 3,
3902 plaintext_pad_len, buffer);
3904 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3905 (tdata->validCipherOffsetInBits.len >> 3);
3907 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3909 reference_ciphertext,
3910 tdata->validCipherLenInBits.len,
3911 "KASUMI Ciphertext data not as expected");
3917 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3919 struct crypto_testsuite_params *ts_params = &testsuite_params;
3920 struct crypto_unittest_params *ut_params = &unittest_params;
3923 uint8_t *ciphertext, *plaintext;
3924 unsigned ciphertext_pad_len;
3925 unsigned ciphertext_len;
3927 /* Verify the capabilities */
3928 struct rte_cryptodev_sym_capability_idx cap_idx;
3929 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3930 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3931 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3933 return TEST_SKIPPED;
3935 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3936 return TEST_SKIPPED;
3938 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3939 return TEST_SKIPPED;
3941 /* Create KASUMI session */
3942 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3943 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3944 RTE_CRYPTO_CIPHER_KASUMI_F8,
3945 tdata->key.data, tdata->key.len,
3946 tdata->cipher_iv.len);
3950 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3951 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3953 /* Clear mbuf payload */
3954 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3955 rte_pktmbuf_tailroom(ut_params->ibuf));
3957 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3958 /* Append data which is padded to a multiple */
3959 /* of the algorithms block size */
3960 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3961 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3962 ciphertext_pad_len);
3963 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3964 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3966 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3968 /* Create KASUMI operation */
3969 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3970 tdata->cipher_iv.len,
3971 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3972 tdata->validCipherOffsetInBits.len);
3976 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3978 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3980 ut_params->obuf = ut_params->op->sym->m_dst;
3981 if (ut_params->obuf)
3982 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3984 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3986 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3988 const uint8_t *reference_plaintext = tdata->plaintext.data +
3989 (tdata->validCipherOffsetInBits.len >> 3);
3991 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3993 reference_plaintext,
3994 tdata->validCipherLenInBits.len,
3995 "KASUMI Plaintext data not as expected");
4000 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4002 struct crypto_testsuite_params *ts_params = &testsuite_params;
4003 struct crypto_unittest_params *ut_params = &unittest_params;
4006 uint8_t *ciphertext, *plaintext;
4007 unsigned ciphertext_pad_len;
4008 unsigned ciphertext_len;
4009 struct rte_cryptodev_info dev_info;
4011 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4012 uint64_t feat_flags = dev_info.feature_flags;
4014 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4015 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4016 printf("Device doesn't support RAW data-path APIs.\n");
4017 return TEST_SKIPPED;
4020 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4021 return TEST_SKIPPED;
4023 /* Verify the capabilities */
4024 struct rte_cryptodev_sym_capability_idx cap_idx;
4025 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4026 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4027 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4029 return TEST_SKIPPED;
4031 /* Create KASUMI session */
4032 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4033 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4034 RTE_CRYPTO_CIPHER_KASUMI_F8,
4035 tdata->key.data, tdata->key.len,
4036 tdata->cipher_iv.len);
4040 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4042 /* Clear mbuf payload */
4043 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4044 rte_pktmbuf_tailroom(ut_params->ibuf));
4046 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4047 /* Append data which is padded to a multiple */
4048 /* of the algorithms block size */
4049 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4050 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4051 ciphertext_pad_len);
4052 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4054 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4056 /* Create KASUMI operation */
4057 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4058 tdata->cipher_iv.len,
4059 tdata->ciphertext.len,
4060 tdata->validCipherOffsetInBits.len);
4064 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4065 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4066 ut_params->op, 1, 0, 1, 0);
4068 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4070 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4072 ut_params->obuf = ut_params->op->sym->m_dst;
4073 if (ut_params->obuf)
4074 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4076 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4078 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4080 const uint8_t *reference_plaintext = tdata->plaintext.data +
4081 (tdata->validCipherOffsetInBits.len >> 3);
4083 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4085 reference_plaintext,
4086 tdata->validCipherLenInBits.len,
4087 "KASUMI Plaintext data not as expected");
4092 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4094 struct crypto_testsuite_params *ts_params = &testsuite_params;
4095 struct crypto_unittest_params *ut_params = &unittest_params;
4098 uint8_t *plaintext, *ciphertext;
4099 unsigned plaintext_pad_len;
4100 unsigned plaintext_len;
4101 struct rte_cryptodev_info dev_info;
4103 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4104 uint64_t feat_flags = dev_info.feature_flags;
4106 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4107 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4108 printf("Device doesn't support RAW data-path APIs.\n");
4109 return TEST_SKIPPED;
4112 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4113 return TEST_SKIPPED;
4115 /* Verify the capabilities */
4116 struct rte_cryptodev_sym_capability_idx cap_idx;
4117 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4118 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4119 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4121 return TEST_SKIPPED;
4123 /* Create SNOW 3G session */
4124 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4125 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4126 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4127 tdata->key.data, tdata->key.len,
4128 tdata->cipher_iv.len);
4132 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4134 /* Clear mbuf payload */
4135 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4136 rte_pktmbuf_tailroom(ut_params->ibuf));
4138 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4139 /* Append data which is padded to a multiple of */
4140 /* the algorithms block size */
4141 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4142 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4144 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4146 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4148 /* Create SNOW 3G operation */
4149 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4150 tdata->cipher_iv.len,
4151 tdata->validCipherLenInBits.len,
4156 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4157 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4158 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4160 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4162 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4164 ut_params->obuf = ut_params->op->sym->m_dst;
4165 if (ut_params->obuf)
4166 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4168 ciphertext = plaintext;
4170 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4173 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4175 tdata->ciphertext.data,
4176 tdata->validDataLenInBits.len,
4177 "SNOW 3G Ciphertext data not as expected");
4183 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4185 struct crypto_testsuite_params *ts_params = &testsuite_params;
4186 struct crypto_unittest_params *ut_params = &unittest_params;
4187 uint8_t *plaintext, *ciphertext;
4190 unsigned plaintext_pad_len;
4191 unsigned plaintext_len;
4193 /* Verify the capabilities */
4194 struct rte_cryptodev_sym_capability_idx cap_idx;
4195 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4196 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4197 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4199 return TEST_SKIPPED;
4201 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4202 return TEST_SKIPPED;
4204 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4205 return TEST_SKIPPED;
4207 /* Create SNOW 3G session */
4208 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4209 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4210 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4211 tdata->key.data, tdata->key.len,
4212 tdata->cipher_iv.len);
4216 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4217 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4219 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4220 "Failed to allocate input buffer in mempool");
4221 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4222 "Failed to allocate output buffer in mempool");
4224 /* Clear mbuf payload */
4225 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4226 rte_pktmbuf_tailroom(ut_params->ibuf));
4228 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4229 /* Append data which is padded to a multiple of */
4230 /* the algorithms block size */
4231 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4232 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4234 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4235 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4237 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4239 /* Create SNOW 3G operation */
4240 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4241 tdata->cipher_iv.len,
4242 tdata->validCipherLenInBits.len,
4247 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4249 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4251 ut_params->obuf = ut_params->op->sym->m_dst;
4252 if (ut_params->obuf)
4253 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4255 ciphertext = plaintext;
4257 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4260 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4262 tdata->ciphertext.data,
4263 tdata->validDataLenInBits.len,
4264 "SNOW 3G Ciphertext data not as expected");
4269 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4271 struct crypto_testsuite_params *ts_params = &testsuite_params;
4272 struct crypto_unittest_params *ut_params = &unittest_params;
4275 unsigned int plaintext_pad_len;
4276 unsigned int plaintext_len;
4277 uint8_t buffer[10000];
4278 const uint8_t *ciphertext;
4280 struct rte_cryptodev_info dev_info;
4282 /* Verify the capabilities */
4283 struct rte_cryptodev_sym_capability_idx cap_idx;
4284 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4285 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4286 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4288 return TEST_SKIPPED;
4290 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4291 return TEST_SKIPPED;
4293 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4294 return TEST_SKIPPED;
4296 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4298 uint64_t feat_flags = dev_info.feature_flags;
4300 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4301 printf("Device doesn't support out-of-place scatter-gather "
4302 "in both input and output mbufs. "
4304 return TEST_SKIPPED;
4307 /* Create SNOW 3G session */
4308 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4309 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4310 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4311 tdata->key.data, tdata->key.len,
4312 tdata->cipher_iv.len);
4316 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4317 /* Append data which is padded to a multiple of */
4318 /* the algorithms block size */
4319 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4321 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4322 plaintext_pad_len, 10, 0);
4323 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4324 plaintext_pad_len, 3, 0);
4326 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4327 "Failed to allocate input buffer in mempool");
4328 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4329 "Failed to allocate output buffer in mempool");
4331 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4333 /* Create SNOW 3G operation */
4334 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4335 tdata->cipher_iv.len,
4336 tdata->validCipherLenInBits.len,
4341 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4343 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4345 ut_params->obuf = ut_params->op->sym->m_dst;
4346 if (ut_params->obuf)
4347 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4348 plaintext_len, buffer);
4350 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4351 plaintext_len, buffer);
4353 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4356 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4358 tdata->ciphertext.data,
4359 tdata->validDataLenInBits.len,
4360 "SNOW 3G Ciphertext data not as expected");
4365 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4367 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4369 uint8_t curr_byte, prev_byte;
4370 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4371 uint8_t lower_byte_mask = (1 << offset) - 1;
4374 prev_byte = buffer[0];
4375 buffer[0] >>= offset;
4377 for (i = 1; i < length_in_bytes; i++) {
4378 curr_byte = buffer[i];
4379 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4380 (curr_byte >> offset);
4381 prev_byte = curr_byte;
4386 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4388 struct crypto_testsuite_params *ts_params = &testsuite_params;
4389 struct crypto_unittest_params *ut_params = &unittest_params;
4390 uint8_t *plaintext, *ciphertext;
4392 uint32_t plaintext_len;
4393 uint32_t plaintext_pad_len;
4394 uint8_t extra_offset = 4;
4395 uint8_t *expected_ciphertext_shifted;
4396 struct rte_cryptodev_info dev_info;
4398 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4399 uint64_t feat_flags = dev_info.feature_flags;
4401 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4402 ((tdata->validDataLenInBits.len % 8) != 0)) {
4403 printf("Device doesn't support NON-Byte Aligned Data.\n");
4404 return TEST_SKIPPED;
4407 /* Verify the capabilities */
4408 struct rte_cryptodev_sym_capability_idx cap_idx;
4409 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4410 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4411 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4413 return TEST_SKIPPED;
4415 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4416 return TEST_SKIPPED;
4418 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4419 return TEST_SKIPPED;
4421 /* Create SNOW 3G session */
4422 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4423 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4424 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4425 tdata->key.data, tdata->key.len,
4426 tdata->cipher_iv.len);
4430 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4431 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4433 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4434 "Failed to allocate input buffer in mempool");
4435 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4436 "Failed to allocate output buffer in mempool");
4438 /* Clear mbuf payload */
4439 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4440 rte_pktmbuf_tailroom(ut_params->ibuf));
4442 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4444 * Append data which is padded to a
4445 * multiple of the algorithms block size
4447 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4449 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4452 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4454 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4455 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4457 #ifdef RTE_APP_TEST_DEBUG
4458 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4460 /* Create SNOW 3G operation */
4461 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4462 tdata->cipher_iv.len,
4463 tdata->validCipherLenInBits.len,
4468 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4470 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4472 ut_params->obuf = ut_params->op->sym->m_dst;
4473 if (ut_params->obuf)
4474 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4476 ciphertext = plaintext;
4478 #ifdef RTE_APP_TEST_DEBUG
4479 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4482 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4484 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4485 "failed to reserve memory for ciphertext shifted\n");
4487 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4488 ceil_byte_length(tdata->ciphertext.len));
4489 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4492 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4494 expected_ciphertext_shifted,
4495 tdata->validDataLenInBits.len,
4497 "SNOW 3G Ciphertext data not as expected");
4501 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4503 struct crypto_testsuite_params *ts_params = &testsuite_params;
4504 struct crypto_unittest_params *ut_params = &unittest_params;
4508 uint8_t *plaintext, *ciphertext;
4509 unsigned ciphertext_pad_len;
4510 unsigned ciphertext_len;
4511 struct rte_cryptodev_info dev_info;
4513 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4514 uint64_t feat_flags = dev_info.feature_flags;
4516 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4517 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4518 printf("Device doesn't support RAW data-path APIs.\n");
4519 return TEST_SKIPPED;
4522 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4523 return TEST_SKIPPED;
4525 /* Verify the capabilities */
4526 struct rte_cryptodev_sym_capability_idx cap_idx;
4527 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4528 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4529 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4531 return TEST_SKIPPED;
4533 /* Create SNOW 3G session */
4534 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4535 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4536 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4537 tdata->key.data, tdata->key.len,
4538 tdata->cipher_iv.len);
4542 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4544 /* Clear mbuf payload */
4545 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4546 rte_pktmbuf_tailroom(ut_params->ibuf));
4548 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4549 /* Append data which is padded to a multiple of */
4550 /* the algorithms block size */
4551 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4552 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4553 ciphertext_pad_len);
4554 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4556 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4558 /* Create SNOW 3G operation */
4559 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4560 tdata->cipher_iv.len,
4561 tdata->validCipherLenInBits.len,
4562 tdata->cipher.offset_bits);
4566 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4567 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4568 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4570 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4572 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4573 ut_params->obuf = ut_params->op->sym->m_dst;
4574 if (ut_params->obuf)
4575 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4577 plaintext = ciphertext;
4579 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4582 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4583 tdata->plaintext.data,
4584 tdata->validDataLenInBits.len,
4585 "SNOW 3G Plaintext data not as expected");
4589 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4591 struct crypto_testsuite_params *ts_params = &testsuite_params;
4592 struct crypto_unittest_params *ut_params = &unittest_params;
4596 uint8_t *plaintext, *ciphertext;
4597 unsigned ciphertext_pad_len;
4598 unsigned ciphertext_len;
4600 /* Verify the capabilities */
4601 struct rte_cryptodev_sym_capability_idx cap_idx;
4602 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4603 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4604 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4606 return TEST_SKIPPED;
4608 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4609 return TEST_SKIPPED;
4611 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4612 return TEST_SKIPPED;
4614 /* Create SNOW 3G session */
4615 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4616 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4617 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4618 tdata->key.data, tdata->key.len,
4619 tdata->cipher_iv.len);
4623 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4624 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4626 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4627 "Failed to allocate input buffer");
4628 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4629 "Failed to allocate output buffer");
4631 /* Clear mbuf payload */
4632 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4633 rte_pktmbuf_tailroom(ut_params->ibuf));
4635 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4636 rte_pktmbuf_tailroom(ut_params->obuf));
4638 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4639 /* Append data which is padded to a multiple of */
4640 /* the algorithms block size */
4641 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4642 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4643 ciphertext_pad_len);
4644 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4645 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4647 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4649 /* Create SNOW 3G operation */
4650 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4651 tdata->cipher_iv.len,
4652 tdata->validCipherLenInBits.len,
4657 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4659 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4660 ut_params->obuf = ut_params->op->sym->m_dst;
4661 if (ut_params->obuf)
4662 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4664 plaintext = ciphertext;
4666 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4669 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4670 tdata->plaintext.data,
4671 tdata->validDataLenInBits.len,
4672 "SNOW 3G Plaintext data not as expected");
4677 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4679 struct crypto_testsuite_params *ts_params = &testsuite_params;
4680 struct crypto_unittest_params *ut_params = &unittest_params;
4684 uint8_t *plaintext, *ciphertext;
4685 unsigned int plaintext_pad_len;
4686 unsigned int plaintext_len;
4688 struct rte_cryptodev_info dev_info;
4689 struct rte_cryptodev_sym_capability_idx cap_idx;
4691 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4692 uint64_t feat_flags = dev_info.feature_flags;
4694 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4695 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4696 (tdata->validDataLenInBits.len % 8 != 0))) {
4697 printf("Device doesn't support NON-Byte Aligned Data.\n");
4698 return TEST_SKIPPED;
4701 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4702 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4703 printf("Device doesn't support RAW data-path APIs.\n");
4704 return TEST_SKIPPED;
4707 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4708 return TEST_SKIPPED;
4710 /* Check if device supports ZUC EEA3 */
4711 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4712 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4714 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4716 return TEST_SKIPPED;
4718 /* Check if device supports ZUC EIA3 */
4719 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4720 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4722 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4724 return TEST_SKIPPED;
4726 /* Create ZUC session */
4727 retval = create_zuc_cipher_auth_encrypt_generate_session(
4728 ts_params->valid_devs[0],
4732 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4734 /* clear mbuf payload */
4735 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4736 rte_pktmbuf_tailroom(ut_params->ibuf));
4738 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4739 /* Append data which is padded to a multiple of */
4740 /* the algorithms block size */
4741 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4742 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4744 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4746 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4748 /* Create ZUC operation */
4749 retval = create_zuc_cipher_hash_generate_operation(tdata);
4753 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4754 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4755 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4757 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4759 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4760 ut_params->obuf = ut_params->op->sym->m_src;
4761 if (ut_params->obuf)
4762 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4764 ciphertext = plaintext;
4766 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4768 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4770 tdata->ciphertext.data,
4771 tdata->validDataLenInBits.len,
4772 "ZUC Ciphertext data not as expected");
4774 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4775 + plaintext_pad_len;
4778 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4782 "ZUC Generated auth tag not as expected");
4787 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4789 struct crypto_testsuite_params *ts_params = &testsuite_params;
4790 struct crypto_unittest_params *ut_params = &unittest_params;
4794 uint8_t *plaintext, *ciphertext;
4795 unsigned plaintext_pad_len;
4796 unsigned plaintext_len;
4797 struct rte_cryptodev_info dev_info;
4799 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4800 uint64_t feat_flags = dev_info.feature_flags;
4802 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4803 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4804 printf("Device doesn't support RAW data-path APIs.\n");
4805 return TEST_SKIPPED;
4808 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4809 return TEST_SKIPPED;
4811 /* Verify the capabilities */
4812 struct rte_cryptodev_sym_capability_idx cap_idx;
4813 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4814 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4815 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4817 return TEST_SKIPPED;
4818 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4819 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4820 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4822 return TEST_SKIPPED;
4824 /* Create SNOW 3G session */
4825 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4826 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4827 RTE_CRYPTO_AUTH_OP_GENERATE,
4828 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4829 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4830 tdata->key.data, tdata->key.len,
4831 tdata->auth_iv.len, tdata->digest.len,
4832 tdata->cipher_iv.len);
4835 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4837 /* clear mbuf payload */
4838 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4839 rte_pktmbuf_tailroom(ut_params->ibuf));
4841 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4842 /* Append data which is padded to a multiple of */
4843 /* the algorithms block size */
4844 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4845 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4847 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4849 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4851 /* Create SNOW 3G operation */
4852 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4853 tdata->digest.len, tdata->auth_iv.data,
4855 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4856 tdata->cipher_iv.data, tdata->cipher_iv.len,
4857 tdata->validCipherLenInBits.len,
4859 tdata->validAuthLenInBits.len,
4865 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4866 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4867 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4869 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4871 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4872 ut_params->obuf = ut_params->op->sym->m_src;
4873 if (ut_params->obuf)
4874 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4876 ciphertext = plaintext;
4878 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4880 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4882 tdata->ciphertext.data,
4883 tdata->validDataLenInBits.len,
4884 "SNOW 3G Ciphertext data not as expected");
4886 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4887 + plaintext_pad_len;
4890 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4893 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4894 "SNOW 3G Generated auth tag not as expected");
4899 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4900 uint8_t op_mode, uint8_t verify)
4902 struct crypto_testsuite_params *ts_params = &testsuite_params;
4903 struct crypto_unittest_params *ut_params = &unittest_params;
4907 uint8_t *plaintext = NULL, *ciphertext = NULL;
4908 unsigned int plaintext_pad_len;
4909 unsigned int plaintext_len;
4910 unsigned int ciphertext_pad_len;
4911 unsigned int ciphertext_len;
4913 struct rte_cryptodev_info dev_info;
4915 /* Verify the capabilities */
4916 struct rte_cryptodev_sym_capability_idx cap_idx;
4917 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4918 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4919 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4921 return TEST_SKIPPED;
4922 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4923 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4924 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4926 return TEST_SKIPPED;
4928 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4929 return TEST_SKIPPED;
4931 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4933 uint64_t feat_flags = dev_info.feature_flags;
4935 if (op_mode == OUT_OF_PLACE) {
4936 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4937 printf("Device doesn't support digest encrypted.\n");
4938 return TEST_SKIPPED;
4940 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4941 return TEST_SKIPPED;
4944 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4945 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4946 printf("Device doesn't support RAW data-path APIs.\n");
4947 return TEST_SKIPPED;
4950 /* Create SNOW 3G session */
4951 retval = create_wireless_algo_auth_cipher_session(
4952 ts_params->valid_devs[0],
4953 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4954 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4955 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4956 : RTE_CRYPTO_AUTH_OP_GENERATE),
4957 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4958 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4959 tdata->key.data, tdata->key.len,
4960 tdata->auth_iv.len, tdata->digest.len,
4961 tdata->cipher_iv.len);
4965 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4966 if (op_mode == OUT_OF_PLACE)
4967 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4969 /* clear mbuf payload */
4970 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4971 rte_pktmbuf_tailroom(ut_params->ibuf));
4972 if (op_mode == OUT_OF_PLACE)
4973 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4974 rte_pktmbuf_tailroom(ut_params->obuf));
4976 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4977 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4978 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4979 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4982 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4983 ciphertext_pad_len);
4984 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4985 if (op_mode == OUT_OF_PLACE)
4986 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4987 debug_hexdump(stdout, "ciphertext:", ciphertext,
4990 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4992 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4993 if (op_mode == OUT_OF_PLACE)
4994 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4995 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4998 /* Create SNOW 3G operation */
4999 retval = create_wireless_algo_auth_cipher_operation(
5000 tdata->digest.data, tdata->digest.len,
5001 tdata->cipher_iv.data, tdata->cipher_iv.len,
5002 tdata->auth_iv.data, tdata->auth_iv.len,
5003 (tdata->digest.offset_bytes == 0 ?
5004 (verify ? ciphertext_pad_len : plaintext_pad_len)
5005 : tdata->digest.offset_bytes),
5006 tdata->validCipherLenInBits.len,
5007 tdata->cipher.offset_bits,
5008 tdata->validAuthLenInBits.len,
5009 tdata->auth.offset_bits,
5010 op_mode, 0, verify);
5015 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5016 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5017 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5019 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5022 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5024 ut_params->obuf = (op_mode == IN_PLACE ?
5025 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5028 if (ut_params->obuf)
5029 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5032 plaintext = ciphertext +
5033 (tdata->cipher.offset_bits >> 3);
5035 debug_hexdump(stdout, "plaintext:", plaintext,
5036 (tdata->plaintext.len >> 3) - tdata->digest.len);
5037 debug_hexdump(stdout, "plaintext expected:",
5038 tdata->plaintext.data,
5039 (tdata->plaintext.len >> 3) - tdata->digest.len);
5041 if (ut_params->obuf)
5042 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5045 ciphertext = plaintext;
5047 debug_hexdump(stdout, "ciphertext:", ciphertext,
5049 debug_hexdump(stdout, "ciphertext expected:",
5050 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5052 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5053 + (tdata->digest.offset_bytes == 0 ?
5054 plaintext_pad_len : tdata->digest.offset_bytes);
5056 debug_hexdump(stdout, "digest:", ut_params->digest,
5058 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5064 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5066 tdata->plaintext.data,
5067 (tdata->plaintext.len - tdata->cipher.offset_bits -
5068 (tdata->digest.len << 3)),
5069 tdata->cipher.offset_bits,
5070 "SNOW 3G Plaintext data not as expected");
5072 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5074 tdata->ciphertext.data,
5075 (tdata->validDataLenInBits.len -
5076 tdata->cipher.offset_bits),
5077 tdata->cipher.offset_bits,
5078 "SNOW 3G Ciphertext data not as expected");
5080 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5083 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5084 "SNOW 3G Generated auth tag not as expected");
5090 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5091 uint8_t op_mode, uint8_t verify)
5093 struct crypto_testsuite_params *ts_params = &testsuite_params;
5094 struct crypto_unittest_params *ut_params = &unittest_params;
5098 const uint8_t *plaintext = NULL;
5099 const uint8_t *ciphertext = NULL;
5100 const uint8_t *digest = NULL;
5101 unsigned int plaintext_pad_len;
5102 unsigned int plaintext_len;
5103 unsigned int ciphertext_pad_len;
5104 unsigned int ciphertext_len;
5105 uint8_t buffer[10000];
5106 uint8_t digest_buffer[10000];
5108 struct rte_cryptodev_info dev_info;
5110 /* Verify the capabilities */
5111 struct rte_cryptodev_sym_capability_idx cap_idx;
5112 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5113 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5114 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5116 return TEST_SKIPPED;
5117 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5118 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5119 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5121 return TEST_SKIPPED;
5123 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5124 return TEST_SKIPPED;
5126 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5128 uint64_t feat_flags = dev_info.feature_flags;
5130 if (op_mode == IN_PLACE) {
5131 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5132 printf("Device doesn't support in-place scatter-gather "
5133 "in both input and output mbufs.\n");
5134 return TEST_SKIPPED;
5136 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5137 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5138 printf("Device doesn't support RAW data-path APIs.\n");
5139 return TEST_SKIPPED;
5142 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5143 return TEST_SKIPPED;
5144 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5145 printf("Device doesn't support out-of-place scatter-gather "
5146 "in both input and output mbufs.\n");
5147 return TEST_SKIPPED;
5149 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5150 printf("Device doesn't support digest encrypted.\n");
5151 return TEST_SKIPPED;
5155 /* Create SNOW 3G session */
5156 retval = create_wireless_algo_auth_cipher_session(
5157 ts_params->valid_devs[0],
5158 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5159 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5160 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5161 : RTE_CRYPTO_AUTH_OP_GENERATE),
5162 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5163 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5164 tdata->key.data, tdata->key.len,
5165 tdata->auth_iv.len, tdata->digest.len,
5166 tdata->cipher_iv.len);
5171 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5172 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5173 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5174 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5176 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5177 plaintext_pad_len, 15, 0);
5178 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5179 "Failed to allocate input buffer in mempool");
5181 if (op_mode == OUT_OF_PLACE) {
5182 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5183 plaintext_pad_len, 15, 0);
5184 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5185 "Failed to allocate output buffer in mempool");
5189 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5190 tdata->ciphertext.data);
5191 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5192 ciphertext_len, buffer);
5193 debug_hexdump(stdout, "ciphertext:", ciphertext,
5196 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5197 tdata->plaintext.data);
5198 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5199 plaintext_len, buffer);
5200 debug_hexdump(stdout, "plaintext:", plaintext,
5203 memset(buffer, 0, sizeof(buffer));
5205 /* Create SNOW 3G operation */
5206 retval = create_wireless_algo_auth_cipher_operation(
5207 tdata->digest.data, tdata->digest.len,
5208 tdata->cipher_iv.data, tdata->cipher_iv.len,
5209 tdata->auth_iv.data, tdata->auth_iv.len,
5210 (tdata->digest.offset_bytes == 0 ?
5211 (verify ? ciphertext_pad_len : plaintext_pad_len)
5212 : tdata->digest.offset_bytes),
5213 tdata->validCipherLenInBits.len,
5214 tdata->cipher.offset_bits,
5215 tdata->validAuthLenInBits.len,
5216 tdata->auth.offset_bits,
5217 op_mode, 1, verify);
5222 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5223 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5224 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5226 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5229 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5231 ut_params->obuf = (op_mode == IN_PLACE ?
5232 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5235 if (ut_params->obuf)
5236 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5237 plaintext_len, buffer);
5239 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5240 plaintext_len, buffer);
5242 debug_hexdump(stdout, "plaintext:", plaintext,
5243 (tdata->plaintext.len >> 3) - tdata->digest.len);
5244 debug_hexdump(stdout, "plaintext expected:",
5245 tdata->plaintext.data,
5246 (tdata->plaintext.len >> 3) - tdata->digest.len);
5248 if (ut_params->obuf)
5249 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5250 ciphertext_len, buffer);
5252 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5253 ciphertext_len, buffer);
5255 debug_hexdump(stdout, "ciphertext:", ciphertext,
5257 debug_hexdump(stdout, "ciphertext expected:",
5258 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5260 if (ut_params->obuf)
5261 digest = rte_pktmbuf_read(ut_params->obuf,
5262 (tdata->digest.offset_bytes == 0 ?
5263 plaintext_pad_len : tdata->digest.offset_bytes),
5264 tdata->digest.len, digest_buffer);
5266 digest = rte_pktmbuf_read(ut_params->ibuf,
5267 (tdata->digest.offset_bytes == 0 ?
5268 plaintext_pad_len : tdata->digest.offset_bytes),
5269 tdata->digest.len, digest_buffer);
5271 debug_hexdump(stdout, "digest:", digest,
5273 debug_hexdump(stdout, "digest expected:",
5274 tdata->digest.data, tdata->digest.len);
5279 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5281 tdata->plaintext.data,
5282 (tdata->plaintext.len - tdata->cipher.offset_bits -
5283 (tdata->digest.len << 3)),
5284 tdata->cipher.offset_bits,
5285 "SNOW 3G Plaintext data not as expected");
5287 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5289 tdata->ciphertext.data,
5290 (tdata->validDataLenInBits.len -
5291 tdata->cipher.offset_bits),
5292 tdata->cipher.offset_bits,
5293 "SNOW 3G Ciphertext data not as expected");
5295 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5298 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5299 "SNOW 3G Generated auth tag not as expected");
5305 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5306 uint8_t op_mode, uint8_t verify)
5308 struct crypto_testsuite_params *ts_params = &testsuite_params;
5309 struct crypto_unittest_params *ut_params = &unittest_params;
5313 uint8_t *plaintext = NULL, *ciphertext = NULL;
5314 unsigned int plaintext_pad_len;
5315 unsigned int plaintext_len;
5316 unsigned int ciphertext_pad_len;
5317 unsigned int ciphertext_len;
5319 struct rte_cryptodev_info dev_info;
5321 /* Verify the capabilities */
5322 struct rte_cryptodev_sym_capability_idx cap_idx;
5323 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5324 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5325 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5327 return TEST_SKIPPED;
5328 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5329 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5330 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5332 return TEST_SKIPPED;
5334 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5336 uint64_t feat_flags = dev_info.feature_flags;
5338 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5339 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5340 printf("Device doesn't support RAW data-path APIs.\n");
5341 return TEST_SKIPPED;
5344 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5345 return TEST_SKIPPED;
5347 if (op_mode == OUT_OF_PLACE) {
5348 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5349 return TEST_SKIPPED;
5350 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5351 printf("Device doesn't support digest encrypted.\n");
5352 return TEST_SKIPPED;
5356 /* Create KASUMI session */
5357 retval = create_wireless_algo_auth_cipher_session(
5358 ts_params->valid_devs[0],
5359 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5360 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5361 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5362 : RTE_CRYPTO_AUTH_OP_GENERATE),
5363 RTE_CRYPTO_AUTH_KASUMI_F9,
5364 RTE_CRYPTO_CIPHER_KASUMI_F8,
5365 tdata->key.data, tdata->key.len,
5366 0, tdata->digest.len,
5367 tdata->cipher_iv.len);
5372 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5373 if (op_mode == OUT_OF_PLACE)
5374 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5376 /* clear mbuf payload */
5377 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5378 rte_pktmbuf_tailroom(ut_params->ibuf));
5379 if (op_mode == OUT_OF_PLACE)
5380 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5381 rte_pktmbuf_tailroom(ut_params->obuf));
5383 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5384 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5385 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5386 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5389 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5390 ciphertext_pad_len);
5391 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5392 if (op_mode == OUT_OF_PLACE)
5393 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5394 debug_hexdump(stdout, "ciphertext:", ciphertext,
5397 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5399 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5400 if (op_mode == OUT_OF_PLACE)
5401 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5402 debug_hexdump(stdout, "plaintext:", plaintext,
5406 /* Create KASUMI operation */
5407 retval = create_wireless_algo_auth_cipher_operation(
5408 tdata->digest.data, tdata->digest.len,
5409 tdata->cipher_iv.data, tdata->cipher_iv.len,
5411 (tdata->digest.offset_bytes == 0 ?
5412 (verify ? ciphertext_pad_len : plaintext_pad_len)
5413 : tdata->digest.offset_bytes),
5414 tdata->validCipherLenInBits.len,
5415 tdata->validCipherOffsetInBits.len,
5416 tdata->validAuthLenInBits.len,
5418 op_mode, 0, verify);
5423 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5424 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5425 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5427 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5430 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5432 ut_params->obuf = (op_mode == IN_PLACE ?
5433 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5437 if (ut_params->obuf)
5438 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5441 plaintext = ciphertext;
5443 debug_hexdump(stdout, "plaintext:", plaintext,
5444 (tdata->plaintext.len >> 3) - tdata->digest.len);
5445 debug_hexdump(stdout, "plaintext expected:",
5446 tdata->plaintext.data,
5447 (tdata->plaintext.len >> 3) - tdata->digest.len);
5449 if (ut_params->obuf)
5450 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5453 ciphertext = plaintext;
5455 debug_hexdump(stdout, "ciphertext:", ciphertext,
5457 debug_hexdump(stdout, "ciphertext expected:",
5458 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5460 ut_params->digest = rte_pktmbuf_mtod(
5461 ut_params->obuf, uint8_t *) +
5462 (tdata->digest.offset_bytes == 0 ?
5463 plaintext_pad_len : tdata->digest.offset_bytes);
5465 debug_hexdump(stdout, "digest:", ut_params->digest,
5467 debug_hexdump(stdout, "digest expected:",
5468 tdata->digest.data, tdata->digest.len);
5473 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5475 tdata->plaintext.data,
5476 tdata->plaintext.len >> 3,
5477 "KASUMI Plaintext data not as expected");
5479 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5481 tdata->ciphertext.data,
5482 tdata->ciphertext.len >> 3,
5483 "KASUMI Ciphertext data not as expected");
5485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5488 DIGEST_BYTE_LENGTH_KASUMI_F9,
5489 "KASUMI Generated auth tag not as expected");
5495 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5496 uint8_t op_mode, uint8_t verify)
5498 struct crypto_testsuite_params *ts_params = &testsuite_params;
5499 struct crypto_unittest_params *ut_params = &unittest_params;
5503 const uint8_t *plaintext = NULL;
5504 const uint8_t *ciphertext = NULL;
5505 const uint8_t *digest = NULL;
5506 unsigned int plaintext_pad_len;
5507 unsigned int plaintext_len;
5508 unsigned int ciphertext_pad_len;
5509 unsigned int ciphertext_len;
5510 uint8_t buffer[10000];
5511 uint8_t digest_buffer[10000];
5513 struct rte_cryptodev_info dev_info;
5515 /* Verify the capabilities */
5516 struct rte_cryptodev_sym_capability_idx cap_idx;
5517 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5518 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5519 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5521 return TEST_SKIPPED;
5522 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5523 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5524 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5526 return TEST_SKIPPED;
5528 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5529 return TEST_SKIPPED;
5531 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5533 uint64_t feat_flags = dev_info.feature_flags;
5535 if (op_mode == IN_PLACE) {
5536 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5537 printf("Device doesn't support in-place scatter-gather "
5538 "in both input and output mbufs.\n");
5539 return TEST_SKIPPED;
5541 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5542 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5543 printf("Device doesn't support RAW data-path APIs.\n");
5544 return TEST_SKIPPED;
5547 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5548 return TEST_SKIPPED;
5549 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5550 printf("Device doesn't support out-of-place scatter-gather "
5551 "in both input and output mbufs.\n");
5552 return TEST_SKIPPED;
5554 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5555 printf("Device doesn't support digest encrypted.\n");
5556 return TEST_SKIPPED;
5560 /* Create KASUMI session */
5561 retval = create_wireless_algo_auth_cipher_session(
5562 ts_params->valid_devs[0],
5563 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5564 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5565 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5566 : RTE_CRYPTO_AUTH_OP_GENERATE),
5567 RTE_CRYPTO_AUTH_KASUMI_F9,
5568 RTE_CRYPTO_CIPHER_KASUMI_F8,
5569 tdata->key.data, tdata->key.len,
5570 0, tdata->digest.len,
5571 tdata->cipher_iv.len);
5576 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5577 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5578 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5579 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5581 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5582 plaintext_pad_len, 15, 0);
5583 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5584 "Failed to allocate input buffer in mempool");
5586 if (op_mode == OUT_OF_PLACE) {
5587 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5588 plaintext_pad_len, 15, 0);
5589 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5590 "Failed to allocate output buffer in mempool");
5594 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5595 tdata->ciphertext.data);
5596 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5597 ciphertext_len, buffer);
5598 debug_hexdump(stdout, "ciphertext:", ciphertext,
5601 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5602 tdata->plaintext.data);
5603 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5604 plaintext_len, buffer);
5605 debug_hexdump(stdout, "plaintext:", plaintext,
5608 memset(buffer, 0, sizeof(buffer));
5610 /* Create KASUMI operation */
5611 retval = create_wireless_algo_auth_cipher_operation(
5612 tdata->digest.data, tdata->digest.len,
5613 tdata->cipher_iv.data, tdata->cipher_iv.len,
5615 (tdata->digest.offset_bytes == 0 ?
5616 (verify ? ciphertext_pad_len : plaintext_pad_len)
5617 : tdata->digest.offset_bytes),
5618 tdata->validCipherLenInBits.len,
5619 tdata->validCipherOffsetInBits.len,
5620 tdata->validAuthLenInBits.len,
5622 op_mode, 1, verify);
5627 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5628 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5629 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5631 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5634 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5636 ut_params->obuf = (op_mode == IN_PLACE ?
5637 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5640 if (ut_params->obuf)
5641 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5642 plaintext_len, buffer);
5644 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5645 plaintext_len, buffer);
5647 debug_hexdump(stdout, "plaintext:", plaintext,
5648 (tdata->plaintext.len >> 3) - tdata->digest.len);
5649 debug_hexdump(stdout, "plaintext expected:",
5650 tdata->plaintext.data,
5651 (tdata->plaintext.len >> 3) - tdata->digest.len);
5653 if (ut_params->obuf)
5654 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5655 ciphertext_len, buffer);
5657 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5658 ciphertext_len, buffer);
5660 debug_hexdump(stdout, "ciphertext:", ciphertext,
5662 debug_hexdump(stdout, "ciphertext expected:",
5663 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5665 if (ut_params->obuf)
5666 digest = rte_pktmbuf_read(ut_params->obuf,
5667 (tdata->digest.offset_bytes == 0 ?
5668 plaintext_pad_len : tdata->digest.offset_bytes),
5669 tdata->digest.len, digest_buffer);
5671 digest = rte_pktmbuf_read(ut_params->ibuf,
5672 (tdata->digest.offset_bytes == 0 ?
5673 plaintext_pad_len : tdata->digest.offset_bytes),
5674 tdata->digest.len, digest_buffer);
5676 debug_hexdump(stdout, "digest:", digest,
5678 debug_hexdump(stdout, "digest expected:",
5679 tdata->digest.data, tdata->digest.len);
5684 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5686 tdata->plaintext.data,
5687 tdata->plaintext.len >> 3,
5688 "KASUMI Plaintext data not as expected");
5690 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5692 tdata->ciphertext.data,
5693 tdata->validDataLenInBits.len,
5694 "KASUMI Ciphertext data not as expected");
5696 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5699 DIGEST_BYTE_LENGTH_KASUMI_F9,
5700 "KASUMI Generated auth tag not as expected");
5706 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5708 struct crypto_testsuite_params *ts_params = &testsuite_params;
5709 struct crypto_unittest_params *ut_params = &unittest_params;
5713 uint8_t *plaintext, *ciphertext;
5714 unsigned plaintext_pad_len;
5715 unsigned plaintext_len;
5716 struct rte_cryptodev_info dev_info;
5718 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5719 uint64_t feat_flags = dev_info.feature_flags;
5721 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5722 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5723 printf("Device doesn't support RAW data-path APIs.\n");
5724 return TEST_SKIPPED;
5727 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5728 return TEST_SKIPPED;
5730 /* Verify the capabilities */
5731 struct rte_cryptodev_sym_capability_idx cap_idx;
5732 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5733 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5734 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5736 return TEST_SKIPPED;
5737 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5738 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5739 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5741 return TEST_SKIPPED;
5743 /* Create KASUMI session */
5744 retval = create_wireless_algo_cipher_auth_session(
5745 ts_params->valid_devs[0],
5746 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5747 RTE_CRYPTO_AUTH_OP_GENERATE,
5748 RTE_CRYPTO_AUTH_KASUMI_F9,
5749 RTE_CRYPTO_CIPHER_KASUMI_F8,
5750 tdata->key.data, tdata->key.len,
5751 0, tdata->digest.len,
5752 tdata->cipher_iv.len);
5756 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5758 /* clear mbuf payload */
5759 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5760 rte_pktmbuf_tailroom(ut_params->ibuf));
5762 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5763 /* Append data which is padded to a multiple of */
5764 /* the algorithms block size */
5765 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5766 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5768 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5770 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5772 /* Create KASUMI operation */
5773 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5774 tdata->digest.len, NULL, 0,
5775 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5776 tdata->cipher_iv.data, tdata->cipher_iv.len,
5777 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5778 tdata->validCipherOffsetInBits.len,
5779 tdata->validAuthLenInBits.len,
5785 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5786 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5787 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5789 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5791 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5793 if (ut_params->op->sym->m_dst)
5794 ut_params->obuf = ut_params->op->sym->m_dst;
5796 ut_params->obuf = ut_params->op->sym->m_src;
5798 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5799 tdata->validCipherOffsetInBits.len >> 3);
5801 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5802 + plaintext_pad_len;
5804 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5805 (tdata->validCipherOffsetInBits.len >> 3);
5807 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5809 reference_ciphertext,
5810 tdata->validCipherLenInBits.len,
5811 "KASUMI Ciphertext data not as expected");
5814 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5817 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5818 "KASUMI Generated auth tag not as expected");
5823 test_zuc_encryption(const struct wireless_test_data *tdata)
5825 struct crypto_testsuite_params *ts_params = &testsuite_params;
5826 struct crypto_unittest_params *ut_params = &unittest_params;
5829 uint8_t *plaintext, *ciphertext;
5830 unsigned plaintext_pad_len;
5831 unsigned plaintext_len;
5832 struct rte_cryptodev_info dev_info;
5834 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5835 uint64_t feat_flags = dev_info.feature_flags;
5837 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5838 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5839 printf("Device doesn't support RAW data-path APIs.\n");
5840 return TEST_SKIPPED;
5843 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5844 return TEST_SKIPPED;
5846 struct rte_cryptodev_sym_capability_idx cap_idx;
5848 /* Check if device supports ZUC EEA3 */
5849 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5850 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5852 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5854 return TEST_SKIPPED;
5856 /* Create ZUC session */
5857 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5858 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5859 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5860 tdata->key.data, tdata->key.len,
5861 tdata->cipher_iv.len);
5865 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5867 /* Clear mbuf payload */
5868 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5869 rte_pktmbuf_tailroom(ut_params->ibuf));
5871 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5872 /* Append data which is padded to a multiple */
5873 /* of the algorithms block size */
5874 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5875 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5877 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5879 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5881 /* Create ZUC operation */
5882 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5883 tdata->cipher_iv.len,
5884 tdata->plaintext.len,
5889 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5890 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5891 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5893 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5895 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5897 ut_params->obuf = ut_params->op->sym->m_dst;
5898 if (ut_params->obuf)
5899 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5901 ciphertext = plaintext;
5903 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5906 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5908 tdata->ciphertext.data,
5909 tdata->validCipherLenInBits.len,
5910 "ZUC Ciphertext data not as expected");
5915 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5917 struct crypto_testsuite_params *ts_params = &testsuite_params;
5918 struct crypto_unittest_params *ut_params = &unittest_params;
5922 unsigned int plaintext_pad_len;
5923 unsigned int plaintext_len;
5924 const uint8_t *ciphertext;
5925 uint8_t ciphertext_buffer[2048];
5926 struct rte_cryptodev_info dev_info;
5928 struct rte_cryptodev_sym_capability_idx cap_idx;
5930 /* Check if device supports ZUC EEA3 */
5931 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5932 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5934 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5936 return TEST_SKIPPED;
5938 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5939 return TEST_SKIPPED;
5941 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5943 uint64_t feat_flags = dev_info.feature_flags;
5945 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5946 printf("Device doesn't support in-place scatter-gather. "
5948 return TEST_SKIPPED;
5951 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5952 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5953 printf("Device doesn't support RAW data-path APIs.\n");
5954 return TEST_SKIPPED;
5957 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5959 /* Append data which is padded to a multiple */
5960 /* of the algorithms block size */
5961 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5963 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5964 plaintext_pad_len, 10, 0);
5966 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5967 tdata->plaintext.data);
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 /* Clear mbuf payload */
5980 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5982 /* Create ZUC operation */
5983 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5984 tdata->cipher_iv.len, tdata->plaintext.len,
5989 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5990 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5991 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5993 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5995 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5997 ut_params->obuf = ut_params->op->sym->m_dst;
5998 if (ut_params->obuf)
5999 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6000 0, plaintext_len, ciphertext_buffer);
6002 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6003 0, plaintext_len, ciphertext_buffer);
6006 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6009 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6011 tdata->ciphertext.data,
6012 tdata->validCipherLenInBits.len,
6013 "ZUC Ciphertext data not as expected");
6019 test_zuc_authentication(const struct wireless_test_data *tdata)
6021 struct crypto_testsuite_params *ts_params = &testsuite_params;
6022 struct crypto_unittest_params *ut_params = &unittest_params;
6025 unsigned plaintext_pad_len;
6026 unsigned plaintext_len;
6029 struct rte_cryptodev_sym_capability_idx cap_idx;
6030 struct rte_cryptodev_info dev_info;
6032 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6033 uint64_t feat_flags = dev_info.feature_flags;
6035 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6036 (tdata->validAuthLenInBits.len % 8 != 0)) {
6037 printf("Device doesn't support NON-Byte Aligned Data.\n");
6038 return TEST_SKIPPED;
6041 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6042 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6043 printf("Device doesn't support RAW data-path APIs.\n");
6044 return TEST_SKIPPED;
6047 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6048 return TEST_SKIPPED;
6050 /* Check if device supports ZUC EIA3 */
6051 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6052 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6054 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6056 return TEST_SKIPPED;
6058 /* Create ZUC session */
6059 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6060 tdata->key.data, tdata->key.len,
6061 tdata->auth_iv.len, tdata->digest.len,
6062 RTE_CRYPTO_AUTH_OP_GENERATE,
6063 RTE_CRYPTO_AUTH_ZUC_EIA3);
6067 /* alloc mbuf and set payload */
6068 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6070 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6071 rte_pktmbuf_tailroom(ut_params->ibuf));
6073 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6074 /* Append data which is padded to a multiple of */
6075 /* the algorithms block size */
6076 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6077 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6079 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6081 /* Create ZUC operation */
6082 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6083 tdata->auth_iv.data, tdata->auth_iv.len,
6084 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6085 tdata->validAuthLenInBits.len,
6090 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6091 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6092 ut_params->op, 0, 1, 1, 0);
6094 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6096 ut_params->obuf = ut_params->op->sym->m_src;
6097 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6098 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6099 + plaintext_pad_len;
6102 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6106 "ZUC Generated auth tag not as expected");
6112 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6113 uint8_t op_mode, uint8_t verify)
6115 struct crypto_testsuite_params *ts_params = &testsuite_params;
6116 struct crypto_unittest_params *ut_params = &unittest_params;
6120 uint8_t *plaintext = NULL, *ciphertext = NULL;
6121 unsigned int plaintext_pad_len;
6122 unsigned int plaintext_len;
6123 unsigned int ciphertext_pad_len;
6124 unsigned int ciphertext_len;
6126 struct rte_cryptodev_info dev_info;
6127 struct rte_cryptodev_sym_capability_idx cap_idx;
6129 /* Check if device supports ZUC EIA3 */
6130 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6131 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6133 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6135 return TEST_SKIPPED;
6137 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6139 uint64_t feat_flags = dev_info.feature_flags;
6141 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6142 printf("Device doesn't support digest encrypted.\n");
6143 return TEST_SKIPPED;
6145 if (op_mode == IN_PLACE) {
6146 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6147 printf("Device doesn't support in-place scatter-gather "
6148 "in both input and output mbufs.\n");
6149 return TEST_SKIPPED;
6152 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6153 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6154 printf("Device doesn't support RAW data-path APIs.\n");
6155 return TEST_SKIPPED;
6158 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6159 return TEST_SKIPPED;
6160 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6161 printf("Device doesn't support out-of-place scatter-gather "
6162 "in both input and output mbufs.\n");
6163 return TEST_SKIPPED;
6167 /* Create ZUC session */
6168 retval = create_wireless_algo_auth_cipher_session(
6169 ts_params->valid_devs[0],
6170 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6171 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6172 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6173 : RTE_CRYPTO_AUTH_OP_GENERATE),
6174 RTE_CRYPTO_AUTH_ZUC_EIA3,
6175 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6176 tdata->key.data, tdata->key.len,
6177 tdata->auth_iv.len, tdata->digest.len,
6178 tdata->cipher_iv.len);
6183 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6184 if (op_mode == OUT_OF_PLACE)
6185 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6187 /* clear mbuf payload */
6188 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6189 rte_pktmbuf_tailroom(ut_params->ibuf));
6190 if (op_mode == OUT_OF_PLACE)
6191 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6192 rte_pktmbuf_tailroom(ut_params->obuf));
6194 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6195 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6196 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6197 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6200 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6201 ciphertext_pad_len);
6202 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6203 if (op_mode == OUT_OF_PLACE)
6204 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6205 debug_hexdump(stdout, "ciphertext:", ciphertext,
6208 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6210 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6211 if (op_mode == OUT_OF_PLACE)
6212 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6213 debug_hexdump(stdout, "plaintext:", plaintext,
6217 /* Create ZUC operation */
6218 retval = create_wireless_algo_auth_cipher_operation(
6219 tdata->digest.data, tdata->digest.len,
6220 tdata->cipher_iv.data, tdata->cipher_iv.len,
6221 tdata->auth_iv.data, tdata->auth_iv.len,
6222 (tdata->digest.offset_bytes == 0 ?
6223 (verify ? ciphertext_pad_len : plaintext_pad_len)
6224 : tdata->digest.offset_bytes),
6225 tdata->validCipherLenInBits.len,
6226 tdata->validCipherOffsetInBits.len,
6227 tdata->validAuthLenInBits.len,
6229 op_mode, 0, verify);
6234 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6235 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6236 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6238 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6241 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6243 ut_params->obuf = (op_mode == IN_PLACE ?
6244 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6248 if (ut_params->obuf)
6249 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6252 plaintext = ciphertext;
6254 debug_hexdump(stdout, "plaintext:", plaintext,
6255 (tdata->plaintext.len >> 3) - tdata->digest.len);
6256 debug_hexdump(stdout, "plaintext expected:",
6257 tdata->plaintext.data,
6258 (tdata->plaintext.len >> 3) - tdata->digest.len);
6260 if (ut_params->obuf)
6261 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6264 ciphertext = plaintext;
6266 debug_hexdump(stdout, "ciphertext:", ciphertext,
6268 debug_hexdump(stdout, "ciphertext expected:",
6269 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6271 ut_params->digest = rte_pktmbuf_mtod(
6272 ut_params->obuf, uint8_t *) +
6273 (tdata->digest.offset_bytes == 0 ?
6274 plaintext_pad_len : tdata->digest.offset_bytes);
6276 debug_hexdump(stdout, "digest:", ut_params->digest,
6278 debug_hexdump(stdout, "digest expected:",
6279 tdata->digest.data, tdata->digest.len);
6284 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6286 tdata->plaintext.data,
6287 tdata->plaintext.len >> 3,
6288 "ZUC Plaintext data not as expected");
6290 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6292 tdata->ciphertext.data,
6293 tdata->ciphertext.len >> 3,
6294 "ZUC Ciphertext data not as expected");
6296 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6299 DIGEST_BYTE_LENGTH_KASUMI_F9,
6300 "ZUC Generated auth tag not as expected");
6306 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6307 uint8_t op_mode, uint8_t verify)
6309 struct crypto_testsuite_params *ts_params = &testsuite_params;
6310 struct crypto_unittest_params *ut_params = &unittest_params;
6314 const uint8_t *plaintext = NULL;
6315 const uint8_t *ciphertext = NULL;
6316 const uint8_t *digest = NULL;
6317 unsigned int plaintext_pad_len;
6318 unsigned int plaintext_len;
6319 unsigned int ciphertext_pad_len;
6320 unsigned int ciphertext_len;
6321 uint8_t buffer[10000];
6322 uint8_t digest_buffer[10000];
6324 struct rte_cryptodev_info dev_info;
6325 struct rte_cryptodev_sym_capability_idx cap_idx;
6327 /* Check if device supports ZUC EIA3 */
6328 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6329 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6331 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6333 return TEST_SKIPPED;
6335 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6337 uint64_t feat_flags = dev_info.feature_flags;
6339 if (op_mode == IN_PLACE) {
6340 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6341 printf("Device doesn't support in-place scatter-gather "
6342 "in both input and output mbufs.\n");
6343 return TEST_SKIPPED;
6346 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6347 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6348 printf("Device doesn't support RAW data-path APIs.\n");
6349 return TEST_SKIPPED;
6352 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6353 return TEST_SKIPPED;
6354 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6355 printf("Device doesn't support out-of-place scatter-gather "
6356 "in both input and output mbufs.\n");
6357 return TEST_SKIPPED;
6359 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6360 printf("Device doesn't support digest encrypted.\n");
6361 return TEST_SKIPPED;
6365 /* Create ZUC session */
6366 retval = create_wireless_algo_auth_cipher_session(
6367 ts_params->valid_devs[0],
6368 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6369 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6370 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6371 : RTE_CRYPTO_AUTH_OP_GENERATE),
6372 RTE_CRYPTO_AUTH_ZUC_EIA3,
6373 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6374 tdata->key.data, tdata->key.len,
6375 tdata->auth_iv.len, tdata->digest.len,
6376 tdata->cipher_iv.len);
6381 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6382 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6383 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6384 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6386 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6387 plaintext_pad_len, 15, 0);
6388 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6389 "Failed to allocate input buffer in mempool");
6391 if (op_mode == OUT_OF_PLACE) {
6392 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6393 plaintext_pad_len, 15, 0);
6394 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6395 "Failed to allocate output buffer in mempool");
6399 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6400 tdata->ciphertext.data);
6401 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6402 ciphertext_len, buffer);
6403 debug_hexdump(stdout, "ciphertext:", ciphertext,
6406 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6407 tdata->plaintext.data);
6408 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6409 plaintext_len, buffer);
6410 debug_hexdump(stdout, "plaintext:", plaintext,
6413 memset(buffer, 0, sizeof(buffer));
6415 /* Create ZUC operation */
6416 retval = create_wireless_algo_auth_cipher_operation(
6417 tdata->digest.data, tdata->digest.len,
6418 tdata->cipher_iv.data, tdata->cipher_iv.len,
6420 (tdata->digest.offset_bytes == 0 ?
6421 (verify ? ciphertext_pad_len : plaintext_pad_len)
6422 : tdata->digest.offset_bytes),
6423 tdata->validCipherLenInBits.len,
6424 tdata->validCipherOffsetInBits.len,
6425 tdata->validAuthLenInBits.len,
6427 op_mode, 1, verify);
6432 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6433 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6434 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6436 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6439 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6441 ut_params->obuf = (op_mode == IN_PLACE ?
6442 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6445 if (ut_params->obuf)
6446 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6447 plaintext_len, buffer);
6449 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6450 plaintext_len, buffer);
6452 debug_hexdump(stdout, "plaintext:", plaintext,
6453 (tdata->plaintext.len >> 3) - tdata->digest.len);
6454 debug_hexdump(stdout, "plaintext expected:",
6455 tdata->plaintext.data,
6456 (tdata->plaintext.len >> 3) - tdata->digest.len);
6458 if (ut_params->obuf)
6459 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6460 ciphertext_len, buffer);
6462 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6463 ciphertext_len, buffer);
6465 debug_hexdump(stdout, "ciphertext:", ciphertext,
6467 debug_hexdump(stdout, "ciphertext expected:",
6468 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6470 if (ut_params->obuf)
6471 digest = rte_pktmbuf_read(ut_params->obuf,
6472 (tdata->digest.offset_bytes == 0 ?
6473 plaintext_pad_len : tdata->digest.offset_bytes),
6474 tdata->digest.len, digest_buffer);
6476 digest = rte_pktmbuf_read(ut_params->ibuf,
6477 (tdata->digest.offset_bytes == 0 ?
6478 plaintext_pad_len : tdata->digest.offset_bytes),
6479 tdata->digest.len, digest_buffer);
6481 debug_hexdump(stdout, "digest:", digest,
6483 debug_hexdump(stdout, "digest expected:",
6484 tdata->digest.data, tdata->digest.len);
6489 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6491 tdata->plaintext.data,
6492 tdata->plaintext.len >> 3,
6493 "ZUC Plaintext data not as expected");
6495 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6497 tdata->ciphertext.data,
6498 tdata->validDataLenInBits.len,
6499 "ZUC Ciphertext data not as expected");
6501 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6504 DIGEST_BYTE_LENGTH_KASUMI_F9,
6505 "ZUC Generated auth tag not as expected");
6511 test_kasumi_encryption_test_case_1(void)
6513 return test_kasumi_encryption(&kasumi_test_case_1);
6517 test_kasumi_encryption_test_case_1_sgl(void)
6519 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6523 test_kasumi_encryption_test_case_1_oop(void)
6525 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6529 test_kasumi_encryption_test_case_1_oop_sgl(void)
6531 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6535 test_kasumi_encryption_test_case_2(void)
6537 return test_kasumi_encryption(&kasumi_test_case_2);
6541 test_kasumi_encryption_test_case_3(void)
6543 return test_kasumi_encryption(&kasumi_test_case_3);
6547 test_kasumi_encryption_test_case_4(void)
6549 return test_kasumi_encryption(&kasumi_test_case_4);
6553 test_kasumi_encryption_test_case_5(void)
6555 return test_kasumi_encryption(&kasumi_test_case_5);
6559 test_kasumi_decryption_test_case_1(void)
6561 return test_kasumi_decryption(&kasumi_test_case_1);
6565 test_kasumi_decryption_test_case_1_oop(void)
6567 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6571 test_kasumi_decryption_test_case_2(void)
6573 return test_kasumi_decryption(&kasumi_test_case_2);
6577 test_kasumi_decryption_test_case_3(void)
6579 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6580 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6581 return TEST_SKIPPED;
6582 return test_kasumi_decryption(&kasumi_test_case_3);
6586 test_kasumi_decryption_test_case_4(void)
6588 return test_kasumi_decryption(&kasumi_test_case_4);
6592 test_kasumi_decryption_test_case_5(void)
6594 return test_kasumi_decryption(&kasumi_test_case_5);
6597 test_snow3g_encryption_test_case_1(void)
6599 return test_snow3g_encryption(&snow3g_test_case_1);
6603 test_snow3g_encryption_test_case_1_oop(void)
6605 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6609 test_snow3g_encryption_test_case_1_oop_sgl(void)
6611 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6616 test_snow3g_encryption_test_case_1_offset_oop(void)
6618 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6622 test_snow3g_encryption_test_case_2(void)
6624 return test_snow3g_encryption(&snow3g_test_case_2);
6628 test_snow3g_encryption_test_case_3(void)
6630 return test_snow3g_encryption(&snow3g_test_case_3);
6634 test_snow3g_encryption_test_case_4(void)
6636 return test_snow3g_encryption(&snow3g_test_case_4);
6640 test_snow3g_encryption_test_case_5(void)
6642 return test_snow3g_encryption(&snow3g_test_case_5);
6646 test_snow3g_decryption_test_case_1(void)
6648 return test_snow3g_decryption(&snow3g_test_case_1);
6652 test_snow3g_decryption_test_case_1_oop(void)
6654 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6658 test_snow3g_decryption_test_case_2(void)
6660 return test_snow3g_decryption(&snow3g_test_case_2);
6664 test_snow3g_decryption_test_case_3(void)
6666 return test_snow3g_decryption(&snow3g_test_case_3);
6670 test_snow3g_decryption_test_case_4(void)
6672 return test_snow3g_decryption(&snow3g_test_case_4);
6676 test_snow3g_decryption_test_case_5(void)
6678 return test_snow3g_decryption(&snow3g_test_case_5);
6682 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6683 * Pattern digest from snow3g_test_data must be allocated as
6684 * 4 last bytes in plaintext.
6687 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6688 struct snow3g_hash_test_data *output)
6690 if ((pattern != NULL) && (output != NULL)) {
6691 output->key.len = pattern->key.len;
6693 memcpy(output->key.data,
6694 pattern->key.data, pattern->key.len);
6696 output->auth_iv.len = pattern->auth_iv.len;
6698 memcpy(output->auth_iv.data,
6699 pattern->auth_iv.data, pattern->auth_iv.len);
6701 output->plaintext.len = pattern->plaintext.len;
6703 memcpy(output->plaintext.data,
6704 pattern->plaintext.data, pattern->plaintext.len >> 3);
6706 output->digest.len = pattern->digest.len;
6708 memcpy(output->digest.data,
6709 &pattern->plaintext.data[pattern->digest.offset_bytes],
6710 pattern->digest.len);
6712 output->validAuthLenInBits.len =
6713 pattern->validAuthLenInBits.len;
6718 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6721 test_snow3g_decryption_with_digest_test_case_1(void)
6723 struct snow3g_hash_test_data snow3g_hash_data;
6724 struct rte_cryptodev_info dev_info;
6725 struct crypto_testsuite_params *ts_params = &testsuite_params;
6727 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6728 uint64_t feat_flags = dev_info.feature_flags;
6730 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6731 printf("Device doesn't support encrypted digest operations.\n");
6732 return TEST_SKIPPED;
6736 * Function prepare data for hash veryfication test case.
6737 * Digest is allocated in 4 last bytes in plaintext, pattern.
6739 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6741 return test_snow3g_decryption(&snow3g_test_case_7) &
6742 test_snow3g_authentication_verify(&snow3g_hash_data);
6746 test_snow3g_cipher_auth_test_case_1(void)
6748 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6752 test_snow3g_auth_cipher_test_case_1(void)
6754 return test_snow3g_auth_cipher(
6755 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6759 test_snow3g_auth_cipher_test_case_2(void)
6761 return test_snow3g_auth_cipher(
6762 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6766 test_snow3g_auth_cipher_test_case_2_oop(void)
6768 return test_snow3g_auth_cipher(
6769 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6773 test_snow3g_auth_cipher_part_digest_enc(void)
6775 return test_snow3g_auth_cipher(
6776 &snow3g_auth_cipher_partial_digest_encryption,
6781 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6783 return test_snow3g_auth_cipher(
6784 &snow3g_auth_cipher_partial_digest_encryption,
6789 test_snow3g_auth_cipher_test_case_3_sgl(void)
6791 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6792 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6793 return TEST_SKIPPED;
6794 return test_snow3g_auth_cipher_sgl(
6795 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6799 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6801 return test_snow3g_auth_cipher_sgl(
6802 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6806 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6808 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6809 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6810 return TEST_SKIPPED;
6811 return test_snow3g_auth_cipher_sgl(
6812 &snow3g_auth_cipher_partial_digest_encryption,
6817 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6819 return test_snow3g_auth_cipher_sgl(
6820 &snow3g_auth_cipher_partial_digest_encryption,
6825 test_snow3g_auth_cipher_verify_test_case_1(void)
6827 return test_snow3g_auth_cipher(
6828 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6832 test_snow3g_auth_cipher_verify_test_case_2(void)
6834 return test_snow3g_auth_cipher(
6835 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6839 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6841 return test_snow3g_auth_cipher(
6842 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6846 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6848 return test_snow3g_auth_cipher(
6849 &snow3g_auth_cipher_partial_digest_encryption,
6854 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6856 return test_snow3g_auth_cipher(
6857 &snow3g_auth_cipher_partial_digest_encryption,
6862 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6864 return test_snow3g_auth_cipher_sgl(
6865 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6869 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6871 return test_snow3g_auth_cipher_sgl(
6872 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6876 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6878 return test_snow3g_auth_cipher_sgl(
6879 &snow3g_auth_cipher_partial_digest_encryption,
6884 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6886 return test_snow3g_auth_cipher_sgl(
6887 &snow3g_auth_cipher_partial_digest_encryption,
6892 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6894 return test_snow3g_auth_cipher(
6895 &snow3g_test_case_7, IN_PLACE, 0);
6899 test_kasumi_auth_cipher_test_case_1(void)
6901 return test_kasumi_auth_cipher(
6902 &kasumi_test_case_3, IN_PLACE, 0);
6906 test_kasumi_auth_cipher_test_case_2(void)
6908 return test_kasumi_auth_cipher(
6909 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6913 test_kasumi_auth_cipher_test_case_2_oop(void)
6915 return test_kasumi_auth_cipher(
6916 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6920 test_kasumi_auth_cipher_test_case_2_sgl(void)
6922 return test_kasumi_auth_cipher_sgl(
6923 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6927 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6929 return test_kasumi_auth_cipher_sgl(
6930 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6934 test_kasumi_auth_cipher_verify_test_case_1(void)
6936 return test_kasumi_auth_cipher(
6937 &kasumi_test_case_3, IN_PLACE, 1);
6941 test_kasumi_auth_cipher_verify_test_case_2(void)
6943 return test_kasumi_auth_cipher(
6944 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6948 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6950 return test_kasumi_auth_cipher(
6951 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6955 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6957 return test_kasumi_auth_cipher_sgl(
6958 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6962 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6964 return test_kasumi_auth_cipher_sgl(
6965 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6969 test_kasumi_cipher_auth_test_case_1(void)
6971 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6975 test_zuc_encryption_test_case_1(void)
6977 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6981 test_zuc_encryption_test_case_2(void)
6983 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6987 test_zuc_encryption_test_case_3(void)
6989 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6993 test_zuc_encryption_test_case_4(void)
6995 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6999 test_zuc_encryption_test_case_5(void)
7001 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7005 test_zuc_encryption_test_case_6_sgl(void)
7007 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7011 test_zuc_hash_generate_test_case_1(void)
7013 return test_zuc_authentication(&zuc_test_case_auth_1b);
7017 test_zuc_hash_generate_test_case_2(void)
7019 return test_zuc_authentication(&zuc_test_case_auth_90b);
7023 test_zuc_hash_generate_test_case_3(void)
7025 return test_zuc_authentication(&zuc_test_case_auth_577b);
7029 test_zuc_hash_generate_test_case_4(void)
7031 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7035 test_zuc_hash_generate_test_case_5(void)
7037 return test_zuc_authentication(&zuc_test_auth_5670b);
7041 test_zuc_hash_generate_test_case_6(void)
7043 return test_zuc_authentication(&zuc_test_case_auth_128b);
7047 test_zuc_hash_generate_test_case_7(void)
7049 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7053 test_zuc_hash_generate_test_case_8(void)
7055 return test_zuc_authentication(&zuc_test_case_auth_584b);
7059 test_zuc_cipher_auth_test_case_1(void)
7061 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7065 test_zuc_cipher_auth_test_case_2(void)
7067 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7071 test_zuc_auth_cipher_test_case_1(void)
7073 return test_zuc_auth_cipher(
7074 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7078 test_zuc_auth_cipher_test_case_1_oop(void)
7080 return test_zuc_auth_cipher(
7081 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7085 test_zuc_auth_cipher_test_case_1_sgl(void)
7087 return test_zuc_auth_cipher_sgl(
7088 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7092 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7094 return test_zuc_auth_cipher_sgl(
7095 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7099 test_zuc_auth_cipher_verify_test_case_1(void)
7101 return test_zuc_auth_cipher(
7102 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7106 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7108 return test_zuc_auth_cipher(
7109 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7113 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7115 return test_zuc_auth_cipher_sgl(
7116 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7120 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7122 return test_zuc_auth_cipher_sgl(
7123 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7127 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7129 uint8_t dev_id = testsuite_params.valid_devs[0];
7131 struct rte_cryptodev_sym_capability_idx cap_idx;
7133 /* Check if device supports particular cipher algorithm */
7134 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7135 cap_idx.algo.cipher = tdata->cipher_algo;
7136 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7137 return TEST_SKIPPED;
7139 /* Check if device supports particular hash algorithm */
7140 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7141 cap_idx.algo.auth = tdata->auth_algo;
7142 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7143 return TEST_SKIPPED;
7149 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7150 uint8_t op_mode, uint8_t verify)
7152 struct crypto_testsuite_params *ts_params = &testsuite_params;
7153 struct crypto_unittest_params *ut_params = &unittest_params;
7157 uint8_t *plaintext = NULL, *ciphertext = NULL;
7158 unsigned int plaintext_pad_len;
7159 unsigned int plaintext_len;
7160 unsigned int ciphertext_pad_len;
7161 unsigned int ciphertext_len;
7163 struct rte_cryptodev_info dev_info;
7164 struct rte_crypto_op *op;
7166 /* Check if device supports particular algorithms separately */
7167 if (test_mixed_check_if_unsupported(tdata))
7168 return TEST_SKIPPED;
7169 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7170 return TEST_SKIPPED;
7172 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7174 uint64_t feat_flags = dev_info.feature_flags;
7176 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7177 printf("Device doesn't support digest encrypted.\n");
7178 return TEST_SKIPPED;
7181 /* Create the session */
7183 retval = create_wireless_algo_cipher_auth_session(
7184 ts_params->valid_devs[0],
7185 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7186 RTE_CRYPTO_AUTH_OP_VERIFY,
7189 tdata->auth_key.data, tdata->auth_key.len,
7190 tdata->auth_iv.len, tdata->digest_enc.len,
7191 tdata->cipher_iv.len);
7193 retval = create_wireless_algo_auth_cipher_session(
7194 ts_params->valid_devs[0],
7195 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7196 RTE_CRYPTO_AUTH_OP_GENERATE,
7199 tdata->auth_key.data, tdata->auth_key.len,
7200 tdata->auth_iv.len, tdata->digest_enc.len,
7201 tdata->cipher_iv.len);
7205 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7206 if (op_mode == OUT_OF_PLACE)
7207 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7209 /* clear mbuf payload */
7210 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7211 rte_pktmbuf_tailroom(ut_params->ibuf));
7212 if (op_mode == OUT_OF_PLACE) {
7214 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7215 rte_pktmbuf_tailroom(ut_params->obuf));
7218 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7219 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7220 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7221 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7224 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7225 ciphertext_pad_len);
7226 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7227 if (op_mode == OUT_OF_PLACE)
7228 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7229 debug_hexdump(stdout, "ciphertext:", ciphertext,
7232 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7234 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7235 if (op_mode == OUT_OF_PLACE)
7236 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7237 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7240 /* Create the operation */
7241 retval = create_wireless_algo_auth_cipher_operation(
7242 tdata->digest_enc.data, tdata->digest_enc.len,
7243 tdata->cipher_iv.data, tdata->cipher_iv.len,
7244 tdata->auth_iv.data, tdata->auth_iv.len,
7245 (tdata->digest_enc.offset == 0 ?
7247 : tdata->digest_enc.offset),
7248 tdata->validCipherLen.len_bits,
7249 tdata->cipher.offset_bits,
7250 tdata->validAuthLen.len_bits,
7251 tdata->auth.offset_bits,
7252 op_mode, 0, verify);
7257 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7259 /* Check if the op failed because the device doesn't */
7260 /* support this particular combination of algorithms */
7261 if (op == NULL && ut_params->op->status ==
7262 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7263 printf("Device doesn't support this mixed combination. "
7265 return TEST_SKIPPED;
7269 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7271 ut_params->obuf = (op_mode == IN_PLACE ?
7272 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7275 if (ut_params->obuf)
7276 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7279 plaintext = ciphertext +
7280 (tdata->cipher.offset_bits >> 3);
7282 debug_hexdump(stdout, "plaintext:", plaintext,
7283 tdata->plaintext.len_bits >> 3);
7284 debug_hexdump(stdout, "plaintext expected:",
7285 tdata->plaintext.data,
7286 tdata->plaintext.len_bits >> 3);
7288 if (ut_params->obuf)
7289 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7292 ciphertext = plaintext;
7294 debug_hexdump(stdout, "ciphertext:", ciphertext,
7296 debug_hexdump(stdout, "ciphertext expected:",
7297 tdata->ciphertext.data,
7298 tdata->ciphertext.len_bits >> 3);
7300 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7301 + (tdata->digest_enc.offset == 0 ?
7302 plaintext_pad_len : tdata->digest_enc.offset);
7304 debug_hexdump(stdout, "digest:", ut_params->digest,
7305 tdata->digest_enc.len);
7306 debug_hexdump(stdout, "digest expected:",
7307 tdata->digest_enc.data,
7308 tdata->digest_enc.len);
7313 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7315 tdata->plaintext.data,
7316 tdata->plaintext.len_bits >> 3,
7317 "Plaintext data not as expected");
7319 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7321 tdata->ciphertext.data,
7322 tdata->validDataLen.len_bits,
7323 "Ciphertext data not as expected");
7325 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7327 tdata->digest_enc.data,
7328 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7329 "Generated auth tag not as expected");
7332 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7333 "crypto op processing failed");
7339 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7340 uint8_t op_mode, uint8_t verify)
7342 struct crypto_testsuite_params *ts_params = &testsuite_params;
7343 struct crypto_unittest_params *ut_params = &unittest_params;
7347 const uint8_t *plaintext = NULL;
7348 const uint8_t *ciphertext = NULL;
7349 const uint8_t *digest = NULL;
7350 unsigned int plaintext_pad_len;
7351 unsigned int plaintext_len;
7352 unsigned int ciphertext_pad_len;
7353 unsigned int ciphertext_len;
7354 uint8_t buffer[10000];
7355 uint8_t digest_buffer[10000];
7357 struct rte_cryptodev_info dev_info;
7358 struct rte_crypto_op *op;
7360 /* Check if device supports particular algorithms */
7361 if (test_mixed_check_if_unsupported(tdata))
7362 return TEST_SKIPPED;
7363 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7364 return TEST_SKIPPED;
7366 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7368 uint64_t feat_flags = dev_info.feature_flags;
7370 if (op_mode == IN_PLACE) {
7371 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7372 printf("Device doesn't support in-place scatter-gather "
7373 "in both input and output mbufs.\n");
7374 return TEST_SKIPPED;
7377 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7378 printf("Device doesn't support out-of-place scatter-gather "
7379 "in both input and output mbufs.\n");
7380 return TEST_SKIPPED;
7382 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7383 printf("Device doesn't support digest encrypted.\n");
7384 return TEST_SKIPPED;
7388 /* Create the session */
7390 retval = create_wireless_algo_cipher_auth_session(
7391 ts_params->valid_devs[0],
7392 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7393 RTE_CRYPTO_AUTH_OP_VERIFY,
7396 tdata->auth_key.data, tdata->auth_key.len,
7397 tdata->auth_iv.len, tdata->digest_enc.len,
7398 tdata->cipher_iv.len);
7400 retval = create_wireless_algo_auth_cipher_session(
7401 ts_params->valid_devs[0],
7402 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7403 RTE_CRYPTO_AUTH_OP_GENERATE,
7406 tdata->auth_key.data, tdata->auth_key.len,
7407 tdata->auth_iv.len, tdata->digest_enc.len,
7408 tdata->cipher_iv.len);
7412 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7413 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7414 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7415 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7417 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7418 ciphertext_pad_len, 15, 0);
7419 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7420 "Failed to allocate input buffer in mempool");
7422 if (op_mode == OUT_OF_PLACE) {
7423 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7424 plaintext_pad_len, 15, 0);
7425 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7426 "Failed to allocate output buffer in mempool");
7430 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7431 tdata->ciphertext.data);
7432 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7433 ciphertext_len, buffer);
7434 debug_hexdump(stdout, "ciphertext:", ciphertext,
7437 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7438 tdata->plaintext.data);
7439 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7440 plaintext_len, buffer);
7441 debug_hexdump(stdout, "plaintext:", plaintext,
7444 memset(buffer, 0, sizeof(buffer));
7446 /* Create the operation */
7447 retval = create_wireless_algo_auth_cipher_operation(
7448 tdata->digest_enc.data, tdata->digest_enc.len,
7449 tdata->cipher_iv.data, tdata->cipher_iv.len,
7450 tdata->auth_iv.data, tdata->auth_iv.len,
7451 (tdata->digest_enc.offset == 0 ?
7453 : tdata->digest_enc.offset),
7454 tdata->validCipherLen.len_bits,
7455 tdata->cipher.offset_bits,
7456 tdata->validAuthLen.len_bits,
7457 tdata->auth.offset_bits,
7458 op_mode, 1, verify);
7463 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7465 /* Check if the op failed because the device doesn't */
7466 /* support this particular combination of algorithms */
7467 if (op == NULL && ut_params->op->status ==
7468 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7469 printf("Device doesn't support this mixed combination. "
7471 return TEST_SKIPPED;
7475 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7477 ut_params->obuf = (op_mode == IN_PLACE ?
7478 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7481 if (ut_params->obuf)
7482 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7483 plaintext_len, buffer);
7485 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7486 plaintext_len, buffer);
7488 debug_hexdump(stdout, "plaintext:", plaintext,
7489 (tdata->plaintext.len_bits >> 3) -
7490 tdata->digest_enc.len);
7491 debug_hexdump(stdout, "plaintext expected:",
7492 tdata->plaintext.data,
7493 (tdata->plaintext.len_bits >> 3) -
7494 tdata->digest_enc.len);
7496 if (ut_params->obuf)
7497 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7498 ciphertext_len, buffer);
7500 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7501 ciphertext_len, buffer);
7503 debug_hexdump(stdout, "ciphertext:", ciphertext,
7505 debug_hexdump(stdout, "ciphertext expected:",
7506 tdata->ciphertext.data,
7507 tdata->ciphertext.len_bits >> 3);
7509 if (ut_params->obuf)
7510 digest = rte_pktmbuf_read(ut_params->obuf,
7511 (tdata->digest_enc.offset == 0 ?
7513 tdata->digest_enc.offset),
7514 tdata->digest_enc.len, digest_buffer);
7516 digest = rte_pktmbuf_read(ut_params->ibuf,
7517 (tdata->digest_enc.offset == 0 ?
7519 tdata->digest_enc.offset),
7520 tdata->digest_enc.len, digest_buffer);
7522 debug_hexdump(stdout, "digest:", digest,
7523 tdata->digest_enc.len);
7524 debug_hexdump(stdout, "digest expected:",
7525 tdata->digest_enc.data, tdata->digest_enc.len);
7530 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7532 tdata->plaintext.data,
7533 tdata->plaintext.len_bits >> 3,
7534 "Plaintext data not as expected");
7536 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7538 tdata->ciphertext.data,
7539 tdata->validDataLen.len_bits,
7540 "Ciphertext data not as expected");
7541 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7543 tdata->digest_enc.data,
7544 tdata->digest_enc.len,
7545 "Generated auth tag not as expected");
7548 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7549 "crypto op processing failed");
7554 /** AUTH AES CMAC + CIPHER AES CTR */
7557 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7559 return test_mixed_auth_cipher(
7560 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7564 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7566 return test_mixed_auth_cipher(
7567 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7571 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7573 return test_mixed_auth_cipher_sgl(
7574 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7578 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7580 return test_mixed_auth_cipher_sgl(
7581 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7585 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7587 return test_mixed_auth_cipher(
7588 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7592 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7594 return test_mixed_auth_cipher(
7595 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7599 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7601 return test_mixed_auth_cipher_sgl(
7602 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7606 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7608 return test_mixed_auth_cipher_sgl(
7609 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7612 /** MIXED AUTH + CIPHER */
7615 test_auth_zuc_cipher_snow_test_case_1(void)
7617 return test_mixed_auth_cipher(
7618 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7622 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7624 return test_mixed_auth_cipher(
7625 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7629 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7631 return test_mixed_auth_cipher(
7632 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7636 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7638 return test_mixed_auth_cipher(
7639 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7643 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7645 return test_mixed_auth_cipher(
7646 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7650 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7652 return test_mixed_auth_cipher(
7653 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7657 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7659 return test_mixed_auth_cipher(
7660 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7664 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7666 return test_mixed_auth_cipher(
7667 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7671 test_auth_snow_cipher_zuc_test_case_1(void)
7673 return test_mixed_auth_cipher(
7674 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7678 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7680 return test_mixed_auth_cipher(
7681 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7685 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7687 return test_mixed_auth_cipher(
7688 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7692 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7694 return test_mixed_auth_cipher(
7695 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7699 test_auth_null_cipher_snow_test_case_1(void)
7701 return test_mixed_auth_cipher(
7702 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7706 test_verify_auth_null_cipher_snow_test_case_1(void)
7708 return test_mixed_auth_cipher(
7709 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7713 test_auth_null_cipher_zuc_test_case_1(void)
7715 return test_mixed_auth_cipher(
7716 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7720 test_verify_auth_null_cipher_zuc_test_case_1(void)
7722 return test_mixed_auth_cipher(
7723 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7727 test_auth_snow_cipher_null_test_case_1(void)
7729 return test_mixed_auth_cipher(
7730 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7734 test_verify_auth_snow_cipher_null_test_case_1(void)
7736 return test_mixed_auth_cipher(
7737 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7741 test_auth_zuc_cipher_null_test_case_1(void)
7743 return test_mixed_auth_cipher(
7744 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7748 test_verify_auth_zuc_cipher_null_test_case_1(void)
7750 return test_mixed_auth_cipher(
7751 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7755 test_auth_null_cipher_aes_ctr_test_case_1(void)
7757 return test_mixed_auth_cipher(
7758 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7762 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7764 return test_mixed_auth_cipher(
7765 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7769 test_auth_aes_cmac_cipher_null_test_case_1(void)
7771 return test_mixed_auth_cipher(
7772 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7776 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7778 return test_mixed_auth_cipher(
7779 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7782 /* ***** AEAD algorithm Tests ***** */
7785 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7786 enum rte_crypto_aead_operation op,
7787 const uint8_t *key, const uint8_t key_len,
7788 const uint16_t aad_len, const uint8_t auth_len,
7791 uint8_t aead_key[key_len];
7793 struct crypto_testsuite_params *ts_params = &testsuite_params;
7794 struct crypto_unittest_params *ut_params = &unittest_params;
7796 memcpy(aead_key, key, key_len);
7798 /* Setup AEAD Parameters */
7799 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7800 ut_params->aead_xform.next = NULL;
7801 ut_params->aead_xform.aead.algo = algo;
7802 ut_params->aead_xform.aead.op = op;
7803 ut_params->aead_xform.aead.key.data = aead_key;
7804 ut_params->aead_xform.aead.key.length = key_len;
7805 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7806 ut_params->aead_xform.aead.iv.length = iv_len;
7807 ut_params->aead_xform.aead.digest_length = auth_len;
7808 ut_params->aead_xform.aead.aad_length = aad_len;
7810 debug_hexdump(stdout, "key:", key, key_len);
7812 /* Create Crypto session*/
7813 ut_params->sess = rte_cryptodev_sym_session_create(
7814 ts_params->session_mpool);
7816 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7817 &ut_params->aead_xform,
7818 ts_params->session_priv_mpool);
7820 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7826 create_aead_xform(struct rte_crypto_op *op,
7827 enum rte_crypto_aead_algorithm algo,
7828 enum rte_crypto_aead_operation aead_op,
7829 uint8_t *key, const uint8_t key_len,
7830 const uint8_t aad_len, const uint8_t auth_len,
7833 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7834 "failed to allocate space for crypto transform");
7836 struct rte_crypto_sym_op *sym_op = op->sym;
7838 /* Setup AEAD Parameters */
7839 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7840 sym_op->xform->next = NULL;
7841 sym_op->xform->aead.algo = algo;
7842 sym_op->xform->aead.op = aead_op;
7843 sym_op->xform->aead.key.data = key;
7844 sym_op->xform->aead.key.length = key_len;
7845 sym_op->xform->aead.iv.offset = IV_OFFSET;
7846 sym_op->xform->aead.iv.length = iv_len;
7847 sym_op->xform->aead.digest_length = auth_len;
7848 sym_op->xform->aead.aad_length = aad_len;
7850 debug_hexdump(stdout, "key:", key, key_len);
7856 create_aead_operation(enum rte_crypto_aead_operation op,
7857 const struct aead_test_data *tdata)
7859 struct crypto_testsuite_params *ts_params = &testsuite_params;
7860 struct crypto_unittest_params *ut_params = &unittest_params;
7862 uint8_t *plaintext, *ciphertext;
7863 unsigned int aad_pad_len, plaintext_pad_len;
7865 /* Generate Crypto op data structure */
7866 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7867 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7868 TEST_ASSERT_NOT_NULL(ut_params->op,
7869 "Failed to allocate symmetric crypto operation struct");
7871 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7873 /* Append aad data */
7874 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7875 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7876 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7878 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7879 "no room to append aad");
7881 sym_op->aead.aad.phys_addr =
7882 rte_pktmbuf_iova(ut_params->ibuf);
7883 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7884 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7885 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7888 /* Append IV at the end of the crypto operation*/
7889 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7890 uint8_t *, IV_OFFSET);
7892 /* Copy IV 1 byte after the IV pointer, according to the API */
7893 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7894 debug_hexdump(stdout, "iv:", iv_ptr,
7897 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7898 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7900 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7901 "no room to append aad");
7903 sym_op->aead.aad.phys_addr =
7904 rte_pktmbuf_iova(ut_params->ibuf);
7905 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7906 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7909 /* Append IV at the end of the crypto operation*/
7910 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7911 uint8_t *, IV_OFFSET);
7913 if (tdata->iv.len == 0) {
7914 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7915 debug_hexdump(stdout, "iv:", iv_ptr,
7918 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7919 debug_hexdump(stdout, "iv:", iv_ptr,
7924 /* Append plaintext/ciphertext */
7925 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7926 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7927 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7929 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7931 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7932 debug_hexdump(stdout, "plaintext:", plaintext,
7933 tdata->plaintext.len);
7935 if (ut_params->obuf) {
7936 ciphertext = (uint8_t *)rte_pktmbuf_append(
7938 plaintext_pad_len + aad_pad_len);
7939 TEST_ASSERT_NOT_NULL(ciphertext,
7940 "no room to append ciphertext");
7942 memset(ciphertext + aad_pad_len, 0,
7943 tdata->ciphertext.len);
7946 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7947 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7949 TEST_ASSERT_NOT_NULL(ciphertext,
7950 "no room to append ciphertext");
7952 memcpy(ciphertext, tdata->ciphertext.data,
7953 tdata->ciphertext.len);
7954 debug_hexdump(stdout, "ciphertext:", ciphertext,
7955 tdata->ciphertext.len);
7957 if (ut_params->obuf) {
7958 plaintext = (uint8_t *)rte_pktmbuf_append(
7960 plaintext_pad_len + aad_pad_len);
7961 TEST_ASSERT_NOT_NULL(plaintext,
7962 "no room to append plaintext");
7964 memset(plaintext + aad_pad_len, 0,
7965 tdata->plaintext.len);
7969 /* Append digest data */
7970 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7971 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7972 ut_params->obuf ? ut_params->obuf :
7974 tdata->auth_tag.len);
7975 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7976 "no room to append digest");
7977 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7978 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7979 ut_params->obuf ? ut_params->obuf :
7984 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7985 ut_params->ibuf, tdata->auth_tag.len);
7986 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7987 "no room to append digest");
7988 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7990 plaintext_pad_len + aad_pad_len);
7992 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7993 tdata->auth_tag.len);
7994 debug_hexdump(stdout, "digest:",
7995 sym_op->aead.digest.data,
7996 tdata->auth_tag.len);
7999 sym_op->aead.data.length = tdata->plaintext.len;
8000 sym_op->aead.data.offset = aad_pad_len;
8006 test_authenticated_encryption(const struct aead_test_data *tdata)
8008 struct crypto_testsuite_params *ts_params = &testsuite_params;
8009 struct crypto_unittest_params *ut_params = &unittest_params;
8012 uint8_t *ciphertext, *auth_tag;
8013 uint16_t plaintext_pad_len;
8015 struct rte_cryptodev_info dev_info;
8017 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8018 uint64_t feat_flags = dev_info.feature_flags;
8020 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8021 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8022 printf("Device doesn't support RAW data-path APIs.\n");
8023 return TEST_SKIPPED;
8026 /* Verify the capabilities */
8027 struct rte_cryptodev_sym_capability_idx cap_idx;
8028 const struct rte_cryptodev_symmetric_capability *capability;
8029 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8030 cap_idx.algo.aead = tdata->algo;
8031 capability = rte_cryptodev_sym_capability_get(
8032 ts_params->valid_devs[0], &cap_idx);
8033 if (capability == NULL)
8034 return TEST_SKIPPED;
8035 if (rte_cryptodev_sym_capability_check_aead(
8036 capability, tdata->key.len, tdata->auth_tag.len,
8037 tdata->aad.len, tdata->iv.len))
8038 return TEST_SKIPPED;
8040 /* Create AEAD session */
8041 retval = create_aead_session(ts_params->valid_devs[0],
8043 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8044 tdata->key.data, tdata->key.len,
8045 tdata->aad.len, tdata->auth_tag.len,
8050 if (tdata->aad.len > MBUF_SIZE) {
8051 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8052 /* Populate full size of add data */
8053 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8054 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8056 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8058 /* clear mbuf payload */
8059 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8060 rte_pktmbuf_tailroom(ut_params->ibuf));
8062 /* Create AEAD operation */
8063 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8067 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8069 ut_params->op->sym->m_src = ut_params->ibuf;
8071 /* Process crypto operation */
8072 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8073 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8074 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8075 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8076 ut_params->op, 0, 0, 0, 0);
8078 TEST_ASSERT_NOT_NULL(
8079 process_crypto_request(ts_params->valid_devs[0],
8080 ut_params->op), "failed to process sym crypto op");
8082 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8083 "crypto op processing failed");
8085 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8087 if (ut_params->op->sym->m_dst) {
8088 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8090 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8091 uint8_t *, plaintext_pad_len);
8093 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8095 ut_params->op->sym->cipher.data.offset);
8096 auth_tag = ciphertext + plaintext_pad_len;
8099 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8100 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8103 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8105 tdata->ciphertext.data,
8106 tdata->ciphertext.len,
8107 "Ciphertext data not as expected");
8109 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8111 tdata->auth_tag.data,
8112 tdata->auth_tag.len,
8113 "Generated auth tag not as expected");
8119 #ifdef RTE_LIB_SECURITY
8121 security_proto_supported(enum rte_security_session_action_type action,
8122 enum rte_security_session_protocol proto)
8124 struct crypto_testsuite_params *ts_params = &testsuite_params;
8126 const struct rte_security_capability *capabilities;
8127 const struct rte_security_capability *capability;
8130 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8131 rte_cryptodev_get_sec_ctx(
8132 ts_params->valid_devs[0]);
8135 capabilities = rte_security_capabilities_get(ctx);
8137 if (capabilities == NULL)
8140 while ((capability = &capabilities[i++])->action !=
8141 RTE_SECURITY_ACTION_TYPE_NONE) {
8142 if (capability->action == action &&
8143 capability->protocol == proto)
8150 /* Basic algorithm run function for async inplace mode.
8151 * Creates a session from input parameters and runs one operation
8152 * on input_vec. Checks the output of the crypto operation against
8155 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8156 enum rte_crypto_auth_operation opa,
8157 const uint8_t *input_vec, unsigned int input_vec_len,
8158 const uint8_t *output_vec,
8159 unsigned int output_vec_len,
8160 enum rte_crypto_cipher_algorithm cipher_alg,
8161 const uint8_t *cipher_key, uint32_t cipher_key_len,
8162 enum rte_crypto_auth_algorithm auth_alg,
8163 const uint8_t *auth_key, uint32_t auth_key_len,
8164 uint8_t bearer, enum rte_security_pdcp_domain domain,
8165 uint8_t packet_direction, uint8_t sn_size,
8166 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8168 struct crypto_testsuite_params *ts_params = &testsuite_params;
8169 struct crypto_unittest_params *ut_params = &unittest_params;
8171 int ret = TEST_SUCCESS;
8172 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8173 rte_cryptodev_get_sec_ctx(
8174 ts_params->valid_devs[0]);
8176 /* Verify the capabilities */
8177 struct rte_security_capability_idx sec_cap_idx;
8179 sec_cap_idx.action = ut_params->type;
8180 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8181 sec_cap_idx.pdcp.domain = domain;
8182 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8183 return TEST_SKIPPED;
8185 /* Generate test mbuf data */
8186 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8188 /* clear mbuf payload */
8189 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8190 rte_pktmbuf_tailroom(ut_params->ibuf));
8192 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8194 memcpy(plaintext, input_vec, input_vec_len);
8196 /* Out of place support */
8199 * For out-op-place we need to alloc another mbuf
8201 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8202 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8205 /* Setup Cipher Parameters */
8206 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8207 ut_params->cipher_xform.cipher.algo = cipher_alg;
8208 ut_params->cipher_xform.cipher.op = opc;
8209 ut_params->cipher_xform.cipher.key.data = cipher_key;
8210 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8211 ut_params->cipher_xform.cipher.iv.length =
8212 packet_direction ? 4 : 0;
8213 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8215 /* Setup HMAC Parameters if ICV header is required */
8216 if (auth_alg != 0) {
8217 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8218 ut_params->auth_xform.next = NULL;
8219 ut_params->auth_xform.auth.algo = auth_alg;
8220 ut_params->auth_xform.auth.op = opa;
8221 ut_params->auth_xform.auth.key.data = auth_key;
8222 ut_params->auth_xform.auth.key.length = auth_key_len;
8224 ut_params->cipher_xform.next = &ut_params->auth_xform;
8226 ut_params->cipher_xform.next = NULL;
8229 struct rte_security_session_conf sess_conf = {
8230 .action_type = ut_params->type,
8231 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8235 .pkt_dir = packet_direction,
8237 .hfn = packet_direction ? 0 : hfn,
8239 * hfn can be set as pdcp_test_hfn[i]
8240 * if hfn_ovrd is not set. Here, PDCP
8241 * packet direction is just used to
8242 * run half of the cases with session
8243 * HFN and other half with per packet
8246 .hfn_threshold = hfn_threshold,
8247 .hfn_ovrd = packet_direction ? 1 : 0,
8248 .sdap_enabled = sdap,
8250 .crypto_xform = &ut_params->cipher_xform
8253 /* Create security session */
8254 ut_params->sec_session = rte_security_session_create(ctx,
8255 &sess_conf, ts_params->session_mpool,
8256 ts_params->session_priv_mpool);
8258 if (!ut_params->sec_session) {
8259 printf("TestCase %s()-%d line %d failed %s: ",
8260 __func__, i, __LINE__, "Failed to allocate session");
8265 /* Generate crypto op data structure */
8266 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8267 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8268 if (!ut_params->op) {
8269 printf("TestCase %s()-%d line %d failed %s: ",
8270 __func__, i, __LINE__,
8271 "Failed to allocate symmetric crypto operation struct");
8276 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8277 uint32_t *, IV_OFFSET);
8278 *per_pkt_hfn = packet_direction ? hfn : 0;
8280 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8282 /* set crypto operation source mbuf */
8283 ut_params->op->sym->m_src = ut_params->ibuf;
8285 ut_params->op->sym->m_dst = ut_params->obuf;
8287 /* Process crypto operation */
8288 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8290 printf("TestCase %s()-%d line %d failed %s: ",
8291 __func__, i, __LINE__,
8292 "failed to process sym crypto op");
8297 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8298 printf("TestCase %s()-%d line %d failed %s: ",
8299 __func__, i, __LINE__, "crypto op processing failed");
8305 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8308 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8312 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8313 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8314 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8315 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8321 rte_crypto_op_free(ut_params->op);
8322 ut_params->op = NULL;
8324 if (ut_params->sec_session)
8325 rte_security_session_destroy(ctx, ut_params->sec_session);
8326 ut_params->sec_session = NULL;
8328 rte_pktmbuf_free(ut_params->ibuf);
8329 ut_params->ibuf = NULL;
8331 rte_pktmbuf_free(ut_params->obuf);
8332 ut_params->obuf = NULL;
8339 test_pdcp_proto_SGL(int i, int oop,
8340 enum rte_crypto_cipher_operation opc,
8341 enum rte_crypto_auth_operation opa,
8343 unsigned int input_vec_len,
8344 uint8_t *output_vec,
8345 unsigned int output_vec_len,
8347 uint32_t fragsz_oop)
8349 struct crypto_testsuite_params *ts_params = &testsuite_params;
8350 struct crypto_unittest_params *ut_params = &unittest_params;
8352 struct rte_mbuf *buf, *buf_oop = NULL;
8353 int ret = TEST_SUCCESS;
8357 unsigned int trn_data = 0;
8358 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8359 rte_cryptodev_get_sec_ctx(
8360 ts_params->valid_devs[0]);
8362 /* Verify the capabilities */
8363 struct rte_security_capability_idx sec_cap_idx;
8365 sec_cap_idx.action = ut_params->type;
8366 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8367 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8368 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8369 return TEST_SKIPPED;
8371 if (fragsz > input_vec_len)
8372 fragsz = input_vec_len;
8374 uint16_t plaintext_len = fragsz;
8375 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8377 if (fragsz_oop > output_vec_len)
8378 frag_size_oop = output_vec_len;
8381 if (input_vec_len % fragsz != 0) {
8382 if (input_vec_len / fragsz + 1 > 16)
8384 } else if (input_vec_len / fragsz > 16)
8387 /* Out of place support */
8390 * For out-op-place we need to alloc another mbuf
8392 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8393 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8394 buf_oop = ut_params->obuf;
8397 /* Generate test mbuf data */
8398 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8400 /* clear mbuf payload */
8401 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8402 rte_pktmbuf_tailroom(ut_params->ibuf));
8404 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8406 memcpy(plaintext, input_vec, plaintext_len);
8407 trn_data += plaintext_len;
8409 buf = ut_params->ibuf;
8412 * Loop until no more fragments
8415 while (trn_data < input_vec_len) {
8417 to_trn = (input_vec_len - trn_data < fragsz) ?
8418 (input_vec_len - trn_data) : fragsz;
8420 to_trn_tbl[ecx++] = to_trn;
8422 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8425 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8426 rte_pktmbuf_tailroom(buf));
8429 if (oop && !fragsz_oop) {
8431 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8432 buf_oop = buf_oop->next;
8433 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8434 0, rte_pktmbuf_tailroom(buf_oop));
8435 rte_pktmbuf_append(buf_oop, to_trn);
8438 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8441 memcpy(plaintext, input_vec + trn_data, to_trn);
8445 ut_params->ibuf->nb_segs = segs;
8448 if (fragsz_oop && oop) {
8452 trn_data = frag_size_oop;
8453 while (trn_data < output_vec_len) {
8456 (output_vec_len - trn_data <
8458 (output_vec_len - trn_data) :
8461 to_trn_tbl[ecx++] = to_trn;
8464 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8465 buf_oop = buf_oop->next;
8466 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8467 0, rte_pktmbuf_tailroom(buf_oop));
8468 rte_pktmbuf_append(buf_oop, to_trn);
8472 ut_params->obuf->nb_segs = segs;
8475 /* Setup Cipher Parameters */
8476 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8477 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8478 ut_params->cipher_xform.cipher.op = opc;
8479 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8480 ut_params->cipher_xform.cipher.key.length =
8481 pdcp_test_params[i].cipher_key_len;
8482 ut_params->cipher_xform.cipher.iv.length = 0;
8484 /* Setup HMAC Parameters if ICV header is required */
8485 if (pdcp_test_params[i].auth_alg != 0) {
8486 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8487 ut_params->auth_xform.next = NULL;
8488 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8489 ut_params->auth_xform.auth.op = opa;
8490 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8491 ut_params->auth_xform.auth.key.length =
8492 pdcp_test_params[i].auth_key_len;
8494 ut_params->cipher_xform.next = &ut_params->auth_xform;
8496 ut_params->cipher_xform.next = NULL;
8499 struct rte_security_session_conf sess_conf = {
8500 .action_type = ut_params->type,
8501 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8503 .bearer = pdcp_test_bearer[i],
8504 .domain = pdcp_test_params[i].domain,
8505 .pkt_dir = pdcp_test_packet_direction[i],
8506 .sn_size = pdcp_test_data_sn_size[i],
8507 .hfn = pdcp_test_hfn[i],
8508 .hfn_threshold = pdcp_test_hfn_threshold[i],
8511 .crypto_xform = &ut_params->cipher_xform
8514 /* Create security session */
8515 ut_params->sec_session = rte_security_session_create(ctx,
8516 &sess_conf, ts_params->session_mpool,
8517 ts_params->session_priv_mpool);
8519 if (!ut_params->sec_session) {
8520 printf("TestCase %s()-%d line %d failed %s: ",
8521 __func__, i, __LINE__, "Failed to allocate session");
8526 /* Generate crypto op data structure */
8527 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8528 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8529 if (!ut_params->op) {
8530 printf("TestCase %s()-%d line %d failed %s: ",
8531 __func__, i, __LINE__,
8532 "Failed to allocate symmetric crypto operation struct");
8537 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8539 /* set crypto operation source mbuf */
8540 ut_params->op->sym->m_src = ut_params->ibuf;
8542 ut_params->op->sym->m_dst = ut_params->obuf;
8544 /* Process crypto operation */
8545 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8547 printf("TestCase %s()-%d line %d failed %s: ",
8548 __func__, i, __LINE__,
8549 "failed to process sym crypto op");
8554 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8555 printf("TestCase %s()-%d line %d failed %s: ",
8556 __func__, i, __LINE__, "crypto op processing failed");
8562 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8565 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8569 fragsz = frag_size_oop;
8570 if (memcmp(ciphertext, output_vec, fragsz)) {
8571 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8572 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8573 rte_hexdump(stdout, "reference", output_vec, fragsz);
8578 buf = ut_params->op->sym->m_src->next;
8580 buf = ut_params->op->sym->m_dst->next;
8582 unsigned int off = fragsz;
8586 ciphertext = rte_pktmbuf_mtod(buf,
8588 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8589 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8590 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8591 rte_hexdump(stdout, "reference", output_vec + off,
8596 off += to_trn_tbl[ecx++];
8600 rte_crypto_op_free(ut_params->op);
8601 ut_params->op = NULL;
8603 if (ut_params->sec_session)
8604 rte_security_session_destroy(ctx, ut_params->sec_session);
8605 ut_params->sec_session = NULL;
8607 rte_pktmbuf_free(ut_params->ibuf);
8608 ut_params->ibuf = NULL;
8610 rte_pktmbuf_free(ut_params->obuf);
8611 ut_params->obuf = NULL;
8618 test_pdcp_proto_cplane_encap(int i)
8620 return test_pdcp_proto(
8621 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8622 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8623 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8624 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8625 pdcp_test_params[i].cipher_key_len,
8626 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8627 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8628 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8629 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8630 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8634 test_pdcp_proto_uplane_encap(int i)
8636 return test_pdcp_proto(
8637 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8638 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8639 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8640 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8641 pdcp_test_params[i].cipher_key_len,
8642 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8643 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8644 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8645 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8646 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8650 test_pdcp_proto_uplane_encap_with_int(int i)
8652 return test_pdcp_proto(
8653 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8654 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8655 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8656 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8657 pdcp_test_params[i].cipher_key_len,
8658 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8659 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8660 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8661 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8662 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8666 test_pdcp_proto_cplane_decap(int i)
8668 return test_pdcp_proto(
8669 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8670 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8671 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8672 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8673 pdcp_test_params[i].cipher_key_len,
8674 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8675 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8676 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8677 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8678 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8682 test_pdcp_proto_uplane_decap(int i)
8684 return test_pdcp_proto(
8685 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8686 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8687 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8688 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8689 pdcp_test_params[i].cipher_key_len,
8690 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8691 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8692 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8693 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8694 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8698 test_pdcp_proto_uplane_decap_with_int(int i)
8700 return test_pdcp_proto(
8701 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8702 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8703 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8704 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8705 pdcp_test_params[i].cipher_key_len,
8706 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8707 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8708 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8709 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8710 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8714 test_PDCP_PROTO_SGL_in_place_32B(void)
8716 /* i can be used for running any PDCP case
8717 * In this case it is uplane 12-bit AES-SNOW DL encap
8719 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8720 return test_pdcp_proto_SGL(i, IN_PLACE,
8721 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8722 RTE_CRYPTO_AUTH_OP_GENERATE,
8723 pdcp_test_data_in[i],
8724 pdcp_test_data_in_len[i],
8725 pdcp_test_data_out[i],
8726 pdcp_test_data_in_len[i]+4,
8730 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8732 /* i can be used for running any PDCP case
8733 * In this case it is uplane 18-bit NULL-NULL DL encap
8735 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8736 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8737 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8738 RTE_CRYPTO_AUTH_OP_GENERATE,
8739 pdcp_test_data_in[i],
8740 pdcp_test_data_in_len[i],
8741 pdcp_test_data_out[i],
8742 pdcp_test_data_in_len[i]+4,
8746 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8748 /* i can be used for running any PDCP case
8749 * In this case it is uplane 18-bit AES DL encap
8751 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8753 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8754 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8755 RTE_CRYPTO_AUTH_OP_GENERATE,
8756 pdcp_test_data_in[i],
8757 pdcp_test_data_in_len[i],
8758 pdcp_test_data_out[i],
8759 pdcp_test_data_in_len[i],
8763 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8765 /* i can be used for running any PDCP case
8766 * In this case it is cplane 12-bit AES-ZUC DL encap
8768 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8769 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8770 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8771 RTE_CRYPTO_AUTH_OP_GENERATE,
8772 pdcp_test_data_in[i],
8773 pdcp_test_data_in_len[i],
8774 pdcp_test_data_out[i],
8775 pdcp_test_data_in_len[i]+4,
8780 test_PDCP_SDAP_PROTO_encap_all(void)
8782 int i = 0, size = 0;
8783 int err, all_err = TEST_SUCCESS;
8784 const struct pdcp_sdap_test *cur_test;
8786 size = RTE_DIM(list_pdcp_sdap_tests);
8788 for (i = 0; i < size; i++) {
8789 cur_test = &list_pdcp_sdap_tests[i];
8790 err = test_pdcp_proto(
8791 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8792 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8793 cur_test->in_len, cur_test->data_out,
8794 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8795 cur_test->param.cipher_alg, cur_test->cipher_key,
8796 cur_test->param.cipher_key_len,
8797 cur_test->param.auth_alg,
8798 cur_test->auth_key, cur_test->param.auth_key_len,
8799 cur_test->bearer, cur_test->param.domain,
8800 cur_test->packet_direction, cur_test->sn_size,
8802 cur_test->hfn_threshold, SDAP_ENABLED);
8804 printf("\t%d) %s: Encapsulation failed\n",
8806 cur_test->param.name);
8809 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8810 cur_test->param.name);
8816 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8818 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8822 test_PDCP_PROTO_short_mac(void)
8824 int i = 0, size = 0;
8825 int err, all_err = TEST_SUCCESS;
8826 const struct pdcp_short_mac_test *cur_test;
8828 size = RTE_DIM(list_pdcp_smac_tests);
8830 for (i = 0; i < size; i++) {
8831 cur_test = &list_pdcp_smac_tests[i];
8832 err = test_pdcp_proto(
8833 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8834 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8835 cur_test->in_len, cur_test->data_out,
8836 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8837 RTE_CRYPTO_CIPHER_NULL, NULL,
8838 0, cur_test->param.auth_alg,
8839 cur_test->auth_key, cur_test->param.auth_key_len,
8840 0, cur_test->param.domain, 0, 0,
8843 printf("\t%d) %s: Short MAC test failed\n",
8845 cur_test->param.name);
8848 printf("\t%d) %s: Short MAC test PASS\n",
8850 cur_test->param.name);
8851 rte_hexdump(stdout, "MAC I",
8852 cur_test->data_out + cur_test->in_len + 2,
8859 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8861 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8866 test_PDCP_SDAP_PROTO_decap_all(void)
8868 int i = 0, size = 0;
8869 int err, all_err = TEST_SUCCESS;
8870 const struct pdcp_sdap_test *cur_test;
8872 size = RTE_DIM(list_pdcp_sdap_tests);
8874 for (i = 0; i < size; i++) {
8875 cur_test = &list_pdcp_sdap_tests[i];
8876 err = test_pdcp_proto(
8877 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8878 RTE_CRYPTO_AUTH_OP_VERIFY,
8880 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8881 cur_test->data_in, cur_test->in_len,
8882 cur_test->param.cipher_alg,
8883 cur_test->cipher_key, cur_test->param.cipher_key_len,
8884 cur_test->param.auth_alg, cur_test->auth_key,
8885 cur_test->param.auth_key_len, cur_test->bearer,
8886 cur_test->param.domain, cur_test->packet_direction,
8887 cur_test->sn_size, cur_test->hfn,
8888 cur_test->hfn_threshold, SDAP_ENABLED);
8890 printf("\t%d) %s: Decapsulation failed\n",
8892 cur_test->param.name);
8895 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8896 cur_test->param.name);
8902 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8904 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8908 test_ipsec_proto_process(const struct ipsec_test_data td[],
8909 struct ipsec_test_data res_d[],
8912 const struct ipsec_test_flags *flags)
8914 struct crypto_testsuite_params *ts_params = &testsuite_params;
8915 struct crypto_unittest_params *ut_params = &unittest_params;
8916 struct rte_security_capability_idx sec_cap_idx;
8917 const struct rte_security_capability *sec_cap;
8918 struct rte_security_ipsec_xform ipsec_xform;
8919 uint8_t dev_id = ts_params->valid_devs[0];
8920 enum rte_security_ipsec_sa_direction dir;
8921 struct ipsec_test_data *res_d_tmp = NULL;
8922 uint32_t src = RTE_IPV4(192, 168, 1, 0);
8923 uint32_t dst = RTE_IPV4(192, 168, 1, 1);
8924 int salt_len, i, ret = TEST_SUCCESS;
8925 struct rte_security_ctx *ctx;
8926 uint8_t *input_text;
8928 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8929 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8931 /* Use first test data to create session */
8933 /* Copy IPsec xform */
8934 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
8936 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src, sizeof(src));
8937 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst, sizeof(dst));
8939 dir = ipsec_xform.direction;
8941 ctx = rte_cryptodev_get_sec_ctx(dev_id);
8943 sec_cap_idx.action = ut_params->type;
8944 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
8945 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
8946 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
8947 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
8949 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8950 if (sec_cap == NULL)
8951 return TEST_SKIPPED;
8953 /* Copy cipher session parameters */
8955 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
8956 sizeof(ut_params->aead_xform));
8957 ut_params->aead_xform.aead.key.data = td[0].key.data;
8958 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8960 /* Verify crypto capabilities */
8961 if (test_ipsec_crypto_caps_aead_verify(
8963 &ut_params->aead_xform) != 0) {
8965 RTE_LOG(INFO, USER1,
8966 "Crypto capabilities not supported\n");
8967 return TEST_SKIPPED;
8970 /* Only AEAD supported now */
8971 return TEST_SKIPPED;
8974 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
8975 return TEST_SKIPPED;
8977 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
8978 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
8980 struct rte_security_session_conf sess_conf = {
8981 .action_type = ut_params->type,
8982 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
8983 .ipsec = ipsec_xform,
8984 .crypto_xform = &ut_params->aead_xform,
8987 /* Create security session */
8988 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8989 ts_params->session_mpool,
8990 ts_params->session_priv_mpool);
8992 if (ut_params->sec_session == NULL)
8993 return TEST_SKIPPED;
8995 for (i = 0; i < nb_td; i++) {
8996 /* Setup source mbuf payload */
8997 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8998 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8999 rte_pktmbuf_tailroom(ut_params->ibuf));
9001 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9002 td[i].input_text.len);
9004 memcpy(input_text, td[i].input_text.data,
9005 td[i].input_text.len);
9007 /* Generate crypto op data structure */
9008 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9009 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9010 if (!ut_params->op) {
9011 printf("TestCase %s line %d: %s\n",
9013 "failed to allocate crypto op");
9015 goto crypto_op_free;
9018 /* Attach session to operation */
9019 rte_security_attach_session(ut_params->op,
9020 ut_params->sec_session);
9022 /* Set crypto operation mbufs */
9023 ut_params->op->sym->m_src = ut_params->ibuf;
9024 ut_params->op->sym->m_dst = NULL;
9026 /* Process crypto operation */
9027 process_crypto_request(dev_id, ut_params->op);
9029 ret = test_ipsec_status_check(ut_params->op, flags, dir);
9030 if (ret != TEST_SUCCESS)
9031 goto crypto_op_free;
9034 res_d_tmp = &res_d[i];
9036 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9037 res_d_tmp, silent, flags);
9038 if (ret != TEST_SUCCESS)
9039 goto crypto_op_free;
9041 rte_crypto_op_free(ut_params->op);
9042 ut_params->op = NULL;
9044 rte_pktmbuf_free(ut_params->ibuf);
9045 ut_params->ibuf = NULL;
9049 rte_crypto_op_free(ut_params->op);
9050 ut_params->op = NULL;
9052 rte_pktmbuf_free(ut_params->ibuf);
9053 ut_params->ibuf = NULL;
9055 if (ut_params->sec_session)
9056 rte_security_session_destroy(ctx, ut_params->sec_session);
9057 ut_params->sec_session = NULL;
9063 test_ipsec_proto_known_vec_inb(const void *td_outb)
9065 struct ipsec_test_flags flags;
9066 struct ipsec_test_data td_inb;
9068 memset(&flags, 0, sizeof(flags));
9070 test_ipsec_td_in_from_out(td_outb, &td_inb);
9072 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9076 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9078 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9079 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9080 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9083 for (i = 0; i < RTE_DIM(aead_list); i++) {
9084 test_ipsec_td_prepare(&aead_list[i],
9090 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9092 if (ret == TEST_SKIPPED)
9095 if (ret == TEST_FAILED)
9098 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9100 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9102 if (ret == TEST_SKIPPED)
9105 if (ret == TEST_FAILED)
9108 if (flags->display_alg)
9109 test_ipsec_display_alg(&aead_list[i], NULL);
9115 return TEST_SUCCESS;
9117 return TEST_SKIPPED;
9121 test_ipsec_proto_display_list(const void *data __rte_unused)
9123 struct ipsec_test_flags flags;
9125 memset(&flags, 0, sizeof(flags));
9127 flags.display_alg = true;
9129 return test_ipsec_proto_all(&flags);
9133 test_PDCP_PROTO_all(void)
9135 struct crypto_testsuite_params *ts_params = &testsuite_params;
9136 struct crypto_unittest_params *ut_params = &unittest_params;
9137 struct rte_cryptodev_info dev_info;
9140 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9141 uint64_t feat_flags = dev_info.feature_flags;
9143 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9144 return TEST_SKIPPED;
9146 /* Set action type */
9147 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9148 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9151 if (security_proto_supported(ut_params->type,
9152 RTE_SECURITY_PROTOCOL_PDCP) < 0)
9153 return TEST_SKIPPED;
9155 status = test_PDCP_PROTO_cplane_encap_all();
9156 status += test_PDCP_PROTO_cplane_decap_all();
9157 status += test_PDCP_PROTO_uplane_encap_all();
9158 status += test_PDCP_PROTO_uplane_decap_all();
9159 status += test_PDCP_PROTO_SGL_in_place_32B();
9160 status += test_PDCP_PROTO_SGL_oop_32B_128B();
9161 status += test_PDCP_PROTO_SGL_oop_32B_40B();
9162 status += test_PDCP_PROTO_SGL_oop_128B_32B();
9163 status += test_PDCP_SDAP_PROTO_encap_all();
9164 status += test_PDCP_SDAP_PROTO_decap_all();
9165 status += test_PDCP_PROTO_short_mac();
9170 return TEST_SUCCESS;
9174 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
9176 struct crypto_testsuite_params *ts_params = &testsuite_params;
9177 struct crypto_unittest_params *ut_params = &unittest_params;
9178 uint8_t *plaintext, *ciphertext;
9180 int32_t cipher_len, crc_len;
9181 uint32_t crc_data_len;
9182 int ret = TEST_SUCCESS;
9184 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9185 rte_cryptodev_get_sec_ctx(
9186 ts_params->valid_devs[0]);
9188 /* Verify the capabilities */
9189 struct rte_security_capability_idx sec_cap_idx;
9190 const struct rte_security_capability *sec_cap;
9191 const struct rte_cryptodev_capabilities *crypto_cap;
9192 const struct rte_cryptodev_symmetric_capability *sym_cap;
9195 sec_cap_idx.action = ut_params->type;
9196 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9197 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9199 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9200 if (sec_cap == NULL)
9201 return TEST_SKIPPED;
9203 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9204 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9205 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9206 crypto_cap->sym.xform_type ==
9207 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9208 crypto_cap->sym.cipher.algo ==
9209 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9210 sym_cap = &crypto_cap->sym;
9211 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9218 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9219 return TEST_SKIPPED;
9221 /* Setup source mbuf payload */
9222 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9223 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9224 rte_pktmbuf_tailroom(ut_params->ibuf));
9226 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9227 d_td->ciphertext.len);
9229 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
9231 /* Setup cipher session parameters */
9232 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9233 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9234 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
9235 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9236 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9237 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9238 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9239 ut_params->cipher_xform.next = NULL;
9241 /* Setup DOCSIS session parameters */
9242 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9244 struct rte_security_session_conf sess_conf = {
9245 .action_type = ut_params->type,
9246 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9247 .docsis = ut_params->docsis_xform,
9248 .crypto_xform = &ut_params->cipher_xform,
9251 /* Create security session */
9252 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9253 ts_params->session_mpool,
9254 ts_params->session_priv_mpool);
9256 if (!ut_params->sec_session) {
9257 printf("TestCase %s(%d) line %d: %s\n",
9258 __func__, i, __LINE__, "failed to allocate session");
9263 /* Generate crypto op data structure */
9264 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9265 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9266 if (!ut_params->op) {
9267 printf("TestCase %s(%d) line %d: %s\n",
9268 __func__, i, __LINE__,
9269 "failed to allocate symmetric crypto operation");
9274 /* Setup CRC operation parameters */
9275 crc_len = d_td->ciphertext.no_crc == false ?
9276 (d_td->ciphertext.len -
9277 d_td->ciphertext.crc_offset -
9278 RTE_ETHER_CRC_LEN) :
9280 crc_len = crc_len > 0 ? crc_len : 0;
9281 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9282 ut_params->op->sym->auth.data.length = crc_len;
9283 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9285 /* Setup cipher operation parameters */
9286 cipher_len = d_td->ciphertext.no_cipher == false ?
9287 (d_td->ciphertext.len -
9288 d_td->ciphertext.cipher_offset) :
9290 cipher_len = cipher_len > 0 ? cipher_len : 0;
9291 ut_params->op->sym->cipher.data.length = cipher_len;
9292 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9294 /* Setup cipher IV */
9295 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9296 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9298 /* Attach session to operation */
9299 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9301 /* Set crypto operation mbufs */
9302 ut_params->op->sym->m_src = ut_params->ibuf;
9303 ut_params->op->sym->m_dst = NULL;
9305 /* Process crypto operation */
9306 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9308 printf("TestCase %s(%d) line %d: %s\n",
9309 __func__, i, __LINE__,
9310 "failed to process security crypto op");
9315 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9316 printf("TestCase %s(%d) line %d: %s\n",
9317 __func__, i, __LINE__, "crypto op processing failed");
9322 /* Validate plaintext */
9323 plaintext = ciphertext;
9325 if (memcmp(plaintext, d_td->plaintext.data,
9326 d_td->plaintext.len - crc_data_len)) {
9327 printf("TestCase %s(%d) line %d: %s\n",
9328 __func__, i, __LINE__, "plaintext not as expected\n");
9329 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9330 d_td->plaintext.len);
9331 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9337 rte_crypto_op_free(ut_params->op);
9338 ut_params->op = NULL;
9340 if (ut_params->sec_session)
9341 rte_security_session_destroy(ctx, ut_params->sec_session);
9342 ut_params->sec_session = NULL;
9344 rte_pktmbuf_free(ut_params->ibuf);
9345 ut_params->ibuf = NULL;
9351 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9353 struct crypto_testsuite_params *ts_params = &testsuite_params;
9354 struct crypto_unittest_params *ut_params = &unittest_params;
9355 uint8_t *plaintext, *ciphertext;
9357 int32_t cipher_len, crc_len;
9358 int ret = TEST_SUCCESS;
9360 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9361 rte_cryptodev_get_sec_ctx(
9362 ts_params->valid_devs[0]);
9364 /* Verify the capabilities */
9365 struct rte_security_capability_idx sec_cap_idx;
9366 const struct rte_security_capability *sec_cap;
9367 const struct rte_cryptodev_capabilities *crypto_cap;
9368 const struct rte_cryptodev_symmetric_capability *sym_cap;
9371 sec_cap_idx.action = ut_params->type;
9372 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9373 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9375 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9376 if (sec_cap == NULL)
9377 return TEST_SKIPPED;
9379 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9380 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9381 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9382 crypto_cap->sym.xform_type ==
9383 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9384 crypto_cap->sym.cipher.algo ==
9385 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9386 sym_cap = &crypto_cap->sym;
9387 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9394 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9395 return TEST_SKIPPED;
9397 /* Setup source mbuf payload */
9398 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9399 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9400 rte_pktmbuf_tailroom(ut_params->ibuf));
9402 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9403 d_td->plaintext.len);
9405 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9407 /* Setup cipher session parameters */
9408 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9409 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9410 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9411 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9412 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9413 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9414 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9415 ut_params->cipher_xform.next = NULL;
9417 /* Setup DOCSIS session parameters */
9418 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9420 struct rte_security_session_conf sess_conf = {
9421 .action_type = ut_params->type,
9422 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9423 .docsis = ut_params->docsis_xform,
9424 .crypto_xform = &ut_params->cipher_xform,
9427 /* Create security session */
9428 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9429 ts_params->session_mpool,
9430 ts_params->session_priv_mpool);
9432 if (!ut_params->sec_session) {
9433 printf("TestCase %s(%d) line %d: %s\n",
9434 __func__, i, __LINE__, "failed to allocate session");
9439 /* Generate crypto op data structure */
9440 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9441 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9442 if (!ut_params->op) {
9443 printf("TestCase %s(%d) line %d: %s\n",
9444 __func__, i, __LINE__,
9445 "failed to allocate security crypto operation");
9450 /* Setup CRC operation parameters */
9451 crc_len = d_td->plaintext.no_crc == false ?
9452 (d_td->plaintext.len -
9453 d_td->plaintext.crc_offset -
9454 RTE_ETHER_CRC_LEN) :
9456 crc_len = crc_len > 0 ? crc_len : 0;
9457 ut_params->op->sym->auth.data.length = crc_len;
9458 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9460 /* Setup cipher operation parameters */
9461 cipher_len = d_td->plaintext.no_cipher == false ?
9462 (d_td->plaintext.len -
9463 d_td->plaintext.cipher_offset) :
9465 cipher_len = cipher_len > 0 ? cipher_len : 0;
9466 ut_params->op->sym->cipher.data.length = cipher_len;
9467 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9469 /* Setup cipher IV */
9470 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9471 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9473 /* Attach session to operation */
9474 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9476 /* Set crypto operation mbufs */
9477 ut_params->op->sym->m_src = ut_params->ibuf;
9478 ut_params->op->sym->m_dst = NULL;
9480 /* Process crypto operation */
9481 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9483 printf("TestCase %s(%d) line %d: %s\n",
9484 __func__, i, __LINE__,
9485 "failed to process security crypto op");
9490 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9491 printf("TestCase %s(%d) line %d: %s\n",
9492 __func__, i, __LINE__, "crypto op processing failed");
9497 /* Validate ciphertext */
9498 ciphertext = plaintext;
9500 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9501 printf("TestCase %s(%d) line %d: %s\n",
9502 __func__, i, __LINE__, "ciphertext not as expected\n");
9503 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9504 d_td->ciphertext.len);
9505 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9511 rte_crypto_op_free(ut_params->op);
9512 ut_params->op = NULL;
9514 if (ut_params->sec_session)
9515 rte_security_session_destroy(ctx, ut_params->sec_session);
9516 ut_params->sec_session = NULL;
9518 rte_pktmbuf_free(ut_params->ibuf);
9519 ut_params->ibuf = NULL;
9524 #define TEST_DOCSIS_COUNT(func) do { \
9526 if (ret == TEST_SUCCESS) { \
9527 printf("\t%2d)", n++); \
9528 printf("+++++ PASSED:" #func"\n"); \
9530 } else if (ret == TEST_SKIPPED) { \
9531 printf("\t%2d)", n++); \
9532 printf("~~~~~ SKIPPED:" #func"\n"); \
9535 printf("\t%2d)", n++); \
9536 printf("----- FAILED:" #func"\n"); \
9542 test_DOCSIS_PROTO_uplink_all(void)
9544 int p = 0, s = 0, f = 0, n = 0;
9546 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9547 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9548 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9549 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9550 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9551 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9552 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9553 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9554 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9555 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9556 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9557 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9558 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9559 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9560 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9561 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9562 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9563 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9564 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9565 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9566 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9567 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9568 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9569 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9570 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9571 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9574 printf("## %s: %d passed out of %d (%d skipped)\n",
9581 test_DOCSIS_PROTO_downlink_all(void)
9583 int p = 0, s = 0, f = 0, n = 0;
9585 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9586 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9587 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9588 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9589 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9590 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9591 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9592 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9593 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9594 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9595 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9596 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9597 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9598 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9599 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9600 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9601 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9602 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9603 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9604 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9605 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9606 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9607 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9608 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9609 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9610 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9613 printf("## %s: %d passed out of %d (%d skipped)\n",
9620 test_DOCSIS_PROTO_all(void)
9622 struct crypto_testsuite_params *ts_params = &testsuite_params;
9623 struct crypto_unittest_params *ut_params = &unittest_params;
9624 struct rte_cryptodev_info dev_info;
9627 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9628 uint64_t feat_flags = dev_info.feature_flags;
9630 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9631 return TEST_SKIPPED;
9633 /* Set action type */
9634 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9635 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9638 if (security_proto_supported(ut_params->type,
9639 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9640 return TEST_SKIPPED;
9642 status = test_DOCSIS_PROTO_uplink_all();
9643 status += test_DOCSIS_PROTO_downlink_all();
9648 return TEST_SUCCESS;
9653 test_AES_GCM_authenticated_encryption_test_case_1(void)
9655 return test_authenticated_encryption(&gcm_test_case_1);
9659 test_AES_GCM_authenticated_encryption_test_case_2(void)
9661 return test_authenticated_encryption(&gcm_test_case_2);
9665 test_AES_GCM_authenticated_encryption_test_case_3(void)
9667 return test_authenticated_encryption(&gcm_test_case_3);
9671 test_AES_GCM_authenticated_encryption_test_case_4(void)
9673 return test_authenticated_encryption(&gcm_test_case_4);
9677 test_AES_GCM_authenticated_encryption_test_case_5(void)
9679 return test_authenticated_encryption(&gcm_test_case_5);
9683 test_AES_GCM_authenticated_encryption_test_case_6(void)
9685 return test_authenticated_encryption(&gcm_test_case_6);
9689 test_AES_GCM_authenticated_encryption_test_case_7(void)
9691 return test_authenticated_encryption(&gcm_test_case_7);
9695 test_AES_GCM_authenticated_encryption_test_case_8(void)
9697 return test_authenticated_encryption(&gcm_test_case_8);
9701 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9703 return test_authenticated_encryption(&gcm_J0_test_case_1);
9707 test_AES_GCM_auth_encryption_test_case_192_1(void)
9709 return test_authenticated_encryption(&gcm_test_case_192_1);
9713 test_AES_GCM_auth_encryption_test_case_192_2(void)
9715 return test_authenticated_encryption(&gcm_test_case_192_2);
9719 test_AES_GCM_auth_encryption_test_case_192_3(void)
9721 return test_authenticated_encryption(&gcm_test_case_192_3);
9725 test_AES_GCM_auth_encryption_test_case_192_4(void)
9727 return test_authenticated_encryption(&gcm_test_case_192_4);
9731 test_AES_GCM_auth_encryption_test_case_192_5(void)
9733 return test_authenticated_encryption(&gcm_test_case_192_5);
9737 test_AES_GCM_auth_encryption_test_case_192_6(void)
9739 return test_authenticated_encryption(&gcm_test_case_192_6);
9743 test_AES_GCM_auth_encryption_test_case_192_7(void)
9745 return test_authenticated_encryption(&gcm_test_case_192_7);
9749 test_AES_GCM_auth_encryption_test_case_256_1(void)
9751 return test_authenticated_encryption(&gcm_test_case_256_1);
9755 test_AES_GCM_auth_encryption_test_case_256_2(void)
9757 return test_authenticated_encryption(&gcm_test_case_256_2);
9761 test_AES_GCM_auth_encryption_test_case_256_3(void)
9763 return test_authenticated_encryption(&gcm_test_case_256_3);
9767 test_AES_GCM_auth_encryption_test_case_256_4(void)
9769 return test_authenticated_encryption(&gcm_test_case_256_4);
9773 test_AES_GCM_auth_encryption_test_case_256_5(void)
9775 return test_authenticated_encryption(&gcm_test_case_256_5);
9779 test_AES_GCM_auth_encryption_test_case_256_6(void)
9781 return test_authenticated_encryption(&gcm_test_case_256_6);
9785 test_AES_GCM_auth_encryption_test_case_256_7(void)
9787 return test_authenticated_encryption(&gcm_test_case_256_7);
9791 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9793 return test_authenticated_encryption(&gcm_test_case_aad_1);
9797 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9799 return test_authenticated_encryption(&gcm_test_case_aad_2);
9803 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9805 struct aead_test_data tdata;
9808 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9809 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9810 tdata.iv.data[0] += 1;
9811 res = test_authenticated_encryption(&tdata);
9812 if (res == TEST_SKIPPED)
9814 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9815 return TEST_SUCCESS;
9819 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9821 struct aead_test_data tdata;
9824 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9825 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9826 tdata.plaintext.data[0] += 1;
9827 res = test_authenticated_encryption(&tdata);
9828 if (res == TEST_SKIPPED)
9830 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9831 return TEST_SUCCESS;
9835 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9837 struct aead_test_data tdata;
9840 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9841 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9842 tdata.ciphertext.data[0] += 1;
9843 res = test_authenticated_encryption(&tdata);
9844 if (res == TEST_SKIPPED)
9846 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9847 return TEST_SUCCESS;
9851 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9853 struct aead_test_data tdata;
9856 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9857 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9859 res = test_authenticated_encryption(&tdata);
9860 if (res == TEST_SKIPPED)
9862 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9863 return TEST_SUCCESS;
9867 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9869 struct aead_test_data tdata;
9870 uint8_t aad[gcm_test_case_7.aad.len];
9873 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9874 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9875 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9877 tdata.aad.data = aad;
9878 res = test_authenticated_encryption(&tdata);
9879 if (res == TEST_SKIPPED)
9881 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9882 return TEST_SUCCESS;
9886 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9888 struct aead_test_data tdata;
9891 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9892 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9893 tdata.auth_tag.data[0] += 1;
9894 res = test_authenticated_encryption(&tdata);
9895 if (res == TEST_SKIPPED)
9897 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9898 return TEST_SUCCESS;
9902 test_authenticated_decryption(const struct aead_test_data *tdata)
9904 struct crypto_testsuite_params *ts_params = &testsuite_params;
9905 struct crypto_unittest_params *ut_params = &unittest_params;
9910 struct rte_cryptodev_info dev_info;
9912 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9913 uint64_t feat_flags = dev_info.feature_flags;
9915 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9916 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9917 printf("Device doesn't support RAW data-path APIs.\n");
9918 return TEST_SKIPPED;
9921 /* Verify the capabilities */
9922 struct rte_cryptodev_sym_capability_idx cap_idx;
9923 const struct rte_cryptodev_symmetric_capability *capability;
9924 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9925 cap_idx.algo.aead = tdata->algo;
9926 capability = rte_cryptodev_sym_capability_get(
9927 ts_params->valid_devs[0], &cap_idx);
9928 if (capability == NULL)
9929 return TEST_SKIPPED;
9930 if (rte_cryptodev_sym_capability_check_aead(
9931 capability, tdata->key.len, tdata->auth_tag.len,
9932 tdata->aad.len, tdata->iv.len))
9933 return TEST_SKIPPED;
9935 /* Create AEAD session */
9936 retval = create_aead_session(ts_params->valid_devs[0],
9938 RTE_CRYPTO_AEAD_OP_DECRYPT,
9939 tdata->key.data, tdata->key.len,
9940 tdata->aad.len, tdata->auth_tag.len,
9945 /* alloc mbuf and set payload */
9946 if (tdata->aad.len > MBUF_SIZE) {
9947 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9948 /* Populate full size of add data */
9949 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9950 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9952 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9954 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9955 rte_pktmbuf_tailroom(ut_params->ibuf));
9957 /* Create AEAD operation */
9958 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9962 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9964 ut_params->op->sym->m_src = ut_params->ibuf;
9966 /* Process crypto operation */
9967 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9968 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9969 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9970 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9971 ut_params->op, 0, 0, 0, 0);
9973 TEST_ASSERT_NOT_NULL(
9974 process_crypto_request(ts_params->valid_devs[0],
9975 ut_params->op), "failed to process sym crypto op");
9977 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9978 "crypto op processing failed");
9980 if (ut_params->op->sym->m_dst)
9981 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9984 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9986 ut_params->op->sym->cipher.data.offset);
9988 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9991 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9993 tdata->plaintext.data,
9994 tdata->plaintext.len,
9995 "Plaintext data not as expected");
9997 TEST_ASSERT_EQUAL(ut_params->op->status,
9998 RTE_CRYPTO_OP_STATUS_SUCCESS,
9999 "Authentication failed");
10005 test_AES_GCM_authenticated_decryption_test_case_1(void)
10007 return test_authenticated_decryption(&gcm_test_case_1);
10011 test_AES_GCM_authenticated_decryption_test_case_2(void)
10013 return test_authenticated_decryption(&gcm_test_case_2);
10017 test_AES_GCM_authenticated_decryption_test_case_3(void)
10019 return test_authenticated_decryption(&gcm_test_case_3);
10023 test_AES_GCM_authenticated_decryption_test_case_4(void)
10025 return test_authenticated_decryption(&gcm_test_case_4);
10029 test_AES_GCM_authenticated_decryption_test_case_5(void)
10031 return test_authenticated_decryption(&gcm_test_case_5);
10035 test_AES_GCM_authenticated_decryption_test_case_6(void)
10037 return test_authenticated_decryption(&gcm_test_case_6);
10041 test_AES_GCM_authenticated_decryption_test_case_7(void)
10043 return test_authenticated_decryption(&gcm_test_case_7);
10047 test_AES_GCM_authenticated_decryption_test_case_8(void)
10049 return test_authenticated_decryption(&gcm_test_case_8);
10053 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10055 return test_authenticated_decryption(&gcm_J0_test_case_1);
10059 test_AES_GCM_auth_decryption_test_case_192_1(void)
10061 return test_authenticated_decryption(&gcm_test_case_192_1);
10065 test_AES_GCM_auth_decryption_test_case_192_2(void)
10067 return test_authenticated_decryption(&gcm_test_case_192_2);
10071 test_AES_GCM_auth_decryption_test_case_192_3(void)
10073 return test_authenticated_decryption(&gcm_test_case_192_3);
10077 test_AES_GCM_auth_decryption_test_case_192_4(void)
10079 return test_authenticated_decryption(&gcm_test_case_192_4);
10083 test_AES_GCM_auth_decryption_test_case_192_5(void)
10085 return test_authenticated_decryption(&gcm_test_case_192_5);
10089 test_AES_GCM_auth_decryption_test_case_192_6(void)
10091 return test_authenticated_decryption(&gcm_test_case_192_6);
10095 test_AES_GCM_auth_decryption_test_case_192_7(void)
10097 return test_authenticated_decryption(&gcm_test_case_192_7);
10101 test_AES_GCM_auth_decryption_test_case_256_1(void)
10103 return test_authenticated_decryption(&gcm_test_case_256_1);
10107 test_AES_GCM_auth_decryption_test_case_256_2(void)
10109 return test_authenticated_decryption(&gcm_test_case_256_2);
10113 test_AES_GCM_auth_decryption_test_case_256_3(void)
10115 return test_authenticated_decryption(&gcm_test_case_256_3);
10119 test_AES_GCM_auth_decryption_test_case_256_4(void)
10121 return test_authenticated_decryption(&gcm_test_case_256_4);
10125 test_AES_GCM_auth_decryption_test_case_256_5(void)
10127 return test_authenticated_decryption(&gcm_test_case_256_5);
10131 test_AES_GCM_auth_decryption_test_case_256_6(void)
10133 return test_authenticated_decryption(&gcm_test_case_256_6);
10137 test_AES_GCM_auth_decryption_test_case_256_7(void)
10139 return test_authenticated_decryption(&gcm_test_case_256_7);
10143 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10145 return test_authenticated_decryption(&gcm_test_case_aad_1);
10149 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10151 return test_authenticated_decryption(&gcm_test_case_aad_2);
10155 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10157 struct aead_test_data tdata;
10160 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10161 tdata.iv.data[0] += 1;
10162 res = test_authenticated_decryption(&tdata);
10163 if (res == TEST_SKIPPED)
10165 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10166 return TEST_SUCCESS;
10170 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10172 struct aead_test_data tdata;
10175 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10176 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10177 tdata.plaintext.data[0] += 1;
10178 res = test_authenticated_decryption(&tdata);
10179 if (res == TEST_SKIPPED)
10181 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10182 return TEST_SUCCESS;
10186 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10188 struct aead_test_data tdata;
10191 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10192 tdata.ciphertext.data[0] += 1;
10193 res = test_authenticated_decryption(&tdata);
10194 if (res == TEST_SKIPPED)
10196 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10197 return TEST_SUCCESS;
10201 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10203 struct aead_test_data tdata;
10206 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10207 tdata.aad.len += 1;
10208 res = test_authenticated_decryption(&tdata);
10209 if (res == TEST_SKIPPED)
10211 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10212 return TEST_SUCCESS;
10216 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10218 struct aead_test_data tdata;
10219 uint8_t aad[gcm_test_case_7.aad.len];
10222 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10223 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10225 tdata.aad.data = aad;
10226 res = test_authenticated_decryption(&tdata);
10227 if (res == TEST_SKIPPED)
10229 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10230 return TEST_SUCCESS;
10234 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10236 struct aead_test_data tdata;
10239 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10240 tdata.auth_tag.data[0] += 1;
10241 res = test_authenticated_decryption(&tdata);
10242 if (res == TEST_SKIPPED)
10244 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10245 return TEST_SUCCESS;
10249 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10251 struct crypto_testsuite_params *ts_params = &testsuite_params;
10252 struct crypto_unittest_params *ut_params = &unittest_params;
10255 uint8_t *ciphertext, *auth_tag;
10256 uint16_t plaintext_pad_len;
10258 /* Verify the capabilities */
10259 struct rte_cryptodev_sym_capability_idx cap_idx;
10260 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10261 cap_idx.algo.aead = tdata->algo;
10262 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10264 return TEST_SKIPPED;
10266 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10267 return TEST_SKIPPED;
10269 /* not supported with CPU crypto */
10270 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10271 return TEST_SKIPPED;
10273 /* Create AEAD session */
10274 retval = create_aead_session(ts_params->valid_devs[0],
10276 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10277 tdata->key.data, tdata->key.len,
10278 tdata->aad.len, tdata->auth_tag.len,
10283 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10284 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10286 /* clear mbuf payload */
10287 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10288 rte_pktmbuf_tailroom(ut_params->ibuf));
10289 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10290 rte_pktmbuf_tailroom(ut_params->obuf));
10292 /* Create AEAD operation */
10293 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10297 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10299 ut_params->op->sym->m_src = ut_params->ibuf;
10300 ut_params->op->sym->m_dst = ut_params->obuf;
10302 /* Process crypto operation */
10303 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10304 ut_params->op), "failed to process sym crypto op");
10306 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10307 "crypto op processing failed");
10309 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10311 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10312 ut_params->op->sym->cipher.data.offset);
10313 auth_tag = ciphertext + plaintext_pad_len;
10315 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10316 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10318 /* Validate obuf */
10319 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10321 tdata->ciphertext.data,
10322 tdata->ciphertext.len,
10323 "Ciphertext data not as expected");
10325 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10327 tdata->auth_tag.data,
10328 tdata->auth_tag.len,
10329 "Generated auth tag not as expected");
10336 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10338 return test_authenticated_encryption_oop(&gcm_test_case_5);
10342 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10344 struct crypto_testsuite_params *ts_params = &testsuite_params;
10345 struct crypto_unittest_params *ut_params = &unittest_params;
10348 uint8_t *plaintext;
10350 /* Verify the capabilities */
10351 struct rte_cryptodev_sym_capability_idx cap_idx;
10352 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10353 cap_idx.algo.aead = tdata->algo;
10354 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10356 return TEST_SKIPPED;
10358 /* not supported with CPU crypto and raw data-path APIs*/
10359 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10360 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10361 return TEST_SKIPPED;
10363 /* Create AEAD session */
10364 retval = create_aead_session(ts_params->valid_devs[0],
10366 RTE_CRYPTO_AEAD_OP_DECRYPT,
10367 tdata->key.data, tdata->key.len,
10368 tdata->aad.len, tdata->auth_tag.len,
10373 /* alloc mbuf and set payload */
10374 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10375 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10377 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10378 rte_pktmbuf_tailroom(ut_params->ibuf));
10379 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10380 rte_pktmbuf_tailroom(ut_params->obuf));
10382 /* Create AEAD operation */
10383 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10387 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10389 ut_params->op->sym->m_src = ut_params->ibuf;
10390 ut_params->op->sym->m_dst = ut_params->obuf;
10392 /* Process crypto operation */
10393 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10394 ut_params->op), "failed to process sym crypto op");
10396 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10397 "crypto op processing failed");
10399 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10400 ut_params->op->sym->cipher.data.offset);
10402 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10404 /* Validate obuf */
10405 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10407 tdata->plaintext.data,
10408 tdata->plaintext.len,
10409 "Plaintext data not as expected");
10411 TEST_ASSERT_EQUAL(ut_params->op->status,
10412 RTE_CRYPTO_OP_STATUS_SUCCESS,
10413 "Authentication failed");
10418 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10420 return test_authenticated_decryption_oop(&gcm_test_case_5);
10424 test_authenticated_encryption_sessionless(
10425 const struct aead_test_data *tdata)
10427 struct crypto_testsuite_params *ts_params = &testsuite_params;
10428 struct crypto_unittest_params *ut_params = &unittest_params;
10431 uint8_t *ciphertext, *auth_tag;
10432 uint16_t plaintext_pad_len;
10433 uint8_t key[tdata->key.len + 1];
10434 struct rte_cryptodev_info dev_info;
10436 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10437 uint64_t feat_flags = dev_info.feature_flags;
10439 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10440 printf("Device doesn't support Sessionless ops.\n");
10441 return TEST_SKIPPED;
10444 /* not supported with CPU crypto */
10445 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10446 return TEST_SKIPPED;
10448 /* Verify the capabilities */
10449 struct rte_cryptodev_sym_capability_idx cap_idx;
10450 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10451 cap_idx.algo.aead = tdata->algo;
10452 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10454 return TEST_SKIPPED;
10456 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10458 /* clear mbuf payload */
10459 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10460 rte_pktmbuf_tailroom(ut_params->ibuf));
10462 /* Create AEAD operation */
10463 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10467 /* Create GCM xform */
10468 memcpy(key, tdata->key.data, tdata->key.len);
10469 retval = create_aead_xform(ut_params->op,
10471 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10472 key, tdata->key.len,
10473 tdata->aad.len, tdata->auth_tag.len,
10478 ut_params->op->sym->m_src = ut_params->ibuf;
10480 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10481 RTE_CRYPTO_OP_SESSIONLESS,
10482 "crypto op session type not sessionless");
10484 /* Process crypto operation */
10485 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10486 ut_params->op), "failed to process sym crypto op");
10488 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10490 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10491 "crypto op status not success");
10493 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10495 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10496 ut_params->op->sym->cipher.data.offset);
10497 auth_tag = ciphertext + plaintext_pad_len;
10499 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10500 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10502 /* Validate obuf */
10503 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10505 tdata->ciphertext.data,
10506 tdata->ciphertext.len,
10507 "Ciphertext data not as expected");
10509 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10511 tdata->auth_tag.data,
10512 tdata->auth_tag.len,
10513 "Generated auth tag not as expected");
10520 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10522 return test_authenticated_encryption_sessionless(
10527 test_authenticated_decryption_sessionless(
10528 const struct aead_test_data *tdata)
10530 struct crypto_testsuite_params *ts_params = &testsuite_params;
10531 struct crypto_unittest_params *ut_params = &unittest_params;
10534 uint8_t *plaintext;
10535 uint8_t key[tdata->key.len + 1];
10536 struct rte_cryptodev_info dev_info;
10538 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10539 uint64_t feat_flags = dev_info.feature_flags;
10541 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10542 printf("Device doesn't support Sessionless ops.\n");
10543 return TEST_SKIPPED;
10546 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10547 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10548 printf("Device doesn't support RAW data-path APIs.\n");
10549 return TEST_SKIPPED;
10552 /* not supported with CPU crypto */
10553 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10554 return TEST_SKIPPED;
10556 /* Verify the capabilities */
10557 struct rte_cryptodev_sym_capability_idx cap_idx;
10558 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10559 cap_idx.algo.aead = tdata->algo;
10560 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10562 return TEST_SKIPPED;
10564 /* alloc mbuf and set payload */
10565 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10567 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10568 rte_pktmbuf_tailroom(ut_params->ibuf));
10570 /* Create AEAD operation */
10571 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10575 /* Create AEAD xform */
10576 memcpy(key, tdata->key.data, tdata->key.len);
10577 retval = create_aead_xform(ut_params->op,
10579 RTE_CRYPTO_AEAD_OP_DECRYPT,
10580 key, tdata->key.len,
10581 tdata->aad.len, tdata->auth_tag.len,
10586 ut_params->op->sym->m_src = ut_params->ibuf;
10588 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10589 RTE_CRYPTO_OP_SESSIONLESS,
10590 "crypto op session type not sessionless");
10592 /* Process crypto operation */
10593 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10594 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10595 ut_params->op, 0, 0, 0, 0);
10597 TEST_ASSERT_NOT_NULL(process_crypto_request(
10598 ts_params->valid_devs[0], ut_params->op),
10599 "failed to process sym crypto op");
10601 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10603 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10604 "crypto op status not success");
10606 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10607 ut_params->op->sym->cipher.data.offset);
10609 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10611 /* Validate obuf */
10612 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10614 tdata->plaintext.data,
10615 tdata->plaintext.len,
10616 "Plaintext data not as expected");
10618 TEST_ASSERT_EQUAL(ut_params->op->status,
10619 RTE_CRYPTO_OP_STATUS_SUCCESS,
10620 "Authentication failed");
10625 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10627 return test_authenticated_decryption_sessionless(
10632 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10634 return test_authenticated_encryption(&ccm_test_case_128_1);
10638 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10640 return test_authenticated_encryption(&ccm_test_case_128_2);
10644 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10646 return test_authenticated_encryption(&ccm_test_case_128_3);
10650 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10652 return test_authenticated_decryption(&ccm_test_case_128_1);
10656 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10658 return test_authenticated_decryption(&ccm_test_case_128_2);
10662 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10664 return test_authenticated_decryption(&ccm_test_case_128_3);
10668 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10670 return test_authenticated_encryption(&ccm_test_case_192_1);
10674 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10676 return test_authenticated_encryption(&ccm_test_case_192_2);
10680 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10682 return test_authenticated_encryption(&ccm_test_case_192_3);
10686 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10688 return test_authenticated_decryption(&ccm_test_case_192_1);
10692 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10694 return test_authenticated_decryption(&ccm_test_case_192_2);
10698 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10700 return test_authenticated_decryption(&ccm_test_case_192_3);
10704 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10706 return test_authenticated_encryption(&ccm_test_case_256_1);
10710 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10712 return test_authenticated_encryption(&ccm_test_case_256_2);
10716 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10718 return test_authenticated_encryption(&ccm_test_case_256_3);
10722 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10724 return test_authenticated_decryption(&ccm_test_case_256_1);
10728 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10730 return test_authenticated_decryption(&ccm_test_case_256_2);
10734 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10736 return test_authenticated_decryption(&ccm_test_case_256_3);
10742 struct crypto_testsuite_params *ts_params = &testsuite_params;
10743 struct rte_cryptodev_stats stats;
10745 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10746 return TEST_SKIPPED;
10748 /* Verify the capabilities */
10749 struct rte_cryptodev_sym_capability_idx cap_idx;
10750 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10751 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10752 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10754 return TEST_SKIPPED;
10755 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10756 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10757 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10759 return TEST_SKIPPED;
10761 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10763 return TEST_SKIPPED;
10765 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10766 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10767 &stats) == -ENODEV),
10768 "rte_cryptodev_stats_get invalid dev failed");
10769 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10770 "rte_cryptodev_stats_get invalid Param failed");
10772 /* Test expected values */
10773 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10774 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10776 "rte_cryptodev_stats_get failed");
10777 TEST_ASSERT((stats.enqueued_count == 1),
10778 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10779 TEST_ASSERT((stats.dequeued_count == 1),
10780 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10781 TEST_ASSERT((stats.enqueue_err_count == 0),
10782 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10783 TEST_ASSERT((stats.dequeue_err_count == 0),
10784 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10786 /* invalid device but should ignore and not reset device stats*/
10787 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10788 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10790 "rte_cryptodev_stats_get failed");
10791 TEST_ASSERT((stats.enqueued_count == 1),
10792 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10794 /* check that a valid reset clears stats */
10795 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10796 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10798 "rte_cryptodev_stats_get failed");
10799 TEST_ASSERT((stats.enqueued_count == 0),
10800 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10801 TEST_ASSERT((stats.dequeued_count == 0),
10802 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10804 return TEST_SUCCESS;
10807 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10808 struct crypto_unittest_params *ut_params,
10809 enum rte_crypto_auth_operation op,
10810 const struct HMAC_MD5_vector *test_case)
10814 memcpy(key, test_case->key.data, test_case->key.len);
10816 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10817 ut_params->auth_xform.next = NULL;
10818 ut_params->auth_xform.auth.op = op;
10820 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10822 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10823 ut_params->auth_xform.auth.key.length = test_case->key.len;
10824 ut_params->auth_xform.auth.key.data = key;
10826 ut_params->sess = rte_cryptodev_sym_session_create(
10827 ts_params->session_mpool);
10829 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10830 ut_params->sess, &ut_params->auth_xform,
10831 ts_params->session_priv_mpool);
10833 if (ut_params->sess == NULL)
10834 return TEST_FAILED;
10836 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10838 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10839 rte_pktmbuf_tailroom(ut_params->ibuf));
10844 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10845 const struct HMAC_MD5_vector *test_case,
10846 uint8_t **plaintext)
10848 uint16_t plaintext_pad_len;
10850 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10852 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10855 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10856 plaintext_pad_len);
10857 memcpy(*plaintext, test_case->plaintext.data,
10858 test_case->plaintext.len);
10860 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10861 ut_params->ibuf, MD5_DIGEST_LEN);
10862 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10863 "no room to append digest");
10864 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10865 ut_params->ibuf, plaintext_pad_len);
10867 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10868 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10869 test_case->auth_tag.len);
10872 sym_op->auth.data.offset = 0;
10873 sym_op->auth.data.length = test_case->plaintext.len;
10875 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10876 ut_params->op->sym->m_src = ut_params->ibuf;
10882 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10884 uint16_t plaintext_pad_len;
10885 uint8_t *plaintext, *auth_tag;
10887 struct crypto_testsuite_params *ts_params = &testsuite_params;
10888 struct crypto_unittest_params *ut_params = &unittest_params;
10889 struct rte_cryptodev_info dev_info;
10891 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10892 uint64_t feat_flags = dev_info.feature_flags;
10894 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10895 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10896 printf("Device doesn't support RAW data-path APIs.\n");
10897 return TEST_SKIPPED;
10900 /* Verify the capabilities */
10901 struct rte_cryptodev_sym_capability_idx cap_idx;
10902 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10903 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10904 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10906 return TEST_SKIPPED;
10908 if (MD5_HMAC_create_session(ts_params, ut_params,
10909 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10910 return TEST_FAILED;
10912 /* Generate Crypto op data structure */
10913 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10914 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10915 TEST_ASSERT_NOT_NULL(ut_params->op,
10916 "Failed to allocate symmetric crypto operation struct");
10918 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10921 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10922 return TEST_FAILED;
10924 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10925 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10927 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10928 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10929 ut_params->op, 0, 1, 0, 0);
10931 TEST_ASSERT_NOT_NULL(
10932 process_crypto_request(ts_params->valid_devs[0],
10934 "failed to process sym crypto op");
10936 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10937 "crypto op processing failed");
10939 if (ut_params->op->sym->m_dst) {
10940 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10941 uint8_t *, plaintext_pad_len);
10943 auth_tag = plaintext + plaintext_pad_len;
10946 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10948 test_case->auth_tag.data,
10949 test_case->auth_tag.len,
10950 "HMAC_MD5 generated tag not as expected");
10952 return TEST_SUCCESS;
10956 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10958 uint8_t *plaintext;
10960 struct crypto_testsuite_params *ts_params = &testsuite_params;
10961 struct crypto_unittest_params *ut_params = &unittest_params;
10962 struct rte_cryptodev_info dev_info;
10964 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10965 uint64_t feat_flags = dev_info.feature_flags;
10967 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10968 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10969 printf("Device doesn't support RAW data-path APIs.\n");
10970 return TEST_SKIPPED;
10973 /* Verify the capabilities */
10974 struct rte_cryptodev_sym_capability_idx cap_idx;
10975 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10976 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10977 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10979 return TEST_SKIPPED;
10981 if (MD5_HMAC_create_session(ts_params, ut_params,
10982 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10983 return TEST_FAILED;
10986 /* Generate Crypto op data structure */
10987 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10988 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10989 TEST_ASSERT_NOT_NULL(ut_params->op,
10990 "Failed to allocate symmetric crypto operation struct");
10992 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10993 return TEST_FAILED;
10995 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10996 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10998 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10999 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11000 ut_params->op, 0, 1, 0, 0);
11002 TEST_ASSERT_NOT_NULL(
11003 process_crypto_request(ts_params->valid_devs[0],
11005 "failed to process sym crypto op");
11007 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11008 "HMAC_MD5 crypto op processing failed");
11010 return TEST_SUCCESS;
11014 test_MD5_HMAC_generate_case_1(void)
11016 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11020 test_MD5_HMAC_verify_case_1(void)
11022 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11026 test_MD5_HMAC_generate_case_2(void)
11028 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11032 test_MD5_HMAC_verify_case_2(void)
11034 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11038 test_multi_session(void)
11040 struct crypto_testsuite_params *ts_params = &testsuite_params;
11041 struct crypto_unittest_params *ut_params = &unittest_params;
11043 struct rte_cryptodev_info dev_info;
11044 struct rte_cryptodev_sym_session **sessions;
11048 /* Verify the capabilities */
11049 struct rte_cryptodev_sym_capability_idx cap_idx;
11050 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11051 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11052 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11054 return TEST_SKIPPED;
11055 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11056 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11057 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11059 return TEST_SKIPPED;
11061 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11062 aes_cbc_key, hmac_sha512_key);
11065 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11067 sessions = rte_malloc(NULL,
11068 sizeof(struct rte_cryptodev_sym_session *) *
11069 (MAX_NB_SESSIONS + 1), 0);
11071 /* Create multiple crypto sessions*/
11072 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11074 sessions[i] = rte_cryptodev_sym_session_create(
11075 ts_params->session_mpool);
11077 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11078 sessions[i], &ut_params->auth_xform,
11079 ts_params->session_priv_mpool);
11080 TEST_ASSERT_NOT_NULL(sessions[i],
11081 "Session creation failed at session number %u",
11084 /* Attempt to send a request on each session */
11085 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11089 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11090 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11092 "Failed to perform decrypt on request number %u.", i);
11093 /* free crypto operation structure */
11095 rte_crypto_op_free(ut_params->op);
11098 * free mbuf - both obuf and ibuf are usually the same,
11099 * so check if they point at the same address is necessary,
11100 * to avoid freeing the mbuf twice.
11102 if (ut_params->obuf) {
11103 rte_pktmbuf_free(ut_params->obuf);
11104 if (ut_params->ibuf == ut_params->obuf)
11105 ut_params->ibuf = 0;
11106 ut_params->obuf = 0;
11108 if (ut_params->ibuf) {
11109 rte_pktmbuf_free(ut_params->ibuf);
11110 ut_params->ibuf = 0;
11114 sessions[i] = NULL;
11115 /* Next session create should fail */
11116 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11117 sessions[i], &ut_params->auth_xform,
11118 ts_params->session_priv_mpool);
11119 TEST_ASSERT_NULL(sessions[i],
11120 "Session creation succeeded unexpectedly!");
11122 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11123 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11125 rte_cryptodev_sym_session_free(sessions[i]);
11128 rte_free(sessions);
11130 return TEST_SUCCESS;
11133 struct multi_session_params {
11134 struct crypto_unittest_params ut_params;
11135 uint8_t *cipher_key;
11137 const uint8_t *cipher;
11138 const uint8_t *digest;
11142 #define MB_SESSION_NUMBER 3
11145 test_multi_session_random_usage(void)
11147 struct crypto_testsuite_params *ts_params = &testsuite_params;
11148 struct rte_cryptodev_info dev_info;
11149 struct rte_cryptodev_sym_session **sessions;
11151 struct multi_session_params ut_paramz[] = {
11154 .cipher_key = ms_aes_cbc_key0,
11155 .hmac_key = ms_hmac_key0,
11156 .cipher = ms_aes_cbc_cipher0,
11157 .digest = ms_hmac_digest0,
11158 .iv = ms_aes_cbc_iv0
11161 .cipher_key = ms_aes_cbc_key1,
11162 .hmac_key = ms_hmac_key1,
11163 .cipher = ms_aes_cbc_cipher1,
11164 .digest = ms_hmac_digest1,
11165 .iv = ms_aes_cbc_iv1
11168 .cipher_key = ms_aes_cbc_key2,
11169 .hmac_key = ms_hmac_key2,
11170 .cipher = ms_aes_cbc_cipher2,
11171 .digest = ms_hmac_digest2,
11172 .iv = ms_aes_cbc_iv2
11177 /* Verify the capabilities */
11178 struct rte_cryptodev_sym_capability_idx cap_idx;
11179 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11180 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11181 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11183 return TEST_SKIPPED;
11184 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11185 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11186 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11188 return TEST_SKIPPED;
11190 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11192 sessions = rte_malloc(NULL,
11193 (sizeof(struct rte_cryptodev_sym_session *)
11194 * MAX_NB_SESSIONS) + 1, 0);
11196 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11197 sessions[i] = rte_cryptodev_sym_session_create(
11198 ts_params->session_mpool);
11200 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11201 sizeof(struct crypto_unittest_params));
11203 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11204 &ut_paramz[i].ut_params,
11205 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11207 /* Create multiple crypto sessions*/
11208 rte_cryptodev_sym_session_init(
11209 ts_params->valid_devs[0],
11211 &ut_paramz[i].ut_params.auth_xform,
11212 ts_params->session_priv_mpool);
11214 TEST_ASSERT_NOT_NULL(sessions[i],
11215 "Session creation failed at session number %u",
11221 for (i = 0; i < 40000; i++) {
11223 j = rand() % MB_SESSION_NUMBER;
11225 TEST_ASSERT_SUCCESS(
11226 test_AES_CBC_HMAC_SHA512_decrypt_perform(
11228 &ut_paramz[j].ut_params,
11229 ts_params, ut_paramz[j].cipher,
11230 ut_paramz[j].digest,
11232 "Failed to perform decrypt on request number %u.", i);
11234 if (ut_paramz[j].ut_params.op)
11235 rte_crypto_op_free(ut_paramz[j].ut_params.op);
11238 * free mbuf - both obuf and ibuf are usually the same,
11239 * so check if they point at the same address is necessary,
11240 * to avoid freeing the mbuf twice.
11242 if (ut_paramz[j].ut_params.obuf) {
11243 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11244 if (ut_paramz[j].ut_params.ibuf
11245 == ut_paramz[j].ut_params.obuf)
11246 ut_paramz[j].ut_params.ibuf = 0;
11247 ut_paramz[j].ut_params.obuf = 0;
11249 if (ut_paramz[j].ut_params.ibuf) {
11250 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11251 ut_paramz[j].ut_params.ibuf = 0;
11255 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11256 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11258 rte_cryptodev_sym_session_free(sessions[i]);
11261 rte_free(sessions);
11263 return TEST_SUCCESS;
11266 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11267 0xab, 0xab, 0xab, 0xab,
11268 0xab, 0xab, 0xab, 0xab,
11269 0xab, 0xab, 0xab, 0xab};
11272 test_null_invalid_operation(void)
11274 struct crypto_testsuite_params *ts_params = &testsuite_params;
11275 struct crypto_unittest_params *ut_params = &unittest_params;
11278 /* This test is for NULL PMD only */
11279 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11280 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11281 return TEST_SKIPPED;
11283 /* Setup Cipher Parameters */
11284 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11285 ut_params->cipher_xform.next = NULL;
11287 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11288 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11290 ut_params->sess = rte_cryptodev_sym_session_create(
11291 ts_params->session_mpool);
11293 /* Create Crypto session*/
11294 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11295 ut_params->sess, &ut_params->cipher_xform,
11296 ts_params->session_priv_mpool);
11297 TEST_ASSERT(ret < 0,
11298 "Session creation succeeded unexpectedly");
11301 /* Setup HMAC Parameters */
11302 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11303 ut_params->auth_xform.next = NULL;
11305 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11306 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11308 ut_params->sess = rte_cryptodev_sym_session_create(
11309 ts_params->session_mpool);
11311 /* Create Crypto session*/
11312 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11313 ut_params->sess, &ut_params->auth_xform,
11314 ts_params->session_priv_mpool);
11315 TEST_ASSERT(ret < 0,
11316 "Session creation succeeded unexpectedly");
11318 return TEST_SUCCESS;
11322 #define NULL_BURST_LENGTH (32)
11325 test_null_burst_operation(void)
11327 struct crypto_testsuite_params *ts_params = &testsuite_params;
11328 struct crypto_unittest_params *ut_params = &unittest_params;
11330 unsigned i, burst_len = NULL_BURST_LENGTH;
11332 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11333 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11335 /* This test is for NULL PMD only */
11336 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11337 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11338 return TEST_SKIPPED;
11340 /* Setup Cipher Parameters */
11341 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11342 ut_params->cipher_xform.next = &ut_params->auth_xform;
11344 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11345 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11347 /* Setup HMAC Parameters */
11348 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11349 ut_params->auth_xform.next = NULL;
11351 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11352 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11354 ut_params->sess = rte_cryptodev_sym_session_create(
11355 ts_params->session_mpool);
11357 /* Create Crypto session*/
11358 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11359 ut_params->sess, &ut_params->cipher_xform,
11360 ts_params->session_priv_mpool);
11361 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11363 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11364 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11365 burst_len, "failed to generate burst of crypto ops");
11367 /* Generate an operation for each mbuf in burst */
11368 for (i = 0; i < burst_len; i++) {
11369 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11371 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11373 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11377 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11379 burst[i]->sym->m_src = m;
11382 /* Process crypto operation */
11383 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11384 0, burst, burst_len),
11386 "Error enqueuing burst");
11388 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11389 0, burst_dequeued, burst_len),
11391 "Error dequeuing burst");
11394 for (i = 0; i < burst_len; i++) {
11396 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11397 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11399 "data not as expected");
11401 rte_pktmbuf_free(burst[i]->sym->m_src);
11402 rte_crypto_op_free(burst[i]);
11405 return TEST_SUCCESS;
11409 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11410 uint16_t nb_ops, void *user_param)
11412 RTE_SET_USED(dev_id);
11413 RTE_SET_USED(qp_id);
11415 RTE_SET_USED(user_param);
11417 printf("crypto enqueue callback called\n");
11422 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11423 uint16_t nb_ops, void *user_param)
11425 RTE_SET_USED(dev_id);
11426 RTE_SET_USED(qp_id);
11428 RTE_SET_USED(user_param);
11430 printf("crypto dequeue callback called\n");
11435 * Thread using enqueue/dequeue callback with RCU.
11438 test_enqdeq_callback_thread(void *arg)
11441 /* DP thread calls rte_cryptodev_enqueue_burst()/
11442 * rte_cryptodev_dequeue_burst() and invokes callback.
11444 test_null_burst_operation();
11449 test_enq_callback_setup(void)
11451 struct crypto_testsuite_params *ts_params = &testsuite_params;
11452 struct rte_cryptodev_info dev_info;
11453 struct rte_cryptodev_qp_conf qp_conf = {
11454 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11457 struct rte_cryptodev_cb *cb;
11458 uint16_t qp_id = 0;
11460 /* Stop the device in case it's started so it can be configured */
11461 rte_cryptodev_stop(ts_params->valid_devs[0]);
11463 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11465 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11467 "Failed to configure cryptodev %u",
11468 ts_params->valid_devs[0]);
11470 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11471 qp_conf.mp_session = ts_params->session_mpool;
11472 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11474 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11475 ts_params->valid_devs[0], qp_id, &qp_conf,
11476 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11478 "rte_cryptodev_queue_pair_setup: num_inflights "
11479 "%u on qp %u on cryptodev %u",
11480 qp_conf.nb_descriptors, qp_id,
11481 ts_params->valid_devs[0]);
11483 /* Test with invalid crypto device */
11484 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11485 qp_id, test_enq_callback, NULL);
11486 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11487 "cryptodev %u did not fail",
11488 qp_id, RTE_CRYPTO_MAX_DEVS);
11490 /* Test with invalid queue pair */
11491 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11492 dev_info.max_nb_queue_pairs + 1,
11493 test_enq_callback, NULL);
11494 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11495 "cryptodev %u did not fail",
11496 dev_info.max_nb_queue_pairs + 1,
11497 ts_params->valid_devs[0]);
11499 /* Test with NULL callback */
11500 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11501 qp_id, NULL, NULL);
11502 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11503 "cryptodev %u did not fail",
11504 qp_id, ts_params->valid_devs[0]);
11506 /* Test with valid configuration */
11507 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11508 qp_id, test_enq_callback, NULL);
11509 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11510 "qp %u on cryptodev %u",
11511 qp_id, ts_params->valid_devs[0]);
11513 rte_cryptodev_start(ts_params->valid_devs[0]);
11515 /* Launch a thread */
11516 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11517 rte_get_next_lcore(-1, 1, 0));
11519 /* Wait until reader exited. */
11520 rte_eal_mp_wait_lcore();
11522 /* Test with invalid crypto device */
11523 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11524 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11525 "Expected call to fail as crypto device is invalid");
11527 /* Test with invalid queue pair */
11528 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11529 ts_params->valid_devs[0],
11530 dev_info.max_nb_queue_pairs + 1, cb),
11531 "Expected call to fail as queue pair is invalid");
11533 /* Test with NULL callback */
11534 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11535 ts_params->valid_devs[0], qp_id, NULL),
11536 "Expected call to fail as callback is NULL");
11538 /* Test with valid configuration */
11539 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11540 ts_params->valid_devs[0], qp_id, cb),
11541 "Failed test to remove callback on "
11542 "qp %u on cryptodev %u",
11543 qp_id, ts_params->valid_devs[0]);
11545 return TEST_SUCCESS;
11549 test_deq_callback_setup(void)
11551 struct crypto_testsuite_params *ts_params = &testsuite_params;
11552 struct rte_cryptodev_info dev_info;
11553 struct rte_cryptodev_qp_conf qp_conf = {
11554 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11557 struct rte_cryptodev_cb *cb;
11558 uint16_t qp_id = 0;
11560 /* Stop the device in case it's started so it can be configured */
11561 rte_cryptodev_stop(ts_params->valid_devs[0]);
11563 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11565 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11567 "Failed to configure cryptodev %u",
11568 ts_params->valid_devs[0]);
11570 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11571 qp_conf.mp_session = ts_params->session_mpool;
11572 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11574 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11575 ts_params->valid_devs[0], qp_id, &qp_conf,
11576 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11578 "rte_cryptodev_queue_pair_setup: num_inflights "
11579 "%u on qp %u on cryptodev %u",
11580 qp_conf.nb_descriptors, qp_id,
11581 ts_params->valid_devs[0]);
11583 /* Test with invalid crypto device */
11584 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11585 qp_id, test_deq_callback, NULL);
11586 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11587 "cryptodev %u did not fail",
11588 qp_id, RTE_CRYPTO_MAX_DEVS);
11590 /* Test with invalid queue pair */
11591 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11592 dev_info.max_nb_queue_pairs + 1,
11593 test_deq_callback, NULL);
11594 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11595 "cryptodev %u did not fail",
11596 dev_info.max_nb_queue_pairs + 1,
11597 ts_params->valid_devs[0]);
11599 /* Test with NULL callback */
11600 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11601 qp_id, NULL, NULL);
11602 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11603 "cryptodev %u did not fail",
11604 qp_id, ts_params->valid_devs[0]);
11606 /* Test with valid configuration */
11607 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11608 qp_id, test_deq_callback, NULL);
11609 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11610 "qp %u on cryptodev %u",
11611 qp_id, ts_params->valid_devs[0]);
11613 rte_cryptodev_start(ts_params->valid_devs[0]);
11615 /* Launch a thread */
11616 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11617 rte_get_next_lcore(-1, 1, 0));
11619 /* Wait until reader exited. */
11620 rte_eal_mp_wait_lcore();
11622 /* Test with invalid crypto device */
11623 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11624 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11625 "Expected call to fail as crypto device is invalid");
11627 /* Test with invalid queue pair */
11628 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11629 ts_params->valid_devs[0],
11630 dev_info.max_nb_queue_pairs + 1, cb),
11631 "Expected call to fail as queue pair is invalid");
11633 /* Test with NULL callback */
11634 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11635 ts_params->valid_devs[0], qp_id, NULL),
11636 "Expected call to fail as callback is NULL");
11638 /* Test with valid configuration */
11639 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11640 ts_params->valid_devs[0], qp_id, cb),
11641 "Failed test to remove callback on "
11642 "qp %u on cryptodev %u",
11643 qp_id, ts_params->valid_devs[0]);
11645 return TEST_SUCCESS;
11649 generate_gmac_large_plaintext(uint8_t *data)
11653 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11654 memcpy(&data[i], &data[0], 32);
11658 create_gmac_operation(enum rte_crypto_auth_operation op,
11659 const struct gmac_test_data *tdata)
11661 struct crypto_testsuite_params *ts_params = &testsuite_params;
11662 struct crypto_unittest_params *ut_params = &unittest_params;
11663 struct rte_crypto_sym_op *sym_op;
11665 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11667 /* Generate Crypto op data structure */
11668 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11669 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11670 TEST_ASSERT_NOT_NULL(ut_params->op,
11671 "Failed to allocate symmetric crypto operation struct");
11673 sym_op = ut_params->op->sym;
11675 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11676 ut_params->ibuf, tdata->gmac_tag.len);
11677 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11678 "no room to append digest");
11680 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11681 ut_params->ibuf, plaintext_pad_len);
11683 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11684 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11685 tdata->gmac_tag.len);
11686 debug_hexdump(stdout, "digest:",
11687 sym_op->auth.digest.data,
11688 tdata->gmac_tag.len);
11691 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11692 uint8_t *, IV_OFFSET);
11694 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11696 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11698 sym_op->cipher.data.length = 0;
11699 sym_op->cipher.data.offset = 0;
11701 sym_op->auth.data.offset = 0;
11702 sym_op->auth.data.length = tdata->plaintext.len;
11708 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11709 const struct gmac_test_data *tdata,
11710 void *digest_mem, uint64_t digest_phys)
11712 struct crypto_testsuite_params *ts_params = &testsuite_params;
11713 struct crypto_unittest_params *ut_params = &unittest_params;
11714 struct rte_crypto_sym_op *sym_op;
11716 /* Generate Crypto op data structure */
11717 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11718 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11719 TEST_ASSERT_NOT_NULL(ut_params->op,
11720 "Failed to allocate symmetric crypto operation struct");
11722 sym_op = ut_params->op->sym;
11724 sym_op->auth.digest.data = digest_mem;
11725 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11726 "no room to append digest");
11728 sym_op->auth.digest.phys_addr = digest_phys;
11730 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11731 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11732 tdata->gmac_tag.len);
11733 debug_hexdump(stdout, "digest:",
11734 sym_op->auth.digest.data,
11735 tdata->gmac_tag.len);
11738 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11739 uint8_t *, IV_OFFSET);
11741 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11743 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11745 sym_op->cipher.data.length = 0;
11746 sym_op->cipher.data.offset = 0;
11748 sym_op->auth.data.offset = 0;
11749 sym_op->auth.data.length = tdata->plaintext.len;
11754 static int create_gmac_session(uint8_t dev_id,
11755 const struct gmac_test_data *tdata,
11756 enum rte_crypto_auth_operation auth_op)
11758 uint8_t auth_key[tdata->key.len];
11760 struct crypto_testsuite_params *ts_params = &testsuite_params;
11761 struct crypto_unittest_params *ut_params = &unittest_params;
11763 memcpy(auth_key, tdata->key.data, tdata->key.len);
11765 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11766 ut_params->auth_xform.next = NULL;
11768 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11769 ut_params->auth_xform.auth.op = auth_op;
11770 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11771 ut_params->auth_xform.auth.key.length = tdata->key.len;
11772 ut_params->auth_xform.auth.key.data = auth_key;
11773 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11774 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11777 ut_params->sess = rte_cryptodev_sym_session_create(
11778 ts_params->session_mpool);
11780 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11781 &ut_params->auth_xform,
11782 ts_params->session_priv_mpool);
11784 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11790 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11792 struct crypto_testsuite_params *ts_params = &testsuite_params;
11793 struct crypto_unittest_params *ut_params = &unittest_params;
11794 struct rte_cryptodev_info dev_info;
11796 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11797 uint64_t feat_flags = dev_info.feature_flags;
11799 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11800 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11801 printf("Device doesn't support RAW data-path APIs.\n");
11802 return TEST_SKIPPED;
11807 uint8_t *auth_tag, *plaintext;
11808 uint16_t plaintext_pad_len;
11810 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11811 "No GMAC length in the source data");
11813 /* Verify the capabilities */
11814 struct rte_cryptodev_sym_capability_idx cap_idx;
11815 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11816 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11817 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11819 return TEST_SKIPPED;
11821 retval = create_gmac_session(ts_params->valid_devs[0],
11822 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11827 if (tdata->plaintext.len > MBUF_SIZE)
11828 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11830 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11831 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11832 "Failed to allocate input buffer in mempool");
11834 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11835 rte_pktmbuf_tailroom(ut_params->ibuf));
11837 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11839 * Runtime generate the large plain text instead of use hard code
11840 * plain text vector. It is done to avoid create huge source file
11841 * with the test vector.
11843 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11844 generate_gmac_large_plaintext(tdata->plaintext.data);
11846 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11847 plaintext_pad_len);
11848 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11850 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11851 debug_hexdump(stdout, "plaintext:", plaintext,
11852 tdata->plaintext.len);
11854 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11860 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11862 ut_params->op->sym->m_src = ut_params->ibuf;
11864 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11865 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11867 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11868 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11869 ut_params->op, 0, 1, 0, 0);
11871 TEST_ASSERT_NOT_NULL(
11872 process_crypto_request(ts_params->valid_devs[0],
11873 ut_params->op), "failed to process sym crypto op");
11875 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11876 "crypto op processing failed");
11878 if (ut_params->op->sym->m_dst) {
11879 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11880 uint8_t *, plaintext_pad_len);
11882 auth_tag = plaintext + plaintext_pad_len;
11885 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11887 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11889 tdata->gmac_tag.data,
11890 tdata->gmac_tag.len,
11891 "GMAC Generated auth tag not as expected");
11897 test_AES_GMAC_authentication_test_case_1(void)
11899 return test_AES_GMAC_authentication(&gmac_test_case_1);
11903 test_AES_GMAC_authentication_test_case_2(void)
11905 return test_AES_GMAC_authentication(&gmac_test_case_2);
11909 test_AES_GMAC_authentication_test_case_3(void)
11911 return test_AES_GMAC_authentication(&gmac_test_case_3);
11915 test_AES_GMAC_authentication_test_case_4(void)
11917 return test_AES_GMAC_authentication(&gmac_test_case_4);
11921 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11923 struct crypto_testsuite_params *ts_params = &testsuite_params;
11924 struct crypto_unittest_params *ut_params = &unittest_params;
11926 uint32_t plaintext_pad_len;
11927 uint8_t *plaintext;
11928 struct rte_cryptodev_info dev_info;
11930 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11931 uint64_t feat_flags = dev_info.feature_flags;
11933 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11934 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11935 printf("Device doesn't support RAW data-path APIs.\n");
11936 return TEST_SKIPPED;
11939 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11940 "No GMAC length in the source data");
11942 /* Verify the capabilities */
11943 struct rte_cryptodev_sym_capability_idx cap_idx;
11944 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11945 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11946 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11948 return TEST_SKIPPED;
11950 retval = create_gmac_session(ts_params->valid_devs[0],
11951 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11956 if (tdata->plaintext.len > MBUF_SIZE)
11957 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11959 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11960 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11961 "Failed to allocate input buffer in mempool");
11963 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11964 rte_pktmbuf_tailroom(ut_params->ibuf));
11966 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11969 * Runtime generate the large plain text instead of use hard code
11970 * plain text vector. It is done to avoid create huge source file
11971 * with the test vector.
11973 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11974 generate_gmac_large_plaintext(tdata->plaintext.data);
11976 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11977 plaintext_pad_len);
11978 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11980 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11981 debug_hexdump(stdout, "plaintext:", plaintext,
11982 tdata->plaintext.len);
11984 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11990 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11992 ut_params->op->sym->m_src = ut_params->ibuf;
11994 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11995 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11997 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11998 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11999 ut_params->op, 0, 1, 0, 0);
12001 TEST_ASSERT_NOT_NULL(
12002 process_crypto_request(ts_params->valid_devs[0],
12003 ut_params->op), "failed to process sym crypto op");
12005 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12006 "crypto op processing failed");
12013 test_AES_GMAC_authentication_verify_test_case_1(void)
12015 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12019 test_AES_GMAC_authentication_verify_test_case_2(void)
12021 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12025 test_AES_GMAC_authentication_verify_test_case_3(void)
12027 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12031 test_AES_GMAC_authentication_verify_test_case_4(void)
12033 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12037 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12040 struct crypto_testsuite_params *ts_params = &testsuite_params;
12041 struct crypto_unittest_params *ut_params = &unittest_params;
12042 struct rte_cryptodev_info dev_info;
12043 uint64_t feature_flags;
12044 unsigned int trn_data = 0;
12045 void *digest_mem = NULL;
12047 unsigned int to_trn = 0;
12048 struct rte_mbuf *buf = NULL;
12049 uint8_t *auth_tag, *plaintext;
12052 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12053 "No GMAC length in the source data");
12055 /* Verify the capabilities */
12056 struct rte_cryptodev_sym_capability_idx cap_idx;
12057 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12058 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12059 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12061 return TEST_SKIPPED;
12063 /* Check for any input SGL support */
12064 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12065 feature_flags = dev_info.feature_flags;
12067 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12068 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12069 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12070 return TEST_SKIPPED;
12072 if (fragsz > tdata->plaintext.len)
12073 fragsz = tdata->plaintext.len;
12075 uint16_t plaintext_len = fragsz;
12077 retval = create_gmac_session(ts_params->valid_devs[0],
12078 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12083 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12084 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12085 "Failed to allocate input buffer in mempool");
12087 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12088 rte_pktmbuf_tailroom(ut_params->ibuf));
12090 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12092 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12094 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12096 trn_data += plaintext_len;
12098 buf = ut_params->ibuf;
12101 * Loop until no more fragments
12104 while (trn_data < tdata->plaintext.len) {
12106 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12107 (tdata->plaintext.len - trn_data) : fragsz;
12109 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12112 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12113 rte_pktmbuf_tailroom(buf));
12115 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12118 memcpy(plaintext, tdata->plaintext.data + trn_data,
12120 trn_data += to_trn;
12121 if (trn_data == tdata->plaintext.len)
12122 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12123 tdata->gmac_tag.len);
12125 ut_params->ibuf->nb_segs = segs;
12128 * Place digest at the end of the last buffer
12130 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12133 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12134 + tdata->gmac_tag.len);
12135 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12136 tdata->plaintext.len);
12139 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12140 tdata, digest_mem, digest_phys);
12145 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12147 ut_params->op->sym->m_src = ut_params->ibuf;
12149 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12150 return TEST_SKIPPED;
12152 TEST_ASSERT_NOT_NULL(
12153 process_crypto_request(ts_params->valid_devs[0],
12154 ut_params->op), "failed to process sym crypto op");
12156 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12157 "crypto op processing failed");
12159 auth_tag = digest_mem;
12160 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12161 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12163 tdata->gmac_tag.data,
12164 tdata->gmac_tag.len,
12165 "GMAC Generated auth tag not as expected");
12170 /* Segment size not multiple of block size (16B) */
12172 test_AES_GMAC_authentication_SGL_40B(void)
12174 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12178 test_AES_GMAC_authentication_SGL_80B(void)
12180 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12184 test_AES_GMAC_authentication_SGL_2048B(void)
12186 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12189 /* Segment size not multiple of block size (16B) */
12191 test_AES_GMAC_authentication_SGL_2047B(void)
12193 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12196 struct test_crypto_vector {
12197 enum rte_crypto_cipher_algorithm crypto_algo;
12198 unsigned int cipher_offset;
12199 unsigned int cipher_len;
12212 const uint8_t *data;
12217 const uint8_t *data;
12221 enum rte_crypto_auth_algorithm auth_algo;
12222 unsigned int auth_offset;
12230 const uint8_t *data;
12240 static const struct test_crypto_vector
12241 hmac_sha1_test_crypto_vector = {
12242 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12244 .data = plaintext_hash,
12249 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12250 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12251 0xDE, 0xF4, 0xDE, 0xAD
12257 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12258 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12259 0x3F, 0x91, 0x64, 0x59
12265 static const struct test_crypto_vector
12266 aes128_gmac_test_vector = {
12267 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12269 .data = plaintext_hash,
12274 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12275 0x08, 0x09, 0x0A, 0x0B
12281 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12282 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12288 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12289 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12295 static const struct test_crypto_vector
12296 aes128cbc_hmac_sha1_test_vector = {
12297 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12298 .cipher_offset = 0,
12302 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12303 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12309 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12310 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12315 .data = plaintext_hash,
12319 .data = ciphertext512_aes128cbc,
12322 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12326 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12327 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12328 0xDE, 0xF4, 0xDE, 0xAD
12334 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12335 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12336 0x18, 0x8C, 0x1D, 0x32
12342 static const struct test_crypto_vector
12343 aes128cbc_hmac_sha1_aad_test_vector = {
12344 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12345 .cipher_offset = 8,
12349 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12350 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12356 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12357 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12362 .data = plaintext_hash,
12366 .data = ciphertext512_aes128cbc_aad,
12369 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12373 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12374 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12375 0xDE, 0xF4, 0xDE, 0xAD
12381 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12382 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12383 0x62, 0x0F, 0xFB, 0x10
12390 data_corruption(uint8_t *data)
12396 tag_corruption(uint8_t *data, unsigned int tag_offset)
12398 data[tag_offset] += 1;
12402 create_auth_session(struct crypto_unittest_params *ut_params,
12404 const struct test_crypto_vector *reference,
12405 enum rte_crypto_auth_operation auth_op)
12407 struct crypto_testsuite_params *ts_params = &testsuite_params;
12408 uint8_t auth_key[reference->auth_key.len + 1];
12410 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12412 /* Setup Authentication Parameters */
12413 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12414 ut_params->auth_xform.auth.op = auth_op;
12415 ut_params->auth_xform.next = NULL;
12416 ut_params->auth_xform.auth.algo = reference->auth_algo;
12417 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12418 ut_params->auth_xform.auth.key.data = auth_key;
12419 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12421 /* Create Crypto session*/
12422 ut_params->sess = rte_cryptodev_sym_session_create(
12423 ts_params->session_mpool);
12425 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12426 &ut_params->auth_xform,
12427 ts_params->session_priv_mpool);
12429 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12435 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12437 const struct test_crypto_vector *reference,
12438 enum rte_crypto_auth_operation auth_op,
12439 enum rte_crypto_cipher_operation cipher_op)
12441 struct crypto_testsuite_params *ts_params = &testsuite_params;
12442 uint8_t cipher_key[reference->cipher_key.len + 1];
12443 uint8_t auth_key[reference->auth_key.len + 1];
12445 memcpy(cipher_key, reference->cipher_key.data,
12446 reference->cipher_key.len);
12447 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12449 /* Setup Authentication Parameters */
12450 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12451 ut_params->auth_xform.auth.op = auth_op;
12452 ut_params->auth_xform.auth.algo = reference->auth_algo;
12453 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12454 ut_params->auth_xform.auth.key.data = auth_key;
12455 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12457 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12458 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12459 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12461 ut_params->auth_xform.next = &ut_params->cipher_xform;
12463 /* Setup Cipher Parameters */
12464 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12465 ut_params->cipher_xform.next = NULL;
12466 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12467 ut_params->cipher_xform.cipher.op = cipher_op;
12468 ut_params->cipher_xform.cipher.key.data = cipher_key;
12469 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12470 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12471 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12474 /* Create Crypto session*/
12475 ut_params->sess = rte_cryptodev_sym_session_create(
12476 ts_params->session_mpool);
12478 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12479 &ut_params->auth_xform,
12480 ts_params->session_priv_mpool);
12482 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12488 create_auth_operation(struct crypto_testsuite_params *ts_params,
12489 struct crypto_unittest_params *ut_params,
12490 const struct test_crypto_vector *reference,
12491 unsigned int auth_generate)
12493 /* Generate Crypto op data structure */
12494 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12495 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12496 TEST_ASSERT_NOT_NULL(ut_params->op,
12497 "Failed to allocate pktmbuf offload");
12499 /* Set crypto operation data parameters */
12500 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12502 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12504 /* set crypto operation source mbuf */
12505 sym_op->m_src = ut_params->ibuf;
12508 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12509 ut_params->ibuf, reference->digest.len);
12511 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12512 "no room to append auth tag");
12514 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12515 ut_params->ibuf, reference->plaintext.len);
12518 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12520 memcpy(sym_op->auth.digest.data,
12521 reference->digest.data,
12522 reference->digest.len);
12524 debug_hexdump(stdout, "digest:",
12525 sym_op->auth.digest.data,
12526 reference->digest.len);
12528 sym_op->auth.data.length = reference->plaintext.len;
12529 sym_op->auth.data.offset = 0;
12535 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12536 struct crypto_unittest_params *ut_params,
12537 const struct test_crypto_vector *reference,
12538 unsigned int auth_generate)
12540 /* Generate Crypto op data structure */
12541 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12542 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12543 TEST_ASSERT_NOT_NULL(ut_params->op,
12544 "Failed to allocate pktmbuf offload");
12546 /* Set crypto operation data parameters */
12547 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12549 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12551 /* set crypto operation source mbuf */
12552 sym_op->m_src = ut_params->ibuf;
12555 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12556 ut_params->ibuf, reference->digest.len);
12558 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12559 "no room to append auth tag");
12561 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12562 ut_params->ibuf, reference->ciphertext.len);
12565 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12567 memcpy(sym_op->auth.digest.data,
12568 reference->digest.data,
12569 reference->digest.len);
12571 debug_hexdump(stdout, "digest:",
12572 sym_op->auth.digest.data,
12573 reference->digest.len);
12575 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12576 reference->iv.data, reference->iv.len);
12578 sym_op->cipher.data.length = 0;
12579 sym_op->cipher.data.offset = 0;
12581 sym_op->auth.data.length = reference->plaintext.len;
12582 sym_op->auth.data.offset = 0;
12588 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12589 struct crypto_unittest_params *ut_params,
12590 const struct test_crypto_vector *reference,
12591 unsigned int auth_generate)
12593 /* Generate Crypto op data structure */
12594 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12595 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12596 TEST_ASSERT_NOT_NULL(ut_params->op,
12597 "Failed to allocate pktmbuf offload");
12599 /* Set crypto operation data parameters */
12600 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12602 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12604 /* set crypto operation source mbuf */
12605 sym_op->m_src = ut_params->ibuf;
12608 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12609 ut_params->ibuf, reference->digest.len);
12611 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12612 "no room to append auth tag");
12614 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12615 ut_params->ibuf, reference->ciphertext.len);
12618 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12620 memcpy(sym_op->auth.digest.data,
12621 reference->digest.data,
12622 reference->digest.len);
12624 debug_hexdump(stdout, "digest:",
12625 sym_op->auth.digest.data,
12626 reference->digest.len);
12628 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12629 reference->iv.data, reference->iv.len);
12631 sym_op->cipher.data.length = reference->cipher_len;
12632 sym_op->cipher.data.offset = reference->cipher_offset;
12634 sym_op->auth.data.length = reference->plaintext.len;
12635 sym_op->auth.data.offset = reference->auth_offset;
12641 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12642 struct crypto_unittest_params *ut_params,
12643 const struct test_crypto_vector *reference)
12645 return create_auth_operation(ts_params, ut_params, reference, 0);
12649 create_auth_verify_GMAC_operation(
12650 struct crypto_testsuite_params *ts_params,
12651 struct crypto_unittest_params *ut_params,
12652 const struct test_crypto_vector *reference)
12654 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12658 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12659 struct crypto_unittest_params *ut_params,
12660 const struct test_crypto_vector *reference)
12662 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12666 test_authentication_verify_fail_when_data_corruption(
12667 struct crypto_testsuite_params *ts_params,
12668 struct crypto_unittest_params *ut_params,
12669 const struct test_crypto_vector *reference,
12670 unsigned int data_corrupted)
12674 uint8_t *plaintext;
12675 struct rte_cryptodev_info dev_info;
12677 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12678 uint64_t feat_flags = dev_info.feature_flags;
12680 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12681 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12682 printf("Device doesn't support RAW data-path APIs.\n");
12683 return TEST_SKIPPED;
12686 /* Verify the capabilities */
12687 struct rte_cryptodev_sym_capability_idx cap_idx;
12688 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12689 cap_idx.algo.auth = reference->auth_algo;
12690 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12692 return TEST_SKIPPED;
12695 /* Create session */
12696 retval = create_auth_session(ut_params,
12697 ts_params->valid_devs[0],
12699 RTE_CRYPTO_AUTH_OP_VERIFY);
12703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12704 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12705 "Failed to allocate input buffer in mempool");
12707 /* clear mbuf payload */
12708 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12709 rte_pktmbuf_tailroom(ut_params->ibuf));
12711 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12712 reference->plaintext.len);
12713 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12714 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12716 debug_hexdump(stdout, "plaintext:", plaintext,
12717 reference->plaintext.len);
12719 /* Create operation */
12720 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12725 if (data_corrupted)
12726 data_corruption(plaintext);
12728 tag_corruption(plaintext, reference->plaintext.len);
12730 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12731 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12733 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12734 RTE_CRYPTO_OP_STATUS_SUCCESS,
12735 "authentication not failed");
12736 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12737 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12738 ut_params->op, 0, 1, 0, 0);
12740 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12742 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12749 test_authentication_verify_GMAC_fail_when_corruption(
12750 struct crypto_testsuite_params *ts_params,
12751 struct crypto_unittest_params *ut_params,
12752 const struct test_crypto_vector *reference,
12753 unsigned int data_corrupted)
12756 uint8_t *plaintext;
12757 struct rte_cryptodev_info dev_info;
12759 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12760 uint64_t feat_flags = dev_info.feature_flags;
12762 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12763 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12764 printf("Device doesn't support RAW data-path APIs.\n");
12765 return TEST_SKIPPED;
12768 /* Verify the capabilities */
12769 struct rte_cryptodev_sym_capability_idx cap_idx;
12770 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12771 cap_idx.algo.auth = reference->auth_algo;
12772 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12774 return TEST_SKIPPED;
12776 /* Create session */
12777 retval = create_auth_cipher_session(ut_params,
12778 ts_params->valid_devs[0],
12780 RTE_CRYPTO_AUTH_OP_VERIFY,
12781 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12785 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12786 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12787 "Failed to allocate input buffer in mempool");
12789 /* clear mbuf payload */
12790 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12791 rte_pktmbuf_tailroom(ut_params->ibuf));
12793 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12794 reference->plaintext.len);
12795 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12796 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12798 debug_hexdump(stdout, "plaintext:", plaintext,
12799 reference->plaintext.len);
12801 /* Create operation */
12802 retval = create_auth_verify_GMAC_operation(ts_params,
12809 if (data_corrupted)
12810 data_corruption(plaintext);
12812 tag_corruption(plaintext, reference->aad.len);
12814 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12815 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12817 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12818 RTE_CRYPTO_OP_STATUS_SUCCESS,
12819 "authentication not failed");
12820 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12821 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12822 ut_params->op, 0, 1, 0, 0);
12824 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12826 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12833 test_authenticated_decryption_fail_when_corruption(
12834 struct crypto_testsuite_params *ts_params,
12835 struct crypto_unittest_params *ut_params,
12836 const struct test_crypto_vector *reference,
12837 unsigned int data_corrupted)
12841 uint8_t *ciphertext;
12842 struct rte_cryptodev_info dev_info;
12844 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12845 uint64_t feat_flags = dev_info.feature_flags;
12847 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12848 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12849 printf("Device doesn't support RAW data-path APIs.\n");
12850 return TEST_SKIPPED;
12853 /* Verify the capabilities */
12854 struct rte_cryptodev_sym_capability_idx cap_idx;
12855 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12856 cap_idx.algo.auth = reference->auth_algo;
12857 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12859 return TEST_SKIPPED;
12860 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12861 cap_idx.algo.cipher = reference->crypto_algo;
12862 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12864 return TEST_SKIPPED;
12866 /* Create session */
12867 retval = create_auth_cipher_session(ut_params,
12868 ts_params->valid_devs[0],
12870 RTE_CRYPTO_AUTH_OP_VERIFY,
12871 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12875 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12876 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12877 "Failed to allocate input buffer in mempool");
12879 /* clear mbuf payload */
12880 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12881 rte_pktmbuf_tailroom(ut_params->ibuf));
12883 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12884 reference->ciphertext.len);
12885 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12886 memcpy(ciphertext, reference->ciphertext.data,
12887 reference->ciphertext.len);
12889 /* Create operation */
12890 retval = create_cipher_auth_verify_operation(ts_params,
12897 if (data_corrupted)
12898 data_corruption(ciphertext);
12900 tag_corruption(ciphertext, reference->ciphertext.len);
12902 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12903 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12905 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12906 RTE_CRYPTO_OP_STATUS_SUCCESS,
12907 "authentication not failed");
12908 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12909 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12910 ut_params->op, 1, 1, 0, 0);
12912 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12914 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12921 test_authenticated_encrypt_with_esn(
12922 struct crypto_testsuite_params *ts_params,
12923 struct crypto_unittest_params *ut_params,
12924 const struct test_crypto_vector *reference)
12928 uint8_t *authciphertext, *plaintext, *auth_tag;
12929 uint16_t plaintext_pad_len;
12930 uint8_t cipher_key[reference->cipher_key.len + 1];
12931 uint8_t auth_key[reference->auth_key.len + 1];
12932 struct rte_cryptodev_info dev_info;
12934 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12935 uint64_t feat_flags = dev_info.feature_flags;
12937 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12938 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12939 printf("Device doesn't support RAW data-path APIs.\n");
12940 return TEST_SKIPPED;
12943 /* Verify the capabilities */
12944 struct rte_cryptodev_sym_capability_idx cap_idx;
12945 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12946 cap_idx.algo.auth = reference->auth_algo;
12947 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12949 return TEST_SKIPPED;
12950 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12951 cap_idx.algo.cipher = reference->crypto_algo;
12952 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12954 return TEST_SKIPPED;
12956 /* Create session */
12957 memcpy(cipher_key, reference->cipher_key.data,
12958 reference->cipher_key.len);
12959 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12961 /* Setup Cipher Parameters */
12962 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12963 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12964 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12965 ut_params->cipher_xform.cipher.key.data = cipher_key;
12966 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12967 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12968 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12970 ut_params->cipher_xform.next = &ut_params->auth_xform;
12972 /* Setup Authentication Parameters */
12973 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12974 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12975 ut_params->auth_xform.auth.algo = reference->auth_algo;
12976 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12977 ut_params->auth_xform.auth.key.data = auth_key;
12978 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12979 ut_params->auth_xform.next = NULL;
12981 /* Create Crypto session*/
12982 ut_params->sess = rte_cryptodev_sym_session_create(
12983 ts_params->session_mpool);
12985 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12987 &ut_params->cipher_xform,
12988 ts_params->session_priv_mpool);
12990 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12992 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12993 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12994 "Failed to allocate input buffer in mempool");
12996 /* clear mbuf payload */
12997 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12998 rte_pktmbuf_tailroom(ut_params->ibuf));
13000 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13001 reference->plaintext.len);
13002 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13003 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13005 /* Create operation */
13006 retval = create_cipher_auth_operation(ts_params,
13013 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13014 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13016 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13017 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13018 ut_params->op, 1, 1, 0, 0);
13020 ut_params->op = process_crypto_request(
13021 ts_params->valid_devs[0], ut_params->op);
13023 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13025 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13026 "crypto op processing failed");
13028 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13030 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13031 ut_params->op->sym->auth.data.offset);
13032 auth_tag = authciphertext + plaintext_pad_len;
13033 debug_hexdump(stdout, "ciphertext:", authciphertext,
13034 reference->ciphertext.len);
13035 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13037 /* Validate obuf */
13038 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13040 reference->ciphertext.data,
13041 reference->ciphertext.len,
13042 "Ciphertext data not as expected");
13044 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13046 reference->digest.data,
13047 reference->digest.len,
13048 "Generated digest not as expected");
13050 return TEST_SUCCESS;
13055 test_authenticated_decrypt_with_esn(
13056 struct crypto_testsuite_params *ts_params,
13057 struct crypto_unittest_params *ut_params,
13058 const struct test_crypto_vector *reference)
13062 uint8_t *ciphertext;
13063 uint8_t cipher_key[reference->cipher_key.len + 1];
13064 uint8_t auth_key[reference->auth_key.len + 1];
13065 struct rte_cryptodev_info dev_info;
13067 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13068 uint64_t feat_flags = dev_info.feature_flags;
13070 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13071 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13072 printf("Device doesn't support RAW data-path APIs.\n");
13073 return TEST_SKIPPED;
13076 /* Verify the capabilities */
13077 struct rte_cryptodev_sym_capability_idx cap_idx;
13078 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13079 cap_idx.algo.auth = reference->auth_algo;
13080 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13082 return TEST_SKIPPED;
13083 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13084 cap_idx.algo.cipher = reference->crypto_algo;
13085 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13087 return TEST_SKIPPED;
13089 /* Create session */
13090 memcpy(cipher_key, reference->cipher_key.data,
13091 reference->cipher_key.len);
13092 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13094 /* Setup Authentication Parameters */
13095 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13096 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13097 ut_params->auth_xform.auth.algo = reference->auth_algo;
13098 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13099 ut_params->auth_xform.auth.key.data = auth_key;
13100 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13101 ut_params->auth_xform.next = &ut_params->cipher_xform;
13103 /* Setup Cipher Parameters */
13104 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13105 ut_params->cipher_xform.next = NULL;
13106 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13107 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13108 ut_params->cipher_xform.cipher.key.data = cipher_key;
13109 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13110 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13111 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13113 /* Create Crypto session*/
13114 ut_params->sess = rte_cryptodev_sym_session_create(
13115 ts_params->session_mpool);
13117 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13119 &ut_params->auth_xform,
13120 ts_params->session_priv_mpool);
13122 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13124 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13125 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13126 "Failed to allocate input buffer in mempool");
13128 /* clear mbuf payload */
13129 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13130 rte_pktmbuf_tailroom(ut_params->ibuf));
13132 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13133 reference->ciphertext.len);
13134 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13135 memcpy(ciphertext, reference->ciphertext.data,
13136 reference->ciphertext.len);
13138 /* Create operation */
13139 retval = create_cipher_auth_verify_operation(ts_params,
13146 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13147 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13149 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13150 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13151 ut_params->op, 1, 1, 0, 0);
13153 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13156 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13157 TEST_ASSERT_EQUAL(ut_params->op->status,
13158 RTE_CRYPTO_OP_STATUS_SUCCESS,
13159 "crypto op processing passed");
13161 ut_params->obuf = ut_params->op->sym->m_src;
13162 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13168 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13169 const struct aead_test_data *tdata,
13170 void *digest_mem, uint64_t digest_phys)
13172 struct crypto_testsuite_params *ts_params = &testsuite_params;
13173 struct crypto_unittest_params *ut_params = &unittest_params;
13175 const unsigned int auth_tag_len = tdata->auth_tag.len;
13176 const unsigned int iv_len = tdata->iv.len;
13177 unsigned int aad_len = tdata->aad.len;
13178 unsigned int aad_len_pad = 0;
13180 /* Generate Crypto op data structure */
13181 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13182 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13183 TEST_ASSERT_NOT_NULL(ut_params->op,
13184 "Failed to allocate symmetric crypto operation struct");
13186 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13188 sym_op->aead.digest.data = digest_mem;
13190 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13191 "no room to append digest");
13193 sym_op->aead.digest.phys_addr = digest_phys;
13195 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13196 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13198 debug_hexdump(stdout, "digest:",
13199 sym_op->aead.digest.data,
13203 /* Append aad data */
13204 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13205 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13206 uint8_t *, IV_OFFSET);
13208 /* Copy IV 1 byte after the IV pointer, according to the API */
13209 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13211 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13213 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13214 ut_params->ibuf, aad_len);
13215 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13216 "no room to prepend aad");
13217 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13220 memset(sym_op->aead.aad.data, 0, aad_len);
13221 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
13222 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13224 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13225 debug_hexdump(stdout, "aad:",
13226 sym_op->aead.aad.data, aad_len);
13228 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13229 uint8_t *, IV_OFFSET);
13231 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13233 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13235 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13236 ut_params->ibuf, aad_len_pad);
13237 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13238 "no room to prepend aad");
13239 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13242 memset(sym_op->aead.aad.data, 0, aad_len);
13243 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13245 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13246 debug_hexdump(stdout, "aad:",
13247 sym_op->aead.aad.data, aad_len);
13250 sym_op->aead.data.length = tdata->plaintext.len;
13251 sym_op->aead.data.offset = aad_len_pad;
13256 #define SGL_MAX_NO 16
13259 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13260 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13262 struct crypto_testsuite_params *ts_params = &testsuite_params;
13263 struct crypto_unittest_params *ut_params = &unittest_params;
13264 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13267 int to_trn_tbl[SGL_MAX_NO];
13269 unsigned int trn_data = 0;
13270 uint8_t *plaintext, *ciphertext, *auth_tag;
13271 struct rte_cryptodev_info dev_info;
13273 /* Verify the capabilities */
13274 struct rte_cryptodev_sym_capability_idx cap_idx;
13275 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13276 cap_idx.algo.aead = tdata->algo;
13277 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13279 return TEST_SKIPPED;
13281 /* OOP not supported with CPU crypto */
13282 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13283 return TEST_SKIPPED;
13285 /* Detailed check for the particular SGL support flag */
13286 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13288 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13289 if (sgl_in && (!(dev_info.feature_flags &
13290 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13291 return TEST_SKIPPED;
13293 uint64_t feat_flags = dev_info.feature_flags;
13295 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13296 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13297 printf("Device doesn't support RAW data-path APIs.\n");
13298 return TEST_SKIPPED;
13301 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13302 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13303 tdata->plaintext.len;
13304 /* Raw data path API does not support OOP */
13305 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13306 return TEST_SKIPPED;
13307 if (sgl_in && !sgl_out) {
13308 if (!(dev_info.feature_flags &
13309 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13310 return TEST_SKIPPED;
13311 } else if (!sgl_in && sgl_out) {
13312 if (!(dev_info.feature_flags &
13313 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13314 return TEST_SKIPPED;
13315 } else if (sgl_in && sgl_out) {
13316 if (!(dev_info.feature_flags &
13317 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13318 return TEST_SKIPPED;
13322 if (fragsz > tdata->plaintext.len)
13323 fragsz = tdata->plaintext.len;
13325 uint16_t plaintext_len = fragsz;
13326 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13328 if (fragsz_oop > tdata->plaintext.len)
13329 frag_size_oop = tdata->plaintext.len;
13332 void *digest_mem = NULL;
13334 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13336 if (tdata->plaintext.len % fragsz != 0) {
13337 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13340 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13345 * For out-op-place we need to alloc another mbuf
13348 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13349 rte_pktmbuf_append(ut_params->obuf,
13350 frag_size_oop + prepend_len);
13351 buf_oop = ut_params->obuf;
13354 /* Create AEAD session */
13355 retval = create_aead_session(ts_params->valid_devs[0],
13357 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13358 tdata->key.data, tdata->key.len,
13359 tdata->aad.len, tdata->auth_tag.len,
13364 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13366 /* clear mbuf payload */
13367 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13368 rte_pktmbuf_tailroom(ut_params->ibuf));
13370 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13373 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13375 trn_data += plaintext_len;
13377 buf = ut_params->ibuf;
13380 * Loop until no more fragments
13383 while (trn_data < tdata->plaintext.len) {
13385 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13386 (tdata->plaintext.len - trn_data) : fragsz;
13388 to_trn_tbl[ecx++] = to_trn;
13390 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13393 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13394 rte_pktmbuf_tailroom(buf));
13397 if (oop && !fragsz_oop) {
13398 buf_last_oop = buf_oop->next =
13399 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13400 buf_oop = buf_oop->next;
13401 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13402 0, rte_pktmbuf_tailroom(buf_oop));
13403 rte_pktmbuf_append(buf_oop, to_trn);
13406 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13409 memcpy(plaintext, tdata->plaintext.data + trn_data,
13411 trn_data += to_trn;
13412 if (trn_data == tdata->plaintext.len) {
13415 digest_mem = rte_pktmbuf_append(buf_oop,
13416 tdata->auth_tag.len);
13418 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13419 tdata->auth_tag.len);
13423 uint64_t digest_phys = 0;
13425 ut_params->ibuf->nb_segs = segs;
13428 if (fragsz_oop && oop) {
13432 if (frag_size_oop == tdata->plaintext.len) {
13433 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13434 tdata->auth_tag.len);
13436 digest_phys = rte_pktmbuf_iova_offset(
13438 tdata->plaintext.len + prepend_len);
13441 trn_data = frag_size_oop;
13442 while (trn_data < tdata->plaintext.len) {
13445 (tdata->plaintext.len - trn_data <
13447 (tdata->plaintext.len - trn_data) :
13450 to_trn_tbl[ecx++] = to_trn;
13452 buf_last_oop = buf_oop->next =
13453 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13454 buf_oop = buf_oop->next;
13455 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13456 0, rte_pktmbuf_tailroom(buf_oop));
13457 rte_pktmbuf_append(buf_oop, to_trn);
13459 trn_data += to_trn;
13461 if (trn_data == tdata->plaintext.len) {
13462 digest_mem = rte_pktmbuf_append(buf_oop,
13463 tdata->auth_tag.len);
13467 ut_params->obuf->nb_segs = segs;
13471 * Place digest at the end of the last buffer
13474 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13475 if (oop && buf_last_oop)
13476 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13478 if (!digest_mem && !oop) {
13479 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13480 + tdata->auth_tag.len);
13481 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13482 tdata->plaintext.len);
13485 /* Create AEAD operation */
13486 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13487 tdata, digest_mem, digest_phys);
13492 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13494 ut_params->op->sym->m_src = ut_params->ibuf;
13496 ut_params->op->sym->m_dst = ut_params->obuf;
13498 /* Process crypto operation */
13499 if (oop == IN_PLACE &&
13500 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13501 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13502 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13503 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13504 ut_params->op, 0, 0, 0, 0);
13506 TEST_ASSERT_NOT_NULL(
13507 process_crypto_request(ts_params->valid_devs[0],
13508 ut_params->op), "failed to process sym crypto op");
13510 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13511 "crypto op processing failed");
13514 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13515 uint8_t *, prepend_len);
13517 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13518 uint8_t *, prepend_len);
13522 fragsz = fragsz_oop;
13524 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13526 tdata->ciphertext.data,
13528 "Ciphertext data not as expected");
13530 buf = ut_params->op->sym->m_src->next;
13532 buf = ut_params->op->sym->m_dst->next;
13534 unsigned int off = fragsz;
13538 ciphertext = rte_pktmbuf_mtod(buf,
13541 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13543 tdata->ciphertext.data + off,
13545 "Ciphertext data not as expected");
13547 off += to_trn_tbl[ecx++];
13551 auth_tag = digest_mem;
13552 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13554 tdata->auth_tag.data,
13555 tdata->auth_tag.len,
13556 "Generated auth tag not as expected");
13562 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13564 return test_authenticated_encryption_SGL(
13565 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13569 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13571 return test_authenticated_encryption_SGL(
13572 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13576 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13578 return test_authenticated_encryption_SGL(
13579 &gcm_test_case_8, OUT_OF_PLACE, 400,
13580 gcm_test_case_8.plaintext.len);
13584 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13586 /* This test is not for OPENSSL PMD */
13587 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13588 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13589 return TEST_SKIPPED;
13591 return test_authenticated_encryption_SGL(
13592 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13596 test_authentication_verify_fail_when_data_corrupted(
13597 struct crypto_testsuite_params *ts_params,
13598 struct crypto_unittest_params *ut_params,
13599 const struct test_crypto_vector *reference)
13601 return test_authentication_verify_fail_when_data_corruption(
13602 ts_params, ut_params, reference, 1);
13606 test_authentication_verify_fail_when_tag_corrupted(
13607 struct crypto_testsuite_params *ts_params,
13608 struct crypto_unittest_params *ut_params,
13609 const struct test_crypto_vector *reference)
13611 return test_authentication_verify_fail_when_data_corruption(
13612 ts_params, ut_params, reference, 0);
13616 test_authentication_verify_GMAC_fail_when_data_corrupted(
13617 struct crypto_testsuite_params *ts_params,
13618 struct crypto_unittest_params *ut_params,
13619 const struct test_crypto_vector *reference)
13621 return test_authentication_verify_GMAC_fail_when_corruption(
13622 ts_params, ut_params, reference, 1);
13626 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13627 struct crypto_testsuite_params *ts_params,
13628 struct crypto_unittest_params *ut_params,
13629 const struct test_crypto_vector *reference)
13631 return test_authentication_verify_GMAC_fail_when_corruption(
13632 ts_params, ut_params, reference, 0);
13636 test_authenticated_decryption_fail_when_data_corrupted(
13637 struct crypto_testsuite_params *ts_params,
13638 struct crypto_unittest_params *ut_params,
13639 const struct test_crypto_vector *reference)
13641 return test_authenticated_decryption_fail_when_corruption(
13642 ts_params, ut_params, reference, 1);
13646 test_authenticated_decryption_fail_when_tag_corrupted(
13647 struct crypto_testsuite_params *ts_params,
13648 struct crypto_unittest_params *ut_params,
13649 const struct test_crypto_vector *reference)
13651 return test_authenticated_decryption_fail_when_corruption(
13652 ts_params, ut_params, reference, 0);
13656 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13658 return test_authentication_verify_fail_when_data_corrupted(
13659 &testsuite_params, &unittest_params,
13660 &hmac_sha1_test_crypto_vector);
13664 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13666 return test_authentication_verify_fail_when_tag_corrupted(
13667 &testsuite_params, &unittest_params,
13668 &hmac_sha1_test_crypto_vector);
13672 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13674 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13675 &testsuite_params, &unittest_params,
13676 &aes128_gmac_test_vector);
13680 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13682 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13683 &testsuite_params, &unittest_params,
13684 &aes128_gmac_test_vector);
13688 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13690 return test_authenticated_decryption_fail_when_data_corrupted(
13693 &aes128cbc_hmac_sha1_test_vector);
13697 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13699 return test_authenticated_decryption_fail_when_tag_corrupted(
13702 &aes128cbc_hmac_sha1_test_vector);
13706 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13708 return test_authenticated_encrypt_with_esn(
13711 &aes128cbc_hmac_sha1_aad_test_vector);
13715 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13717 return test_authenticated_decrypt_with_esn(
13720 &aes128cbc_hmac_sha1_aad_test_vector);
13724 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13726 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13730 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13732 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13735 #ifdef RTE_CRYPTO_SCHEDULER
13737 /* global AESNI worker IDs for the scheduler test */
13738 uint8_t aesni_ids[2];
13741 scheduler_testsuite_setup(void)
13744 int32_t nb_devs, ret;
13745 char vdev_args[VDEV_ARGS_SIZE] = {""};
13746 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
13747 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
13748 uint16_t worker_core_count = 0;
13749 uint16_t socket_id = 0;
13751 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13752 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
13754 /* Identify the Worker Cores
13755 * Use 2 worker cores for the device args
13757 RTE_LCORE_FOREACH_WORKER(i) {
13758 if (worker_core_count > 1)
13760 snprintf(vdev_args, sizeof(vdev_args),
13761 "%s%d", temp_str, i);
13762 strcpy(temp_str, vdev_args);
13763 strlcat(temp_str, ";", sizeof(temp_str));
13764 worker_core_count++;
13765 socket_id = rte_lcore_to_socket_id(i);
13767 if (worker_core_count != 2) {
13768 RTE_LOG(ERR, USER1,
13769 "Cryptodev scheduler test require at least "
13770 "two worker cores to run. "
13771 "Please use the correct coremask.\n");
13772 return TEST_FAILED;
13774 strcpy(temp_str, vdev_args);
13775 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
13776 temp_str, socket_id);
13777 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
13778 nb_devs = rte_cryptodev_device_count_by_driver(
13779 rte_cryptodev_driver_id_get(
13780 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
13782 ret = rte_vdev_init(
13783 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
13785 TEST_ASSERT(ret == 0,
13786 "Failed to create instance %u of pmd : %s",
13787 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13790 return testsuite_setup();
13794 test_scheduler_attach_worker_op(void)
13796 struct crypto_testsuite_params *ts_params = &testsuite_params;
13797 uint8_t sched_id = ts_params->valid_devs[0];
13798 uint32_t i, nb_devs_attached = 0;
13800 char vdev_name[32];
13801 unsigned int count = rte_cryptodev_count();
13803 /* create 2 AESNI_MB vdevs on top of existing devices */
13804 for (i = count; i < count + 2; i++) {
13805 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13806 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13808 ret = rte_vdev_init(vdev_name, NULL);
13810 TEST_ASSERT(ret == 0,
13811 "Failed to create instance %u of"
13813 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13816 RTE_LOG(ERR, USER1,
13817 "Failed to create 2 AESNI MB PMDs.\n");
13818 return TEST_SKIPPED;
13822 /* attach 2 AESNI_MB cdevs */
13823 for (i = count; i < count + 2; i++) {
13824 struct rte_cryptodev_info info;
13825 unsigned int session_size;
13827 rte_cryptodev_info_get(i, &info);
13828 if (info.driver_id != rte_cryptodev_driver_id_get(
13829 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13832 session_size = rte_cryptodev_sym_get_private_session_size(i);
13834 * Create the session mempool again, since now there are new devices
13835 * to use the mempool.
13837 if (ts_params->session_mpool) {
13838 rte_mempool_free(ts_params->session_mpool);
13839 ts_params->session_mpool = NULL;
13841 if (ts_params->session_priv_mpool) {
13842 rte_mempool_free(ts_params->session_priv_mpool);
13843 ts_params->session_priv_mpool = NULL;
13846 if (info.sym.max_nb_sessions != 0 &&
13847 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13848 RTE_LOG(ERR, USER1,
13849 "Device does not support "
13850 "at least %u sessions\n",
13852 return TEST_FAILED;
13855 * Create mempool with maximum number of sessions,
13856 * to include the session headers
13858 if (ts_params->session_mpool == NULL) {
13859 ts_params->session_mpool =
13860 rte_cryptodev_sym_session_pool_create(
13862 MAX_NB_SESSIONS, 0, 0, 0,
13864 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13865 "session mempool allocation failed");
13869 * Create mempool with maximum number of sessions,
13870 * to include device specific session private data
13872 if (ts_params->session_priv_mpool == NULL) {
13873 ts_params->session_priv_mpool = rte_mempool_create(
13874 "test_sess_mp_priv",
13877 0, 0, NULL, NULL, NULL,
13878 NULL, SOCKET_ID_ANY,
13881 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13882 "session mempool allocation failed");
13885 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13886 ts_params->qp_conf.mp_session_private =
13887 ts_params->session_priv_mpool;
13889 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13892 TEST_ASSERT(ret == 0,
13893 "Failed to attach device %u of pmd : %s", i,
13894 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13896 aesni_ids[nb_devs_attached] = (uint8_t)i;
13898 nb_devs_attached++;
13905 test_scheduler_detach_worker_op(void)
13907 struct crypto_testsuite_params *ts_params = &testsuite_params;
13908 uint8_t sched_id = ts_params->valid_devs[0];
13912 for (i = 0; i < 2; i++) {
13913 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13915 TEST_ASSERT(ret == 0,
13916 "Failed to detach device %u", aesni_ids[i]);
13923 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13925 struct crypto_testsuite_params *ts_params = &testsuite_params;
13926 uint8_t sched_id = ts_params->valid_devs[0];
13928 return rte_cryptodev_scheduler_mode_set(sched_id,
13933 test_scheduler_mode_roundrobin_op(void)
13935 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13936 0, "Failed to set roundrobin mode");
13942 test_scheduler_mode_multicore_op(void)
13944 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13945 0, "Failed to set multicore mode");
13951 test_scheduler_mode_failover_op(void)
13953 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13954 0, "Failed to set failover mode");
13960 test_scheduler_mode_pkt_size_distr_op(void)
13962 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13963 0, "Failed to set pktsize mode");
13969 scheduler_multicore_testsuite_setup(void)
13971 if (test_scheduler_attach_worker_op() < 0)
13972 return TEST_SKIPPED;
13973 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
13974 return TEST_SKIPPED;
13979 scheduler_roundrobin_testsuite_setup(void)
13981 if (test_scheduler_attach_worker_op() < 0)
13982 return TEST_SKIPPED;
13983 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
13984 return TEST_SKIPPED;
13989 scheduler_failover_testsuite_setup(void)
13991 if (test_scheduler_attach_worker_op() < 0)
13992 return TEST_SKIPPED;
13993 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
13994 return TEST_SKIPPED;
13999 scheduler_pkt_size_distr_testsuite_setup(void)
14001 if (test_scheduler_attach_worker_op() < 0)
14002 return TEST_SKIPPED;
14003 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14004 return TEST_SKIPPED;
14009 scheduler_mode_testsuite_teardown(void)
14011 test_scheduler_detach_worker_op();
14014 #endif /* RTE_CRYPTO_SCHEDULER */
14016 static struct unit_test_suite end_testsuite = {
14017 .suite_name = NULL,
14020 .unit_test_suites = NULL
14023 #ifdef RTE_LIB_SECURITY
14024 static struct unit_test_suite ipsec_proto_testsuite = {
14025 .suite_name = "IPsec Proto Unit Test Suite",
14026 .setup = ipsec_proto_testsuite_setup,
14027 .unit_test_cases = {
14028 TEST_CASE_NAMED_WITH_DATA(
14029 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14030 ut_setup_security, ut_teardown,
14031 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14032 TEST_CASE_NAMED_WITH_DATA(
14033 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14034 ut_setup_security, ut_teardown,
14035 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14036 TEST_CASE_NAMED_WITH_DATA(
14037 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14038 ut_setup_security, ut_teardown,
14039 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14040 TEST_CASE_NAMED_ST(
14041 "Combined test alg list",
14042 ut_setup_security, ut_teardown,
14043 test_ipsec_proto_display_list),
14044 TEST_CASES_END() /**< NULL terminate unit test array */
14048 static struct unit_test_suite pdcp_proto_testsuite = {
14049 .suite_name = "PDCP Proto Unit Test Suite",
14050 .setup = pdcp_proto_testsuite_setup,
14051 .unit_test_cases = {
14052 TEST_CASE_ST(ut_setup_security, ut_teardown,
14053 test_PDCP_PROTO_all),
14054 TEST_CASES_END() /**< NULL terminate unit test array */
14058 static struct unit_test_suite docsis_proto_testsuite = {
14059 .suite_name = "Docsis Proto Unit Test Suite",
14060 .setup = docsis_proto_testsuite_setup,
14061 .unit_test_cases = {
14062 TEST_CASE_ST(ut_setup_security, ut_teardown,
14063 test_DOCSIS_PROTO_all),
14064 TEST_CASES_END() /**< NULL terminate unit test array */
14069 static struct unit_test_suite cryptodev_gen_testsuite = {
14070 .suite_name = "Crypto General Unit Test Suite",
14071 .setup = crypto_gen_testsuite_setup,
14072 .unit_test_cases = {
14073 TEST_CASE_ST(ut_setup, ut_teardown,
14074 test_device_configure_invalid_dev_id),
14075 TEST_CASE_ST(ut_setup, ut_teardown,
14076 test_queue_pair_descriptor_setup),
14077 TEST_CASE_ST(ut_setup, ut_teardown,
14078 test_device_configure_invalid_queue_pair_ids),
14079 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
14080 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
14081 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
14082 TEST_CASES_END() /**< NULL terminate unit test array */
14086 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
14087 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
14088 .setup = negative_hmac_sha1_testsuite_setup,
14089 .unit_test_cases = {
14090 /** Negative tests */
14091 TEST_CASE_ST(ut_setup, ut_teardown,
14092 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14093 TEST_CASE_ST(ut_setup, ut_teardown,
14094 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14095 TEST_CASE_ST(ut_setup, ut_teardown,
14096 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14097 TEST_CASE_ST(ut_setup, ut_teardown,
14098 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14100 TEST_CASES_END() /**< NULL terminate unit test array */
14104 static struct unit_test_suite cryptodev_multi_session_testsuite = {
14105 .suite_name = "Multi Session Unit Test Suite",
14106 .setup = multi_session_testsuite_setup,
14107 .unit_test_cases = {
14108 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14109 TEST_CASE_ST(ut_setup, ut_teardown,
14110 test_multi_session_random_usage),
14112 TEST_CASES_END() /**< NULL terminate unit test array */
14116 static struct unit_test_suite cryptodev_null_testsuite = {
14117 .suite_name = "NULL Test Suite",
14118 .setup = null_testsuite_setup,
14119 .unit_test_cases = {
14120 TEST_CASE_ST(ut_setup, ut_teardown,
14121 test_null_invalid_operation),
14122 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
14127 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
14128 .suite_name = "AES CCM Authenticated Test Suite",
14129 .setup = aes_ccm_auth_testsuite_setup,
14130 .unit_test_cases = {
14131 /** AES CCM Authenticated Encryption 128 bits key*/
14132 TEST_CASE_ST(ut_setup, ut_teardown,
14133 test_AES_CCM_authenticated_encryption_test_case_128_1),
14134 TEST_CASE_ST(ut_setup, ut_teardown,
14135 test_AES_CCM_authenticated_encryption_test_case_128_2),
14136 TEST_CASE_ST(ut_setup, ut_teardown,
14137 test_AES_CCM_authenticated_encryption_test_case_128_3),
14139 /** AES CCM Authenticated Decryption 128 bits key*/
14140 TEST_CASE_ST(ut_setup, ut_teardown,
14141 test_AES_CCM_authenticated_decryption_test_case_128_1),
14142 TEST_CASE_ST(ut_setup, ut_teardown,
14143 test_AES_CCM_authenticated_decryption_test_case_128_2),
14144 TEST_CASE_ST(ut_setup, ut_teardown,
14145 test_AES_CCM_authenticated_decryption_test_case_128_3),
14147 /** AES CCM Authenticated Encryption 192 bits key */
14148 TEST_CASE_ST(ut_setup, ut_teardown,
14149 test_AES_CCM_authenticated_encryption_test_case_192_1),
14150 TEST_CASE_ST(ut_setup, ut_teardown,
14151 test_AES_CCM_authenticated_encryption_test_case_192_2),
14152 TEST_CASE_ST(ut_setup, ut_teardown,
14153 test_AES_CCM_authenticated_encryption_test_case_192_3),
14155 /** AES CCM Authenticated Decryption 192 bits key*/
14156 TEST_CASE_ST(ut_setup, ut_teardown,
14157 test_AES_CCM_authenticated_decryption_test_case_192_1),
14158 TEST_CASE_ST(ut_setup, ut_teardown,
14159 test_AES_CCM_authenticated_decryption_test_case_192_2),
14160 TEST_CASE_ST(ut_setup, ut_teardown,
14161 test_AES_CCM_authenticated_decryption_test_case_192_3),
14163 /** AES CCM Authenticated Encryption 256 bits key */
14164 TEST_CASE_ST(ut_setup, ut_teardown,
14165 test_AES_CCM_authenticated_encryption_test_case_256_1),
14166 TEST_CASE_ST(ut_setup, ut_teardown,
14167 test_AES_CCM_authenticated_encryption_test_case_256_2),
14168 TEST_CASE_ST(ut_setup, ut_teardown,
14169 test_AES_CCM_authenticated_encryption_test_case_256_3),
14171 /** AES CCM Authenticated Decryption 256 bits key*/
14172 TEST_CASE_ST(ut_setup, ut_teardown,
14173 test_AES_CCM_authenticated_decryption_test_case_256_1),
14174 TEST_CASE_ST(ut_setup, ut_teardown,
14175 test_AES_CCM_authenticated_decryption_test_case_256_2),
14176 TEST_CASE_ST(ut_setup, ut_teardown,
14177 test_AES_CCM_authenticated_decryption_test_case_256_3),
14182 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
14183 .suite_name = "AES GCM Authenticated Test Suite",
14184 .setup = aes_gcm_auth_testsuite_setup,
14185 .unit_test_cases = {
14186 /** AES GCM Authenticated Encryption */
14187 TEST_CASE_ST(ut_setup, ut_teardown,
14188 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
14189 TEST_CASE_ST(ut_setup, ut_teardown,
14190 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
14191 TEST_CASE_ST(ut_setup, ut_teardown,
14192 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
14193 TEST_CASE_ST(ut_setup, ut_teardown,
14194 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
14195 TEST_CASE_ST(ut_setup, ut_teardown,
14196 test_AES_GCM_authenticated_encryption_test_case_1),
14197 TEST_CASE_ST(ut_setup, ut_teardown,
14198 test_AES_GCM_authenticated_encryption_test_case_2),
14199 TEST_CASE_ST(ut_setup, ut_teardown,
14200 test_AES_GCM_authenticated_encryption_test_case_3),
14201 TEST_CASE_ST(ut_setup, ut_teardown,
14202 test_AES_GCM_authenticated_encryption_test_case_4),
14203 TEST_CASE_ST(ut_setup, ut_teardown,
14204 test_AES_GCM_authenticated_encryption_test_case_5),
14205 TEST_CASE_ST(ut_setup, ut_teardown,
14206 test_AES_GCM_authenticated_encryption_test_case_6),
14207 TEST_CASE_ST(ut_setup, ut_teardown,
14208 test_AES_GCM_authenticated_encryption_test_case_7),
14209 TEST_CASE_ST(ut_setup, ut_teardown,
14210 test_AES_GCM_authenticated_encryption_test_case_8),
14211 TEST_CASE_ST(ut_setup, ut_teardown,
14212 test_AES_GCM_J0_authenticated_encryption_test_case_1),
14214 /** AES GCM Authenticated Decryption */
14215 TEST_CASE_ST(ut_setup, ut_teardown,
14216 test_AES_GCM_authenticated_decryption_test_case_1),
14217 TEST_CASE_ST(ut_setup, ut_teardown,
14218 test_AES_GCM_authenticated_decryption_test_case_2),
14219 TEST_CASE_ST(ut_setup, ut_teardown,
14220 test_AES_GCM_authenticated_decryption_test_case_3),
14221 TEST_CASE_ST(ut_setup, ut_teardown,
14222 test_AES_GCM_authenticated_decryption_test_case_4),
14223 TEST_CASE_ST(ut_setup, ut_teardown,
14224 test_AES_GCM_authenticated_decryption_test_case_5),
14225 TEST_CASE_ST(ut_setup, ut_teardown,
14226 test_AES_GCM_authenticated_decryption_test_case_6),
14227 TEST_CASE_ST(ut_setup, ut_teardown,
14228 test_AES_GCM_authenticated_decryption_test_case_7),
14229 TEST_CASE_ST(ut_setup, ut_teardown,
14230 test_AES_GCM_authenticated_decryption_test_case_8),
14231 TEST_CASE_ST(ut_setup, ut_teardown,
14232 test_AES_GCM_J0_authenticated_decryption_test_case_1),
14234 /** AES GCM Authenticated Encryption 192 bits key */
14235 TEST_CASE_ST(ut_setup, ut_teardown,
14236 test_AES_GCM_auth_encryption_test_case_192_1),
14237 TEST_CASE_ST(ut_setup, ut_teardown,
14238 test_AES_GCM_auth_encryption_test_case_192_2),
14239 TEST_CASE_ST(ut_setup, ut_teardown,
14240 test_AES_GCM_auth_encryption_test_case_192_3),
14241 TEST_CASE_ST(ut_setup, ut_teardown,
14242 test_AES_GCM_auth_encryption_test_case_192_4),
14243 TEST_CASE_ST(ut_setup, ut_teardown,
14244 test_AES_GCM_auth_encryption_test_case_192_5),
14245 TEST_CASE_ST(ut_setup, ut_teardown,
14246 test_AES_GCM_auth_encryption_test_case_192_6),
14247 TEST_CASE_ST(ut_setup, ut_teardown,
14248 test_AES_GCM_auth_encryption_test_case_192_7),
14250 /** AES GCM Authenticated Decryption 192 bits key */
14251 TEST_CASE_ST(ut_setup, ut_teardown,
14252 test_AES_GCM_auth_decryption_test_case_192_1),
14253 TEST_CASE_ST(ut_setup, ut_teardown,
14254 test_AES_GCM_auth_decryption_test_case_192_2),
14255 TEST_CASE_ST(ut_setup, ut_teardown,
14256 test_AES_GCM_auth_decryption_test_case_192_3),
14257 TEST_CASE_ST(ut_setup, ut_teardown,
14258 test_AES_GCM_auth_decryption_test_case_192_4),
14259 TEST_CASE_ST(ut_setup, ut_teardown,
14260 test_AES_GCM_auth_decryption_test_case_192_5),
14261 TEST_CASE_ST(ut_setup, ut_teardown,
14262 test_AES_GCM_auth_decryption_test_case_192_6),
14263 TEST_CASE_ST(ut_setup, ut_teardown,
14264 test_AES_GCM_auth_decryption_test_case_192_7),
14266 /** AES GCM Authenticated Encryption 256 bits key */
14267 TEST_CASE_ST(ut_setup, ut_teardown,
14268 test_AES_GCM_auth_encryption_test_case_256_1),
14269 TEST_CASE_ST(ut_setup, ut_teardown,
14270 test_AES_GCM_auth_encryption_test_case_256_2),
14271 TEST_CASE_ST(ut_setup, ut_teardown,
14272 test_AES_GCM_auth_encryption_test_case_256_3),
14273 TEST_CASE_ST(ut_setup, ut_teardown,
14274 test_AES_GCM_auth_encryption_test_case_256_4),
14275 TEST_CASE_ST(ut_setup, ut_teardown,
14276 test_AES_GCM_auth_encryption_test_case_256_5),
14277 TEST_CASE_ST(ut_setup, ut_teardown,
14278 test_AES_GCM_auth_encryption_test_case_256_6),
14279 TEST_CASE_ST(ut_setup, ut_teardown,
14280 test_AES_GCM_auth_encryption_test_case_256_7),
14282 /** AES GCM Authenticated Decryption 256 bits key */
14283 TEST_CASE_ST(ut_setup, ut_teardown,
14284 test_AES_GCM_auth_decryption_test_case_256_1),
14285 TEST_CASE_ST(ut_setup, ut_teardown,
14286 test_AES_GCM_auth_decryption_test_case_256_2),
14287 TEST_CASE_ST(ut_setup, ut_teardown,
14288 test_AES_GCM_auth_decryption_test_case_256_3),
14289 TEST_CASE_ST(ut_setup, ut_teardown,
14290 test_AES_GCM_auth_decryption_test_case_256_4),
14291 TEST_CASE_ST(ut_setup, ut_teardown,
14292 test_AES_GCM_auth_decryption_test_case_256_5),
14293 TEST_CASE_ST(ut_setup, ut_teardown,
14294 test_AES_GCM_auth_decryption_test_case_256_6),
14295 TEST_CASE_ST(ut_setup, ut_teardown,
14296 test_AES_GCM_auth_decryption_test_case_256_7),
14298 /** AES GCM Authenticated Encryption big aad size */
14299 TEST_CASE_ST(ut_setup, ut_teardown,
14300 test_AES_GCM_auth_encryption_test_case_aad_1),
14301 TEST_CASE_ST(ut_setup, ut_teardown,
14302 test_AES_GCM_auth_encryption_test_case_aad_2),
14304 /** AES GCM Authenticated Decryption big aad size */
14305 TEST_CASE_ST(ut_setup, ut_teardown,
14306 test_AES_GCM_auth_decryption_test_case_aad_1),
14307 TEST_CASE_ST(ut_setup, ut_teardown,
14308 test_AES_GCM_auth_decryption_test_case_aad_2),
14310 /** Out of place tests */
14311 TEST_CASE_ST(ut_setup, ut_teardown,
14312 test_AES_GCM_authenticated_encryption_oop_test_case_1),
14313 TEST_CASE_ST(ut_setup, ut_teardown,
14314 test_AES_GCM_authenticated_decryption_oop_test_case_1),
14316 /** Session-less tests */
14317 TEST_CASE_ST(ut_setup, ut_teardown,
14318 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
14319 TEST_CASE_ST(ut_setup, ut_teardown,
14320 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
14326 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
14327 .suite_name = "AES GMAC Authentication Test Suite",
14328 .setup = aes_gmac_auth_testsuite_setup,
14329 .unit_test_cases = {
14330 TEST_CASE_ST(ut_setup, ut_teardown,
14331 test_AES_GMAC_authentication_test_case_1),
14332 TEST_CASE_ST(ut_setup, ut_teardown,
14333 test_AES_GMAC_authentication_verify_test_case_1),
14334 TEST_CASE_ST(ut_setup, ut_teardown,
14335 test_AES_GMAC_authentication_test_case_2),
14336 TEST_CASE_ST(ut_setup, ut_teardown,
14337 test_AES_GMAC_authentication_verify_test_case_2),
14338 TEST_CASE_ST(ut_setup, ut_teardown,
14339 test_AES_GMAC_authentication_test_case_3),
14340 TEST_CASE_ST(ut_setup, ut_teardown,
14341 test_AES_GMAC_authentication_verify_test_case_3),
14342 TEST_CASE_ST(ut_setup, ut_teardown,
14343 test_AES_GMAC_authentication_test_case_4),
14344 TEST_CASE_ST(ut_setup, ut_teardown,
14345 test_AES_GMAC_authentication_verify_test_case_4),
14346 TEST_CASE_ST(ut_setup, ut_teardown,
14347 test_AES_GMAC_authentication_SGL_40B),
14348 TEST_CASE_ST(ut_setup, ut_teardown,
14349 test_AES_GMAC_authentication_SGL_80B),
14350 TEST_CASE_ST(ut_setup, ut_teardown,
14351 test_AES_GMAC_authentication_SGL_2048B),
14352 TEST_CASE_ST(ut_setup, ut_teardown,
14353 test_AES_GMAC_authentication_SGL_2047B),
14359 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14360 .suite_name = "Chacha20-Poly1305 Test Suite",
14361 .setup = chacha20_poly1305_testsuite_setup,
14362 .unit_test_cases = {
14363 TEST_CASE_ST(ut_setup, ut_teardown,
14364 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14365 TEST_CASE_ST(ut_setup, ut_teardown,
14366 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14371 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14372 .suite_name = "SNOW 3G Test Suite",
14373 .setup = snow3g_testsuite_setup,
14374 .unit_test_cases = {
14375 /** SNOW 3G encrypt only (UEA2) */
14376 TEST_CASE_ST(ut_setup, ut_teardown,
14377 test_snow3g_encryption_test_case_1),
14378 TEST_CASE_ST(ut_setup, ut_teardown,
14379 test_snow3g_encryption_test_case_2),
14380 TEST_CASE_ST(ut_setup, ut_teardown,
14381 test_snow3g_encryption_test_case_3),
14382 TEST_CASE_ST(ut_setup, ut_teardown,
14383 test_snow3g_encryption_test_case_4),
14384 TEST_CASE_ST(ut_setup, ut_teardown,
14385 test_snow3g_encryption_test_case_5),
14387 TEST_CASE_ST(ut_setup, ut_teardown,
14388 test_snow3g_encryption_test_case_1_oop),
14389 TEST_CASE_ST(ut_setup, ut_teardown,
14390 test_snow3g_encryption_test_case_1_oop_sgl),
14391 TEST_CASE_ST(ut_setup, ut_teardown,
14392 test_snow3g_encryption_test_case_1_offset_oop),
14393 TEST_CASE_ST(ut_setup, ut_teardown,
14394 test_snow3g_decryption_test_case_1_oop),
14396 /** SNOW 3G generate auth, then encrypt (UEA2) */
14397 TEST_CASE_ST(ut_setup, ut_teardown,
14398 test_snow3g_auth_cipher_test_case_1),
14399 TEST_CASE_ST(ut_setup, ut_teardown,
14400 test_snow3g_auth_cipher_test_case_2),
14401 TEST_CASE_ST(ut_setup, ut_teardown,
14402 test_snow3g_auth_cipher_test_case_2_oop),
14403 TEST_CASE_ST(ut_setup, ut_teardown,
14404 test_snow3g_auth_cipher_part_digest_enc),
14405 TEST_CASE_ST(ut_setup, ut_teardown,
14406 test_snow3g_auth_cipher_part_digest_enc_oop),
14407 TEST_CASE_ST(ut_setup, ut_teardown,
14408 test_snow3g_auth_cipher_test_case_3_sgl),
14409 TEST_CASE_ST(ut_setup, ut_teardown,
14410 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14411 TEST_CASE_ST(ut_setup, ut_teardown,
14412 test_snow3g_auth_cipher_part_digest_enc_sgl),
14413 TEST_CASE_ST(ut_setup, ut_teardown,
14414 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14416 /** SNOW 3G decrypt (UEA2), then verify auth */
14417 TEST_CASE_ST(ut_setup, ut_teardown,
14418 test_snow3g_auth_cipher_verify_test_case_1),
14419 TEST_CASE_ST(ut_setup, ut_teardown,
14420 test_snow3g_auth_cipher_verify_test_case_2),
14421 TEST_CASE_ST(ut_setup, ut_teardown,
14422 test_snow3g_auth_cipher_verify_test_case_2_oop),
14423 TEST_CASE_ST(ut_setup, ut_teardown,
14424 test_snow3g_auth_cipher_verify_part_digest_enc),
14425 TEST_CASE_ST(ut_setup, ut_teardown,
14426 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14427 TEST_CASE_ST(ut_setup, ut_teardown,
14428 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14429 TEST_CASE_ST(ut_setup, ut_teardown,
14430 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14431 TEST_CASE_ST(ut_setup, ut_teardown,
14432 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14433 TEST_CASE_ST(ut_setup, ut_teardown,
14434 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14436 /** SNOW 3G decrypt only (UEA2) */
14437 TEST_CASE_ST(ut_setup, ut_teardown,
14438 test_snow3g_decryption_test_case_1),
14439 TEST_CASE_ST(ut_setup, ut_teardown,
14440 test_snow3g_decryption_test_case_2),
14441 TEST_CASE_ST(ut_setup, ut_teardown,
14442 test_snow3g_decryption_test_case_3),
14443 TEST_CASE_ST(ut_setup, ut_teardown,
14444 test_snow3g_decryption_test_case_4),
14445 TEST_CASE_ST(ut_setup, ut_teardown,
14446 test_snow3g_decryption_test_case_5),
14447 TEST_CASE_ST(ut_setup, ut_teardown,
14448 test_snow3g_decryption_with_digest_test_case_1),
14449 TEST_CASE_ST(ut_setup, ut_teardown,
14450 test_snow3g_hash_generate_test_case_1),
14451 TEST_CASE_ST(ut_setup, ut_teardown,
14452 test_snow3g_hash_generate_test_case_2),
14453 TEST_CASE_ST(ut_setup, ut_teardown,
14454 test_snow3g_hash_generate_test_case_3),
14456 /* Tests with buffers which length is not byte-aligned */
14457 TEST_CASE_ST(ut_setup, ut_teardown,
14458 test_snow3g_hash_generate_test_case_4),
14459 TEST_CASE_ST(ut_setup, ut_teardown,
14460 test_snow3g_hash_generate_test_case_5),
14461 TEST_CASE_ST(ut_setup, ut_teardown,
14462 test_snow3g_hash_generate_test_case_6),
14463 TEST_CASE_ST(ut_setup, ut_teardown,
14464 test_snow3g_hash_verify_test_case_1),
14465 TEST_CASE_ST(ut_setup, ut_teardown,
14466 test_snow3g_hash_verify_test_case_2),
14467 TEST_CASE_ST(ut_setup, ut_teardown,
14468 test_snow3g_hash_verify_test_case_3),
14470 /* Tests with buffers which length is not byte-aligned */
14471 TEST_CASE_ST(ut_setup, ut_teardown,
14472 test_snow3g_hash_verify_test_case_4),
14473 TEST_CASE_ST(ut_setup, ut_teardown,
14474 test_snow3g_hash_verify_test_case_5),
14475 TEST_CASE_ST(ut_setup, ut_teardown,
14476 test_snow3g_hash_verify_test_case_6),
14477 TEST_CASE_ST(ut_setup, ut_teardown,
14478 test_snow3g_cipher_auth_test_case_1),
14479 TEST_CASE_ST(ut_setup, ut_teardown,
14480 test_snow3g_auth_cipher_with_digest_test_case_1),
14485 static struct unit_test_suite cryptodev_zuc_testsuite = {
14486 .suite_name = "ZUC Test Suite",
14487 .setup = zuc_testsuite_setup,
14488 .unit_test_cases = {
14489 /** ZUC encrypt only (EEA3) */
14490 TEST_CASE_ST(ut_setup, ut_teardown,
14491 test_zuc_encryption_test_case_1),
14492 TEST_CASE_ST(ut_setup, ut_teardown,
14493 test_zuc_encryption_test_case_2),
14494 TEST_CASE_ST(ut_setup, ut_teardown,
14495 test_zuc_encryption_test_case_3),
14496 TEST_CASE_ST(ut_setup, ut_teardown,
14497 test_zuc_encryption_test_case_4),
14498 TEST_CASE_ST(ut_setup, ut_teardown,
14499 test_zuc_encryption_test_case_5),
14500 TEST_CASE_ST(ut_setup, ut_teardown,
14501 test_zuc_encryption_test_case_6_sgl),
14503 /** ZUC authenticate (EIA3) */
14504 TEST_CASE_ST(ut_setup, ut_teardown,
14505 test_zuc_hash_generate_test_case_1),
14506 TEST_CASE_ST(ut_setup, ut_teardown,
14507 test_zuc_hash_generate_test_case_2),
14508 TEST_CASE_ST(ut_setup, ut_teardown,
14509 test_zuc_hash_generate_test_case_3),
14510 TEST_CASE_ST(ut_setup, ut_teardown,
14511 test_zuc_hash_generate_test_case_4),
14512 TEST_CASE_ST(ut_setup, ut_teardown,
14513 test_zuc_hash_generate_test_case_5),
14514 TEST_CASE_ST(ut_setup, ut_teardown,
14515 test_zuc_hash_generate_test_case_6),
14516 TEST_CASE_ST(ut_setup, ut_teardown,
14517 test_zuc_hash_generate_test_case_7),
14518 TEST_CASE_ST(ut_setup, ut_teardown,
14519 test_zuc_hash_generate_test_case_8),
14521 /** ZUC alg-chain (EEA3/EIA3) */
14522 TEST_CASE_ST(ut_setup, ut_teardown,
14523 test_zuc_cipher_auth_test_case_1),
14524 TEST_CASE_ST(ut_setup, ut_teardown,
14525 test_zuc_cipher_auth_test_case_2),
14527 /** ZUC generate auth, then encrypt (EEA3) */
14528 TEST_CASE_ST(ut_setup, ut_teardown,
14529 test_zuc_auth_cipher_test_case_1),
14530 TEST_CASE_ST(ut_setup, ut_teardown,
14531 test_zuc_auth_cipher_test_case_1_oop),
14532 TEST_CASE_ST(ut_setup, ut_teardown,
14533 test_zuc_auth_cipher_test_case_1_sgl),
14534 TEST_CASE_ST(ut_setup, ut_teardown,
14535 test_zuc_auth_cipher_test_case_1_oop_sgl),
14537 /** ZUC decrypt (EEA3), then verify auth */
14538 TEST_CASE_ST(ut_setup, ut_teardown,
14539 test_zuc_auth_cipher_verify_test_case_1),
14540 TEST_CASE_ST(ut_setup, ut_teardown,
14541 test_zuc_auth_cipher_verify_test_case_1_oop),
14542 TEST_CASE_ST(ut_setup, ut_teardown,
14543 test_zuc_auth_cipher_verify_test_case_1_sgl),
14544 TEST_CASE_ST(ut_setup, ut_teardown,
14545 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14550 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14551 .suite_name = "HMAC_MD5 Authentication Test Suite",
14552 .setup = hmac_md5_auth_testsuite_setup,
14553 .unit_test_cases = {
14554 TEST_CASE_ST(ut_setup, ut_teardown,
14555 test_MD5_HMAC_generate_case_1),
14556 TEST_CASE_ST(ut_setup, ut_teardown,
14557 test_MD5_HMAC_verify_case_1),
14558 TEST_CASE_ST(ut_setup, ut_teardown,
14559 test_MD5_HMAC_generate_case_2),
14560 TEST_CASE_ST(ut_setup, ut_teardown,
14561 test_MD5_HMAC_verify_case_2),
14566 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14567 .suite_name = "Kasumi Test Suite",
14568 .setup = kasumi_testsuite_setup,
14569 .unit_test_cases = {
14570 /** KASUMI hash only (UIA1) */
14571 TEST_CASE_ST(ut_setup, ut_teardown,
14572 test_kasumi_hash_generate_test_case_1),
14573 TEST_CASE_ST(ut_setup, ut_teardown,
14574 test_kasumi_hash_generate_test_case_2),
14575 TEST_CASE_ST(ut_setup, ut_teardown,
14576 test_kasumi_hash_generate_test_case_3),
14577 TEST_CASE_ST(ut_setup, ut_teardown,
14578 test_kasumi_hash_generate_test_case_4),
14579 TEST_CASE_ST(ut_setup, ut_teardown,
14580 test_kasumi_hash_generate_test_case_5),
14581 TEST_CASE_ST(ut_setup, ut_teardown,
14582 test_kasumi_hash_generate_test_case_6),
14584 TEST_CASE_ST(ut_setup, ut_teardown,
14585 test_kasumi_hash_verify_test_case_1),
14586 TEST_CASE_ST(ut_setup, ut_teardown,
14587 test_kasumi_hash_verify_test_case_2),
14588 TEST_CASE_ST(ut_setup, ut_teardown,
14589 test_kasumi_hash_verify_test_case_3),
14590 TEST_CASE_ST(ut_setup, ut_teardown,
14591 test_kasumi_hash_verify_test_case_4),
14592 TEST_CASE_ST(ut_setup, ut_teardown,
14593 test_kasumi_hash_verify_test_case_5),
14595 /** KASUMI encrypt only (UEA1) */
14596 TEST_CASE_ST(ut_setup, ut_teardown,
14597 test_kasumi_encryption_test_case_1),
14598 TEST_CASE_ST(ut_setup, ut_teardown,
14599 test_kasumi_encryption_test_case_1_sgl),
14600 TEST_CASE_ST(ut_setup, ut_teardown,
14601 test_kasumi_encryption_test_case_1_oop),
14602 TEST_CASE_ST(ut_setup, ut_teardown,
14603 test_kasumi_encryption_test_case_1_oop_sgl),
14604 TEST_CASE_ST(ut_setup, ut_teardown,
14605 test_kasumi_encryption_test_case_2),
14606 TEST_CASE_ST(ut_setup, ut_teardown,
14607 test_kasumi_encryption_test_case_3),
14608 TEST_CASE_ST(ut_setup, ut_teardown,
14609 test_kasumi_encryption_test_case_4),
14610 TEST_CASE_ST(ut_setup, ut_teardown,
14611 test_kasumi_encryption_test_case_5),
14613 /** KASUMI decrypt only (UEA1) */
14614 TEST_CASE_ST(ut_setup, ut_teardown,
14615 test_kasumi_decryption_test_case_1),
14616 TEST_CASE_ST(ut_setup, ut_teardown,
14617 test_kasumi_decryption_test_case_2),
14618 TEST_CASE_ST(ut_setup, ut_teardown,
14619 test_kasumi_decryption_test_case_3),
14620 TEST_CASE_ST(ut_setup, ut_teardown,
14621 test_kasumi_decryption_test_case_4),
14622 TEST_CASE_ST(ut_setup, ut_teardown,
14623 test_kasumi_decryption_test_case_5),
14624 TEST_CASE_ST(ut_setup, ut_teardown,
14625 test_kasumi_decryption_test_case_1_oop),
14626 TEST_CASE_ST(ut_setup, ut_teardown,
14627 test_kasumi_cipher_auth_test_case_1),
14629 /** KASUMI generate auth, then encrypt (F8) */
14630 TEST_CASE_ST(ut_setup, ut_teardown,
14631 test_kasumi_auth_cipher_test_case_1),
14632 TEST_CASE_ST(ut_setup, ut_teardown,
14633 test_kasumi_auth_cipher_test_case_2),
14634 TEST_CASE_ST(ut_setup, ut_teardown,
14635 test_kasumi_auth_cipher_test_case_2_oop),
14636 TEST_CASE_ST(ut_setup, ut_teardown,
14637 test_kasumi_auth_cipher_test_case_2_sgl),
14638 TEST_CASE_ST(ut_setup, ut_teardown,
14639 test_kasumi_auth_cipher_test_case_2_oop_sgl),
14641 /** KASUMI decrypt (F8), then verify auth */
14642 TEST_CASE_ST(ut_setup, ut_teardown,
14643 test_kasumi_auth_cipher_verify_test_case_1),
14644 TEST_CASE_ST(ut_setup, ut_teardown,
14645 test_kasumi_auth_cipher_verify_test_case_2),
14646 TEST_CASE_ST(ut_setup, ut_teardown,
14647 test_kasumi_auth_cipher_verify_test_case_2_oop),
14648 TEST_CASE_ST(ut_setup, ut_teardown,
14649 test_kasumi_auth_cipher_verify_test_case_2_sgl),
14650 TEST_CASE_ST(ut_setup, ut_teardown,
14651 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14657 static struct unit_test_suite cryptodev_esn_testsuite = {
14658 .suite_name = "ESN Test Suite",
14659 .setup = esn_testsuite_setup,
14660 .unit_test_cases = {
14661 TEST_CASE_ST(ut_setup, ut_teardown,
14662 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14663 TEST_CASE_ST(ut_setup, ut_teardown,
14664 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14669 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
14670 .suite_name = "Negative AES GCM Test Suite",
14671 .setup = negative_aes_gcm_testsuite_setup,
14672 .unit_test_cases = {
14673 TEST_CASE_ST(ut_setup, ut_teardown,
14674 test_AES_GCM_auth_encryption_fail_iv_corrupt),
14675 TEST_CASE_ST(ut_setup, ut_teardown,
14676 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14677 TEST_CASE_ST(ut_setup, ut_teardown,
14678 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14679 TEST_CASE_ST(ut_setup, ut_teardown,
14680 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14681 TEST_CASE_ST(ut_setup, ut_teardown,
14682 test_AES_GCM_auth_encryption_fail_aad_corrupt),
14683 TEST_CASE_ST(ut_setup, ut_teardown,
14684 test_AES_GCM_auth_encryption_fail_tag_corrupt),
14685 TEST_CASE_ST(ut_setup, ut_teardown,
14686 test_AES_GCM_auth_decryption_fail_iv_corrupt),
14687 TEST_CASE_ST(ut_setup, ut_teardown,
14688 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
14689 TEST_CASE_ST(ut_setup, ut_teardown,
14690 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
14691 TEST_CASE_ST(ut_setup, ut_teardown,
14692 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
14693 TEST_CASE_ST(ut_setup, ut_teardown,
14694 test_AES_GCM_auth_decryption_fail_aad_corrupt),
14695 TEST_CASE_ST(ut_setup, ut_teardown,
14696 test_AES_GCM_auth_decryption_fail_tag_corrupt),
14702 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
14703 .suite_name = "Negative AES GMAC Test Suite",
14704 .setup = negative_aes_gmac_testsuite_setup,
14705 .unit_test_cases = {
14706 TEST_CASE_ST(ut_setup, ut_teardown,
14707 authentication_verify_AES128_GMAC_fail_data_corrupt),
14708 TEST_CASE_ST(ut_setup, ut_teardown,
14709 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14715 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
14716 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
14717 .setup = mixed_cipher_hash_testsuite_setup,
14718 .unit_test_cases = {
14719 /** AUTH AES CMAC + CIPHER AES CTR */
14720 TEST_CASE_ST(ut_setup, ut_teardown,
14721 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
14722 TEST_CASE_ST(ut_setup, ut_teardown,
14723 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14724 TEST_CASE_ST(ut_setup, ut_teardown,
14725 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14726 TEST_CASE_ST(ut_setup, ut_teardown,
14727 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14728 TEST_CASE_ST(ut_setup, ut_teardown,
14729 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
14730 TEST_CASE_ST(ut_setup, ut_teardown,
14731 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14732 TEST_CASE_ST(ut_setup, ut_teardown,
14733 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14734 TEST_CASE_ST(ut_setup, ut_teardown,
14735 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14737 /** AUTH ZUC + CIPHER SNOW3G */
14738 TEST_CASE_ST(ut_setup, ut_teardown,
14739 test_auth_zuc_cipher_snow_test_case_1),
14740 TEST_CASE_ST(ut_setup, ut_teardown,
14741 test_verify_auth_zuc_cipher_snow_test_case_1),
14742 /** AUTH AES CMAC + CIPHER SNOW3G */
14743 TEST_CASE_ST(ut_setup, ut_teardown,
14744 test_auth_aes_cmac_cipher_snow_test_case_1),
14745 TEST_CASE_ST(ut_setup, ut_teardown,
14746 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
14747 /** AUTH ZUC + CIPHER AES CTR */
14748 TEST_CASE_ST(ut_setup, ut_teardown,
14749 test_auth_zuc_cipher_aes_ctr_test_case_1),
14750 TEST_CASE_ST(ut_setup, ut_teardown,
14751 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
14752 /** AUTH SNOW3G + CIPHER AES CTR */
14753 TEST_CASE_ST(ut_setup, ut_teardown,
14754 test_auth_snow_cipher_aes_ctr_test_case_1),
14755 TEST_CASE_ST(ut_setup, ut_teardown,
14756 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
14757 /** AUTH SNOW3G + CIPHER ZUC */
14758 TEST_CASE_ST(ut_setup, ut_teardown,
14759 test_auth_snow_cipher_zuc_test_case_1),
14760 TEST_CASE_ST(ut_setup, ut_teardown,
14761 test_verify_auth_snow_cipher_zuc_test_case_1),
14762 /** AUTH AES CMAC + CIPHER ZUC */
14763 TEST_CASE_ST(ut_setup, ut_teardown,
14764 test_auth_aes_cmac_cipher_zuc_test_case_1),
14765 TEST_CASE_ST(ut_setup, ut_teardown,
14766 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
14768 /** AUTH NULL + CIPHER SNOW3G */
14769 TEST_CASE_ST(ut_setup, ut_teardown,
14770 test_auth_null_cipher_snow_test_case_1),
14771 TEST_CASE_ST(ut_setup, ut_teardown,
14772 test_verify_auth_null_cipher_snow_test_case_1),
14773 /** AUTH NULL + CIPHER ZUC */
14774 TEST_CASE_ST(ut_setup, ut_teardown,
14775 test_auth_null_cipher_zuc_test_case_1),
14776 TEST_CASE_ST(ut_setup, ut_teardown,
14777 test_verify_auth_null_cipher_zuc_test_case_1),
14778 /** AUTH SNOW3G + CIPHER NULL */
14779 TEST_CASE_ST(ut_setup, ut_teardown,
14780 test_auth_snow_cipher_null_test_case_1),
14781 TEST_CASE_ST(ut_setup, ut_teardown,
14782 test_verify_auth_snow_cipher_null_test_case_1),
14783 /** AUTH ZUC + CIPHER NULL */
14784 TEST_CASE_ST(ut_setup, ut_teardown,
14785 test_auth_zuc_cipher_null_test_case_1),
14786 TEST_CASE_ST(ut_setup, ut_teardown,
14787 test_verify_auth_zuc_cipher_null_test_case_1),
14788 /** AUTH NULL + CIPHER AES CTR */
14789 TEST_CASE_ST(ut_setup, ut_teardown,
14790 test_auth_null_cipher_aes_ctr_test_case_1),
14791 TEST_CASE_ST(ut_setup, ut_teardown,
14792 test_verify_auth_null_cipher_aes_ctr_test_case_1),
14793 /** AUTH AES CMAC + CIPHER NULL */
14794 TEST_CASE_ST(ut_setup, ut_teardown,
14795 test_auth_aes_cmac_cipher_null_test_case_1),
14796 TEST_CASE_ST(ut_setup, ut_teardown,
14797 test_verify_auth_aes_cmac_cipher_null_test_case_1),
14803 run_cryptodev_testsuite(const char *pmd_name)
14805 uint8_t ret, j, i = 0, blk_start_idx = 0;
14806 const enum blockcipher_test_type blk_suites[] = {
14807 BLKCIPHER_AES_CHAIN_TYPE,
14808 BLKCIPHER_AES_CIPHERONLY_TYPE,
14809 BLKCIPHER_AES_DOCSIS_TYPE,
14810 BLKCIPHER_3DES_CHAIN_TYPE,
14811 BLKCIPHER_3DES_CIPHERONLY_TYPE,
14812 BLKCIPHER_DES_CIPHERONLY_TYPE,
14813 BLKCIPHER_DES_DOCSIS_TYPE,
14814 BLKCIPHER_AUTHONLY_TYPE};
14815 struct unit_test_suite *static_suites[] = {
14816 &cryptodev_multi_session_testsuite,
14817 &cryptodev_null_testsuite,
14818 &cryptodev_aes_ccm_auth_testsuite,
14819 &cryptodev_aes_gcm_auth_testsuite,
14820 &cryptodev_aes_gmac_auth_testsuite,
14821 &cryptodev_snow3g_testsuite,
14822 &cryptodev_chacha20_poly1305_testsuite,
14823 &cryptodev_zuc_testsuite,
14824 &cryptodev_hmac_md5_auth_testsuite,
14825 &cryptodev_kasumi_testsuite,
14826 &cryptodev_esn_testsuite,
14827 &cryptodev_negative_aes_gcm_testsuite,
14828 &cryptodev_negative_aes_gmac_testsuite,
14829 &cryptodev_mixed_cipher_hash_testsuite,
14830 &cryptodev_negative_hmac_sha1_testsuite,
14831 &cryptodev_gen_testsuite,
14832 #ifdef RTE_LIB_SECURITY
14833 &ipsec_proto_testsuite,
14834 &pdcp_proto_testsuite,
14835 &docsis_proto_testsuite,
14839 static struct unit_test_suite ts = {
14840 .suite_name = "Cryptodev Unit Test Suite",
14841 .setup = testsuite_setup,
14842 .teardown = testsuite_teardown,
14843 .unit_test_cases = {TEST_CASES_END()}
14846 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
14848 if (gbl_driver_id == -1) {
14849 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
14850 return TEST_SKIPPED;
14853 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14854 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
14856 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
14857 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14858 ret = unit_test_suite_runner(&ts);
14860 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
14861 free(ts.unit_test_suites);
14866 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
14868 struct rte_cryptodev_info dev_info;
14869 uint8_t i, nb_devs;
14872 driver_id = rte_cryptodev_driver_id_get(pmd_name);
14873 if (driver_id == -1) {
14874 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
14875 return TEST_SKIPPED;
14878 nb_devs = rte_cryptodev_count();
14880 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
14881 return TEST_SKIPPED;
14884 for (i = 0; i < nb_devs; i++) {
14885 rte_cryptodev_info_get(i, &dev_info);
14886 if (dev_info.driver_id == driver_id) {
14887 if (!(dev_info.feature_flags & flag)) {
14888 RTE_LOG(INFO, USER1, "%s not supported\n",
14890 return TEST_SKIPPED;
14892 return 0; /* found */
14896 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
14897 return TEST_SKIPPED;
14901 test_cryptodev_qat(void)
14903 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14907 test_cryptodev_virtio(void)
14909 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14913 test_cryptodev_aesni_mb(void)
14915 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14919 test_cryptodev_cpu_aesni_mb(void)
14922 enum rte_security_session_action_type at = gbl_action_type;
14923 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14924 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14925 gbl_action_type = at;
14930 test_cryptodev_openssl(void)
14932 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14936 test_cryptodev_aesni_gcm(void)
14938 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14942 test_cryptodev_cpu_aesni_gcm(void)
14945 enum rte_security_session_action_type at = gbl_action_type;
14946 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14947 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14948 gbl_action_type = at;
14953 test_cryptodev_mlx5(void)
14955 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
14959 test_cryptodev_null(void)
14961 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14965 test_cryptodev_sw_snow3g(void)
14967 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14971 test_cryptodev_sw_kasumi(void)
14973 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14977 test_cryptodev_sw_zuc(void)
14979 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14983 test_cryptodev_armv8(void)
14985 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14989 test_cryptodev_mrvl(void)
14991 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14994 #ifdef RTE_CRYPTO_SCHEDULER
14997 test_cryptodev_scheduler(void)
14999 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
15000 const enum blockcipher_test_type blk_suites[] = {
15001 BLKCIPHER_AES_CHAIN_TYPE,
15002 BLKCIPHER_AES_CIPHERONLY_TYPE,
15003 BLKCIPHER_AUTHONLY_TYPE
15005 static struct unit_test_suite scheduler_multicore = {
15006 .suite_name = "Scheduler Multicore Unit Test Suite",
15007 .setup = scheduler_multicore_testsuite_setup,
15008 .teardown = scheduler_mode_testsuite_teardown,
15009 .unit_test_cases = {TEST_CASES_END()}
15011 static struct unit_test_suite scheduler_round_robin = {
15012 .suite_name = "Scheduler Round Robin Unit Test Suite",
15013 .setup = scheduler_roundrobin_testsuite_setup,
15014 .teardown = scheduler_mode_testsuite_teardown,
15015 .unit_test_cases = {TEST_CASES_END()}
15017 static struct unit_test_suite scheduler_failover = {
15018 .suite_name = "Scheduler Failover Unit Test Suite",
15019 .setup = scheduler_failover_testsuite_setup,
15020 .teardown = scheduler_mode_testsuite_teardown,
15021 .unit_test_cases = {TEST_CASES_END()}
15023 static struct unit_test_suite scheduler_pkt_size_distr = {
15024 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
15025 .setup = scheduler_pkt_size_distr_testsuite_setup,
15026 .teardown = scheduler_mode_testsuite_teardown,
15027 .unit_test_cases = {TEST_CASES_END()}
15029 struct unit_test_suite *sched_mode_suites[] = {
15030 &scheduler_multicore,
15031 &scheduler_round_robin,
15032 &scheduler_failover,
15033 &scheduler_pkt_size_distr
15035 static struct unit_test_suite scheduler_config = {
15036 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
15037 .unit_test_cases = {
15038 TEST_CASE(test_scheduler_attach_worker_op),
15039 TEST_CASE(test_scheduler_mode_multicore_op),
15040 TEST_CASE(test_scheduler_mode_roundrobin_op),
15041 TEST_CASE(test_scheduler_mode_failover_op),
15042 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
15043 TEST_CASE(test_scheduler_detach_worker_op),
15045 TEST_CASES_END() /**< NULL terminate array */
15048 struct unit_test_suite *static_suites[] = {
15052 static struct unit_test_suite ts = {
15053 .suite_name = "Scheduler Unit Test Suite",
15054 .setup = scheduler_testsuite_setup,
15055 .teardown = testsuite_teardown,
15056 .unit_test_cases = {TEST_CASES_END()}
15059 gbl_driver_id = rte_cryptodev_driver_id_get(
15060 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15062 if (gbl_driver_id == -1) {
15063 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
15064 return TEST_SKIPPED;
15067 if (rte_cryptodev_driver_id_get(
15068 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
15069 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
15070 return TEST_SKIPPED;
15073 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15075 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
15076 (struct unit_test_suite *) *
15077 (RTE_DIM(blk_suites) + 1));
15078 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
15079 blk_suites, RTE_DIM(blk_suites));
15080 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
15083 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15084 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
15085 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
15086 RTE_DIM(sched_mode_suites));
15087 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15088 ret = unit_test_suite_runner(&ts);
15090 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15091 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
15092 (*sched_mode_suites[sched_i]),
15093 RTE_DIM(blk_suites));
15094 free(sched_mode_suites[sched_i]->unit_test_suites);
15096 free(ts.unit_test_suites);
15100 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
15105 test_cryptodev_dpaa2_sec(void)
15107 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
15111 test_cryptodev_dpaa_sec(void)
15113 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
15117 test_cryptodev_ccp(void)
15119 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
15123 test_cryptodev_octeontx(void)
15125 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
15129 test_cryptodev_octeontx2(void)
15131 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
15135 test_cryptodev_caam_jr(void)
15137 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
15141 test_cryptodev_nitrox(void)
15143 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
15147 test_cryptodev_bcmfs(void)
15149 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
15153 test_cryptodev_qat_raw_api(void)
15155 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
15158 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15163 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15164 ret = run_cryptodev_testsuite(pmd_name);
15165 global_api_test_type = CRYPTODEV_API_TEST;
15171 test_cryptodev_cn9k(void)
15173 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
15177 test_cryptodev_cn10k(void)
15179 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
15182 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
15183 test_cryptodev_qat_raw_api);
15184 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
15185 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
15186 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
15187 test_cryptodev_cpu_aesni_mb);
15188 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
15189 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
15190 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
15191 test_cryptodev_cpu_aesni_gcm);
15192 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
15193 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
15194 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
15195 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
15196 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
15197 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
15198 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
15199 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
15200 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
15201 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
15202 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
15203 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
15204 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
15205 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
15206 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
15207 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
15208 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
15209 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);