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 if (status == -ENOTSUP)
2407 return TEST_SKIPPED;
2409 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2410 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2415 create_wireless_algo_cipher_session(uint8_t dev_id,
2416 enum rte_crypto_cipher_operation op,
2417 enum rte_crypto_cipher_algorithm algo,
2418 const uint8_t *key, const uint8_t key_len,
2421 uint8_t cipher_key[key_len];
2423 struct crypto_testsuite_params *ts_params = &testsuite_params;
2424 struct crypto_unittest_params *ut_params = &unittest_params;
2426 memcpy(cipher_key, key, key_len);
2428 /* Setup Cipher Parameters */
2429 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2430 ut_params->cipher_xform.next = NULL;
2432 ut_params->cipher_xform.cipher.algo = algo;
2433 ut_params->cipher_xform.cipher.op = op;
2434 ut_params->cipher_xform.cipher.key.data = cipher_key;
2435 ut_params->cipher_xform.cipher.key.length = key_len;
2436 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2437 ut_params->cipher_xform.cipher.iv.length = iv_len;
2439 debug_hexdump(stdout, "key:", key, key_len);
2441 /* Create Crypto session */
2442 ut_params->sess = rte_cryptodev_sym_session_create(
2443 ts_params->session_mpool);
2445 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2446 &ut_params->cipher_xform,
2447 ts_params->session_priv_mpool);
2448 if (status == -ENOTSUP)
2449 return TEST_SKIPPED;
2451 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2452 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2457 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2458 unsigned int cipher_len,
2459 unsigned int cipher_offset)
2461 struct crypto_testsuite_params *ts_params = &testsuite_params;
2462 struct crypto_unittest_params *ut_params = &unittest_params;
2464 /* Generate Crypto op data structure */
2465 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2466 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2467 TEST_ASSERT_NOT_NULL(ut_params->op,
2468 "Failed to allocate pktmbuf offload");
2470 /* Set crypto operation data parameters */
2471 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2473 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2475 /* set crypto operation source mbuf */
2476 sym_op->m_src = ut_params->ibuf;
2479 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2481 sym_op->cipher.data.length = cipher_len;
2482 sym_op->cipher.data.offset = cipher_offset;
2487 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2488 unsigned int cipher_len,
2489 unsigned int cipher_offset)
2491 struct crypto_testsuite_params *ts_params = &testsuite_params;
2492 struct crypto_unittest_params *ut_params = &unittest_params;
2494 /* Generate Crypto op data structure */
2495 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2496 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2497 TEST_ASSERT_NOT_NULL(ut_params->op,
2498 "Failed to allocate pktmbuf offload");
2500 /* Set crypto operation data parameters */
2501 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2503 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2505 /* set crypto operation source mbuf */
2506 sym_op->m_src = ut_params->ibuf;
2507 sym_op->m_dst = ut_params->obuf;
2510 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2512 sym_op->cipher.data.length = cipher_len;
2513 sym_op->cipher.data.offset = cipher_offset;
2518 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2519 enum rte_crypto_cipher_operation cipher_op,
2520 enum rte_crypto_auth_operation auth_op,
2521 enum rte_crypto_auth_algorithm auth_algo,
2522 enum rte_crypto_cipher_algorithm cipher_algo,
2523 const uint8_t *key, uint8_t key_len,
2524 uint8_t auth_iv_len, uint8_t auth_len,
2525 uint8_t cipher_iv_len)
2528 uint8_t cipher_auth_key[key_len];
2531 struct crypto_testsuite_params *ts_params = &testsuite_params;
2532 struct crypto_unittest_params *ut_params = &unittest_params;
2534 memcpy(cipher_auth_key, key, key_len);
2536 /* Setup Authentication Parameters */
2537 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2538 ut_params->auth_xform.next = NULL;
2540 ut_params->auth_xform.auth.op = auth_op;
2541 ut_params->auth_xform.auth.algo = auth_algo;
2542 ut_params->auth_xform.auth.key.length = key_len;
2543 /* Hash key = cipher key */
2544 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2545 ut_params->auth_xform.auth.digest_length = auth_len;
2546 /* Auth IV will be after cipher IV */
2547 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2548 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2550 /* Setup Cipher Parameters */
2551 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2552 ut_params->cipher_xform.next = &ut_params->auth_xform;
2554 ut_params->cipher_xform.cipher.algo = cipher_algo;
2555 ut_params->cipher_xform.cipher.op = cipher_op;
2556 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2557 ut_params->cipher_xform.cipher.key.length = key_len;
2558 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2559 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2561 debug_hexdump(stdout, "key:", key, key_len);
2563 /* Create Crypto session*/
2564 ut_params->sess = rte_cryptodev_sym_session_create(
2565 ts_params->session_mpool);
2566 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2568 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2569 &ut_params->cipher_xform,
2570 ts_params->session_priv_mpool);
2571 if (status == -ENOTSUP)
2572 return TEST_SKIPPED;
2574 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2579 create_wireless_cipher_auth_session(uint8_t dev_id,
2580 enum rte_crypto_cipher_operation cipher_op,
2581 enum rte_crypto_auth_operation auth_op,
2582 enum rte_crypto_auth_algorithm auth_algo,
2583 enum rte_crypto_cipher_algorithm cipher_algo,
2584 const struct wireless_test_data *tdata)
2586 const uint8_t key_len = tdata->key.len;
2587 uint8_t cipher_auth_key[key_len];
2590 struct crypto_testsuite_params *ts_params = &testsuite_params;
2591 struct crypto_unittest_params *ut_params = &unittest_params;
2592 const uint8_t *key = tdata->key.data;
2593 const uint8_t auth_len = tdata->digest.len;
2594 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2595 uint8_t auth_iv_len = tdata->auth_iv.len;
2597 memcpy(cipher_auth_key, key, key_len);
2599 /* Setup Authentication Parameters */
2600 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2601 ut_params->auth_xform.next = NULL;
2603 ut_params->auth_xform.auth.op = auth_op;
2604 ut_params->auth_xform.auth.algo = auth_algo;
2605 ut_params->auth_xform.auth.key.length = key_len;
2606 /* Hash key = cipher key */
2607 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2608 ut_params->auth_xform.auth.digest_length = auth_len;
2609 /* Auth IV will be after cipher IV */
2610 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2611 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2613 /* Setup Cipher Parameters */
2614 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2615 ut_params->cipher_xform.next = &ut_params->auth_xform;
2617 ut_params->cipher_xform.cipher.algo = cipher_algo;
2618 ut_params->cipher_xform.cipher.op = cipher_op;
2619 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2620 ut_params->cipher_xform.cipher.key.length = key_len;
2621 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2622 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2625 debug_hexdump(stdout, "key:", key, key_len);
2627 /* Create Crypto session*/
2628 ut_params->sess = rte_cryptodev_sym_session_create(
2629 ts_params->session_mpool);
2631 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2632 &ut_params->cipher_xform,
2633 ts_params->session_priv_mpool);
2634 if (status == -ENOTSUP)
2635 return TEST_SKIPPED;
2637 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2638 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2643 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2644 const struct wireless_test_data *tdata)
2646 return create_wireless_cipher_auth_session(dev_id,
2647 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2648 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2649 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2653 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2654 enum rte_crypto_cipher_operation cipher_op,
2655 enum rte_crypto_auth_operation auth_op,
2656 enum rte_crypto_auth_algorithm auth_algo,
2657 enum rte_crypto_cipher_algorithm cipher_algo,
2658 const uint8_t *key, const uint8_t key_len,
2659 uint8_t auth_iv_len, uint8_t auth_len,
2660 uint8_t cipher_iv_len)
2662 uint8_t auth_cipher_key[key_len];
2664 struct crypto_testsuite_params *ts_params = &testsuite_params;
2665 struct crypto_unittest_params *ut_params = &unittest_params;
2667 memcpy(auth_cipher_key, key, key_len);
2669 /* Setup Authentication Parameters */
2670 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2671 ut_params->auth_xform.auth.op = auth_op;
2672 ut_params->auth_xform.next = &ut_params->cipher_xform;
2673 ut_params->auth_xform.auth.algo = auth_algo;
2674 ut_params->auth_xform.auth.key.length = key_len;
2675 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2676 ut_params->auth_xform.auth.digest_length = auth_len;
2677 /* Auth IV will be after cipher IV */
2678 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2679 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2681 /* Setup Cipher Parameters */
2682 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2683 ut_params->cipher_xform.next = NULL;
2684 ut_params->cipher_xform.cipher.algo = cipher_algo;
2685 ut_params->cipher_xform.cipher.op = cipher_op;
2686 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2687 ut_params->cipher_xform.cipher.key.length = key_len;
2688 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2689 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2691 debug_hexdump(stdout, "key:", key, key_len);
2693 /* Create Crypto session*/
2694 ut_params->sess = rte_cryptodev_sym_session_create(
2695 ts_params->session_mpool);
2696 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2698 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2699 ut_params->auth_xform.next = NULL;
2700 ut_params->cipher_xform.next = &ut_params->auth_xform;
2701 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2702 &ut_params->cipher_xform,
2703 ts_params->session_priv_mpool);
2706 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2707 &ut_params->auth_xform,
2708 ts_params->session_priv_mpool);
2710 if (status == -ENOTSUP)
2711 return TEST_SKIPPED;
2713 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2719 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2720 unsigned int auth_tag_len,
2721 const uint8_t *iv, unsigned int iv_len,
2722 unsigned int data_pad_len,
2723 enum rte_crypto_auth_operation op,
2724 unsigned int auth_len, unsigned int auth_offset)
2726 struct crypto_testsuite_params *ts_params = &testsuite_params;
2728 struct crypto_unittest_params *ut_params = &unittest_params;
2730 /* Generate Crypto op data structure */
2731 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2732 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2733 TEST_ASSERT_NOT_NULL(ut_params->op,
2734 "Failed to allocate pktmbuf offload");
2736 /* Set crypto operation data parameters */
2737 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2739 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2741 /* set crypto operation source mbuf */
2742 sym_op->m_src = ut_params->ibuf;
2745 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2748 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2749 ut_params->ibuf, auth_tag_len);
2751 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2752 "no room to append auth tag");
2753 ut_params->digest = sym_op->auth.digest.data;
2754 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2755 ut_params->ibuf, data_pad_len);
2756 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2757 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2759 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2761 debug_hexdump(stdout, "digest:",
2762 sym_op->auth.digest.data,
2765 sym_op->auth.data.length = auth_len;
2766 sym_op->auth.data.offset = auth_offset;
2772 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2773 enum rte_crypto_auth_operation op)
2775 struct crypto_testsuite_params *ts_params = &testsuite_params;
2776 struct crypto_unittest_params *ut_params = &unittest_params;
2778 const uint8_t *auth_tag = tdata->digest.data;
2779 const unsigned int auth_tag_len = tdata->digest.len;
2780 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2781 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2783 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2784 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2785 const uint8_t *auth_iv = tdata->auth_iv.data;
2786 const uint8_t auth_iv_len = tdata->auth_iv.len;
2787 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2788 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2790 /* Generate Crypto op data structure */
2791 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2792 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2793 TEST_ASSERT_NOT_NULL(ut_params->op,
2794 "Failed to allocate pktmbuf offload");
2795 /* Set crypto operation data parameters */
2796 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2798 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2800 /* set crypto operation source mbuf */
2801 sym_op->m_src = ut_params->ibuf;
2804 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2805 ut_params->ibuf, auth_tag_len);
2807 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2808 "no room to append auth tag");
2809 ut_params->digest = sym_op->auth.digest.data;
2810 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2811 ut_params->ibuf, data_pad_len);
2812 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2813 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2815 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2817 debug_hexdump(stdout, "digest:",
2818 sym_op->auth.digest.data,
2821 /* Copy cipher and auth IVs at the end of the crypto operation */
2822 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2824 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2825 iv_ptr += cipher_iv_len;
2826 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2828 sym_op->cipher.data.length = cipher_len;
2829 sym_op->cipher.data.offset = 0;
2830 sym_op->auth.data.length = auth_len;
2831 sym_op->auth.data.offset = 0;
2837 create_zuc_cipher_hash_generate_operation(
2838 const struct wireless_test_data *tdata)
2840 return create_wireless_cipher_hash_operation(tdata,
2841 RTE_CRYPTO_AUTH_OP_GENERATE);
2845 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2846 const unsigned auth_tag_len,
2847 const uint8_t *auth_iv, uint8_t auth_iv_len,
2848 unsigned data_pad_len,
2849 enum rte_crypto_auth_operation op,
2850 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2851 const unsigned cipher_len, const unsigned cipher_offset,
2852 const unsigned auth_len, const unsigned auth_offset)
2854 struct crypto_testsuite_params *ts_params = &testsuite_params;
2855 struct crypto_unittest_params *ut_params = &unittest_params;
2857 enum rte_crypto_cipher_algorithm cipher_algo =
2858 ut_params->cipher_xform.cipher.algo;
2859 enum rte_crypto_auth_algorithm auth_algo =
2860 ut_params->auth_xform.auth.algo;
2862 /* Generate Crypto op data structure */
2863 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2864 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2865 TEST_ASSERT_NOT_NULL(ut_params->op,
2866 "Failed to allocate pktmbuf offload");
2867 /* Set crypto operation data parameters */
2868 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2870 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2872 /* set crypto operation source mbuf */
2873 sym_op->m_src = ut_params->ibuf;
2876 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2877 ut_params->ibuf, auth_tag_len);
2879 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2880 "no room to append auth tag");
2881 ut_params->digest = sym_op->auth.digest.data;
2883 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2884 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2885 ut_params->ibuf, data_pad_len);
2887 struct rte_mbuf *m = ut_params->ibuf;
2888 unsigned int offset = data_pad_len;
2890 while (offset > m->data_len && m->next != NULL) {
2891 offset -= m->data_len;
2894 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2898 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2899 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2901 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2903 debug_hexdump(stdout, "digest:",
2904 sym_op->auth.digest.data,
2907 /* Copy cipher and auth IVs at the end of the crypto operation */
2908 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2910 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2911 iv_ptr += cipher_iv_len;
2912 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2914 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2915 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2916 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2917 sym_op->cipher.data.length = cipher_len;
2918 sym_op->cipher.data.offset = cipher_offset;
2920 sym_op->cipher.data.length = cipher_len >> 3;
2921 sym_op->cipher.data.offset = cipher_offset >> 3;
2924 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2925 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2926 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2927 sym_op->auth.data.length = auth_len;
2928 sym_op->auth.data.offset = auth_offset;
2930 sym_op->auth.data.length = auth_len >> 3;
2931 sym_op->auth.data.offset = auth_offset >> 3;
2938 create_wireless_algo_auth_cipher_operation(
2939 const uint8_t *auth_tag, unsigned int auth_tag_len,
2940 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2941 const uint8_t *auth_iv, uint8_t auth_iv_len,
2942 unsigned int data_pad_len,
2943 unsigned int cipher_len, unsigned int cipher_offset,
2944 unsigned int auth_len, unsigned int auth_offset,
2945 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2947 struct crypto_testsuite_params *ts_params = &testsuite_params;
2948 struct crypto_unittest_params *ut_params = &unittest_params;
2950 enum rte_crypto_cipher_algorithm cipher_algo =
2951 ut_params->cipher_xform.cipher.algo;
2952 enum rte_crypto_auth_algorithm auth_algo =
2953 ut_params->auth_xform.auth.algo;
2955 /* Generate Crypto op data structure */
2956 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2957 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2958 TEST_ASSERT_NOT_NULL(ut_params->op,
2959 "Failed to allocate pktmbuf offload");
2961 /* Set crypto operation data parameters */
2962 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2964 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2966 /* set crypto operation mbufs */
2967 sym_op->m_src = ut_params->ibuf;
2968 if (op_mode == OUT_OF_PLACE)
2969 sym_op->m_dst = ut_params->obuf;
2973 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2974 (op_mode == IN_PLACE ?
2975 ut_params->ibuf : ut_params->obuf),
2976 uint8_t *, data_pad_len);
2977 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2978 (op_mode == IN_PLACE ?
2979 ut_params->ibuf : ut_params->obuf),
2981 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2983 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2984 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2985 sym_op->m_src : sym_op->m_dst);
2986 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2987 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2988 sgl_buf = sgl_buf->next;
2990 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2991 uint8_t *, remaining_off);
2992 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2994 memset(sym_op->auth.digest.data, 0, remaining_off);
2995 while (sgl_buf->next != NULL) {
2996 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2997 0, rte_pktmbuf_data_len(sgl_buf));
2998 sgl_buf = sgl_buf->next;
3002 /* Copy digest for the verification */
3004 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3006 /* Copy cipher and auth IVs at the end of the crypto operation */
3007 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3008 ut_params->op, uint8_t *, IV_OFFSET);
3010 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3011 iv_ptr += cipher_iv_len;
3012 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3014 /* Only copy over the offset data needed from src to dst in OOP,
3015 * if the auth and cipher offsets are not aligned
3017 if (op_mode == OUT_OF_PLACE) {
3018 if (cipher_offset > auth_offset)
3020 rte_pktmbuf_mtod_offset(
3022 uint8_t *, auth_offset >> 3),
3023 rte_pktmbuf_mtod_offset(
3025 uint8_t *, auth_offset >> 3),
3026 ((cipher_offset >> 3) - (auth_offset >> 3)));
3029 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3030 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3031 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3032 sym_op->cipher.data.length = cipher_len;
3033 sym_op->cipher.data.offset = cipher_offset;
3035 sym_op->cipher.data.length = cipher_len >> 3;
3036 sym_op->cipher.data.offset = cipher_offset >> 3;
3039 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3040 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3041 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3042 sym_op->auth.data.length = auth_len;
3043 sym_op->auth.data.offset = auth_offset;
3045 sym_op->auth.data.length = auth_len >> 3;
3046 sym_op->auth.data.offset = auth_offset >> 3;
3053 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3055 struct crypto_testsuite_params *ts_params = &testsuite_params;
3056 struct crypto_unittest_params *ut_params = &unittest_params;
3059 unsigned plaintext_pad_len;
3060 unsigned plaintext_len;
3062 struct rte_cryptodev_info dev_info;
3064 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3065 uint64_t feat_flags = dev_info.feature_flags;
3067 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3068 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3069 printf("Device doesn't support NON-Byte Aligned Data.\n");
3070 return TEST_SKIPPED;
3073 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3074 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3075 printf("Device doesn't support RAW data-path APIs.\n");
3076 return TEST_SKIPPED;
3079 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3080 return TEST_SKIPPED;
3082 /* Verify the capabilities */
3083 struct rte_cryptodev_sym_capability_idx cap_idx;
3084 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3085 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3086 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3088 return TEST_SKIPPED;
3090 /* Create SNOW 3G session */
3091 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3092 tdata->key.data, tdata->key.len,
3093 tdata->auth_iv.len, tdata->digest.len,
3094 RTE_CRYPTO_AUTH_OP_GENERATE,
3095 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3099 /* alloc mbuf and set payload */
3100 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3102 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3103 rte_pktmbuf_tailroom(ut_params->ibuf));
3105 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3106 /* Append data which is padded to a multiple of */
3107 /* the algorithms block size */
3108 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3109 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3111 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3113 /* Create SNOW 3G operation */
3114 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3115 tdata->auth_iv.data, tdata->auth_iv.len,
3116 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3117 tdata->validAuthLenInBits.len,
3122 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3123 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3124 ut_params->op, 0, 1, 1, 0);
3126 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3128 ut_params->obuf = ut_params->op->sym->m_src;
3129 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3130 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3131 + plaintext_pad_len;
3134 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3137 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3138 "SNOW 3G Generated auth tag not as expected");
3144 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3146 struct crypto_testsuite_params *ts_params = &testsuite_params;
3147 struct crypto_unittest_params *ut_params = &unittest_params;
3150 unsigned plaintext_pad_len;
3151 unsigned plaintext_len;
3153 struct rte_cryptodev_info dev_info;
3155 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3156 uint64_t feat_flags = dev_info.feature_flags;
3158 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3159 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3160 printf("Device doesn't support NON-Byte Aligned Data.\n");
3161 return TEST_SKIPPED;
3164 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3165 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3166 printf("Device doesn't support RAW data-path APIs.\n");
3167 return TEST_SKIPPED;
3170 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3171 return TEST_SKIPPED;
3173 /* Verify the capabilities */
3174 struct rte_cryptodev_sym_capability_idx cap_idx;
3175 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3176 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3177 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3179 return TEST_SKIPPED;
3181 /* Create SNOW 3G session */
3182 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3183 tdata->key.data, tdata->key.len,
3184 tdata->auth_iv.len, tdata->digest.len,
3185 RTE_CRYPTO_AUTH_OP_VERIFY,
3186 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3189 /* alloc mbuf and set payload */
3190 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3192 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3193 rte_pktmbuf_tailroom(ut_params->ibuf));
3195 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3196 /* Append data which is padded to a multiple of */
3197 /* the algorithms block size */
3198 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3199 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3201 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3203 /* Create SNOW 3G operation */
3204 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3206 tdata->auth_iv.data, tdata->auth_iv.len,
3208 RTE_CRYPTO_AUTH_OP_VERIFY,
3209 tdata->validAuthLenInBits.len,
3214 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3215 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3216 ut_params->op, 0, 1, 1, 0);
3218 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3220 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3221 ut_params->obuf = ut_params->op->sym->m_src;
3222 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3223 + plaintext_pad_len;
3226 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3235 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3237 struct crypto_testsuite_params *ts_params = &testsuite_params;
3238 struct crypto_unittest_params *ut_params = &unittest_params;
3241 unsigned plaintext_pad_len;
3242 unsigned plaintext_len;
3244 struct rte_cryptodev_info dev_info;
3246 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3247 uint64_t feat_flags = dev_info.feature_flags;
3249 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3250 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3251 printf("Device doesn't support RAW data-path APIs.\n");
3252 return TEST_SKIPPED;
3255 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3256 return TEST_SKIPPED;
3258 /* Verify the capabilities */
3259 struct rte_cryptodev_sym_capability_idx cap_idx;
3260 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3261 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3262 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3264 return TEST_SKIPPED;
3266 /* Create KASUMI session */
3267 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3268 tdata->key.data, tdata->key.len,
3269 0, tdata->digest.len,
3270 RTE_CRYPTO_AUTH_OP_GENERATE,
3271 RTE_CRYPTO_AUTH_KASUMI_F9);
3275 /* alloc mbuf and set payload */
3276 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3278 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3279 rte_pktmbuf_tailroom(ut_params->ibuf));
3281 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3282 /* Append data which is padded to a multiple of */
3283 /* the algorithms block size */
3284 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3285 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3287 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3289 /* Create KASUMI operation */
3290 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3292 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3293 tdata->plaintext.len,
3298 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3299 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3301 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3302 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3303 ut_params->op, 0, 1, 1, 0);
3305 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3308 ut_params->obuf = ut_params->op->sym->m_src;
3309 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3310 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3311 + plaintext_pad_len;
3314 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3317 DIGEST_BYTE_LENGTH_KASUMI_F9,
3318 "KASUMI Generated auth tag not as expected");
3324 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3326 struct crypto_testsuite_params *ts_params = &testsuite_params;
3327 struct crypto_unittest_params *ut_params = &unittest_params;
3330 unsigned plaintext_pad_len;
3331 unsigned plaintext_len;
3333 struct rte_cryptodev_info dev_info;
3335 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3336 uint64_t feat_flags = dev_info.feature_flags;
3338 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3339 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3340 printf("Device doesn't support RAW data-path APIs.\n");
3341 return TEST_SKIPPED;
3344 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3345 return TEST_SKIPPED;
3347 /* Verify the capabilities */
3348 struct rte_cryptodev_sym_capability_idx cap_idx;
3349 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3350 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3351 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3353 return TEST_SKIPPED;
3355 /* Create KASUMI session */
3356 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3357 tdata->key.data, tdata->key.len,
3358 0, tdata->digest.len,
3359 RTE_CRYPTO_AUTH_OP_VERIFY,
3360 RTE_CRYPTO_AUTH_KASUMI_F9);
3363 /* alloc mbuf and set payload */
3364 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3366 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3367 rte_pktmbuf_tailroom(ut_params->ibuf));
3369 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3370 /* Append data which is padded to a multiple */
3371 /* of the algorithms block size */
3372 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3373 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3375 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3377 /* Create KASUMI operation */
3378 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3382 RTE_CRYPTO_AUTH_OP_VERIFY,
3383 tdata->plaintext.len,
3388 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3389 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3390 ut_params->op, 0, 1, 1, 0);
3392 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3394 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3395 ut_params->obuf = ut_params->op->sym->m_src;
3396 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3397 + plaintext_pad_len;
3400 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3409 test_snow3g_hash_generate_test_case_1(void)
3411 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3415 test_snow3g_hash_generate_test_case_2(void)
3417 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3421 test_snow3g_hash_generate_test_case_3(void)
3423 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3427 test_snow3g_hash_generate_test_case_4(void)
3429 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3433 test_snow3g_hash_generate_test_case_5(void)
3435 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3439 test_snow3g_hash_generate_test_case_6(void)
3441 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3445 test_snow3g_hash_verify_test_case_1(void)
3447 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3452 test_snow3g_hash_verify_test_case_2(void)
3454 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3458 test_snow3g_hash_verify_test_case_3(void)
3460 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3464 test_snow3g_hash_verify_test_case_4(void)
3466 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3470 test_snow3g_hash_verify_test_case_5(void)
3472 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3476 test_snow3g_hash_verify_test_case_6(void)
3478 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3482 test_kasumi_hash_generate_test_case_1(void)
3484 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3488 test_kasumi_hash_generate_test_case_2(void)
3490 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3494 test_kasumi_hash_generate_test_case_3(void)
3496 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3500 test_kasumi_hash_generate_test_case_4(void)
3502 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3506 test_kasumi_hash_generate_test_case_5(void)
3508 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3512 test_kasumi_hash_generate_test_case_6(void)
3514 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3518 test_kasumi_hash_verify_test_case_1(void)
3520 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3524 test_kasumi_hash_verify_test_case_2(void)
3526 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3530 test_kasumi_hash_verify_test_case_3(void)
3532 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3536 test_kasumi_hash_verify_test_case_4(void)
3538 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3542 test_kasumi_hash_verify_test_case_5(void)
3544 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3548 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3550 struct crypto_testsuite_params *ts_params = &testsuite_params;
3551 struct crypto_unittest_params *ut_params = &unittest_params;
3554 uint8_t *plaintext, *ciphertext;
3555 unsigned plaintext_pad_len;
3556 unsigned plaintext_len;
3557 struct rte_cryptodev_info dev_info;
3559 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3560 uint64_t feat_flags = dev_info.feature_flags;
3562 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3563 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3564 printf("Device doesn't support RAW data-path APIs.\n");
3565 return TEST_SKIPPED;
3568 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3569 return TEST_SKIPPED;
3571 /* Verify the capabilities */
3572 struct rte_cryptodev_sym_capability_idx cap_idx;
3573 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3574 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3575 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3577 return TEST_SKIPPED;
3579 /* Create KASUMI session */
3580 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3581 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3582 RTE_CRYPTO_CIPHER_KASUMI_F8,
3583 tdata->key.data, tdata->key.len,
3584 tdata->cipher_iv.len);
3588 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3590 /* Clear mbuf payload */
3591 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3592 rte_pktmbuf_tailroom(ut_params->ibuf));
3594 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3595 /* Append data which is padded to a multiple */
3596 /* of the algorithms block size */
3597 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3598 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3600 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3602 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3604 /* Create KASUMI operation */
3605 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3606 tdata->cipher_iv.len,
3607 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3608 tdata->validCipherOffsetInBits.len);
3612 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3613 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3614 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3616 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3618 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3620 ut_params->obuf = ut_params->op->sym->m_dst;
3621 if (ut_params->obuf)
3622 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3624 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3626 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3628 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3629 (tdata->validCipherOffsetInBits.len >> 3);
3631 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3633 reference_ciphertext,
3634 tdata->validCipherLenInBits.len,
3635 "KASUMI Ciphertext data not as expected");
3640 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3642 struct crypto_testsuite_params *ts_params = &testsuite_params;
3643 struct crypto_unittest_params *ut_params = &unittest_params;
3647 unsigned int plaintext_pad_len;
3648 unsigned int plaintext_len;
3650 uint8_t buffer[10000];
3651 const uint8_t *ciphertext;
3653 struct rte_cryptodev_info dev_info;
3655 /* Verify the capabilities */
3656 struct rte_cryptodev_sym_capability_idx cap_idx;
3657 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3658 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3659 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3661 return TEST_SKIPPED;
3663 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3665 uint64_t feat_flags = dev_info.feature_flags;
3667 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3668 printf("Device doesn't support in-place scatter-gather. "
3670 return TEST_SKIPPED;
3673 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3674 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3675 printf("Device doesn't support RAW data-path APIs.\n");
3676 return TEST_SKIPPED;
3679 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3680 return TEST_SKIPPED;
3682 /* Create KASUMI session */
3683 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3684 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3685 RTE_CRYPTO_CIPHER_KASUMI_F8,
3686 tdata->key.data, tdata->key.len,
3687 tdata->cipher_iv.len);
3691 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3694 /* Append data which is padded to a multiple */
3695 /* of the algorithms block size */
3696 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3698 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3699 plaintext_pad_len, 10, 0);
3701 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3703 /* Create KASUMI operation */
3704 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3705 tdata->cipher_iv.len,
3706 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3707 tdata->validCipherOffsetInBits.len);
3711 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3712 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3713 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3715 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3717 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3719 ut_params->obuf = ut_params->op->sym->m_dst;
3721 if (ut_params->obuf)
3722 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3723 plaintext_len, buffer);
3725 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3726 tdata->validCipherOffsetInBits.len >> 3,
3727 plaintext_len, buffer);
3730 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3732 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3733 (tdata->validCipherOffsetInBits.len >> 3);
3735 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3737 reference_ciphertext,
3738 tdata->validCipherLenInBits.len,
3739 "KASUMI Ciphertext data not as expected");
3744 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3746 struct crypto_testsuite_params *ts_params = &testsuite_params;
3747 struct crypto_unittest_params *ut_params = &unittest_params;
3750 uint8_t *plaintext, *ciphertext;
3751 unsigned plaintext_pad_len;
3752 unsigned plaintext_len;
3754 /* Verify the capabilities */
3755 struct rte_cryptodev_sym_capability_idx cap_idx;
3756 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3757 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3758 /* Data-path service does not support OOP */
3759 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3761 return TEST_SKIPPED;
3763 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3764 return TEST_SKIPPED;
3766 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3767 return TEST_SKIPPED;
3769 /* Create KASUMI session */
3770 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3771 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3772 RTE_CRYPTO_CIPHER_KASUMI_F8,
3773 tdata->key.data, tdata->key.len,
3774 tdata->cipher_iv.len);
3778 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3779 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3781 /* Clear mbuf payload */
3782 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3783 rte_pktmbuf_tailroom(ut_params->ibuf));
3785 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3786 /* Append data which is padded to a multiple */
3787 /* of the algorithms block size */
3788 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3789 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3791 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3792 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3794 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3796 /* Create KASUMI operation */
3797 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3798 tdata->cipher_iv.len,
3799 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3800 tdata->validCipherOffsetInBits.len);
3804 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3806 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3808 ut_params->obuf = ut_params->op->sym->m_dst;
3809 if (ut_params->obuf)
3810 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3812 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3814 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3816 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3817 (tdata->validCipherOffsetInBits.len >> 3);
3819 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3821 reference_ciphertext,
3822 tdata->validCipherLenInBits.len,
3823 "KASUMI Ciphertext data not as expected");
3828 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3830 struct crypto_testsuite_params *ts_params = &testsuite_params;
3831 struct crypto_unittest_params *ut_params = &unittest_params;
3834 unsigned int plaintext_pad_len;
3835 unsigned int plaintext_len;
3837 const uint8_t *ciphertext;
3838 uint8_t buffer[2048];
3840 struct rte_cryptodev_info dev_info;
3842 /* Verify the capabilities */
3843 struct rte_cryptodev_sym_capability_idx cap_idx;
3844 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3845 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3846 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3848 return TEST_SKIPPED;
3850 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3851 return TEST_SKIPPED;
3853 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3854 return TEST_SKIPPED;
3856 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3858 uint64_t feat_flags = dev_info.feature_flags;
3859 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3860 printf("Device doesn't support out-of-place scatter-gather "
3861 "in both input and output mbufs. "
3863 return TEST_SKIPPED;
3866 /* Create KASUMI session */
3867 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3868 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3869 RTE_CRYPTO_CIPHER_KASUMI_F8,
3870 tdata->key.data, tdata->key.len,
3871 tdata->cipher_iv.len);
3875 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3876 /* Append data which is padded to a multiple */
3877 /* of the algorithms block size */
3878 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3880 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3881 plaintext_pad_len, 10, 0);
3882 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3883 plaintext_pad_len, 3, 0);
3885 /* Append data which is padded to a multiple */
3886 /* of the algorithms block size */
3887 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3889 /* Create KASUMI operation */
3890 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3891 tdata->cipher_iv.len,
3892 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3893 tdata->validCipherOffsetInBits.len);
3897 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3899 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3901 ut_params->obuf = ut_params->op->sym->m_dst;
3902 if (ut_params->obuf)
3903 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3904 plaintext_pad_len, buffer);
3906 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3907 tdata->validCipherOffsetInBits.len >> 3,
3908 plaintext_pad_len, buffer);
3910 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3911 (tdata->validCipherOffsetInBits.len >> 3);
3913 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3915 reference_ciphertext,
3916 tdata->validCipherLenInBits.len,
3917 "KASUMI Ciphertext data not as expected");
3923 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3925 struct crypto_testsuite_params *ts_params = &testsuite_params;
3926 struct crypto_unittest_params *ut_params = &unittest_params;
3929 uint8_t *ciphertext, *plaintext;
3930 unsigned ciphertext_pad_len;
3931 unsigned ciphertext_len;
3933 /* Verify the capabilities */
3934 struct rte_cryptodev_sym_capability_idx cap_idx;
3935 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3936 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3937 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3939 return TEST_SKIPPED;
3941 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3942 return TEST_SKIPPED;
3944 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3945 return TEST_SKIPPED;
3947 /* Create KASUMI session */
3948 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3949 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3950 RTE_CRYPTO_CIPHER_KASUMI_F8,
3951 tdata->key.data, tdata->key.len,
3952 tdata->cipher_iv.len);
3956 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3957 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3959 /* Clear mbuf payload */
3960 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3961 rte_pktmbuf_tailroom(ut_params->ibuf));
3963 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3964 /* Append data which is padded to a multiple */
3965 /* of the algorithms block size */
3966 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3967 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3968 ciphertext_pad_len);
3969 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3970 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3972 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3974 /* Create KASUMI operation */
3975 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3976 tdata->cipher_iv.len,
3977 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3978 tdata->validCipherOffsetInBits.len);
3982 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3984 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3986 ut_params->obuf = ut_params->op->sym->m_dst;
3987 if (ut_params->obuf)
3988 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3990 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3992 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3994 const uint8_t *reference_plaintext = tdata->plaintext.data +
3995 (tdata->validCipherOffsetInBits.len >> 3);
3997 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3999 reference_plaintext,
4000 tdata->validCipherLenInBits.len,
4001 "KASUMI Plaintext data not as expected");
4006 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4008 struct crypto_testsuite_params *ts_params = &testsuite_params;
4009 struct crypto_unittest_params *ut_params = &unittest_params;
4012 uint8_t *ciphertext, *plaintext;
4013 unsigned ciphertext_pad_len;
4014 unsigned ciphertext_len;
4015 struct rte_cryptodev_info dev_info;
4017 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4018 uint64_t feat_flags = dev_info.feature_flags;
4020 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4021 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4022 printf("Device doesn't support RAW data-path APIs.\n");
4023 return TEST_SKIPPED;
4026 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4027 return TEST_SKIPPED;
4029 /* Verify the capabilities */
4030 struct rte_cryptodev_sym_capability_idx cap_idx;
4031 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4032 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4033 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4035 return TEST_SKIPPED;
4037 /* Create KASUMI session */
4038 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4039 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4040 RTE_CRYPTO_CIPHER_KASUMI_F8,
4041 tdata->key.data, tdata->key.len,
4042 tdata->cipher_iv.len);
4046 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4048 /* Clear mbuf payload */
4049 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4050 rte_pktmbuf_tailroom(ut_params->ibuf));
4052 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4053 /* Append data which is padded to a multiple */
4054 /* of the algorithms block size */
4055 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4056 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4057 ciphertext_pad_len);
4058 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4060 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4062 /* Create KASUMI operation */
4063 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4064 tdata->cipher_iv.len,
4065 tdata->ciphertext.len,
4066 tdata->validCipherOffsetInBits.len);
4070 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4071 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4072 ut_params->op, 1, 0, 1, 0);
4074 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4076 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4078 ut_params->obuf = ut_params->op->sym->m_dst;
4079 if (ut_params->obuf)
4080 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4082 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4084 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4086 const uint8_t *reference_plaintext = tdata->plaintext.data +
4087 (tdata->validCipherOffsetInBits.len >> 3);
4089 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4091 reference_plaintext,
4092 tdata->validCipherLenInBits.len,
4093 "KASUMI Plaintext data not as expected");
4098 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4100 struct crypto_testsuite_params *ts_params = &testsuite_params;
4101 struct crypto_unittest_params *ut_params = &unittest_params;
4104 uint8_t *plaintext, *ciphertext;
4105 unsigned plaintext_pad_len;
4106 unsigned plaintext_len;
4107 struct rte_cryptodev_info dev_info;
4109 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4110 uint64_t feat_flags = dev_info.feature_flags;
4112 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4113 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4114 printf("Device doesn't support RAW data-path APIs.\n");
4115 return TEST_SKIPPED;
4118 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4119 return TEST_SKIPPED;
4121 /* Verify the capabilities */
4122 struct rte_cryptodev_sym_capability_idx cap_idx;
4123 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4124 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4125 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4127 return TEST_SKIPPED;
4129 /* Create SNOW 3G session */
4130 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4131 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4132 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4133 tdata->key.data, tdata->key.len,
4134 tdata->cipher_iv.len);
4138 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4140 /* Clear mbuf payload */
4141 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4142 rte_pktmbuf_tailroom(ut_params->ibuf));
4144 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4145 /* Append data which is padded to a multiple of */
4146 /* the algorithms block size */
4147 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4148 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4150 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4152 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4154 /* Create SNOW 3G operation */
4155 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4156 tdata->cipher_iv.len,
4157 tdata->validCipherLenInBits.len,
4162 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4163 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4164 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4166 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4168 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4170 ut_params->obuf = ut_params->op->sym->m_dst;
4171 if (ut_params->obuf)
4172 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4174 ciphertext = plaintext;
4176 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4179 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4181 tdata->ciphertext.data,
4182 tdata->validDataLenInBits.len,
4183 "SNOW 3G Ciphertext data not as expected");
4189 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4191 struct crypto_testsuite_params *ts_params = &testsuite_params;
4192 struct crypto_unittest_params *ut_params = &unittest_params;
4193 uint8_t *plaintext, *ciphertext;
4196 unsigned plaintext_pad_len;
4197 unsigned plaintext_len;
4199 /* Verify the capabilities */
4200 struct rte_cryptodev_sym_capability_idx cap_idx;
4201 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4202 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4203 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4205 return TEST_SKIPPED;
4207 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4208 return TEST_SKIPPED;
4210 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4211 return TEST_SKIPPED;
4213 /* Create SNOW 3G session */
4214 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4215 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4216 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4217 tdata->key.data, tdata->key.len,
4218 tdata->cipher_iv.len);
4222 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4223 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4225 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4226 "Failed to allocate input buffer in mempool");
4227 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4228 "Failed to allocate output buffer in mempool");
4230 /* Clear mbuf payload */
4231 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4232 rte_pktmbuf_tailroom(ut_params->ibuf));
4234 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4235 /* Append data which is padded to a multiple of */
4236 /* the algorithms block size */
4237 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4238 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4240 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4241 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4243 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4245 /* Create SNOW 3G operation */
4246 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4247 tdata->cipher_iv.len,
4248 tdata->validCipherLenInBits.len,
4253 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4255 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4257 ut_params->obuf = ut_params->op->sym->m_dst;
4258 if (ut_params->obuf)
4259 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4261 ciphertext = plaintext;
4263 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4266 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4268 tdata->ciphertext.data,
4269 tdata->validDataLenInBits.len,
4270 "SNOW 3G Ciphertext data not as expected");
4275 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4277 struct crypto_testsuite_params *ts_params = &testsuite_params;
4278 struct crypto_unittest_params *ut_params = &unittest_params;
4281 unsigned int plaintext_pad_len;
4282 unsigned int plaintext_len;
4283 uint8_t buffer[10000];
4284 const uint8_t *ciphertext;
4286 struct rte_cryptodev_info dev_info;
4288 /* Verify the capabilities */
4289 struct rte_cryptodev_sym_capability_idx cap_idx;
4290 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4291 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4292 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4294 return TEST_SKIPPED;
4296 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4297 return TEST_SKIPPED;
4299 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4300 return TEST_SKIPPED;
4302 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4304 uint64_t feat_flags = dev_info.feature_flags;
4306 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4307 printf("Device doesn't support out-of-place scatter-gather "
4308 "in both input and output mbufs. "
4310 return TEST_SKIPPED;
4313 /* Create SNOW 3G session */
4314 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4315 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4316 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4317 tdata->key.data, tdata->key.len,
4318 tdata->cipher_iv.len);
4322 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4323 /* Append data which is padded to a multiple of */
4324 /* the algorithms block size */
4325 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4327 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4328 plaintext_pad_len, 10, 0);
4329 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4330 plaintext_pad_len, 3, 0);
4332 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4333 "Failed to allocate input buffer in mempool");
4334 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4335 "Failed to allocate output buffer in mempool");
4337 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4339 /* Create SNOW 3G operation */
4340 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4341 tdata->cipher_iv.len,
4342 tdata->validCipherLenInBits.len,
4347 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4349 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4351 ut_params->obuf = ut_params->op->sym->m_dst;
4352 if (ut_params->obuf)
4353 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4354 plaintext_len, buffer);
4356 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4357 plaintext_len, buffer);
4359 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4362 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4364 tdata->ciphertext.data,
4365 tdata->validDataLenInBits.len,
4366 "SNOW 3G Ciphertext data not as expected");
4371 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4373 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4375 uint8_t curr_byte, prev_byte;
4376 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4377 uint8_t lower_byte_mask = (1 << offset) - 1;
4380 prev_byte = buffer[0];
4381 buffer[0] >>= offset;
4383 for (i = 1; i < length_in_bytes; i++) {
4384 curr_byte = buffer[i];
4385 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4386 (curr_byte >> offset);
4387 prev_byte = curr_byte;
4392 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4394 struct crypto_testsuite_params *ts_params = &testsuite_params;
4395 struct crypto_unittest_params *ut_params = &unittest_params;
4396 uint8_t *plaintext, *ciphertext;
4398 uint32_t plaintext_len;
4399 uint32_t plaintext_pad_len;
4400 uint8_t extra_offset = 4;
4401 uint8_t *expected_ciphertext_shifted;
4402 struct rte_cryptodev_info dev_info;
4404 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4405 uint64_t feat_flags = dev_info.feature_flags;
4407 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4408 ((tdata->validDataLenInBits.len % 8) != 0)) {
4409 printf("Device doesn't support NON-Byte Aligned Data.\n");
4410 return TEST_SKIPPED;
4413 /* Verify the capabilities */
4414 struct rte_cryptodev_sym_capability_idx cap_idx;
4415 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4416 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4417 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4419 return TEST_SKIPPED;
4421 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4422 return TEST_SKIPPED;
4424 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4425 return TEST_SKIPPED;
4427 /* Create SNOW 3G session */
4428 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4429 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4430 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4431 tdata->key.data, tdata->key.len,
4432 tdata->cipher_iv.len);
4436 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4437 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4439 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4440 "Failed to allocate input buffer in mempool");
4441 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4442 "Failed to allocate output buffer in mempool");
4444 /* Clear mbuf payload */
4445 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4446 rte_pktmbuf_tailroom(ut_params->ibuf));
4448 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4450 * Append data which is padded to a
4451 * multiple of the algorithms block size
4453 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4455 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4458 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4460 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4461 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4463 #ifdef RTE_APP_TEST_DEBUG
4464 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4466 /* Create SNOW 3G operation */
4467 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4468 tdata->cipher_iv.len,
4469 tdata->validCipherLenInBits.len,
4474 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4476 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4478 ut_params->obuf = ut_params->op->sym->m_dst;
4479 if (ut_params->obuf)
4480 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4482 ciphertext = plaintext;
4484 #ifdef RTE_APP_TEST_DEBUG
4485 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4488 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4490 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4491 "failed to reserve memory for ciphertext shifted\n");
4493 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4494 ceil_byte_length(tdata->ciphertext.len));
4495 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4498 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4500 expected_ciphertext_shifted,
4501 tdata->validDataLenInBits.len,
4503 "SNOW 3G Ciphertext data not as expected");
4507 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4509 struct crypto_testsuite_params *ts_params = &testsuite_params;
4510 struct crypto_unittest_params *ut_params = &unittest_params;
4514 uint8_t *plaintext, *ciphertext;
4515 unsigned ciphertext_pad_len;
4516 unsigned ciphertext_len;
4517 struct rte_cryptodev_info dev_info;
4519 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4520 uint64_t feat_flags = dev_info.feature_flags;
4522 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4523 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4524 printf("Device doesn't support RAW data-path APIs.\n");
4525 return TEST_SKIPPED;
4528 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4529 return TEST_SKIPPED;
4531 /* Verify the capabilities */
4532 struct rte_cryptodev_sym_capability_idx cap_idx;
4533 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4534 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4535 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4537 return TEST_SKIPPED;
4539 /* Create SNOW 3G session */
4540 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4541 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4542 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4543 tdata->key.data, tdata->key.len,
4544 tdata->cipher_iv.len);
4548 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4550 /* Clear mbuf payload */
4551 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4552 rte_pktmbuf_tailroom(ut_params->ibuf));
4554 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4555 /* Append data which is padded to a multiple of */
4556 /* the algorithms block size */
4557 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4558 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4559 ciphertext_pad_len);
4560 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4562 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4564 /* Create SNOW 3G operation */
4565 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4566 tdata->cipher_iv.len,
4567 tdata->validCipherLenInBits.len,
4568 tdata->cipher.offset_bits);
4572 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4573 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4574 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4576 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4578 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4579 ut_params->obuf = ut_params->op->sym->m_dst;
4580 if (ut_params->obuf)
4581 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4583 plaintext = ciphertext;
4585 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4588 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4589 tdata->plaintext.data,
4590 tdata->validDataLenInBits.len,
4591 "SNOW 3G Plaintext data not as expected");
4595 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4597 struct crypto_testsuite_params *ts_params = &testsuite_params;
4598 struct crypto_unittest_params *ut_params = &unittest_params;
4602 uint8_t *plaintext, *ciphertext;
4603 unsigned ciphertext_pad_len;
4604 unsigned ciphertext_len;
4606 /* Verify the capabilities */
4607 struct rte_cryptodev_sym_capability_idx cap_idx;
4608 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4609 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4610 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4612 return TEST_SKIPPED;
4614 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4615 return TEST_SKIPPED;
4617 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4618 return TEST_SKIPPED;
4620 /* Create SNOW 3G session */
4621 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4622 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4623 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4624 tdata->key.data, tdata->key.len,
4625 tdata->cipher_iv.len);
4629 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4630 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4632 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4633 "Failed to allocate input buffer");
4634 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4635 "Failed to allocate output buffer");
4637 /* Clear mbuf payload */
4638 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4639 rte_pktmbuf_tailroom(ut_params->ibuf));
4641 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4642 rte_pktmbuf_tailroom(ut_params->obuf));
4644 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4645 /* Append data which is padded to a multiple of */
4646 /* the algorithms block size */
4647 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4648 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4649 ciphertext_pad_len);
4650 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4651 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4653 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4655 /* Create SNOW 3G operation */
4656 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4657 tdata->cipher_iv.len,
4658 tdata->validCipherLenInBits.len,
4663 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4665 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4666 ut_params->obuf = ut_params->op->sym->m_dst;
4667 if (ut_params->obuf)
4668 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4670 plaintext = ciphertext;
4672 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4675 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4676 tdata->plaintext.data,
4677 tdata->validDataLenInBits.len,
4678 "SNOW 3G Plaintext data not as expected");
4683 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4685 struct crypto_testsuite_params *ts_params = &testsuite_params;
4686 struct crypto_unittest_params *ut_params = &unittest_params;
4690 uint8_t *plaintext, *ciphertext;
4691 unsigned int plaintext_pad_len;
4692 unsigned int plaintext_len;
4694 struct rte_cryptodev_info dev_info;
4695 struct rte_cryptodev_sym_capability_idx cap_idx;
4697 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4698 uint64_t feat_flags = dev_info.feature_flags;
4700 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4701 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4702 (tdata->validDataLenInBits.len % 8 != 0))) {
4703 printf("Device doesn't support NON-Byte Aligned Data.\n");
4704 return TEST_SKIPPED;
4707 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4708 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4709 printf("Device doesn't support RAW data-path APIs.\n");
4710 return TEST_SKIPPED;
4713 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4714 return TEST_SKIPPED;
4716 /* Check if device supports ZUC EEA3 */
4717 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4718 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4720 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4722 return TEST_SKIPPED;
4724 /* Check if device supports ZUC EIA3 */
4725 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4726 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4728 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4730 return TEST_SKIPPED;
4732 /* Create ZUC session */
4733 retval = create_zuc_cipher_auth_encrypt_generate_session(
4734 ts_params->valid_devs[0],
4738 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4740 /* clear mbuf payload */
4741 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4742 rte_pktmbuf_tailroom(ut_params->ibuf));
4744 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4745 /* Append data which is padded to a multiple of */
4746 /* the algorithms block size */
4747 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4748 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4750 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4752 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4754 /* Create ZUC operation */
4755 retval = create_zuc_cipher_hash_generate_operation(tdata);
4759 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4760 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4761 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4763 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4765 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4766 ut_params->obuf = ut_params->op->sym->m_src;
4767 if (ut_params->obuf)
4768 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4770 ciphertext = plaintext;
4772 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4774 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4776 tdata->ciphertext.data,
4777 tdata->validDataLenInBits.len,
4778 "ZUC Ciphertext data not as expected");
4780 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4781 + plaintext_pad_len;
4784 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4788 "ZUC Generated auth tag not as expected");
4793 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4795 struct crypto_testsuite_params *ts_params = &testsuite_params;
4796 struct crypto_unittest_params *ut_params = &unittest_params;
4800 uint8_t *plaintext, *ciphertext;
4801 unsigned plaintext_pad_len;
4802 unsigned plaintext_len;
4803 struct rte_cryptodev_info dev_info;
4805 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4806 uint64_t feat_flags = dev_info.feature_flags;
4808 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4809 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4810 printf("Device doesn't support RAW data-path APIs.\n");
4811 return TEST_SKIPPED;
4814 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4815 return TEST_SKIPPED;
4817 /* Verify the capabilities */
4818 struct rte_cryptodev_sym_capability_idx cap_idx;
4819 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4820 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4821 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4823 return TEST_SKIPPED;
4824 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4825 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4826 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4828 return TEST_SKIPPED;
4830 /* Create SNOW 3G session */
4831 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4832 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4833 RTE_CRYPTO_AUTH_OP_GENERATE,
4834 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4835 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4836 tdata->key.data, tdata->key.len,
4837 tdata->auth_iv.len, tdata->digest.len,
4838 tdata->cipher_iv.len);
4841 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4843 /* clear mbuf payload */
4844 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4845 rte_pktmbuf_tailroom(ut_params->ibuf));
4847 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4848 /* Append data which is padded to a multiple of */
4849 /* the algorithms block size */
4850 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4851 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4853 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4855 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4857 /* Create SNOW 3G operation */
4858 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4859 tdata->digest.len, tdata->auth_iv.data,
4861 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4862 tdata->cipher_iv.data, tdata->cipher_iv.len,
4863 tdata->validCipherLenInBits.len,
4865 tdata->validAuthLenInBits.len,
4871 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4872 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4873 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4875 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4877 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4878 ut_params->obuf = ut_params->op->sym->m_src;
4879 if (ut_params->obuf)
4880 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4882 ciphertext = plaintext;
4884 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4886 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4888 tdata->ciphertext.data,
4889 tdata->validDataLenInBits.len,
4890 "SNOW 3G Ciphertext data not as expected");
4892 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4893 + plaintext_pad_len;
4896 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4899 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4900 "SNOW 3G Generated auth tag not as expected");
4905 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4906 uint8_t op_mode, uint8_t verify)
4908 struct crypto_testsuite_params *ts_params = &testsuite_params;
4909 struct crypto_unittest_params *ut_params = &unittest_params;
4913 uint8_t *plaintext = NULL, *ciphertext = NULL;
4914 unsigned int plaintext_pad_len;
4915 unsigned int plaintext_len;
4916 unsigned int ciphertext_pad_len;
4917 unsigned int ciphertext_len;
4919 struct rte_cryptodev_info dev_info;
4921 /* Verify the capabilities */
4922 struct rte_cryptodev_sym_capability_idx cap_idx;
4923 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4924 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4925 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4927 return TEST_SKIPPED;
4928 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4929 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4930 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4932 return TEST_SKIPPED;
4934 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4935 return TEST_SKIPPED;
4937 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4939 uint64_t feat_flags = dev_info.feature_flags;
4941 if (op_mode == OUT_OF_PLACE) {
4942 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4943 printf("Device doesn't support digest encrypted.\n");
4944 return TEST_SKIPPED;
4946 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4947 return TEST_SKIPPED;
4950 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4951 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4952 printf("Device doesn't support RAW data-path APIs.\n");
4953 return TEST_SKIPPED;
4956 /* Create SNOW 3G session */
4957 retval = create_wireless_algo_auth_cipher_session(
4958 ts_params->valid_devs[0],
4959 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4960 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4961 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4962 : RTE_CRYPTO_AUTH_OP_GENERATE),
4963 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4964 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4965 tdata->key.data, tdata->key.len,
4966 tdata->auth_iv.len, tdata->digest.len,
4967 tdata->cipher_iv.len);
4971 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4972 if (op_mode == OUT_OF_PLACE)
4973 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4975 /* clear mbuf payload */
4976 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4977 rte_pktmbuf_tailroom(ut_params->ibuf));
4978 if (op_mode == OUT_OF_PLACE)
4979 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4980 rte_pktmbuf_tailroom(ut_params->obuf));
4982 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4983 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4984 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4985 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4988 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4989 ciphertext_pad_len);
4990 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4991 if (op_mode == OUT_OF_PLACE)
4992 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4993 debug_hexdump(stdout, "ciphertext:", ciphertext,
4996 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4998 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4999 if (op_mode == OUT_OF_PLACE)
5000 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5001 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5004 /* Create SNOW 3G operation */
5005 retval = create_wireless_algo_auth_cipher_operation(
5006 tdata->digest.data, tdata->digest.len,
5007 tdata->cipher_iv.data, tdata->cipher_iv.len,
5008 tdata->auth_iv.data, tdata->auth_iv.len,
5009 (tdata->digest.offset_bytes == 0 ?
5010 (verify ? ciphertext_pad_len : plaintext_pad_len)
5011 : tdata->digest.offset_bytes),
5012 tdata->validCipherLenInBits.len,
5013 tdata->cipher.offset_bits,
5014 tdata->validAuthLenInBits.len,
5015 tdata->auth.offset_bits,
5016 op_mode, 0, verify);
5021 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5022 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5023 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5025 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5028 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5030 ut_params->obuf = (op_mode == IN_PLACE ?
5031 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5034 if (ut_params->obuf)
5035 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5038 plaintext = ciphertext +
5039 (tdata->cipher.offset_bits >> 3);
5041 debug_hexdump(stdout, "plaintext:", plaintext,
5042 (tdata->plaintext.len >> 3) - tdata->digest.len);
5043 debug_hexdump(stdout, "plaintext expected:",
5044 tdata->plaintext.data,
5045 (tdata->plaintext.len >> 3) - tdata->digest.len);
5047 if (ut_params->obuf)
5048 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5051 ciphertext = plaintext;
5053 debug_hexdump(stdout, "ciphertext:", ciphertext,
5055 debug_hexdump(stdout, "ciphertext expected:",
5056 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5058 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5059 + (tdata->digest.offset_bytes == 0 ?
5060 plaintext_pad_len : tdata->digest.offset_bytes);
5062 debug_hexdump(stdout, "digest:", ut_params->digest,
5064 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5070 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5072 tdata->plaintext.data,
5073 (tdata->plaintext.len - tdata->cipher.offset_bits -
5074 (tdata->digest.len << 3)),
5075 tdata->cipher.offset_bits,
5076 "SNOW 3G Plaintext data not as expected");
5078 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5080 tdata->ciphertext.data,
5081 (tdata->validDataLenInBits.len -
5082 tdata->cipher.offset_bits),
5083 tdata->cipher.offset_bits,
5084 "SNOW 3G Ciphertext data not as expected");
5086 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5089 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5090 "SNOW 3G Generated auth tag not as expected");
5096 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5097 uint8_t op_mode, uint8_t verify)
5099 struct crypto_testsuite_params *ts_params = &testsuite_params;
5100 struct crypto_unittest_params *ut_params = &unittest_params;
5104 const uint8_t *plaintext = NULL;
5105 const uint8_t *ciphertext = NULL;
5106 const uint8_t *digest = NULL;
5107 unsigned int plaintext_pad_len;
5108 unsigned int plaintext_len;
5109 unsigned int ciphertext_pad_len;
5110 unsigned int ciphertext_len;
5111 uint8_t buffer[10000];
5112 uint8_t digest_buffer[10000];
5114 struct rte_cryptodev_info dev_info;
5116 /* Verify the capabilities */
5117 struct rte_cryptodev_sym_capability_idx cap_idx;
5118 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5119 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5120 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5122 return TEST_SKIPPED;
5123 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5124 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5125 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5127 return TEST_SKIPPED;
5129 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5130 return TEST_SKIPPED;
5132 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5134 uint64_t feat_flags = dev_info.feature_flags;
5136 if (op_mode == IN_PLACE) {
5137 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5138 printf("Device doesn't support in-place scatter-gather "
5139 "in both input and output mbufs.\n");
5140 return TEST_SKIPPED;
5142 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5143 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5144 printf("Device doesn't support RAW data-path APIs.\n");
5145 return TEST_SKIPPED;
5148 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5149 return TEST_SKIPPED;
5150 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5151 printf("Device doesn't support out-of-place scatter-gather "
5152 "in both input and output mbufs.\n");
5153 return TEST_SKIPPED;
5155 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5156 printf("Device doesn't support digest encrypted.\n");
5157 return TEST_SKIPPED;
5161 /* Create SNOW 3G session */
5162 retval = create_wireless_algo_auth_cipher_session(
5163 ts_params->valid_devs[0],
5164 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5165 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5166 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5167 : RTE_CRYPTO_AUTH_OP_GENERATE),
5168 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5169 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5170 tdata->key.data, tdata->key.len,
5171 tdata->auth_iv.len, tdata->digest.len,
5172 tdata->cipher_iv.len);
5177 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5178 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5179 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5180 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5182 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5183 plaintext_pad_len, 15, 0);
5184 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5185 "Failed to allocate input buffer in mempool");
5187 if (op_mode == OUT_OF_PLACE) {
5188 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5189 plaintext_pad_len, 15, 0);
5190 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5191 "Failed to allocate output buffer in mempool");
5195 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5196 tdata->ciphertext.data);
5197 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5198 ciphertext_len, buffer);
5199 debug_hexdump(stdout, "ciphertext:", ciphertext,
5202 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5203 tdata->plaintext.data);
5204 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5205 plaintext_len, buffer);
5206 debug_hexdump(stdout, "plaintext:", plaintext,
5209 memset(buffer, 0, sizeof(buffer));
5211 /* Create SNOW 3G operation */
5212 retval = create_wireless_algo_auth_cipher_operation(
5213 tdata->digest.data, tdata->digest.len,
5214 tdata->cipher_iv.data, tdata->cipher_iv.len,
5215 tdata->auth_iv.data, tdata->auth_iv.len,
5216 (tdata->digest.offset_bytes == 0 ?
5217 (verify ? ciphertext_pad_len : plaintext_pad_len)
5218 : tdata->digest.offset_bytes),
5219 tdata->validCipherLenInBits.len,
5220 tdata->cipher.offset_bits,
5221 tdata->validAuthLenInBits.len,
5222 tdata->auth.offset_bits,
5223 op_mode, 1, verify);
5228 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5229 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5230 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5232 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5235 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5237 ut_params->obuf = (op_mode == IN_PLACE ?
5238 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5241 if (ut_params->obuf)
5242 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5243 plaintext_len, buffer);
5245 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5246 plaintext_len, buffer);
5248 debug_hexdump(stdout, "plaintext:", plaintext,
5249 (tdata->plaintext.len >> 3) - tdata->digest.len);
5250 debug_hexdump(stdout, "plaintext expected:",
5251 tdata->plaintext.data,
5252 (tdata->plaintext.len >> 3) - tdata->digest.len);
5254 if (ut_params->obuf)
5255 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5256 ciphertext_len, buffer);
5258 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5259 ciphertext_len, buffer);
5261 debug_hexdump(stdout, "ciphertext:", ciphertext,
5263 debug_hexdump(stdout, "ciphertext expected:",
5264 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5266 if (ut_params->obuf)
5267 digest = rte_pktmbuf_read(ut_params->obuf,
5268 (tdata->digest.offset_bytes == 0 ?
5269 plaintext_pad_len : tdata->digest.offset_bytes),
5270 tdata->digest.len, digest_buffer);
5272 digest = rte_pktmbuf_read(ut_params->ibuf,
5273 (tdata->digest.offset_bytes == 0 ?
5274 plaintext_pad_len : tdata->digest.offset_bytes),
5275 tdata->digest.len, digest_buffer);
5277 debug_hexdump(stdout, "digest:", digest,
5279 debug_hexdump(stdout, "digest expected:",
5280 tdata->digest.data, tdata->digest.len);
5285 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5287 tdata->plaintext.data,
5288 (tdata->plaintext.len - tdata->cipher.offset_bits -
5289 (tdata->digest.len << 3)),
5290 tdata->cipher.offset_bits,
5291 "SNOW 3G Plaintext data not as expected");
5293 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5295 tdata->ciphertext.data,
5296 (tdata->validDataLenInBits.len -
5297 tdata->cipher.offset_bits),
5298 tdata->cipher.offset_bits,
5299 "SNOW 3G Ciphertext data not as expected");
5301 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5304 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5305 "SNOW 3G Generated auth tag not as expected");
5311 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5312 uint8_t op_mode, uint8_t verify)
5314 struct crypto_testsuite_params *ts_params = &testsuite_params;
5315 struct crypto_unittest_params *ut_params = &unittest_params;
5319 uint8_t *plaintext = NULL, *ciphertext = NULL;
5320 unsigned int plaintext_pad_len;
5321 unsigned int plaintext_len;
5322 unsigned int ciphertext_pad_len;
5323 unsigned int ciphertext_len;
5325 struct rte_cryptodev_info dev_info;
5327 /* Verify the capabilities */
5328 struct rte_cryptodev_sym_capability_idx cap_idx;
5329 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5330 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5331 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5333 return TEST_SKIPPED;
5334 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5335 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5336 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5338 return TEST_SKIPPED;
5340 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5342 uint64_t feat_flags = dev_info.feature_flags;
5344 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5345 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5346 printf("Device doesn't support RAW data-path APIs.\n");
5347 return TEST_SKIPPED;
5350 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5351 return TEST_SKIPPED;
5353 if (op_mode == OUT_OF_PLACE) {
5354 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5355 return TEST_SKIPPED;
5356 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5357 printf("Device doesn't support digest encrypted.\n");
5358 return TEST_SKIPPED;
5362 /* Create KASUMI session */
5363 retval = create_wireless_algo_auth_cipher_session(
5364 ts_params->valid_devs[0],
5365 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5366 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5367 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5368 : RTE_CRYPTO_AUTH_OP_GENERATE),
5369 RTE_CRYPTO_AUTH_KASUMI_F9,
5370 RTE_CRYPTO_CIPHER_KASUMI_F8,
5371 tdata->key.data, tdata->key.len,
5372 0, tdata->digest.len,
5373 tdata->cipher_iv.len);
5378 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5379 if (op_mode == OUT_OF_PLACE)
5380 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5382 /* clear mbuf payload */
5383 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5384 rte_pktmbuf_tailroom(ut_params->ibuf));
5385 if (op_mode == OUT_OF_PLACE)
5386 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5387 rte_pktmbuf_tailroom(ut_params->obuf));
5389 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5390 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5391 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5392 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5395 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5396 ciphertext_pad_len);
5397 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5398 if (op_mode == OUT_OF_PLACE)
5399 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5400 debug_hexdump(stdout, "ciphertext:", ciphertext,
5403 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5405 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5406 if (op_mode == OUT_OF_PLACE)
5407 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5408 debug_hexdump(stdout, "plaintext:", plaintext,
5412 /* Create KASUMI operation */
5413 retval = create_wireless_algo_auth_cipher_operation(
5414 tdata->digest.data, tdata->digest.len,
5415 tdata->cipher_iv.data, tdata->cipher_iv.len,
5417 (tdata->digest.offset_bytes == 0 ?
5418 (verify ? ciphertext_pad_len : plaintext_pad_len)
5419 : tdata->digest.offset_bytes),
5420 tdata->validCipherLenInBits.len,
5421 tdata->validCipherOffsetInBits.len,
5422 tdata->validAuthLenInBits.len,
5424 op_mode, 0, verify);
5429 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5430 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5431 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5433 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5436 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5438 ut_params->obuf = (op_mode == IN_PLACE ?
5439 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5443 if (ut_params->obuf)
5444 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5447 plaintext = ciphertext;
5449 debug_hexdump(stdout, "plaintext:", plaintext,
5450 (tdata->plaintext.len >> 3) - tdata->digest.len);
5451 debug_hexdump(stdout, "plaintext expected:",
5452 tdata->plaintext.data,
5453 (tdata->plaintext.len >> 3) - tdata->digest.len);
5455 if (ut_params->obuf)
5456 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5459 ciphertext = plaintext;
5461 debug_hexdump(stdout, "ciphertext:", ciphertext,
5463 debug_hexdump(stdout, "ciphertext expected:",
5464 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5466 ut_params->digest = rte_pktmbuf_mtod(
5467 ut_params->obuf, uint8_t *) +
5468 (tdata->digest.offset_bytes == 0 ?
5469 plaintext_pad_len : tdata->digest.offset_bytes);
5471 debug_hexdump(stdout, "digest:", ut_params->digest,
5473 debug_hexdump(stdout, "digest expected:",
5474 tdata->digest.data, tdata->digest.len);
5479 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5481 tdata->plaintext.data,
5482 tdata->plaintext.len >> 3,
5483 "KASUMI Plaintext data not as expected");
5485 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5487 tdata->ciphertext.data,
5488 tdata->ciphertext.len >> 3,
5489 "KASUMI Ciphertext data not as expected");
5491 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5494 DIGEST_BYTE_LENGTH_KASUMI_F9,
5495 "KASUMI Generated auth tag not as expected");
5501 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5502 uint8_t op_mode, uint8_t verify)
5504 struct crypto_testsuite_params *ts_params = &testsuite_params;
5505 struct crypto_unittest_params *ut_params = &unittest_params;
5509 const uint8_t *plaintext = NULL;
5510 const uint8_t *ciphertext = NULL;
5511 const uint8_t *digest = NULL;
5512 unsigned int plaintext_pad_len;
5513 unsigned int plaintext_len;
5514 unsigned int ciphertext_pad_len;
5515 unsigned int ciphertext_len;
5516 uint8_t buffer[10000];
5517 uint8_t digest_buffer[10000];
5519 struct rte_cryptodev_info dev_info;
5521 /* Verify the capabilities */
5522 struct rte_cryptodev_sym_capability_idx cap_idx;
5523 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5524 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5525 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5527 return TEST_SKIPPED;
5528 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5529 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5530 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5532 return TEST_SKIPPED;
5534 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5535 return TEST_SKIPPED;
5537 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5539 uint64_t feat_flags = dev_info.feature_flags;
5541 if (op_mode == IN_PLACE) {
5542 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5543 printf("Device doesn't support in-place scatter-gather "
5544 "in both input and output mbufs.\n");
5545 return TEST_SKIPPED;
5547 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5548 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5549 printf("Device doesn't support RAW data-path APIs.\n");
5550 return TEST_SKIPPED;
5553 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5554 return TEST_SKIPPED;
5555 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5556 printf("Device doesn't support out-of-place scatter-gather "
5557 "in both input and output mbufs.\n");
5558 return TEST_SKIPPED;
5560 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5561 printf("Device doesn't support digest encrypted.\n");
5562 return TEST_SKIPPED;
5566 /* Create KASUMI session */
5567 retval = create_wireless_algo_auth_cipher_session(
5568 ts_params->valid_devs[0],
5569 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5570 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5571 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5572 : RTE_CRYPTO_AUTH_OP_GENERATE),
5573 RTE_CRYPTO_AUTH_KASUMI_F9,
5574 RTE_CRYPTO_CIPHER_KASUMI_F8,
5575 tdata->key.data, tdata->key.len,
5576 0, tdata->digest.len,
5577 tdata->cipher_iv.len);
5582 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5583 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5584 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5585 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5587 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5588 plaintext_pad_len, 15, 0);
5589 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5590 "Failed to allocate input buffer in mempool");
5592 if (op_mode == OUT_OF_PLACE) {
5593 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5594 plaintext_pad_len, 15, 0);
5595 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5596 "Failed to allocate output buffer in mempool");
5600 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5601 tdata->ciphertext.data);
5602 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5603 ciphertext_len, buffer);
5604 debug_hexdump(stdout, "ciphertext:", ciphertext,
5607 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5608 tdata->plaintext.data);
5609 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5610 plaintext_len, buffer);
5611 debug_hexdump(stdout, "plaintext:", plaintext,
5614 memset(buffer, 0, sizeof(buffer));
5616 /* Create KASUMI operation */
5617 retval = create_wireless_algo_auth_cipher_operation(
5618 tdata->digest.data, tdata->digest.len,
5619 tdata->cipher_iv.data, tdata->cipher_iv.len,
5621 (tdata->digest.offset_bytes == 0 ?
5622 (verify ? ciphertext_pad_len : plaintext_pad_len)
5623 : tdata->digest.offset_bytes),
5624 tdata->validCipherLenInBits.len,
5625 tdata->validCipherOffsetInBits.len,
5626 tdata->validAuthLenInBits.len,
5628 op_mode, 1, verify);
5633 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5634 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5635 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5637 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5640 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5642 ut_params->obuf = (op_mode == IN_PLACE ?
5643 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5646 if (ut_params->obuf)
5647 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5648 plaintext_len, buffer);
5650 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5651 plaintext_len, buffer);
5653 debug_hexdump(stdout, "plaintext:", plaintext,
5654 (tdata->plaintext.len >> 3) - tdata->digest.len);
5655 debug_hexdump(stdout, "plaintext expected:",
5656 tdata->plaintext.data,
5657 (tdata->plaintext.len >> 3) - tdata->digest.len);
5659 if (ut_params->obuf)
5660 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5661 ciphertext_len, buffer);
5663 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5664 ciphertext_len, buffer);
5666 debug_hexdump(stdout, "ciphertext:", ciphertext,
5668 debug_hexdump(stdout, "ciphertext expected:",
5669 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5671 if (ut_params->obuf)
5672 digest = rte_pktmbuf_read(ut_params->obuf,
5673 (tdata->digest.offset_bytes == 0 ?
5674 plaintext_pad_len : tdata->digest.offset_bytes),
5675 tdata->digest.len, digest_buffer);
5677 digest = rte_pktmbuf_read(ut_params->ibuf,
5678 (tdata->digest.offset_bytes == 0 ?
5679 plaintext_pad_len : tdata->digest.offset_bytes),
5680 tdata->digest.len, digest_buffer);
5682 debug_hexdump(stdout, "digest:", digest,
5684 debug_hexdump(stdout, "digest expected:",
5685 tdata->digest.data, tdata->digest.len);
5690 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5692 tdata->plaintext.data,
5693 tdata->plaintext.len >> 3,
5694 "KASUMI Plaintext data not as expected");
5696 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5698 tdata->ciphertext.data,
5699 tdata->validDataLenInBits.len,
5700 "KASUMI Ciphertext data not as expected");
5702 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5705 DIGEST_BYTE_LENGTH_KASUMI_F9,
5706 "KASUMI Generated auth tag not as expected");
5712 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5714 struct crypto_testsuite_params *ts_params = &testsuite_params;
5715 struct crypto_unittest_params *ut_params = &unittest_params;
5719 uint8_t *plaintext, *ciphertext;
5720 unsigned plaintext_pad_len;
5721 unsigned plaintext_len;
5722 struct rte_cryptodev_info dev_info;
5724 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5725 uint64_t feat_flags = dev_info.feature_flags;
5727 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5728 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5729 printf("Device doesn't support RAW data-path APIs.\n");
5730 return TEST_SKIPPED;
5733 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5734 return TEST_SKIPPED;
5736 /* Verify the capabilities */
5737 struct rte_cryptodev_sym_capability_idx cap_idx;
5738 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5739 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5740 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5742 return TEST_SKIPPED;
5743 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5744 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5745 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5747 return TEST_SKIPPED;
5749 /* Create KASUMI session */
5750 retval = create_wireless_algo_cipher_auth_session(
5751 ts_params->valid_devs[0],
5752 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5753 RTE_CRYPTO_AUTH_OP_GENERATE,
5754 RTE_CRYPTO_AUTH_KASUMI_F9,
5755 RTE_CRYPTO_CIPHER_KASUMI_F8,
5756 tdata->key.data, tdata->key.len,
5757 0, tdata->digest.len,
5758 tdata->cipher_iv.len);
5762 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5764 /* clear mbuf payload */
5765 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5766 rte_pktmbuf_tailroom(ut_params->ibuf));
5768 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5769 /* Append data which is padded to a multiple of */
5770 /* the algorithms block size */
5771 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5772 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5774 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5776 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5778 /* Create KASUMI operation */
5779 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5780 tdata->digest.len, NULL, 0,
5781 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5782 tdata->cipher_iv.data, tdata->cipher_iv.len,
5783 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5784 tdata->validCipherOffsetInBits.len,
5785 tdata->validAuthLenInBits.len,
5791 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5792 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5793 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5795 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5797 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5799 if (ut_params->op->sym->m_dst)
5800 ut_params->obuf = ut_params->op->sym->m_dst;
5802 ut_params->obuf = ut_params->op->sym->m_src;
5804 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5805 tdata->validCipherOffsetInBits.len >> 3);
5807 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5808 + plaintext_pad_len;
5810 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5811 (tdata->validCipherOffsetInBits.len >> 3);
5813 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5815 reference_ciphertext,
5816 tdata->validCipherLenInBits.len,
5817 "KASUMI Ciphertext data not as expected");
5820 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5823 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5824 "KASUMI Generated auth tag not as expected");
5829 test_zuc_encryption(const struct wireless_test_data *tdata)
5831 struct crypto_testsuite_params *ts_params = &testsuite_params;
5832 struct crypto_unittest_params *ut_params = &unittest_params;
5835 uint8_t *plaintext, *ciphertext;
5836 unsigned plaintext_pad_len;
5837 unsigned plaintext_len;
5838 struct rte_cryptodev_info dev_info;
5840 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5841 uint64_t feat_flags = dev_info.feature_flags;
5843 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5844 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5845 printf("Device doesn't support RAW data-path APIs.\n");
5846 return TEST_SKIPPED;
5849 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5850 return TEST_SKIPPED;
5852 struct rte_cryptodev_sym_capability_idx cap_idx;
5854 /* Check if device supports ZUC EEA3 */
5855 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5856 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5858 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5860 return TEST_SKIPPED;
5862 /* Create ZUC session */
5863 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5864 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5865 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5866 tdata->key.data, tdata->key.len,
5867 tdata->cipher_iv.len);
5871 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5873 /* Clear mbuf payload */
5874 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5875 rte_pktmbuf_tailroom(ut_params->ibuf));
5877 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5878 /* Append data which is padded to a multiple */
5879 /* of the algorithms block size */
5880 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5881 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5883 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5885 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5887 /* Create ZUC operation */
5888 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5889 tdata->cipher_iv.len,
5890 tdata->plaintext.len,
5895 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5896 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5897 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5899 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5901 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5903 ut_params->obuf = ut_params->op->sym->m_dst;
5904 if (ut_params->obuf)
5905 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5907 ciphertext = plaintext;
5909 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5912 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5914 tdata->ciphertext.data,
5915 tdata->validCipherLenInBits.len,
5916 "ZUC Ciphertext data not as expected");
5921 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5923 struct crypto_testsuite_params *ts_params = &testsuite_params;
5924 struct crypto_unittest_params *ut_params = &unittest_params;
5928 unsigned int plaintext_pad_len;
5929 unsigned int plaintext_len;
5930 const uint8_t *ciphertext;
5931 uint8_t ciphertext_buffer[2048];
5932 struct rte_cryptodev_info dev_info;
5934 struct rte_cryptodev_sym_capability_idx cap_idx;
5936 /* Check if device supports ZUC EEA3 */
5937 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5938 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5940 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5942 return TEST_SKIPPED;
5944 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5945 return TEST_SKIPPED;
5947 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5949 uint64_t feat_flags = dev_info.feature_flags;
5951 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5952 printf("Device doesn't support in-place scatter-gather. "
5954 return TEST_SKIPPED;
5957 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5958 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5959 printf("Device doesn't support RAW data-path APIs.\n");
5960 return TEST_SKIPPED;
5963 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5965 /* Append data which is padded to a multiple */
5966 /* of the algorithms block size */
5967 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5969 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5970 plaintext_pad_len, 10, 0);
5972 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5973 tdata->plaintext.data);
5975 /* Create ZUC session */
5976 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5977 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5978 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5979 tdata->key.data, tdata->key.len,
5980 tdata->cipher_iv.len);
5984 /* Clear mbuf payload */
5986 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5988 /* Create ZUC operation */
5989 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5990 tdata->cipher_iv.len, tdata->plaintext.len,
5995 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5996 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5997 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5999 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6001 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6003 ut_params->obuf = ut_params->op->sym->m_dst;
6004 if (ut_params->obuf)
6005 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6006 0, plaintext_len, ciphertext_buffer);
6008 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6009 0, plaintext_len, ciphertext_buffer);
6012 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6015 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6017 tdata->ciphertext.data,
6018 tdata->validCipherLenInBits.len,
6019 "ZUC Ciphertext data not as expected");
6025 test_zuc_authentication(const struct wireless_test_data *tdata)
6027 struct crypto_testsuite_params *ts_params = &testsuite_params;
6028 struct crypto_unittest_params *ut_params = &unittest_params;
6031 unsigned plaintext_pad_len;
6032 unsigned plaintext_len;
6035 struct rte_cryptodev_sym_capability_idx cap_idx;
6036 struct rte_cryptodev_info dev_info;
6038 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6039 uint64_t feat_flags = dev_info.feature_flags;
6041 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6042 (tdata->validAuthLenInBits.len % 8 != 0)) {
6043 printf("Device doesn't support NON-Byte Aligned Data.\n");
6044 return TEST_SKIPPED;
6047 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6048 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6049 printf("Device doesn't support RAW data-path APIs.\n");
6050 return TEST_SKIPPED;
6053 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6054 return TEST_SKIPPED;
6056 /* Check if device supports ZUC EIA3 */
6057 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6058 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6060 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6062 return TEST_SKIPPED;
6064 /* Create ZUC session */
6065 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6066 tdata->key.data, tdata->key.len,
6067 tdata->auth_iv.len, tdata->digest.len,
6068 RTE_CRYPTO_AUTH_OP_GENERATE,
6069 RTE_CRYPTO_AUTH_ZUC_EIA3);
6073 /* alloc mbuf and set payload */
6074 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6076 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6077 rte_pktmbuf_tailroom(ut_params->ibuf));
6079 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6080 /* Append data which is padded to a multiple of */
6081 /* the algorithms block size */
6082 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6083 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6085 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6087 /* Create ZUC operation */
6088 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6089 tdata->auth_iv.data, tdata->auth_iv.len,
6090 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6091 tdata->validAuthLenInBits.len,
6096 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6097 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6098 ut_params->op, 0, 1, 1, 0);
6100 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6102 ut_params->obuf = ut_params->op->sym->m_src;
6103 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6104 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6105 + plaintext_pad_len;
6108 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6112 "ZUC Generated auth tag not as expected");
6118 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6119 uint8_t op_mode, uint8_t verify)
6121 struct crypto_testsuite_params *ts_params = &testsuite_params;
6122 struct crypto_unittest_params *ut_params = &unittest_params;
6126 uint8_t *plaintext = NULL, *ciphertext = NULL;
6127 unsigned int plaintext_pad_len;
6128 unsigned int plaintext_len;
6129 unsigned int ciphertext_pad_len;
6130 unsigned int ciphertext_len;
6132 struct rte_cryptodev_info dev_info;
6133 struct rte_cryptodev_sym_capability_idx cap_idx;
6135 /* Check if device supports ZUC EIA3 */
6136 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6137 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6139 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6141 return TEST_SKIPPED;
6143 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6145 uint64_t feat_flags = dev_info.feature_flags;
6147 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6148 printf("Device doesn't support digest encrypted.\n");
6149 return TEST_SKIPPED;
6151 if (op_mode == IN_PLACE) {
6152 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6153 printf("Device doesn't support in-place scatter-gather "
6154 "in both input and output mbufs.\n");
6155 return TEST_SKIPPED;
6158 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6159 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6160 printf("Device doesn't support RAW data-path APIs.\n");
6161 return TEST_SKIPPED;
6164 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6165 return TEST_SKIPPED;
6166 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6167 printf("Device doesn't support out-of-place scatter-gather "
6168 "in both input and output mbufs.\n");
6169 return TEST_SKIPPED;
6173 /* Create ZUC session */
6174 retval = create_wireless_algo_auth_cipher_session(
6175 ts_params->valid_devs[0],
6176 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6177 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6178 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6179 : RTE_CRYPTO_AUTH_OP_GENERATE),
6180 RTE_CRYPTO_AUTH_ZUC_EIA3,
6181 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6182 tdata->key.data, tdata->key.len,
6183 tdata->auth_iv.len, tdata->digest.len,
6184 tdata->cipher_iv.len);
6189 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6190 if (op_mode == OUT_OF_PLACE)
6191 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6193 /* clear mbuf payload */
6194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6195 rte_pktmbuf_tailroom(ut_params->ibuf));
6196 if (op_mode == OUT_OF_PLACE)
6197 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6198 rte_pktmbuf_tailroom(ut_params->obuf));
6200 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6201 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6202 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6203 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6206 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6207 ciphertext_pad_len);
6208 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6209 if (op_mode == OUT_OF_PLACE)
6210 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6211 debug_hexdump(stdout, "ciphertext:", ciphertext,
6214 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6216 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6217 if (op_mode == OUT_OF_PLACE)
6218 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6219 debug_hexdump(stdout, "plaintext:", plaintext,
6223 /* Create ZUC operation */
6224 retval = create_wireless_algo_auth_cipher_operation(
6225 tdata->digest.data, tdata->digest.len,
6226 tdata->cipher_iv.data, tdata->cipher_iv.len,
6227 tdata->auth_iv.data, tdata->auth_iv.len,
6228 (tdata->digest.offset_bytes == 0 ?
6229 (verify ? ciphertext_pad_len : plaintext_pad_len)
6230 : tdata->digest.offset_bytes),
6231 tdata->validCipherLenInBits.len,
6232 tdata->validCipherOffsetInBits.len,
6233 tdata->validAuthLenInBits.len,
6235 op_mode, 0, verify);
6240 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6241 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6242 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6244 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6247 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6249 ut_params->obuf = (op_mode == IN_PLACE ?
6250 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6254 if (ut_params->obuf)
6255 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6258 plaintext = ciphertext;
6260 debug_hexdump(stdout, "plaintext:", plaintext,
6261 (tdata->plaintext.len >> 3) - tdata->digest.len);
6262 debug_hexdump(stdout, "plaintext expected:",
6263 tdata->plaintext.data,
6264 (tdata->plaintext.len >> 3) - tdata->digest.len);
6266 if (ut_params->obuf)
6267 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6270 ciphertext = plaintext;
6272 debug_hexdump(stdout, "ciphertext:", ciphertext,
6274 debug_hexdump(stdout, "ciphertext expected:",
6275 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6277 ut_params->digest = rte_pktmbuf_mtod(
6278 ut_params->obuf, uint8_t *) +
6279 (tdata->digest.offset_bytes == 0 ?
6280 plaintext_pad_len : tdata->digest.offset_bytes);
6282 debug_hexdump(stdout, "digest:", ut_params->digest,
6284 debug_hexdump(stdout, "digest expected:",
6285 tdata->digest.data, tdata->digest.len);
6290 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6292 tdata->plaintext.data,
6293 tdata->plaintext.len >> 3,
6294 "ZUC Plaintext data not as expected");
6296 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6298 tdata->ciphertext.data,
6299 tdata->ciphertext.len >> 3,
6300 "ZUC Ciphertext data not as expected");
6302 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6305 DIGEST_BYTE_LENGTH_KASUMI_F9,
6306 "ZUC Generated auth tag not as expected");
6312 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6313 uint8_t op_mode, uint8_t verify)
6315 struct crypto_testsuite_params *ts_params = &testsuite_params;
6316 struct crypto_unittest_params *ut_params = &unittest_params;
6320 const uint8_t *plaintext = NULL;
6321 const uint8_t *ciphertext = NULL;
6322 const uint8_t *digest = NULL;
6323 unsigned int plaintext_pad_len;
6324 unsigned int plaintext_len;
6325 unsigned int ciphertext_pad_len;
6326 unsigned int ciphertext_len;
6327 uint8_t buffer[10000];
6328 uint8_t digest_buffer[10000];
6330 struct rte_cryptodev_info dev_info;
6331 struct rte_cryptodev_sym_capability_idx cap_idx;
6333 /* Check if device supports ZUC EIA3 */
6334 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6335 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6337 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6339 return TEST_SKIPPED;
6341 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6343 uint64_t feat_flags = dev_info.feature_flags;
6345 if (op_mode == IN_PLACE) {
6346 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6347 printf("Device doesn't support in-place scatter-gather "
6348 "in both input and output mbufs.\n");
6349 return TEST_SKIPPED;
6352 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6353 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6354 printf("Device doesn't support RAW data-path APIs.\n");
6355 return TEST_SKIPPED;
6358 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6359 return TEST_SKIPPED;
6360 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6361 printf("Device doesn't support out-of-place scatter-gather "
6362 "in both input and output mbufs.\n");
6363 return TEST_SKIPPED;
6365 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6366 printf("Device doesn't support digest encrypted.\n");
6367 return TEST_SKIPPED;
6371 /* Create ZUC session */
6372 retval = create_wireless_algo_auth_cipher_session(
6373 ts_params->valid_devs[0],
6374 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6375 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6376 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6377 : RTE_CRYPTO_AUTH_OP_GENERATE),
6378 RTE_CRYPTO_AUTH_ZUC_EIA3,
6379 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6380 tdata->key.data, tdata->key.len,
6381 tdata->auth_iv.len, tdata->digest.len,
6382 tdata->cipher_iv.len);
6387 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6388 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6389 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6390 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6392 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6393 plaintext_pad_len, 15, 0);
6394 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6395 "Failed to allocate input buffer in mempool");
6397 if (op_mode == OUT_OF_PLACE) {
6398 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6399 plaintext_pad_len, 15, 0);
6400 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6401 "Failed to allocate output buffer in mempool");
6405 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6406 tdata->ciphertext.data);
6407 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6408 ciphertext_len, buffer);
6409 debug_hexdump(stdout, "ciphertext:", ciphertext,
6412 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6413 tdata->plaintext.data);
6414 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6415 plaintext_len, buffer);
6416 debug_hexdump(stdout, "plaintext:", plaintext,
6419 memset(buffer, 0, sizeof(buffer));
6421 /* Create ZUC operation */
6422 retval = create_wireless_algo_auth_cipher_operation(
6423 tdata->digest.data, tdata->digest.len,
6424 tdata->cipher_iv.data, tdata->cipher_iv.len,
6426 (tdata->digest.offset_bytes == 0 ?
6427 (verify ? ciphertext_pad_len : plaintext_pad_len)
6428 : tdata->digest.offset_bytes),
6429 tdata->validCipherLenInBits.len,
6430 tdata->validCipherOffsetInBits.len,
6431 tdata->validAuthLenInBits.len,
6433 op_mode, 1, verify);
6438 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6439 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6440 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6442 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6445 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6447 ut_params->obuf = (op_mode == IN_PLACE ?
6448 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6451 if (ut_params->obuf)
6452 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6453 plaintext_len, buffer);
6455 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6456 plaintext_len, buffer);
6458 debug_hexdump(stdout, "plaintext:", plaintext,
6459 (tdata->plaintext.len >> 3) - tdata->digest.len);
6460 debug_hexdump(stdout, "plaintext expected:",
6461 tdata->plaintext.data,
6462 (tdata->plaintext.len >> 3) - tdata->digest.len);
6464 if (ut_params->obuf)
6465 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6466 ciphertext_len, buffer);
6468 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6469 ciphertext_len, buffer);
6471 debug_hexdump(stdout, "ciphertext:", ciphertext,
6473 debug_hexdump(stdout, "ciphertext expected:",
6474 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6476 if (ut_params->obuf)
6477 digest = rte_pktmbuf_read(ut_params->obuf,
6478 (tdata->digest.offset_bytes == 0 ?
6479 plaintext_pad_len : tdata->digest.offset_bytes),
6480 tdata->digest.len, digest_buffer);
6482 digest = rte_pktmbuf_read(ut_params->ibuf,
6483 (tdata->digest.offset_bytes == 0 ?
6484 plaintext_pad_len : tdata->digest.offset_bytes),
6485 tdata->digest.len, digest_buffer);
6487 debug_hexdump(stdout, "digest:", digest,
6489 debug_hexdump(stdout, "digest expected:",
6490 tdata->digest.data, tdata->digest.len);
6495 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6497 tdata->plaintext.data,
6498 tdata->plaintext.len >> 3,
6499 "ZUC Plaintext data not as expected");
6501 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6503 tdata->ciphertext.data,
6504 tdata->validDataLenInBits.len,
6505 "ZUC Ciphertext data not as expected");
6507 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6510 DIGEST_BYTE_LENGTH_KASUMI_F9,
6511 "ZUC Generated auth tag not as expected");
6517 test_kasumi_encryption_test_case_1(void)
6519 return test_kasumi_encryption(&kasumi_test_case_1);
6523 test_kasumi_encryption_test_case_1_sgl(void)
6525 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6529 test_kasumi_encryption_test_case_1_oop(void)
6531 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6535 test_kasumi_encryption_test_case_1_oop_sgl(void)
6537 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6541 test_kasumi_encryption_test_case_2(void)
6543 return test_kasumi_encryption(&kasumi_test_case_2);
6547 test_kasumi_encryption_test_case_3(void)
6549 return test_kasumi_encryption(&kasumi_test_case_3);
6553 test_kasumi_encryption_test_case_4(void)
6555 return test_kasumi_encryption(&kasumi_test_case_4);
6559 test_kasumi_encryption_test_case_5(void)
6561 return test_kasumi_encryption(&kasumi_test_case_5);
6565 test_kasumi_decryption_test_case_1(void)
6567 return test_kasumi_decryption(&kasumi_test_case_1);
6571 test_kasumi_decryption_test_case_1_oop(void)
6573 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6577 test_kasumi_decryption_test_case_2(void)
6579 return test_kasumi_decryption(&kasumi_test_case_2);
6583 test_kasumi_decryption_test_case_3(void)
6585 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6586 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6587 return TEST_SKIPPED;
6588 return test_kasumi_decryption(&kasumi_test_case_3);
6592 test_kasumi_decryption_test_case_4(void)
6594 return test_kasumi_decryption(&kasumi_test_case_4);
6598 test_kasumi_decryption_test_case_5(void)
6600 return test_kasumi_decryption(&kasumi_test_case_5);
6603 test_snow3g_encryption_test_case_1(void)
6605 return test_snow3g_encryption(&snow3g_test_case_1);
6609 test_snow3g_encryption_test_case_1_oop(void)
6611 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6615 test_snow3g_encryption_test_case_1_oop_sgl(void)
6617 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6622 test_snow3g_encryption_test_case_1_offset_oop(void)
6624 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6628 test_snow3g_encryption_test_case_2(void)
6630 return test_snow3g_encryption(&snow3g_test_case_2);
6634 test_snow3g_encryption_test_case_3(void)
6636 return test_snow3g_encryption(&snow3g_test_case_3);
6640 test_snow3g_encryption_test_case_4(void)
6642 return test_snow3g_encryption(&snow3g_test_case_4);
6646 test_snow3g_encryption_test_case_5(void)
6648 return test_snow3g_encryption(&snow3g_test_case_5);
6652 test_snow3g_decryption_test_case_1(void)
6654 return test_snow3g_decryption(&snow3g_test_case_1);
6658 test_snow3g_decryption_test_case_1_oop(void)
6660 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6664 test_snow3g_decryption_test_case_2(void)
6666 return test_snow3g_decryption(&snow3g_test_case_2);
6670 test_snow3g_decryption_test_case_3(void)
6672 return test_snow3g_decryption(&snow3g_test_case_3);
6676 test_snow3g_decryption_test_case_4(void)
6678 return test_snow3g_decryption(&snow3g_test_case_4);
6682 test_snow3g_decryption_test_case_5(void)
6684 return test_snow3g_decryption(&snow3g_test_case_5);
6688 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6689 * Pattern digest from snow3g_test_data must be allocated as
6690 * 4 last bytes in plaintext.
6693 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6694 struct snow3g_hash_test_data *output)
6696 if ((pattern != NULL) && (output != NULL)) {
6697 output->key.len = pattern->key.len;
6699 memcpy(output->key.data,
6700 pattern->key.data, pattern->key.len);
6702 output->auth_iv.len = pattern->auth_iv.len;
6704 memcpy(output->auth_iv.data,
6705 pattern->auth_iv.data, pattern->auth_iv.len);
6707 output->plaintext.len = pattern->plaintext.len;
6709 memcpy(output->plaintext.data,
6710 pattern->plaintext.data, pattern->plaintext.len >> 3);
6712 output->digest.len = pattern->digest.len;
6714 memcpy(output->digest.data,
6715 &pattern->plaintext.data[pattern->digest.offset_bytes],
6716 pattern->digest.len);
6718 output->validAuthLenInBits.len =
6719 pattern->validAuthLenInBits.len;
6724 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6727 test_snow3g_decryption_with_digest_test_case_1(void)
6729 struct snow3g_hash_test_data snow3g_hash_data;
6730 struct rte_cryptodev_info dev_info;
6731 struct crypto_testsuite_params *ts_params = &testsuite_params;
6733 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6734 uint64_t feat_flags = dev_info.feature_flags;
6736 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6737 printf("Device doesn't support encrypted digest operations.\n");
6738 return TEST_SKIPPED;
6742 * Function prepare data for hash veryfication test case.
6743 * Digest is allocated in 4 last bytes in plaintext, pattern.
6745 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6747 return test_snow3g_decryption(&snow3g_test_case_7) &
6748 test_snow3g_authentication_verify(&snow3g_hash_data);
6752 test_snow3g_cipher_auth_test_case_1(void)
6754 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6758 test_snow3g_auth_cipher_test_case_1(void)
6760 return test_snow3g_auth_cipher(
6761 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6765 test_snow3g_auth_cipher_test_case_2(void)
6767 return test_snow3g_auth_cipher(
6768 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6772 test_snow3g_auth_cipher_test_case_2_oop(void)
6774 return test_snow3g_auth_cipher(
6775 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6779 test_snow3g_auth_cipher_part_digest_enc(void)
6781 return test_snow3g_auth_cipher(
6782 &snow3g_auth_cipher_partial_digest_encryption,
6787 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6789 return test_snow3g_auth_cipher(
6790 &snow3g_auth_cipher_partial_digest_encryption,
6795 test_snow3g_auth_cipher_test_case_3_sgl(void)
6797 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6798 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6799 return TEST_SKIPPED;
6800 return test_snow3g_auth_cipher_sgl(
6801 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6805 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6807 return test_snow3g_auth_cipher_sgl(
6808 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6812 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6814 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6815 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6816 return TEST_SKIPPED;
6817 return test_snow3g_auth_cipher_sgl(
6818 &snow3g_auth_cipher_partial_digest_encryption,
6823 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6825 return test_snow3g_auth_cipher_sgl(
6826 &snow3g_auth_cipher_partial_digest_encryption,
6831 test_snow3g_auth_cipher_verify_test_case_1(void)
6833 return test_snow3g_auth_cipher(
6834 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6838 test_snow3g_auth_cipher_verify_test_case_2(void)
6840 return test_snow3g_auth_cipher(
6841 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6845 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6847 return test_snow3g_auth_cipher(
6848 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6852 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6854 return test_snow3g_auth_cipher(
6855 &snow3g_auth_cipher_partial_digest_encryption,
6860 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6862 return test_snow3g_auth_cipher(
6863 &snow3g_auth_cipher_partial_digest_encryption,
6868 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6870 return test_snow3g_auth_cipher_sgl(
6871 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6875 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6877 return test_snow3g_auth_cipher_sgl(
6878 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6882 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6884 return test_snow3g_auth_cipher_sgl(
6885 &snow3g_auth_cipher_partial_digest_encryption,
6890 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6892 return test_snow3g_auth_cipher_sgl(
6893 &snow3g_auth_cipher_partial_digest_encryption,
6898 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6900 return test_snow3g_auth_cipher(
6901 &snow3g_test_case_7, IN_PLACE, 0);
6905 test_kasumi_auth_cipher_test_case_1(void)
6907 return test_kasumi_auth_cipher(
6908 &kasumi_test_case_3, IN_PLACE, 0);
6912 test_kasumi_auth_cipher_test_case_2(void)
6914 return test_kasumi_auth_cipher(
6915 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6919 test_kasumi_auth_cipher_test_case_2_oop(void)
6921 return test_kasumi_auth_cipher(
6922 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6926 test_kasumi_auth_cipher_test_case_2_sgl(void)
6928 return test_kasumi_auth_cipher_sgl(
6929 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6933 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6935 return test_kasumi_auth_cipher_sgl(
6936 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6940 test_kasumi_auth_cipher_verify_test_case_1(void)
6942 return test_kasumi_auth_cipher(
6943 &kasumi_test_case_3, IN_PLACE, 1);
6947 test_kasumi_auth_cipher_verify_test_case_2(void)
6949 return test_kasumi_auth_cipher(
6950 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6954 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6956 return test_kasumi_auth_cipher(
6957 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6961 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6963 return test_kasumi_auth_cipher_sgl(
6964 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6968 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6970 return test_kasumi_auth_cipher_sgl(
6971 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6975 test_kasumi_cipher_auth_test_case_1(void)
6977 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6981 test_zuc_encryption_test_case_1(void)
6983 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6987 test_zuc_encryption_test_case_2(void)
6989 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6993 test_zuc_encryption_test_case_3(void)
6995 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6999 test_zuc_encryption_test_case_4(void)
7001 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7005 test_zuc_encryption_test_case_5(void)
7007 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7011 test_zuc_encryption_test_case_6_sgl(void)
7013 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7017 test_zuc_encryption_test_case_7(void)
7019 return test_zuc_encryption(&zuc_test_case_cipher_800b_key_256b);
7023 test_zuc_hash_generate_test_case_1(void)
7025 return test_zuc_authentication(&zuc_test_case_auth_1b);
7029 test_zuc_hash_generate_test_case_2(void)
7031 return test_zuc_authentication(&zuc_test_case_auth_90b);
7035 test_zuc_hash_generate_test_case_3(void)
7037 return test_zuc_authentication(&zuc_test_case_auth_577b);
7041 test_zuc_hash_generate_test_case_4(void)
7043 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7047 test_zuc_hash_generate_test_case_5(void)
7049 return test_zuc_authentication(&zuc_test_auth_5670b);
7053 test_zuc_hash_generate_test_case_6(void)
7055 return test_zuc_authentication(&zuc_test_case_auth_128b);
7059 test_zuc_hash_generate_test_case_7(void)
7061 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7065 test_zuc_hash_generate_test_case_8(void)
7067 return test_zuc_authentication(&zuc_test_case_auth_584b);
7071 test_zuc_hash_generate_test_case_9(void)
7073 return test_zuc_authentication(&zuc_test_case_auth_584b_mac_64b);
7077 test_zuc_hash_generate_test_case_10(void)
7079 return test_zuc_authentication(&zuc_test_case_auth_2080b_mac_128b);
7083 test_zuc_cipher_auth_test_case_1(void)
7085 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7089 test_zuc_cipher_auth_test_case_2(void)
7091 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7095 test_zuc_auth_cipher_test_case_1(void)
7097 return test_zuc_auth_cipher(
7098 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7102 test_zuc_auth_cipher_test_case_1_oop(void)
7104 return test_zuc_auth_cipher(
7105 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7109 test_zuc_auth_cipher_test_case_1_sgl(void)
7111 return test_zuc_auth_cipher_sgl(
7112 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7116 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7118 return test_zuc_auth_cipher_sgl(
7119 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7123 test_zuc_auth_cipher_verify_test_case_1(void)
7125 return test_zuc_auth_cipher(
7126 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7130 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7132 return test_zuc_auth_cipher(
7133 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7137 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7139 return test_zuc_auth_cipher_sgl(
7140 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7144 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7146 return test_zuc_auth_cipher_sgl(
7147 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7151 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7153 uint8_t dev_id = testsuite_params.valid_devs[0];
7155 struct rte_cryptodev_sym_capability_idx cap_idx;
7157 /* Check if device supports particular cipher algorithm */
7158 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7159 cap_idx.algo.cipher = tdata->cipher_algo;
7160 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7161 return TEST_SKIPPED;
7163 /* Check if device supports particular hash algorithm */
7164 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7165 cap_idx.algo.auth = tdata->auth_algo;
7166 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7167 return TEST_SKIPPED;
7173 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7174 uint8_t op_mode, uint8_t verify)
7176 struct crypto_testsuite_params *ts_params = &testsuite_params;
7177 struct crypto_unittest_params *ut_params = &unittest_params;
7181 uint8_t *plaintext = NULL, *ciphertext = NULL;
7182 unsigned int plaintext_pad_len;
7183 unsigned int plaintext_len;
7184 unsigned int ciphertext_pad_len;
7185 unsigned int ciphertext_len;
7187 struct rte_cryptodev_info dev_info;
7188 struct rte_crypto_op *op;
7190 /* Check if device supports particular algorithms separately */
7191 if (test_mixed_check_if_unsupported(tdata))
7192 return TEST_SKIPPED;
7193 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7194 return TEST_SKIPPED;
7196 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7198 uint64_t feat_flags = dev_info.feature_flags;
7200 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7201 printf("Device doesn't support digest encrypted.\n");
7202 return TEST_SKIPPED;
7205 /* Create the session */
7207 retval = create_wireless_algo_cipher_auth_session(
7208 ts_params->valid_devs[0],
7209 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7210 RTE_CRYPTO_AUTH_OP_VERIFY,
7213 tdata->auth_key.data, tdata->auth_key.len,
7214 tdata->auth_iv.len, tdata->digest_enc.len,
7215 tdata->cipher_iv.len);
7217 retval = create_wireless_algo_auth_cipher_session(
7218 ts_params->valid_devs[0],
7219 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7220 RTE_CRYPTO_AUTH_OP_GENERATE,
7223 tdata->auth_key.data, tdata->auth_key.len,
7224 tdata->auth_iv.len, tdata->digest_enc.len,
7225 tdata->cipher_iv.len);
7229 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7230 if (op_mode == OUT_OF_PLACE)
7231 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7233 /* clear mbuf payload */
7234 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7235 rte_pktmbuf_tailroom(ut_params->ibuf));
7236 if (op_mode == OUT_OF_PLACE) {
7238 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7239 rte_pktmbuf_tailroom(ut_params->obuf));
7242 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7243 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7244 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7245 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7248 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7249 ciphertext_pad_len);
7250 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7251 if (op_mode == OUT_OF_PLACE)
7252 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7253 debug_hexdump(stdout, "ciphertext:", ciphertext,
7256 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7258 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7259 if (op_mode == OUT_OF_PLACE)
7260 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7261 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7264 /* Create the operation */
7265 retval = create_wireless_algo_auth_cipher_operation(
7266 tdata->digest_enc.data, tdata->digest_enc.len,
7267 tdata->cipher_iv.data, tdata->cipher_iv.len,
7268 tdata->auth_iv.data, tdata->auth_iv.len,
7269 (tdata->digest_enc.offset == 0 ?
7271 : tdata->digest_enc.offset),
7272 tdata->validCipherLen.len_bits,
7273 tdata->cipher.offset_bits,
7274 tdata->validAuthLen.len_bits,
7275 tdata->auth.offset_bits,
7276 op_mode, 0, verify);
7281 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7283 /* Check if the op failed because the device doesn't */
7284 /* support this particular combination of algorithms */
7285 if (op == NULL && ut_params->op->status ==
7286 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7287 printf("Device doesn't support this mixed combination. "
7289 return TEST_SKIPPED;
7293 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7295 ut_params->obuf = (op_mode == IN_PLACE ?
7296 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7299 if (ut_params->obuf)
7300 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7303 plaintext = ciphertext +
7304 (tdata->cipher.offset_bits >> 3);
7306 debug_hexdump(stdout, "plaintext:", plaintext,
7307 tdata->plaintext.len_bits >> 3);
7308 debug_hexdump(stdout, "plaintext expected:",
7309 tdata->plaintext.data,
7310 tdata->plaintext.len_bits >> 3);
7312 if (ut_params->obuf)
7313 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7316 ciphertext = plaintext;
7318 debug_hexdump(stdout, "ciphertext:", ciphertext,
7320 debug_hexdump(stdout, "ciphertext expected:",
7321 tdata->ciphertext.data,
7322 tdata->ciphertext.len_bits >> 3);
7324 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7325 + (tdata->digest_enc.offset == 0 ?
7326 plaintext_pad_len : tdata->digest_enc.offset);
7328 debug_hexdump(stdout, "digest:", ut_params->digest,
7329 tdata->digest_enc.len);
7330 debug_hexdump(stdout, "digest expected:",
7331 tdata->digest_enc.data,
7332 tdata->digest_enc.len);
7337 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7339 tdata->plaintext.data,
7340 tdata->plaintext.len_bits >> 3,
7341 "Plaintext data not as expected");
7343 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7345 tdata->ciphertext.data,
7346 tdata->validDataLen.len_bits,
7347 "Ciphertext data not as expected");
7349 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7351 tdata->digest_enc.data,
7352 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7353 "Generated auth tag not as expected");
7356 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7357 "crypto op processing failed");
7363 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7364 uint8_t op_mode, uint8_t verify)
7366 struct crypto_testsuite_params *ts_params = &testsuite_params;
7367 struct crypto_unittest_params *ut_params = &unittest_params;
7371 const uint8_t *plaintext = NULL;
7372 const uint8_t *ciphertext = NULL;
7373 const uint8_t *digest = NULL;
7374 unsigned int plaintext_pad_len;
7375 unsigned int plaintext_len;
7376 unsigned int ciphertext_pad_len;
7377 unsigned int ciphertext_len;
7378 uint8_t buffer[10000];
7379 uint8_t digest_buffer[10000];
7381 struct rte_cryptodev_info dev_info;
7382 struct rte_crypto_op *op;
7384 /* Check if device supports particular algorithms */
7385 if (test_mixed_check_if_unsupported(tdata))
7386 return TEST_SKIPPED;
7387 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7388 return TEST_SKIPPED;
7390 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7392 uint64_t feat_flags = dev_info.feature_flags;
7394 if (op_mode == IN_PLACE) {
7395 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7396 printf("Device doesn't support in-place scatter-gather "
7397 "in both input and output mbufs.\n");
7398 return TEST_SKIPPED;
7401 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7402 printf("Device doesn't support out-of-place scatter-gather "
7403 "in both input and output mbufs.\n");
7404 return TEST_SKIPPED;
7406 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7407 printf("Device doesn't support digest encrypted.\n");
7408 return TEST_SKIPPED;
7412 /* Create the session */
7414 retval = create_wireless_algo_cipher_auth_session(
7415 ts_params->valid_devs[0],
7416 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7417 RTE_CRYPTO_AUTH_OP_VERIFY,
7420 tdata->auth_key.data, tdata->auth_key.len,
7421 tdata->auth_iv.len, tdata->digest_enc.len,
7422 tdata->cipher_iv.len);
7424 retval = create_wireless_algo_auth_cipher_session(
7425 ts_params->valid_devs[0],
7426 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7427 RTE_CRYPTO_AUTH_OP_GENERATE,
7430 tdata->auth_key.data, tdata->auth_key.len,
7431 tdata->auth_iv.len, tdata->digest_enc.len,
7432 tdata->cipher_iv.len);
7436 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7437 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7438 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7439 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7441 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7442 ciphertext_pad_len, 15, 0);
7443 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7444 "Failed to allocate input buffer in mempool");
7446 if (op_mode == OUT_OF_PLACE) {
7447 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7448 plaintext_pad_len, 15, 0);
7449 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7450 "Failed to allocate output buffer in mempool");
7454 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7455 tdata->ciphertext.data);
7456 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7457 ciphertext_len, buffer);
7458 debug_hexdump(stdout, "ciphertext:", ciphertext,
7461 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7462 tdata->plaintext.data);
7463 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7464 plaintext_len, buffer);
7465 debug_hexdump(stdout, "plaintext:", plaintext,
7468 memset(buffer, 0, sizeof(buffer));
7470 /* Create the operation */
7471 retval = create_wireless_algo_auth_cipher_operation(
7472 tdata->digest_enc.data, tdata->digest_enc.len,
7473 tdata->cipher_iv.data, tdata->cipher_iv.len,
7474 tdata->auth_iv.data, tdata->auth_iv.len,
7475 (tdata->digest_enc.offset == 0 ?
7477 : tdata->digest_enc.offset),
7478 tdata->validCipherLen.len_bits,
7479 tdata->cipher.offset_bits,
7480 tdata->validAuthLen.len_bits,
7481 tdata->auth.offset_bits,
7482 op_mode, 1, verify);
7487 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7489 /* Check if the op failed because the device doesn't */
7490 /* support this particular combination of algorithms */
7491 if (op == NULL && ut_params->op->status ==
7492 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7493 printf("Device doesn't support this mixed combination. "
7495 return TEST_SKIPPED;
7499 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7501 ut_params->obuf = (op_mode == IN_PLACE ?
7502 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7505 if (ut_params->obuf)
7506 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7507 plaintext_len, buffer);
7509 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7510 plaintext_len, buffer);
7512 debug_hexdump(stdout, "plaintext:", plaintext,
7513 (tdata->plaintext.len_bits >> 3) -
7514 tdata->digest_enc.len);
7515 debug_hexdump(stdout, "plaintext expected:",
7516 tdata->plaintext.data,
7517 (tdata->plaintext.len_bits >> 3) -
7518 tdata->digest_enc.len);
7520 if (ut_params->obuf)
7521 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7522 ciphertext_len, buffer);
7524 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7525 ciphertext_len, buffer);
7527 debug_hexdump(stdout, "ciphertext:", ciphertext,
7529 debug_hexdump(stdout, "ciphertext expected:",
7530 tdata->ciphertext.data,
7531 tdata->ciphertext.len_bits >> 3);
7533 if (ut_params->obuf)
7534 digest = rte_pktmbuf_read(ut_params->obuf,
7535 (tdata->digest_enc.offset == 0 ?
7537 tdata->digest_enc.offset),
7538 tdata->digest_enc.len, digest_buffer);
7540 digest = rte_pktmbuf_read(ut_params->ibuf,
7541 (tdata->digest_enc.offset == 0 ?
7543 tdata->digest_enc.offset),
7544 tdata->digest_enc.len, digest_buffer);
7546 debug_hexdump(stdout, "digest:", digest,
7547 tdata->digest_enc.len);
7548 debug_hexdump(stdout, "digest expected:",
7549 tdata->digest_enc.data, tdata->digest_enc.len);
7554 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7556 tdata->plaintext.data,
7557 tdata->plaintext.len_bits >> 3,
7558 "Plaintext data not as expected");
7560 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7562 tdata->ciphertext.data,
7563 tdata->validDataLen.len_bits,
7564 "Ciphertext data not as expected");
7565 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7567 tdata->digest_enc.data,
7568 tdata->digest_enc.len,
7569 "Generated auth tag not as expected");
7572 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7573 "crypto op processing failed");
7578 /** AUTH AES CMAC + CIPHER AES CTR */
7581 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7583 return test_mixed_auth_cipher(
7584 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7588 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7590 return test_mixed_auth_cipher(
7591 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7595 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7597 return test_mixed_auth_cipher_sgl(
7598 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7602 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7604 return test_mixed_auth_cipher_sgl(
7605 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7609 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7611 return test_mixed_auth_cipher(
7612 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7616 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7618 return test_mixed_auth_cipher(
7619 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7623 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7625 return test_mixed_auth_cipher_sgl(
7626 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7630 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7632 return test_mixed_auth_cipher_sgl(
7633 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7636 /** MIXED AUTH + CIPHER */
7639 test_auth_zuc_cipher_snow_test_case_1(void)
7641 return test_mixed_auth_cipher(
7642 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7646 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7648 return test_mixed_auth_cipher(
7649 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7653 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7655 return test_mixed_auth_cipher(
7656 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7660 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7662 return test_mixed_auth_cipher(
7663 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7667 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7669 return test_mixed_auth_cipher(
7670 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7674 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7676 return test_mixed_auth_cipher(
7677 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7681 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7683 return test_mixed_auth_cipher(
7684 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7688 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7690 return test_mixed_auth_cipher(
7691 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7695 test_auth_snow_cipher_zuc_test_case_1(void)
7697 return test_mixed_auth_cipher(
7698 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7702 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7704 return test_mixed_auth_cipher(
7705 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7709 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7711 return test_mixed_auth_cipher(
7712 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7716 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7718 return test_mixed_auth_cipher(
7719 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7723 test_auth_null_cipher_snow_test_case_1(void)
7725 return test_mixed_auth_cipher(
7726 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7730 test_verify_auth_null_cipher_snow_test_case_1(void)
7732 return test_mixed_auth_cipher(
7733 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7737 test_auth_null_cipher_zuc_test_case_1(void)
7739 return test_mixed_auth_cipher(
7740 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7744 test_verify_auth_null_cipher_zuc_test_case_1(void)
7746 return test_mixed_auth_cipher(
7747 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7751 test_auth_snow_cipher_null_test_case_1(void)
7753 return test_mixed_auth_cipher(
7754 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7758 test_verify_auth_snow_cipher_null_test_case_1(void)
7760 return test_mixed_auth_cipher(
7761 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7765 test_auth_zuc_cipher_null_test_case_1(void)
7767 return test_mixed_auth_cipher(
7768 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7772 test_verify_auth_zuc_cipher_null_test_case_1(void)
7774 return test_mixed_auth_cipher(
7775 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7779 test_auth_null_cipher_aes_ctr_test_case_1(void)
7781 return test_mixed_auth_cipher(
7782 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7786 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7788 return test_mixed_auth_cipher(
7789 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7793 test_auth_aes_cmac_cipher_null_test_case_1(void)
7795 return test_mixed_auth_cipher(
7796 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7800 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7802 return test_mixed_auth_cipher(
7803 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7806 /* ***** AEAD algorithm Tests ***** */
7809 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7810 enum rte_crypto_aead_operation op,
7811 const uint8_t *key, const uint8_t key_len,
7812 const uint16_t aad_len, const uint8_t auth_len,
7815 uint8_t aead_key[key_len];
7817 struct crypto_testsuite_params *ts_params = &testsuite_params;
7818 struct crypto_unittest_params *ut_params = &unittest_params;
7820 memcpy(aead_key, key, key_len);
7822 /* Setup AEAD Parameters */
7823 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7824 ut_params->aead_xform.next = NULL;
7825 ut_params->aead_xform.aead.algo = algo;
7826 ut_params->aead_xform.aead.op = op;
7827 ut_params->aead_xform.aead.key.data = aead_key;
7828 ut_params->aead_xform.aead.key.length = key_len;
7829 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7830 ut_params->aead_xform.aead.iv.length = iv_len;
7831 ut_params->aead_xform.aead.digest_length = auth_len;
7832 ut_params->aead_xform.aead.aad_length = aad_len;
7834 debug_hexdump(stdout, "key:", key, key_len);
7836 /* Create Crypto session*/
7837 ut_params->sess = rte_cryptodev_sym_session_create(
7838 ts_params->session_mpool);
7840 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7841 &ut_params->aead_xform,
7842 ts_params->session_priv_mpool);
7844 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7850 create_aead_xform(struct rte_crypto_op *op,
7851 enum rte_crypto_aead_algorithm algo,
7852 enum rte_crypto_aead_operation aead_op,
7853 uint8_t *key, const uint8_t key_len,
7854 const uint8_t aad_len, const uint8_t auth_len,
7857 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7858 "failed to allocate space for crypto transform");
7860 struct rte_crypto_sym_op *sym_op = op->sym;
7862 /* Setup AEAD Parameters */
7863 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7864 sym_op->xform->next = NULL;
7865 sym_op->xform->aead.algo = algo;
7866 sym_op->xform->aead.op = aead_op;
7867 sym_op->xform->aead.key.data = key;
7868 sym_op->xform->aead.key.length = key_len;
7869 sym_op->xform->aead.iv.offset = IV_OFFSET;
7870 sym_op->xform->aead.iv.length = iv_len;
7871 sym_op->xform->aead.digest_length = auth_len;
7872 sym_op->xform->aead.aad_length = aad_len;
7874 debug_hexdump(stdout, "key:", key, key_len);
7880 create_aead_operation(enum rte_crypto_aead_operation op,
7881 const struct aead_test_data *tdata)
7883 struct crypto_testsuite_params *ts_params = &testsuite_params;
7884 struct crypto_unittest_params *ut_params = &unittest_params;
7886 uint8_t *plaintext, *ciphertext;
7887 unsigned int aad_pad_len, plaintext_pad_len;
7889 /* Generate Crypto op data structure */
7890 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7891 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7892 TEST_ASSERT_NOT_NULL(ut_params->op,
7893 "Failed to allocate symmetric crypto operation struct");
7895 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7897 /* Append aad data */
7898 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7899 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7900 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7902 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7903 "no room to append aad");
7905 sym_op->aead.aad.phys_addr =
7906 rte_pktmbuf_iova(ut_params->ibuf);
7907 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7908 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7909 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7912 /* Append IV at the end of the crypto operation*/
7913 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7914 uint8_t *, IV_OFFSET);
7916 /* Copy IV 1 byte after the IV pointer, according to the API */
7917 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7918 debug_hexdump(stdout, "iv:", iv_ptr,
7921 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7922 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7924 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7925 "no room to append aad");
7927 sym_op->aead.aad.phys_addr =
7928 rte_pktmbuf_iova(ut_params->ibuf);
7929 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7930 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7933 /* Append IV at the end of the crypto operation*/
7934 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7935 uint8_t *, IV_OFFSET);
7937 if (tdata->iv.len == 0) {
7938 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7939 debug_hexdump(stdout, "iv:", iv_ptr,
7942 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7943 debug_hexdump(stdout, "iv:", iv_ptr,
7948 /* Append plaintext/ciphertext */
7949 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7950 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7951 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7953 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7955 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7956 debug_hexdump(stdout, "plaintext:", plaintext,
7957 tdata->plaintext.len);
7959 if (ut_params->obuf) {
7960 ciphertext = (uint8_t *)rte_pktmbuf_append(
7962 plaintext_pad_len + aad_pad_len);
7963 TEST_ASSERT_NOT_NULL(ciphertext,
7964 "no room to append ciphertext");
7966 memset(ciphertext + aad_pad_len, 0,
7967 tdata->ciphertext.len);
7970 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7971 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7973 TEST_ASSERT_NOT_NULL(ciphertext,
7974 "no room to append ciphertext");
7976 memcpy(ciphertext, tdata->ciphertext.data,
7977 tdata->ciphertext.len);
7978 debug_hexdump(stdout, "ciphertext:", ciphertext,
7979 tdata->ciphertext.len);
7981 if (ut_params->obuf) {
7982 plaintext = (uint8_t *)rte_pktmbuf_append(
7984 plaintext_pad_len + aad_pad_len);
7985 TEST_ASSERT_NOT_NULL(plaintext,
7986 "no room to append plaintext");
7988 memset(plaintext + aad_pad_len, 0,
7989 tdata->plaintext.len);
7993 /* Append digest data */
7994 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7995 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7996 ut_params->obuf ? ut_params->obuf :
7998 tdata->auth_tag.len);
7999 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8000 "no room to append digest");
8001 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8002 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8003 ut_params->obuf ? ut_params->obuf :
8008 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8009 ut_params->ibuf, tdata->auth_tag.len);
8010 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8011 "no room to append digest");
8012 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8014 plaintext_pad_len + aad_pad_len);
8016 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8017 tdata->auth_tag.len);
8018 debug_hexdump(stdout, "digest:",
8019 sym_op->aead.digest.data,
8020 tdata->auth_tag.len);
8023 sym_op->aead.data.length = tdata->plaintext.len;
8024 sym_op->aead.data.offset = aad_pad_len;
8030 test_authenticated_encryption(const struct aead_test_data *tdata)
8032 struct crypto_testsuite_params *ts_params = &testsuite_params;
8033 struct crypto_unittest_params *ut_params = &unittest_params;
8036 uint8_t *ciphertext, *auth_tag;
8037 uint16_t plaintext_pad_len;
8039 struct rte_cryptodev_info dev_info;
8041 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8042 uint64_t feat_flags = dev_info.feature_flags;
8044 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8045 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8046 printf("Device doesn't support RAW data-path APIs.\n");
8047 return TEST_SKIPPED;
8050 /* Verify the capabilities */
8051 struct rte_cryptodev_sym_capability_idx cap_idx;
8052 const struct rte_cryptodev_symmetric_capability *capability;
8053 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8054 cap_idx.algo.aead = tdata->algo;
8055 capability = rte_cryptodev_sym_capability_get(
8056 ts_params->valid_devs[0], &cap_idx);
8057 if (capability == NULL)
8058 return TEST_SKIPPED;
8059 if (rte_cryptodev_sym_capability_check_aead(
8060 capability, tdata->key.len, tdata->auth_tag.len,
8061 tdata->aad.len, tdata->iv.len))
8062 return TEST_SKIPPED;
8064 /* Create AEAD session */
8065 retval = create_aead_session(ts_params->valid_devs[0],
8067 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8068 tdata->key.data, tdata->key.len,
8069 tdata->aad.len, tdata->auth_tag.len,
8074 if (tdata->aad.len > MBUF_SIZE) {
8075 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8076 /* Populate full size of add data */
8077 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8078 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8080 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8082 /* clear mbuf payload */
8083 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8084 rte_pktmbuf_tailroom(ut_params->ibuf));
8086 /* Create AEAD operation */
8087 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8091 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8093 ut_params->op->sym->m_src = ut_params->ibuf;
8095 /* Process crypto operation */
8096 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8097 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8098 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8099 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8100 ut_params->op, 0, 0, 0, 0);
8102 TEST_ASSERT_NOT_NULL(
8103 process_crypto_request(ts_params->valid_devs[0],
8104 ut_params->op), "failed to process sym crypto op");
8106 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8107 "crypto op processing failed");
8109 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8111 if (ut_params->op->sym->m_dst) {
8112 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8114 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8115 uint8_t *, plaintext_pad_len);
8117 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8119 ut_params->op->sym->cipher.data.offset);
8120 auth_tag = ciphertext + plaintext_pad_len;
8123 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8124 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8127 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8129 tdata->ciphertext.data,
8130 tdata->ciphertext.len,
8131 "Ciphertext data not as expected");
8133 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8135 tdata->auth_tag.data,
8136 tdata->auth_tag.len,
8137 "Generated auth tag not as expected");
8143 #ifdef RTE_LIB_SECURITY
8145 security_proto_supported(enum rte_security_session_action_type action,
8146 enum rte_security_session_protocol proto)
8148 struct crypto_testsuite_params *ts_params = &testsuite_params;
8150 const struct rte_security_capability *capabilities;
8151 const struct rte_security_capability *capability;
8154 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8155 rte_cryptodev_get_sec_ctx(
8156 ts_params->valid_devs[0]);
8159 capabilities = rte_security_capabilities_get(ctx);
8161 if (capabilities == NULL)
8164 while ((capability = &capabilities[i++])->action !=
8165 RTE_SECURITY_ACTION_TYPE_NONE) {
8166 if (capability->action == action &&
8167 capability->protocol == proto)
8174 /* Basic algorithm run function for async inplace mode.
8175 * Creates a session from input parameters and runs one operation
8176 * on input_vec. Checks the output of the crypto operation against
8179 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8180 enum rte_crypto_auth_operation opa,
8181 const uint8_t *input_vec, unsigned int input_vec_len,
8182 const uint8_t *output_vec,
8183 unsigned int output_vec_len,
8184 enum rte_crypto_cipher_algorithm cipher_alg,
8185 const uint8_t *cipher_key, uint32_t cipher_key_len,
8186 enum rte_crypto_auth_algorithm auth_alg,
8187 const uint8_t *auth_key, uint32_t auth_key_len,
8188 uint8_t bearer, enum rte_security_pdcp_domain domain,
8189 uint8_t packet_direction, uint8_t sn_size,
8190 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8192 struct crypto_testsuite_params *ts_params = &testsuite_params;
8193 struct crypto_unittest_params *ut_params = &unittest_params;
8195 int ret = TEST_SUCCESS;
8196 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8197 rte_cryptodev_get_sec_ctx(
8198 ts_params->valid_devs[0]);
8200 /* Verify the capabilities */
8201 struct rte_security_capability_idx sec_cap_idx;
8203 sec_cap_idx.action = ut_params->type;
8204 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8205 sec_cap_idx.pdcp.domain = domain;
8206 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8207 return TEST_SKIPPED;
8209 /* Generate test mbuf data */
8210 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8212 /* clear mbuf payload */
8213 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8214 rte_pktmbuf_tailroom(ut_params->ibuf));
8216 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8218 memcpy(plaintext, input_vec, input_vec_len);
8220 /* Out of place support */
8223 * For out-op-place we need to alloc another mbuf
8225 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8226 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8229 /* Setup Cipher Parameters */
8230 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8231 ut_params->cipher_xform.cipher.algo = cipher_alg;
8232 ut_params->cipher_xform.cipher.op = opc;
8233 ut_params->cipher_xform.cipher.key.data = cipher_key;
8234 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8235 ut_params->cipher_xform.cipher.iv.length =
8236 packet_direction ? 4 : 0;
8237 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8239 /* Setup HMAC Parameters if ICV header is required */
8240 if (auth_alg != 0) {
8241 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8242 ut_params->auth_xform.next = NULL;
8243 ut_params->auth_xform.auth.algo = auth_alg;
8244 ut_params->auth_xform.auth.op = opa;
8245 ut_params->auth_xform.auth.key.data = auth_key;
8246 ut_params->auth_xform.auth.key.length = auth_key_len;
8248 ut_params->cipher_xform.next = &ut_params->auth_xform;
8250 ut_params->cipher_xform.next = NULL;
8253 struct rte_security_session_conf sess_conf = {
8254 .action_type = ut_params->type,
8255 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8259 .pkt_dir = packet_direction,
8261 .hfn = packet_direction ? 0 : hfn,
8263 * hfn can be set as pdcp_test_hfn[i]
8264 * if hfn_ovrd is not set. Here, PDCP
8265 * packet direction is just used to
8266 * run half of the cases with session
8267 * HFN and other half with per packet
8270 .hfn_threshold = hfn_threshold,
8271 .hfn_ovrd = packet_direction ? 1 : 0,
8272 .sdap_enabled = sdap,
8274 .crypto_xform = &ut_params->cipher_xform
8277 /* Create security session */
8278 ut_params->sec_session = rte_security_session_create(ctx,
8279 &sess_conf, ts_params->session_mpool,
8280 ts_params->session_priv_mpool);
8282 if (!ut_params->sec_session) {
8283 printf("TestCase %s()-%d line %d failed %s: ",
8284 __func__, i, __LINE__, "Failed to allocate session");
8289 /* Generate crypto op data structure */
8290 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8291 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8292 if (!ut_params->op) {
8293 printf("TestCase %s()-%d line %d failed %s: ",
8294 __func__, i, __LINE__,
8295 "Failed to allocate symmetric crypto operation struct");
8300 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8301 uint32_t *, IV_OFFSET);
8302 *per_pkt_hfn = packet_direction ? hfn : 0;
8304 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8306 /* set crypto operation source mbuf */
8307 ut_params->op->sym->m_src = ut_params->ibuf;
8309 ut_params->op->sym->m_dst = ut_params->obuf;
8311 /* Process crypto operation */
8312 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8314 printf("TestCase %s()-%d line %d failed %s: ",
8315 __func__, i, __LINE__,
8316 "failed to process sym crypto op");
8321 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8322 printf("TestCase %s()-%d line %d failed %s: ",
8323 __func__, i, __LINE__, "crypto op processing failed");
8329 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8332 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8336 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8337 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8338 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8339 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8345 rte_crypto_op_free(ut_params->op);
8346 ut_params->op = NULL;
8348 if (ut_params->sec_session)
8349 rte_security_session_destroy(ctx, ut_params->sec_session);
8350 ut_params->sec_session = NULL;
8352 rte_pktmbuf_free(ut_params->ibuf);
8353 ut_params->ibuf = NULL;
8355 rte_pktmbuf_free(ut_params->obuf);
8356 ut_params->obuf = NULL;
8363 test_pdcp_proto_SGL(int i, int oop,
8364 enum rte_crypto_cipher_operation opc,
8365 enum rte_crypto_auth_operation opa,
8367 unsigned int input_vec_len,
8368 uint8_t *output_vec,
8369 unsigned int output_vec_len,
8371 uint32_t fragsz_oop)
8373 struct crypto_testsuite_params *ts_params = &testsuite_params;
8374 struct crypto_unittest_params *ut_params = &unittest_params;
8376 struct rte_mbuf *buf, *buf_oop = NULL;
8377 int ret = TEST_SUCCESS;
8381 unsigned int trn_data = 0;
8382 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8383 rte_cryptodev_get_sec_ctx(
8384 ts_params->valid_devs[0]);
8386 /* Verify the capabilities */
8387 struct rte_security_capability_idx sec_cap_idx;
8389 sec_cap_idx.action = ut_params->type;
8390 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8391 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8392 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8393 return TEST_SKIPPED;
8395 if (fragsz > input_vec_len)
8396 fragsz = input_vec_len;
8398 uint16_t plaintext_len = fragsz;
8399 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8401 if (fragsz_oop > output_vec_len)
8402 frag_size_oop = output_vec_len;
8405 if (input_vec_len % fragsz != 0) {
8406 if (input_vec_len / fragsz + 1 > 16)
8408 } else if (input_vec_len / fragsz > 16)
8411 /* Out of place support */
8414 * For out-op-place we need to alloc another mbuf
8416 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8417 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8418 buf_oop = ut_params->obuf;
8421 /* Generate test mbuf data */
8422 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8424 /* clear mbuf payload */
8425 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8426 rte_pktmbuf_tailroom(ut_params->ibuf));
8428 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8430 memcpy(plaintext, input_vec, plaintext_len);
8431 trn_data += plaintext_len;
8433 buf = ut_params->ibuf;
8436 * Loop until no more fragments
8439 while (trn_data < input_vec_len) {
8441 to_trn = (input_vec_len - trn_data < fragsz) ?
8442 (input_vec_len - trn_data) : fragsz;
8444 to_trn_tbl[ecx++] = to_trn;
8446 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8449 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8450 rte_pktmbuf_tailroom(buf));
8453 if (oop && !fragsz_oop) {
8455 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8456 buf_oop = buf_oop->next;
8457 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8458 0, rte_pktmbuf_tailroom(buf_oop));
8459 rte_pktmbuf_append(buf_oop, to_trn);
8462 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8465 memcpy(plaintext, input_vec + trn_data, to_trn);
8469 ut_params->ibuf->nb_segs = segs;
8472 if (fragsz_oop && oop) {
8476 trn_data = frag_size_oop;
8477 while (trn_data < output_vec_len) {
8480 (output_vec_len - trn_data <
8482 (output_vec_len - trn_data) :
8485 to_trn_tbl[ecx++] = to_trn;
8488 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8489 buf_oop = buf_oop->next;
8490 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8491 0, rte_pktmbuf_tailroom(buf_oop));
8492 rte_pktmbuf_append(buf_oop, to_trn);
8496 ut_params->obuf->nb_segs = segs;
8499 /* Setup Cipher Parameters */
8500 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8501 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8502 ut_params->cipher_xform.cipher.op = opc;
8503 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8504 ut_params->cipher_xform.cipher.key.length =
8505 pdcp_test_params[i].cipher_key_len;
8506 ut_params->cipher_xform.cipher.iv.length = 0;
8508 /* Setup HMAC Parameters if ICV header is required */
8509 if (pdcp_test_params[i].auth_alg != 0) {
8510 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8511 ut_params->auth_xform.next = NULL;
8512 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8513 ut_params->auth_xform.auth.op = opa;
8514 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8515 ut_params->auth_xform.auth.key.length =
8516 pdcp_test_params[i].auth_key_len;
8518 ut_params->cipher_xform.next = &ut_params->auth_xform;
8520 ut_params->cipher_xform.next = NULL;
8523 struct rte_security_session_conf sess_conf = {
8524 .action_type = ut_params->type,
8525 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8527 .bearer = pdcp_test_bearer[i],
8528 .domain = pdcp_test_params[i].domain,
8529 .pkt_dir = pdcp_test_packet_direction[i],
8530 .sn_size = pdcp_test_data_sn_size[i],
8531 .hfn = pdcp_test_hfn[i],
8532 .hfn_threshold = pdcp_test_hfn_threshold[i],
8535 .crypto_xform = &ut_params->cipher_xform
8538 /* Create security session */
8539 ut_params->sec_session = rte_security_session_create(ctx,
8540 &sess_conf, ts_params->session_mpool,
8541 ts_params->session_priv_mpool);
8543 if (!ut_params->sec_session) {
8544 printf("TestCase %s()-%d line %d failed %s: ",
8545 __func__, i, __LINE__, "Failed to allocate session");
8550 /* Generate crypto op data structure */
8551 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8552 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8553 if (!ut_params->op) {
8554 printf("TestCase %s()-%d line %d failed %s: ",
8555 __func__, i, __LINE__,
8556 "Failed to allocate symmetric crypto operation struct");
8561 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8563 /* set crypto operation source mbuf */
8564 ut_params->op->sym->m_src = ut_params->ibuf;
8566 ut_params->op->sym->m_dst = ut_params->obuf;
8568 /* Process crypto operation */
8569 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8571 printf("TestCase %s()-%d line %d failed %s: ",
8572 __func__, i, __LINE__,
8573 "failed to process sym crypto op");
8578 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8579 printf("TestCase %s()-%d line %d failed %s: ",
8580 __func__, i, __LINE__, "crypto op processing failed");
8586 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8589 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8593 fragsz = frag_size_oop;
8594 if (memcmp(ciphertext, output_vec, fragsz)) {
8595 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8596 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8597 rte_hexdump(stdout, "reference", output_vec, fragsz);
8602 buf = ut_params->op->sym->m_src->next;
8604 buf = ut_params->op->sym->m_dst->next;
8606 unsigned int off = fragsz;
8610 ciphertext = rte_pktmbuf_mtod(buf,
8612 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8613 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8614 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8615 rte_hexdump(stdout, "reference", output_vec + off,
8620 off += to_trn_tbl[ecx++];
8624 rte_crypto_op_free(ut_params->op);
8625 ut_params->op = NULL;
8627 if (ut_params->sec_session)
8628 rte_security_session_destroy(ctx, ut_params->sec_session);
8629 ut_params->sec_session = NULL;
8631 rte_pktmbuf_free(ut_params->ibuf);
8632 ut_params->ibuf = NULL;
8634 rte_pktmbuf_free(ut_params->obuf);
8635 ut_params->obuf = NULL;
8642 test_pdcp_proto_cplane_encap(int i)
8644 return test_pdcp_proto(
8645 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8646 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8647 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8648 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8649 pdcp_test_params[i].cipher_key_len,
8650 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8651 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8652 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8653 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8654 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8658 test_pdcp_proto_uplane_encap(int i)
8660 return test_pdcp_proto(
8661 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8662 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8663 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8664 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8665 pdcp_test_params[i].cipher_key_len,
8666 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8667 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8668 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8669 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8670 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8674 test_pdcp_proto_uplane_encap_with_int(int i)
8676 return test_pdcp_proto(
8677 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8678 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8679 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8680 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8681 pdcp_test_params[i].cipher_key_len,
8682 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8683 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8684 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8685 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8686 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8690 test_pdcp_proto_cplane_decap(int i)
8692 return test_pdcp_proto(
8693 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8694 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8695 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8696 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8697 pdcp_test_params[i].cipher_key_len,
8698 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8699 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8700 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8701 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8702 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8706 test_pdcp_proto_uplane_decap(int i)
8708 return test_pdcp_proto(
8709 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8710 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8711 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8712 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8713 pdcp_test_params[i].cipher_key_len,
8714 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8715 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8716 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8717 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8718 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8722 test_pdcp_proto_uplane_decap_with_int(int i)
8724 return test_pdcp_proto(
8725 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8726 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8727 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8728 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8729 pdcp_test_params[i].cipher_key_len,
8730 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8731 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8732 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8733 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8734 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8738 test_PDCP_PROTO_SGL_in_place_32B(void)
8740 /* i can be used for running any PDCP case
8741 * In this case it is uplane 12-bit AES-SNOW DL encap
8743 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8744 return test_pdcp_proto_SGL(i, IN_PLACE,
8745 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8746 RTE_CRYPTO_AUTH_OP_GENERATE,
8747 pdcp_test_data_in[i],
8748 pdcp_test_data_in_len[i],
8749 pdcp_test_data_out[i],
8750 pdcp_test_data_in_len[i]+4,
8754 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8756 /* i can be used for running any PDCP case
8757 * In this case it is uplane 18-bit NULL-NULL DL encap
8759 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8760 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8761 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8762 RTE_CRYPTO_AUTH_OP_GENERATE,
8763 pdcp_test_data_in[i],
8764 pdcp_test_data_in_len[i],
8765 pdcp_test_data_out[i],
8766 pdcp_test_data_in_len[i]+4,
8770 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8772 /* i can be used for running any PDCP case
8773 * In this case it is uplane 18-bit AES DL encap
8775 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8777 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8778 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8779 RTE_CRYPTO_AUTH_OP_GENERATE,
8780 pdcp_test_data_in[i],
8781 pdcp_test_data_in_len[i],
8782 pdcp_test_data_out[i],
8783 pdcp_test_data_in_len[i],
8787 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8789 /* i can be used for running any PDCP case
8790 * In this case it is cplane 12-bit AES-ZUC DL encap
8792 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8793 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8794 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8795 RTE_CRYPTO_AUTH_OP_GENERATE,
8796 pdcp_test_data_in[i],
8797 pdcp_test_data_in_len[i],
8798 pdcp_test_data_out[i],
8799 pdcp_test_data_in_len[i]+4,
8804 test_PDCP_SDAP_PROTO_encap_all(void)
8806 int i = 0, size = 0;
8807 int err, all_err = TEST_SUCCESS;
8808 const struct pdcp_sdap_test *cur_test;
8810 size = RTE_DIM(list_pdcp_sdap_tests);
8812 for (i = 0; i < size; i++) {
8813 cur_test = &list_pdcp_sdap_tests[i];
8814 err = test_pdcp_proto(
8815 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8816 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8817 cur_test->in_len, cur_test->data_out,
8818 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8819 cur_test->param.cipher_alg, cur_test->cipher_key,
8820 cur_test->param.cipher_key_len,
8821 cur_test->param.auth_alg,
8822 cur_test->auth_key, cur_test->param.auth_key_len,
8823 cur_test->bearer, cur_test->param.domain,
8824 cur_test->packet_direction, cur_test->sn_size,
8826 cur_test->hfn_threshold, SDAP_ENABLED);
8828 printf("\t%d) %s: Encapsulation failed\n",
8830 cur_test->param.name);
8833 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8834 cur_test->param.name);
8840 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8842 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8846 test_PDCP_PROTO_short_mac(void)
8848 int i = 0, size = 0;
8849 int err, all_err = TEST_SUCCESS;
8850 const struct pdcp_short_mac_test *cur_test;
8852 size = RTE_DIM(list_pdcp_smac_tests);
8854 for (i = 0; i < size; i++) {
8855 cur_test = &list_pdcp_smac_tests[i];
8856 err = test_pdcp_proto(
8857 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8858 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8859 cur_test->in_len, cur_test->data_out,
8860 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8861 RTE_CRYPTO_CIPHER_NULL, NULL,
8862 0, cur_test->param.auth_alg,
8863 cur_test->auth_key, cur_test->param.auth_key_len,
8864 0, cur_test->param.domain, 0, 0,
8867 printf("\t%d) %s: Short MAC test failed\n",
8869 cur_test->param.name);
8872 printf("\t%d) %s: Short MAC test PASS\n",
8874 cur_test->param.name);
8875 rte_hexdump(stdout, "MAC I",
8876 cur_test->data_out + cur_test->in_len + 2,
8883 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8885 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8890 test_PDCP_SDAP_PROTO_decap_all(void)
8892 int i = 0, size = 0;
8893 int err, all_err = TEST_SUCCESS;
8894 const struct pdcp_sdap_test *cur_test;
8896 size = RTE_DIM(list_pdcp_sdap_tests);
8898 for (i = 0; i < size; i++) {
8899 cur_test = &list_pdcp_sdap_tests[i];
8900 err = test_pdcp_proto(
8901 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8902 RTE_CRYPTO_AUTH_OP_VERIFY,
8904 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8905 cur_test->data_in, cur_test->in_len,
8906 cur_test->param.cipher_alg,
8907 cur_test->cipher_key, cur_test->param.cipher_key_len,
8908 cur_test->param.auth_alg, cur_test->auth_key,
8909 cur_test->param.auth_key_len, cur_test->bearer,
8910 cur_test->param.domain, cur_test->packet_direction,
8911 cur_test->sn_size, cur_test->hfn,
8912 cur_test->hfn_threshold, SDAP_ENABLED);
8914 printf("\t%d) %s: Decapsulation failed\n",
8916 cur_test->param.name);
8919 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8920 cur_test->param.name);
8926 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8928 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8932 test_ipsec_proto_process(const struct ipsec_test_data td[],
8933 struct ipsec_test_data res_d[],
8936 const struct ipsec_test_flags *flags)
8938 struct crypto_testsuite_params *ts_params = &testsuite_params;
8939 struct crypto_unittest_params *ut_params = &unittest_params;
8940 struct rte_security_capability_idx sec_cap_idx;
8941 const struct rte_security_capability *sec_cap;
8942 struct rte_security_ipsec_xform ipsec_xform;
8943 uint8_t dev_id = ts_params->valid_devs[0];
8944 enum rte_security_ipsec_sa_direction dir;
8945 struct ipsec_test_data *res_d_tmp = NULL;
8946 uint32_t src = RTE_IPV4(192, 168, 1, 0);
8947 uint32_t dst = RTE_IPV4(192, 168, 1, 1);
8948 int salt_len, i, ret = TEST_SUCCESS;
8949 struct rte_security_ctx *ctx;
8950 uint8_t *input_text;
8953 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8954 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8956 /* Use first test data to create session */
8958 /* Copy IPsec xform */
8959 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
8961 dir = ipsec_xform.direction;
8962 verify = flags->tunnel_hdr_verify;
8964 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
8965 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
8967 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
8971 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src, sizeof(src));
8972 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst, sizeof(dst));
8974 ctx = rte_cryptodev_get_sec_ctx(dev_id);
8976 sec_cap_idx.action = ut_params->type;
8977 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
8978 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
8979 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
8980 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
8982 if (flags->udp_encap)
8983 ipsec_xform.options.udp_encap = 1;
8985 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8986 if (sec_cap == NULL)
8987 return TEST_SKIPPED;
8989 /* Copy cipher session parameters */
8991 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
8992 sizeof(ut_params->aead_xform));
8993 ut_params->aead_xform.aead.key.data = td[0].key.data;
8994 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8996 /* Verify crypto capabilities */
8997 if (test_ipsec_crypto_caps_aead_verify(
8999 &ut_params->aead_xform) != 0) {
9001 RTE_LOG(INFO, USER1,
9002 "Crypto capabilities not supported\n");
9003 return TEST_SKIPPED;
9006 /* Only AEAD supported now */
9007 return TEST_SKIPPED;
9010 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9011 return TEST_SKIPPED;
9013 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9014 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9016 struct rte_security_session_conf sess_conf = {
9017 .action_type = ut_params->type,
9018 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9019 .ipsec = ipsec_xform,
9020 .crypto_xform = &ut_params->aead_xform,
9023 /* Create security session */
9024 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9025 ts_params->session_mpool,
9026 ts_params->session_priv_mpool);
9028 if (ut_params->sec_session == NULL)
9029 return TEST_SKIPPED;
9031 for (i = 0; i < nb_td; i++) {
9032 /* Setup source mbuf payload */
9033 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9034 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9035 rte_pktmbuf_tailroom(ut_params->ibuf));
9037 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9038 td[i].input_text.len);
9040 memcpy(input_text, td[i].input_text.data,
9041 td[i].input_text.len);
9043 /* Generate crypto op data structure */
9044 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9045 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9046 if (!ut_params->op) {
9047 printf("TestCase %s line %d: %s\n",
9049 "failed to allocate crypto op");
9051 goto crypto_op_free;
9054 /* Attach session to operation */
9055 rte_security_attach_session(ut_params->op,
9056 ut_params->sec_session);
9058 /* Set crypto operation mbufs */
9059 ut_params->op->sym->m_src = ut_params->ibuf;
9060 ut_params->op->sym->m_dst = NULL;
9062 /* Copy IV in crypto operation when IV generation is disabled */
9063 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9064 ipsec_xform.options.iv_gen_disable == 1) {
9065 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9071 len = td[i].xform.aead.aead.iv.length;
9073 len = td[i].xform.chain.cipher.cipher.iv.length;
9075 memcpy(iv, td[i].iv.data, len);
9078 /* Process crypto operation */
9079 process_crypto_request(dev_id, ut_params->op);
9081 ret = test_ipsec_status_check(ut_params->op, flags, dir, i + 1);
9082 if (ret != TEST_SUCCESS)
9083 goto crypto_op_free;
9086 res_d_tmp = &res_d[i];
9088 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9089 res_d_tmp, silent, flags);
9090 if (ret != TEST_SUCCESS)
9091 goto crypto_op_free;
9093 rte_crypto_op_free(ut_params->op);
9094 ut_params->op = NULL;
9096 rte_pktmbuf_free(ut_params->ibuf);
9097 ut_params->ibuf = NULL;
9101 rte_crypto_op_free(ut_params->op);
9102 ut_params->op = NULL;
9104 rte_pktmbuf_free(ut_params->ibuf);
9105 ut_params->ibuf = NULL;
9107 if (ut_params->sec_session)
9108 rte_security_session_destroy(ctx, ut_params->sec_session);
9109 ut_params->sec_session = NULL;
9115 test_ipsec_proto_known_vec(const void *test_data)
9117 struct ipsec_test_data td_outb;
9118 struct ipsec_test_flags flags;
9120 memset(&flags, 0, sizeof(flags));
9122 memcpy(&td_outb, test_data, sizeof(td_outb));
9124 /* Disable IV gen to be able to test with known vectors */
9125 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9127 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9131 test_ipsec_proto_known_vec_inb(const void *td_outb)
9133 struct ipsec_test_flags flags;
9134 struct ipsec_test_data td_inb;
9136 memset(&flags, 0, sizeof(flags));
9138 test_ipsec_td_in_from_out(td_outb, &td_inb);
9140 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9144 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9146 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9147 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9148 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9151 if (flags->iv_gen ||
9152 flags->sa_expiry_pkts_soft ||
9153 flags->sa_expiry_pkts_hard)
9154 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9156 for (i = 0; i < RTE_DIM(aead_list); i++) {
9157 test_ipsec_td_prepare(&aead_list[i],
9163 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9165 if (ret == TEST_SKIPPED)
9168 if (ret == TEST_FAILED)
9171 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9173 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9175 if (ret == TEST_SKIPPED)
9178 if (ret == TEST_FAILED)
9181 if (flags->display_alg)
9182 test_ipsec_display_alg(&aead_list[i], NULL);
9188 return TEST_SUCCESS;
9190 return TEST_SKIPPED;
9194 test_ipsec_proto_display_list(const void *data __rte_unused)
9196 struct ipsec_test_flags flags;
9198 memset(&flags, 0, sizeof(flags));
9200 flags.display_alg = true;
9202 return test_ipsec_proto_all(&flags);
9206 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9208 struct ipsec_test_flags flags;
9210 memset(&flags, 0, sizeof(flags));
9212 flags.iv_gen = true;
9214 return test_ipsec_proto_all(&flags);
9218 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9220 struct ipsec_test_flags flags;
9222 memset(&flags, 0, sizeof(flags));
9224 flags.sa_expiry_pkts_soft = true;
9226 return test_ipsec_proto_all(&flags);
9230 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9232 struct ipsec_test_flags flags;
9234 memset(&flags, 0, sizeof(flags));
9236 flags.sa_expiry_pkts_hard = true;
9238 return test_ipsec_proto_all(&flags);
9242 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9244 struct ipsec_test_flags flags;
9246 memset(&flags, 0, sizeof(flags));
9248 flags.icv_corrupt = true;
9250 return test_ipsec_proto_all(&flags);
9254 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9256 struct ipsec_test_flags flags;
9258 memset(&flags, 0, sizeof(flags));
9260 flags.udp_encap = true;
9262 return test_ipsec_proto_all(&flags);
9266 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9268 struct ipsec_test_flags flags;
9270 memset(&flags, 0, sizeof(flags));
9272 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9274 return test_ipsec_proto_all(&flags);
9278 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9280 struct ipsec_test_flags flags;
9282 memset(&flags, 0, sizeof(flags));
9284 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9286 return test_ipsec_proto_all(&flags);
9290 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9292 struct ipsec_test_flags flags;
9294 memset(&flags, 0, sizeof(flags));
9296 flags.udp_encap = true;
9297 flags.udp_ports_verify = true;
9299 return test_ipsec_proto_all(&flags);
9303 test_PDCP_PROTO_all(void)
9305 struct crypto_testsuite_params *ts_params = &testsuite_params;
9306 struct crypto_unittest_params *ut_params = &unittest_params;
9307 struct rte_cryptodev_info dev_info;
9310 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9311 uint64_t feat_flags = dev_info.feature_flags;
9313 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9314 return TEST_SKIPPED;
9316 /* Set action type */
9317 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9318 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9321 if (security_proto_supported(ut_params->type,
9322 RTE_SECURITY_PROTOCOL_PDCP) < 0)
9323 return TEST_SKIPPED;
9325 status = test_PDCP_PROTO_cplane_encap_all();
9326 status += test_PDCP_PROTO_cplane_decap_all();
9327 status += test_PDCP_PROTO_uplane_encap_all();
9328 status += test_PDCP_PROTO_uplane_decap_all();
9329 status += test_PDCP_PROTO_SGL_in_place_32B();
9330 status += test_PDCP_PROTO_SGL_oop_32B_128B();
9331 status += test_PDCP_PROTO_SGL_oop_32B_40B();
9332 status += test_PDCP_PROTO_SGL_oop_128B_32B();
9333 status += test_PDCP_SDAP_PROTO_encap_all();
9334 status += test_PDCP_SDAP_PROTO_decap_all();
9335 status += test_PDCP_PROTO_short_mac();
9340 return TEST_SUCCESS;
9344 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
9346 struct crypto_testsuite_params *ts_params = &testsuite_params;
9347 struct crypto_unittest_params *ut_params = &unittest_params;
9348 uint8_t *plaintext, *ciphertext;
9350 int32_t cipher_len, crc_len;
9351 uint32_t crc_data_len;
9352 int ret = TEST_SUCCESS;
9354 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9355 rte_cryptodev_get_sec_ctx(
9356 ts_params->valid_devs[0]);
9358 /* Verify the capabilities */
9359 struct rte_security_capability_idx sec_cap_idx;
9360 const struct rte_security_capability *sec_cap;
9361 const struct rte_cryptodev_capabilities *crypto_cap;
9362 const struct rte_cryptodev_symmetric_capability *sym_cap;
9365 sec_cap_idx.action = ut_params->type;
9366 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9367 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9369 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9370 if (sec_cap == NULL)
9371 return TEST_SKIPPED;
9373 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9374 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9375 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9376 crypto_cap->sym.xform_type ==
9377 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9378 crypto_cap->sym.cipher.algo ==
9379 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9380 sym_cap = &crypto_cap->sym;
9381 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9388 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9389 return TEST_SKIPPED;
9391 /* Setup source mbuf payload */
9392 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9393 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9394 rte_pktmbuf_tailroom(ut_params->ibuf));
9396 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9397 d_td->ciphertext.len);
9399 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
9401 /* Setup cipher session parameters */
9402 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9403 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9404 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
9405 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9406 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9407 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9408 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9409 ut_params->cipher_xform.next = NULL;
9411 /* Setup DOCSIS session parameters */
9412 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9414 struct rte_security_session_conf sess_conf = {
9415 .action_type = ut_params->type,
9416 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9417 .docsis = ut_params->docsis_xform,
9418 .crypto_xform = &ut_params->cipher_xform,
9421 /* Create security session */
9422 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9423 ts_params->session_mpool,
9424 ts_params->session_priv_mpool);
9426 if (!ut_params->sec_session) {
9427 printf("TestCase %s(%d) line %d: %s\n",
9428 __func__, i, __LINE__, "failed to allocate session");
9433 /* Generate crypto op data structure */
9434 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9435 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9436 if (!ut_params->op) {
9437 printf("TestCase %s(%d) line %d: %s\n",
9438 __func__, i, __LINE__,
9439 "failed to allocate symmetric crypto operation");
9444 /* Setup CRC operation parameters */
9445 crc_len = d_td->ciphertext.no_crc == false ?
9446 (d_td->ciphertext.len -
9447 d_td->ciphertext.crc_offset -
9448 RTE_ETHER_CRC_LEN) :
9450 crc_len = crc_len > 0 ? crc_len : 0;
9451 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9452 ut_params->op->sym->auth.data.length = crc_len;
9453 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9455 /* Setup cipher operation parameters */
9456 cipher_len = d_td->ciphertext.no_cipher == false ?
9457 (d_td->ciphertext.len -
9458 d_td->ciphertext.cipher_offset) :
9460 cipher_len = cipher_len > 0 ? cipher_len : 0;
9461 ut_params->op->sym->cipher.data.length = cipher_len;
9462 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9464 /* Setup cipher IV */
9465 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9466 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9468 /* Attach session to operation */
9469 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9471 /* Set crypto operation mbufs */
9472 ut_params->op->sym->m_src = ut_params->ibuf;
9473 ut_params->op->sym->m_dst = NULL;
9475 /* Process crypto operation */
9476 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9478 printf("TestCase %s(%d) line %d: %s\n",
9479 __func__, i, __LINE__,
9480 "failed to process security crypto op");
9485 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9486 printf("TestCase %s(%d) line %d: %s\n",
9487 __func__, i, __LINE__, "crypto op processing failed");
9492 /* Validate plaintext */
9493 plaintext = ciphertext;
9495 if (memcmp(plaintext, d_td->plaintext.data,
9496 d_td->plaintext.len - crc_data_len)) {
9497 printf("TestCase %s(%d) line %d: %s\n",
9498 __func__, i, __LINE__, "plaintext not as expected\n");
9499 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9500 d_td->plaintext.len);
9501 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9507 rte_crypto_op_free(ut_params->op);
9508 ut_params->op = NULL;
9510 if (ut_params->sec_session)
9511 rte_security_session_destroy(ctx, ut_params->sec_session);
9512 ut_params->sec_session = NULL;
9514 rte_pktmbuf_free(ut_params->ibuf);
9515 ut_params->ibuf = NULL;
9521 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9523 struct crypto_testsuite_params *ts_params = &testsuite_params;
9524 struct crypto_unittest_params *ut_params = &unittest_params;
9525 uint8_t *plaintext, *ciphertext;
9527 int32_t cipher_len, crc_len;
9528 int ret = TEST_SUCCESS;
9530 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9531 rte_cryptodev_get_sec_ctx(
9532 ts_params->valid_devs[0]);
9534 /* Verify the capabilities */
9535 struct rte_security_capability_idx sec_cap_idx;
9536 const struct rte_security_capability *sec_cap;
9537 const struct rte_cryptodev_capabilities *crypto_cap;
9538 const struct rte_cryptodev_symmetric_capability *sym_cap;
9541 sec_cap_idx.action = ut_params->type;
9542 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9543 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9545 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9546 if (sec_cap == NULL)
9547 return TEST_SKIPPED;
9549 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9550 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9551 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9552 crypto_cap->sym.xform_type ==
9553 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9554 crypto_cap->sym.cipher.algo ==
9555 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9556 sym_cap = &crypto_cap->sym;
9557 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9564 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9565 return TEST_SKIPPED;
9567 /* Setup source mbuf payload */
9568 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9569 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9570 rte_pktmbuf_tailroom(ut_params->ibuf));
9572 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9573 d_td->plaintext.len);
9575 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9577 /* Setup cipher session parameters */
9578 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9579 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9580 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9581 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9582 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9583 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9584 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9585 ut_params->cipher_xform.next = NULL;
9587 /* Setup DOCSIS session parameters */
9588 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9590 struct rte_security_session_conf sess_conf = {
9591 .action_type = ut_params->type,
9592 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9593 .docsis = ut_params->docsis_xform,
9594 .crypto_xform = &ut_params->cipher_xform,
9597 /* Create security session */
9598 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9599 ts_params->session_mpool,
9600 ts_params->session_priv_mpool);
9602 if (!ut_params->sec_session) {
9603 printf("TestCase %s(%d) line %d: %s\n",
9604 __func__, i, __LINE__, "failed to allocate session");
9609 /* Generate crypto op data structure */
9610 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9611 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9612 if (!ut_params->op) {
9613 printf("TestCase %s(%d) line %d: %s\n",
9614 __func__, i, __LINE__,
9615 "failed to allocate security crypto operation");
9620 /* Setup CRC operation parameters */
9621 crc_len = d_td->plaintext.no_crc == false ?
9622 (d_td->plaintext.len -
9623 d_td->plaintext.crc_offset -
9624 RTE_ETHER_CRC_LEN) :
9626 crc_len = crc_len > 0 ? crc_len : 0;
9627 ut_params->op->sym->auth.data.length = crc_len;
9628 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9630 /* Setup cipher operation parameters */
9631 cipher_len = d_td->plaintext.no_cipher == false ?
9632 (d_td->plaintext.len -
9633 d_td->plaintext.cipher_offset) :
9635 cipher_len = cipher_len > 0 ? cipher_len : 0;
9636 ut_params->op->sym->cipher.data.length = cipher_len;
9637 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9639 /* Setup cipher IV */
9640 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9641 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9643 /* Attach session to operation */
9644 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9646 /* Set crypto operation mbufs */
9647 ut_params->op->sym->m_src = ut_params->ibuf;
9648 ut_params->op->sym->m_dst = NULL;
9650 /* Process crypto operation */
9651 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9653 printf("TestCase %s(%d) line %d: %s\n",
9654 __func__, i, __LINE__,
9655 "failed to process security crypto op");
9660 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9661 printf("TestCase %s(%d) line %d: %s\n",
9662 __func__, i, __LINE__, "crypto op processing failed");
9667 /* Validate ciphertext */
9668 ciphertext = plaintext;
9670 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9671 printf("TestCase %s(%d) line %d: %s\n",
9672 __func__, i, __LINE__, "ciphertext not as expected\n");
9673 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9674 d_td->ciphertext.len);
9675 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9681 rte_crypto_op_free(ut_params->op);
9682 ut_params->op = NULL;
9684 if (ut_params->sec_session)
9685 rte_security_session_destroy(ctx, ut_params->sec_session);
9686 ut_params->sec_session = NULL;
9688 rte_pktmbuf_free(ut_params->ibuf);
9689 ut_params->ibuf = NULL;
9694 #define TEST_DOCSIS_COUNT(func) do { \
9696 if (ret == TEST_SUCCESS) { \
9697 printf("\t%2d)", n++); \
9698 printf("+++++ PASSED:" #func"\n"); \
9700 } else if (ret == TEST_SKIPPED) { \
9701 printf("\t%2d)", n++); \
9702 printf("~~~~~ SKIPPED:" #func"\n"); \
9705 printf("\t%2d)", n++); \
9706 printf("----- FAILED:" #func"\n"); \
9712 test_DOCSIS_PROTO_uplink_all(void)
9714 int p = 0, s = 0, f = 0, n = 0;
9716 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9717 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9718 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9719 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9720 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9721 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9722 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9723 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9724 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9725 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9726 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9727 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9728 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9729 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9730 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9731 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9732 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9733 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9734 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9735 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9736 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9737 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9738 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9739 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9740 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9741 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9744 printf("## %s: %d passed out of %d (%d skipped)\n",
9751 test_DOCSIS_PROTO_downlink_all(void)
9753 int p = 0, s = 0, f = 0, n = 0;
9755 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9756 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9757 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9758 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9759 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9760 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9761 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9762 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9763 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9764 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9765 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9766 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9767 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9768 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9769 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9770 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9771 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9772 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9773 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9774 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9775 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9776 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9777 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9778 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9779 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9780 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9783 printf("## %s: %d passed out of %d (%d skipped)\n",
9790 test_DOCSIS_PROTO_all(void)
9792 struct crypto_testsuite_params *ts_params = &testsuite_params;
9793 struct crypto_unittest_params *ut_params = &unittest_params;
9794 struct rte_cryptodev_info dev_info;
9797 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9798 uint64_t feat_flags = dev_info.feature_flags;
9800 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9801 return TEST_SKIPPED;
9803 /* Set action type */
9804 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9805 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9808 if (security_proto_supported(ut_params->type,
9809 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9810 return TEST_SKIPPED;
9812 status = test_DOCSIS_PROTO_uplink_all();
9813 status += test_DOCSIS_PROTO_downlink_all();
9818 return TEST_SUCCESS;
9823 test_AES_GCM_authenticated_encryption_test_case_1(void)
9825 return test_authenticated_encryption(&gcm_test_case_1);
9829 test_AES_GCM_authenticated_encryption_test_case_2(void)
9831 return test_authenticated_encryption(&gcm_test_case_2);
9835 test_AES_GCM_authenticated_encryption_test_case_3(void)
9837 return test_authenticated_encryption(&gcm_test_case_3);
9841 test_AES_GCM_authenticated_encryption_test_case_4(void)
9843 return test_authenticated_encryption(&gcm_test_case_4);
9847 test_AES_GCM_authenticated_encryption_test_case_5(void)
9849 return test_authenticated_encryption(&gcm_test_case_5);
9853 test_AES_GCM_authenticated_encryption_test_case_6(void)
9855 return test_authenticated_encryption(&gcm_test_case_6);
9859 test_AES_GCM_authenticated_encryption_test_case_7(void)
9861 return test_authenticated_encryption(&gcm_test_case_7);
9865 test_AES_GCM_authenticated_encryption_test_case_8(void)
9867 return test_authenticated_encryption(&gcm_test_case_8);
9871 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9873 return test_authenticated_encryption(&gcm_J0_test_case_1);
9877 test_AES_GCM_auth_encryption_test_case_192_1(void)
9879 return test_authenticated_encryption(&gcm_test_case_192_1);
9883 test_AES_GCM_auth_encryption_test_case_192_2(void)
9885 return test_authenticated_encryption(&gcm_test_case_192_2);
9889 test_AES_GCM_auth_encryption_test_case_192_3(void)
9891 return test_authenticated_encryption(&gcm_test_case_192_3);
9895 test_AES_GCM_auth_encryption_test_case_192_4(void)
9897 return test_authenticated_encryption(&gcm_test_case_192_4);
9901 test_AES_GCM_auth_encryption_test_case_192_5(void)
9903 return test_authenticated_encryption(&gcm_test_case_192_5);
9907 test_AES_GCM_auth_encryption_test_case_192_6(void)
9909 return test_authenticated_encryption(&gcm_test_case_192_6);
9913 test_AES_GCM_auth_encryption_test_case_192_7(void)
9915 return test_authenticated_encryption(&gcm_test_case_192_7);
9919 test_AES_GCM_auth_encryption_test_case_256_1(void)
9921 return test_authenticated_encryption(&gcm_test_case_256_1);
9925 test_AES_GCM_auth_encryption_test_case_256_2(void)
9927 return test_authenticated_encryption(&gcm_test_case_256_2);
9931 test_AES_GCM_auth_encryption_test_case_256_3(void)
9933 return test_authenticated_encryption(&gcm_test_case_256_3);
9937 test_AES_GCM_auth_encryption_test_case_256_4(void)
9939 return test_authenticated_encryption(&gcm_test_case_256_4);
9943 test_AES_GCM_auth_encryption_test_case_256_5(void)
9945 return test_authenticated_encryption(&gcm_test_case_256_5);
9949 test_AES_GCM_auth_encryption_test_case_256_6(void)
9951 return test_authenticated_encryption(&gcm_test_case_256_6);
9955 test_AES_GCM_auth_encryption_test_case_256_7(void)
9957 return test_authenticated_encryption(&gcm_test_case_256_7);
9961 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9963 return test_authenticated_encryption(&gcm_test_case_aad_1);
9967 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9969 return test_authenticated_encryption(&gcm_test_case_aad_2);
9973 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9975 struct aead_test_data tdata;
9978 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9979 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9980 tdata.iv.data[0] += 1;
9981 res = test_authenticated_encryption(&tdata);
9982 if (res == TEST_SKIPPED)
9984 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9985 return TEST_SUCCESS;
9989 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9991 struct aead_test_data tdata;
9994 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9995 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9996 tdata.plaintext.data[0] += 1;
9997 res = test_authenticated_encryption(&tdata);
9998 if (res == TEST_SKIPPED)
10000 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10001 return TEST_SUCCESS;
10005 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10007 struct aead_test_data tdata;
10010 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10011 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10012 tdata.ciphertext.data[0] += 1;
10013 res = test_authenticated_encryption(&tdata);
10014 if (res == TEST_SKIPPED)
10016 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10017 return TEST_SUCCESS;
10021 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10023 struct aead_test_data tdata;
10026 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10027 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10028 tdata.aad.len += 1;
10029 res = test_authenticated_encryption(&tdata);
10030 if (res == TEST_SKIPPED)
10032 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10033 return TEST_SUCCESS;
10037 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10039 struct aead_test_data tdata;
10040 uint8_t aad[gcm_test_case_7.aad.len];
10043 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10044 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10045 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10047 tdata.aad.data = aad;
10048 res = test_authenticated_encryption(&tdata);
10049 if (res == TEST_SKIPPED)
10051 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10052 return TEST_SUCCESS;
10056 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10058 struct aead_test_data tdata;
10061 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10062 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10063 tdata.auth_tag.data[0] += 1;
10064 res = test_authenticated_encryption(&tdata);
10065 if (res == TEST_SKIPPED)
10067 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10068 return TEST_SUCCESS;
10072 test_authenticated_decryption(const struct aead_test_data *tdata)
10074 struct crypto_testsuite_params *ts_params = &testsuite_params;
10075 struct crypto_unittest_params *ut_params = &unittest_params;
10078 uint8_t *plaintext;
10080 struct rte_cryptodev_info dev_info;
10082 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10083 uint64_t feat_flags = dev_info.feature_flags;
10085 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10086 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10087 printf("Device doesn't support RAW data-path APIs.\n");
10088 return TEST_SKIPPED;
10091 /* Verify the capabilities */
10092 struct rte_cryptodev_sym_capability_idx cap_idx;
10093 const struct rte_cryptodev_symmetric_capability *capability;
10094 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10095 cap_idx.algo.aead = tdata->algo;
10096 capability = rte_cryptodev_sym_capability_get(
10097 ts_params->valid_devs[0], &cap_idx);
10098 if (capability == NULL)
10099 return TEST_SKIPPED;
10100 if (rte_cryptodev_sym_capability_check_aead(
10101 capability, tdata->key.len, tdata->auth_tag.len,
10102 tdata->aad.len, tdata->iv.len))
10103 return TEST_SKIPPED;
10105 /* Create AEAD session */
10106 retval = create_aead_session(ts_params->valid_devs[0],
10108 RTE_CRYPTO_AEAD_OP_DECRYPT,
10109 tdata->key.data, tdata->key.len,
10110 tdata->aad.len, tdata->auth_tag.len,
10115 /* alloc mbuf and set payload */
10116 if (tdata->aad.len > MBUF_SIZE) {
10117 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10118 /* Populate full size of add data */
10119 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10120 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10122 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10124 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10125 rte_pktmbuf_tailroom(ut_params->ibuf));
10127 /* Create AEAD operation */
10128 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10132 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10134 ut_params->op->sym->m_src = ut_params->ibuf;
10136 /* Process crypto operation */
10137 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10138 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10139 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10140 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10141 ut_params->op, 0, 0, 0, 0);
10143 TEST_ASSERT_NOT_NULL(
10144 process_crypto_request(ts_params->valid_devs[0],
10145 ut_params->op), "failed to process sym crypto op");
10147 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10148 "crypto op processing failed");
10150 if (ut_params->op->sym->m_dst)
10151 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10154 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10156 ut_params->op->sym->cipher.data.offset);
10158 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10160 /* Validate obuf */
10161 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10163 tdata->plaintext.data,
10164 tdata->plaintext.len,
10165 "Plaintext data not as expected");
10167 TEST_ASSERT_EQUAL(ut_params->op->status,
10168 RTE_CRYPTO_OP_STATUS_SUCCESS,
10169 "Authentication failed");
10175 test_AES_GCM_authenticated_decryption_test_case_1(void)
10177 return test_authenticated_decryption(&gcm_test_case_1);
10181 test_AES_GCM_authenticated_decryption_test_case_2(void)
10183 return test_authenticated_decryption(&gcm_test_case_2);
10187 test_AES_GCM_authenticated_decryption_test_case_3(void)
10189 return test_authenticated_decryption(&gcm_test_case_3);
10193 test_AES_GCM_authenticated_decryption_test_case_4(void)
10195 return test_authenticated_decryption(&gcm_test_case_4);
10199 test_AES_GCM_authenticated_decryption_test_case_5(void)
10201 return test_authenticated_decryption(&gcm_test_case_5);
10205 test_AES_GCM_authenticated_decryption_test_case_6(void)
10207 return test_authenticated_decryption(&gcm_test_case_6);
10211 test_AES_GCM_authenticated_decryption_test_case_7(void)
10213 return test_authenticated_decryption(&gcm_test_case_7);
10217 test_AES_GCM_authenticated_decryption_test_case_8(void)
10219 return test_authenticated_decryption(&gcm_test_case_8);
10223 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10225 return test_authenticated_decryption(&gcm_J0_test_case_1);
10229 test_AES_GCM_auth_decryption_test_case_192_1(void)
10231 return test_authenticated_decryption(&gcm_test_case_192_1);
10235 test_AES_GCM_auth_decryption_test_case_192_2(void)
10237 return test_authenticated_decryption(&gcm_test_case_192_2);
10241 test_AES_GCM_auth_decryption_test_case_192_3(void)
10243 return test_authenticated_decryption(&gcm_test_case_192_3);
10247 test_AES_GCM_auth_decryption_test_case_192_4(void)
10249 return test_authenticated_decryption(&gcm_test_case_192_4);
10253 test_AES_GCM_auth_decryption_test_case_192_5(void)
10255 return test_authenticated_decryption(&gcm_test_case_192_5);
10259 test_AES_GCM_auth_decryption_test_case_192_6(void)
10261 return test_authenticated_decryption(&gcm_test_case_192_6);
10265 test_AES_GCM_auth_decryption_test_case_192_7(void)
10267 return test_authenticated_decryption(&gcm_test_case_192_7);
10271 test_AES_GCM_auth_decryption_test_case_256_1(void)
10273 return test_authenticated_decryption(&gcm_test_case_256_1);
10277 test_AES_GCM_auth_decryption_test_case_256_2(void)
10279 return test_authenticated_decryption(&gcm_test_case_256_2);
10283 test_AES_GCM_auth_decryption_test_case_256_3(void)
10285 return test_authenticated_decryption(&gcm_test_case_256_3);
10289 test_AES_GCM_auth_decryption_test_case_256_4(void)
10291 return test_authenticated_decryption(&gcm_test_case_256_4);
10295 test_AES_GCM_auth_decryption_test_case_256_5(void)
10297 return test_authenticated_decryption(&gcm_test_case_256_5);
10301 test_AES_GCM_auth_decryption_test_case_256_6(void)
10303 return test_authenticated_decryption(&gcm_test_case_256_6);
10307 test_AES_GCM_auth_decryption_test_case_256_7(void)
10309 return test_authenticated_decryption(&gcm_test_case_256_7);
10313 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10315 return test_authenticated_decryption(&gcm_test_case_aad_1);
10319 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10321 return test_authenticated_decryption(&gcm_test_case_aad_2);
10325 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10327 struct aead_test_data tdata;
10330 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10331 tdata.iv.data[0] += 1;
10332 res = test_authenticated_decryption(&tdata);
10333 if (res == TEST_SKIPPED)
10335 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10336 return TEST_SUCCESS;
10340 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10342 struct aead_test_data tdata;
10345 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10346 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10347 tdata.plaintext.data[0] += 1;
10348 res = test_authenticated_decryption(&tdata);
10349 if (res == TEST_SKIPPED)
10351 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10352 return TEST_SUCCESS;
10356 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10358 struct aead_test_data tdata;
10361 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10362 tdata.ciphertext.data[0] += 1;
10363 res = test_authenticated_decryption(&tdata);
10364 if (res == TEST_SKIPPED)
10366 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10367 return TEST_SUCCESS;
10371 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10373 struct aead_test_data tdata;
10376 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10377 tdata.aad.len += 1;
10378 res = test_authenticated_decryption(&tdata);
10379 if (res == TEST_SKIPPED)
10381 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10382 return TEST_SUCCESS;
10386 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10388 struct aead_test_data tdata;
10389 uint8_t aad[gcm_test_case_7.aad.len];
10392 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10393 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10395 tdata.aad.data = aad;
10396 res = test_authenticated_decryption(&tdata);
10397 if (res == TEST_SKIPPED)
10399 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10400 return TEST_SUCCESS;
10404 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10406 struct aead_test_data tdata;
10409 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10410 tdata.auth_tag.data[0] += 1;
10411 res = test_authenticated_decryption(&tdata);
10412 if (res == TEST_SKIPPED)
10414 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10415 return TEST_SUCCESS;
10419 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10421 struct crypto_testsuite_params *ts_params = &testsuite_params;
10422 struct crypto_unittest_params *ut_params = &unittest_params;
10425 uint8_t *ciphertext, *auth_tag;
10426 uint16_t plaintext_pad_len;
10428 /* Verify the capabilities */
10429 struct rte_cryptodev_sym_capability_idx cap_idx;
10430 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10431 cap_idx.algo.aead = tdata->algo;
10432 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10434 return TEST_SKIPPED;
10436 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10437 return TEST_SKIPPED;
10439 /* not supported with CPU crypto */
10440 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10441 return TEST_SKIPPED;
10443 /* Create AEAD session */
10444 retval = create_aead_session(ts_params->valid_devs[0],
10446 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10447 tdata->key.data, tdata->key.len,
10448 tdata->aad.len, tdata->auth_tag.len,
10453 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10454 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10456 /* clear mbuf payload */
10457 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10458 rte_pktmbuf_tailroom(ut_params->ibuf));
10459 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10460 rte_pktmbuf_tailroom(ut_params->obuf));
10462 /* Create AEAD operation */
10463 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10467 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10469 ut_params->op->sym->m_src = ut_params->ibuf;
10470 ut_params->op->sym->m_dst = ut_params->obuf;
10472 /* Process crypto operation */
10473 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10474 ut_params->op), "failed to process sym crypto op");
10476 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10477 "crypto op processing failed");
10479 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10481 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10482 ut_params->op->sym->cipher.data.offset);
10483 auth_tag = ciphertext + plaintext_pad_len;
10485 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10486 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10488 /* Validate obuf */
10489 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10491 tdata->ciphertext.data,
10492 tdata->ciphertext.len,
10493 "Ciphertext data not as expected");
10495 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10497 tdata->auth_tag.data,
10498 tdata->auth_tag.len,
10499 "Generated auth tag not as expected");
10506 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10508 return test_authenticated_encryption_oop(&gcm_test_case_5);
10512 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10514 struct crypto_testsuite_params *ts_params = &testsuite_params;
10515 struct crypto_unittest_params *ut_params = &unittest_params;
10518 uint8_t *plaintext;
10520 /* Verify the capabilities */
10521 struct rte_cryptodev_sym_capability_idx cap_idx;
10522 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10523 cap_idx.algo.aead = tdata->algo;
10524 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10526 return TEST_SKIPPED;
10528 /* not supported with CPU crypto and raw data-path APIs*/
10529 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10530 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10531 return TEST_SKIPPED;
10533 /* Create AEAD session */
10534 retval = create_aead_session(ts_params->valid_devs[0],
10536 RTE_CRYPTO_AEAD_OP_DECRYPT,
10537 tdata->key.data, tdata->key.len,
10538 tdata->aad.len, tdata->auth_tag.len,
10543 /* alloc mbuf and set payload */
10544 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10545 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10547 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10548 rte_pktmbuf_tailroom(ut_params->ibuf));
10549 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10550 rte_pktmbuf_tailroom(ut_params->obuf));
10552 /* Create AEAD operation */
10553 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10557 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10559 ut_params->op->sym->m_src = ut_params->ibuf;
10560 ut_params->op->sym->m_dst = ut_params->obuf;
10562 /* Process crypto operation */
10563 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10564 ut_params->op), "failed to process sym crypto op");
10566 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10567 "crypto op processing failed");
10569 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10570 ut_params->op->sym->cipher.data.offset);
10572 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10574 /* Validate obuf */
10575 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10577 tdata->plaintext.data,
10578 tdata->plaintext.len,
10579 "Plaintext data not as expected");
10581 TEST_ASSERT_EQUAL(ut_params->op->status,
10582 RTE_CRYPTO_OP_STATUS_SUCCESS,
10583 "Authentication failed");
10588 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10590 return test_authenticated_decryption_oop(&gcm_test_case_5);
10594 test_authenticated_encryption_sessionless(
10595 const struct aead_test_data *tdata)
10597 struct crypto_testsuite_params *ts_params = &testsuite_params;
10598 struct crypto_unittest_params *ut_params = &unittest_params;
10601 uint8_t *ciphertext, *auth_tag;
10602 uint16_t plaintext_pad_len;
10603 uint8_t key[tdata->key.len + 1];
10604 struct rte_cryptodev_info dev_info;
10606 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10607 uint64_t feat_flags = dev_info.feature_flags;
10609 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10610 printf("Device doesn't support Sessionless ops.\n");
10611 return TEST_SKIPPED;
10614 /* not supported with CPU crypto */
10615 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10616 return TEST_SKIPPED;
10618 /* Verify the capabilities */
10619 struct rte_cryptodev_sym_capability_idx cap_idx;
10620 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10621 cap_idx.algo.aead = tdata->algo;
10622 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10624 return TEST_SKIPPED;
10626 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10628 /* clear mbuf payload */
10629 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10630 rte_pktmbuf_tailroom(ut_params->ibuf));
10632 /* Create AEAD operation */
10633 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10637 /* Create GCM xform */
10638 memcpy(key, tdata->key.data, tdata->key.len);
10639 retval = create_aead_xform(ut_params->op,
10641 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10642 key, tdata->key.len,
10643 tdata->aad.len, tdata->auth_tag.len,
10648 ut_params->op->sym->m_src = ut_params->ibuf;
10650 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10651 RTE_CRYPTO_OP_SESSIONLESS,
10652 "crypto op session type not sessionless");
10654 /* Process crypto operation */
10655 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10656 ut_params->op), "failed to process sym crypto op");
10658 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10660 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10661 "crypto op status not success");
10663 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10665 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10666 ut_params->op->sym->cipher.data.offset);
10667 auth_tag = ciphertext + plaintext_pad_len;
10669 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10670 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10672 /* Validate obuf */
10673 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10675 tdata->ciphertext.data,
10676 tdata->ciphertext.len,
10677 "Ciphertext data not as expected");
10679 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10681 tdata->auth_tag.data,
10682 tdata->auth_tag.len,
10683 "Generated auth tag not as expected");
10690 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10692 return test_authenticated_encryption_sessionless(
10697 test_authenticated_decryption_sessionless(
10698 const struct aead_test_data *tdata)
10700 struct crypto_testsuite_params *ts_params = &testsuite_params;
10701 struct crypto_unittest_params *ut_params = &unittest_params;
10704 uint8_t *plaintext;
10705 uint8_t key[tdata->key.len + 1];
10706 struct rte_cryptodev_info dev_info;
10708 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10709 uint64_t feat_flags = dev_info.feature_flags;
10711 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10712 printf("Device doesn't support Sessionless ops.\n");
10713 return TEST_SKIPPED;
10716 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10717 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10718 printf("Device doesn't support RAW data-path APIs.\n");
10719 return TEST_SKIPPED;
10722 /* not supported with CPU crypto */
10723 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10724 return TEST_SKIPPED;
10726 /* Verify the capabilities */
10727 struct rte_cryptodev_sym_capability_idx cap_idx;
10728 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10729 cap_idx.algo.aead = tdata->algo;
10730 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10732 return TEST_SKIPPED;
10734 /* alloc mbuf and set payload */
10735 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10737 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10738 rte_pktmbuf_tailroom(ut_params->ibuf));
10740 /* Create AEAD operation */
10741 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10745 /* Create AEAD xform */
10746 memcpy(key, tdata->key.data, tdata->key.len);
10747 retval = create_aead_xform(ut_params->op,
10749 RTE_CRYPTO_AEAD_OP_DECRYPT,
10750 key, tdata->key.len,
10751 tdata->aad.len, tdata->auth_tag.len,
10756 ut_params->op->sym->m_src = ut_params->ibuf;
10758 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10759 RTE_CRYPTO_OP_SESSIONLESS,
10760 "crypto op session type not sessionless");
10762 /* Process crypto operation */
10763 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10764 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10765 ut_params->op, 0, 0, 0, 0);
10767 TEST_ASSERT_NOT_NULL(process_crypto_request(
10768 ts_params->valid_devs[0], ut_params->op),
10769 "failed to process sym crypto op");
10771 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10773 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10774 "crypto op status not success");
10776 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10777 ut_params->op->sym->cipher.data.offset);
10779 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10781 /* Validate obuf */
10782 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10784 tdata->plaintext.data,
10785 tdata->plaintext.len,
10786 "Plaintext data not as expected");
10788 TEST_ASSERT_EQUAL(ut_params->op->status,
10789 RTE_CRYPTO_OP_STATUS_SUCCESS,
10790 "Authentication failed");
10795 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10797 return test_authenticated_decryption_sessionless(
10802 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10804 return test_authenticated_encryption(&ccm_test_case_128_1);
10808 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10810 return test_authenticated_encryption(&ccm_test_case_128_2);
10814 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10816 return test_authenticated_encryption(&ccm_test_case_128_3);
10820 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10822 return test_authenticated_decryption(&ccm_test_case_128_1);
10826 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10828 return test_authenticated_decryption(&ccm_test_case_128_2);
10832 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10834 return test_authenticated_decryption(&ccm_test_case_128_3);
10838 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10840 return test_authenticated_encryption(&ccm_test_case_192_1);
10844 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10846 return test_authenticated_encryption(&ccm_test_case_192_2);
10850 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10852 return test_authenticated_encryption(&ccm_test_case_192_3);
10856 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10858 return test_authenticated_decryption(&ccm_test_case_192_1);
10862 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10864 return test_authenticated_decryption(&ccm_test_case_192_2);
10868 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10870 return test_authenticated_decryption(&ccm_test_case_192_3);
10874 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10876 return test_authenticated_encryption(&ccm_test_case_256_1);
10880 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10882 return test_authenticated_encryption(&ccm_test_case_256_2);
10886 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10888 return test_authenticated_encryption(&ccm_test_case_256_3);
10892 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10894 return test_authenticated_decryption(&ccm_test_case_256_1);
10898 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10900 return test_authenticated_decryption(&ccm_test_case_256_2);
10904 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10906 return test_authenticated_decryption(&ccm_test_case_256_3);
10912 struct crypto_testsuite_params *ts_params = &testsuite_params;
10913 struct rte_cryptodev_stats stats;
10915 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10916 return TEST_SKIPPED;
10918 /* Verify the capabilities */
10919 struct rte_cryptodev_sym_capability_idx cap_idx;
10920 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10921 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10922 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10924 return TEST_SKIPPED;
10925 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10926 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10927 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10929 return TEST_SKIPPED;
10931 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10933 return TEST_SKIPPED;
10935 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10936 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10937 &stats) == -ENODEV),
10938 "rte_cryptodev_stats_get invalid dev failed");
10939 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10940 "rte_cryptodev_stats_get invalid Param failed");
10942 /* Test expected values */
10943 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10944 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10946 "rte_cryptodev_stats_get failed");
10947 TEST_ASSERT((stats.enqueued_count == 1),
10948 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10949 TEST_ASSERT((stats.dequeued_count == 1),
10950 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10951 TEST_ASSERT((stats.enqueue_err_count == 0),
10952 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10953 TEST_ASSERT((stats.dequeue_err_count == 0),
10954 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10956 /* invalid device but should ignore and not reset device stats*/
10957 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10958 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10960 "rte_cryptodev_stats_get failed");
10961 TEST_ASSERT((stats.enqueued_count == 1),
10962 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10964 /* check that a valid reset clears stats */
10965 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10966 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10968 "rte_cryptodev_stats_get failed");
10969 TEST_ASSERT((stats.enqueued_count == 0),
10970 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10971 TEST_ASSERT((stats.dequeued_count == 0),
10972 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10974 return TEST_SUCCESS;
10977 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10978 struct crypto_unittest_params *ut_params,
10979 enum rte_crypto_auth_operation op,
10980 const struct HMAC_MD5_vector *test_case)
10984 memcpy(key, test_case->key.data, test_case->key.len);
10986 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10987 ut_params->auth_xform.next = NULL;
10988 ut_params->auth_xform.auth.op = op;
10990 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10992 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10993 ut_params->auth_xform.auth.key.length = test_case->key.len;
10994 ut_params->auth_xform.auth.key.data = key;
10996 ut_params->sess = rte_cryptodev_sym_session_create(
10997 ts_params->session_mpool);
10999 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11000 ut_params->sess, &ut_params->auth_xform,
11001 ts_params->session_priv_mpool);
11003 if (ut_params->sess == NULL)
11004 return TEST_FAILED;
11006 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11008 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11009 rte_pktmbuf_tailroom(ut_params->ibuf));
11014 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11015 const struct HMAC_MD5_vector *test_case,
11016 uint8_t **plaintext)
11018 uint16_t plaintext_pad_len;
11020 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11022 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11025 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11026 plaintext_pad_len);
11027 memcpy(*plaintext, test_case->plaintext.data,
11028 test_case->plaintext.len);
11030 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11031 ut_params->ibuf, MD5_DIGEST_LEN);
11032 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11033 "no room to append digest");
11034 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11035 ut_params->ibuf, plaintext_pad_len);
11037 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11038 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11039 test_case->auth_tag.len);
11042 sym_op->auth.data.offset = 0;
11043 sym_op->auth.data.length = test_case->plaintext.len;
11045 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11046 ut_params->op->sym->m_src = ut_params->ibuf;
11052 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11054 uint16_t plaintext_pad_len;
11055 uint8_t *plaintext, *auth_tag;
11057 struct crypto_testsuite_params *ts_params = &testsuite_params;
11058 struct crypto_unittest_params *ut_params = &unittest_params;
11059 struct rte_cryptodev_info dev_info;
11061 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11062 uint64_t feat_flags = dev_info.feature_flags;
11064 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11065 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11066 printf("Device doesn't support RAW data-path APIs.\n");
11067 return TEST_SKIPPED;
11070 /* Verify the capabilities */
11071 struct rte_cryptodev_sym_capability_idx cap_idx;
11072 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11073 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11074 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11076 return TEST_SKIPPED;
11078 if (MD5_HMAC_create_session(ts_params, ut_params,
11079 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11080 return TEST_FAILED;
11082 /* Generate Crypto op data structure */
11083 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11084 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11085 TEST_ASSERT_NOT_NULL(ut_params->op,
11086 "Failed to allocate symmetric crypto operation struct");
11088 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11091 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11092 return TEST_FAILED;
11094 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11095 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11097 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11098 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11099 ut_params->op, 0, 1, 0, 0);
11101 TEST_ASSERT_NOT_NULL(
11102 process_crypto_request(ts_params->valid_devs[0],
11104 "failed to process sym crypto op");
11106 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11107 "crypto op processing failed");
11109 if (ut_params->op->sym->m_dst) {
11110 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11111 uint8_t *, plaintext_pad_len);
11113 auth_tag = plaintext + plaintext_pad_len;
11116 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11118 test_case->auth_tag.data,
11119 test_case->auth_tag.len,
11120 "HMAC_MD5 generated tag not as expected");
11122 return TEST_SUCCESS;
11126 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11128 uint8_t *plaintext;
11130 struct crypto_testsuite_params *ts_params = &testsuite_params;
11131 struct crypto_unittest_params *ut_params = &unittest_params;
11132 struct rte_cryptodev_info dev_info;
11134 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11135 uint64_t feat_flags = dev_info.feature_flags;
11137 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11138 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11139 printf("Device doesn't support RAW data-path APIs.\n");
11140 return TEST_SKIPPED;
11143 /* Verify the capabilities */
11144 struct rte_cryptodev_sym_capability_idx cap_idx;
11145 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11146 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11147 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11149 return TEST_SKIPPED;
11151 if (MD5_HMAC_create_session(ts_params, ut_params,
11152 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11153 return TEST_FAILED;
11156 /* Generate Crypto op data structure */
11157 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11158 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11159 TEST_ASSERT_NOT_NULL(ut_params->op,
11160 "Failed to allocate symmetric crypto operation struct");
11162 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11163 return TEST_FAILED;
11165 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11166 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11168 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11169 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11170 ut_params->op, 0, 1, 0, 0);
11172 TEST_ASSERT_NOT_NULL(
11173 process_crypto_request(ts_params->valid_devs[0],
11175 "failed to process sym crypto op");
11177 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11178 "HMAC_MD5 crypto op processing failed");
11180 return TEST_SUCCESS;
11184 test_MD5_HMAC_generate_case_1(void)
11186 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11190 test_MD5_HMAC_verify_case_1(void)
11192 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11196 test_MD5_HMAC_generate_case_2(void)
11198 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11202 test_MD5_HMAC_verify_case_2(void)
11204 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11208 test_multi_session(void)
11210 struct crypto_testsuite_params *ts_params = &testsuite_params;
11211 struct crypto_unittest_params *ut_params = &unittest_params;
11213 struct rte_cryptodev_info dev_info;
11214 struct rte_cryptodev_sym_session **sessions;
11218 /* Verify the capabilities */
11219 struct rte_cryptodev_sym_capability_idx cap_idx;
11220 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11221 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11222 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11224 return TEST_SKIPPED;
11225 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11226 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11227 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11229 return TEST_SKIPPED;
11231 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11232 aes_cbc_key, hmac_sha512_key);
11235 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11237 sessions = rte_malloc(NULL,
11238 sizeof(struct rte_cryptodev_sym_session *) *
11239 (MAX_NB_SESSIONS + 1), 0);
11241 /* Create multiple crypto sessions*/
11242 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11244 sessions[i] = rte_cryptodev_sym_session_create(
11245 ts_params->session_mpool);
11247 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11248 sessions[i], &ut_params->auth_xform,
11249 ts_params->session_priv_mpool);
11250 TEST_ASSERT_NOT_NULL(sessions[i],
11251 "Session creation failed at session number %u",
11254 /* Attempt to send a request on each session */
11255 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11259 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11260 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11262 "Failed to perform decrypt on request number %u.", i);
11263 /* free crypto operation structure */
11265 rte_crypto_op_free(ut_params->op);
11268 * free mbuf - both obuf and ibuf are usually the same,
11269 * so check if they point at the same address is necessary,
11270 * to avoid freeing the mbuf twice.
11272 if (ut_params->obuf) {
11273 rte_pktmbuf_free(ut_params->obuf);
11274 if (ut_params->ibuf == ut_params->obuf)
11275 ut_params->ibuf = 0;
11276 ut_params->obuf = 0;
11278 if (ut_params->ibuf) {
11279 rte_pktmbuf_free(ut_params->ibuf);
11280 ut_params->ibuf = 0;
11284 sessions[i] = NULL;
11285 /* Next session create should fail */
11286 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11287 sessions[i], &ut_params->auth_xform,
11288 ts_params->session_priv_mpool);
11289 TEST_ASSERT_NULL(sessions[i],
11290 "Session creation succeeded unexpectedly!");
11292 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11293 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11295 rte_cryptodev_sym_session_free(sessions[i]);
11298 rte_free(sessions);
11300 return TEST_SUCCESS;
11303 struct multi_session_params {
11304 struct crypto_unittest_params ut_params;
11305 uint8_t *cipher_key;
11307 const uint8_t *cipher;
11308 const uint8_t *digest;
11312 #define MB_SESSION_NUMBER 3
11315 test_multi_session_random_usage(void)
11317 struct crypto_testsuite_params *ts_params = &testsuite_params;
11318 struct rte_cryptodev_info dev_info;
11319 struct rte_cryptodev_sym_session **sessions;
11321 struct multi_session_params ut_paramz[] = {
11324 .cipher_key = ms_aes_cbc_key0,
11325 .hmac_key = ms_hmac_key0,
11326 .cipher = ms_aes_cbc_cipher0,
11327 .digest = ms_hmac_digest0,
11328 .iv = ms_aes_cbc_iv0
11331 .cipher_key = ms_aes_cbc_key1,
11332 .hmac_key = ms_hmac_key1,
11333 .cipher = ms_aes_cbc_cipher1,
11334 .digest = ms_hmac_digest1,
11335 .iv = ms_aes_cbc_iv1
11338 .cipher_key = ms_aes_cbc_key2,
11339 .hmac_key = ms_hmac_key2,
11340 .cipher = ms_aes_cbc_cipher2,
11341 .digest = ms_hmac_digest2,
11342 .iv = ms_aes_cbc_iv2
11347 /* Verify the capabilities */
11348 struct rte_cryptodev_sym_capability_idx cap_idx;
11349 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11350 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11351 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11353 return TEST_SKIPPED;
11354 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11355 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11356 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11358 return TEST_SKIPPED;
11360 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11362 sessions = rte_malloc(NULL,
11363 (sizeof(struct rte_cryptodev_sym_session *)
11364 * MAX_NB_SESSIONS) + 1, 0);
11366 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11367 sessions[i] = rte_cryptodev_sym_session_create(
11368 ts_params->session_mpool);
11370 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11371 sizeof(struct crypto_unittest_params));
11373 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11374 &ut_paramz[i].ut_params,
11375 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11377 /* Create multiple crypto sessions*/
11378 rte_cryptodev_sym_session_init(
11379 ts_params->valid_devs[0],
11381 &ut_paramz[i].ut_params.auth_xform,
11382 ts_params->session_priv_mpool);
11384 TEST_ASSERT_NOT_NULL(sessions[i],
11385 "Session creation failed at session number %u",
11391 for (i = 0; i < 40000; i++) {
11393 j = rand() % MB_SESSION_NUMBER;
11395 TEST_ASSERT_SUCCESS(
11396 test_AES_CBC_HMAC_SHA512_decrypt_perform(
11398 &ut_paramz[j].ut_params,
11399 ts_params, ut_paramz[j].cipher,
11400 ut_paramz[j].digest,
11402 "Failed to perform decrypt on request number %u.", i);
11404 if (ut_paramz[j].ut_params.op)
11405 rte_crypto_op_free(ut_paramz[j].ut_params.op);
11408 * free mbuf - both obuf and ibuf are usually the same,
11409 * so check if they point at the same address is necessary,
11410 * to avoid freeing the mbuf twice.
11412 if (ut_paramz[j].ut_params.obuf) {
11413 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11414 if (ut_paramz[j].ut_params.ibuf
11415 == ut_paramz[j].ut_params.obuf)
11416 ut_paramz[j].ut_params.ibuf = 0;
11417 ut_paramz[j].ut_params.obuf = 0;
11419 if (ut_paramz[j].ut_params.ibuf) {
11420 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11421 ut_paramz[j].ut_params.ibuf = 0;
11425 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11426 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11428 rte_cryptodev_sym_session_free(sessions[i]);
11431 rte_free(sessions);
11433 return TEST_SUCCESS;
11436 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11437 0xab, 0xab, 0xab, 0xab,
11438 0xab, 0xab, 0xab, 0xab,
11439 0xab, 0xab, 0xab, 0xab};
11442 test_null_invalid_operation(void)
11444 struct crypto_testsuite_params *ts_params = &testsuite_params;
11445 struct crypto_unittest_params *ut_params = &unittest_params;
11448 /* This test is for NULL PMD only */
11449 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11450 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11451 return TEST_SKIPPED;
11453 /* Setup Cipher Parameters */
11454 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11455 ut_params->cipher_xform.next = NULL;
11457 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11458 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11460 ut_params->sess = rte_cryptodev_sym_session_create(
11461 ts_params->session_mpool);
11463 /* Create Crypto session*/
11464 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11465 ut_params->sess, &ut_params->cipher_xform,
11466 ts_params->session_priv_mpool);
11467 TEST_ASSERT(ret < 0,
11468 "Session creation succeeded unexpectedly");
11471 /* Setup HMAC Parameters */
11472 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11473 ut_params->auth_xform.next = NULL;
11475 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11476 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11478 ut_params->sess = rte_cryptodev_sym_session_create(
11479 ts_params->session_mpool);
11481 /* Create Crypto session*/
11482 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11483 ut_params->sess, &ut_params->auth_xform,
11484 ts_params->session_priv_mpool);
11485 TEST_ASSERT(ret < 0,
11486 "Session creation succeeded unexpectedly");
11488 return TEST_SUCCESS;
11492 #define NULL_BURST_LENGTH (32)
11495 test_null_burst_operation(void)
11497 struct crypto_testsuite_params *ts_params = &testsuite_params;
11498 struct crypto_unittest_params *ut_params = &unittest_params;
11500 unsigned i, burst_len = NULL_BURST_LENGTH;
11502 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11503 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11505 /* This test is for NULL PMD only */
11506 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11507 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11508 return TEST_SKIPPED;
11510 /* Setup Cipher Parameters */
11511 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11512 ut_params->cipher_xform.next = &ut_params->auth_xform;
11514 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11515 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11517 /* Setup HMAC Parameters */
11518 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11519 ut_params->auth_xform.next = NULL;
11521 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11522 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11524 ut_params->sess = rte_cryptodev_sym_session_create(
11525 ts_params->session_mpool);
11527 /* Create Crypto session*/
11528 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11529 ut_params->sess, &ut_params->cipher_xform,
11530 ts_params->session_priv_mpool);
11531 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11533 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11534 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11535 burst_len, "failed to generate burst of crypto ops");
11537 /* Generate an operation for each mbuf in burst */
11538 for (i = 0; i < burst_len; i++) {
11539 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11541 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11543 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11547 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11549 burst[i]->sym->m_src = m;
11552 /* Process crypto operation */
11553 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11554 0, burst, burst_len),
11556 "Error enqueuing burst");
11558 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11559 0, burst_dequeued, burst_len),
11561 "Error dequeuing burst");
11564 for (i = 0; i < burst_len; i++) {
11566 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11567 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11569 "data not as expected");
11571 rte_pktmbuf_free(burst[i]->sym->m_src);
11572 rte_crypto_op_free(burst[i]);
11575 return TEST_SUCCESS;
11579 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11580 uint16_t nb_ops, void *user_param)
11582 RTE_SET_USED(dev_id);
11583 RTE_SET_USED(qp_id);
11585 RTE_SET_USED(user_param);
11587 printf("crypto enqueue callback called\n");
11592 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11593 uint16_t nb_ops, void *user_param)
11595 RTE_SET_USED(dev_id);
11596 RTE_SET_USED(qp_id);
11598 RTE_SET_USED(user_param);
11600 printf("crypto dequeue callback called\n");
11605 * Thread using enqueue/dequeue callback with RCU.
11608 test_enqdeq_callback_thread(void *arg)
11611 /* DP thread calls rte_cryptodev_enqueue_burst()/
11612 * rte_cryptodev_dequeue_burst() and invokes callback.
11614 test_null_burst_operation();
11619 test_enq_callback_setup(void)
11621 struct crypto_testsuite_params *ts_params = &testsuite_params;
11622 struct rte_cryptodev_info dev_info;
11623 struct rte_cryptodev_qp_conf qp_conf = {
11624 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11627 struct rte_cryptodev_cb *cb;
11628 uint16_t qp_id = 0;
11630 /* Stop the device in case it's started so it can be configured */
11631 rte_cryptodev_stop(ts_params->valid_devs[0]);
11633 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11635 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11637 "Failed to configure cryptodev %u",
11638 ts_params->valid_devs[0]);
11640 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11641 qp_conf.mp_session = ts_params->session_mpool;
11642 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11644 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11645 ts_params->valid_devs[0], qp_id, &qp_conf,
11646 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11648 "rte_cryptodev_queue_pair_setup: num_inflights "
11649 "%u on qp %u on cryptodev %u",
11650 qp_conf.nb_descriptors, qp_id,
11651 ts_params->valid_devs[0]);
11653 /* Test with invalid crypto device */
11654 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11655 qp_id, test_enq_callback, NULL);
11656 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11657 "cryptodev %u did not fail",
11658 qp_id, RTE_CRYPTO_MAX_DEVS);
11660 /* Test with invalid queue pair */
11661 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11662 dev_info.max_nb_queue_pairs + 1,
11663 test_enq_callback, NULL);
11664 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11665 "cryptodev %u did not fail",
11666 dev_info.max_nb_queue_pairs + 1,
11667 ts_params->valid_devs[0]);
11669 /* Test with NULL callback */
11670 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11671 qp_id, NULL, NULL);
11672 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11673 "cryptodev %u did not fail",
11674 qp_id, ts_params->valid_devs[0]);
11676 /* Test with valid configuration */
11677 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11678 qp_id, test_enq_callback, NULL);
11679 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11680 "qp %u on cryptodev %u",
11681 qp_id, ts_params->valid_devs[0]);
11683 rte_cryptodev_start(ts_params->valid_devs[0]);
11685 /* Launch a thread */
11686 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11687 rte_get_next_lcore(-1, 1, 0));
11689 /* Wait until reader exited. */
11690 rte_eal_mp_wait_lcore();
11692 /* Test with invalid crypto device */
11693 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11694 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11695 "Expected call to fail as crypto device is invalid");
11697 /* Test with invalid queue pair */
11698 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11699 ts_params->valid_devs[0],
11700 dev_info.max_nb_queue_pairs + 1, cb),
11701 "Expected call to fail as queue pair is invalid");
11703 /* Test with NULL callback */
11704 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11705 ts_params->valid_devs[0], qp_id, NULL),
11706 "Expected call to fail as callback is NULL");
11708 /* Test with valid configuration */
11709 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11710 ts_params->valid_devs[0], qp_id, cb),
11711 "Failed test to remove callback on "
11712 "qp %u on cryptodev %u",
11713 qp_id, ts_params->valid_devs[0]);
11715 return TEST_SUCCESS;
11719 test_deq_callback_setup(void)
11721 struct crypto_testsuite_params *ts_params = &testsuite_params;
11722 struct rte_cryptodev_info dev_info;
11723 struct rte_cryptodev_qp_conf qp_conf = {
11724 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11727 struct rte_cryptodev_cb *cb;
11728 uint16_t qp_id = 0;
11730 /* Stop the device in case it's started so it can be configured */
11731 rte_cryptodev_stop(ts_params->valid_devs[0]);
11733 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11735 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11737 "Failed to configure cryptodev %u",
11738 ts_params->valid_devs[0]);
11740 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11741 qp_conf.mp_session = ts_params->session_mpool;
11742 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11744 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11745 ts_params->valid_devs[0], qp_id, &qp_conf,
11746 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11748 "rte_cryptodev_queue_pair_setup: num_inflights "
11749 "%u on qp %u on cryptodev %u",
11750 qp_conf.nb_descriptors, qp_id,
11751 ts_params->valid_devs[0]);
11753 /* Test with invalid crypto device */
11754 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11755 qp_id, test_deq_callback, NULL);
11756 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11757 "cryptodev %u did not fail",
11758 qp_id, RTE_CRYPTO_MAX_DEVS);
11760 /* Test with invalid queue pair */
11761 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11762 dev_info.max_nb_queue_pairs + 1,
11763 test_deq_callback, NULL);
11764 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11765 "cryptodev %u did not fail",
11766 dev_info.max_nb_queue_pairs + 1,
11767 ts_params->valid_devs[0]);
11769 /* Test with NULL callback */
11770 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11771 qp_id, NULL, NULL);
11772 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11773 "cryptodev %u did not fail",
11774 qp_id, ts_params->valid_devs[0]);
11776 /* Test with valid configuration */
11777 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11778 qp_id, test_deq_callback, NULL);
11779 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11780 "qp %u on cryptodev %u",
11781 qp_id, ts_params->valid_devs[0]);
11783 rte_cryptodev_start(ts_params->valid_devs[0]);
11785 /* Launch a thread */
11786 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11787 rte_get_next_lcore(-1, 1, 0));
11789 /* Wait until reader exited. */
11790 rte_eal_mp_wait_lcore();
11792 /* Test with invalid crypto device */
11793 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11794 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11795 "Expected call to fail as crypto device is invalid");
11797 /* Test with invalid queue pair */
11798 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11799 ts_params->valid_devs[0],
11800 dev_info.max_nb_queue_pairs + 1, cb),
11801 "Expected call to fail as queue pair is invalid");
11803 /* Test with NULL callback */
11804 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11805 ts_params->valid_devs[0], qp_id, NULL),
11806 "Expected call to fail as callback is NULL");
11808 /* Test with valid configuration */
11809 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11810 ts_params->valid_devs[0], qp_id, cb),
11811 "Failed test to remove callback on "
11812 "qp %u on cryptodev %u",
11813 qp_id, ts_params->valid_devs[0]);
11815 return TEST_SUCCESS;
11819 generate_gmac_large_plaintext(uint8_t *data)
11823 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11824 memcpy(&data[i], &data[0], 32);
11828 create_gmac_operation(enum rte_crypto_auth_operation op,
11829 const struct gmac_test_data *tdata)
11831 struct crypto_testsuite_params *ts_params = &testsuite_params;
11832 struct crypto_unittest_params *ut_params = &unittest_params;
11833 struct rte_crypto_sym_op *sym_op;
11835 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11837 /* Generate Crypto op data structure */
11838 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11839 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11840 TEST_ASSERT_NOT_NULL(ut_params->op,
11841 "Failed to allocate symmetric crypto operation struct");
11843 sym_op = ut_params->op->sym;
11845 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11846 ut_params->ibuf, tdata->gmac_tag.len);
11847 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11848 "no room to append digest");
11850 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11851 ut_params->ibuf, plaintext_pad_len);
11853 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11854 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11855 tdata->gmac_tag.len);
11856 debug_hexdump(stdout, "digest:",
11857 sym_op->auth.digest.data,
11858 tdata->gmac_tag.len);
11861 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11862 uint8_t *, IV_OFFSET);
11864 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11866 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11868 sym_op->cipher.data.length = 0;
11869 sym_op->cipher.data.offset = 0;
11871 sym_op->auth.data.offset = 0;
11872 sym_op->auth.data.length = tdata->plaintext.len;
11878 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11879 const struct gmac_test_data *tdata,
11880 void *digest_mem, uint64_t digest_phys)
11882 struct crypto_testsuite_params *ts_params = &testsuite_params;
11883 struct crypto_unittest_params *ut_params = &unittest_params;
11884 struct rte_crypto_sym_op *sym_op;
11886 /* Generate Crypto op data structure */
11887 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11888 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11889 TEST_ASSERT_NOT_NULL(ut_params->op,
11890 "Failed to allocate symmetric crypto operation struct");
11892 sym_op = ut_params->op->sym;
11894 sym_op->auth.digest.data = digest_mem;
11895 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11896 "no room to append digest");
11898 sym_op->auth.digest.phys_addr = digest_phys;
11900 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11901 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11902 tdata->gmac_tag.len);
11903 debug_hexdump(stdout, "digest:",
11904 sym_op->auth.digest.data,
11905 tdata->gmac_tag.len);
11908 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11909 uint8_t *, IV_OFFSET);
11911 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11913 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11915 sym_op->cipher.data.length = 0;
11916 sym_op->cipher.data.offset = 0;
11918 sym_op->auth.data.offset = 0;
11919 sym_op->auth.data.length = tdata->plaintext.len;
11924 static int create_gmac_session(uint8_t dev_id,
11925 const struct gmac_test_data *tdata,
11926 enum rte_crypto_auth_operation auth_op)
11928 uint8_t auth_key[tdata->key.len];
11930 struct crypto_testsuite_params *ts_params = &testsuite_params;
11931 struct crypto_unittest_params *ut_params = &unittest_params;
11933 memcpy(auth_key, tdata->key.data, tdata->key.len);
11935 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11936 ut_params->auth_xform.next = NULL;
11938 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11939 ut_params->auth_xform.auth.op = auth_op;
11940 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11941 ut_params->auth_xform.auth.key.length = tdata->key.len;
11942 ut_params->auth_xform.auth.key.data = auth_key;
11943 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11944 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11947 ut_params->sess = rte_cryptodev_sym_session_create(
11948 ts_params->session_mpool);
11950 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11951 &ut_params->auth_xform,
11952 ts_params->session_priv_mpool);
11954 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11960 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11962 struct crypto_testsuite_params *ts_params = &testsuite_params;
11963 struct crypto_unittest_params *ut_params = &unittest_params;
11964 struct rte_cryptodev_info dev_info;
11966 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11967 uint64_t feat_flags = dev_info.feature_flags;
11969 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11970 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11971 printf("Device doesn't support RAW data-path APIs.\n");
11972 return TEST_SKIPPED;
11977 uint8_t *auth_tag, *plaintext;
11978 uint16_t plaintext_pad_len;
11980 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11981 "No GMAC length in the source data");
11983 /* Verify the capabilities */
11984 struct rte_cryptodev_sym_capability_idx cap_idx;
11985 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11986 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11987 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11989 return TEST_SKIPPED;
11991 retval = create_gmac_session(ts_params->valid_devs[0],
11992 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11997 if (tdata->plaintext.len > MBUF_SIZE)
11998 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12000 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12001 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12002 "Failed to allocate input buffer in mempool");
12004 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12005 rte_pktmbuf_tailroom(ut_params->ibuf));
12007 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12009 * Runtime generate the large plain text instead of use hard code
12010 * plain text vector. It is done to avoid create huge source file
12011 * with the test vector.
12013 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12014 generate_gmac_large_plaintext(tdata->plaintext.data);
12016 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12017 plaintext_pad_len);
12018 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12020 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12021 debug_hexdump(stdout, "plaintext:", plaintext,
12022 tdata->plaintext.len);
12024 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12030 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12032 ut_params->op->sym->m_src = ut_params->ibuf;
12034 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12035 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12037 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12038 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12039 ut_params->op, 0, 1, 0, 0);
12041 TEST_ASSERT_NOT_NULL(
12042 process_crypto_request(ts_params->valid_devs[0],
12043 ut_params->op), "failed to process sym crypto op");
12045 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12046 "crypto op processing failed");
12048 if (ut_params->op->sym->m_dst) {
12049 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12050 uint8_t *, plaintext_pad_len);
12052 auth_tag = plaintext + plaintext_pad_len;
12055 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12057 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12059 tdata->gmac_tag.data,
12060 tdata->gmac_tag.len,
12061 "GMAC Generated auth tag not as expected");
12067 test_AES_GMAC_authentication_test_case_1(void)
12069 return test_AES_GMAC_authentication(&gmac_test_case_1);
12073 test_AES_GMAC_authentication_test_case_2(void)
12075 return test_AES_GMAC_authentication(&gmac_test_case_2);
12079 test_AES_GMAC_authentication_test_case_3(void)
12081 return test_AES_GMAC_authentication(&gmac_test_case_3);
12085 test_AES_GMAC_authentication_test_case_4(void)
12087 return test_AES_GMAC_authentication(&gmac_test_case_4);
12091 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12093 struct crypto_testsuite_params *ts_params = &testsuite_params;
12094 struct crypto_unittest_params *ut_params = &unittest_params;
12096 uint32_t plaintext_pad_len;
12097 uint8_t *plaintext;
12098 struct rte_cryptodev_info dev_info;
12100 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12101 uint64_t feat_flags = dev_info.feature_flags;
12103 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12104 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12105 printf("Device doesn't support RAW data-path APIs.\n");
12106 return TEST_SKIPPED;
12109 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12110 "No GMAC length in the source data");
12112 /* Verify the capabilities */
12113 struct rte_cryptodev_sym_capability_idx cap_idx;
12114 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12115 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12116 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12118 return TEST_SKIPPED;
12120 retval = create_gmac_session(ts_params->valid_devs[0],
12121 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12126 if (tdata->plaintext.len > MBUF_SIZE)
12127 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12129 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12130 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12131 "Failed to allocate input buffer in mempool");
12133 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12134 rte_pktmbuf_tailroom(ut_params->ibuf));
12136 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12139 * Runtime generate the large plain text instead of use hard code
12140 * plain text vector. It is done to avoid create huge source file
12141 * with the test vector.
12143 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12144 generate_gmac_large_plaintext(tdata->plaintext.data);
12146 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12147 plaintext_pad_len);
12148 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12150 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12151 debug_hexdump(stdout, "plaintext:", plaintext,
12152 tdata->plaintext.len);
12154 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
12160 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12162 ut_params->op->sym->m_src = ut_params->ibuf;
12164 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12165 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12167 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12168 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12169 ut_params->op, 0, 1, 0, 0);
12171 TEST_ASSERT_NOT_NULL(
12172 process_crypto_request(ts_params->valid_devs[0],
12173 ut_params->op), "failed to process sym crypto op");
12175 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12176 "crypto op processing failed");
12183 test_AES_GMAC_authentication_verify_test_case_1(void)
12185 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12189 test_AES_GMAC_authentication_verify_test_case_2(void)
12191 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12195 test_AES_GMAC_authentication_verify_test_case_3(void)
12197 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12201 test_AES_GMAC_authentication_verify_test_case_4(void)
12203 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12207 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12210 struct crypto_testsuite_params *ts_params = &testsuite_params;
12211 struct crypto_unittest_params *ut_params = &unittest_params;
12212 struct rte_cryptodev_info dev_info;
12213 uint64_t feature_flags;
12214 unsigned int trn_data = 0;
12215 void *digest_mem = NULL;
12217 unsigned int to_trn = 0;
12218 struct rte_mbuf *buf = NULL;
12219 uint8_t *auth_tag, *plaintext;
12222 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12223 "No GMAC length in the source data");
12225 /* Verify the capabilities */
12226 struct rte_cryptodev_sym_capability_idx cap_idx;
12227 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12228 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12229 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12231 return TEST_SKIPPED;
12233 /* Check for any input SGL support */
12234 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12235 feature_flags = dev_info.feature_flags;
12237 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12238 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12239 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12240 return TEST_SKIPPED;
12242 if (fragsz > tdata->plaintext.len)
12243 fragsz = tdata->plaintext.len;
12245 uint16_t plaintext_len = fragsz;
12247 retval = create_gmac_session(ts_params->valid_devs[0],
12248 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12253 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12254 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12255 "Failed to allocate input buffer in mempool");
12257 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12258 rte_pktmbuf_tailroom(ut_params->ibuf));
12260 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12262 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12264 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12266 trn_data += plaintext_len;
12268 buf = ut_params->ibuf;
12271 * Loop until no more fragments
12274 while (trn_data < tdata->plaintext.len) {
12276 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12277 (tdata->plaintext.len - trn_data) : fragsz;
12279 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12282 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12283 rte_pktmbuf_tailroom(buf));
12285 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12288 memcpy(plaintext, tdata->plaintext.data + trn_data,
12290 trn_data += to_trn;
12291 if (trn_data == tdata->plaintext.len)
12292 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12293 tdata->gmac_tag.len);
12295 ut_params->ibuf->nb_segs = segs;
12298 * Place digest at the end of the last buffer
12300 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12303 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12304 + tdata->gmac_tag.len);
12305 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12306 tdata->plaintext.len);
12309 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12310 tdata, digest_mem, digest_phys);
12315 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12317 ut_params->op->sym->m_src = ut_params->ibuf;
12319 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12320 return TEST_SKIPPED;
12322 TEST_ASSERT_NOT_NULL(
12323 process_crypto_request(ts_params->valid_devs[0],
12324 ut_params->op), "failed to process sym crypto op");
12326 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12327 "crypto op processing failed");
12329 auth_tag = digest_mem;
12330 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12331 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12333 tdata->gmac_tag.data,
12334 tdata->gmac_tag.len,
12335 "GMAC Generated auth tag not as expected");
12340 /* Segment size not multiple of block size (16B) */
12342 test_AES_GMAC_authentication_SGL_40B(void)
12344 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12348 test_AES_GMAC_authentication_SGL_80B(void)
12350 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12354 test_AES_GMAC_authentication_SGL_2048B(void)
12356 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12359 /* Segment size not multiple of block size (16B) */
12361 test_AES_GMAC_authentication_SGL_2047B(void)
12363 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12366 struct test_crypto_vector {
12367 enum rte_crypto_cipher_algorithm crypto_algo;
12368 unsigned int cipher_offset;
12369 unsigned int cipher_len;
12382 const uint8_t *data;
12387 const uint8_t *data;
12391 enum rte_crypto_auth_algorithm auth_algo;
12392 unsigned int auth_offset;
12400 const uint8_t *data;
12410 static const struct test_crypto_vector
12411 hmac_sha1_test_crypto_vector = {
12412 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12414 .data = plaintext_hash,
12419 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12420 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12421 0xDE, 0xF4, 0xDE, 0xAD
12427 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12428 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12429 0x3F, 0x91, 0x64, 0x59
12435 static const struct test_crypto_vector
12436 aes128_gmac_test_vector = {
12437 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12439 .data = plaintext_hash,
12444 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12445 0x08, 0x09, 0x0A, 0x0B
12451 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12452 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12458 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12459 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12465 static const struct test_crypto_vector
12466 aes128cbc_hmac_sha1_test_vector = {
12467 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12468 .cipher_offset = 0,
12472 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12473 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12479 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12480 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12485 .data = plaintext_hash,
12489 .data = ciphertext512_aes128cbc,
12492 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12496 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12497 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12498 0xDE, 0xF4, 0xDE, 0xAD
12504 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12505 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12506 0x18, 0x8C, 0x1D, 0x32
12512 static const struct test_crypto_vector
12513 aes128cbc_hmac_sha1_aad_test_vector = {
12514 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12515 .cipher_offset = 8,
12519 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12520 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12526 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12527 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12532 .data = plaintext_hash,
12536 .data = ciphertext512_aes128cbc_aad,
12539 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12543 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12544 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12545 0xDE, 0xF4, 0xDE, 0xAD
12551 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12552 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12553 0x62, 0x0F, 0xFB, 0x10
12560 data_corruption(uint8_t *data)
12566 tag_corruption(uint8_t *data, unsigned int tag_offset)
12568 data[tag_offset] += 1;
12572 create_auth_session(struct crypto_unittest_params *ut_params,
12574 const struct test_crypto_vector *reference,
12575 enum rte_crypto_auth_operation auth_op)
12577 struct crypto_testsuite_params *ts_params = &testsuite_params;
12578 uint8_t auth_key[reference->auth_key.len + 1];
12580 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12582 /* Setup Authentication Parameters */
12583 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12584 ut_params->auth_xform.auth.op = auth_op;
12585 ut_params->auth_xform.next = NULL;
12586 ut_params->auth_xform.auth.algo = reference->auth_algo;
12587 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12588 ut_params->auth_xform.auth.key.data = auth_key;
12589 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12591 /* Create Crypto session*/
12592 ut_params->sess = rte_cryptodev_sym_session_create(
12593 ts_params->session_mpool);
12595 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12596 &ut_params->auth_xform,
12597 ts_params->session_priv_mpool);
12599 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12605 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12607 const struct test_crypto_vector *reference,
12608 enum rte_crypto_auth_operation auth_op,
12609 enum rte_crypto_cipher_operation cipher_op)
12611 struct crypto_testsuite_params *ts_params = &testsuite_params;
12612 uint8_t cipher_key[reference->cipher_key.len + 1];
12613 uint8_t auth_key[reference->auth_key.len + 1];
12615 memcpy(cipher_key, reference->cipher_key.data,
12616 reference->cipher_key.len);
12617 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12619 /* Setup Authentication Parameters */
12620 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12621 ut_params->auth_xform.auth.op = auth_op;
12622 ut_params->auth_xform.auth.algo = reference->auth_algo;
12623 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12624 ut_params->auth_xform.auth.key.data = auth_key;
12625 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12627 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12628 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12629 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12631 ut_params->auth_xform.next = &ut_params->cipher_xform;
12633 /* Setup Cipher Parameters */
12634 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12635 ut_params->cipher_xform.next = NULL;
12636 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12637 ut_params->cipher_xform.cipher.op = cipher_op;
12638 ut_params->cipher_xform.cipher.key.data = cipher_key;
12639 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12640 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12641 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12644 /* Create Crypto session*/
12645 ut_params->sess = rte_cryptodev_sym_session_create(
12646 ts_params->session_mpool);
12648 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12649 &ut_params->auth_xform,
12650 ts_params->session_priv_mpool);
12652 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12658 create_auth_operation(struct crypto_testsuite_params *ts_params,
12659 struct crypto_unittest_params *ut_params,
12660 const struct test_crypto_vector *reference,
12661 unsigned int auth_generate)
12663 /* Generate Crypto op data structure */
12664 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12665 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12666 TEST_ASSERT_NOT_NULL(ut_params->op,
12667 "Failed to allocate pktmbuf offload");
12669 /* Set crypto operation data parameters */
12670 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12672 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12674 /* set crypto operation source mbuf */
12675 sym_op->m_src = ut_params->ibuf;
12678 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12679 ut_params->ibuf, reference->digest.len);
12681 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12682 "no room to append auth tag");
12684 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12685 ut_params->ibuf, reference->plaintext.len);
12688 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12690 memcpy(sym_op->auth.digest.data,
12691 reference->digest.data,
12692 reference->digest.len);
12694 debug_hexdump(stdout, "digest:",
12695 sym_op->auth.digest.data,
12696 reference->digest.len);
12698 sym_op->auth.data.length = reference->plaintext.len;
12699 sym_op->auth.data.offset = 0;
12705 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12706 struct crypto_unittest_params *ut_params,
12707 const struct test_crypto_vector *reference,
12708 unsigned int auth_generate)
12710 /* Generate Crypto op data structure */
12711 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12712 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12713 TEST_ASSERT_NOT_NULL(ut_params->op,
12714 "Failed to allocate pktmbuf offload");
12716 /* Set crypto operation data parameters */
12717 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12719 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12721 /* set crypto operation source mbuf */
12722 sym_op->m_src = ut_params->ibuf;
12725 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12726 ut_params->ibuf, reference->digest.len);
12728 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12729 "no room to append auth tag");
12731 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12732 ut_params->ibuf, reference->ciphertext.len);
12735 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12737 memcpy(sym_op->auth.digest.data,
12738 reference->digest.data,
12739 reference->digest.len);
12741 debug_hexdump(stdout, "digest:",
12742 sym_op->auth.digest.data,
12743 reference->digest.len);
12745 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12746 reference->iv.data, reference->iv.len);
12748 sym_op->cipher.data.length = 0;
12749 sym_op->cipher.data.offset = 0;
12751 sym_op->auth.data.length = reference->plaintext.len;
12752 sym_op->auth.data.offset = 0;
12758 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12759 struct crypto_unittest_params *ut_params,
12760 const struct test_crypto_vector *reference,
12761 unsigned int auth_generate)
12763 /* Generate Crypto op data structure */
12764 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12765 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12766 TEST_ASSERT_NOT_NULL(ut_params->op,
12767 "Failed to allocate pktmbuf offload");
12769 /* Set crypto operation data parameters */
12770 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12772 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12774 /* set crypto operation source mbuf */
12775 sym_op->m_src = ut_params->ibuf;
12778 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12779 ut_params->ibuf, reference->digest.len);
12781 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12782 "no room to append auth tag");
12784 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12785 ut_params->ibuf, reference->ciphertext.len);
12788 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12790 memcpy(sym_op->auth.digest.data,
12791 reference->digest.data,
12792 reference->digest.len);
12794 debug_hexdump(stdout, "digest:",
12795 sym_op->auth.digest.data,
12796 reference->digest.len);
12798 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12799 reference->iv.data, reference->iv.len);
12801 sym_op->cipher.data.length = reference->cipher_len;
12802 sym_op->cipher.data.offset = reference->cipher_offset;
12804 sym_op->auth.data.length = reference->plaintext.len;
12805 sym_op->auth.data.offset = reference->auth_offset;
12811 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12812 struct crypto_unittest_params *ut_params,
12813 const struct test_crypto_vector *reference)
12815 return create_auth_operation(ts_params, ut_params, reference, 0);
12819 create_auth_verify_GMAC_operation(
12820 struct crypto_testsuite_params *ts_params,
12821 struct crypto_unittest_params *ut_params,
12822 const struct test_crypto_vector *reference)
12824 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12828 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12829 struct crypto_unittest_params *ut_params,
12830 const struct test_crypto_vector *reference)
12832 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12836 test_authentication_verify_fail_when_data_corruption(
12837 struct crypto_testsuite_params *ts_params,
12838 struct crypto_unittest_params *ut_params,
12839 const struct test_crypto_vector *reference,
12840 unsigned int data_corrupted)
12844 uint8_t *plaintext;
12845 struct rte_cryptodev_info dev_info;
12847 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12848 uint64_t feat_flags = dev_info.feature_flags;
12850 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12851 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12852 printf("Device doesn't support RAW data-path APIs.\n");
12853 return TEST_SKIPPED;
12856 /* Verify the capabilities */
12857 struct rte_cryptodev_sym_capability_idx cap_idx;
12858 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12859 cap_idx.algo.auth = reference->auth_algo;
12860 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12862 return TEST_SKIPPED;
12865 /* Create session */
12866 retval = create_auth_session(ut_params,
12867 ts_params->valid_devs[0],
12869 RTE_CRYPTO_AUTH_OP_VERIFY);
12873 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12874 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12875 "Failed to allocate input buffer in mempool");
12877 /* clear mbuf payload */
12878 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12879 rte_pktmbuf_tailroom(ut_params->ibuf));
12881 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12882 reference->plaintext.len);
12883 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12884 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12886 debug_hexdump(stdout, "plaintext:", plaintext,
12887 reference->plaintext.len);
12889 /* Create operation */
12890 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12895 if (data_corrupted)
12896 data_corruption(plaintext);
12898 tag_corruption(plaintext, reference->plaintext.len);
12900 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12901 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12903 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12904 RTE_CRYPTO_OP_STATUS_SUCCESS,
12905 "authentication not failed");
12906 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12907 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12908 ut_params->op, 0, 1, 0, 0);
12910 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12912 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12919 test_authentication_verify_GMAC_fail_when_corruption(
12920 struct crypto_testsuite_params *ts_params,
12921 struct crypto_unittest_params *ut_params,
12922 const struct test_crypto_vector *reference,
12923 unsigned int data_corrupted)
12926 uint8_t *plaintext;
12927 struct rte_cryptodev_info dev_info;
12929 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12930 uint64_t feat_flags = dev_info.feature_flags;
12932 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12933 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12934 printf("Device doesn't support RAW data-path APIs.\n");
12935 return TEST_SKIPPED;
12938 /* Verify the capabilities */
12939 struct rte_cryptodev_sym_capability_idx cap_idx;
12940 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12941 cap_idx.algo.auth = reference->auth_algo;
12942 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12944 return TEST_SKIPPED;
12946 /* Create session */
12947 retval = create_auth_cipher_session(ut_params,
12948 ts_params->valid_devs[0],
12950 RTE_CRYPTO_AUTH_OP_VERIFY,
12951 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12955 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12956 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12957 "Failed to allocate input buffer in mempool");
12959 /* clear mbuf payload */
12960 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12961 rte_pktmbuf_tailroom(ut_params->ibuf));
12963 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12964 reference->plaintext.len);
12965 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12966 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12968 debug_hexdump(stdout, "plaintext:", plaintext,
12969 reference->plaintext.len);
12971 /* Create operation */
12972 retval = create_auth_verify_GMAC_operation(ts_params,
12979 if (data_corrupted)
12980 data_corruption(plaintext);
12982 tag_corruption(plaintext, reference->aad.len);
12984 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12985 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12987 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12988 RTE_CRYPTO_OP_STATUS_SUCCESS,
12989 "authentication not failed");
12990 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12991 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12992 ut_params->op, 0, 1, 0, 0);
12994 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12996 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13003 test_authenticated_decryption_fail_when_corruption(
13004 struct crypto_testsuite_params *ts_params,
13005 struct crypto_unittest_params *ut_params,
13006 const struct test_crypto_vector *reference,
13007 unsigned int data_corrupted)
13011 uint8_t *ciphertext;
13012 struct rte_cryptodev_info dev_info;
13014 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13015 uint64_t feat_flags = dev_info.feature_flags;
13017 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13018 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13019 printf("Device doesn't support RAW data-path APIs.\n");
13020 return TEST_SKIPPED;
13023 /* Verify the capabilities */
13024 struct rte_cryptodev_sym_capability_idx cap_idx;
13025 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13026 cap_idx.algo.auth = reference->auth_algo;
13027 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13029 return TEST_SKIPPED;
13030 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13031 cap_idx.algo.cipher = reference->crypto_algo;
13032 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13034 return TEST_SKIPPED;
13036 /* Create session */
13037 retval = create_auth_cipher_session(ut_params,
13038 ts_params->valid_devs[0],
13040 RTE_CRYPTO_AUTH_OP_VERIFY,
13041 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13045 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13046 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13047 "Failed to allocate input buffer in mempool");
13049 /* clear mbuf payload */
13050 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13051 rte_pktmbuf_tailroom(ut_params->ibuf));
13053 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13054 reference->ciphertext.len);
13055 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13056 memcpy(ciphertext, reference->ciphertext.data,
13057 reference->ciphertext.len);
13059 /* Create operation */
13060 retval = create_cipher_auth_verify_operation(ts_params,
13067 if (data_corrupted)
13068 data_corruption(ciphertext);
13070 tag_corruption(ciphertext, reference->ciphertext.len);
13072 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13073 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13075 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13076 RTE_CRYPTO_OP_STATUS_SUCCESS,
13077 "authentication not failed");
13078 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13079 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13080 ut_params->op, 1, 1, 0, 0);
13082 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13084 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13091 test_authenticated_encrypt_with_esn(
13092 struct crypto_testsuite_params *ts_params,
13093 struct crypto_unittest_params *ut_params,
13094 const struct test_crypto_vector *reference)
13098 uint8_t *authciphertext, *plaintext, *auth_tag;
13099 uint16_t plaintext_pad_len;
13100 uint8_t cipher_key[reference->cipher_key.len + 1];
13101 uint8_t auth_key[reference->auth_key.len + 1];
13102 struct rte_cryptodev_info dev_info;
13104 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13105 uint64_t feat_flags = dev_info.feature_flags;
13107 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13108 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13109 printf("Device doesn't support RAW data-path APIs.\n");
13110 return TEST_SKIPPED;
13113 /* Verify the capabilities */
13114 struct rte_cryptodev_sym_capability_idx cap_idx;
13115 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13116 cap_idx.algo.auth = reference->auth_algo;
13117 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13119 return TEST_SKIPPED;
13120 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13121 cap_idx.algo.cipher = reference->crypto_algo;
13122 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13124 return TEST_SKIPPED;
13126 /* Create session */
13127 memcpy(cipher_key, reference->cipher_key.data,
13128 reference->cipher_key.len);
13129 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13131 /* Setup Cipher Parameters */
13132 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13133 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13134 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13135 ut_params->cipher_xform.cipher.key.data = cipher_key;
13136 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13137 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13138 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13140 ut_params->cipher_xform.next = &ut_params->auth_xform;
13142 /* Setup Authentication Parameters */
13143 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13144 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13145 ut_params->auth_xform.auth.algo = reference->auth_algo;
13146 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13147 ut_params->auth_xform.auth.key.data = auth_key;
13148 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13149 ut_params->auth_xform.next = NULL;
13151 /* Create Crypto session*/
13152 ut_params->sess = rte_cryptodev_sym_session_create(
13153 ts_params->session_mpool);
13155 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13157 &ut_params->cipher_xform,
13158 ts_params->session_priv_mpool);
13160 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13162 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13163 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13164 "Failed to allocate input buffer in mempool");
13166 /* clear mbuf payload */
13167 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13168 rte_pktmbuf_tailroom(ut_params->ibuf));
13170 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13171 reference->plaintext.len);
13172 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13173 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13175 /* Create operation */
13176 retval = create_cipher_auth_operation(ts_params,
13183 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13184 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13186 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13187 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13188 ut_params->op, 1, 1, 0, 0);
13190 ut_params->op = process_crypto_request(
13191 ts_params->valid_devs[0], ut_params->op);
13193 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13195 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13196 "crypto op processing failed");
13198 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13200 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13201 ut_params->op->sym->auth.data.offset);
13202 auth_tag = authciphertext + plaintext_pad_len;
13203 debug_hexdump(stdout, "ciphertext:", authciphertext,
13204 reference->ciphertext.len);
13205 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13207 /* Validate obuf */
13208 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13210 reference->ciphertext.data,
13211 reference->ciphertext.len,
13212 "Ciphertext data not as expected");
13214 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13216 reference->digest.data,
13217 reference->digest.len,
13218 "Generated digest not as expected");
13220 return TEST_SUCCESS;
13225 test_authenticated_decrypt_with_esn(
13226 struct crypto_testsuite_params *ts_params,
13227 struct crypto_unittest_params *ut_params,
13228 const struct test_crypto_vector *reference)
13232 uint8_t *ciphertext;
13233 uint8_t cipher_key[reference->cipher_key.len + 1];
13234 uint8_t auth_key[reference->auth_key.len + 1];
13235 struct rte_cryptodev_info dev_info;
13237 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13238 uint64_t feat_flags = dev_info.feature_flags;
13240 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13241 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13242 printf("Device doesn't support RAW data-path APIs.\n");
13243 return TEST_SKIPPED;
13246 /* Verify the capabilities */
13247 struct rte_cryptodev_sym_capability_idx cap_idx;
13248 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13249 cap_idx.algo.auth = reference->auth_algo;
13250 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13252 return TEST_SKIPPED;
13253 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13254 cap_idx.algo.cipher = reference->crypto_algo;
13255 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13257 return TEST_SKIPPED;
13259 /* Create session */
13260 memcpy(cipher_key, reference->cipher_key.data,
13261 reference->cipher_key.len);
13262 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13264 /* Setup Authentication Parameters */
13265 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13266 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13267 ut_params->auth_xform.auth.algo = reference->auth_algo;
13268 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13269 ut_params->auth_xform.auth.key.data = auth_key;
13270 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13271 ut_params->auth_xform.next = &ut_params->cipher_xform;
13273 /* Setup Cipher Parameters */
13274 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13275 ut_params->cipher_xform.next = NULL;
13276 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13277 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13278 ut_params->cipher_xform.cipher.key.data = cipher_key;
13279 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13280 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13281 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13283 /* Create Crypto session*/
13284 ut_params->sess = rte_cryptodev_sym_session_create(
13285 ts_params->session_mpool);
13287 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13289 &ut_params->auth_xform,
13290 ts_params->session_priv_mpool);
13292 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13294 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13295 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13296 "Failed to allocate input buffer in mempool");
13298 /* clear mbuf payload */
13299 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13300 rte_pktmbuf_tailroom(ut_params->ibuf));
13302 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13303 reference->ciphertext.len);
13304 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13305 memcpy(ciphertext, reference->ciphertext.data,
13306 reference->ciphertext.len);
13308 /* Create operation */
13309 retval = create_cipher_auth_verify_operation(ts_params,
13316 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13317 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13319 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13320 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13321 ut_params->op, 1, 1, 0, 0);
13323 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13326 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13327 TEST_ASSERT_EQUAL(ut_params->op->status,
13328 RTE_CRYPTO_OP_STATUS_SUCCESS,
13329 "crypto op processing passed");
13331 ut_params->obuf = ut_params->op->sym->m_src;
13332 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13338 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13339 const struct aead_test_data *tdata,
13340 void *digest_mem, uint64_t digest_phys)
13342 struct crypto_testsuite_params *ts_params = &testsuite_params;
13343 struct crypto_unittest_params *ut_params = &unittest_params;
13345 const unsigned int auth_tag_len = tdata->auth_tag.len;
13346 const unsigned int iv_len = tdata->iv.len;
13347 unsigned int aad_len = tdata->aad.len;
13348 unsigned int aad_len_pad = 0;
13350 /* Generate Crypto op data structure */
13351 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13352 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13353 TEST_ASSERT_NOT_NULL(ut_params->op,
13354 "Failed to allocate symmetric crypto operation struct");
13356 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13358 sym_op->aead.digest.data = digest_mem;
13360 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13361 "no room to append digest");
13363 sym_op->aead.digest.phys_addr = digest_phys;
13365 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13366 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13368 debug_hexdump(stdout, "digest:",
13369 sym_op->aead.digest.data,
13373 /* Append aad data */
13374 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13375 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13376 uint8_t *, IV_OFFSET);
13378 /* Copy IV 1 byte after the IV pointer, according to the API */
13379 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13381 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13383 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13384 ut_params->ibuf, aad_len);
13385 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13386 "no room to prepend aad");
13387 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13390 memset(sym_op->aead.aad.data, 0, aad_len);
13391 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
13392 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13394 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13395 debug_hexdump(stdout, "aad:",
13396 sym_op->aead.aad.data, aad_len);
13398 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13399 uint8_t *, IV_OFFSET);
13401 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13403 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13405 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13406 ut_params->ibuf, aad_len_pad);
13407 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13408 "no room to prepend aad");
13409 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13412 memset(sym_op->aead.aad.data, 0, aad_len);
13413 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13415 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13416 debug_hexdump(stdout, "aad:",
13417 sym_op->aead.aad.data, aad_len);
13420 sym_op->aead.data.length = tdata->plaintext.len;
13421 sym_op->aead.data.offset = aad_len_pad;
13426 #define SGL_MAX_NO 16
13429 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13430 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13432 struct crypto_testsuite_params *ts_params = &testsuite_params;
13433 struct crypto_unittest_params *ut_params = &unittest_params;
13434 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13437 int to_trn_tbl[SGL_MAX_NO];
13439 unsigned int trn_data = 0;
13440 uint8_t *plaintext, *ciphertext, *auth_tag;
13441 struct rte_cryptodev_info dev_info;
13443 /* Verify the capabilities */
13444 struct rte_cryptodev_sym_capability_idx cap_idx;
13445 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13446 cap_idx.algo.aead = tdata->algo;
13447 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13449 return TEST_SKIPPED;
13451 /* OOP not supported with CPU crypto */
13452 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13453 return TEST_SKIPPED;
13455 /* Detailed check for the particular SGL support flag */
13456 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13458 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13459 if (sgl_in && (!(dev_info.feature_flags &
13460 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13461 return TEST_SKIPPED;
13463 uint64_t feat_flags = dev_info.feature_flags;
13465 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13466 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13467 printf("Device doesn't support RAW data-path APIs.\n");
13468 return TEST_SKIPPED;
13471 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13472 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13473 tdata->plaintext.len;
13474 /* Raw data path API does not support OOP */
13475 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13476 return TEST_SKIPPED;
13477 if (sgl_in && !sgl_out) {
13478 if (!(dev_info.feature_flags &
13479 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13480 return TEST_SKIPPED;
13481 } else if (!sgl_in && sgl_out) {
13482 if (!(dev_info.feature_flags &
13483 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13484 return TEST_SKIPPED;
13485 } else if (sgl_in && sgl_out) {
13486 if (!(dev_info.feature_flags &
13487 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13488 return TEST_SKIPPED;
13492 if (fragsz > tdata->plaintext.len)
13493 fragsz = tdata->plaintext.len;
13495 uint16_t plaintext_len = fragsz;
13496 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13498 if (fragsz_oop > tdata->plaintext.len)
13499 frag_size_oop = tdata->plaintext.len;
13502 void *digest_mem = NULL;
13504 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13506 if (tdata->plaintext.len % fragsz != 0) {
13507 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13510 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13515 * For out-op-place we need to alloc another mbuf
13518 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13519 rte_pktmbuf_append(ut_params->obuf,
13520 frag_size_oop + prepend_len);
13521 buf_oop = ut_params->obuf;
13524 /* Create AEAD session */
13525 retval = create_aead_session(ts_params->valid_devs[0],
13527 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13528 tdata->key.data, tdata->key.len,
13529 tdata->aad.len, tdata->auth_tag.len,
13534 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13536 /* clear mbuf payload */
13537 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13538 rte_pktmbuf_tailroom(ut_params->ibuf));
13540 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13543 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13545 trn_data += plaintext_len;
13547 buf = ut_params->ibuf;
13550 * Loop until no more fragments
13553 while (trn_data < tdata->plaintext.len) {
13555 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13556 (tdata->plaintext.len - trn_data) : fragsz;
13558 to_trn_tbl[ecx++] = to_trn;
13560 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13563 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13564 rte_pktmbuf_tailroom(buf));
13567 if (oop && !fragsz_oop) {
13568 buf_last_oop = buf_oop->next =
13569 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13570 buf_oop = buf_oop->next;
13571 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13572 0, rte_pktmbuf_tailroom(buf_oop));
13573 rte_pktmbuf_append(buf_oop, to_trn);
13576 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13579 memcpy(plaintext, tdata->plaintext.data + trn_data,
13581 trn_data += to_trn;
13582 if (trn_data == tdata->plaintext.len) {
13585 digest_mem = rte_pktmbuf_append(buf_oop,
13586 tdata->auth_tag.len);
13588 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13589 tdata->auth_tag.len);
13593 uint64_t digest_phys = 0;
13595 ut_params->ibuf->nb_segs = segs;
13598 if (fragsz_oop && oop) {
13602 if (frag_size_oop == tdata->plaintext.len) {
13603 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13604 tdata->auth_tag.len);
13606 digest_phys = rte_pktmbuf_iova_offset(
13608 tdata->plaintext.len + prepend_len);
13611 trn_data = frag_size_oop;
13612 while (trn_data < tdata->plaintext.len) {
13615 (tdata->plaintext.len - trn_data <
13617 (tdata->plaintext.len - trn_data) :
13620 to_trn_tbl[ecx++] = to_trn;
13622 buf_last_oop = buf_oop->next =
13623 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13624 buf_oop = buf_oop->next;
13625 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13626 0, rte_pktmbuf_tailroom(buf_oop));
13627 rte_pktmbuf_append(buf_oop, to_trn);
13629 trn_data += to_trn;
13631 if (trn_data == tdata->plaintext.len) {
13632 digest_mem = rte_pktmbuf_append(buf_oop,
13633 tdata->auth_tag.len);
13637 ut_params->obuf->nb_segs = segs;
13641 * Place digest at the end of the last buffer
13644 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13645 if (oop && buf_last_oop)
13646 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13648 if (!digest_mem && !oop) {
13649 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13650 + tdata->auth_tag.len);
13651 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13652 tdata->plaintext.len);
13655 /* Create AEAD operation */
13656 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13657 tdata, digest_mem, digest_phys);
13662 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13664 ut_params->op->sym->m_src = ut_params->ibuf;
13666 ut_params->op->sym->m_dst = ut_params->obuf;
13668 /* Process crypto operation */
13669 if (oop == IN_PLACE &&
13670 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13671 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13672 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13673 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13674 ut_params->op, 0, 0, 0, 0);
13676 TEST_ASSERT_NOT_NULL(
13677 process_crypto_request(ts_params->valid_devs[0],
13678 ut_params->op), "failed to process sym crypto op");
13680 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13681 "crypto op processing failed");
13684 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13685 uint8_t *, prepend_len);
13687 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13688 uint8_t *, prepend_len);
13692 fragsz = fragsz_oop;
13694 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13696 tdata->ciphertext.data,
13698 "Ciphertext data not as expected");
13700 buf = ut_params->op->sym->m_src->next;
13702 buf = ut_params->op->sym->m_dst->next;
13704 unsigned int off = fragsz;
13708 ciphertext = rte_pktmbuf_mtod(buf,
13711 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13713 tdata->ciphertext.data + off,
13715 "Ciphertext data not as expected");
13717 off += to_trn_tbl[ecx++];
13721 auth_tag = digest_mem;
13722 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13724 tdata->auth_tag.data,
13725 tdata->auth_tag.len,
13726 "Generated auth tag not as expected");
13732 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13734 return test_authenticated_encryption_SGL(
13735 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13739 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13741 return test_authenticated_encryption_SGL(
13742 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13746 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13748 return test_authenticated_encryption_SGL(
13749 &gcm_test_case_8, OUT_OF_PLACE, 400,
13750 gcm_test_case_8.plaintext.len);
13754 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13756 /* This test is not for OPENSSL PMD */
13757 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13758 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13759 return TEST_SKIPPED;
13761 return test_authenticated_encryption_SGL(
13762 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13766 test_authentication_verify_fail_when_data_corrupted(
13767 struct crypto_testsuite_params *ts_params,
13768 struct crypto_unittest_params *ut_params,
13769 const struct test_crypto_vector *reference)
13771 return test_authentication_verify_fail_when_data_corruption(
13772 ts_params, ut_params, reference, 1);
13776 test_authentication_verify_fail_when_tag_corrupted(
13777 struct crypto_testsuite_params *ts_params,
13778 struct crypto_unittest_params *ut_params,
13779 const struct test_crypto_vector *reference)
13781 return test_authentication_verify_fail_when_data_corruption(
13782 ts_params, ut_params, reference, 0);
13786 test_authentication_verify_GMAC_fail_when_data_corrupted(
13787 struct crypto_testsuite_params *ts_params,
13788 struct crypto_unittest_params *ut_params,
13789 const struct test_crypto_vector *reference)
13791 return test_authentication_verify_GMAC_fail_when_corruption(
13792 ts_params, ut_params, reference, 1);
13796 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13797 struct crypto_testsuite_params *ts_params,
13798 struct crypto_unittest_params *ut_params,
13799 const struct test_crypto_vector *reference)
13801 return test_authentication_verify_GMAC_fail_when_corruption(
13802 ts_params, ut_params, reference, 0);
13806 test_authenticated_decryption_fail_when_data_corrupted(
13807 struct crypto_testsuite_params *ts_params,
13808 struct crypto_unittest_params *ut_params,
13809 const struct test_crypto_vector *reference)
13811 return test_authenticated_decryption_fail_when_corruption(
13812 ts_params, ut_params, reference, 1);
13816 test_authenticated_decryption_fail_when_tag_corrupted(
13817 struct crypto_testsuite_params *ts_params,
13818 struct crypto_unittest_params *ut_params,
13819 const struct test_crypto_vector *reference)
13821 return test_authenticated_decryption_fail_when_corruption(
13822 ts_params, ut_params, reference, 0);
13826 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13828 return test_authentication_verify_fail_when_data_corrupted(
13829 &testsuite_params, &unittest_params,
13830 &hmac_sha1_test_crypto_vector);
13834 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13836 return test_authentication_verify_fail_when_tag_corrupted(
13837 &testsuite_params, &unittest_params,
13838 &hmac_sha1_test_crypto_vector);
13842 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13844 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13845 &testsuite_params, &unittest_params,
13846 &aes128_gmac_test_vector);
13850 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13852 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13853 &testsuite_params, &unittest_params,
13854 &aes128_gmac_test_vector);
13858 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13860 return test_authenticated_decryption_fail_when_data_corrupted(
13863 &aes128cbc_hmac_sha1_test_vector);
13867 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13869 return test_authenticated_decryption_fail_when_tag_corrupted(
13872 &aes128cbc_hmac_sha1_test_vector);
13876 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13878 return test_authenticated_encrypt_with_esn(
13881 &aes128cbc_hmac_sha1_aad_test_vector);
13885 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13887 return test_authenticated_decrypt_with_esn(
13890 &aes128cbc_hmac_sha1_aad_test_vector);
13894 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13896 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13900 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13902 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13905 #ifdef RTE_CRYPTO_SCHEDULER
13907 /* global AESNI worker IDs for the scheduler test */
13908 uint8_t aesni_ids[2];
13911 scheduler_testsuite_setup(void)
13914 int32_t nb_devs, ret;
13915 char vdev_args[VDEV_ARGS_SIZE] = {""};
13916 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
13917 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
13918 uint16_t worker_core_count = 0;
13919 uint16_t socket_id = 0;
13921 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13922 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
13924 /* Identify the Worker Cores
13925 * Use 2 worker cores for the device args
13927 RTE_LCORE_FOREACH_WORKER(i) {
13928 if (worker_core_count > 1)
13930 snprintf(vdev_args, sizeof(vdev_args),
13931 "%s%d", temp_str, i);
13932 strcpy(temp_str, vdev_args);
13933 strlcat(temp_str, ";", sizeof(temp_str));
13934 worker_core_count++;
13935 socket_id = rte_lcore_to_socket_id(i);
13937 if (worker_core_count != 2) {
13938 RTE_LOG(ERR, USER1,
13939 "Cryptodev scheduler test require at least "
13940 "two worker cores to run. "
13941 "Please use the correct coremask.\n");
13942 return TEST_FAILED;
13944 strcpy(temp_str, vdev_args);
13945 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
13946 temp_str, socket_id);
13947 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
13948 nb_devs = rte_cryptodev_device_count_by_driver(
13949 rte_cryptodev_driver_id_get(
13950 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
13952 ret = rte_vdev_init(
13953 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
13955 TEST_ASSERT(ret == 0,
13956 "Failed to create instance %u of pmd : %s",
13957 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13960 return testsuite_setup();
13964 test_scheduler_attach_worker_op(void)
13966 struct crypto_testsuite_params *ts_params = &testsuite_params;
13967 uint8_t sched_id = ts_params->valid_devs[0];
13968 uint32_t i, nb_devs_attached = 0;
13970 char vdev_name[32];
13971 unsigned int count = rte_cryptodev_count();
13973 /* create 2 AESNI_MB vdevs on top of existing devices */
13974 for (i = count; i < count + 2; i++) {
13975 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13976 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13978 ret = rte_vdev_init(vdev_name, NULL);
13980 TEST_ASSERT(ret == 0,
13981 "Failed to create instance %u of"
13983 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13986 RTE_LOG(ERR, USER1,
13987 "Failed to create 2 AESNI MB PMDs.\n");
13988 return TEST_SKIPPED;
13992 /* attach 2 AESNI_MB cdevs */
13993 for (i = count; i < count + 2; i++) {
13994 struct rte_cryptodev_info info;
13995 unsigned int session_size;
13997 rte_cryptodev_info_get(i, &info);
13998 if (info.driver_id != rte_cryptodev_driver_id_get(
13999 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14002 session_size = rte_cryptodev_sym_get_private_session_size(i);
14004 * Create the session mempool again, since now there are new devices
14005 * to use the mempool.
14007 if (ts_params->session_mpool) {
14008 rte_mempool_free(ts_params->session_mpool);
14009 ts_params->session_mpool = NULL;
14011 if (ts_params->session_priv_mpool) {
14012 rte_mempool_free(ts_params->session_priv_mpool);
14013 ts_params->session_priv_mpool = NULL;
14016 if (info.sym.max_nb_sessions != 0 &&
14017 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14018 RTE_LOG(ERR, USER1,
14019 "Device does not support "
14020 "at least %u sessions\n",
14022 return TEST_FAILED;
14025 * Create mempool with maximum number of sessions,
14026 * to include the session headers
14028 if (ts_params->session_mpool == NULL) {
14029 ts_params->session_mpool =
14030 rte_cryptodev_sym_session_pool_create(
14032 MAX_NB_SESSIONS, 0, 0, 0,
14034 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14035 "session mempool allocation failed");
14039 * Create mempool with maximum number of sessions,
14040 * to include device specific session private data
14042 if (ts_params->session_priv_mpool == NULL) {
14043 ts_params->session_priv_mpool = rte_mempool_create(
14044 "test_sess_mp_priv",
14047 0, 0, NULL, NULL, NULL,
14048 NULL, SOCKET_ID_ANY,
14051 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14052 "session mempool allocation failed");
14055 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14056 ts_params->qp_conf.mp_session_private =
14057 ts_params->session_priv_mpool;
14059 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14062 TEST_ASSERT(ret == 0,
14063 "Failed to attach device %u of pmd : %s", i,
14064 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14066 aesni_ids[nb_devs_attached] = (uint8_t)i;
14068 nb_devs_attached++;
14075 test_scheduler_detach_worker_op(void)
14077 struct crypto_testsuite_params *ts_params = &testsuite_params;
14078 uint8_t sched_id = ts_params->valid_devs[0];
14082 for (i = 0; i < 2; i++) {
14083 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14085 TEST_ASSERT(ret == 0,
14086 "Failed to detach device %u", aesni_ids[i]);
14093 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14095 struct crypto_testsuite_params *ts_params = &testsuite_params;
14096 uint8_t sched_id = ts_params->valid_devs[0];
14098 return rte_cryptodev_scheduler_mode_set(sched_id,
14103 test_scheduler_mode_roundrobin_op(void)
14105 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14106 0, "Failed to set roundrobin mode");
14112 test_scheduler_mode_multicore_op(void)
14114 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14115 0, "Failed to set multicore mode");
14121 test_scheduler_mode_failover_op(void)
14123 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
14124 0, "Failed to set failover mode");
14130 test_scheduler_mode_pkt_size_distr_op(void)
14132 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
14133 0, "Failed to set pktsize mode");
14139 scheduler_multicore_testsuite_setup(void)
14141 if (test_scheduler_attach_worker_op() < 0)
14142 return TEST_SKIPPED;
14143 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
14144 return TEST_SKIPPED;
14149 scheduler_roundrobin_testsuite_setup(void)
14151 if (test_scheduler_attach_worker_op() < 0)
14152 return TEST_SKIPPED;
14153 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
14154 return TEST_SKIPPED;
14159 scheduler_failover_testsuite_setup(void)
14161 if (test_scheduler_attach_worker_op() < 0)
14162 return TEST_SKIPPED;
14163 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
14164 return TEST_SKIPPED;
14169 scheduler_pkt_size_distr_testsuite_setup(void)
14171 if (test_scheduler_attach_worker_op() < 0)
14172 return TEST_SKIPPED;
14173 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14174 return TEST_SKIPPED;
14179 scheduler_mode_testsuite_teardown(void)
14181 test_scheduler_detach_worker_op();
14184 #endif /* RTE_CRYPTO_SCHEDULER */
14186 static struct unit_test_suite end_testsuite = {
14187 .suite_name = NULL,
14190 .unit_test_suites = NULL
14193 #ifdef RTE_LIB_SECURITY
14194 static struct unit_test_suite ipsec_proto_testsuite = {
14195 .suite_name = "IPsec Proto Unit Test Suite",
14196 .setup = ipsec_proto_testsuite_setup,
14197 .unit_test_cases = {
14198 TEST_CASE_NAMED_WITH_DATA(
14199 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14200 ut_setup_security, ut_teardown,
14201 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
14202 TEST_CASE_NAMED_WITH_DATA(
14203 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14204 ut_setup_security, ut_teardown,
14205 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
14206 TEST_CASE_NAMED_WITH_DATA(
14207 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14208 ut_setup_security, ut_teardown,
14209 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
14210 TEST_CASE_NAMED_WITH_DATA(
14211 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14212 ut_setup_security, ut_teardown,
14213 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14214 TEST_CASE_NAMED_WITH_DATA(
14215 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14216 ut_setup_security, ut_teardown,
14217 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14218 TEST_CASE_NAMED_WITH_DATA(
14219 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14220 ut_setup_security, ut_teardown,
14221 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14222 TEST_CASE_NAMED_ST(
14223 "Combined test alg list",
14224 ut_setup_security, ut_teardown,
14225 test_ipsec_proto_display_list),
14226 TEST_CASE_NAMED_ST(
14228 ut_setup_security, ut_teardown,
14229 test_ipsec_proto_iv_gen),
14230 TEST_CASE_NAMED_ST(
14231 "UDP encapsulation",
14232 ut_setup_security, ut_teardown,
14233 test_ipsec_proto_udp_encap),
14234 TEST_CASE_NAMED_ST(
14235 "UDP encapsulation ports verification test",
14236 ut_setup_security, ut_teardown,
14237 test_ipsec_proto_udp_ports_verify),
14238 TEST_CASE_NAMED_ST(
14239 "SA expiry packets soft",
14240 ut_setup_security, ut_teardown,
14241 test_ipsec_proto_sa_exp_pkts_soft),
14242 TEST_CASE_NAMED_ST(
14243 "SA expiry packets hard",
14244 ut_setup_security, ut_teardown,
14245 test_ipsec_proto_sa_exp_pkts_hard),
14246 TEST_CASE_NAMED_ST(
14247 "Negative test: ICV corruption",
14248 ut_setup_security, ut_teardown,
14249 test_ipsec_proto_err_icv_corrupt),
14250 TEST_CASE_NAMED_ST(
14251 "Tunnel dst addr verification",
14252 ut_setup_security, ut_teardown,
14253 test_ipsec_proto_tunnel_dst_addr_verify),
14254 TEST_CASE_NAMED_ST(
14255 "Tunnel src and dst addr verification",
14256 ut_setup_security, ut_teardown,
14257 test_ipsec_proto_tunnel_src_dst_addr_verify),
14258 TEST_CASES_END() /**< NULL terminate unit test array */
14262 static struct unit_test_suite pdcp_proto_testsuite = {
14263 .suite_name = "PDCP Proto Unit Test Suite",
14264 .setup = pdcp_proto_testsuite_setup,
14265 .unit_test_cases = {
14266 TEST_CASE_ST(ut_setup_security, ut_teardown,
14267 test_PDCP_PROTO_all),
14268 TEST_CASES_END() /**< NULL terminate unit test array */
14272 static struct unit_test_suite docsis_proto_testsuite = {
14273 .suite_name = "Docsis Proto Unit Test Suite",
14274 .setup = docsis_proto_testsuite_setup,
14275 .unit_test_cases = {
14276 TEST_CASE_ST(ut_setup_security, ut_teardown,
14277 test_DOCSIS_PROTO_all),
14278 TEST_CASES_END() /**< NULL terminate unit test array */
14283 static struct unit_test_suite cryptodev_gen_testsuite = {
14284 .suite_name = "Crypto General Unit Test Suite",
14285 .setup = crypto_gen_testsuite_setup,
14286 .unit_test_cases = {
14287 TEST_CASE_ST(ut_setup, ut_teardown,
14288 test_device_configure_invalid_dev_id),
14289 TEST_CASE_ST(ut_setup, ut_teardown,
14290 test_queue_pair_descriptor_setup),
14291 TEST_CASE_ST(ut_setup, ut_teardown,
14292 test_device_configure_invalid_queue_pair_ids),
14293 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
14294 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
14295 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
14296 TEST_CASES_END() /**< NULL terminate unit test array */
14300 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
14301 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
14302 .setup = negative_hmac_sha1_testsuite_setup,
14303 .unit_test_cases = {
14304 /** Negative tests */
14305 TEST_CASE_ST(ut_setup, ut_teardown,
14306 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14307 TEST_CASE_ST(ut_setup, ut_teardown,
14308 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14309 TEST_CASE_ST(ut_setup, ut_teardown,
14310 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14311 TEST_CASE_ST(ut_setup, ut_teardown,
14312 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14314 TEST_CASES_END() /**< NULL terminate unit test array */
14318 static struct unit_test_suite cryptodev_multi_session_testsuite = {
14319 .suite_name = "Multi Session Unit Test Suite",
14320 .setup = multi_session_testsuite_setup,
14321 .unit_test_cases = {
14322 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14323 TEST_CASE_ST(ut_setup, ut_teardown,
14324 test_multi_session_random_usage),
14326 TEST_CASES_END() /**< NULL terminate unit test array */
14330 static struct unit_test_suite cryptodev_null_testsuite = {
14331 .suite_name = "NULL Test Suite",
14332 .setup = null_testsuite_setup,
14333 .unit_test_cases = {
14334 TEST_CASE_ST(ut_setup, ut_teardown,
14335 test_null_invalid_operation),
14336 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
14341 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
14342 .suite_name = "AES CCM Authenticated Test Suite",
14343 .setup = aes_ccm_auth_testsuite_setup,
14344 .unit_test_cases = {
14345 /** AES CCM Authenticated Encryption 128 bits key*/
14346 TEST_CASE_ST(ut_setup, ut_teardown,
14347 test_AES_CCM_authenticated_encryption_test_case_128_1),
14348 TEST_CASE_ST(ut_setup, ut_teardown,
14349 test_AES_CCM_authenticated_encryption_test_case_128_2),
14350 TEST_CASE_ST(ut_setup, ut_teardown,
14351 test_AES_CCM_authenticated_encryption_test_case_128_3),
14353 /** AES CCM Authenticated Decryption 128 bits key*/
14354 TEST_CASE_ST(ut_setup, ut_teardown,
14355 test_AES_CCM_authenticated_decryption_test_case_128_1),
14356 TEST_CASE_ST(ut_setup, ut_teardown,
14357 test_AES_CCM_authenticated_decryption_test_case_128_2),
14358 TEST_CASE_ST(ut_setup, ut_teardown,
14359 test_AES_CCM_authenticated_decryption_test_case_128_3),
14361 /** AES CCM Authenticated Encryption 192 bits key */
14362 TEST_CASE_ST(ut_setup, ut_teardown,
14363 test_AES_CCM_authenticated_encryption_test_case_192_1),
14364 TEST_CASE_ST(ut_setup, ut_teardown,
14365 test_AES_CCM_authenticated_encryption_test_case_192_2),
14366 TEST_CASE_ST(ut_setup, ut_teardown,
14367 test_AES_CCM_authenticated_encryption_test_case_192_3),
14369 /** AES CCM Authenticated Decryption 192 bits key*/
14370 TEST_CASE_ST(ut_setup, ut_teardown,
14371 test_AES_CCM_authenticated_decryption_test_case_192_1),
14372 TEST_CASE_ST(ut_setup, ut_teardown,
14373 test_AES_CCM_authenticated_decryption_test_case_192_2),
14374 TEST_CASE_ST(ut_setup, ut_teardown,
14375 test_AES_CCM_authenticated_decryption_test_case_192_3),
14377 /** AES CCM Authenticated Encryption 256 bits key */
14378 TEST_CASE_ST(ut_setup, ut_teardown,
14379 test_AES_CCM_authenticated_encryption_test_case_256_1),
14380 TEST_CASE_ST(ut_setup, ut_teardown,
14381 test_AES_CCM_authenticated_encryption_test_case_256_2),
14382 TEST_CASE_ST(ut_setup, ut_teardown,
14383 test_AES_CCM_authenticated_encryption_test_case_256_3),
14385 /** AES CCM Authenticated Decryption 256 bits key*/
14386 TEST_CASE_ST(ut_setup, ut_teardown,
14387 test_AES_CCM_authenticated_decryption_test_case_256_1),
14388 TEST_CASE_ST(ut_setup, ut_teardown,
14389 test_AES_CCM_authenticated_decryption_test_case_256_2),
14390 TEST_CASE_ST(ut_setup, ut_teardown,
14391 test_AES_CCM_authenticated_decryption_test_case_256_3),
14396 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
14397 .suite_name = "AES GCM Authenticated Test Suite",
14398 .setup = aes_gcm_auth_testsuite_setup,
14399 .unit_test_cases = {
14400 /** AES GCM Authenticated Encryption */
14401 TEST_CASE_ST(ut_setup, ut_teardown,
14402 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
14403 TEST_CASE_ST(ut_setup, ut_teardown,
14404 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
14405 TEST_CASE_ST(ut_setup, ut_teardown,
14406 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
14407 TEST_CASE_ST(ut_setup, ut_teardown,
14408 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
14409 TEST_CASE_ST(ut_setup, ut_teardown,
14410 test_AES_GCM_authenticated_encryption_test_case_1),
14411 TEST_CASE_ST(ut_setup, ut_teardown,
14412 test_AES_GCM_authenticated_encryption_test_case_2),
14413 TEST_CASE_ST(ut_setup, ut_teardown,
14414 test_AES_GCM_authenticated_encryption_test_case_3),
14415 TEST_CASE_ST(ut_setup, ut_teardown,
14416 test_AES_GCM_authenticated_encryption_test_case_4),
14417 TEST_CASE_ST(ut_setup, ut_teardown,
14418 test_AES_GCM_authenticated_encryption_test_case_5),
14419 TEST_CASE_ST(ut_setup, ut_teardown,
14420 test_AES_GCM_authenticated_encryption_test_case_6),
14421 TEST_CASE_ST(ut_setup, ut_teardown,
14422 test_AES_GCM_authenticated_encryption_test_case_7),
14423 TEST_CASE_ST(ut_setup, ut_teardown,
14424 test_AES_GCM_authenticated_encryption_test_case_8),
14425 TEST_CASE_ST(ut_setup, ut_teardown,
14426 test_AES_GCM_J0_authenticated_encryption_test_case_1),
14428 /** AES GCM Authenticated Decryption */
14429 TEST_CASE_ST(ut_setup, ut_teardown,
14430 test_AES_GCM_authenticated_decryption_test_case_1),
14431 TEST_CASE_ST(ut_setup, ut_teardown,
14432 test_AES_GCM_authenticated_decryption_test_case_2),
14433 TEST_CASE_ST(ut_setup, ut_teardown,
14434 test_AES_GCM_authenticated_decryption_test_case_3),
14435 TEST_CASE_ST(ut_setup, ut_teardown,
14436 test_AES_GCM_authenticated_decryption_test_case_4),
14437 TEST_CASE_ST(ut_setup, ut_teardown,
14438 test_AES_GCM_authenticated_decryption_test_case_5),
14439 TEST_CASE_ST(ut_setup, ut_teardown,
14440 test_AES_GCM_authenticated_decryption_test_case_6),
14441 TEST_CASE_ST(ut_setup, ut_teardown,
14442 test_AES_GCM_authenticated_decryption_test_case_7),
14443 TEST_CASE_ST(ut_setup, ut_teardown,
14444 test_AES_GCM_authenticated_decryption_test_case_8),
14445 TEST_CASE_ST(ut_setup, ut_teardown,
14446 test_AES_GCM_J0_authenticated_decryption_test_case_1),
14448 /** AES GCM Authenticated Encryption 192 bits key */
14449 TEST_CASE_ST(ut_setup, ut_teardown,
14450 test_AES_GCM_auth_encryption_test_case_192_1),
14451 TEST_CASE_ST(ut_setup, ut_teardown,
14452 test_AES_GCM_auth_encryption_test_case_192_2),
14453 TEST_CASE_ST(ut_setup, ut_teardown,
14454 test_AES_GCM_auth_encryption_test_case_192_3),
14455 TEST_CASE_ST(ut_setup, ut_teardown,
14456 test_AES_GCM_auth_encryption_test_case_192_4),
14457 TEST_CASE_ST(ut_setup, ut_teardown,
14458 test_AES_GCM_auth_encryption_test_case_192_5),
14459 TEST_CASE_ST(ut_setup, ut_teardown,
14460 test_AES_GCM_auth_encryption_test_case_192_6),
14461 TEST_CASE_ST(ut_setup, ut_teardown,
14462 test_AES_GCM_auth_encryption_test_case_192_7),
14464 /** AES GCM Authenticated Decryption 192 bits key */
14465 TEST_CASE_ST(ut_setup, ut_teardown,
14466 test_AES_GCM_auth_decryption_test_case_192_1),
14467 TEST_CASE_ST(ut_setup, ut_teardown,
14468 test_AES_GCM_auth_decryption_test_case_192_2),
14469 TEST_CASE_ST(ut_setup, ut_teardown,
14470 test_AES_GCM_auth_decryption_test_case_192_3),
14471 TEST_CASE_ST(ut_setup, ut_teardown,
14472 test_AES_GCM_auth_decryption_test_case_192_4),
14473 TEST_CASE_ST(ut_setup, ut_teardown,
14474 test_AES_GCM_auth_decryption_test_case_192_5),
14475 TEST_CASE_ST(ut_setup, ut_teardown,
14476 test_AES_GCM_auth_decryption_test_case_192_6),
14477 TEST_CASE_ST(ut_setup, ut_teardown,
14478 test_AES_GCM_auth_decryption_test_case_192_7),
14480 /** AES GCM Authenticated Encryption 256 bits key */
14481 TEST_CASE_ST(ut_setup, ut_teardown,
14482 test_AES_GCM_auth_encryption_test_case_256_1),
14483 TEST_CASE_ST(ut_setup, ut_teardown,
14484 test_AES_GCM_auth_encryption_test_case_256_2),
14485 TEST_CASE_ST(ut_setup, ut_teardown,
14486 test_AES_GCM_auth_encryption_test_case_256_3),
14487 TEST_CASE_ST(ut_setup, ut_teardown,
14488 test_AES_GCM_auth_encryption_test_case_256_4),
14489 TEST_CASE_ST(ut_setup, ut_teardown,
14490 test_AES_GCM_auth_encryption_test_case_256_5),
14491 TEST_CASE_ST(ut_setup, ut_teardown,
14492 test_AES_GCM_auth_encryption_test_case_256_6),
14493 TEST_CASE_ST(ut_setup, ut_teardown,
14494 test_AES_GCM_auth_encryption_test_case_256_7),
14496 /** AES GCM Authenticated Decryption 256 bits key */
14497 TEST_CASE_ST(ut_setup, ut_teardown,
14498 test_AES_GCM_auth_decryption_test_case_256_1),
14499 TEST_CASE_ST(ut_setup, ut_teardown,
14500 test_AES_GCM_auth_decryption_test_case_256_2),
14501 TEST_CASE_ST(ut_setup, ut_teardown,
14502 test_AES_GCM_auth_decryption_test_case_256_3),
14503 TEST_CASE_ST(ut_setup, ut_teardown,
14504 test_AES_GCM_auth_decryption_test_case_256_4),
14505 TEST_CASE_ST(ut_setup, ut_teardown,
14506 test_AES_GCM_auth_decryption_test_case_256_5),
14507 TEST_CASE_ST(ut_setup, ut_teardown,
14508 test_AES_GCM_auth_decryption_test_case_256_6),
14509 TEST_CASE_ST(ut_setup, ut_teardown,
14510 test_AES_GCM_auth_decryption_test_case_256_7),
14512 /** AES GCM Authenticated Encryption big aad size */
14513 TEST_CASE_ST(ut_setup, ut_teardown,
14514 test_AES_GCM_auth_encryption_test_case_aad_1),
14515 TEST_CASE_ST(ut_setup, ut_teardown,
14516 test_AES_GCM_auth_encryption_test_case_aad_2),
14518 /** AES GCM Authenticated Decryption big aad size */
14519 TEST_CASE_ST(ut_setup, ut_teardown,
14520 test_AES_GCM_auth_decryption_test_case_aad_1),
14521 TEST_CASE_ST(ut_setup, ut_teardown,
14522 test_AES_GCM_auth_decryption_test_case_aad_2),
14524 /** Out of place tests */
14525 TEST_CASE_ST(ut_setup, ut_teardown,
14526 test_AES_GCM_authenticated_encryption_oop_test_case_1),
14527 TEST_CASE_ST(ut_setup, ut_teardown,
14528 test_AES_GCM_authenticated_decryption_oop_test_case_1),
14530 /** Session-less tests */
14531 TEST_CASE_ST(ut_setup, ut_teardown,
14532 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
14533 TEST_CASE_ST(ut_setup, ut_teardown,
14534 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
14540 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
14541 .suite_name = "AES GMAC Authentication Test Suite",
14542 .setup = aes_gmac_auth_testsuite_setup,
14543 .unit_test_cases = {
14544 TEST_CASE_ST(ut_setup, ut_teardown,
14545 test_AES_GMAC_authentication_test_case_1),
14546 TEST_CASE_ST(ut_setup, ut_teardown,
14547 test_AES_GMAC_authentication_verify_test_case_1),
14548 TEST_CASE_ST(ut_setup, ut_teardown,
14549 test_AES_GMAC_authentication_test_case_2),
14550 TEST_CASE_ST(ut_setup, ut_teardown,
14551 test_AES_GMAC_authentication_verify_test_case_2),
14552 TEST_CASE_ST(ut_setup, ut_teardown,
14553 test_AES_GMAC_authentication_test_case_3),
14554 TEST_CASE_ST(ut_setup, ut_teardown,
14555 test_AES_GMAC_authentication_verify_test_case_3),
14556 TEST_CASE_ST(ut_setup, ut_teardown,
14557 test_AES_GMAC_authentication_test_case_4),
14558 TEST_CASE_ST(ut_setup, ut_teardown,
14559 test_AES_GMAC_authentication_verify_test_case_4),
14560 TEST_CASE_ST(ut_setup, ut_teardown,
14561 test_AES_GMAC_authentication_SGL_40B),
14562 TEST_CASE_ST(ut_setup, ut_teardown,
14563 test_AES_GMAC_authentication_SGL_80B),
14564 TEST_CASE_ST(ut_setup, ut_teardown,
14565 test_AES_GMAC_authentication_SGL_2048B),
14566 TEST_CASE_ST(ut_setup, ut_teardown,
14567 test_AES_GMAC_authentication_SGL_2047B),
14573 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14574 .suite_name = "Chacha20-Poly1305 Test Suite",
14575 .setup = chacha20_poly1305_testsuite_setup,
14576 .unit_test_cases = {
14577 TEST_CASE_ST(ut_setup, ut_teardown,
14578 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14579 TEST_CASE_ST(ut_setup, ut_teardown,
14580 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14585 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14586 .suite_name = "SNOW 3G Test Suite",
14587 .setup = snow3g_testsuite_setup,
14588 .unit_test_cases = {
14589 /** SNOW 3G encrypt only (UEA2) */
14590 TEST_CASE_ST(ut_setup, ut_teardown,
14591 test_snow3g_encryption_test_case_1),
14592 TEST_CASE_ST(ut_setup, ut_teardown,
14593 test_snow3g_encryption_test_case_2),
14594 TEST_CASE_ST(ut_setup, ut_teardown,
14595 test_snow3g_encryption_test_case_3),
14596 TEST_CASE_ST(ut_setup, ut_teardown,
14597 test_snow3g_encryption_test_case_4),
14598 TEST_CASE_ST(ut_setup, ut_teardown,
14599 test_snow3g_encryption_test_case_5),
14601 TEST_CASE_ST(ut_setup, ut_teardown,
14602 test_snow3g_encryption_test_case_1_oop),
14603 TEST_CASE_ST(ut_setup, ut_teardown,
14604 test_snow3g_encryption_test_case_1_oop_sgl),
14605 TEST_CASE_ST(ut_setup, ut_teardown,
14606 test_snow3g_encryption_test_case_1_offset_oop),
14607 TEST_CASE_ST(ut_setup, ut_teardown,
14608 test_snow3g_decryption_test_case_1_oop),
14610 /** SNOW 3G generate auth, then encrypt (UEA2) */
14611 TEST_CASE_ST(ut_setup, ut_teardown,
14612 test_snow3g_auth_cipher_test_case_1),
14613 TEST_CASE_ST(ut_setup, ut_teardown,
14614 test_snow3g_auth_cipher_test_case_2),
14615 TEST_CASE_ST(ut_setup, ut_teardown,
14616 test_snow3g_auth_cipher_test_case_2_oop),
14617 TEST_CASE_ST(ut_setup, ut_teardown,
14618 test_snow3g_auth_cipher_part_digest_enc),
14619 TEST_CASE_ST(ut_setup, ut_teardown,
14620 test_snow3g_auth_cipher_part_digest_enc_oop),
14621 TEST_CASE_ST(ut_setup, ut_teardown,
14622 test_snow3g_auth_cipher_test_case_3_sgl),
14623 TEST_CASE_ST(ut_setup, ut_teardown,
14624 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14625 TEST_CASE_ST(ut_setup, ut_teardown,
14626 test_snow3g_auth_cipher_part_digest_enc_sgl),
14627 TEST_CASE_ST(ut_setup, ut_teardown,
14628 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14630 /** SNOW 3G decrypt (UEA2), then verify auth */
14631 TEST_CASE_ST(ut_setup, ut_teardown,
14632 test_snow3g_auth_cipher_verify_test_case_1),
14633 TEST_CASE_ST(ut_setup, ut_teardown,
14634 test_snow3g_auth_cipher_verify_test_case_2),
14635 TEST_CASE_ST(ut_setup, ut_teardown,
14636 test_snow3g_auth_cipher_verify_test_case_2_oop),
14637 TEST_CASE_ST(ut_setup, ut_teardown,
14638 test_snow3g_auth_cipher_verify_part_digest_enc),
14639 TEST_CASE_ST(ut_setup, ut_teardown,
14640 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14641 TEST_CASE_ST(ut_setup, ut_teardown,
14642 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14643 TEST_CASE_ST(ut_setup, ut_teardown,
14644 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14645 TEST_CASE_ST(ut_setup, ut_teardown,
14646 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14647 TEST_CASE_ST(ut_setup, ut_teardown,
14648 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14650 /** SNOW 3G decrypt only (UEA2) */
14651 TEST_CASE_ST(ut_setup, ut_teardown,
14652 test_snow3g_decryption_test_case_1),
14653 TEST_CASE_ST(ut_setup, ut_teardown,
14654 test_snow3g_decryption_test_case_2),
14655 TEST_CASE_ST(ut_setup, ut_teardown,
14656 test_snow3g_decryption_test_case_3),
14657 TEST_CASE_ST(ut_setup, ut_teardown,
14658 test_snow3g_decryption_test_case_4),
14659 TEST_CASE_ST(ut_setup, ut_teardown,
14660 test_snow3g_decryption_test_case_5),
14661 TEST_CASE_ST(ut_setup, ut_teardown,
14662 test_snow3g_decryption_with_digest_test_case_1),
14663 TEST_CASE_ST(ut_setup, ut_teardown,
14664 test_snow3g_hash_generate_test_case_1),
14665 TEST_CASE_ST(ut_setup, ut_teardown,
14666 test_snow3g_hash_generate_test_case_2),
14667 TEST_CASE_ST(ut_setup, ut_teardown,
14668 test_snow3g_hash_generate_test_case_3),
14670 /* Tests with buffers which length is not byte-aligned */
14671 TEST_CASE_ST(ut_setup, ut_teardown,
14672 test_snow3g_hash_generate_test_case_4),
14673 TEST_CASE_ST(ut_setup, ut_teardown,
14674 test_snow3g_hash_generate_test_case_5),
14675 TEST_CASE_ST(ut_setup, ut_teardown,
14676 test_snow3g_hash_generate_test_case_6),
14677 TEST_CASE_ST(ut_setup, ut_teardown,
14678 test_snow3g_hash_verify_test_case_1),
14679 TEST_CASE_ST(ut_setup, ut_teardown,
14680 test_snow3g_hash_verify_test_case_2),
14681 TEST_CASE_ST(ut_setup, ut_teardown,
14682 test_snow3g_hash_verify_test_case_3),
14684 /* Tests with buffers which length is not byte-aligned */
14685 TEST_CASE_ST(ut_setup, ut_teardown,
14686 test_snow3g_hash_verify_test_case_4),
14687 TEST_CASE_ST(ut_setup, ut_teardown,
14688 test_snow3g_hash_verify_test_case_5),
14689 TEST_CASE_ST(ut_setup, ut_teardown,
14690 test_snow3g_hash_verify_test_case_6),
14691 TEST_CASE_ST(ut_setup, ut_teardown,
14692 test_snow3g_cipher_auth_test_case_1),
14693 TEST_CASE_ST(ut_setup, ut_teardown,
14694 test_snow3g_auth_cipher_with_digest_test_case_1),
14699 static struct unit_test_suite cryptodev_zuc_testsuite = {
14700 .suite_name = "ZUC Test Suite",
14701 .setup = zuc_testsuite_setup,
14702 .unit_test_cases = {
14703 /** ZUC encrypt only (EEA3) */
14704 TEST_CASE_ST(ut_setup, ut_teardown,
14705 test_zuc_encryption_test_case_1),
14706 TEST_CASE_ST(ut_setup, ut_teardown,
14707 test_zuc_encryption_test_case_2),
14708 TEST_CASE_ST(ut_setup, ut_teardown,
14709 test_zuc_encryption_test_case_3),
14710 TEST_CASE_ST(ut_setup, ut_teardown,
14711 test_zuc_encryption_test_case_4),
14712 TEST_CASE_ST(ut_setup, ut_teardown,
14713 test_zuc_encryption_test_case_5),
14714 TEST_CASE_ST(ut_setup, ut_teardown,
14715 test_zuc_encryption_test_case_6_sgl),
14716 TEST_CASE_ST(ut_setup, ut_teardown,
14717 test_zuc_encryption_test_case_7),
14719 /** ZUC authenticate (EIA3) */
14720 TEST_CASE_ST(ut_setup, ut_teardown,
14721 test_zuc_hash_generate_test_case_1),
14722 TEST_CASE_ST(ut_setup, ut_teardown,
14723 test_zuc_hash_generate_test_case_2),
14724 TEST_CASE_ST(ut_setup, ut_teardown,
14725 test_zuc_hash_generate_test_case_3),
14726 TEST_CASE_ST(ut_setup, ut_teardown,
14727 test_zuc_hash_generate_test_case_4),
14728 TEST_CASE_ST(ut_setup, ut_teardown,
14729 test_zuc_hash_generate_test_case_5),
14730 TEST_CASE_ST(ut_setup, ut_teardown,
14731 test_zuc_hash_generate_test_case_6),
14732 TEST_CASE_ST(ut_setup, ut_teardown,
14733 test_zuc_hash_generate_test_case_7),
14734 TEST_CASE_ST(ut_setup, ut_teardown,
14735 test_zuc_hash_generate_test_case_8),
14736 TEST_CASE_ST(ut_setup, ut_teardown,
14737 test_zuc_hash_generate_test_case_9),
14738 TEST_CASE_ST(ut_setup, ut_teardown,
14739 test_zuc_hash_generate_test_case_10),
14742 /** ZUC alg-chain (EEA3/EIA3) */
14743 TEST_CASE_ST(ut_setup, ut_teardown,
14744 test_zuc_cipher_auth_test_case_1),
14745 TEST_CASE_ST(ut_setup, ut_teardown,
14746 test_zuc_cipher_auth_test_case_2),
14748 /** ZUC generate auth, then encrypt (EEA3) */
14749 TEST_CASE_ST(ut_setup, ut_teardown,
14750 test_zuc_auth_cipher_test_case_1),
14751 TEST_CASE_ST(ut_setup, ut_teardown,
14752 test_zuc_auth_cipher_test_case_1_oop),
14753 TEST_CASE_ST(ut_setup, ut_teardown,
14754 test_zuc_auth_cipher_test_case_1_sgl),
14755 TEST_CASE_ST(ut_setup, ut_teardown,
14756 test_zuc_auth_cipher_test_case_1_oop_sgl),
14758 /** ZUC decrypt (EEA3), then verify auth */
14759 TEST_CASE_ST(ut_setup, ut_teardown,
14760 test_zuc_auth_cipher_verify_test_case_1),
14761 TEST_CASE_ST(ut_setup, ut_teardown,
14762 test_zuc_auth_cipher_verify_test_case_1_oop),
14763 TEST_CASE_ST(ut_setup, ut_teardown,
14764 test_zuc_auth_cipher_verify_test_case_1_sgl),
14765 TEST_CASE_ST(ut_setup, ut_teardown,
14766 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14771 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14772 .suite_name = "HMAC_MD5 Authentication Test Suite",
14773 .setup = hmac_md5_auth_testsuite_setup,
14774 .unit_test_cases = {
14775 TEST_CASE_ST(ut_setup, ut_teardown,
14776 test_MD5_HMAC_generate_case_1),
14777 TEST_CASE_ST(ut_setup, ut_teardown,
14778 test_MD5_HMAC_verify_case_1),
14779 TEST_CASE_ST(ut_setup, ut_teardown,
14780 test_MD5_HMAC_generate_case_2),
14781 TEST_CASE_ST(ut_setup, ut_teardown,
14782 test_MD5_HMAC_verify_case_2),
14787 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14788 .suite_name = "Kasumi Test Suite",
14789 .setup = kasumi_testsuite_setup,
14790 .unit_test_cases = {
14791 /** KASUMI hash only (UIA1) */
14792 TEST_CASE_ST(ut_setup, ut_teardown,
14793 test_kasumi_hash_generate_test_case_1),
14794 TEST_CASE_ST(ut_setup, ut_teardown,
14795 test_kasumi_hash_generate_test_case_2),
14796 TEST_CASE_ST(ut_setup, ut_teardown,
14797 test_kasumi_hash_generate_test_case_3),
14798 TEST_CASE_ST(ut_setup, ut_teardown,
14799 test_kasumi_hash_generate_test_case_4),
14800 TEST_CASE_ST(ut_setup, ut_teardown,
14801 test_kasumi_hash_generate_test_case_5),
14802 TEST_CASE_ST(ut_setup, ut_teardown,
14803 test_kasumi_hash_generate_test_case_6),
14805 TEST_CASE_ST(ut_setup, ut_teardown,
14806 test_kasumi_hash_verify_test_case_1),
14807 TEST_CASE_ST(ut_setup, ut_teardown,
14808 test_kasumi_hash_verify_test_case_2),
14809 TEST_CASE_ST(ut_setup, ut_teardown,
14810 test_kasumi_hash_verify_test_case_3),
14811 TEST_CASE_ST(ut_setup, ut_teardown,
14812 test_kasumi_hash_verify_test_case_4),
14813 TEST_CASE_ST(ut_setup, ut_teardown,
14814 test_kasumi_hash_verify_test_case_5),
14816 /** KASUMI encrypt only (UEA1) */
14817 TEST_CASE_ST(ut_setup, ut_teardown,
14818 test_kasumi_encryption_test_case_1),
14819 TEST_CASE_ST(ut_setup, ut_teardown,
14820 test_kasumi_encryption_test_case_1_sgl),
14821 TEST_CASE_ST(ut_setup, ut_teardown,
14822 test_kasumi_encryption_test_case_1_oop),
14823 TEST_CASE_ST(ut_setup, ut_teardown,
14824 test_kasumi_encryption_test_case_1_oop_sgl),
14825 TEST_CASE_ST(ut_setup, ut_teardown,
14826 test_kasumi_encryption_test_case_2),
14827 TEST_CASE_ST(ut_setup, ut_teardown,
14828 test_kasumi_encryption_test_case_3),
14829 TEST_CASE_ST(ut_setup, ut_teardown,
14830 test_kasumi_encryption_test_case_4),
14831 TEST_CASE_ST(ut_setup, ut_teardown,
14832 test_kasumi_encryption_test_case_5),
14834 /** KASUMI decrypt only (UEA1) */
14835 TEST_CASE_ST(ut_setup, ut_teardown,
14836 test_kasumi_decryption_test_case_1),
14837 TEST_CASE_ST(ut_setup, ut_teardown,
14838 test_kasumi_decryption_test_case_2),
14839 TEST_CASE_ST(ut_setup, ut_teardown,
14840 test_kasumi_decryption_test_case_3),
14841 TEST_CASE_ST(ut_setup, ut_teardown,
14842 test_kasumi_decryption_test_case_4),
14843 TEST_CASE_ST(ut_setup, ut_teardown,
14844 test_kasumi_decryption_test_case_5),
14845 TEST_CASE_ST(ut_setup, ut_teardown,
14846 test_kasumi_decryption_test_case_1_oop),
14847 TEST_CASE_ST(ut_setup, ut_teardown,
14848 test_kasumi_cipher_auth_test_case_1),
14850 /** KASUMI generate auth, then encrypt (F8) */
14851 TEST_CASE_ST(ut_setup, ut_teardown,
14852 test_kasumi_auth_cipher_test_case_1),
14853 TEST_CASE_ST(ut_setup, ut_teardown,
14854 test_kasumi_auth_cipher_test_case_2),
14855 TEST_CASE_ST(ut_setup, ut_teardown,
14856 test_kasumi_auth_cipher_test_case_2_oop),
14857 TEST_CASE_ST(ut_setup, ut_teardown,
14858 test_kasumi_auth_cipher_test_case_2_sgl),
14859 TEST_CASE_ST(ut_setup, ut_teardown,
14860 test_kasumi_auth_cipher_test_case_2_oop_sgl),
14862 /** KASUMI decrypt (F8), then verify auth */
14863 TEST_CASE_ST(ut_setup, ut_teardown,
14864 test_kasumi_auth_cipher_verify_test_case_1),
14865 TEST_CASE_ST(ut_setup, ut_teardown,
14866 test_kasumi_auth_cipher_verify_test_case_2),
14867 TEST_CASE_ST(ut_setup, ut_teardown,
14868 test_kasumi_auth_cipher_verify_test_case_2_oop),
14869 TEST_CASE_ST(ut_setup, ut_teardown,
14870 test_kasumi_auth_cipher_verify_test_case_2_sgl),
14871 TEST_CASE_ST(ut_setup, ut_teardown,
14872 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14878 static struct unit_test_suite cryptodev_esn_testsuite = {
14879 .suite_name = "ESN Test Suite",
14880 .setup = esn_testsuite_setup,
14881 .unit_test_cases = {
14882 TEST_CASE_ST(ut_setup, ut_teardown,
14883 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14884 TEST_CASE_ST(ut_setup, ut_teardown,
14885 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14890 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
14891 .suite_name = "Negative AES GCM Test Suite",
14892 .setup = negative_aes_gcm_testsuite_setup,
14893 .unit_test_cases = {
14894 TEST_CASE_ST(ut_setup, ut_teardown,
14895 test_AES_GCM_auth_encryption_fail_iv_corrupt),
14896 TEST_CASE_ST(ut_setup, ut_teardown,
14897 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14898 TEST_CASE_ST(ut_setup, ut_teardown,
14899 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14900 TEST_CASE_ST(ut_setup, ut_teardown,
14901 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14902 TEST_CASE_ST(ut_setup, ut_teardown,
14903 test_AES_GCM_auth_encryption_fail_aad_corrupt),
14904 TEST_CASE_ST(ut_setup, ut_teardown,
14905 test_AES_GCM_auth_encryption_fail_tag_corrupt),
14906 TEST_CASE_ST(ut_setup, ut_teardown,
14907 test_AES_GCM_auth_decryption_fail_iv_corrupt),
14908 TEST_CASE_ST(ut_setup, ut_teardown,
14909 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
14910 TEST_CASE_ST(ut_setup, ut_teardown,
14911 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
14912 TEST_CASE_ST(ut_setup, ut_teardown,
14913 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
14914 TEST_CASE_ST(ut_setup, ut_teardown,
14915 test_AES_GCM_auth_decryption_fail_aad_corrupt),
14916 TEST_CASE_ST(ut_setup, ut_teardown,
14917 test_AES_GCM_auth_decryption_fail_tag_corrupt),
14923 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
14924 .suite_name = "Negative AES GMAC Test Suite",
14925 .setup = negative_aes_gmac_testsuite_setup,
14926 .unit_test_cases = {
14927 TEST_CASE_ST(ut_setup, ut_teardown,
14928 authentication_verify_AES128_GMAC_fail_data_corrupt),
14929 TEST_CASE_ST(ut_setup, ut_teardown,
14930 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14936 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
14937 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
14938 .setup = mixed_cipher_hash_testsuite_setup,
14939 .unit_test_cases = {
14940 /** AUTH AES CMAC + CIPHER AES CTR */
14941 TEST_CASE_ST(ut_setup, ut_teardown,
14942 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
14943 TEST_CASE_ST(ut_setup, ut_teardown,
14944 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14945 TEST_CASE_ST(ut_setup, ut_teardown,
14946 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14947 TEST_CASE_ST(ut_setup, ut_teardown,
14948 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14949 TEST_CASE_ST(ut_setup, ut_teardown,
14950 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
14951 TEST_CASE_ST(ut_setup, ut_teardown,
14952 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14953 TEST_CASE_ST(ut_setup, ut_teardown,
14954 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14955 TEST_CASE_ST(ut_setup, ut_teardown,
14956 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14958 /** AUTH ZUC + CIPHER SNOW3G */
14959 TEST_CASE_ST(ut_setup, ut_teardown,
14960 test_auth_zuc_cipher_snow_test_case_1),
14961 TEST_CASE_ST(ut_setup, ut_teardown,
14962 test_verify_auth_zuc_cipher_snow_test_case_1),
14963 /** AUTH AES CMAC + CIPHER SNOW3G */
14964 TEST_CASE_ST(ut_setup, ut_teardown,
14965 test_auth_aes_cmac_cipher_snow_test_case_1),
14966 TEST_CASE_ST(ut_setup, ut_teardown,
14967 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
14968 /** AUTH ZUC + CIPHER AES CTR */
14969 TEST_CASE_ST(ut_setup, ut_teardown,
14970 test_auth_zuc_cipher_aes_ctr_test_case_1),
14971 TEST_CASE_ST(ut_setup, ut_teardown,
14972 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
14973 /** AUTH SNOW3G + CIPHER AES CTR */
14974 TEST_CASE_ST(ut_setup, ut_teardown,
14975 test_auth_snow_cipher_aes_ctr_test_case_1),
14976 TEST_CASE_ST(ut_setup, ut_teardown,
14977 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
14978 /** AUTH SNOW3G + CIPHER ZUC */
14979 TEST_CASE_ST(ut_setup, ut_teardown,
14980 test_auth_snow_cipher_zuc_test_case_1),
14981 TEST_CASE_ST(ut_setup, ut_teardown,
14982 test_verify_auth_snow_cipher_zuc_test_case_1),
14983 /** AUTH AES CMAC + CIPHER ZUC */
14984 TEST_CASE_ST(ut_setup, ut_teardown,
14985 test_auth_aes_cmac_cipher_zuc_test_case_1),
14986 TEST_CASE_ST(ut_setup, ut_teardown,
14987 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
14989 /** AUTH NULL + CIPHER SNOW3G */
14990 TEST_CASE_ST(ut_setup, ut_teardown,
14991 test_auth_null_cipher_snow_test_case_1),
14992 TEST_CASE_ST(ut_setup, ut_teardown,
14993 test_verify_auth_null_cipher_snow_test_case_1),
14994 /** AUTH NULL + CIPHER ZUC */
14995 TEST_CASE_ST(ut_setup, ut_teardown,
14996 test_auth_null_cipher_zuc_test_case_1),
14997 TEST_CASE_ST(ut_setup, ut_teardown,
14998 test_verify_auth_null_cipher_zuc_test_case_1),
14999 /** AUTH SNOW3G + CIPHER NULL */
15000 TEST_CASE_ST(ut_setup, ut_teardown,
15001 test_auth_snow_cipher_null_test_case_1),
15002 TEST_CASE_ST(ut_setup, ut_teardown,
15003 test_verify_auth_snow_cipher_null_test_case_1),
15004 /** AUTH ZUC + CIPHER NULL */
15005 TEST_CASE_ST(ut_setup, ut_teardown,
15006 test_auth_zuc_cipher_null_test_case_1),
15007 TEST_CASE_ST(ut_setup, ut_teardown,
15008 test_verify_auth_zuc_cipher_null_test_case_1),
15009 /** AUTH NULL + CIPHER AES CTR */
15010 TEST_CASE_ST(ut_setup, ut_teardown,
15011 test_auth_null_cipher_aes_ctr_test_case_1),
15012 TEST_CASE_ST(ut_setup, ut_teardown,
15013 test_verify_auth_null_cipher_aes_ctr_test_case_1),
15014 /** AUTH AES CMAC + CIPHER NULL */
15015 TEST_CASE_ST(ut_setup, ut_teardown,
15016 test_auth_aes_cmac_cipher_null_test_case_1),
15017 TEST_CASE_ST(ut_setup, ut_teardown,
15018 test_verify_auth_aes_cmac_cipher_null_test_case_1),
15024 run_cryptodev_testsuite(const char *pmd_name)
15026 uint8_t ret, j, i = 0, blk_start_idx = 0;
15027 const enum blockcipher_test_type blk_suites[] = {
15028 BLKCIPHER_AES_CHAIN_TYPE,
15029 BLKCIPHER_AES_CIPHERONLY_TYPE,
15030 BLKCIPHER_AES_DOCSIS_TYPE,
15031 BLKCIPHER_3DES_CHAIN_TYPE,
15032 BLKCIPHER_3DES_CIPHERONLY_TYPE,
15033 BLKCIPHER_DES_CIPHERONLY_TYPE,
15034 BLKCIPHER_DES_DOCSIS_TYPE,
15035 BLKCIPHER_AUTHONLY_TYPE};
15036 struct unit_test_suite *static_suites[] = {
15037 &cryptodev_multi_session_testsuite,
15038 &cryptodev_null_testsuite,
15039 &cryptodev_aes_ccm_auth_testsuite,
15040 &cryptodev_aes_gcm_auth_testsuite,
15041 &cryptodev_aes_gmac_auth_testsuite,
15042 &cryptodev_snow3g_testsuite,
15043 &cryptodev_chacha20_poly1305_testsuite,
15044 &cryptodev_zuc_testsuite,
15045 &cryptodev_hmac_md5_auth_testsuite,
15046 &cryptodev_kasumi_testsuite,
15047 &cryptodev_esn_testsuite,
15048 &cryptodev_negative_aes_gcm_testsuite,
15049 &cryptodev_negative_aes_gmac_testsuite,
15050 &cryptodev_mixed_cipher_hash_testsuite,
15051 &cryptodev_negative_hmac_sha1_testsuite,
15052 &cryptodev_gen_testsuite,
15053 #ifdef RTE_LIB_SECURITY
15054 &ipsec_proto_testsuite,
15055 &pdcp_proto_testsuite,
15056 &docsis_proto_testsuite,
15060 static struct unit_test_suite ts = {
15061 .suite_name = "Cryptodev Unit Test Suite",
15062 .setup = testsuite_setup,
15063 .teardown = testsuite_teardown,
15064 .unit_test_cases = {TEST_CASES_END()}
15067 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
15069 if (gbl_driver_id == -1) {
15070 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
15071 return TEST_SKIPPED;
15074 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15075 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
15077 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
15078 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15079 ret = unit_test_suite_runner(&ts);
15081 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
15082 free(ts.unit_test_suites);
15087 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
15089 struct rte_cryptodev_info dev_info;
15090 uint8_t i, nb_devs;
15093 driver_id = rte_cryptodev_driver_id_get(pmd_name);
15094 if (driver_id == -1) {
15095 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
15096 return TEST_SKIPPED;
15099 nb_devs = rte_cryptodev_count();
15101 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
15102 return TEST_SKIPPED;
15105 for (i = 0; i < nb_devs; i++) {
15106 rte_cryptodev_info_get(i, &dev_info);
15107 if (dev_info.driver_id == driver_id) {
15108 if (!(dev_info.feature_flags & flag)) {
15109 RTE_LOG(INFO, USER1, "%s not supported\n",
15111 return TEST_SKIPPED;
15113 return 0; /* found */
15117 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
15118 return TEST_SKIPPED;
15122 test_cryptodev_qat(void)
15124 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
15128 test_cryptodev_virtio(void)
15130 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
15134 test_cryptodev_aesni_mb(void)
15136 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15140 test_cryptodev_cpu_aesni_mb(void)
15143 enum rte_security_session_action_type at = gbl_action_type;
15144 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15145 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15146 gbl_action_type = at;
15151 test_cryptodev_openssl(void)
15153 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
15157 test_cryptodev_aesni_gcm(void)
15159 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15163 test_cryptodev_cpu_aesni_gcm(void)
15166 enum rte_security_session_action_type at = gbl_action_type;
15167 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15168 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15169 gbl_action_type = at;
15174 test_cryptodev_mlx5(void)
15176 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
15180 test_cryptodev_null(void)
15182 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
15186 test_cryptodev_sw_snow3g(void)
15188 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
15192 test_cryptodev_sw_kasumi(void)
15194 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
15198 test_cryptodev_sw_zuc(void)
15200 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
15204 test_cryptodev_armv8(void)
15206 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
15210 test_cryptodev_mrvl(void)
15212 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
15215 #ifdef RTE_CRYPTO_SCHEDULER
15218 test_cryptodev_scheduler(void)
15220 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
15221 const enum blockcipher_test_type blk_suites[] = {
15222 BLKCIPHER_AES_CHAIN_TYPE,
15223 BLKCIPHER_AES_CIPHERONLY_TYPE,
15224 BLKCIPHER_AUTHONLY_TYPE
15226 static struct unit_test_suite scheduler_multicore = {
15227 .suite_name = "Scheduler Multicore Unit Test Suite",
15228 .setup = scheduler_multicore_testsuite_setup,
15229 .teardown = scheduler_mode_testsuite_teardown,
15230 .unit_test_cases = {TEST_CASES_END()}
15232 static struct unit_test_suite scheduler_round_robin = {
15233 .suite_name = "Scheduler Round Robin Unit Test Suite",
15234 .setup = scheduler_roundrobin_testsuite_setup,
15235 .teardown = scheduler_mode_testsuite_teardown,
15236 .unit_test_cases = {TEST_CASES_END()}
15238 static struct unit_test_suite scheduler_failover = {
15239 .suite_name = "Scheduler Failover Unit Test Suite",
15240 .setup = scheduler_failover_testsuite_setup,
15241 .teardown = scheduler_mode_testsuite_teardown,
15242 .unit_test_cases = {TEST_CASES_END()}
15244 static struct unit_test_suite scheduler_pkt_size_distr = {
15245 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
15246 .setup = scheduler_pkt_size_distr_testsuite_setup,
15247 .teardown = scheduler_mode_testsuite_teardown,
15248 .unit_test_cases = {TEST_CASES_END()}
15250 struct unit_test_suite *sched_mode_suites[] = {
15251 &scheduler_multicore,
15252 &scheduler_round_robin,
15253 &scheduler_failover,
15254 &scheduler_pkt_size_distr
15256 static struct unit_test_suite scheduler_config = {
15257 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
15258 .unit_test_cases = {
15259 TEST_CASE(test_scheduler_attach_worker_op),
15260 TEST_CASE(test_scheduler_mode_multicore_op),
15261 TEST_CASE(test_scheduler_mode_roundrobin_op),
15262 TEST_CASE(test_scheduler_mode_failover_op),
15263 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
15264 TEST_CASE(test_scheduler_detach_worker_op),
15266 TEST_CASES_END() /**< NULL terminate array */
15269 struct unit_test_suite *static_suites[] = {
15273 static struct unit_test_suite ts = {
15274 .suite_name = "Scheduler Unit Test Suite",
15275 .setup = scheduler_testsuite_setup,
15276 .teardown = testsuite_teardown,
15277 .unit_test_cases = {TEST_CASES_END()}
15280 gbl_driver_id = rte_cryptodev_driver_id_get(
15281 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15283 if (gbl_driver_id == -1) {
15284 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
15285 return TEST_SKIPPED;
15288 if (rte_cryptodev_driver_id_get(
15289 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
15290 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
15291 return TEST_SKIPPED;
15294 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15296 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
15297 (struct unit_test_suite *) *
15298 (RTE_DIM(blk_suites) + 1));
15299 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
15300 blk_suites, RTE_DIM(blk_suites));
15301 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
15304 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15305 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
15306 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
15307 RTE_DIM(sched_mode_suites));
15308 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15309 ret = unit_test_suite_runner(&ts);
15311 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15312 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
15313 (*sched_mode_suites[sched_i]),
15314 RTE_DIM(blk_suites));
15315 free(sched_mode_suites[sched_i]->unit_test_suites);
15317 free(ts.unit_test_suites);
15321 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
15326 test_cryptodev_dpaa2_sec(void)
15328 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
15332 test_cryptodev_dpaa_sec(void)
15334 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
15338 test_cryptodev_ccp(void)
15340 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
15344 test_cryptodev_octeontx(void)
15346 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
15350 test_cryptodev_octeontx2(void)
15352 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
15356 test_cryptodev_caam_jr(void)
15358 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
15362 test_cryptodev_nitrox(void)
15364 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
15368 test_cryptodev_bcmfs(void)
15370 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
15374 test_cryptodev_qat_raw_api(void)
15376 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
15379 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15384 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15385 ret = run_cryptodev_testsuite(pmd_name);
15386 global_api_test_type = CRYPTODEV_API_TEST;
15392 test_cryptodev_cn9k(void)
15394 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
15398 test_cryptodev_cn10k(void)
15400 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
15403 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
15404 test_cryptodev_qat_raw_api);
15405 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
15406 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
15407 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
15408 test_cryptodev_cpu_aesni_mb);
15409 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
15410 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
15411 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
15412 test_cryptodev_cpu_aesni_gcm);
15413 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
15414 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
15415 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
15416 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
15417 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
15418 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
15419 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
15420 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
15421 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
15422 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
15423 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
15424 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
15425 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
15426 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
15427 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
15428 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
15429 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
15430 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);