1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
20 #include <rte_string_fns.h>
24 #ifdef RTE_CRYPTO_SCHEDULER
25 #include <rte_cryptodev_scheduler.h>
26 #include <rte_cryptodev_scheduler_operations.h>
29 #include <rte_lcore.h>
32 #include "test_cryptodev.h"
34 #include "test_cryptodev_blockcipher.h"
35 #include "test_cryptodev_aes_test_vectors.h"
36 #include "test_cryptodev_des_test_vectors.h"
37 #include "test_cryptodev_hash_test_vectors.h"
38 #include "test_cryptodev_kasumi_test_vectors.h"
39 #include "test_cryptodev_kasumi_hash_test_vectors.h"
40 #include "test_cryptodev_snow3g_test_vectors.h"
41 #include "test_cryptodev_snow3g_hash_test_vectors.h"
42 #include "test_cryptodev_zuc_test_vectors.h"
43 #include "test_cryptodev_aead_test_vectors.h"
44 #include "test_cryptodev_hmac_test_vectors.h"
45 #include "test_cryptodev_mixed_test_vectors.h"
46 #ifdef RTE_LIB_SECURITY
47 #include "test_cryptodev_security_ipsec.h"
48 #include "test_cryptodev_security_ipsec_test_vectors.h"
49 #include "test_cryptodev_security_pdcp_test_vectors.h"
50 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
51 #include "test_cryptodev_security_pdcp_test_func.h"
52 #include "test_cryptodev_security_docsis_test_vectors.h"
54 #define SDAP_DISABLED 0
55 #define SDAP_ENABLED 1
58 #define VDEV_ARGS_SIZE 100
59 #define MAX_NB_SESSIONS 4
61 #define MAX_DRV_SERVICE_CTX_SIZE 256
63 #define MAX_RAW_DEQUEUE_COUNT 65535
66 #define OUT_OF_PLACE 1
68 static int gbl_driver_id;
70 static enum rte_security_session_action_type gbl_action_type =
71 RTE_SECURITY_ACTION_TYPE_NONE;
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 struct crypto_unittest_params {
76 struct rte_crypto_sym_xform cipher_xform;
77 struct rte_crypto_sym_xform auth_xform;
78 struct rte_crypto_sym_xform aead_xform;
79 #ifdef RTE_LIB_SECURITY
80 struct rte_security_docsis_xform docsis_xform;
84 struct rte_cryptodev_sym_session *sess;
85 #ifdef RTE_LIB_SECURITY
86 struct rte_security_session *sec_session;
89 #ifdef RTE_LIB_SECURITY
90 enum rte_security_session_action_type type;
92 struct rte_crypto_op *op;
94 struct rte_mbuf *obuf, *ibuf;
99 #define ALIGN_POW2_ROUNDUP(num, align) \
100 (((num) + (align) - 1) & ~((align) - 1))
102 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
103 for (j = 0; j < num_child_ts; index++, j++) \
104 parent_ts.unit_test_suites[index] = child_ts[j]
106 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
107 for (j = 0; j < num_blk_types; index++, j++) \
108 parent_ts.unit_test_suites[index] = \
109 build_blockcipher_test_suite(blk_types[j])
111 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
112 for (j = index; j < index + num_blk_types; j++) \
113 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
116 * Forward declarations.
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 struct crypto_unittest_params *ut_params,
126 struct crypto_testsuite_params *ts_param,
127 const uint8_t *cipher,
128 const uint8_t *digest,
132 security_proto_supported(enum rte_security_session_action_type action,
133 enum rte_security_session_protocol proto);
136 dev_configure_and_start(uint64_t ff_disable);
138 static struct rte_mbuf *
139 setup_test_string(struct rte_mempool *mpool,
140 const char *string, size_t len, uint8_t blocksize)
142 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
143 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
148 memset(m->buf_addr, 0, m->buf_len);
149 dst = rte_pktmbuf_append(m, t_len);
155 rte_memcpy(dst, string, t_len);
157 memset(dst, 0, t_len);
163 /* Get number of bytes in X bits (rounding up) */
165 ceil_byte_length(uint32_t num_bits)
168 return ((num_bits >> 3) + 1);
170 return (num_bits >> 3);
174 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
175 uint8_t is_op_success)
177 struct rte_crypto_op *op = user_data;
178 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
179 RTE_CRYPTO_OP_STATUS_ERROR;
182 static struct crypto_testsuite_params testsuite_params = { NULL };
183 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
184 static struct crypto_unittest_params unittest_params;
187 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
188 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
189 uint8_t len_in_bits, uint8_t cipher_iv_len)
191 struct rte_crypto_sym_op *sop = op->sym;
192 struct rte_crypto_op *ret_op = NULL;
193 struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
194 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
195 union rte_crypto_sym_ofs ofs;
196 struct rte_crypto_sym_vec vec;
197 struct rte_crypto_sgl sgl, dest_sgl;
199 union rte_cryptodev_session_ctx sess;
200 uint64_t auth_end_iova;
202 struct rte_crypto_raw_dp_ctx *ctx;
203 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
207 int ctx_service_size;
209 int enqueue_status, dequeue_status;
210 struct crypto_unittest_params *ut_params = &unittest_params;
211 int is_sgl = sop->m_src->nb_segs > 1;
213 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
214 if (ctx_service_size < 0) {
215 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
219 ctx = malloc(ctx_service_size);
221 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
225 /* Both are enums, setting crypto_sess will suit any session type */
226 sess.crypto_sess = op->sym->session;
228 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
229 op->sess_type, sess, 0) < 0) {
230 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
236 aad_auth_iv.iova = 0;
237 aad_auth_iv.va = NULL;
244 vec.digest = &digest;
245 vec.aad = &aad_auth_iv;
246 vec.status = &status;
250 if (is_cipher && is_auth) {
251 cipher_offset = sop->cipher.data.offset;
252 cipher_len = sop->cipher.data.length;
253 auth_offset = sop->auth.data.offset;
254 auth_len = sop->auth.data.length;
255 max_len = RTE_MAX(cipher_offset + cipher_len,
256 auth_offset + auth_len);
258 max_len = max_len >> 3;
259 cipher_offset = cipher_offset >> 3;
260 auth_offset = auth_offset >> 3;
261 cipher_len = cipher_len >> 3;
262 auth_len = auth_len >> 3;
264 ofs.ofs.cipher.head = cipher_offset;
265 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
266 ofs.ofs.auth.head = auth_offset;
267 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
268 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
269 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
270 aad_auth_iv.va = rte_crypto_op_ctod_offset(
271 op, void *, IV_OFFSET + cipher_iv_len);
272 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
274 digest.va = (void *)sop->auth.digest.data;
275 digest.iova = sop->auth.digest.phys_addr;
278 uint32_t remaining_off = auth_offset + auth_len;
279 struct rte_mbuf *sgl_buf = sop->m_src;
281 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
282 && sgl_buf->next != NULL) {
283 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
284 sgl_buf = sgl_buf->next;
287 auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
288 sgl_buf, remaining_off);
290 auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
291 auth_offset + auth_len;
293 /* Then check if digest-encrypted conditions are met */
294 if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
295 (digest.iova == auth_end_iova) && is_sgl)
296 max_len = RTE_MAX(max_len, auth_offset + auth_len +
297 ut_params->auth_xform.auth.digest_length);
299 } else if (is_cipher) {
300 cipher_offset = sop->cipher.data.offset;
301 cipher_len = sop->cipher.data.length;
302 max_len = cipher_len + cipher_offset;
304 max_len = max_len >> 3;
305 cipher_offset = cipher_offset >> 3;
306 cipher_len = cipher_len >> 3;
308 ofs.ofs.cipher.head = cipher_offset;
309 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
310 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
311 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
313 } else if (is_auth) {
314 auth_offset = sop->auth.data.offset;
315 auth_len = sop->auth.data.length;
316 max_len = auth_len + auth_offset;
318 max_len = max_len >> 3;
319 auth_offset = auth_offset >> 3;
320 auth_len = auth_len >> 3;
322 ofs.ofs.auth.head = auth_offset;
323 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
324 aad_auth_iv.va = rte_crypto_op_ctod_offset(
325 op, void *, IV_OFFSET + cipher_iv_len);
326 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
328 digest.va = (void *)sop->auth.digest.data;
329 digest.iova = sop->auth.digest.phys_addr;
332 cipher_offset = sop->aead.data.offset;
333 cipher_len = sop->aead.data.length;
334 max_len = cipher_len + cipher_offset;
336 max_len = max_len >> 3;
337 cipher_offset = cipher_offset >> 3;
338 cipher_len = cipher_len >> 3;
340 ofs.ofs.cipher.head = cipher_offset;
341 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
342 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
343 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
344 aad_auth_iv.va = (void *)sop->aead.aad.data;
345 aad_auth_iv.iova = sop->aead.aad.phys_addr;
346 digest.va = (void *)sop->aead.digest.data;
347 digest.iova = sop->aead.digest.phys_addr;
350 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
351 data_vec, RTE_DIM(data_vec));
352 if (n < 0 || n > sop->m_src->nb_segs) {
353 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
359 if (sop->m_dst != NULL) {
360 dest_sgl.vec = dest_data_vec;
361 vec.dest_sgl = &dest_sgl;
362 n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
363 dest_data_vec, RTE_DIM(dest_data_vec));
364 if (n < 0 || n > sop->m_dst->nb_segs) {
365 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
372 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
373 &enqueue_status) < 1) {
374 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
378 if (enqueue_status == 0) {
379 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
381 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
384 } else if (enqueue_status < 0) {
385 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
390 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
391 n = rte_cryptodev_raw_dequeue_burst(ctx,
392 NULL, 1, post_process_raw_dp_op,
393 (void **)&ret_op, 0, &n_success,
395 if (dequeue_status < 0) {
396 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
403 if (n == 1 && dequeue_status == 0) {
404 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
405 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
410 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
411 ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
412 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
413 RTE_CRYPTO_OP_STATUS_SUCCESS;
420 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
423 struct rte_crypto_sym_op *sop;
424 union rte_crypto_sym_ofs ofs;
425 struct rte_crypto_sgl sgl;
426 struct rte_crypto_sym_vec symvec;
427 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
428 struct rte_crypto_vec vec[UINT8_MAX];
432 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
433 sop->aead.data.length, vec, RTE_DIM(vec));
435 if (n < 0 || n != sop->m_src->nb_segs) {
436 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
442 symvec.src_sgl = &sgl;
444 symvec.digest = &digest_ptr;
445 symvec.aad = &aad_ptr;
449 /* for CPU crypto the IOVA address is not required */
450 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
451 digest_ptr.va = (void *)sop->aead.digest.data;
452 aad_ptr.va = (void *)sop->aead.aad.data;
456 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
460 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
462 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
466 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
469 struct rte_crypto_sym_op *sop;
470 union rte_crypto_sym_ofs ofs;
471 struct rte_crypto_sgl sgl;
472 struct rte_crypto_sym_vec symvec;
473 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
474 struct rte_crypto_vec vec[UINT8_MAX];
478 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
479 sop->auth.data.length, vec, RTE_DIM(vec));
481 if (n < 0 || n != sop->m_src->nb_segs) {
482 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
488 symvec.src_sgl = &sgl;
490 symvec.digest = &digest_ptr;
494 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
495 digest_ptr.va = (void *)sop->auth.digest.data;
498 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
499 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
500 (sop->cipher.data.offset + sop->cipher.data.length);
502 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
506 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
508 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
511 static struct rte_crypto_op *
512 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
515 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
517 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
518 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
524 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
527 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
528 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
536 testsuite_setup(void)
538 struct crypto_testsuite_params *ts_params = &testsuite_params;
539 struct rte_cryptodev_info info;
540 uint32_t i = 0, nb_devs, dev_id;
543 memset(ts_params, 0, sizeof(*ts_params));
545 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
546 if (ts_params->mbuf_pool == NULL) {
547 /* Not already created so create */
548 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
550 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
552 if (ts_params->mbuf_pool == NULL) {
553 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
558 ts_params->large_mbuf_pool = rte_mempool_lookup(
559 "CRYPTO_LARGE_MBUFPOOL");
560 if (ts_params->large_mbuf_pool == NULL) {
561 /* Not already created so create */
562 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
563 "CRYPTO_LARGE_MBUFPOOL",
566 if (ts_params->large_mbuf_pool == NULL) {
568 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
573 ts_params->op_mpool = rte_crypto_op_pool_create(
574 "MBUF_CRYPTO_SYM_OP_POOL",
575 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
576 NUM_MBUFS, MBUF_CACHE_SIZE,
578 sizeof(struct rte_crypto_sym_xform) +
581 if (ts_params->op_mpool == NULL) {
582 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
586 nb_devs = rte_cryptodev_count();
588 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
592 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
593 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
594 rte_cryptodev_driver_name_get(gbl_driver_id));
598 /* Create list of valid crypto devs */
599 for (i = 0; i < nb_devs; i++) {
600 rte_cryptodev_info_get(i, &info);
601 if (info.driver_id == gbl_driver_id)
602 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
605 if (ts_params->valid_dev_count < 1)
608 /* Set up all the qps on the first of the valid devices found */
610 dev_id = ts_params->valid_devs[0];
612 rte_cryptodev_info_get(dev_id, &info);
614 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
615 ts_params->conf.socket_id = SOCKET_ID_ANY;
616 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
618 unsigned int session_size =
619 rte_cryptodev_sym_get_private_session_size(dev_id);
621 #ifdef RTE_LIB_SECURITY
622 unsigned int security_session_size = rte_security_session_get_size(
623 rte_cryptodev_get_sec_ctx(dev_id));
625 if (session_size < security_session_size)
626 session_size = security_session_size;
629 * Create mempool with maximum number of sessions.
631 if (info.sym.max_nb_sessions != 0 &&
632 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
633 RTE_LOG(ERR, USER1, "Device does not support "
634 "at least %u sessions\n",
639 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
640 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
642 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
643 "session mempool allocation failed");
645 ts_params->session_priv_mpool = rte_mempool_create(
649 0, 0, NULL, NULL, NULL,
652 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
653 "session mempool allocation failed");
657 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
659 "Failed to configure cryptodev %u with %u qps",
660 dev_id, ts_params->conf.nb_queue_pairs);
662 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
663 ts_params->qp_conf.mp_session = ts_params->session_mpool;
664 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
666 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
667 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
668 dev_id, qp_id, &ts_params->qp_conf,
669 rte_cryptodev_socket_id(dev_id)),
670 "Failed to setup queue pair %u on cryptodev %u",
678 testsuite_teardown(void)
680 struct crypto_testsuite_params *ts_params = &testsuite_params;
683 if (ts_params->mbuf_pool != NULL) {
684 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
685 rte_mempool_avail_count(ts_params->mbuf_pool));
688 if (ts_params->op_mpool != NULL) {
689 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
690 rte_mempool_avail_count(ts_params->op_mpool));
693 /* Free session mempools */
694 if (ts_params->session_priv_mpool != NULL) {
695 rte_mempool_free(ts_params->session_priv_mpool);
696 ts_params->session_priv_mpool = NULL;
699 if (ts_params->session_mpool != NULL) {
700 rte_mempool_free(ts_params->session_mpool);
701 ts_params->session_mpool = NULL;
704 res = rte_cryptodev_close(ts_params->valid_devs[0]);
706 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
710 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
711 const int *algs, uint16_t num_algs)
713 uint8_t dev_id = testsuite_params.valid_devs[0];
714 bool some_alg_supported = FALSE;
717 for (i = 0; i < num_algs && !some_alg_supported; i++) {
718 struct rte_cryptodev_sym_capability_idx alg = {
721 if (rte_cryptodev_sym_capability_get(dev_id,
723 some_alg_supported = TRUE;
725 if (!some_alg_supported)
732 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
733 uint16_t num_ciphers)
735 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
736 (const int *) ciphers, num_ciphers);
740 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
743 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
744 (const int *) auths, num_auths);
748 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
751 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
752 (const int *) aeads, num_aeads);
756 null_testsuite_setup(void)
758 struct crypto_testsuite_params *ts_params = &testsuite_params;
759 uint8_t dev_id = ts_params->valid_devs[0];
760 struct rte_cryptodev_info dev_info;
761 const enum rte_crypto_cipher_algorithm ciphers[] = {
762 RTE_CRYPTO_CIPHER_NULL
764 const enum rte_crypto_auth_algorithm auths[] = {
768 rte_cryptodev_info_get(dev_id, &dev_info);
770 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
771 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
772 "testsuite not met\n");
776 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
777 && check_auth_capabilities_supported(auths,
778 RTE_DIM(auths)) != 0) {
779 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
780 "testsuite not met\n");
788 crypto_gen_testsuite_setup(void)
790 struct crypto_testsuite_params *ts_params = &testsuite_params;
791 uint8_t dev_id = ts_params->valid_devs[0];
792 struct rte_cryptodev_info dev_info;
794 rte_cryptodev_info_get(dev_id, &dev_info);
796 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
797 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
798 "testsuite not met\n");
805 #ifdef RTE_LIB_SECURITY
807 ipsec_proto_testsuite_setup(void)
809 struct crypto_testsuite_params *ts_params = &testsuite_params;
810 struct crypto_unittest_params *ut_params = &unittest_params;
811 struct rte_cryptodev_info dev_info;
814 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
816 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
817 RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
818 "testsuite not met\n");
822 /* Reconfigure to enable security */
823 ret = dev_configure_and_start(0);
824 if (ret != TEST_SUCCESS)
827 /* Set action type */
828 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
830 if (security_proto_supported(
831 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
832 RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
833 RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
839 * Stop the device. Device would be started again by individual test
840 * case setup routine.
842 rte_cryptodev_stop(ts_params->valid_devs[0]);
848 pdcp_proto_testsuite_setup(void)
850 struct crypto_testsuite_params *ts_params = &testsuite_params;
851 uint8_t dev_id = ts_params->valid_devs[0];
852 struct rte_cryptodev_info dev_info;
853 const enum rte_crypto_cipher_algorithm ciphers[] = {
854 RTE_CRYPTO_CIPHER_NULL,
855 RTE_CRYPTO_CIPHER_AES_CTR,
856 RTE_CRYPTO_CIPHER_ZUC_EEA3,
857 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
859 const enum rte_crypto_auth_algorithm auths[] = {
860 RTE_CRYPTO_AUTH_NULL,
861 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
862 RTE_CRYPTO_AUTH_AES_CMAC,
863 RTE_CRYPTO_AUTH_ZUC_EIA3
866 rte_cryptodev_info_get(dev_id, &dev_info);
868 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
869 !(dev_info.feature_flags &
870 RTE_CRYPTODEV_FF_SECURITY)) {
871 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
872 "testsuite not met\n");
876 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
877 && check_auth_capabilities_supported(auths,
878 RTE_DIM(auths)) != 0) {
879 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
880 "testsuite not met\n");
888 docsis_proto_testsuite_setup(void)
890 struct crypto_testsuite_params *ts_params = &testsuite_params;
891 uint8_t dev_id = ts_params->valid_devs[0];
892 struct rte_cryptodev_info dev_info;
893 const enum rte_crypto_cipher_algorithm ciphers[] = {
894 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
897 rte_cryptodev_info_get(dev_id, &dev_info);
899 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
900 !(dev_info.feature_flags &
901 RTE_CRYPTODEV_FF_SECURITY)) {
902 RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
903 "Proto testsuite not met\n");
907 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
908 RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
909 "testsuite not met\n");
918 aes_ccm_auth_testsuite_setup(void)
920 struct crypto_testsuite_params *ts_params = &testsuite_params;
921 uint8_t dev_id = ts_params->valid_devs[0];
922 struct rte_cryptodev_info dev_info;
923 const enum rte_crypto_aead_algorithm aeads[] = {
924 RTE_CRYPTO_AEAD_AES_CCM
927 rte_cryptodev_info_get(dev_id, &dev_info);
929 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
930 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
931 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
932 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
933 "testsuite not met\n");
937 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
938 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
939 "testsuite not met\n");
947 aes_gcm_auth_testsuite_setup(void)
949 struct crypto_testsuite_params *ts_params = &testsuite_params;
950 uint8_t dev_id = ts_params->valid_devs[0];
951 struct rte_cryptodev_info dev_info;
952 const enum rte_crypto_aead_algorithm aeads[] = {
953 RTE_CRYPTO_AEAD_AES_GCM
956 rte_cryptodev_info_get(dev_id, &dev_info);
958 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
959 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
960 "testsuite not met\n");
964 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
965 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
966 "testsuite not met\n");
974 aes_gmac_auth_testsuite_setup(void)
976 struct crypto_testsuite_params *ts_params = &testsuite_params;
977 uint8_t dev_id = ts_params->valid_devs[0];
978 struct rte_cryptodev_info dev_info;
979 const enum rte_crypto_auth_algorithm auths[] = {
980 RTE_CRYPTO_AUTH_AES_GMAC
983 rte_cryptodev_info_get(dev_id, &dev_info);
985 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
986 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
987 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
988 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
989 "testsuite not met\n");
993 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
994 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
995 "testsuite not met\n");
1003 chacha20_poly1305_testsuite_setup(void)
1005 struct crypto_testsuite_params *ts_params = &testsuite_params;
1006 uint8_t dev_id = ts_params->valid_devs[0];
1007 struct rte_cryptodev_info dev_info;
1008 const enum rte_crypto_aead_algorithm aeads[] = {
1009 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1012 rte_cryptodev_info_get(dev_id, &dev_info);
1014 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1015 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1016 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1017 RTE_LOG(INFO, USER1, "Feature flag requirements for "
1018 "Chacha20-Poly1305 testsuite not met\n");
1019 return TEST_SKIPPED;
1022 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1023 RTE_LOG(INFO, USER1, "Capability requirements for "
1024 "Chacha20-Poly1305 testsuite not met\n");
1025 return TEST_SKIPPED;
1032 snow3g_testsuite_setup(void)
1034 struct crypto_testsuite_params *ts_params = &testsuite_params;
1035 uint8_t dev_id = ts_params->valid_devs[0];
1036 struct rte_cryptodev_info dev_info;
1037 const enum rte_crypto_cipher_algorithm ciphers[] = {
1038 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1041 const enum rte_crypto_auth_algorithm auths[] = {
1042 RTE_CRYPTO_AUTH_SNOW3G_UIA2
1045 rte_cryptodev_info_get(dev_id, &dev_info);
1047 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1048 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1049 "testsuite not met\n");
1050 return TEST_SKIPPED;
1053 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1054 && check_auth_capabilities_supported(auths,
1055 RTE_DIM(auths)) != 0) {
1056 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1057 "testsuite not met\n");
1058 return TEST_SKIPPED;
1065 zuc_testsuite_setup(void)
1067 struct crypto_testsuite_params *ts_params = &testsuite_params;
1068 uint8_t dev_id = ts_params->valid_devs[0];
1069 struct rte_cryptodev_info dev_info;
1070 const enum rte_crypto_cipher_algorithm ciphers[] = {
1071 RTE_CRYPTO_CIPHER_ZUC_EEA3
1073 const enum rte_crypto_auth_algorithm auths[] = {
1074 RTE_CRYPTO_AUTH_ZUC_EIA3
1077 rte_cryptodev_info_get(dev_id, &dev_info);
1079 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1080 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1081 "testsuite not met\n");
1082 return TEST_SKIPPED;
1085 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1086 && check_auth_capabilities_supported(auths,
1087 RTE_DIM(auths)) != 0) {
1088 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1089 "testsuite not met\n");
1090 return TEST_SKIPPED;
1097 hmac_md5_auth_testsuite_setup(void)
1099 struct crypto_testsuite_params *ts_params = &testsuite_params;
1100 uint8_t dev_id = ts_params->valid_devs[0];
1101 struct rte_cryptodev_info dev_info;
1102 const enum rte_crypto_auth_algorithm auths[] = {
1103 RTE_CRYPTO_AUTH_MD5_HMAC
1106 rte_cryptodev_info_get(dev_id, &dev_info);
1108 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1109 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1110 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1111 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1112 "Auth testsuite not met\n");
1113 return TEST_SKIPPED;
1116 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1117 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1118 "testsuite not met\n");
1119 return TEST_SKIPPED;
1126 kasumi_testsuite_setup(void)
1128 struct crypto_testsuite_params *ts_params = &testsuite_params;
1129 uint8_t dev_id = ts_params->valid_devs[0];
1130 struct rte_cryptodev_info dev_info;
1131 const enum rte_crypto_cipher_algorithm ciphers[] = {
1132 RTE_CRYPTO_CIPHER_KASUMI_F8
1134 const enum rte_crypto_auth_algorithm auths[] = {
1135 RTE_CRYPTO_AUTH_KASUMI_F9
1138 rte_cryptodev_info_get(dev_id, &dev_info);
1140 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1141 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1142 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1143 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1144 "testsuite not met\n");
1145 return TEST_SKIPPED;
1148 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1149 && check_auth_capabilities_supported(auths,
1150 RTE_DIM(auths)) != 0) {
1151 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1152 "testsuite not met\n");
1153 return TEST_SKIPPED;
1160 negative_aes_gcm_testsuite_setup(void)
1162 struct crypto_testsuite_params *ts_params = &testsuite_params;
1163 uint8_t dev_id = ts_params->valid_devs[0];
1164 struct rte_cryptodev_info dev_info;
1165 const enum rte_crypto_aead_algorithm aeads[] = {
1166 RTE_CRYPTO_AEAD_AES_GCM
1169 rte_cryptodev_info_get(dev_id, &dev_info);
1171 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1172 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1173 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1174 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1175 "AES GCM testsuite not met\n");
1176 return TEST_SKIPPED;
1179 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1180 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1181 "AES GCM testsuite not met\n");
1182 return TEST_SKIPPED;
1189 negative_aes_gmac_testsuite_setup(void)
1191 struct crypto_testsuite_params *ts_params = &testsuite_params;
1192 uint8_t dev_id = ts_params->valid_devs[0];
1193 struct rte_cryptodev_info dev_info;
1194 const enum rte_crypto_auth_algorithm auths[] = {
1195 RTE_CRYPTO_AUTH_AES_GMAC
1198 rte_cryptodev_info_get(dev_id, &dev_info);
1200 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1201 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1202 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1203 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1204 "AES GMAC testsuite not met\n");
1205 return TEST_SKIPPED;
1208 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1209 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1210 "AES GMAC testsuite not met\n");
1211 return TEST_SKIPPED;
1218 mixed_cipher_hash_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 uint64_t feat_flags;
1224 const enum rte_crypto_cipher_algorithm ciphers[] = {
1225 RTE_CRYPTO_CIPHER_NULL,
1226 RTE_CRYPTO_CIPHER_AES_CTR,
1227 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1228 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1230 const enum rte_crypto_auth_algorithm auths[] = {
1231 RTE_CRYPTO_AUTH_NULL,
1232 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1233 RTE_CRYPTO_AUTH_AES_CMAC,
1234 RTE_CRYPTO_AUTH_ZUC_EIA3
1237 rte_cryptodev_info_get(dev_id, &dev_info);
1238 feat_flags = dev_info.feature_flags;
1240 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1241 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1242 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1243 "Cipher Hash testsuite not met\n");
1244 return TEST_SKIPPED;
1247 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1248 && check_auth_capabilities_supported(auths,
1249 RTE_DIM(auths)) != 0) {
1250 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1251 "Cipher Hash testsuite not met\n");
1252 return TEST_SKIPPED;
1259 esn_testsuite_setup(void)
1261 struct crypto_testsuite_params *ts_params = &testsuite_params;
1262 uint8_t dev_id = ts_params->valid_devs[0];
1263 struct rte_cryptodev_info dev_info;
1264 const enum rte_crypto_cipher_algorithm ciphers[] = {
1265 RTE_CRYPTO_CIPHER_AES_CBC
1267 const enum rte_crypto_auth_algorithm auths[] = {
1268 RTE_CRYPTO_AUTH_SHA1_HMAC
1271 rte_cryptodev_info_get(dev_id, &dev_info);
1273 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1274 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1275 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1276 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1277 "testsuite not met\n");
1278 return TEST_SKIPPED;
1281 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1282 && check_auth_capabilities_supported(auths,
1283 RTE_DIM(auths)) != 0) {
1284 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1285 "testsuite not met\n");
1286 return TEST_SKIPPED;
1293 multi_session_testsuite_setup(void)
1295 struct crypto_testsuite_params *ts_params = &testsuite_params;
1296 uint8_t dev_id = ts_params->valid_devs[0];
1297 struct rte_cryptodev_info dev_info;
1298 const enum rte_crypto_cipher_algorithm ciphers[] = {
1299 RTE_CRYPTO_CIPHER_AES_CBC
1301 const enum rte_crypto_auth_algorithm auths[] = {
1302 RTE_CRYPTO_AUTH_SHA512_HMAC
1305 rte_cryptodev_info_get(dev_id, &dev_info);
1307 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1308 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1309 "Session testsuite not met\n");
1310 return TEST_SKIPPED;
1313 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1314 && check_auth_capabilities_supported(auths,
1315 RTE_DIM(auths)) != 0) {
1316 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1317 "Session testsuite not met\n");
1318 return TEST_SKIPPED;
1325 negative_hmac_sha1_testsuite_setup(void)
1327 struct crypto_testsuite_params *ts_params = &testsuite_params;
1328 uint8_t dev_id = ts_params->valid_devs[0];
1329 struct rte_cryptodev_info dev_info;
1330 const enum rte_crypto_cipher_algorithm ciphers[] = {
1331 RTE_CRYPTO_CIPHER_AES_CBC
1333 const enum rte_crypto_auth_algorithm auths[] = {
1334 RTE_CRYPTO_AUTH_SHA1_HMAC
1337 rte_cryptodev_info_get(dev_id, &dev_info);
1339 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1340 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1341 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1342 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1343 "HMAC SHA1 testsuite not met\n");
1344 return TEST_SKIPPED;
1347 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1348 && check_auth_capabilities_supported(auths,
1349 RTE_DIM(auths)) != 0) {
1350 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1351 "HMAC SHA1 testsuite not met\n");
1352 return TEST_SKIPPED;
1359 dev_configure_and_start(uint64_t ff_disable)
1361 struct crypto_testsuite_params *ts_params = &testsuite_params;
1362 struct crypto_unittest_params *ut_params = &unittest_params;
1366 /* Clear unit test parameters before running test */
1367 memset(ut_params, 0, sizeof(*ut_params));
1369 /* Reconfigure device to default parameters */
1370 ts_params->conf.socket_id = SOCKET_ID_ANY;
1371 ts_params->conf.ff_disable = ff_disable;
1372 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1373 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1374 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1376 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1378 "Failed to configure cryptodev %u",
1379 ts_params->valid_devs[0]);
1381 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1382 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1383 ts_params->valid_devs[0], qp_id,
1384 &ts_params->qp_conf,
1385 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1386 "Failed to setup queue pair %u on cryptodev %u",
1387 qp_id, ts_params->valid_devs[0]);
1391 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1393 /* Start the device */
1394 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1395 "Failed to start cryptodev %u",
1396 ts_params->valid_devs[0]);
1398 return TEST_SUCCESS;
1404 /* Configure and start the device with security feature disabled */
1405 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1409 ut_setup_security(void)
1411 /* Configure and start the device with no features disabled */
1412 return dev_configure_and_start(0);
1418 struct crypto_testsuite_params *ts_params = &testsuite_params;
1419 struct crypto_unittest_params *ut_params = &unittest_params;
1421 /* free crypto session structure */
1422 #ifdef RTE_LIB_SECURITY
1423 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1424 if (ut_params->sec_session) {
1425 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1426 (ts_params->valid_devs[0]),
1427 ut_params->sec_session);
1428 ut_params->sec_session = NULL;
1433 if (ut_params->sess) {
1434 rte_cryptodev_sym_session_clear(
1435 ts_params->valid_devs[0],
1437 rte_cryptodev_sym_session_free(ut_params->sess);
1438 ut_params->sess = NULL;
1442 /* free crypto operation structure */
1444 rte_crypto_op_free(ut_params->op);
1447 * free mbuf - both obuf and ibuf are usually the same,
1448 * so check if they point at the same address is necessary,
1449 * to avoid freeing the mbuf twice.
1451 if (ut_params->obuf) {
1452 rte_pktmbuf_free(ut_params->obuf);
1453 if (ut_params->ibuf == ut_params->obuf)
1454 ut_params->ibuf = 0;
1455 ut_params->obuf = 0;
1457 if (ut_params->ibuf) {
1458 rte_pktmbuf_free(ut_params->ibuf);
1459 ut_params->ibuf = 0;
1462 if (ts_params->mbuf_pool != NULL)
1463 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1464 rte_mempool_avail_count(ts_params->mbuf_pool));
1466 /* Stop the device */
1467 rte_cryptodev_stop(ts_params->valid_devs[0]);
1471 test_device_configure_invalid_dev_id(void)
1473 struct crypto_testsuite_params *ts_params = &testsuite_params;
1474 uint16_t dev_id, num_devs = 0;
1476 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1477 "Need at least %d devices for test", 1);
1479 /* valid dev_id values */
1480 dev_id = ts_params->valid_devs[0];
1482 /* Stop the device in case it's started so it can be configured */
1483 rte_cryptodev_stop(dev_id);
1485 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1486 "Failed test for rte_cryptodev_configure: "
1487 "invalid dev_num %u", dev_id);
1489 /* invalid dev_id values */
1492 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1493 "Failed test for rte_cryptodev_configure: "
1494 "invalid dev_num %u", dev_id);
1498 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1499 "Failed test for rte_cryptodev_configure:"
1500 "invalid dev_num %u", dev_id);
1502 return TEST_SUCCESS;
1506 test_device_configure_invalid_queue_pair_ids(void)
1508 struct crypto_testsuite_params *ts_params = &testsuite_params;
1509 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1511 /* Stop the device in case it's started so it can be configured */
1512 rte_cryptodev_stop(ts_params->valid_devs[0]);
1514 /* valid - max value queue pairs */
1515 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1517 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1519 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1520 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1522 /* valid - one queue pairs */
1523 ts_params->conf.nb_queue_pairs = 1;
1525 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1527 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1528 ts_params->valid_devs[0],
1529 ts_params->conf.nb_queue_pairs);
1532 /* invalid - zero queue pairs */
1533 ts_params->conf.nb_queue_pairs = 0;
1535 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1537 "Failed test for rte_cryptodev_configure, dev_id %u,"
1539 ts_params->valid_devs[0],
1540 ts_params->conf.nb_queue_pairs);
1543 /* invalid - max value supported by field queue pairs */
1544 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1546 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1548 "Failed test for rte_cryptodev_configure, dev_id %u,"
1550 ts_params->valid_devs[0],
1551 ts_params->conf.nb_queue_pairs);
1554 /* invalid - max value + 1 queue pairs */
1555 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1557 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1559 "Failed test for rte_cryptodev_configure, dev_id %u,"
1561 ts_params->valid_devs[0],
1562 ts_params->conf.nb_queue_pairs);
1564 /* revert to original testsuite value */
1565 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1567 return TEST_SUCCESS;
1571 test_queue_pair_descriptor_setup(void)
1573 struct crypto_testsuite_params *ts_params = &testsuite_params;
1574 struct rte_cryptodev_qp_conf qp_conf = {
1575 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1579 /* Stop the device in case it's started so it can be configured */
1580 rte_cryptodev_stop(ts_params->valid_devs[0]);
1582 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1584 "Failed to configure cryptodev %u",
1585 ts_params->valid_devs[0]);
1588 * Test various ring sizes on this device. memzones can't be
1589 * freed so are re-used if ring is released and re-created.
1591 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1592 qp_conf.mp_session = ts_params->session_mpool;
1593 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1595 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1596 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1597 ts_params->valid_devs[0], qp_id, &qp_conf,
1598 rte_cryptodev_socket_id(
1599 ts_params->valid_devs[0])),
1601 "rte_cryptodev_queue_pair_setup: num_inflights "
1602 "%u on qp %u on cryptodev %u",
1603 qp_conf.nb_descriptors, qp_id,
1604 ts_params->valid_devs[0]);
1607 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1609 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1610 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1611 ts_params->valid_devs[0], qp_id, &qp_conf,
1612 rte_cryptodev_socket_id(
1613 ts_params->valid_devs[0])),
1615 " rte_cryptodev_queue_pair_setup: num_inflights"
1616 " %u on qp %u on cryptodev %u",
1617 qp_conf.nb_descriptors, qp_id,
1618 ts_params->valid_devs[0]);
1621 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1623 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1624 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1625 ts_params->valid_devs[0], qp_id, &qp_conf,
1626 rte_cryptodev_socket_id(
1627 ts_params->valid_devs[0])),
1629 "rte_cryptodev_queue_pair_setup: num_inflights"
1630 " %u on qp %u on cryptodev %u",
1631 qp_conf.nb_descriptors, qp_id,
1632 ts_params->valid_devs[0]);
1635 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1637 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1638 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1639 ts_params->valid_devs[0], qp_id, &qp_conf,
1640 rte_cryptodev_socket_id(
1641 ts_params->valid_devs[0])),
1643 " rte_cryptodev_queue_pair_setup:"
1644 "num_inflights %u on qp %u on cryptodev %u",
1645 qp_conf.nb_descriptors, qp_id,
1646 ts_params->valid_devs[0]);
1649 /* test invalid queue pair id */
1650 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1652 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1654 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1655 ts_params->valid_devs[0],
1657 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1658 "Failed test for rte_cryptodev_queue_pair_setup:"
1659 "invalid qp %u on cryptodev %u",
1660 qp_id, ts_params->valid_devs[0]);
1662 qp_id = 0xffff; /*invalid*/
1664 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1665 ts_params->valid_devs[0],
1667 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1668 "Failed test for rte_cryptodev_queue_pair_setup:"
1669 "invalid qp %u on cryptodev %u",
1670 qp_id, ts_params->valid_devs[0]);
1672 return TEST_SUCCESS;
1675 /* ***** Plaintext data for tests ***** */
1677 const char catch_22_quote_1[] =
1678 "There was only one catch and that was Catch-22, which "
1679 "specified that a concern for one's safety in the face of "
1680 "dangers that were real and immediate was the process of a "
1681 "rational mind. Orr was crazy and could be grounded. All he "
1682 "had to do was ask; and as soon as he did, he would no longer "
1683 "be crazy and would have to fly more missions. Orr would be "
1684 "crazy to fly more missions and sane if he didn't, but if he "
1685 "was sane he had to fly them. If he flew them he was crazy "
1686 "and didn't have to; but if he didn't want to he was sane and "
1687 "had to. Yossarian was moved very deeply by the absolute "
1688 "simplicity of this clause of Catch-22 and let out a "
1689 "respectful whistle. \"That's some catch, that Catch-22\", he "
1690 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1692 const char catch_22_quote[] =
1693 "What a lousy earth! He wondered how many people were "
1694 "destitute that same night even in his own prosperous country, "
1695 "how many homes were shanties, how many husbands were drunk "
1696 "and wives socked, and how many children were bullied, abused, "
1697 "or abandoned. How many families hungered for food they could "
1698 "not afford to buy? How many hearts were broken? How many "
1699 "suicides would take place that same night, how many people "
1700 "would go insane? How many cockroaches and landlords would "
1701 "triumph? How many winners were losers, successes failures, "
1702 "and rich men poor men? How many wise guys were stupid? How "
1703 "many happy endings were unhappy endings? How many honest men "
1704 "were liars, brave men cowards, loyal men traitors, how many "
1705 "sainted men were corrupt, how many people in positions of "
1706 "trust had sold their souls to bodyguards, how many had never "
1707 "had souls? How many straight-and-narrow paths were crooked "
1708 "paths? How many best families were worst families and how "
1709 "many good people were bad people? When you added them all up "
1710 "and then subtracted, you might be left with only the children, "
1711 "and perhaps with Albert Einstein and an old violinist or "
1712 "sculptor somewhere.";
1714 #define QUOTE_480_BYTES (480)
1715 #define QUOTE_512_BYTES (512)
1716 #define QUOTE_768_BYTES (768)
1717 #define QUOTE_1024_BYTES (1024)
1721 /* ***** SHA1 Hash Tests ***** */
1723 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1725 static uint8_t hmac_sha1_key[] = {
1726 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1727 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1728 0xDE, 0xF4, 0xDE, 0xAD };
1730 /* ***** SHA224 Hash Tests ***** */
1732 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1735 /* ***** AES-CBC Cipher Tests ***** */
1737 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1738 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1740 static uint8_t aes_cbc_key[] = {
1741 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1742 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1744 static uint8_t aes_cbc_iv[] = {
1745 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1746 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1749 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1751 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1752 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1753 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1754 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1755 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1756 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1757 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1758 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1759 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1760 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1761 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1762 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1763 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1764 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1765 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1766 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1767 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1768 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1769 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1770 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1771 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1772 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1773 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1774 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1775 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1776 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1777 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1778 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1779 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1780 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1781 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1782 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1783 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1784 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1785 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1786 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1787 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1788 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1789 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1790 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1791 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1792 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1793 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1794 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1795 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1796 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1797 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1798 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1799 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1800 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1801 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1802 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1803 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1804 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1805 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1806 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1807 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1808 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1809 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1810 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1811 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1812 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1813 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1814 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1815 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1818 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1819 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1820 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1821 0x18, 0x8c, 0x1d, 0x32
1825 /* Multisession Vector context Test */
1826 /*Begin Session 0 */
1827 static uint8_t ms_aes_cbc_key0[] = {
1828 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1829 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1832 static uint8_t ms_aes_cbc_iv0[] = {
1833 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1834 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1837 static const uint8_t ms_aes_cbc_cipher0[] = {
1838 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1839 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1840 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1841 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1842 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1843 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1844 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1845 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1846 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1847 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1848 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1849 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1850 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1851 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1852 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1853 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1854 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1855 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1856 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1857 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1858 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1859 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1860 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1861 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1862 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1863 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1864 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1865 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1866 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1867 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1868 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1869 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1870 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1871 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1872 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1873 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1874 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1875 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1876 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1877 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1878 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1879 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1880 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1881 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1882 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1883 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1884 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1885 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1886 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1887 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1888 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1889 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1890 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1891 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1892 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1893 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1894 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1895 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1896 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1897 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1898 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1899 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1900 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1901 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1905 static uint8_t ms_hmac_key0[] = {
1906 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1907 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1908 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1909 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1910 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1911 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1912 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1913 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1916 static const uint8_t ms_hmac_digest0[] = {
1917 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1918 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1919 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1920 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1921 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1922 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1923 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1924 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1928 /* Begin session 1 */
1930 static uint8_t ms_aes_cbc_key1[] = {
1931 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1932 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1935 static uint8_t ms_aes_cbc_iv1[] = {
1936 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1937 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1940 static const uint8_t ms_aes_cbc_cipher1[] = {
1941 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1942 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1943 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1944 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1945 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1946 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1947 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1948 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1949 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1950 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1951 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1952 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1953 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1954 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1955 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1956 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1957 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1958 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1959 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1960 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1961 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1962 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1963 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1964 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1965 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1966 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1967 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1968 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1969 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1970 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1971 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1972 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1973 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1974 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1975 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1976 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1977 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1978 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1979 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1980 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1981 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1982 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1983 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1984 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1985 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1986 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1987 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1988 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1989 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1990 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1991 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1992 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1993 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1994 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1995 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1996 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1997 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1998 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1999 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2000 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2001 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2002 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2003 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2004 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2008 static uint8_t ms_hmac_key1[] = {
2009 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2010 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2011 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2012 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2013 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2014 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2015 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2016 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2019 static const uint8_t ms_hmac_digest1[] = {
2020 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2021 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2022 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2023 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2024 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2025 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2026 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2027 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2030 /* Begin Session 2 */
2031 static uint8_t ms_aes_cbc_key2[] = {
2032 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2033 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2036 static uint8_t ms_aes_cbc_iv2[] = {
2037 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2038 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2041 static const uint8_t ms_aes_cbc_cipher2[] = {
2042 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2043 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2044 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2045 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2046 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2047 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2048 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2049 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2050 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2051 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2052 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2053 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2054 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2055 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2056 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2057 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2058 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2059 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2060 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2061 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2062 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2063 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2064 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2065 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2066 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2067 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2068 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2069 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2070 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2071 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2072 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2073 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2074 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2075 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2076 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2077 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2078 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2079 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2080 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2081 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2082 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2083 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2084 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2085 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2086 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2087 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2088 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2089 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2090 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2091 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2092 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2093 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2094 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2095 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2096 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2097 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2098 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2099 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2100 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2101 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2102 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2103 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2104 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2105 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2108 static uint8_t ms_hmac_key2[] = {
2109 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2110 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2111 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2112 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2113 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2114 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2115 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2116 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2119 static const uint8_t ms_hmac_digest2[] = {
2120 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2121 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2122 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2123 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2124 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2125 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2126 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2127 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2134 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2136 struct crypto_testsuite_params *ts_params = &testsuite_params;
2137 struct crypto_unittest_params *ut_params = &unittest_params;
2140 /* Verify the capabilities */
2141 struct rte_cryptodev_sym_capability_idx cap_idx;
2142 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2143 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2144 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2146 return TEST_SKIPPED;
2147 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2148 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2149 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2151 return TEST_SKIPPED;
2153 /* Generate test mbuf data and space for digest */
2154 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2155 catch_22_quote, QUOTE_512_BYTES, 0);
2157 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2158 DIGEST_BYTE_LENGTH_SHA1);
2159 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2161 /* Setup Cipher Parameters */
2162 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2163 ut_params->cipher_xform.next = &ut_params->auth_xform;
2165 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2166 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2167 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2168 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2169 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2170 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2172 /* Setup HMAC Parameters */
2173 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2175 ut_params->auth_xform.next = NULL;
2177 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2178 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2179 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2180 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2181 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2183 ut_params->sess = rte_cryptodev_sym_session_create(
2184 ts_params->session_mpool);
2185 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2187 /* Create crypto session*/
2188 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2189 ut_params->sess, &ut_params->cipher_xform,
2190 ts_params->session_priv_mpool);
2192 if (status == -ENOTSUP)
2193 return TEST_SKIPPED;
2195 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
2197 /* Generate crypto op data structure */
2198 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2199 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2200 TEST_ASSERT_NOT_NULL(ut_params->op,
2201 "Failed to allocate symmetric crypto operation struct");
2203 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2205 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2207 /* set crypto operation source mbuf */
2208 sym_op->m_src = ut_params->ibuf;
2210 /* Set crypto operation authentication parameters */
2211 sym_op->auth.digest.data = ut_params->digest;
2212 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2213 ut_params->ibuf, QUOTE_512_BYTES);
2215 sym_op->auth.data.offset = 0;
2216 sym_op->auth.data.length = QUOTE_512_BYTES;
2218 /* Copy IV at the end of the crypto operation */
2219 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2220 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2222 /* Set crypto operation cipher parameters */
2223 sym_op->cipher.data.offset = 0;
2224 sym_op->cipher.data.length = QUOTE_512_BYTES;
2226 /* Process crypto operation */
2227 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2228 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2231 TEST_ASSERT_NOT_NULL(
2232 process_crypto_request(ts_params->valid_devs[0],
2234 "failed to process sym crypto op");
2236 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2237 "crypto op processing failed");
2240 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2243 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2244 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2246 "ciphertext data not as expected");
2248 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2250 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2251 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2252 gbl_driver_id == rte_cryptodev_driver_id_get(
2253 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2254 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2255 DIGEST_BYTE_LENGTH_SHA1,
2256 "Generated digest data not as expected");
2258 return TEST_SUCCESS;
2261 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2263 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2265 static uint8_t hmac_sha512_key[] = {
2266 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2267 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2268 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2269 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2270 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2271 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2272 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2273 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2275 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2276 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2277 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2278 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2279 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2280 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2281 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2282 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2283 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2288 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2289 struct crypto_unittest_params *ut_params,
2290 uint8_t *cipher_key,
2294 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2295 struct crypto_unittest_params *ut_params,
2296 struct crypto_testsuite_params *ts_params,
2297 const uint8_t *cipher,
2298 const uint8_t *digest,
2303 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2304 struct crypto_unittest_params *ut_params,
2305 uint8_t *cipher_key,
2309 /* Setup Cipher Parameters */
2310 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2311 ut_params->cipher_xform.next = NULL;
2313 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2314 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2315 ut_params->cipher_xform.cipher.key.data = cipher_key;
2316 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2317 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2318 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2320 /* Setup HMAC Parameters */
2321 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2322 ut_params->auth_xform.next = &ut_params->cipher_xform;
2324 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2325 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2326 ut_params->auth_xform.auth.key.data = hmac_key;
2327 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2328 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2330 return TEST_SUCCESS;
2335 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2336 struct crypto_unittest_params *ut_params,
2337 struct crypto_testsuite_params *ts_params,
2338 const uint8_t *cipher,
2339 const uint8_t *digest,
2342 /* Generate test mbuf data and digest */
2343 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2346 QUOTE_512_BYTES, 0);
2348 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2349 DIGEST_BYTE_LENGTH_SHA512);
2350 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2352 rte_memcpy(ut_params->digest,
2354 DIGEST_BYTE_LENGTH_SHA512);
2356 /* Generate Crypto op data structure */
2357 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2358 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2359 TEST_ASSERT_NOT_NULL(ut_params->op,
2360 "Failed to allocate symmetric crypto operation struct");
2362 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2364 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2366 /* set crypto operation source mbuf */
2367 sym_op->m_src = ut_params->ibuf;
2369 sym_op->auth.digest.data = ut_params->digest;
2370 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2371 ut_params->ibuf, QUOTE_512_BYTES);
2373 sym_op->auth.data.offset = 0;
2374 sym_op->auth.data.length = QUOTE_512_BYTES;
2376 /* Copy IV at the end of the crypto operation */
2377 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2378 iv, CIPHER_IV_LENGTH_AES_CBC);
2380 sym_op->cipher.data.offset = 0;
2381 sym_op->cipher.data.length = QUOTE_512_BYTES;
2383 /* Process crypto operation */
2384 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2385 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2387 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2388 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2389 ut_params->op, 1, 1, 0, 0);
2391 TEST_ASSERT_NOT_NULL(
2392 process_crypto_request(ts_params->valid_devs[0],
2394 "failed to process sym crypto op");
2396 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2397 "crypto op processing failed");
2399 ut_params->obuf = ut_params->op->sym->m_src;
2402 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2403 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2406 "Plaintext data not as expected");
2409 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2410 "Digest verification failed");
2412 return TEST_SUCCESS;
2415 /* ***** SNOW 3G Tests ***** */
2417 create_wireless_algo_hash_session(uint8_t dev_id,
2418 const uint8_t *key, const uint8_t key_len,
2419 const uint8_t iv_len, const uint8_t auth_len,
2420 enum rte_crypto_auth_operation op,
2421 enum rte_crypto_auth_algorithm algo)
2423 uint8_t hash_key[key_len];
2426 struct crypto_testsuite_params *ts_params = &testsuite_params;
2427 struct crypto_unittest_params *ut_params = &unittest_params;
2429 memcpy(hash_key, key, key_len);
2431 debug_hexdump(stdout, "key:", key, key_len);
2433 /* Setup Authentication Parameters */
2434 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2435 ut_params->auth_xform.next = NULL;
2437 ut_params->auth_xform.auth.op = op;
2438 ut_params->auth_xform.auth.algo = algo;
2439 ut_params->auth_xform.auth.key.length = key_len;
2440 ut_params->auth_xform.auth.key.data = hash_key;
2441 ut_params->auth_xform.auth.digest_length = auth_len;
2442 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2443 ut_params->auth_xform.auth.iv.length = iv_len;
2444 ut_params->sess = rte_cryptodev_sym_session_create(
2445 ts_params->session_mpool);
2447 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2448 &ut_params->auth_xform,
2449 ts_params->session_priv_mpool);
2450 if (status == -ENOTSUP)
2451 return TEST_SKIPPED;
2453 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2454 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2459 create_wireless_algo_cipher_session(uint8_t dev_id,
2460 enum rte_crypto_cipher_operation op,
2461 enum rte_crypto_cipher_algorithm algo,
2462 const uint8_t *key, const uint8_t key_len,
2465 uint8_t cipher_key[key_len];
2467 struct crypto_testsuite_params *ts_params = &testsuite_params;
2468 struct crypto_unittest_params *ut_params = &unittest_params;
2470 memcpy(cipher_key, key, key_len);
2472 /* Setup Cipher Parameters */
2473 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2474 ut_params->cipher_xform.next = NULL;
2476 ut_params->cipher_xform.cipher.algo = algo;
2477 ut_params->cipher_xform.cipher.op = op;
2478 ut_params->cipher_xform.cipher.key.data = cipher_key;
2479 ut_params->cipher_xform.cipher.key.length = key_len;
2480 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2481 ut_params->cipher_xform.cipher.iv.length = iv_len;
2483 debug_hexdump(stdout, "key:", key, key_len);
2485 /* Create Crypto session */
2486 ut_params->sess = rte_cryptodev_sym_session_create(
2487 ts_params->session_mpool);
2489 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2490 &ut_params->cipher_xform,
2491 ts_params->session_priv_mpool);
2492 if (status == -ENOTSUP)
2493 return TEST_SKIPPED;
2495 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2496 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2501 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2502 unsigned int cipher_len,
2503 unsigned int cipher_offset)
2505 struct crypto_testsuite_params *ts_params = &testsuite_params;
2506 struct crypto_unittest_params *ut_params = &unittest_params;
2508 /* Generate Crypto op data structure */
2509 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2510 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2511 TEST_ASSERT_NOT_NULL(ut_params->op,
2512 "Failed to allocate pktmbuf offload");
2514 /* Set crypto operation data parameters */
2515 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2517 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2519 /* set crypto operation source mbuf */
2520 sym_op->m_src = ut_params->ibuf;
2523 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2525 sym_op->cipher.data.length = cipher_len;
2526 sym_op->cipher.data.offset = cipher_offset;
2531 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2532 unsigned int cipher_len,
2533 unsigned int cipher_offset)
2535 struct crypto_testsuite_params *ts_params = &testsuite_params;
2536 struct crypto_unittest_params *ut_params = &unittest_params;
2538 /* Generate Crypto op data structure */
2539 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2540 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2541 TEST_ASSERT_NOT_NULL(ut_params->op,
2542 "Failed to allocate pktmbuf offload");
2544 /* Set crypto operation data parameters */
2545 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2547 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2549 /* set crypto operation source mbuf */
2550 sym_op->m_src = ut_params->ibuf;
2551 sym_op->m_dst = ut_params->obuf;
2554 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2556 sym_op->cipher.data.length = cipher_len;
2557 sym_op->cipher.data.offset = cipher_offset;
2562 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2563 enum rte_crypto_cipher_operation cipher_op,
2564 enum rte_crypto_auth_operation auth_op,
2565 enum rte_crypto_auth_algorithm auth_algo,
2566 enum rte_crypto_cipher_algorithm cipher_algo,
2567 const uint8_t *key, uint8_t key_len,
2568 uint8_t auth_iv_len, uint8_t auth_len,
2569 uint8_t cipher_iv_len)
2572 uint8_t cipher_auth_key[key_len];
2575 struct crypto_testsuite_params *ts_params = &testsuite_params;
2576 struct crypto_unittest_params *ut_params = &unittest_params;
2578 memcpy(cipher_auth_key, key, key_len);
2580 /* Setup Authentication Parameters */
2581 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2582 ut_params->auth_xform.next = NULL;
2584 ut_params->auth_xform.auth.op = auth_op;
2585 ut_params->auth_xform.auth.algo = auth_algo;
2586 ut_params->auth_xform.auth.key.length = key_len;
2587 /* Hash key = cipher key */
2588 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2589 ut_params->auth_xform.auth.digest_length = auth_len;
2590 /* Auth IV will be after cipher IV */
2591 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2592 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2594 /* Setup Cipher Parameters */
2595 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2596 ut_params->cipher_xform.next = &ut_params->auth_xform;
2598 ut_params->cipher_xform.cipher.algo = cipher_algo;
2599 ut_params->cipher_xform.cipher.op = cipher_op;
2600 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2601 ut_params->cipher_xform.cipher.key.length = key_len;
2602 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2603 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2605 debug_hexdump(stdout, "key:", key, key_len);
2607 /* Create Crypto session*/
2608 ut_params->sess = rte_cryptodev_sym_session_create(
2609 ts_params->session_mpool);
2610 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2612 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2613 &ut_params->cipher_xform,
2614 ts_params->session_priv_mpool);
2615 if (status == -ENOTSUP)
2616 return TEST_SKIPPED;
2618 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2623 create_wireless_cipher_auth_session(uint8_t dev_id,
2624 enum rte_crypto_cipher_operation cipher_op,
2625 enum rte_crypto_auth_operation auth_op,
2626 enum rte_crypto_auth_algorithm auth_algo,
2627 enum rte_crypto_cipher_algorithm cipher_algo,
2628 const struct wireless_test_data *tdata)
2630 const uint8_t key_len = tdata->key.len;
2631 uint8_t cipher_auth_key[key_len];
2634 struct crypto_testsuite_params *ts_params = &testsuite_params;
2635 struct crypto_unittest_params *ut_params = &unittest_params;
2636 const uint8_t *key = tdata->key.data;
2637 const uint8_t auth_len = tdata->digest.len;
2638 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2639 uint8_t auth_iv_len = tdata->auth_iv.len;
2641 memcpy(cipher_auth_key, key, key_len);
2643 /* Setup Authentication Parameters */
2644 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2645 ut_params->auth_xform.next = NULL;
2647 ut_params->auth_xform.auth.op = auth_op;
2648 ut_params->auth_xform.auth.algo = auth_algo;
2649 ut_params->auth_xform.auth.key.length = key_len;
2650 /* Hash key = cipher key */
2651 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2652 ut_params->auth_xform.auth.digest_length = auth_len;
2653 /* Auth IV will be after cipher IV */
2654 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2655 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2657 /* Setup Cipher Parameters */
2658 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2659 ut_params->cipher_xform.next = &ut_params->auth_xform;
2661 ut_params->cipher_xform.cipher.algo = cipher_algo;
2662 ut_params->cipher_xform.cipher.op = cipher_op;
2663 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2664 ut_params->cipher_xform.cipher.key.length = key_len;
2665 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2666 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2669 debug_hexdump(stdout, "key:", key, key_len);
2671 /* Create Crypto session*/
2672 ut_params->sess = rte_cryptodev_sym_session_create(
2673 ts_params->session_mpool);
2675 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2676 &ut_params->cipher_xform,
2677 ts_params->session_priv_mpool);
2678 if (status == -ENOTSUP)
2679 return TEST_SKIPPED;
2681 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2682 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2687 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2688 const struct wireless_test_data *tdata)
2690 return create_wireless_cipher_auth_session(dev_id,
2691 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2692 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2693 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2697 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2698 enum rte_crypto_cipher_operation cipher_op,
2699 enum rte_crypto_auth_operation auth_op,
2700 enum rte_crypto_auth_algorithm auth_algo,
2701 enum rte_crypto_cipher_algorithm cipher_algo,
2702 const uint8_t *key, const uint8_t key_len,
2703 uint8_t auth_iv_len, uint8_t auth_len,
2704 uint8_t cipher_iv_len)
2706 uint8_t auth_cipher_key[key_len];
2708 struct crypto_testsuite_params *ts_params = &testsuite_params;
2709 struct crypto_unittest_params *ut_params = &unittest_params;
2711 memcpy(auth_cipher_key, key, key_len);
2713 /* Setup Authentication Parameters */
2714 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2715 ut_params->auth_xform.auth.op = auth_op;
2716 ut_params->auth_xform.next = &ut_params->cipher_xform;
2717 ut_params->auth_xform.auth.algo = auth_algo;
2718 ut_params->auth_xform.auth.key.length = key_len;
2719 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2720 ut_params->auth_xform.auth.digest_length = auth_len;
2721 /* Auth IV will be after cipher IV */
2722 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2723 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2725 /* Setup Cipher Parameters */
2726 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2727 ut_params->cipher_xform.next = NULL;
2728 ut_params->cipher_xform.cipher.algo = cipher_algo;
2729 ut_params->cipher_xform.cipher.op = cipher_op;
2730 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2731 ut_params->cipher_xform.cipher.key.length = key_len;
2732 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2733 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2735 debug_hexdump(stdout, "key:", key, key_len);
2737 /* Create Crypto session*/
2738 ut_params->sess = rte_cryptodev_sym_session_create(
2739 ts_params->session_mpool);
2740 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2742 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2743 ut_params->auth_xform.next = NULL;
2744 ut_params->cipher_xform.next = &ut_params->auth_xform;
2745 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2746 &ut_params->cipher_xform,
2747 ts_params->session_priv_mpool);
2750 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2751 &ut_params->auth_xform,
2752 ts_params->session_priv_mpool);
2754 if (status == -ENOTSUP)
2755 return TEST_SKIPPED;
2757 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2763 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2764 unsigned int auth_tag_len,
2765 const uint8_t *iv, unsigned int iv_len,
2766 unsigned int data_pad_len,
2767 enum rte_crypto_auth_operation op,
2768 unsigned int auth_len, unsigned int auth_offset)
2770 struct crypto_testsuite_params *ts_params = &testsuite_params;
2772 struct crypto_unittest_params *ut_params = &unittest_params;
2774 /* Generate Crypto op data structure */
2775 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2776 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2777 TEST_ASSERT_NOT_NULL(ut_params->op,
2778 "Failed to allocate pktmbuf offload");
2780 /* Set crypto operation data parameters */
2781 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2783 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2785 /* set crypto operation source mbuf */
2786 sym_op->m_src = ut_params->ibuf;
2789 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2792 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2793 ut_params->ibuf, auth_tag_len);
2795 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2796 "no room to append auth tag");
2797 ut_params->digest = sym_op->auth.digest.data;
2798 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2799 ut_params->ibuf, data_pad_len);
2800 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2801 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2803 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2805 debug_hexdump(stdout, "digest:",
2806 sym_op->auth.digest.data,
2809 sym_op->auth.data.length = auth_len;
2810 sym_op->auth.data.offset = auth_offset;
2816 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2817 enum rte_crypto_auth_operation op)
2819 struct crypto_testsuite_params *ts_params = &testsuite_params;
2820 struct crypto_unittest_params *ut_params = &unittest_params;
2822 const uint8_t *auth_tag = tdata->digest.data;
2823 const unsigned int auth_tag_len = tdata->digest.len;
2824 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2825 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2827 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2828 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2829 const uint8_t *auth_iv = tdata->auth_iv.data;
2830 const uint8_t auth_iv_len = tdata->auth_iv.len;
2831 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2832 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2834 /* Generate Crypto op data structure */
2835 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2836 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2837 TEST_ASSERT_NOT_NULL(ut_params->op,
2838 "Failed to allocate pktmbuf offload");
2839 /* Set crypto operation data parameters */
2840 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2842 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2844 /* set crypto operation source mbuf */
2845 sym_op->m_src = ut_params->ibuf;
2848 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2849 ut_params->ibuf, auth_tag_len);
2851 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2852 "no room to append auth tag");
2853 ut_params->digest = sym_op->auth.digest.data;
2854 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2855 ut_params->ibuf, data_pad_len);
2856 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2857 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2859 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2861 debug_hexdump(stdout, "digest:",
2862 sym_op->auth.digest.data,
2865 /* Copy cipher and auth IVs at the end of the crypto operation */
2866 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2868 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2869 iv_ptr += cipher_iv_len;
2870 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2872 sym_op->cipher.data.length = cipher_len;
2873 sym_op->cipher.data.offset = 0;
2874 sym_op->auth.data.length = auth_len;
2875 sym_op->auth.data.offset = 0;
2881 create_zuc_cipher_hash_generate_operation(
2882 const struct wireless_test_data *tdata)
2884 return create_wireless_cipher_hash_operation(tdata,
2885 RTE_CRYPTO_AUTH_OP_GENERATE);
2889 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2890 const unsigned auth_tag_len,
2891 const uint8_t *auth_iv, uint8_t auth_iv_len,
2892 unsigned data_pad_len,
2893 enum rte_crypto_auth_operation op,
2894 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2895 const unsigned cipher_len, const unsigned cipher_offset,
2896 const unsigned auth_len, const unsigned auth_offset)
2898 struct crypto_testsuite_params *ts_params = &testsuite_params;
2899 struct crypto_unittest_params *ut_params = &unittest_params;
2901 enum rte_crypto_cipher_algorithm cipher_algo =
2902 ut_params->cipher_xform.cipher.algo;
2903 enum rte_crypto_auth_algorithm auth_algo =
2904 ut_params->auth_xform.auth.algo;
2906 /* Generate Crypto op data structure */
2907 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2908 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2909 TEST_ASSERT_NOT_NULL(ut_params->op,
2910 "Failed to allocate pktmbuf offload");
2911 /* Set crypto operation data parameters */
2912 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2914 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2916 /* set crypto operation source mbuf */
2917 sym_op->m_src = ut_params->ibuf;
2920 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2921 ut_params->ibuf, auth_tag_len);
2923 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2924 "no room to append auth tag");
2925 ut_params->digest = sym_op->auth.digest.data;
2927 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2928 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2929 ut_params->ibuf, data_pad_len);
2931 struct rte_mbuf *m = ut_params->ibuf;
2932 unsigned int offset = data_pad_len;
2934 while (offset > m->data_len && m->next != NULL) {
2935 offset -= m->data_len;
2938 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2942 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2943 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2945 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2947 debug_hexdump(stdout, "digest:",
2948 sym_op->auth.digest.data,
2951 /* Copy cipher and auth IVs at the end of the crypto operation */
2952 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2954 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2955 iv_ptr += cipher_iv_len;
2956 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2958 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2959 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2960 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2961 sym_op->cipher.data.length = cipher_len;
2962 sym_op->cipher.data.offset = cipher_offset;
2964 sym_op->cipher.data.length = cipher_len >> 3;
2965 sym_op->cipher.data.offset = cipher_offset >> 3;
2968 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2969 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2970 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2971 sym_op->auth.data.length = auth_len;
2972 sym_op->auth.data.offset = auth_offset;
2974 sym_op->auth.data.length = auth_len >> 3;
2975 sym_op->auth.data.offset = auth_offset >> 3;
2982 create_wireless_algo_auth_cipher_operation(
2983 const uint8_t *auth_tag, unsigned int auth_tag_len,
2984 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2985 const uint8_t *auth_iv, uint8_t auth_iv_len,
2986 unsigned int data_pad_len,
2987 unsigned int cipher_len, unsigned int cipher_offset,
2988 unsigned int auth_len, unsigned int auth_offset,
2989 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2991 struct crypto_testsuite_params *ts_params = &testsuite_params;
2992 struct crypto_unittest_params *ut_params = &unittest_params;
2994 enum rte_crypto_cipher_algorithm cipher_algo =
2995 ut_params->cipher_xform.cipher.algo;
2996 enum rte_crypto_auth_algorithm auth_algo =
2997 ut_params->auth_xform.auth.algo;
2999 /* Generate Crypto op data structure */
3000 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3001 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3002 TEST_ASSERT_NOT_NULL(ut_params->op,
3003 "Failed to allocate pktmbuf offload");
3005 /* Set crypto operation data parameters */
3006 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3008 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3010 /* set crypto operation mbufs */
3011 sym_op->m_src = ut_params->ibuf;
3012 if (op_mode == OUT_OF_PLACE)
3013 sym_op->m_dst = ut_params->obuf;
3017 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3018 (op_mode == IN_PLACE ?
3019 ut_params->ibuf : ut_params->obuf),
3020 uint8_t *, data_pad_len);
3021 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3022 (op_mode == IN_PLACE ?
3023 ut_params->ibuf : ut_params->obuf),
3025 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3027 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3028 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3029 sym_op->m_src : sym_op->m_dst);
3030 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3031 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3032 sgl_buf = sgl_buf->next;
3034 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3035 uint8_t *, remaining_off);
3036 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3038 memset(sym_op->auth.digest.data, 0, remaining_off);
3039 while (sgl_buf->next != NULL) {
3040 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3041 0, rte_pktmbuf_data_len(sgl_buf));
3042 sgl_buf = sgl_buf->next;
3046 /* Copy digest for the verification */
3048 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3050 /* Copy cipher and auth IVs at the end of the crypto operation */
3051 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3052 ut_params->op, uint8_t *, IV_OFFSET);
3054 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3055 iv_ptr += cipher_iv_len;
3056 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3058 /* Only copy over the offset data needed from src to dst in OOP,
3059 * if the auth and cipher offsets are not aligned
3061 if (op_mode == OUT_OF_PLACE) {
3062 if (cipher_offset > auth_offset)
3064 rte_pktmbuf_mtod_offset(
3066 uint8_t *, auth_offset >> 3),
3067 rte_pktmbuf_mtod_offset(
3069 uint8_t *, auth_offset >> 3),
3070 ((cipher_offset >> 3) - (auth_offset >> 3)));
3073 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3074 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3075 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3076 sym_op->cipher.data.length = cipher_len;
3077 sym_op->cipher.data.offset = cipher_offset;
3079 sym_op->cipher.data.length = cipher_len >> 3;
3080 sym_op->cipher.data.offset = cipher_offset >> 3;
3083 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3084 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3085 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3086 sym_op->auth.data.length = auth_len;
3087 sym_op->auth.data.offset = auth_offset;
3089 sym_op->auth.data.length = auth_len >> 3;
3090 sym_op->auth.data.offset = auth_offset >> 3;
3097 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3099 struct crypto_testsuite_params *ts_params = &testsuite_params;
3100 struct crypto_unittest_params *ut_params = &unittest_params;
3103 unsigned plaintext_pad_len;
3104 unsigned plaintext_len;
3106 struct rte_cryptodev_info dev_info;
3108 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3109 uint64_t feat_flags = dev_info.feature_flags;
3111 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3112 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3113 printf("Device doesn't support NON-Byte Aligned Data.\n");
3114 return TEST_SKIPPED;
3117 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3118 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3119 printf("Device doesn't support RAW data-path APIs.\n");
3120 return TEST_SKIPPED;
3123 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3124 return TEST_SKIPPED;
3126 /* Verify the capabilities */
3127 struct rte_cryptodev_sym_capability_idx cap_idx;
3128 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3129 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3130 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3132 return TEST_SKIPPED;
3134 /* Create SNOW 3G session */
3135 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3136 tdata->key.data, tdata->key.len,
3137 tdata->auth_iv.len, tdata->digest.len,
3138 RTE_CRYPTO_AUTH_OP_GENERATE,
3139 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3143 /* alloc mbuf and set payload */
3144 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3146 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3147 rte_pktmbuf_tailroom(ut_params->ibuf));
3149 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3150 /* Append data which is padded to a multiple of */
3151 /* the algorithms block size */
3152 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3153 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3155 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3157 /* Create SNOW 3G operation */
3158 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3159 tdata->auth_iv.data, tdata->auth_iv.len,
3160 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3161 tdata->validAuthLenInBits.len,
3166 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3167 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3168 ut_params->op, 0, 1, 1, 0);
3170 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3172 ut_params->obuf = ut_params->op->sym->m_src;
3173 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3174 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3175 + plaintext_pad_len;
3178 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3181 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3182 "SNOW 3G Generated auth tag not as expected");
3188 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3190 struct crypto_testsuite_params *ts_params = &testsuite_params;
3191 struct crypto_unittest_params *ut_params = &unittest_params;
3194 unsigned plaintext_pad_len;
3195 unsigned plaintext_len;
3197 struct rte_cryptodev_info dev_info;
3199 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3200 uint64_t feat_flags = dev_info.feature_flags;
3202 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3203 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3204 printf("Device doesn't support NON-Byte Aligned Data.\n");
3205 return TEST_SKIPPED;
3208 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3209 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3210 printf("Device doesn't support RAW data-path APIs.\n");
3211 return TEST_SKIPPED;
3214 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3215 return TEST_SKIPPED;
3217 /* Verify the capabilities */
3218 struct rte_cryptodev_sym_capability_idx cap_idx;
3219 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3220 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3221 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3223 return TEST_SKIPPED;
3225 /* Create SNOW 3G session */
3226 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3227 tdata->key.data, tdata->key.len,
3228 tdata->auth_iv.len, tdata->digest.len,
3229 RTE_CRYPTO_AUTH_OP_VERIFY,
3230 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3233 /* alloc mbuf and set payload */
3234 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3236 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3237 rte_pktmbuf_tailroom(ut_params->ibuf));
3239 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3240 /* Append data which is padded to a multiple of */
3241 /* the algorithms block size */
3242 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3243 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3245 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3247 /* Create SNOW 3G operation */
3248 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3250 tdata->auth_iv.data, tdata->auth_iv.len,
3252 RTE_CRYPTO_AUTH_OP_VERIFY,
3253 tdata->validAuthLenInBits.len,
3258 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3259 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3260 ut_params->op, 0, 1, 1, 0);
3262 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3264 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3265 ut_params->obuf = ut_params->op->sym->m_src;
3266 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3267 + plaintext_pad_len;
3270 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3279 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3281 struct crypto_testsuite_params *ts_params = &testsuite_params;
3282 struct crypto_unittest_params *ut_params = &unittest_params;
3285 unsigned plaintext_pad_len;
3286 unsigned plaintext_len;
3288 struct rte_cryptodev_info dev_info;
3290 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3291 uint64_t feat_flags = dev_info.feature_flags;
3293 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3294 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3295 printf("Device doesn't support RAW data-path APIs.\n");
3296 return TEST_SKIPPED;
3299 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3300 return TEST_SKIPPED;
3302 /* Verify the capabilities */
3303 struct rte_cryptodev_sym_capability_idx cap_idx;
3304 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3305 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3306 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3308 return TEST_SKIPPED;
3310 /* Create KASUMI session */
3311 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3312 tdata->key.data, tdata->key.len,
3313 0, tdata->digest.len,
3314 RTE_CRYPTO_AUTH_OP_GENERATE,
3315 RTE_CRYPTO_AUTH_KASUMI_F9);
3319 /* alloc mbuf and set payload */
3320 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3322 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3323 rte_pktmbuf_tailroom(ut_params->ibuf));
3325 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3326 /* Append data which is padded to a multiple of */
3327 /* the algorithms block size */
3328 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3329 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3331 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3333 /* Create KASUMI operation */
3334 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3336 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3337 tdata->plaintext.len,
3342 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3343 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3345 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3346 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3347 ut_params->op, 0, 1, 1, 0);
3349 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3352 ut_params->obuf = ut_params->op->sym->m_src;
3353 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3354 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3355 + plaintext_pad_len;
3358 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3361 DIGEST_BYTE_LENGTH_KASUMI_F9,
3362 "KASUMI Generated auth tag not as expected");
3368 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3370 struct crypto_testsuite_params *ts_params = &testsuite_params;
3371 struct crypto_unittest_params *ut_params = &unittest_params;
3374 unsigned plaintext_pad_len;
3375 unsigned plaintext_len;
3377 struct rte_cryptodev_info dev_info;
3379 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3380 uint64_t feat_flags = dev_info.feature_flags;
3382 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3383 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3384 printf("Device doesn't support RAW data-path APIs.\n");
3385 return TEST_SKIPPED;
3388 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3389 return TEST_SKIPPED;
3391 /* Verify the capabilities */
3392 struct rte_cryptodev_sym_capability_idx cap_idx;
3393 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3394 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3395 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3397 return TEST_SKIPPED;
3399 /* Create KASUMI session */
3400 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3401 tdata->key.data, tdata->key.len,
3402 0, tdata->digest.len,
3403 RTE_CRYPTO_AUTH_OP_VERIFY,
3404 RTE_CRYPTO_AUTH_KASUMI_F9);
3407 /* alloc mbuf and set payload */
3408 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3410 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3411 rte_pktmbuf_tailroom(ut_params->ibuf));
3413 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3414 /* Append data which is padded to a multiple */
3415 /* of the algorithms block size */
3416 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3417 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3419 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3421 /* Create KASUMI operation */
3422 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3426 RTE_CRYPTO_AUTH_OP_VERIFY,
3427 tdata->plaintext.len,
3432 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3433 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3434 ut_params->op, 0, 1, 1, 0);
3436 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3438 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3439 ut_params->obuf = ut_params->op->sym->m_src;
3440 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3441 + plaintext_pad_len;
3444 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3453 test_snow3g_hash_generate_test_case_1(void)
3455 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3459 test_snow3g_hash_generate_test_case_2(void)
3461 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3465 test_snow3g_hash_generate_test_case_3(void)
3467 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3471 test_snow3g_hash_generate_test_case_4(void)
3473 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3477 test_snow3g_hash_generate_test_case_5(void)
3479 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3483 test_snow3g_hash_generate_test_case_6(void)
3485 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3489 test_snow3g_hash_verify_test_case_1(void)
3491 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3496 test_snow3g_hash_verify_test_case_2(void)
3498 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3502 test_snow3g_hash_verify_test_case_3(void)
3504 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3508 test_snow3g_hash_verify_test_case_4(void)
3510 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3514 test_snow3g_hash_verify_test_case_5(void)
3516 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3520 test_snow3g_hash_verify_test_case_6(void)
3522 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3526 test_kasumi_hash_generate_test_case_1(void)
3528 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3532 test_kasumi_hash_generate_test_case_2(void)
3534 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3538 test_kasumi_hash_generate_test_case_3(void)
3540 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3544 test_kasumi_hash_generate_test_case_4(void)
3546 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3550 test_kasumi_hash_generate_test_case_5(void)
3552 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3556 test_kasumi_hash_generate_test_case_6(void)
3558 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3562 test_kasumi_hash_verify_test_case_1(void)
3564 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3568 test_kasumi_hash_verify_test_case_2(void)
3570 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3574 test_kasumi_hash_verify_test_case_3(void)
3576 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3580 test_kasumi_hash_verify_test_case_4(void)
3582 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3586 test_kasumi_hash_verify_test_case_5(void)
3588 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3592 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3594 struct crypto_testsuite_params *ts_params = &testsuite_params;
3595 struct crypto_unittest_params *ut_params = &unittest_params;
3598 uint8_t *plaintext, *ciphertext;
3599 unsigned plaintext_pad_len;
3600 unsigned plaintext_len;
3601 struct rte_cryptodev_info dev_info;
3603 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3604 uint64_t feat_flags = dev_info.feature_flags;
3606 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3607 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3608 printf("Device doesn't support RAW data-path APIs.\n");
3609 return TEST_SKIPPED;
3612 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3613 return TEST_SKIPPED;
3615 /* Verify the capabilities */
3616 struct rte_cryptodev_sym_capability_idx cap_idx;
3617 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3618 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3619 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3621 return TEST_SKIPPED;
3623 /* Create KASUMI session */
3624 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3625 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3626 RTE_CRYPTO_CIPHER_KASUMI_F8,
3627 tdata->key.data, tdata->key.len,
3628 tdata->cipher_iv.len);
3632 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3634 /* Clear mbuf payload */
3635 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3636 rte_pktmbuf_tailroom(ut_params->ibuf));
3638 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3639 /* Append data which is padded to a multiple */
3640 /* of the algorithms block size */
3641 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3642 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3644 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3646 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3648 /* Create KASUMI operation */
3649 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3650 tdata->cipher_iv.len,
3651 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3652 tdata->validCipherOffsetInBits.len);
3656 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3657 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3658 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3660 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3662 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3664 ut_params->obuf = ut_params->op->sym->m_dst;
3665 if (ut_params->obuf)
3666 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3668 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3670 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3672 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3673 (tdata->validCipherOffsetInBits.len >> 3);
3675 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3677 reference_ciphertext,
3678 tdata->validCipherLenInBits.len,
3679 "KASUMI Ciphertext data not as expected");
3684 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3686 struct crypto_testsuite_params *ts_params = &testsuite_params;
3687 struct crypto_unittest_params *ut_params = &unittest_params;
3691 unsigned int plaintext_pad_len;
3692 unsigned int plaintext_len;
3694 uint8_t buffer[10000];
3695 const uint8_t *ciphertext;
3697 struct rte_cryptodev_info dev_info;
3699 /* Verify the capabilities */
3700 struct rte_cryptodev_sym_capability_idx cap_idx;
3701 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3702 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3703 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3705 return TEST_SKIPPED;
3707 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3709 uint64_t feat_flags = dev_info.feature_flags;
3711 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3712 printf("Device doesn't support in-place scatter-gather. "
3714 return TEST_SKIPPED;
3717 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3718 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3719 printf("Device doesn't support RAW data-path APIs.\n");
3720 return TEST_SKIPPED;
3723 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3724 return TEST_SKIPPED;
3726 /* Create KASUMI session */
3727 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3728 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3729 RTE_CRYPTO_CIPHER_KASUMI_F8,
3730 tdata->key.data, tdata->key.len,
3731 tdata->cipher_iv.len);
3735 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3738 /* Append data which is padded to a multiple */
3739 /* of the algorithms block size */
3740 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3742 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3743 plaintext_pad_len, 10, 0);
3745 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3747 /* Create KASUMI operation */
3748 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3749 tdata->cipher_iv.len,
3750 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3751 tdata->validCipherOffsetInBits.len);
3755 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3756 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3757 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3759 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3761 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3763 ut_params->obuf = ut_params->op->sym->m_dst;
3765 if (ut_params->obuf)
3766 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3767 plaintext_len, buffer);
3769 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3770 tdata->validCipherOffsetInBits.len >> 3,
3771 plaintext_len, buffer);
3774 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3776 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3777 (tdata->validCipherOffsetInBits.len >> 3);
3779 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3781 reference_ciphertext,
3782 tdata->validCipherLenInBits.len,
3783 "KASUMI Ciphertext data not as expected");
3788 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3790 struct crypto_testsuite_params *ts_params = &testsuite_params;
3791 struct crypto_unittest_params *ut_params = &unittest_params;
3794 uint8_t *plaintext, *ciphertext;
3795 unsigned plaintext_pad_len;
3796 unsigned plaintext_len;
3798 /* Verify the capabilities */
3799 struct rte_cryptodev_sym_capability_idx cap_idx;
3800 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3801 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3802 /* Data-path service does not support OOP */
3803 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3805 return TEST_SKIPPED;
3807 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3808 return TEST_SKIPPED;
3810 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3811 return TEST_SKIPPED;
3813 /* Create KASUMI session */
3814 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3815 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3816 RTE_CRYPTO_CIPHER_KASUMI_F8,
3817 tdata->key.data, tdata->key.len,
3818 tdata->cipher_iv.len);
3822 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3823 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3825 /* Clear mbuf payload */
3826 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3827 rte_pktmbuf_tailroom(ut_params->ibuf));
3829 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3830 /* Append data which is padded to a multiple */
3831 /* of the algorithms block size */
3832 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3833 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3835 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3836 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3838 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3840 /* Create KASUMI operation */
3841 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3842 tdata->cipher_iv.len,
3843 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3844 tdata->validCipherOffsetInBits.len);
3848 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3850 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3852 ut_params->obuf = ut_params->op->sym->m_dst;
3853 if (ut_params->obuf)
3854 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3856 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3858 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3860 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3861 (tdata->validCipherOffsetInBits.len >> 3);
3863 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3865 reference_ciphertext,
3866 tdata->validCipherLenInBits.len,
3867 "KASUMI Ciphertext data not as expected");
3872 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3874 struct crypto_testsuite_params *ts_params = &testsuite_params;
3875 struct crypto_unittest_params *ut_params = &unittest_params;
3878 unsigned int plaintext_pad_len;
3879 unsigned int plaintext_len;
3881 const uint8_t *ciphertext;
3882 uint8_t buffer[2048];
3884 struct rte_cryptodev_info dev_info;
3886 /* Verify the capabilities */
3887 struct rte_cryptodev_sym_capability_idx cap_idx;
3888 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3889 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3890 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3892 return TEST_SKIPPED;
3894 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3895 return TEST_SKIPPED;
3897 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3898 return TEST_SKIPPED;
3900 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3902 uint64_t feat_flags = dev_info.feature_flags;
3903 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3904 printf("Device doesn't support out-of-place scatter-gather "
3905 "in both input and output mbufs. "
3907 return TEST_SKIPPED;
3910 /* Create KASUMI session */
3911 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3912 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3913 RTE_CRYPTO_CIPHER_KASUMI_F8,
3914 tdata->key.data, tdata->key.len,
3915 tdata->cipher_iv.len);
3919 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3920 /* Append data which is padded to a multiple */
3921 /* of the algorithms block size */
3922 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3924 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3925 plaintext_pad_len, 10, 0);
3926 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3927 plaintext_pad_len, 3, 0);
3929 /* Append data which is padded to a multiple */
3930 /* of the algorithms block size */
3931 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3933 /* Create KASUMI operation */
3934 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3935 tdata->cipher_iv.len,
3936 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3937 tdata->validCipherOffsetInBits.len);
3941 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3943 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3945 ut_params->obuf = ut_params->op->sym->m_dst;
3946 if (ut_params->obuf)
3947 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3948 plaintext_pad_len, buffer);
3950 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3951 tdata->validCipherOffsetInBits.len >> 3,
3952 plaintext_pad_len, buffer);
3954 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3955 (tdata->validCipherOffsetInBits.len >> 3);
3957 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3959 reference_ciphertext,
3960 tdata->validCipherLenInBits.len,
3961 "KASUMI Ciphertext data not as expected");
3967 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3969 struct crypto_testsuite_params *ts_params = &testsuite_params;
3970 struct crypto_unittest_params *ut_params = &unittest_params;
3973 uint8_t *ciphertext, *plaintext;
3974 unsigned ciphertext_pad_len;
3975 unsigned ciphertext_len;
3977 /* Verify the capabilities */
3978 struct rte_cryptodev_sym_capability_idx cap_idx;
3979 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3980 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3981 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3983 return TEST_SKIPPED;
3985 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3986 return TEST_SKIPPED;
3988 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3989 return TEST_SKIPPED;
3991 /* Create KASUMI session */
3992 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3993 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3994 RTE_CRYPTO_CIPHER_KASUMI_F8,
3995 tdata->key.data, tdata->key.len,
3996 tdata->cipher_iv.len);
4000 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4001 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4003 /* Clear mbuf payload */
4004 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4005 rte_pktmbuf_tailroom(ut_params->ibuf));
4007 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4008 /* Append data which is padded to a multiple */
4009 /* of the algorithms block size */
4010 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4011 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4012 ciphertext_pad_len);
4013 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4014 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4016 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4018 /* Create KASUMI operation */
4019 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4020 tdata->cipher_iv.len,
4021 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4022 tdata->validCipherOffsetInBits.len);
4026 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4028 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4030 ut_params->obuf = ut_params->op->sym->m_dst;
4031 if (ut_params->obuf)
4032 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4034 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4036 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4038 const uint8_t *reference_plaintext = tdata->plaintext.data +
4039 (tdata->validCipherOffsetInBits.len >> 3);
4041 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4043 reference_plaintext,
4044 tdata->validCipherLenInBits.len,
4045 "KASUMI Plaintext data not as expected");
4050 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4052 struct crypto_testsuite_params *ts_params = &testsuite_params;
4053 struct crypto_unittest_params *ut_params = &unittest_params;
4056 uint8_t *ciphertext, *plaintext;
4057 unsigned ciphertext_pad_len;
4058 unsigned ciphertext_len;
4059 struct rte_cryptodev_info dev_info;
4061 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4062 uint64_t feat_flags = dev_info.feature_flags;
4064 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4065 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4066 printf("Device doesn't support RAW data-path APIs.\n");
4067 return TEST_SKIPPED;
4070 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4071 return TEST_SKIPPED;
4073 /* Verify the capabilities */
4074 struct rte_cryptodev_sym_capability_idx cap_idx;
4075 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4076 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4077 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4079 return TEST_SKIPPED;
4081 /* Create KASUMI session */
4082 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4083 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4084 RTE_CRYPTO_CIPHER_KASUMI_F8,
4085 tdata->key.data, tdata->key.len,
4086 tdata->cipher_iv.len);
4090 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4092 /* Clear mbuf payload */
4093 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4094 rte_pktmbuf_tailroom(ut_params->ibuf));
4096 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4097 /* Append data which is padded to a multiple */
4098 /* of the algorithms block size */
4099 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4100 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4101 ciphertext_pad_len);
4102 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4104 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4106 /* Create KASUMI operation */
4107 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4108 tdata->cipher_iv.len,
4109 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4110 tdata->validCipherOffsetInBits.len);
4114 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4115 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4116 ut_params->op, 1, 0, 1, 0);
4118 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4120 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4122 ut_params->obuf = ut_params->op->sym->m_dst;
4123 if (ut_params->obuf)
4124 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4126 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4128 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4130 const uint8_t *reference_plaintext = tdata->plaintext.data +
4131 (tdata->validCipherOffsetInBits.len >> 3);
4133 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4135 reference_plaintext,
4136 tdata->validCipherLenInBits.len,
4137 "KASUMI Plaintext data not as expected");
4142 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4144 struct crypto_testsuite_params *ts_params = &testsuite_params;
4145 struct crypto_unittest_params *ut_params = &unittest_params;
4148 uint8_t *plaintext, *ciphertext;
4149 unsigned plaintext_pad_len;
4150 unsigned plaintext_len;
4151 struct rte_cryptodev_info dev_info;
4153 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4154 uint64_t feat_flags = dev_info.feature_flags;
4156 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4157 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4158 printf("Device doesn't support RAW data-path APIs.\n");
4159 return TEST_SKIPPED;
4162 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4163 return TEST_SKIPPED;
4165 /* Verify the capabilities */
4166 struct rte_cryptodev_sym_capability_idx cap_idx;
4167 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4168 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4169 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4171 return TEST_SKIPPED;
4173 /* Create SNOW 3G session */
4174 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4175 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4176 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4177 tdata->key.data, tdata->key.len,
4178 tdata->cipher_iv.len);
4182 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4184 /* Clear mbuf payload */
4185 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4186 rte_pktmbuf_tailroom(ut_params->ibuf));
4188 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4189 /* Append data which is padded to a multiple of */
4190 /* the algorithms block size */
4191 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4192 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4194 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4196 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4198 /* Create SNOW 3G operation */
4199 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4200 tdata->cipher_iv.len,
4201 tdata->validCipherLenInBits.len,
4206 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4207 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4208 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4210 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4212 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4214 ut_params->obuf = ut_params->op->sym->m_dst;
4215 if (ut_params->obuf)
4216 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4218 ciphertext = plaintext;
4220 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4223 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4225 tdata->ciphertext.data,
4226 tdata->validDataLenInBits.len,
4227 "SNOW 3G Ciphertext data not as expected");
4233 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4235 struct crypto_testsuite_params *ts_params = &testsuite_params;
4236 struct crypto_unittest_params *ut_params = &unittest_params;
4237 uint8_t *plaintext, *ciphertext;
4240 unsigned plaintext_pad_len;
4241 unsigned plaintext_len;
4242 struct rte_cryptodev_info dev_info;
4244 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4245 uint64_t feat_flags = dev_info.feature_flags;
4247 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4248 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4249 printf("Device does not support RAW data-path APIs.\n");
4253 /* Verify the capabilities */
4254 struct rte_cryptodev_sym_capability_idx cap_idx;
4255 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4256 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4257 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4259 return TEST_SKIPPED;
4261 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4262 return TEST_SKIPPED;
4264 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4265 return TEST_SKIPPED;
4267 /* Create SNOW 3G session */
4268 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4269 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4270 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4271 tdata->key.data, tdata->key.len,
4272 tdata->cipher_iv.len);
4276 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4277 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4279 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4280 "Failed to allocate input buffer in mempool");
4281 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4282 "Failed to allocate output buffer in mempool");
4284 /* Clear mbuf payload */
4285 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4286 rte_pktmbuf_tailroom(ut_params->ibuf));
4288 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4289 /* Append data which is padded to a multiple of */
4290 /* the algorithms block size */
4291 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4292 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4294 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4295 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4297 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4299 /* Create SNOW 3G operation */
4300 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4301 tdata->cipher_iv.len,
4302 tdata->validCipherLenInBits.len,
4307 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4308 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4309 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4311 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4313 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4315 ut_params->obuf = ut_params->op->sym->m_dst;
4316 if (ut_params->obuf)
4317 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4319 ciphertext = plaintext;
4321 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4324 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4326 tdata->ciphertext.data,
4327 tdata->validDataLenInBits.len,
4328 "SNOW 3G Ciphertext data not as expected");
4333 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4335 struct crypto_testsuite_params *ts_params = &testsuite_params;
4336 struct crypto_unittest_params *ut_params = &unittest_params;
4339 unsigned int plaintext_pad_len;
4340 unsigned int plaintext_len;
4341 uint8_t buffer[10000];
4342 const uint8_t *ciphertext;
4344 struct rte_cryptodev_info dev_info;
4346 /* Verify the capabilities */
4347 struct rte_cryptodev_sym_capability_idx cap_idx;
4348 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4349 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4350 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4352 return TEST_SKIPPED;
4354 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4355 return TEST_SKIPPED;
4357 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4358 return TEST_SKIPPED;
4360 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4362 uint64_t feat_flags = dev_info.feature_flags;
4364 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4365 printf("Device doesn't support out-of-place scatter-gather "
4366 "in both input and output mbufs. "
4368 return TEST_SKIPPED;
4371 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4372 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4373 printf("Device does not support RAW data-path APIs.\n");
4377 /* Create SNOW 3G session */
4378 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4379 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4380 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4381 tdata->key.data, tdata->key.len,
4382 tdata->cipher_iv.len);
4386 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4387 /* Append data which is padded to a multiple of */
4388 /* the algorithms block size */
4389 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4391 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4392 plaintext_pad_len, 10, 0);
4393 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4394 plaintext_pad_len, 3, 0);
4396 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4397 "Failed to allocate input buffer in mempool");
4398 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4399 "Failed to allocate output buffer in mempool");
4401 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4403 /* Create SNOW 3G operation */
4404 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4405 tdata->cipher_iv.len,
4406 tdata->validCipherLenInBits.len,
4411 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4412 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4413 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4415 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4417 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4419 ut_params->obuf = ut_params->op->sym->m_dst;
4420 if (ut_params->obuf)
4421 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4422 plaintext_len, buffer);
4424 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4425 plaintext_len, buffer);
4427 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4430 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4432 tdata->ciphertext.data,
4433 tdata->validDataLenInBits.len,
4434 "SNOW 3G Ciphertext data not as expected");
4439 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4441 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4443 uint8_t curr_byte, prev_byte;
4444 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4445 uint8_t lower_byte_mask = (1 << offset) - 1;
4448 prev_byte = buffer[0];
4449 buffer[0] >>= offset;
4451 for (i = 1; i < length_in_bytes; i++) {
4452 curr_byte = buffer[i];
4453 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4454 (curr_byte >> offset);
4455 prev_byte = curr_byte;
4460 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4462 struct crypto_testsuite_params *ts_params = &testsuite_params;
4463 struct crypto_unittest_params *ut_params = &unittest_params;
4464 uint8_t *plaintext, *ciphertext;
4466 uint32_t plaintext_len;
4467 uint32_t plaintext_pad_len;
4468 uint8_t extra_offset = 4;
4469 uint8_t *expected_ciphertext_shifted;
4470 struct rte_cryptodev_info dev_info;
4472 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4473 uint64_t feat_flags = dev_info.feature_flags;
4475 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4476 ((tdata->validDataLenInBits.len % 8) != 0)) {
4477 printf("Device doesn't support NON-Byte Aligned Data.\n");
4478 return TEST_SKIPPED;
4481 /* Verify the capabilities */
4482 struct rte_cryptodev_sym_capability_idx cap_idx;
4483 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4484 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4485 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4487 return TEST_SKIPPED;
4489 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4490 return TEST_SKIPPED;
4492 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4493 return TEST_SKIPPED;
4495 /* Create SNOW 3G session */
4496 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4497 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4498 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4499 tdata->key.data, tdata->key.len,
4500 tdata->cipher_iv.len);
4504 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4505 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4507 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4508 "Failed to allocate input buffer in mempool");
4509 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4510 "Failed to allocate output buffer in mempool");
4512 /* Clear mbuf payload */
4513 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4514 rte_pktmbuf_tailroom(ut_params->ibuf));
4516 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4518 * Append data which is padded to a
4519 * multiple of the algorithms block size
4521 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4523 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4526 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4528 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4529 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4531 #ifdef RTE_APP_TEST_DEBUG
4532 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4534 /* Create SNOW 3G operation */
4535 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4536 tdata->cipher_iv.len,
4537 tdata->validCipherLenInBits.len,
4542 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4543 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4544 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4546 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4548 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4550 ut_params->obuf = ut_params->op->sym->m_dst;
4551 if (ut_params->obuf)
4552 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4554 ciphertext = plaintext;
4556 #ifdef RTE_APP_TEST_DEBUG
4557 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4560 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4562 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4563 "failed to reserve memory for ciphertext shifted\n");
4565 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4566 ceil_byte_length(tdata->ciphertext.len));
4567 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4570 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4572 expected_ciphertext_shifted,
4573 tdata->validDataLenInBits.len,
4575 "SNOW 3G Ciphertext data not as expected");
4579 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4581 struct crypto_testsuite_params *ts_params = &testsuite_params;
4582 struct crypto_unittest_params *ut_params = &unittest_params;
4586 uint8_t *plaintext, *ciphertext;
4587 unsigned ciphertext_pad_len;
4588 unsigned ciphertext_len;
4589 struct rte_cryptodev_info dev_info;
4591 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4592 uint64_t feat_flags = dev_info.feature_flags;
4594 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4595 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4596 printf("Device doesn't support RAW data-path APIs.\n");
4597 return TEST_SKIPPED;
4600 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4601 return TEST_SKIPPED;
4603 /* Verify the capabilities */
4604 struct rte_cryptodev_sym_capability_idx cap_idx;
4605 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4606 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4607 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4609 return TEST_SKIPPED;
4611 /* Create SNOW 3G session */
4612 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4613 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4614 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4615 tdata->key.data, tdata->key.len,
4616 tdata->cipher_iv.len);
4620 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4622 /* Clear mbuf payload */
4623 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4624 rte_pktmbuf_tailroom(ut_params->ibuf));
4626 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4627 /* Append data which is padded to a multiple of */
4628 /* the algorithms block size */
4629 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4630 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4631 ciphertext_pad_len);
4632 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4634 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4636 /* Create SNOW 3G operation */
4637 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4638 tdata->cipher_iv.len,
4639 tdata->validCipherLenInBits.len,
4640 tdata->cipher.offset_bits);
4644 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4645 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4646 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4648 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4650 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4651 ut_params->obuf = ut_params->op->sym->m_dst;
4652 if (ut_params->obuf)
4653 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4655 plaintext = ciphertext;
4657 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4660 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4661 tdata->plaintext.data,
4662 tdata->validDataLenInBits.len,
4663 "SNOW 3G Plaintext data not as expected");
4667 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4669 struct crypto_testsuite_params *ts_params = &testsuite_params;
4670 struct crypto_unittest_params *ut_params = &unittest_params;
4674 uint8_t *plaintext, *ciphertext;
4675 unsigned ciphertext_pad_len;
4676 unsigned ciphertext_len;
4677 struct rte_cryptodev_info dev_info;
4679 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4680 uint64_t feat_flags = dev_info.feature_flags;
4682 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4683 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4684 printf("Device does not support RAW data-path APIs.\n");
4687 /* Verify the capabilities */
4688 struct rte_cryptodev_sym_capability_idx cap_idx;
4689 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4690 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4691 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4693 return TEST_SKIPPED;
4695 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4696 return TEST_SKIPPED;
4698 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4699 return TEST_SKIPPED;
4701 /* Create SNOW 3G session */
4702 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4703 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4704 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4705 tdata->key.data, tdata->key.len,
4706 tdata->cipher_iv.len);
4710 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4711 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4713 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4714 "Failed to allocate input buffer");
4715 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4716 "Failed to allocate output buffer");
4718 /* Clear mbuf payload */
4719 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4720 rte_pktmbuf_tailroom(ut_params->ibuf));
4722 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4723 rte_pktmbuf_tailroom(ut_params->obuf));
4725 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4726 /* Append data which is padded to a multiple of */
4727 /* the algorithms block size */
4728 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4729 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4730 ciphertext_pad_len);
4731 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4732 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4734 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4736 /* Create SNOW 3G operation */
4737 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4738 tdata->cipher_iv.len,
4739 tdata->validCipherLenInBits.len,
4744 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4745 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4746 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4748 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4750 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4751 ut_params->obuf = ut_params->op->sym->m_dst;
4752 if (ut_params->obuf)
4753 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4755 plaintext = ciphertext;
4757 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4760 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4761 tdata->plaintext.data,
4762 tdata->validDataLenInBits.len,
4763 "SNOW 3G Plaintext data not as expected");
4768 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4770 struct crypto_testsuite_params *ts_params = &testsuite_params;
4771 struct crypto_unittest_params *ut_params = &unittest_params;
4775 uint8_t *plaintext, *ciphertext;
4776 unsigned int plaintext_pad_len;
4777 unsigned int plaintext_len;
4779 struct rte_cryptodev_info dev_info;
4780 struct rte_cryptodev_sym_capability_idx cap_idx;
4782 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4783 uint64_t feat_flags = dev_info.feature_flags;
4785 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4786 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4787 (tdata->validDataLenInBits.len % 8 != 0))) {
4788 printf("Device doesn't support NON-Byte Aligned Data.\n");
4789 return TEST_SKIPPED;
4792 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4793 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4794 printf("Device doesn't support RAW data-path APIs.\n");
4795 return TEST_SKIPPED;
4798 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4799 return TEST_SKIPPED;
4801 /* Check if device supports ZUC EEA3 */
4802 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4803 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4805 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4807 return TEST_SKIPPED;
4809 /* Check if device supports ZUC EIA3 */
4810 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4811 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4813 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4815 return TEST_SKIPPED;
4817 /* Create ZUC session */
4818 retval = create_zuc_cipher_auth_encrypt_generate_session(
4819 ts_params->valid_devs[0],
4823 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4825 /* clear mbuf payload */
4826 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4827 rte_pktmbuf_tailroom(ut_params->ibuf));
4829 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4830 /* Append data which is padded to a multiple of */
4831 /* the algorithms block size */
4832 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4833 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4835 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4837 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4839 /* Create ZUC operation */
4840 retval = create_zuc_cipher_hash_generate_operation(tdata);
4844 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4845 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4846 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4848 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4850 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4851 ut_params->obuf = ut_params->op->sym->m_src;
4852 if (ut_params->obuf)
4853 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4855 ciphertext = plaintext;
4857 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4859 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4861 tdata->ciphertext.data,
4862 tdata->validDataLenInBits.len,
4863 "ZUC Ciphertext data not as expected");
4865 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4866 + plaintext_pad_len;
4869 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4873 "ZUC Generated auth tag not as expected");
4878 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4880 struct crypto_testsuite_params *ts_params = &testsuite_params;
4881 struct crypto_unittest_params *ut_params = &unittest_params;
4885 uint8_t *plaintext, *ciphertext;
4886 unsigned plaintext_pad_len;
4887 unsigned plaintext_len;
4888 struct rte_cryptodev_info dev_info;
4890 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4891 uint64_t feat_flags = dev_info.feature_flags;
4893 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4894 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4895 printf("Device doesn't support RAW data-path APIs.\n");
4896 return TEST_SKIPPED;
4899 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4900 return TEST_SKIPPED;
4902 /* Verify the capabilities */
4903 struct rte_cryptodev_sym_capability_idx cap_idx;
4904 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4905 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4906 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4908 return TEST_SKIPPED;
4909 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4910 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4911 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4913 return TEST_SKIPPED;
4915 /* Create SNOW 3G session */
4916 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4917 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4918 RTE_CRYPTO_AUTH_OP_GENERATE,
4919 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4920 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4921 tdata->key.data, tdata->key.len,
4922 tdata->auth_iv.len, tdata->digest.len,
4923 tdata->cipher_iv.len);
4926 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4928 /* clear mbuf payload */
4929 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4930 rte_pktmbuf_tailroom(ut_params->ibuf));
4932 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4933 /* Append data which is padded to a multiple of */
4934 /* the algorithms block size */
4935 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4936 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4938 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4940 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4942 /* Create SNOW 3G operation */
4943 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4944 tdata->digest.len, tdata->auth_iv.data,
4946 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4947 tdata->cipher_iv.data, tdata->cipher_iv.len,
4948 tdata->validCipherLenInBits.len,
4950 tdata->validAuthLenInBits.len,
4956 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4957 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4958 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4960 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4962 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4963 ut_params->obuf = ut_params->op->sym->m_src;
4964 if (ut_params->obuf)
4965 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4967 ciphertext = plaintext;
4969 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4971 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4973 tdata->ciphertext.data,
4974 tdata->validDataLenInBits.len,
4975 "SNOW 3G Ciphertext data not as expected");
4977 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4978 + plaintext_pad_len;
4981 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4984 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4985 "SNOW 3G Generated auth tag not as expected");
4990 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4991 uint8_t op_mode, uint8_t verify)
4993 struct crypto_testsuite_params *ts_params = &testsuite_params;
4994 struct crypto_unittest_params *ut_params = &unittest_params;
4998 uint8_t *plaintext = NULL, *ciphertext = NULL;
4999 unsigned int plaintext_pad_len;
5000 unsigned int plaintext_len;
5001 unsigned int ciphertext_pad_len;
5002 unsigned int ciphertext_len;
5004 struct rte_cryptodev_info dev_info;
5006 /* Verify the capabilities */
5007 struct rte_cryptodev_sym_capability_idx cap_idx;
5008 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5009 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5010 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5012 return TEST_SKIPPED;
5013 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5014 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5015 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5017 return TEST_SKIPPED;
5019 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5020 return TEST_SKIPPED;
5022 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5024 uint64_t feat_flags = dev_info.feature_flags;
5026 if (op_mode == OUT_OF_PLACE) {
5027 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5028 printf("Device doesn't support digest encrypted.\n");
5029 return TEST_SKIPPED;
5031 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5032 return TEST_SKIPPED;
5035 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5036 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5037 printf("Device doesn't support RAW data-path APIs.\n");
5038 return TEST_SKIPPED;
5041 /* Create SNOW 3G session */
5042 retval = create_wireless_algo_auth_cipher_session(
5043 ts_params->valid_devs[0],
5044 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5045 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5046 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5047 : RTE_CRYPTO_AUTH_OP_GENERATE),
5048 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5049 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5050 tdata->key.data, tdata->key.len,
5051 tdata->auth_iv.len, tdata->digest.len,
5052 tdata->cipher_iv.len);
5056 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5057 if (op_mode == OUT_OF_PLACE)
5058 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5060 /* clear mbuf payload */
5061 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5062 rte_pktmbuf_tailroom(ut_params->ibuf));
5063 if (op_mode == OUT_OF_PLACE)
5064 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5065 rte_pktmbuf_tailroom(ut_params->obuf));
5067 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5068 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5069 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5070 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5073 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5074 ciphertext_pad_len);
5075 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5076 if (op_mode == OUT_OF_PLACE)
5077 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5078 debug_hexdump(stdout, "ciphertext:", ciphertext,
5081 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5083 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5084 if (op_mode == OUT_OF_PLACE)
5085 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5086 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5089 /* Create SNOW 3G operation */
5090 retval = create_wireless_algo_auth_cipher_operation(
5091 tdata->digest.data, tdata->digest.len,
5092 tdata->cipher_iv.data, tdata->cipher_iv.len,
5093 tdata->auth_iv.data, tdata->auth_iv.len,
5094 (tdata->digest.offset_bytes == 0 ?
5095 (verify ? ciphertext_pad_len : plaintext_pad_len)
5096 : tdata->digest.offset_bytes),
5097 tdata->validCipherLenInBits.len,
5098 tdata->cipher.offset_bits,
5099 tdata->validAuthLenInBits.len,
5100 tdata->auth.offset_bits,
5101 op_mode, 0, verify);
5106 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5107 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5108 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5110 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5113 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5115 ut_params->obuf = (op_mode == IN_PLACE ?
5116 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5119 if (ut_params->obuf)
5120 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5123 plaintext = ciphertext +
5124 (tdata->cipher.offset_bits >> 3);
5126 debug_hexdump(stdout, "plaintext:", plaintext,
5127 (tdata->plaintext.len >> 3) - tdata->digest.len);
5128 debug_hexdump(stdout, "plaintext expected:",
5129 tdata->plaintext.data,
5130 (tdata->plaintext.len >> 3) - tdata->digest.len);
5132 if (ut_params->obuf)
5133 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5136 ciphertext = plaintext;
5138 debug_hexdump(stdout, "ciphertext:", ciphertext,
5140 debug_hexdump(stdout, "ciphertext expected:",
5141 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5143 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5144 + (tdata->digest.offset_bytes == 0 ?
5145 plaintext_pad_len : tdata->digest.offset_bytes);
5147 debug_hexdump(stdout, "digest:", ut_params->digest,
5149 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5155 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5157 tdata->plaintext.data,
5158 (tdata->plaintext.len - tdata->cipher.offset_bits -
5159 (tdata->digest.len << 3)),
5160 tdata->cipher.offset_bits,
5161 "SNOW 3G Plaintext data not as expected");
5163 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5165 tdata->ciphertext.data,
5166 (tdata->validDataLenInBits.len -
5167 tdata->cipher.offset_bits),
5168 tdata->cipher.offset_bits,
5169 "SNOW 3G Ciphertext data not as expected");
5171 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5174 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5175 "SNOW 3G Generated auth tag not as expected");
5181 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5182 uint8_t op_mode, uint8_t verify)
5184 struct crypto_testsuite_params *ts_params = &testsuite_params;
5185 struct crypto_unittest_params *ut_params = &unittest_params;
5189 const uint8_t *plaintext = NULL;
5190 const uint8_t *ciphertext = NULL;
5191 const uint8_t *digest = NULL;
5192 unsigned int plaintext_pad_len;
5193 unsigned int plaintext_len;
5194 unsigned int ciphertext_pad_len;
5195 unsigned int ciphertext_len;
5196 uint8_t buffer[10000];
5197 uint8_t digest_buffer[10000];
5199 struct rte_cryptodev_info dev_info;
5201 /* Verify the capabilities */
5202 struct rte_cryptodev_sym_capability_idx cap_idx;
5203 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5204 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5205 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5207 return TEST_SKIPPED;
5208 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5209 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5210 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5212 return TEST_SKIPPED;
5214 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5215 return TEST_SKIPPED;
5217 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5219 uint64_t feat_flags = dev_info.feature_flags;
5221 if (op_mode == IN_PLACE) {
5222 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5223 printf("Device doesn't support in-place scatter-gather "
5224 "in both input and output mbufs.\n");
5225 return TEST_SKIPPED;
5227 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5228 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5229 printf("Device doesn't support RAW data-path APIs.\n");
5230 return TEST_SKIPPED;
5233 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5234 return TEST_SKIPPED;
5235 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5236 printf("Device doesn't support out-of-place scatter-gather "
5237 "in both input and output mbufs.\n");
5238 return TEST_SKIPPED;
5240 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5241 printf("Device doesn't support digest encrypted.\n");
5242 return TEST_SKIPPED;
5246 /* Create SNOW 3G session */
5247 retval = create_wireless_algo_auth_cipher_session(
5248 ts_params->valid_devs[0],
5249 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5250 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5251 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5252 : RTE_CRYPTO_AUTH_OP_GENERATE),
5253 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5254 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5255 tdata->key.data, tdata->key.len,
5256 tdata->auth_iv.len, tdata->digest.len,
5257 tdata->cipher_iv.len);
5262 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5263 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5264 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5265 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5267 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5268 plaintext_pad_len, 15, 0);
5269 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5270 "Failed to allocate input buffer in mempool");
5272 if (op_mode == OUT_OF_PLACE) {
5273 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5274 plaintext_pad_len, 15, 0);
5275 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5276 "Failed to allocate output buffer in mempool");
5280 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5281 tdata->ciphertext.data);
5282 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5283 ciphertext_len, buffer);
5284 debug_hexdump(stdout, "ciphertext:", ciphertext,
5287 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5288 tdata->plaintext.data);
5289 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5290 plaintext_len, buffer);
5291 debug_hexdump(stdout, "plaintext:", plaintext,
5294 memset(buffer, 0, sizeof(buffer));
5296 /* Create SNOW 3G operation */
5297 retval = create_wireless_algo_auth_cipher_operation(
5298 tdata->digest.data, tdata->digest.len,
5299 tdata->cipher_iv.data, tdata->cipher_iv.len,
5300 tdata->auth_iv.data, tdata->auth_iv.len,
5301 (tdata->digest.offset_bytes == 0 ?
5302 (verify ? ciphertext_pad_len : plaintext_pad_len)
5303 : tdata->digest.offset_bytes),
5304 tdata->validCipherLenInBits.len,
5305 tdata->cipher.offset_bits,
5306 tdata->validAuthLenInBits.len,
5307 tdata->auth.offset_bits,
5308 op_mode, 1, verify);
5313 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5314 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5315 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5317 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5320 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5322 ut_params->obuf = (op_mode == IN_PLACE ?
5323 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5326 if (ut_params->obuf)
5327 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5328 plaintext_len, buffer);
5330 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5331 plaintext_len, buffer);
5333 debug_hexdump(stdout, "plaintext:", plaintext,
5334 (tdata->plaintext.len >> 3) - tdata->digest.len);
5335 debug_hexdump(stdout, "plaintext expected:",
5336 tdata->plaintext.data,
5337 (tdata->plaintext.len >> 3) - tdata->digest.len);
5339 if (ut_params->obuf)
5340 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5341 ciphertext_len, buffer);
5343 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5344 ciphertext_len, buffer);
5346 debug_hexdump(stdout, "ciphertext:", ciphertext,
5348 debug_hexdump(stdout, "ciphertext expected:",
5349 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5351 if (ut_params->obuf)
5352 digest = rte_pktmbuf_read(ut_params->obuf,
5353 (tdata->digest.offset_bytes == 0 ?
5354 plaintext_pad_len : tdata->digest.offset_bytes),
5355 tdata->digest.len, digest_buffer);
5357 digest = rte_pktmbuf_read(ut_params->ibuf,
5358 (tdata->digest.offset_bytes == 0 ?
5359 plaintext_pad_len : tdata->digest.offset_bytes),
5360 tdata->digest.len, digest_buffer);
5362 debug_hexdump(stdout, "digest:", digest,
5364 debug_hexdump(stdout, "digest expected:",
5365 tdata->digest.data, tdata->digest.len);
5370 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5372 tdata->plaintext.data,
5373 (tdata->plaintext.len - tdata->cipher.offset_bits -
5374 (tdata->digest.len << 3)),
5375 tdata->cipher.offset_bits,
5376 "SNOW 3G Plaintext data not as expected");
5378 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5380 tdata->ciphertext.data,
5381 (tdata->validDataLenInBits.len -
5382 tdata->cipher.offset_bits),
5383 tdata->cipher.offset_bits,
5384 "SNOW 3G Ciphertext data not as expected");
5386 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5389 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5390 "SNOW 3G Generated auth tag not as expected");
5396 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5397 uint8_t op_mode, uint8_t verify)
5399 struct crypto_testsuite_params *ts_params = &testsuite_params;
5400 struct crypto_unittest_params *ut_params = &unittest_params;
5404 uint8_t *plaintext = NULL, *ciphertext = NULL;
5405 unsigned int plaintext_pad_len;
5406 unsigned int plaintext_len;
5407 unsigned int ciphertext_pad_len;
5408 unsigned int ciphertext_len;
5410 struct rte_cryptodev_info dev_info;
5412 /* Verify the capabilities */
5413 struct rte_cryptodev_sym_capability_idx cap_idx;
5414 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5415 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5416 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5418 return TEST_SKIPPED;
5419 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5420 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5421 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5423 return TEST_SKIPPED;
5425 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5427 uint64_t feat_flags = dev_info.feature_flags;
5429 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5430 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5431 printf("Device doesn't support RAW data-path APIs.\n");
5432 return TEST_SKIPPED;
5435 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5436 return TEST_SKIPPED;
5438 if (op_mode == OUT_OF_PLACE) {
5439 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5440 return TEST_SKIPPED;
5441 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5442 printf("Device doesn't support digest encrypted.\n");
5443 return TEST_SKIPPED;
5447 /* Create KASUMI session */
5448 retval = create_wireless_algo_auth_cipher_session(
5449 ts_params->valid_devs[0],
5450 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5451 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5452 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5453 : RTE_CRYPTO_AUTH_OP_GENERATE),
5454 RTE_CRYPTO_AUTH_KASUMI_F9,
5455 RTE_CRYPTO_CIPHER_KASUMI_F8,
5456 tdata->key.data, tdata->key.len,
5457 0, tdata->digest.len,
5458 tdata->cipher_iv.len);
5463 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5464 if (op_mode == OUT_OF_PLACE)
5465 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5467 /* clear mbuf payload */
5468 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5469 rte_pktmbuf_tailroom(ut_params->ibuf));
5470 if (op_mode == OUT_OF_PLACE)
5471 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5472 rte_pktmbuf_tailroom(ut_params->obuf));
5474 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5475 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5476 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5477 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5480 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5481 ciphertext_pad_len);
5482 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5483 if (op_mode == OUT_OF_PLACE)
5484 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5485 debug_hexdump(stdout, "ciphertext:", ciphertext,
5488 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5490 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5491 if (op_mode == OUT_OF_PLACE)
5492 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5493 debug_hexdump(stdout, "plaintext:", plaintext,
5497 /* Create KASUMI operation */
5498 retval = create_wireless_algo_auth_cipher_operation(
5499 tdata->digest.data, tdata->digest.len,
5500 tdata->cipher_iv.data, tdata->cipher_iv.len,
5502 (tdata->digest.offset_bytes == 0 ?
5503 (verify ? ciphertext_pad_len : plaintext_pad_len)
5504 : tdata->digest.offset_bytes),
5505 tdata->validCipherLenInBits.len,
5506 tdata->validCipherOffsetInBits.len,
5507 tdata->validAuthLenInBits.len,
5509 op_mode, 0, verify);
5514 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5515 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5516 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5518 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5521 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5523 ut_params->obuf = (op_mode == IN_PLACE ?
5524 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5528 if (ut_params->obuf)
5529 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5532 plaintext = ciphertext;
5534 debug_hexdump(stdout, "plaintext:", plaintext,
5535 (tdata->plaintext.len >> 3) - tdata->digest.len);
5536 debug_hexdump(stdout, "plaintext expected:",
5537 tdata->plaintext.data,
5538 (tdata->plaintext.len >> 3) - tdata->digest.len);
5540 if (ut_params->obuf)
5541 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5544 ciphertext = plaintext;
5546 debug_hexdump(stdout, "ciphertext:", ciphertext,
5548 debug_hexdump(stdout, "ciphertext expected:",
5549 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5551 ut_params->digest = rte_pktmbuf_mtod(
5552 ut_params->obuf, uint8_t *) +
5553 (tdata->digest.offset_bytes == 0 ?
5554 plaintext_pad_len : tdata->digest.offset_bytes);
5556 debug_hexdump(stdout, "digest:", ut_params->digest,
5558 debug_hexdump(stdout, "digest expected:",
5559 tdata->digest.data, tdata->digest.len);
5564 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5566 tdata->plaintext.data,
5567 tdata->plaintext.len >> 3,
5568 "KASUMI Plaintext data not as expected");
5570 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5572 tdata->ciphertext.data,
5573 tdata->ciphertext.len >> 3,
5574 "KASUMI Ciphertext data not as expected");
5576 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5579 DIGEST_BYTE_LENGTH_KASUMI_F9,
5580 "KASUMI Generated auth tag not as expected");
5586 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5587 uint8_t op_mode, uint8_t verify)
5589 struct crypto_testsuite_params *ts_params = &testsuite_params;
5590 struct crypto_unittest_params *ut_params = &unittest_params;
5594 const uint8_t *plaintext = NULL;
5595 const uint8_t *ciphertext = NULL;
5596 const uint8_t *digest = NULL;
5597 unsigned int plaintext_pad_len;
5598 unsigned int plaintext_len;
5599 unsigned int ciphertext_pad_len;
5600 unsigned int ciphertext_len;
5601 uint8_t buffer[10000];
5602 uint8_t digest_buffer[10000];
5604 struct rte_cryptodev_info dev_info;
5606 /* Verify the capabilities */
5607 struct rte_cryptodev_sym_capability_idx cap_idx;
5608 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5609 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5610 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5612 return TEST_SKIPPED;
5613 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5614 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5615 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5617 return TEST_SKIPPED;
5619 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5620 return TEST_SKIPPED;
5622 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5624 uint64_t feat_flags = dev_info.feature_flags;
5626 if (op_mode == IN_PLACE) {
5627 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5628 printf("Device doesn't support in-place scatter-gather "
5629 "in both input and output mbufs.\n");
5630 return TEST_SKIPPED;
5632 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5633 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5634 printf("Device doesn't support RAW data-path APIs.\n");
5635 return TEST_SKIPPED;
5638 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5639 return TEST_SKIPPED;
5640 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5641 printf("Device doesn't support out-of-place scatter-gather "
5642 "in both input and output mbufs.\n");
5643 return TEST_SKIPPED;
5645 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5646 printf("Device doesn't support digest encrypted.\n");
5647 return TEST_SKIPPED;
5651 /* Create KASUMI session */
5652 retval = create_wireless_algo_auth_cipher_session(
5653 ts_params->valid_devs[0],
5654 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5655 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5656 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5657 : RTE_CRYPTO_AUTH_OP_GENERATE),
5658 RTE_CRYPTO_AUTH_KASUMI_F9,
5659 RTE_CRYPTO_CIPHER_KASUMI_F8,
5660 tdata->key.data, tdata->key.len,
5661 0, tdata->digest.len,
5662 tdata->cipher_iv.len);
5667 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5668 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5669 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5670 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5672 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5673 plaintext_pad_len, 15, 0);
5674 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5675 "Failed to allocate input buffer in mempool");
5677 if (op_mode == OUT_OF_PLACE) {
5678 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5679 plaintext_pad_len, 15, 0);
5680 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5681 "Failed to allocate output buffer in mempool");
5685 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5686 tdata->ciphertext.data);
5687 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5688 ciphertext_len, buffer);
5689 debug_hexdump(stdout, "ciphertext:", ciphertext,
5692 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5693 tdata->plaintext.data);
5694 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5695 plaintext_len, buffer);
5696 debug_hexdump(stdout, "plaintext:", plaintext,
5699 memset(buffer, 0, sizeof(buffer));
5701 /* Create KASUMI operation */
5702 retval = create_wireless_algo_auth_cipher_operation(
5703 tdata->digest.data, tdata->digest.len,
5704 tdata->cipher_iv.data, tdata->cipher_iv.len,
5706 (tdata->digest.offset_bytes == 0 ?
5707 (verify ? ciphertext_pad_len : plaintext_pad_len)
5708 : tdata->digest.offset_bytes),
5709 tdata->validCipherLenInBits.len,
5710 tdata->validCipherOffsetInBits.len,
5711 tdata->validAuthLenInBits.len,
5713 op_mode, 1, verify);
5718 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5719 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5720 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5722 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5725 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5727 ut_params->obuf = (op_mode == IN_PLACE ?
5728 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5731 if (ut_params->obuf)
5732 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5733 plaintext_len, buffer);
5735 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5736 plaintext_len, buffer);
5738 debug_hexdump(stdout, "plaintext:", plaintext,
5739 (tdata->plaintext.len >> 3) - tdata->digest.len);
5740 debug_hexdump(stdout, "plaintext expected:",
5741 tdata->plaintext.data,
5742 (tdata->plaintext.len >> 3) - tdata->digest.len);
5744 if (ut_params->obuf)
5745 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5746 ciphertext_len, buffer);
5748 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5749 ciphertext_len, buffer);
5751 debug_hexdump(stdout, "ciphertext:", ciphertext,
5753 debug_hexdump(stdout, "ciphertext expected:",
5754 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5756 if (ut_params->obuf)
5757 digest = rte_pktmbuf_read(ut_params->obuf,
5758 (tdata->digest.offset_bytes == 0 ?
5759 plaintext_pad_len : tdata->digest.offset_bytes),
5760 tdata->digest.len, digest_buffer);
5762 digest = rte_pktmbuf_read(ut_params->ibuf,
5763 (tdata->digest.offset_bytes == 0 ?
5764 plaintext_pad_len : tdata->digest.offset_bytes),
5765 tdata->digest.len, digest_buffer);
5767 debug_hexdump(stdout, "digest:", digest,
5769 debug_hexdump(stdout, "digest expected:",
5770 tdata->digest.data, tdata->digest.len);
5775 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5777 tdata->plaintext.data,
5778 tdata->plaintext.len >> 3,
5779 "KASUMI Plaintext data not as expected");
5781 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5783 tdata->ciphertext.data,
5784 tdata->validDataLenInBits.len,
5785 "KASUMI Ciphertext data not as expected");
5787 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5790 DIGEST_BYTE_LENGTH_KASUMI_F9,
5791 "KASUMI Generated auth tag not as expected");
5797 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5799 struct crypto_testsuite_params *ts_params = &testsuite_params;
5800 struct crypto_unittest_params *ut_params = &unittest_params;
5804 uint8_t *plaintext, *ciphertext;
5805 unsigned plaintext_pad_len;
5806 unsigned plaintext_len;
5807 struct rte_cryptodev_info dev_info;
5809 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5810 uint64_t feat_flags = dev_info.feature_flags;
5812 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5813 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5814 printf("Device doesn't support RAW data-path APIs.\n");
5815 return TEST_SKIPPED;
5818 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5819 return TEST_SKIPPED;
5821 /* Verify the capabilities */
5822 struct rte_cryptodev_sym_capability_idx cap_idx;
5823 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5824 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5825 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5827 return TEST_SKIPPED;
5828 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5829 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5830 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5832 return TEST_SKIPPED;
5834 /* Create KASUMI session */
5835 retval = create_wireless_algo_cipher_auth_session(
5836 ts_params->valid_devs[0],
5837 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5838 RTE_CRYPTO_AUTH_OP_GENERATE,
5839 RTE_CRYPTO_AUTH_KASUMI_F9,
5840 RTE_CRYPTO_CIPHER_KASUMI_F8,
5841 tdata->key.data, tdata->key.len,
5842 0, tdata->digest.len,
5843 tdata->cipher_iv.len);
5847 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5849 /* clear mbuf payload */
5850 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5851 rte_pktmbuf_tailroom(ut_params->ibuf));
5853 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5854 /* Append data which is padded to a multiple of */
5855 /* the algorithms block size */
5856 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5857 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5859 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5861 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5863 /* Create KASUMI operation */
5864 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5865 tdata->digest.len, NULL, 0,
5866 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5867 tdata->cipher_iv.data, tdata->cipher_iv.len,
5868 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5869 tdata->validCipherOffsetInBits.len,
5870 tdata->validAuthLenInBits.len,
5876 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5877 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5878 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5880 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5882 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5884 if (ut_params->op->sym->m_dst)
5885 ut_params->obuf = ut_params->op->sym->m_dst;
5887 ut_params->obuf = ut_params->op->sym->m_src;
5889 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5890 tdata->validCipherOffsetInBits.len >> 3);
5892 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5893 + plaintext_pad_len;
5895 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5896 (tdata->validCipherOffsetInBits.len >> 3);
5898 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5900 reference_ciphertext,
5901 tdata->validCipherLenInBits.len,
5902 "KASUMI Ciphertext data not as expected");
5905 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5908 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5909 "KASUMI Generated auth tag not as expected");
5914 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
5915 const enum rte_crypto_cipher_algorithm cipher_algo,
5916 const uint16_t key_size, const uint16_t iv_size)
5918 struct rte_cryptodev_sym_capability_idx cap_idx;
5919 const struct rte_cryptodev_symmetric_capability *cap;
5921 /* Check if device supports the algorithm */
5922 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5923 cap_idx.algo.cipher = cipher_algo;
5925 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5931 /* Check if device supports key size and IV size */
5932 if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
5941 check_auth_capability(const struct crypto_testsuite_params *ts_params,
5942 const enum rte_crypto_auth_algorithm auth_algo,
5943 const uint16_t key_size, const uint16_t iv_size,
5944 const uint16_t tag_size)
5946 struct rte_cryptodev_sym_capability_idx cap_idx;
5947 const struct rte_cryptodev_symmetric_capability *cap;
5949 /* Check if device supports the algorithm */
5950 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5951 cap_idx.algo.auth = auth_algo;
5953 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5959 /* Check if device supports key size and IV size */
5960 if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
5961 tag_size, iv_size) < 0) {
5969 test_zuc_encryption(const struct wireless_test_data *tdata)
5971 struct crypto_testsuite_params *ts_params = &testsuite_params;
5972 struct crypto_unittest_params *ut_params = &unittest_params;
5975 uint8_t *plaintext, *ciphertext;
5976 unsigned plaintext_pad_len;
5977 unsigned plaintext_len;
5978 struct rte_cryptodev_info dev_info;
5980 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5981 uint64_t feat_flags = dev_info.feature_flags;
5983 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5984 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5985 printf("Device doesn't support RAW data-path APIs.\n");
5986 return TEST_SKIPPED;
5989 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5990 return TEST_SKIPPED;
5992 /* Check if device supports ZUC EEA3 */
5993 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5994 tdata->key.len, tdata->cipher_iv.len) < 0)
5995 return TEST_SKIPPED;
5997 /* Create ZUC session */
5998 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5999 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6000 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6001 tdata->key.data, tdata->key.len,
6002 tdata->cipher_iv.len);
6006 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6008 /* Clear mbuf payload */
6009 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6010 rte_pktmbuf_tailroom(ut_params->ibuf));
6012 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6013 /* Append data which is padded to a multiple */
6014 /* of the algorithms block size */
6015 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6016 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6018 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6020 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6022 /* Create ZUC operation */
6023 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6024 tdata->cipher_iv.len,
6025 tdata->plaintext.len,
6030 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6031 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6032 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6034 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6036 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6038 ut_params->obuf = ut_params->op->sym->m_dst;
6039 if (ut_params->obuf)
6040 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6042 ciphertext = plaintext;
6044 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6047 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6049 tdata->ciphertext.data,
6050 tdata->validCipherLenInBits.len,
6051 "ZUC Ciphertext data not as expected");
6056 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
6058 struct crypto_testsuite_params *ts_params = &testsuite_params;
6059 struct crypto_unittest_params *ut_params = &unittest_params;
6063 unsigned int plaintext_pad_len;
6064 unsigned int plaintext_len;
6065 const uint8_t *ciphertext;
6066 uint8_t ciphertext_buffer[2048];
6067 struct rte_cryptodev_info dev_info;
6069 /* Check if device supports ZUC EEA3 */
6070 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6071 tdata->key.len, tdata->cipher_iv.len) < 0)
6072 return TEST_SKIPPED;
6074 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6075 return TEST_SKIPPED;
6077 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6079 uint64_t feat_flags = dev_info.feature_flags;
6081 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6082 printf("Device doesn't support in-place scatter-gather. "
6084 return TEST_SKIPPED;
6087 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6088 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6089 printf("Device doesn't support RAW data-path APIs.\n");
6090 return TEST_SKIPPED;
6093 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6095 /* Append data which is padded to a multiple */
6096 /* of the algorithms block size */
6097 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6099 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6100 plaintext_pad_len, 10, 0);
6102 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6103 tdata->plaintext.data);
6105 /* Create ZUC session */
6106 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6107 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6108 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6109 tdata->key.data, tdata->key.len,
6110 tdata->cipher_iv.len);
6114 /* Clear mbuf payload */
6116 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6118 /* Create ZUC operation */
6119 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6120 tdata->cipher_iv.len, tdata->plaintext.len,
6125 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6126 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6127 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6129 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6131 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6133 ut_params->obuf = ut_params->op->sym->m_dst;
6134 if (ut_params->obuf)
6135 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6136 0, plaintext_len, ciphertext_buffer);
6138 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6139 0, plaintext_len, ciphertext_buffer);
6142 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6145 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6147 tdata->ciphertext.data,
6148 tdata->validCipherLenInBits.len,
6149 "ZUC Ciphertext data not as expected");
6155 test_zuc_authentication(const struct wireless_test_data *tdata)
6157 struct crypto_testsuite_params *ts_params = &testsuite_params;
6158 struct crypto_unittest_params *ut_params = &unittest_params;
6161 unsigned plaintext_pad_len;
6162 unsigned plaintext_len;
6165 struct rte_cryptodev_info dev_info;
6167 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6168 uint64_t feat_flags = dev_info.feature_flags;
6170 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6171 (tdata->validAuthLenInBits.len % 8 != 0)) {
6172 printf("Device doesn't support NON-Byte Aligned Data.\n");
6173 return TEST_SKIPPED;
6176 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6177 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6178 printf("Device doesn't support RAW data-path APIs.\n");
6179 return TEST_SKIPPED;
6182 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6183 return TEST_SKIPPED;
6185 /* Check if device supports ZUC EIA3 */
6186 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6187 tdata->key.len, tdata->auth_iv.len,
6188 tdata->digest.len) < 0)
6189 return TEST_SKIPPED;
6191 /* Create ZUC session */
6192 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6193 tdata->key.data, tdata->key.len,
6194 tdata->auth_iv.len, tdata->digest.len,
6195 RTE_CRYPTO_AUTH_OP_GENERATE,
6196 RTE_CRYPTO_AUTH_ZUC_EIA3);
6200 /* alloc mbuf and set payload */
6201 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6203 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6204 rte_pktmbuf_tailroom(ut_params->ibuf));
6206 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6207 /* Append data which is padded to a multiple of */
6208 /* the algorithms block size */
6209 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6210 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6212 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6214 /* Create ZUC operation */
6215 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6216 tdata->auth_iv.data, tdata->auth_iv.len,
6217 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6218 tdata->validAuthLenInBits.len,
6223 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6224 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6225 ut_params->op, 0, 1, 1, 0);
6227 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6229 ut_params->obuf = ut_params->op->sym->m_src;
6230 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6231 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6232 + plaintext_pad_len;
6235 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6239 "ZUC Generated auth tag not as expected");
6245 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6246 uint8_t op_mode, uint8_t verify)
6248 struct crypto_testsuite_params *ts_params = &testsuite_params;
6249 struct crypto_unittest_params *ut_params = &unittest_params;
6253 uint8_t *plaintext = NULL, *ciphertext = NULL;
6254 unsigned int plaintext_pad_len;
6255 unsigned int plaintext_len;
6256 unsigned int ciphertext_pad_len;
6257 unsigned int ciphertext_len;
6259 struct rte_cryptodev_info dev_info;
6261 /* Check if device supports ZUC EEA3 */
6262 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6263 tdata->key.len, tdata->cipher_iv.len) < 0)
6264 return TEST_SKIPPED;
6266 /* Check if device supports ZUC EIA3 */
6267 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6268 tdata->key.len, tdata->auth_iv.len,
6269 tdata->digest.len) < 0)
6270 return TEST_SKIPPED;
6272 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6274 uint64_t feat_flags = dev_info.feature_flags;
6276 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6277 printf("Device doesn't support digest encrypted.\n");
6278 return TEST_SKIPPED;
6280 if (op_mode == IN_PLACE) {
6281 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6282 printf("Device doesn't support in-place scatter-gather "
6283 "in both input and output mbufs.\n");
6284 return TEST_SKIPPED;
6287 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6288 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6289 printf("Device doesn't support RAW data-path APIs.\n");
6290 return TEST_SKIPPED;
6293 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6294 return TEST_SKIPPED;
6295 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6296 printf("Device doesn't support out-of-place scatter-gather "
6297 "in both input and output mbufs.\n");
6298 return TEST_SKIPPED;
6302 /* Create ZUC session */
6303 retval = create_wireless_algo_auth_cipher_session(
6304 ts_params->valid_devs[0],
6305 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6306 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6307 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6308 : RTE_CRYPTO_AUTH_OP_GENERATE),
6309 RTE_CRYPTO_AUTH_ZUC_EIA3,
6310 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6311 tdata->key.data, tdata->key.len,
6312 tdata->auth_iv.len, tdata->digest.len,
6313 tdata->cipher_iv.len);
6318 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6319 if (op_mode == OUT_OF_PLACE)
6320 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6322 /* clear mbuf payload */
6323 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6324 rte_pktmbuf_tailroom(ut_params->ibuf));
6325 if (op_mode == OUT_OF_PLACE)
6326 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6327 rte_pktmbuf_tailroom(ut_params->obuf));
6329 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6330 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6331 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6332 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6335 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6336 ciphertext_pad_len);
6337 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6338 debug_hexdump(stdout, "ciphertext:", ciphertext,
6341 /* make sure enough space to cover partial digest verify case */
6342 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6343 ciphertext_pad_len);
6344 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6345 debug_hexdump(stdout, "plaintext:", plaintext,
6349 if (op_mode == OUT_OF_PLACE)
6350 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6352 /* Create ZUC operation */
6353 retval = create_wireless_algo_auth_cipher_operation(
6354 tdata->digest.data, tdata->digest.len,
6355 tdata->cipher_iv.data, tdata->cipher_iv.len,
6356 tdata->auth_iv.data, tdata->auth_iv.len,
6357 (tdata->digest.offset_bytes == 0 ?
6358 (verify ? ciphertext_pad_len : plaintext_pad_len)
6359 : tdata->digest.offset_bytes),
6360 tdata->validCipherLenInBits.len,
6361 tdata->validCipherOffsetInBits.len,
6362 tdata->validAuthLenInBits.len,
6364 op_mode, 0, verify);
6369 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6370 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6371 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6373 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6376 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6378 ut_params->obuf = (op_mode == IN_PLACE ?
6379 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6383 if (ut_params->obuf)
6384 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6387 plaintext = ciphertext;
6389 debug_hexdump(stdout, "plaintext:", plaintext,
6390 (tdata->plaintext.len >> 3) - tdata->digest.len);
6391 debug_hexdump(stdout, "plaintext expected:",
6392 tdata->plaintext.data,
6393 (tdata->plaintext.len >> 3) - tdata->digest.len);
6395 if (ut_params->obuf)
6396 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6399 ciphertext = plaintext;
6401 debug_hexdump(stdout, "ciphertext:", ciphertext,
6403 debug_hexdump(stdout, "ciphertext expected:",
6404 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6406 ut_params->digest = rte_pktmbuf_mtod(
6407 ut_params->obuf, uint8_t *) +
6408 (tdata->digest.offset_bytes == 0 ?
6409 plaintext_pad_len : tdata->digest.offset_bytes);
6411 debug_hexdump(stdout, "digest:", ut_params->digest,
6413 debug_hexdump(stdout, "digest expected:",
6414 tdata->digest.data, tdata->digest.len);
6419 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6421 tdata->plaintext.data,
6422 tdata->plaintext.len >> 3,
6423 "ZUC Plaintext data not as expected");
6425 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6427 tdata->ciphertext.data,
6428 tdata->ciphertext.len >> 3,
6429 "ZUC Ciphertext data not as expected");
6431 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6434 DIGEST_BYTE_LENGTH_KASUMI_F9,
6435 "ZUC Generated auth tag not as expected");
6441 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6442 uint8_t op_mode, uint8_t verify)
6444 struct crypto_testsuite_params *ts_params = &testsuite_params;
6445 struct crypto_unittest_params *ut_params = &unittest_params;
6449 const uint8_t *plaintext = NULL;
6450 const uint8_t *ciphertext = NULL;
6451 const uint8_t *digest = NULL;
6452 unsigned int plaintext_pad_len;
6453 unsigned int plaintext_len;
6454 unsigned int ciphertext_pad_len;
6455 unsigned int ciphertext_len;
6456 uint8_t buffer[10000];
6457 uint8_t digest_buffer[10000];
6459 struct rte_cryptodev_info dev_info;
6461 /* Check if device supports ZUC EEA3 */
6462 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6463 tdata->key.len, tdata->cipher_iv.len) < 0)
6464 return TEST_SKIPPED;
6466 /* Check if device supports ZUC EIA3 */
6467 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6468 tdata->key.len, tdata->auth_iv.len,
6469 tdata->digest.len) < 0)
6470 return TEST_SKIPPED;
6472 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6474 uint64_t feat_flags = dev_info.feature_flags;
6476 if (op_mode == IN_PLACE) {
6477 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6478 printf("Device doesn't support in-place scatter-gather "
6479 "in both input and output mbufs.\n");
6480 return TEST_SKIPPED;
6483 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6484 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6485 printf("Device doesn't support RAW data-path APIs.\n");
6486 return TEST_SKIPPED;
6489 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6490 return TEST_SKIPPED;
6491 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6492 printf("Device doesn't support out-of-place scatter-gather "
6493 "in both input and output mbufs.\n");
6494 return TEST_SKIPPED;
6496 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6497 printf("Device doesn't support digest encrypted.\n");
6498 return TEST_SKIPPED;
6502 /* Create ZUC session */
6503 retval = create_wireless_algo_auth_cipher_session(
6504 ts_params->valid_devs[0],
6505 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6506 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6507 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6508 : RTE_CRYPTO_AUTH_OP_GENERATE),
6509 RTE_CRYPTO_AUTH_ZUC_EIA3,
6510 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6511 tdata->key.data, tdata->key.len,
6512 tdata->auth_iv.len, tdata->digest.len,
6513 tdata->cipher_iv.len);
6518 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6519 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6520 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6521 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6523 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6524 plaintext_pad_len, 15, 0);
6525 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6526 "Failed to allocate input buffer in mempool");
6528 if (op_mode == OUT_OF_PLACE) {
6529 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6530 plaintext_pad_len, 15, 0);
6531 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6532 "Failed to allocate output buffer in mempool");
6536 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6537 tdata->ciphertext.data);
6538 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6539 ciphertext_len, buffer);
6540 debug_hexdump(stdout, "ciphertext:", ciphertext,
6543 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6544 tdata->plaintext.data);
6545 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6546 plaintext_len, buffer);
6547 debug_hexdump(stdout, "plaintext:", plaintext,
6550 memset(buffer, 0, sizeof(buffer));
6552 /* Create ZUC operation */
6553 retval = create_wireless_algo_auth_cipher_operation(
6554 tdata->digest.data, tdata->digest.len,
6555 tdata->cipher_iv.data, tdata->cipher_iv.len,
6557 (tdata->digest.offset_bytes == 0 ?
6558 (verify ? ciphertext_pad_len : plaintext_pad_len)
6559 : tdata->digest.offset_bytes),
6560 tdata->validCipherLenInBits.len,
6561 tdata->validCipherOffsetInBits.len,
6562 tdata->validAuthLenInBits.len,
6564 op_mode, 1, verify);
6569 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6570 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6571 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6573 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6576 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6578 ut_params->obuf = (op_mode == IN_PLACE ?
6579 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6582 if (ut_params->obuf)
6583 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6584 plaintext_len, buffer);
6586 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6587 plaintext_len, buffer);
6589 debug_hexdump(stdout, "plaintext:", plaintext,
6590 (tdata->plaintext.len >> 3) - tdata->digest.len);
6591 debug_hexdump(stdout, "plaintext expected:",
6592 tdata->plaintext.data,
6593 (tdata->plaintext.len >> 3) - tdata->digest.len);
6595 if (ut_params->obuf)
6596 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6597 ciphertext_len, buffer);
6599 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6600 ciphertext_len, buffer);
6602 debug_hexdump(stdout, "ciphertext:", ciphertext,
6604 debug_hexdump(stdout, "ciphertext expected:",
6605 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6607 if (ut_params->obuf)
6608 digest = rte_pktmbuf_read(ut_params->obuf,
6609 (tdata->digest.offset_bytes == 0 ?
6610 plaintext_pad_len : tdata->digest.offset_bytes),
6611 tdata->digest.len, digest_buffer);
6613 digest = rte_pktmbuf_read(ut_params->ibuf,
6614 (tdata->digest.offset_bytes == 0 ?
6615 plaintext_pad_len : tdata->digest.offset_bytes),
6616 tdata->digest.len, digest_buffer);
6618 debug_hexdump(stdout, "digest:", digest,
6620 debug_hexdump(stdout, "digest expected:",
6621 tdata->digest.data, tdata->digest.len);
6626 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6628 tdata->plaintext.data,
6629 tdata->plaintext.len >> 3,
6630 "ZUC Plaintext data not as expected");
6632 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6634 tdata->ciphertext.data,
6635 tdata->validDataLenInBits.len,
6636 "ZUC Ciphertext data not as expected");
6638 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6641 DIGEST_BYTE_LENGTH_KASUMI_F9,
6642 "ZUC Generated auth tag not as expected");
6648 test_kasumi_encryption_test_case_1(void)
6650 return test_kasumi_encryption(&kasumi_test_case_1);
6654 test_kasumi_encryption_test_case_1_sgl(void)
6656 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6660 test_kasumi_encryption_test_case_1_oop(void)
6662 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6666 test_kasumi_encryption_test_case_1_oop_sgl(void)
6668 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6672 test_kasumi_encryption_test_case_2(void)
6674 return test_kasumi_encryption(&kasumi_test_case_2);
6678 test_kasumi_encryption_test_case_3(void)
6680 return test_kasumi_encryption(&kasumi_test_case_3);
6684 test_kasumi_encryption_test_case_4(void)
6686 return test_kasumi_encryption(&kasumi_test_case_4);
6690 test_kasumi_encryption_test_case_5(void)
6692 return test_kasumi_encryption(&kasumi_test_case_5);
6696 test_kasumi_decryption_test_case_1(void)
6698 return test_kasumi_decryption(&kasumi_test_case_1);
6702 test_kasumi_decryption_test_case_1_oop(void)
6704 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6708 test_kasumi_decryption_test_case_2(void)
6710 return test_kasumi_decryption(&kasumi_test_case_2);
6714 test_kasumi_decryption_test_case_3(void)
6716 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6717 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6718 return TEST_SKIPPED;
6719 return test_kasumi_decryption(&kasumi_test_case_3);
6723 test_kasumi_decryption_test_case_4(void)
6725 return test_kasumi_decryption(&kasumi_test_case_4);
6729 test_kasumi_decryption_test_case_5(void)
6731 return test_kasumi_decryption(&kasumi_test_case_5);
6734 test_snow3g_encryption_test_case_1(void)
6736 return test_snow3g_encryption(&snow3g_test_case_1);
6740 test_snow3g_encryption_test_case_1_oop(void)
6742 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6746 test_snow3g_encryption_test_case_1_oop_sgl(void)
6748 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6753 test_snow3g_encryption_test_case_1_offset_oop(void)
6755 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6759 test_snow3g_encryption_test_case_2(void)
6761 return test_snow3g_encryption(&snow3g_test_case_2);
6765 test_snow3g_encryption_test_case_3(void)
6767 return test_snow3g_encryption(&snow3g_test_case_3);
6771 test_snow3g_encryption_test_case_4(void)
6773 return test_snow3g_encryption(&snow3g_test_case_4);
6777 test_snow3g_encryption_test_case_5(void)
6779 return test_snow3g_encryption(&snow3g_test_case_5);
6783 test_snow3g_decryption_test_case_1(void)
6785 return test_snow3g_decryption(&snow3g_test_case_1);
6789 test_snow3g_decryption_test_case_1_oop(void)
6791 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6795 test_snow3g_decryption_test_case_2(void)
6797 return test_snow3g_decryption(&snow3g_test_case_2);
6801 test_snow3g_decryption_test_case_3(void)
6803 return test_snow3g_decryption(&snow3g_test_case_3);
6807 test_snow3g_decryption_test_case_4(void)
6809 return test_snow3g_decryption(&snow3g_test_case_4);
6813 test_snow3g_decryption_test_case_5(void)
6815 return test_snow3g_decryption(&snow3g_test_case_5);
6819 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6820 * Pattern digest from snow3g_test_data must be allocated as
6821 * 4 last bytes in plaintext.
6824 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6825 struct snow3g_hash_test_data *output)
6827 if ((pattern != NULL) && (output != NULL)) {
6828 output->key.len = pattern->key.len;
6830 memcpy(output->key.data,
6831 pattern->key.data, pattern->key.len);
6833 output->auth_iv.len = pattern->auth_iv.len;
6835 memcpy(output->auth_iv.data,
6836 pattern->auth_iv.data, pattern->auth_iv.len);
6838 output->plaintext.len = pattern->plaintext.len;
6840 memcpy(output->plaintext.data,
6841 pattern->plaintext.data, pattern->plaintext.len >> 3);
6843 output->digest.len = pattern->digest.len;
6845 memcpy(output->digest.data,
6846 &pattern->plaintext.data[pattern->digest.offset_bytes],
6847 pattern->digest.len);
6849 output->validAuthLenInBits.len =
6850 pattern->validAuthLenInBits.len;
6855 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6858 test_snow3g_decryption_with_digest_test_case_1(void)
6860 struct snow3g_hash_test_data snow3g_hash_data;
6861 struct rte_cryptodev_info dev_info;
6862 struct crypto_testsuite_params *ts_params = &testsuite_params;
6864 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6865 uint64_t feat_flags = dev_info.feature_flags;
6867 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6868 printf("Device doesn't support encrypted digest operations.\n");
6869 return TEST_SKIPPED;
6873 * Function prepare data for hash verification test case.
6874 * Digest is allocated in 4 last bytes in plaintext, pattern.
6876 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6878 return test_snow3g_decryption(&snow3g_test_case_7) &
6879 test_snow3g_authentication_verify(&snow3g_hash_data);
6883 test_snow3g_cipher_auth_test_case_1(void)
6885 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6889 test_snow3g_auth_cipher_test_case_1(void)
6891 return test_snow3g_auth_cipher(
6892 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6896 test_snow3g_auth_cipher_test_case_2(void)
6898 return test_snow3g_auth_cipher(
6899 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6903 test_snow3g_auth_cipher_test_case_2_oop(void)
6905 return test_snow3g_auth_cipher(
6906 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6910 test_snow3g_auth_cipher_part_digest_enc(void)
6912 return test_snow3g_auth_cipher(
6913 &snow3g_auth_cipher_partial_digest_encryption,
6918 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6920 return test_snow3g_auth_cipher(
6921 &snow3g_auth_cipher_partial_digest_encryption,
6926 test_snow3g_auth_cipher_test_case_3_sgl(void)
6928 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6929 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6930 return TEST_SKIPPED;
6931 return test_snow3g_auth_cipher_sgl(
6932 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6936 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6938 return test_snow3g_auth_cipher_sgl(
6939 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6943 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6945 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6946 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6947 return TEST_SKIPPED;
6948 return test_snow3g_auth_cipher_sgl(
6949 &snow3g_auth_cipher_partial_digest_encryption,
6954 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6956 return test_snow3g_auth_cipher_sgl(
6957 &snow3g_auth_cipher_partial_digest_encryption,
6962 test_snow3g_auth_cipher_verify_test_case_1(void)
6964 return test_snow3g_auth_cipher(
6965 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6969 test_snow3g_auth_cipher_verify_test_case_2(void)
6971 return test_snow3g_auth_cipher(
6972 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6976 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6978 return test_snow3g_auth_cipher(
6979 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6983 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6985 return test_snow3g_auth_cipher(
6986 &snow3g_auth_cipher_partial_digest_encryption,
6991 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6993 return test_snow3g_auth_cipher(
6994 &snow3g_auth_cipher_partial_digest_encryption,
6999 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7001 return test_snow3g_auth_cipher_sgl(
7002 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7006 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7008 return test_snow3g_auth_cipher_sgl(
7009 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7013 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7015 return test_snow3g_auth_cipher_sgl(
7016 &snow3g_auth_cipher_partial_digest_encryption,
7021 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7023 return test_snow3g_auth_cipher_sgl(
7024 &snow3g_auth_cipher_partial_digest_encryption,
7029 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7031 return test_snow3g_auth_cipher(
7032 &snow3g_test_case_7, IN_PLACE, 0);
7036 test_kasumi_auth_cipher_test_case_1(void)
7038 return test_kasumi_auth_cipher(
7039 &kasumi_test_case_3, IN_PLACE, 0);
7043 test_kasumi_auth_cipher_test_case_2(void)
7045 return test_kasumi_auth_cipher(
7046 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7050 test_kasumi_auth_cipher_test_case_2_oop(void)
7052 return test_kasumi_auth_cipher(
7053 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7057 test_kasumi_auth_cipher_test_case_2_sgl(void)
7059 return test_kasumi_auth_cipher_sgl(
7060 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7064 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7066 return test_kasumi_auth_cipher_sgl(
7067 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7071 test_kasumi_auth_cipher_verify_test_case_1(void)
7073 return test_kasumi_auth_cipher(
7074 &kasumi_test_case_3, IN_PLACE, 1);
7078 test_kasumi_auth_cipher_verify_test_case_2(void)
7080 return test_kasumi_auth_cipher(
7081 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7085 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7087 return test_kasumi_auth_cipher(
7088 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7092 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7094 return test_kasumi_auth_cipher_sgl(
7095 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7099 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7101 return test_kasumi_auth_cipher_sgl(
7102 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7106 test_kasumi_cipher_auth_test_case_1(void)
7108 return test_kasumi_cipher_auth(&kasumi_test_case_6);
7112 test_zuc_encryption_test_case_1(void)
7114 return test_zuc_encryption(&zuc_test_case_cipher_193b);
7118 test_zuc_encryption_test_case_2(void)
7120 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7124 test_zuc_encryption_test_case_3(void)
7126 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7130 test_zuc_encryption_test_case_4(void)
7132 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7136 test_zuc_encryption_test_case_5(void)
7138 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7142 test_zuc_encryption_test_case_6_sgl(void)
7144 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7148 test_zuc_hash_generate_test_case_1(void)
7150 return test_zuc_authentication(&zuc_test_case_auth_1b);
7154 test_zuc_hash_generate_test_case_2(void)
7156 return test_zuc_authentication(&zuc_test_case_auth_90b);
7160 test_zuc_hash_generate_test_case_3(void)
7162 return test_zuc_authentication(&zuc_test_case_auth_577b);
7166 test_zuc_hash_generate_test_case_4(void)
7168 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7172 test_zuc_hash_generate_test_case_5(void)
7174 return test_zuc_authentication(&zuc_test_auth_5670b);
7178 test_zuc_hash_generate_test_case_6(void)
7180 return test_zuc_authentication(&zuc_test_case_auth_128b);
7184 test_zuc_hash_generate_test_case_7(void)
7186 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7190 test_zuc_hash_generate_test_case_8(void)
7192 return test_zuc_authentication(&zuc_test_case_auth_584b);
7196 test_zuc_hash_generate_test_case_9(void)
7198 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b);
7202 test_zuc_hash_generate_test_case_10(void)
7204 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b);
7208 test_zuc_hash_generate_test_case_11(void)
7210 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b);
7214 test_zuc_cipher_auth_test_case_1(void)
7216 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7220 test_zuc_cipher_auth_test_case_2(void)
7222 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7226 test_zuc_auth_cipher_test_case_1(void)
7228 return test_zuc_auth_cipher(
7229 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7233 test_zuc_auth_cipher_test_case_1_oop(void)
7235 return test_zuc_auth_cipher(
7236 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7240 test_zuc_auth_cipher_test_case_1_sgl(void)
7242 return test_zuc_auth_cipher_sgl(
7243 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7247 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7249 return test_zuc_auth_cipher_sgl(
7250 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7254 test_zuc_auth_cipher_verify_test_case_1(void)
7256 return test_zuc_auth_cipher(
7257 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7261 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7263 return test_zuc_auth_cipher(
7264 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7268 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7270 return test_zuc_auth_cipher_sgl(
7271 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7275 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7277 return test_zuc_auth_cipher_sgl(
7278 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7282 test_zuc256_encryption_test_case_1(void)
7284 return test_zuc_encryption(&zuc256_test_case_cipher_1);
7288 test_zuc256_encryption_test_case_2(void)
7290 return test_zuc_encryption(&zuc256_test_case_cipher_2);
7294 test_zuc256_authentication_test_case_1(void)
7296 return test_zuc_authentication(&zuc256_test_case_auth_1);
7300 test_zuc256_authentication_test_case_2(void)
7302 return test_zuc_authentication(&zuc256_test_case_auth_2);
7306 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7308 uint8_t dev_id = testsuite_params.valid_devs[0];
7310 struct rte_cryptodev_sym_capability_idx cap_idx;
7312 /* Check if device supports particular cipher algorithm */
7313 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7314 cap_idx.algo.cipher = tdata->cipher_algo;
7315 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7316 return TEST_SKIPPED;
7318 /* Check if device supports particular hash algorithm */
7319 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7320 cap_idx.algo.auth = tdata->auth_algo;
7321 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7322 return TEST_SKIPPED;
7328 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7329 uint8_t op_mode, uint8_t verify)
7331 struct crypto_testsuite_params *ts_params = &testsuite_params;
7332 struct crypto_unittest_params *ut_params = &unittest_params;
7336 uint8_t *plaintext = NULL, *ciphertext = NULL;
7337 unsigned int plaintext_pad_len;
7338 unsigned int plaintext_len;
7339 unsigned int ciphertext_pad_len;
7340 unsigned int ciphertext_len;
7342 struct rte_cryptodev_info dev_info;
7343 struct rte_crypto_op *op;
7345 /* Check if device supports particular algorithms separately */
7346 if (test_mixed_check_if_unsupported(tdata))
7347 return TEST_SKIPPED;
7348 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7349 return TEST_SKIPPED;
7351 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7353 uint64_t feat_flags = dev_info.feature_flags;
7355 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7356 printf("Device doesn't support digest encrypted.\n");
7357 return TEST_SKIPPED;
7360 /* Create the session */
7362 retval = create_wireless_algo_cipher_auth_session(
7363 ts_params->valid_devs[0],
7364 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7365 RTE_CRYPTO_AUTH_OP_VERIFY,
7368 tdata->auth_key.data, tdata->auth_key.len,
7369 tdata->auth_iv.len, tdata->digest_enc.len,
7370 tdata->cipher_iv.len);
7372 retval = create_wireless_algo_auth_cipher_session(
7373 ts_params->valid_devs[0],
7374 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7375 RTE_CRYPTO_AUTH_OP_GENERATE,
7378 tdata->auth_key.data, tdata->auth_key.len,
7379 tdata->auth_iv.len, tdata->digest_enc.len,
7380 tdata->cipher_iv.len);
7384 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7385 if (op_mode == OUT_OF_PLACE)
7386 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7388 /* clear mbuf payload */
7389 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7390 rte_pktmbuf_tailroom(ut_params->ibuf));
7391 if (op_mode == OUT_OF_PLACE) {
7393 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7394 rte_pktmbuf_tailroom(ut_params->obuf));
7397 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7398 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7399 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7400 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7403 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7404 ciphertext_pad_len);
7405 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7406 debug_hexdump(stdout, "ciphertext:", ciphertext,
7409 /* make sure enough space to cover partial digest verify case */
7410 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7411 ciphertext_pad_len);
7412 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7413 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7416 if (op_mode == OUT_OF_PLACE)
7417 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7419 /* Create the operation */
7420 retval = create_wireless_algo_auth_cipher_operation(
7421 tdata->digest_enc.data, tdata->digest_enc.len,
7422 tdata->cipher_iv.data, tdata->cipher_iv.len,
7423 tdata->auth_iv.data, tdata->auth_iv.len,
7424 (tdata->digest_enc.offset == 0 ?
7426 : tdata->digest_enc.offset),
7427 tdata->validCipherLen.len_bits,
7428 tdata->cipher.offset_bits,
7429 tdata->validAuthLen.len_bits,
7430 tdata->auth.offset_bits,
7431 op_mode, 0, verify);
7436 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7438 /* Check if the op failed because the device doesn't */
7439 /* support this particular combination of algorithms */
7440 if (op == NULL && ut_params->op->status ==
7441 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7442 printf("Device doesn't support this mixed combination. "
7444 return TEST_SKIPPED;
7448 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7450 ut_params->obuf = (op_mode == IN_PLACE ?
7451 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7454 if (ut_params->obuf)
7455 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7458 plaintext = ciphertext +
7459 (tdata->cipher.offset_bits >> 3);
7461 debug_hexdump(stdout, "plaintext:", plaintext,
7462 tdata->plaintext.len_bits >> 3);
7463 debug_hexdump(stdout, "plaintext expected:",
7464 tdata->plaintext.data,
7465 tdata->plaintext.len_bits >> 3);
7467 if (ut_params->obuf)
7468 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7471 ciphertext = plaintext;
7473 debug_hexdump(stdout, "ciphertext:", ciphertext,
7475 debug_hexdump(stdout, "ciphertext expected:",
7476 tdata->ciphertext.data,
7477 tdata->ciphertext.len_bits >> 3);
7479 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7480 + (tdata->digest_enc.offset == 0 ?
7481 plaintext_pad_len : tdata->digest_enc.offset);
7483 debug_hexdump(stdout, "digest:", ut_params->digest,
7484 tdata->digest_enc.len);
7485 debug_hexdump(stdout, "digest expected:",
7486 tdata->digest_enc.data,
7487 tdata->digest_enc.len);
7491 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7493 tdata->digest_enc.data,
7494 tdata->digest_enc.len,
7495 "Generated auth tag not as expected");
7498 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7500 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7502 tdata->plaintext.data,
7503 tdata->plaintext.len_bits >> 3,
7504 "Plaintext data not as expected");
7506 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7508 tdata->ciphertext.data,
7509 tdata->validDataLen.len_bits,
7510 "Ciphertext data not as expected");
7514 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7515 "crypto op processing failed");
7521 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7522 uint8_t op_mode, uint8_t verify)
7524 struct crypto_testsuite_params *ts_params = &testsuite_params;
7525 struct crypto_unittest_params *ut_params = &unittest_params;
7529 const uint8_t *plaintext = NULL;
7530 const uint8_t *ciphertext = NULL;
7531 const uint8_t *digest = NULL;
7532 unsigned int plaintext_pad_len;
7533 unsigned int plaintext_len;
7534 unsigned int ciphertext_pad_len;
7535 unsigned int ciphertext_len;
7536 uint8_t buffer[10000];
7537 uint8_t digest_buffer[10000];
7539 struct rte_cryptodev_info dev_info;
7540 struct rte_crypto_op *op;
7542 /* Check if device supports particular algorithms */
7543 if (test_mixed_check_if_unsupported(tdata))
7544 return TEST_SKIPPED;
7545 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7546 return TEST_SKIPPED;
7548 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7550 uint64_t feat_flags = dev_info.feature_flags;
7552 if (op_mode == IN_PLACE) {
7553 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7554 printf("Device doesn't support in-place scatter-gather "
7555 "in both input and output mbufs.\n");
7556 return TEST_SKIPPED;
7559 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7560 printf("Device doesn't support out-of-place scatter-gather "
7561 "in both input and output mbufs.\n");
7562 return TEST_SKIPPED;
7564 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7565 printf("Device doesn't support digest encrypted.\n");
7566 return TEST_SKIPPED;
7570 /* Create the session */
7572 retval = create_wireless_algo_cipher_auth_session(
7573 ts_params->valid_devs[0],
7574 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7575 RTE_CRYPTO_AUTH_OP_VERIFY,
7578 tdata->auth_key.data, tdata->auth_key.len,
7579 tdata->auth_iv.len, tdata->digest_enc.len,
7580 tdata->cipher_iv.len);
7582 retval = create_wireless_algo_auth_cipher_session(
7583 ts_params->valid_devs[0],
7584 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7585 RTE_CRYPTO_AUTH_OP_GENERATE,
7588 tdata->auth_key.data, tdata->auth_key.len,
7589 tdata->auth_iv.len, tdata->digest_enc.len,
7590 tdata->cipher_iv.len);
7594 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7595 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7596 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7597 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7599 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7600 ciphertext_pad_len, 15, 0);
7601 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7602 "Failed to allocate input buffer in mempool");
7604 if (op_mode == OUT_OF_PLACE) {
7605 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7606 plaintext_pad_len, 15, 0);
7607 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7608 "Failed to allocate output buffer in mempool");
7612 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7613 tdata->ciphertext.data);
7614 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7615 ciphertext_len, buffer);
7616 debug_hexdump(stdout, "ciphertext:", ciphertext,
7619 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7620 tdata->plaintext.data);
7621 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7622 plaintext_len, buffer);
7623 debug_hexdump(stdout, "plaintext:", plaintext,
7626 memset(buffer, 0, sizeof(buffer));
7628 /* Create the operation */
7629 retval = create_wireless_algo_auth_cipher_operation(
7630 tdata->digest_enc.data, tdata->digest_enc.len,
7631 tdata->cipher_iv.data, tdata->cipher_iv.len,
7632 tdata->auth_iv.data, tdata->auth_iv.len,
7633 (tdata->digest_enc.offset == 0 ?
7635 : tdata->digest_enc.offset),
7636 tdata->validCipherLen.len_bits,
7637 tdata->cipher.offset_bits,
7638 tdata->validAuthLen.len_bits,
7639 tdata->auth.offset_bits,
7640 op_mode, 1, verify);
7645 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7647 /* Check if the op failed because the device doesn't */
7648 /* support this particular combination of algorithms */
7649 if (op == NULL && ut_params->op->status ==
7650 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7651 printf("Device doesn't support this mixed combination. "
7653 return TEST_SKIPPED;
7657 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7659 ut_params->obuf = (op_mode == IN_PLACE ?
7660 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7663 if (ut_params->obuf)
7664 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7665 plaintext_len, buffer);
7667 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7668 plaintext_len, buffer);
7670 debug_hexdump(stdout, "plaintext:", plaintext,
7671 (tdata->plaintext.len_bits >> 3) -
7672 tdata->digest_enc.len);
7673 debug_hexdump(stdout, "plaintext expected:",
7674 tdata->plaintext.data,
7675 (tdata->plaintext.len_bits >> 3) -
7676 tdata->digest_enc.len);
7678 if (ut_params->obuf)
7679 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7680 ciphertext_len, buffer);
7682 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7683 ciphertext_len, buffer);
7685 debug_hexdump(stdout, "ciphertext:", ciphertext,
7687 debug_hexdump(stdout, "ciphertext expected:",
7688 tdata->ciphertext.data,
7689 tdata->ciphertext.len_bits >> 3);
7691 if (ut_params->obuf)
7692 digest = rte_pktmbuf_read(ut_params->obuf,
7693 (tdata->digest_enc.offset == 0 ?
7695 tdata->digest_enc.offset),
7696 tdata->digest_enc.len, digest_buffer);
7698 digest = rte_pktmbuf_read(ut_params->ibuf,
7699 (tdata->digest_enc.offset == 0 ?
7701 tdata->digest_enc.offset),
7702 tdata->digest_enc.len, digest_buffer);
7704 debug_hexdump(stdout, "digest:", digest,
7705 tdata->digest_enc.len);
7706 debug_hexdump(stdout, "digest expected:",
7707 tdata->digest_enc.data, tdata->digest_enc.len);
7711 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7713 tdata->digest_enc.data,
7714 tdata->digest_enc.len,
7715 "Generated auth tag not as expected");
7718 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7720 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7722 tdata->plaintext.data,
7723 tdata->plaintext.len_bits >> 3,
7724 "Plaintext data not as expected");
7726 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7728 tdata->ciphertext.data,
7729 tdata->validDataLen.len_bits,
7730 "Ciphertext data not as expected");
7734 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7735 "crypto op processing failed");
7740 /** AUTH AES CMAC + CIPHER AES CTR */
7743 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7745 return test_mixed_auth_cipher(
7746 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7750 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7752 return test_mixed_auth_cipher(
7753 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7757 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7759 return test_mixed_auth_cipher_sgl(
7760 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7764 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7766 return test_mixed_auth_cipher_sgl(
7767 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7771 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7773 return test_mixed_auth_cipher(
7774 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7778 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7780 return test_mixed_auth_cipher(
7781 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7785 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7787 return test_mixed_auth_cipher_sgl(
7788 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7792 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7794 return test_mixed_auth_cipher_sgl(
7795 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7798 /** MIXED AUTH + CIPHER */
7801 test_auth_zuc_cipher_snow_test_case_1(void)
7803 return test_mixed_auth_cipher(
7804 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7808 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7810 return test_mixed_auth_cipher(
7811 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7815 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7817 return test_mixed_auth_cipher(
7818 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7822 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7824 return test_mixed_auth_cipher(
7825 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7829 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7831 return test_mixed_auth_cipher(
7832 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7836 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7838 return test_mixed_auth_cipher(
7839 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7843 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7845 return test_mixed_auth_cipher(
7846 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7850 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7852 return test_mixed_auth_cipher(
7853 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7857 test_auth_snow_cipher_zuc_test_case_1(void)
7859 return test_mixed_auth_cipher(
7860 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7864 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7866 return test_mixed_auth_cipher(
7867 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7871 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7873 return test_mixed_auth_cipher(
7874 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7878 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7880 return test_mixed_auth_cipher(
7881 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7885 test_auth_null_cipher_snow_test_case_1(void)
7887 return test_mixed_auth_cipher(
7888 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7892 test_verify_auth_null_cipher_snow_test_case_1(void)
7894 return test_mixed_auth_cipher(
7895 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7899 test_auth_null_cipher_zuc_test_case_1(void)
7901 return test_mixed_auth_cipher(
7902 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7906 test_verify_auth_null_cipher_zuc_test_case_1(void)
7908 return test_mixed_auth_cipher(
7909 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7913 test_auth_snow_cipher_null_test_case_1(void)
7915 return test_mixed_auth_cipher(
7916 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7920 test_verify_auth_snow_cipher_null_test_case_1(void)
7922 return test_mixed_auth_cipher(
7923 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7927 test_auth_zuc_cipher_null_test_case_1(void)
7929 return test_mixed_auth_cipher(
7930 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7934 test_verify_auth_zuc_cipher_null_test_case_1(void)
7936 return test_mixed_auth_cipher(
7937 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7941 test_auth_null_cipher_aes_ctr_test_case_1(void)
7943 return test_mixed_auth_cipher(
7944 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7948 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7950 return test_mixed_auth_cipher(
7951 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7955 test_auth_aes_cmac_cipher_null_test_case_1(void)
7957 return test_mixed_auth_cipher(
7958 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7962 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7964 return test_mixed_auth_cipher(
7965 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7968 /* ***** AEAD algorithm Tests ***** */
7971 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7972 enum rte_crypto_aead_operation op,
7973 const uint8_t *key, const uint8_t key_len,
7974 const uint16_t aad_len, const uint8_t auth_len,
7977 uint8_t aead_key[key_len];
7980 struct crypto_testsuite_params *ts_params = &testsuite_params;
7981 struct crypto_unittest_params *ut_params = &unittest_params;
7983 memcpy(aead_key, key, key_len);
7985 /* Setup AEAD Parameters */
7986 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7987 ut_params->aead_xform.next = NULL;
7988 ut_params->aead_xform.aead.algo = algo;
7989 ut_params->aead_xform.aead.op = op;
7990 ut_params->aead_xform.aead.key.data = aead_key;
7991 ut_params->aead_xform.aead.key.length = key_len;
7992 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7993 ut_params->aead_xform.aead.iv.length = iv_len;
7994 ut_params->aead_xform.aead.digest_length = auth_len;
7995 ut_params->aead_xform.aead.aad_length = aad_len;
7997 debug_hexdump(stdout, "key:", key, key_len);
7999 /* Create Crypto session*/
8000 ut_params->sess = rte_cryptodev_sym_session_create(
8001 ts_params->session_mpool);
8002 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8004 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8005 &ut_params->aead_xform,
8006 ts_params->session_priv_mpool);
8012 create_aead_xform(struct rte_crypto_op *op,
8013 enum rte_crypto_aead_algorithm algo,
8014 enum rte_crypto_aead_operation aead_op,
8015 uint8_t *key, const uint8_t key_len,
8016 const uint8_t aad_len, const uint8_t auth_len,
8019 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8020 "failed to allocate space for crypto transform");
8022 struct rte_crypto_sym_op *sym_op = op->sym;
8024 /* Setup AEAD Parameters */
8025 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8026 sym_op->xform->next = NULL;
8027 sym_op->xform->aead.algo = algo;
8028 sym_op->xform->aead.op = aead_op;
8029 sym_op->xform->aead.key.data = key;
8030 sym_op->xform->aead.key.length = key_len;
8031 sym_op->xform->aead.iv.offset = IV_OFFSET;
8032 sym_op->xform->aead.iv.length = iv_len;
8033 sym_op->xform->aead.digest_length = auth_len;
8034 sym_op->xform->aead.aad_length = aad_len;
8036 debug_hexdump(stdout, "key:", key, key_len);
8042 create_aead_operation(enum rte_crypto_aead_operation op,
8043 const struct aead_test_data *tdata)
8045 struct crypto_testsuite_params *ts_params = &testsuite_params;
8046 struct crypto_unittest_params *ut_params = &unittest_params;
8048 uint8_t *plaintext, *ciphertext;
8049 unsigned int aad_pad_len, plaintext_pad_len;
8051 /* Generate Crypto op data structure */
8052 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8053 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8054 TEST_ASSERT_NOT_NULL(ut_params->op,
8055 "Failed to allocate symmetric crypto operation struct");
8057 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8059 /* Append aad data */
8060 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8061 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8062 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8064 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8065 "no room to append aad");
8067 sym_op->aead.aad.phys_addr =
8068 rte_pktmbuf_iova(ut_params->ibuf);
8069 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8070 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8071 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8074 /* Append IV at the end of the crypto operation*/
8075 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8076 uint8_t *, IV_OFFSET);
8078 /* Copy IV 1 byte after the IV pointer, according to the API */
8079 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8080 debug_hexdump(stdout, "iv:", iv_ptr,
8083 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8084 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8086 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8087 "no room to append aad");
8089 sym_op->aead.aad.phys_addr =
8090 rte_pktmbuf_iova(ut_params->ibuf);
8091 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8092 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8095 /* Append IV at the end of the crypto operation*/
8096 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8097 uint8_t *, IV_OFFSET);
8099 if (tdata->iv.len == 0) {
8100 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8101 debug_hexdump(stdout, "iv:", iv_ptr,
8104 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8105 debug_hexdump(stdout, "iv:", iv_ptr,
8110 /* Append plaintext/ciphertext */
8111 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8112 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8113 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8115 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8117 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8118 debug_hexdump(stdout, "plaintext:", plaintext,
8119 tdata->plaintext.len);
8121 if (ut_params->obuf) {
8122 ciphertext = (uint8_t *)rte_pktmbuf_append(
8124 plaintext_pad_len + aad_pad_len);
8125 TEST_ASSERT_NOT_NULL(ciphertext,
8126 "no room to append ciphertext");
8128 memset(ciphertext + aad_pad_len, 0,
8129 tdata->ciphertext.len);
8132 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8133 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8135 TEST_ASSERT_NOT_NULL(ciphertext,
8136 "no room to append ciphertext");
8138 memcpy(ciphertext, tdata->ciphertext.data,
8139 tdata->ciphertext.len);
8140 debug_hexdump(stdout, "ciphertext:", ciphertext,
8141 tdata->ciphertext.len);
8143 if (ut_params->obuf) {
8144 plaintext = (uint8_t *)rte_pktmbuf_append(
8146 plaintext_pad_len + aad_pad_len);
8147 TEST_ASSERT_NOT_NULL(plaintext,
8148 "no room to append plaintext");
8150 memset(plaintext + aad_pad_len, 0,
8151 tdata->plaintext.len);
8155 /* Append digest data */
8156 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8157 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8158 ut_params->obuf ? ut_params->obuf :
8160 tdata->auth_tag.len);
8161 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8162 "no room to append digest");
8163 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8164 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8165 ut_params->obuf ? ut_params->obuf :
8170 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8171 ut_params->ibuf, tdata->auth_tag.len);
8172 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8173 "no room to append digest");
8174 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8176 plaintext_pad_len + aad_pad_len);
8178 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8179 tdata->auth_tag.len);
8180 debug_hexdump(stdout, "digest:",
8181 sym_op->aead.digest.data,
8182 tdata->auth_tag.len);
8185 sym_op->aead.data.length = tdata->plaintext.len;
8186 sym_op->aead.data.offset = aad_pad_len;
8192 test_authenticated_encryption(const struct aead_test_data *tdata)
8194 struct crypto_testsuite_params *ts_params = &testsuite_params;
8195 struct crypto_unittest_params *ut_params = &unittest_params;
8198 uint8_t *ciphertext, *auth_tag;
8199 uint16_t plaintext_pad_len;
8201 struct rte_cryptodev_info dev_info;
8203 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8204 uint64_t feat_flags = dev_info.feature_flags;
8206 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8207 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8208 printf("Device doesn't support RAW data-path APIs.\n");
8209 return TEST_SKIPPED;
8212 /* Verify the capabilities */
8213 struct rte_cryptodev_sym_capability_idx cap_idx;
8214 const struct rte_cryptodev_symmetric_capability *capability;
8215 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8216 cap_idx.algo.aead = tdata->algo;
8217 capability = rte_cryptodev_sym_capability_get(
8218 ts_params->valid_devs[0], &cap_idx);
8219 if (capability == NULL)
8220 return TEST_SKIPPED;
8221 if (rte_cryptodev_sym_capability_check_aead(
8222 capability, tdata->key.len, tdata->auth_tag.len,
8223 tdata->aad.len, tdata->iv.len))
8224 return TEST_SKIPPED;
8226 /* Create AEAD session */
8227 retval = create_aead_session(ts_params->valid_devs[0],
8229 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8230 tdata->key.data, tdata->key.len,
8231 tdata->aad.len, tdata->auth_tag.len,
8236 if (tdata->aad.len > MBUF_SIZE) {
8237 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8238 /* Populate full size of add data */
8239 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8240 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8242 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8244 /* clear mbuf payload */
8245 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8246 rte_pktmbuf_tailroom(ut_params->ibuf));
8248 /* Create AEAD operation */
8249 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8253 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8255 ut_params->op->sym->m_src = ut_params->ibuf;
8257 /* Process crypto operation */
8258 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8259 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8260 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8261 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8262 ut_params->op, 0, 0, 0, 0);
8264 TEST_ASSERT_NOT_NULL(
8265 process_crypto_request(ts_params->valid_devs[0],
8266 ut_params->op), "failed to process sym crypto op");
8268 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8269 "crypto op processing failed");
8271 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8273 if (ut_params->op->sym->m_dst) {
8274 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8276 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8277 uint8_t *, plaintext_pad_len);
8279 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8281 ut_params->op->sym->cipher.data.offset);
8282 auth_tag = ciphertext + plaintext_pad_len;
8285 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8286 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8289 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8291 tdata->ciphertext.data,
8292 tdata->ciphertext.len,
8293 "Ciphertext data not as expected");
8295 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8297 tdata->auth_tag.data,
8298 tdata->auth_tag.len,
8299 "Generated auth tag not as expected");
8305 #ifdef RTE_LIB_SECURITY
8307 security_proto_supported(enum rte_security_session_action_type action,
8308 enum rte_security_session_protocol proto)
8310 struct crypto_testsuite_params *ts_params = &testsuite_params;
8312 const struct rte_security_capability *capabilities;
8313 const struct rte_security_capability *capability;
8316 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8317 rte_cryptodev_get_sec_ctx(
8318 ts_params->valid_devs[0]);
8321 capabilities = rte_security_capabilities_get(ctx);
8323 if (capabilities == NULL)
8326 while ((capability = &capabilities[i++])->action !=
8327 RTE_SECURITY_ACTION_TYPE_NONE) {
8328 if (capability->action == action &&
8329 capability->protocol == proto)
8336 /* Basic algorithm run function for async inplace mode.
8337 * Creates a session from input parameters and runs one operation
8338 * on input_vec. Checks the output of the crypto operation against
8341 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8342 enum rte_crypto_auth_operation opa,
8343 const uint8_t *input_vec, unsigned int input_vec_len,
8344 const uint8_t *output_vec,
8345 unsigned int output_vec_len,
8346 enum rte_crypto_cipher_algorithm cipher_alg,
8347 const uint8_t *cipher_key, uint32_t cipher_key_len,
8348 enum rte_crypto_auth_algorithm auth_alg,
8349 const uint8_t *auth_key, uint32_t auth_key_len,
8350 uint8_t bearer, enum rte_security_pdcp_domain domain,
8351 uint8_t packet_direction, uint8_t sn_size,
8352 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8354 struct crypto_testsuite_params *ts_params = &testsuite_params;
8355 struct crypto_unittest_params *ut_params = &unittest_params;
8357 int ret = TEST_SUCCESS;
8358 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8359 rte_cryptodev_get_sec_ctx(
8360 ts_params->valid_devs[0]);
8362 /* Verify the capabilities */
8363 struct rte_security_capability_idx sec_cap_idx;
8365 sec_cap_idx.action = ut_params->type;
8366 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8367 sec_cap_idx.pdcp.domain = domain;
8368 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8369 return TEST_SKIPPED;
8371 /* Generate test mbuf data */
8372 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8374 /* clear mbuf payload */
8375 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8376 rte_pktmbuf_tailroom(ut_params->ibuf));
8378 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8380 memcpy(plaintext, input_vec, input_vec_len);
8382 /* Out of place support */
8385 * For out-op-place we need to alloc another mbuf
8387 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8388 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8391 /* Setup Cipher Parameters */
8392 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8393 ut_params->cipher_xform.cipher.algo = cipher_alg;
8394 ut_params->cipher_xform.cipher.op = opc;
8395 ut_params->cipher_xform.cipher.key.data = cipher_key;
8396 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8397 ut_params->cipher_xform.cipher.iv.length =
8398 packet_direction ? 4 : 0;
8399 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8401 /* Setup HMAC Parameters if ICV header is required */
8402 if (auth_alg != 0) {
8403 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8404 ut_params->auth_xform.next = NULL;
8405 ut_params->auth_xform.auth.algo = auth_alg;
8406 ut_params->auth_xform.auth.op = opa;
8407 ut_params->auth_xform.auth.key.data = auth_key;
8408 ut_params->auth_xform.auth.key.length = auth_key_len;
8410 ut_params->cipher_xform.next = &ut_params->auth_xform;
8412 ut_params->cipher_xform.next = NULL;
8415 struct rte_security_session_conf sess_conf = {
8416 .action_type = ut_params->type,
8417 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8421 .pkt_dir = packet_direction,
8423 .hfn = packet_direction ? 0 : hfn,
8425 * hfn can be set as pdcp_test_hfn[i]
8426 * if hfn_ovrd is not set. Here, PDCP
8427 * packet direction is just used to
8428 * run half of the cases with session
8429 * HFN and other half with per packet
8432 .hfn_threshold = hfn_threshold,
8433 .hfn_ovrd = packet_direction ? 1 : 0,
8434 .sdap_enabled = sdap,
8436 .crypto_xform = &ut_params->cipher_xform
8439 /* Create security session */
8440 ut_params->sec_session = rte_security_session_create(ctx,
8441 &sess_conf, ts_params->session_mpool,
8442 ts_params->session_priv_mpool);
8444 if (!ut_params->sec_session) {
8445 printf("TestCase %s()-%d line %d failed %s: ",
8446 __func__, i, __LINE__, "Failed to allocate session");
8451 /* Generate crypto op data structure */
8452 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8453 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8454 if (!ut_params->op) {
8455 printf("TestCase %s()-%d line %d failed %s: ",
8456 __func__, i, __LINE__,
8457 "Failed to allocate symmetric crypto operation struct");
8462 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8463 uint32_t *, IV_OFFSET);
8464 *per_pkt_hfn = packet_direction ? hfn : 0;
8466 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8468 /* set crypto operation source mbuf */
8469 ut_params->op->sym->m_src = ut_params->ibuf;
8471 ut_params->op->sym->m_dst = ut_params->obuf;
8473 /* Process crypto operation */
8474 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8476 printf("TestCase %s()-%d line %d failed %s: ",
8477 __func__, i, __LINE__,
8478 "failed to process sym crypto op");
8483 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8484 printf("TestCase %s()-%d line %d failed %s: ",
8485 __func__, i, __LINE__, "crypto op processing failed");
8491 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8494 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8498 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8499 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8500 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8501 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8507 rte_crypto_op_free(ut_params->op);
8508 ut_params->op = NULL;
8510 if (ut_params->sec_session)
8511 rte_security_session_destroy(ctx, ut_params->sec_session);
8512 ut_params->sec_session = NULL;
8514 rte_pktmbuf_free(ut_params->ibuf);
8515 ut_params->ibuf = NULL;
8517 rte_pktmbuf_free(ut_params->obuf);
8518 ut_params->obuf = NULL;
8525 test_pdcp_proto_SGL(int i, int oop,
8526 enum rte_crypto_cipher_operation opc,
8527 enum rte_crypto_auth_operation opa,
8529 unsigned int input_vec_len,
8530 uint8_t *output_vec,
8531 unsigned int output_vec_len,
8533 uint32_t fragsz_oop)
8535 struct crypto_testsuite_params *ts_params = &testsuite_params;
8536 struct crypto_unittest_params *ut_params = &unittest_params;
8538 struct rte_mbuf *buf, *buf_oop = NULL;
8539 int ret = TEST_SUCCESS;
8543 unsigned int trn_data = 0;
8544 struct rte_cryptodev_info dev_info;
8545 uint64_t feat_flags;
8546 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8547 rte_cryptodev_get_sec_ctx(
8548 ts_params->valid_devs[0]);
8549 struct rte_mbuf *temp_mbuf;
8551 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8552 feat_flags = dev_info.feature_flags;
8554 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8555 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8556 printf("Device does not support RAW data-path APIs.\n");
8559 /* Verify the capabilities */
8560 struct rte_security_capability_idx sec_cap_idx;
8562 sec_cap_idx.action = ut_params->type;
8563 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8564 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8565 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8566 return TEST_SKIPPED;
8568 if (fragsz > input_vec_len)
8569 fragsz = input_vec_len;
8571 uint16_t plaintext_len = fragsz;
8572 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8574 if (fragsz_oop > output_vec_len)
8575 frag_size_oop = output_vec_len;
8578 if (input_vec_len % fragsz != 0) {
8579 if (input_vec_len / fragsz + 1 > 16)
8581 } else if (input_vec_len / fragsz > 16)
8584 /* Out of place support */
8587 * For out-op-place we need to alloc another mbuf
8589 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8590 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8591 buf_oop = ut_params->obuf;
8594 /* Generate test mbuf data */
8595 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8597 /* clear mbuf payload */
8598 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8599 rte_pktmbuf_tailroom(ut_params->ibuf));
8601 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8603 memcpy(plaintext, input_vec, plaintext_len);
8604 trn_data += plaintext_len;
8606 buf = ut_params->ibuf;
8609 * Loop until no more fragments
8612 while (trn_data < input_vec_len) {
8614 to_trn = (input_vec_len - trn_data < fragsz) ?
8615 (input_vec_len - trn_data) : fragsz;
8617 to_trn_tbl[ecx++] = to_trn;
8619 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8622 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8623 rte_pktmbuf_tailroom(buf));
8626 if (oop && !fragsz_oop) {
8628 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8629 buf_oop = buf_oop->next;
8630 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8631 0, rte_pktmbuf_tailroom(buf_oop));
8632 rte_pktmbuf_append(buf_oop, to_trn);
8635 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8638 memcpy(plaintext, input_vec + trn_data, to_trn);
8642 ut_params->ibuf->nb_segs = segs;
8645 if (fragsz_oop && oop) {
8649 trn_data = frag_size_oop;
8650 while (trn_data < output_vec_len) {
8653 (output_vec_len - trn_data <
8655 (output_vec_len - trn_data) :
8658 to_trn_tbl[ecx++] = to_trn;
8661 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8662 buf_oop = buf_oop->next;
8663 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8664 0, rte_pktmbuf_tailroom(buf_oop));
8665 rte_pktmbuf_append(buf_oop, to_trn);
8669 ut_params->obuf->nb_segs = segs;
8672 /* Setup Cipher Parameters */
8673 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8674 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8675 ut_params->cipher_xform.cipher.op = opc;
8676 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8677 ut_params->cipher_xform.cipher.key.length =
8678 pdcp_test_params[i].cipher_key_len;
8679 ut_params->cipher_xform.cipher.iv.length = 0;
8681 /* Setup HMAC Parameters if ICV header is required */
8682 if (pdcp_test_params[i].auth_alg != 0) {
8683 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8684 ut_params->auth_xform.next = NULL;
8685 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8686 ut_params->auth_xform.auth.op = opa;
8687 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8688 ut_params->auth_xform.auth.key.length =
8689 pdcp_test_params[i].auth_key_len;
8691 ut_params->cipher_xform.next = &ut_params->auth_xform;
8693 ut_params->cipher_xform.next = NULL;
8696 struct rte_security_session_conf sess_conf = {
8697 .action_type = ut_params->type,
8698 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8700 .bearer = pdcp_test_bearer[i],
8701 .domain = pdcp_test_params[i].domain,
8702 .pkt_dir = pdcp_test_packet_direction[i],
8703 .sn_size = pdcp_test_data_sn_size[i],
8704 .hfn = pdcp_test_hfn[i],
8705 .hfn_threshold = pdcp_test_hfn_threshold[i],
8708 .crypto_xform = &ut_params->cipher_xform
8711 /* Create security session */
8712 ut_params->sec_session = rte_security_session_create(ctx,
8713 &sess_conf, ts_params->session_mpool,
8714 ts_params->session_priv_mpool);
8716 if (!ut_params->sec_session) {
8717 printf("TestCase %s()-%d line %d failed %s: ",
8718 __func__, i, __LINE__, "Failed to allocate session");
8723 /* Generate crypto op data structure */
8724 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8725 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8726 if (!ut_params->op) {
8727 printf("TestCase %s()-%d line %d failed %s: ",
8728 __func__, i, __LINE__,
8729 "Failed to allocate symmetric crypto operation struct");
8734 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8736 /* set crypto operation source mbuf */
8737 ut_params->op->sym->m_src = ut_params->ibuf;
8739 ut_params->op->sym->m_dst = ut_params->obuf;
8741 /* Process crypto operation */
8742 temp_mbuf = ut_params->op->sym->m_src;
8743 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8744 /* filling lengths */
8746 ut_params->op->sym->cipher.data.length
8747 += temp_mbuf->pkt_len;
8748 ut_params->op->sym->auth.data.length
8749 += temp_mbuf->pkt_len;
8750 temp_mbuf = temp_mbuf->next;
8752 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8753 ut_params->op, 1, 1, 0, 0);
8755 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8758 if (ut_params->op == NULL) {
8759 printf("TestCase %s()-%d line %d failed %s: ",
8760 __func__, i, __LINE__,
8761 "failed to process sym crypto op");
8766 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8767 printf("TestCase %s()-%d line %d failed %s: ",
8768 __func__, i, __LINE__, "crypto op processing failed");
8774 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8777 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8781 fragsz = frag_size_oop;
8782 if (memcmp(ciphertext, output_vec, fragsz)) {
8783 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8784 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8785 rte_hexdump(stdout, "reference", output_vec, fragsz);
8790 buf = ut_params->op->sym->m_src->next;
8792 buf = ut_params->op->sym->m_dst->next;
8794 unsigned int off = fragsz;
8798 ciphertext = rte_pktmbuf_mtod(buf,
8800 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8801 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8802 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8803 rte_hexdump(stdout, "reference", output_vec + off,
8808 off += to_trn_tbl[ecx++];
8812 rte_crypto_op_free(ut_params->op);
8813 ut_params->op = NULL;
8815 if (ut_params->sec_session)
8816 rte_security_session_destroy(ctx, ut_params->sec_session);
8817 ut_params->sec_session = NULL;
8819 rte_pktmbuf_free(ut_params->ibuf);
8820 ut_params->ibuf = NULL;
8822 rte_pktmbuf_free(ut_params->obuf);
8823 ut_params->obuf = NULL;
8830 test_pdcp_proto_cplane_encap(int i)
8832 return test_pdcp_proto(
8833 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8834 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8835 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8836 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8837 pdcp_test_params[i].cipher_key_len,
8838 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8839 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8840 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8841 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8842 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8846 test_pdcp_proto_uplane_encap(int i)
8848 return test_pdcp_proto(
8849 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8850 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8851 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8852 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8853 pdcp_test_params[i].cipher_key_len,
8854 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8855 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8856 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8857 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8858 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8862 test_pdcp_proto_uplane_encap_with_int(int i)
8864 return test_pdcp_proto(
8865 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8866 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8867 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8868 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8869 pdcp_test_params[i].cipher_key_len,
8870 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8871 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8872 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8873 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8874 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8878 test_pdcp_proto_cplane_decap(int i)
8880 return test_pdcp_proto(
8881 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8882 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8883 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8884 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8885 pdcp_test_params[i].cipher_key_len,
8886 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8887 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8888 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8889 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8890 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8894 test_pdcp_proto_uplane_decap(int i)
8896 return test_pdcp_proto(
8897 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8898 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8899 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8900 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8901 pdcp_test_params[i].cipher_key_len,
8902 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8903 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8904 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8905 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8906 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8910 test_pdcp_proto_uplane_decap_with_int(int i)
8912 return test_pdcp_proto(
8913 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8914 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8915 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8916 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8917 pdcp_test_params[i].cipher_key_len,
8918 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8919 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8920 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8921 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8922 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8926 test_PDCP_PROTO_SGL_in_place_32B(void)
8928 /* i can be used for running any PDCP case
8929 * In this case it is uplane 12-bit AES-SNOW DL encap
8931 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8932 return test_pdcp_proto_SGL(i, IN_PLACE,
8933 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8934 RTE_CRYPTO_AUTH_OP_GENERATE,
8935 pdcp_test_data_in[i],
8936 pdcp_test_data_in_len[i],
8937 pdcp_test_data_out[i],
8938 pdcp_test_data_in_len[i]+4,
8942 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8944 /* i can be used for running any PDCP case
8945 * In this case it is uplane 18-bit NULL-NULL DL encap
8947 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8948 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8949 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8950 RTE_CRYPTO_AUTH_OP_GENERATE,
8951 pdcp_test_data_in[i],
8952 pdcp_test_data_in_len[i],
8953 pdcp_test_data_out[i],
8954 pdcp_test_data_in_len[i]+4,
8958 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8960 /* i can be used for running any PDCP case
8961 * In this case it is uplane 18-bit AES DL encap
8963 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8965 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8966 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8967 RTE_CRYPTO_AUTH_OP_GENERATE,
8968 pdcp_test_data_in[i],
8969 pdcp_test_data_in_len[i],
8970 pdcp_test_data_out[i],
8971 pdcp_test_data_in_len[i],
8975 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8977 /* i can be used for running any PDCP case
8978 * In this case it is cplane 12-bit AES-ZUC DL encap
8980 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8981 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8982 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8983 RTE_CRYPTO_AUTH_OP_GENERATE,
8984 pdcp_test_data_in[i],
8985 pdcp_test_data_in_len[i],
8986 pdcp_test_data_out[i],
8987 pdcp_test_data_in_len[i]+4,
8992 test_PDCP_SDAP_PROTO_encap_all(void)
8994 int i = 0, size = 0;
8995 int err, all_err = TEST_SUCCESS;
8996 const struct pdcp_sdap_test *cur_test;
8998 size = RTE_DIM(list_pdcp_sdap_tests);
9000 for (i = 0; i < size; i++) {
9001 cur_test = &list_pdcp_sdap_tests[i];
9002 err = test_pdcp_proto(
9003 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9004 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9005 cur_test->in_len, cur_test->data_out,
9006 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9007 cur_test->param.cipher_alg, cur_test->cipher_key,
9008 cur_test->param.cipher_key_len,
9009 cur_test->param.auth_alg,
9010 cur_test->auth_key, cur_test->param.auth_key_len,
9011 cur_test->bearer, cur_test->param.domain,
9012 cur_test->packet_direction, cur_test->sn_size,
9014 cur_test->hfn_threshold, SDAP_ENABLED);
9016 printf("\t%d) %s: Encapsulation failed\n",
9018 cur_test->param.name);
9021 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9022 cur_test->param.name);
9028 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9030 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9034 test_PDCP_PROTO_short_mac(void)
9036 int i = 0, size = 0;
9037 int err, all_err = TEST_SUCCESS;
9038 const struct pdcp_short_mac_test *cur_test;
9040 size = RTE_DIM(list_pdcp_smac_tests);
9042 for (i = 0; i < size; i++) {
9043 cur_test = &list_pdcp_smac_tests[i];
9044 err = test_pdcp_proto(
9045 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9046 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9047 cur_test->in_len, cur_test->data_out,
9048 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9049 RTE_CRYPTO_CIPHER_NULL, NULL,
9050 0, cur_test->param.auth_alg,
9051 cur_test->auth_key, cur_test->param.auth_key_len,
9052 0, cur_test->param.domain, 0, 0,
9055 printf("\t%d) %s: Short MAC test failed\n",
9057 cur_test->param.name);
9060 printf("\t%d) %s: Short MAC test PASS\n",
9062 cur_test->param.name);
9063 rte_hexdump(stdout, "MAC I",
9064 cur_test->data_out + cur_test->in_len + 2,
9071 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9073 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9078 test_PDCP_SDAP_PROTO_decap_all(void)
9080 int i = 0, size = 0;
9081 int err, all_err = TEST_SUCCESS;
9082 const struct pdcp_sdap_test *cur_test;
9084 size = RTE_DIM(list_pdcp_sdap_tests);
9086 for (i = 0; i < size; i++) {
9087 cur_test = &list_pdcp_sdap_tests[i];
9088 err = test_pdcp_proto(
9089 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9090 RTE_CRYPTO_AUTH_OP_VERIFY,
9092 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9093 cur_test->data_in, cur_test->in_len,
9094 cur_test->param.cipher_alg,
9095 cur_test->cipher_key, cur_test->param.cipher_key_len,
9096 cur_test->param.auth_alg, cur_test->auth_key,
9097 cur_test->param.auth_key_len, cur_test->bearer,
9098 cur_test->param.domain, cur_test->packet_direction,
9099 cur_test->sn_size, cur_test->hfn,
9100 cur_test->hfn_threshold, SDAP_ENABLED);
9102 printf("\t%d) %s: Decapsulation failed\n",
9104 cur_test->param.name);
9107 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9108 cur_test->param.name);
9114 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9116 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9120 test_ipsec_proto_process(const struct ipsec_test_data td[],
9121 struct ipsec_test_data res_d[],
9124 const struct ipsec_test_flags *flags)
9126 struct crypto_testsuite_params *ts_params = &testsuite_params;
9127 struct crypto_unittest_params *ut_params = &unittest_params;
9128 struct rte_security_capability_idx sec_cap_idx;
9129 const struct rte_security_capability *sec_cap;
9130 struct rte_security_ipsec_xform ipsec_xform;
9131 uint8_t dev_id = ts_params->valid_devs[0];
9132 enum rte_security_ipsec_sa_direction dir;
9133 struct ipsec_test_data *res_d_tmp = NULL;
9134 uint32_t src = RTE_IPV4(192, 168, 1, 0);
9135 uint32_t dst = RTE_IPV4(192, 168, 1, 1);
9136 int salt_len, i, ret = TEST_SUCCESS;
9137 struct rte_security_ctx *ctx;
9138 uint8_t *input_text;
9141 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9142 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9144 /* Use first test data to create session */
9146 /* Copy IPsec xform */
9147 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9149 dir = ipsec_xform.direction;
9150 verify = flags->tunnel_hdr_verify;
9152 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9153 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9155 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9159 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src, sizeof(src));
9160 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst, sizeof(dst));
9162 ctx = rte_cryptodev_get_sec_ctx(dev_id);
9164 sec_cap_idx.action = ut_params->type;
9165 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9166 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9167 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9168 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9170 if (flags->udp_encap)
9171 ipsec_xform.options.udp_encap = 1;
9173 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9174 if (sec_cap == NULL)
9175 return TEST_SKIPPED;
9177 /* Copy cipher session parameters */
9179 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9180 sizeof(ut_params->aead_xform));
9181 ut_params->aead_xform.aead.key.data = td[0].key.data;
9182 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9184 /* Verify crypto capabilities */
9185 if (test_ipsec_crypto_caps_aead_verify(
9187 &ut_params->aead_xform) != 0) {
9189 RTE_LOG(INFO, USER1,
9190 "Crypto capabilities not supported\n");
9191 return TEST_SKIPPED;
9194 /* Only AEAD supported now */
9195 return TEST_SKIPPED;
9198 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9199 return TEST_SKIPPED;
9201 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9202 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9204 struct rte_security_session_conf sess_conf = {
9205 .action_type = ut_params->type,
9206 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9207 .ipsec = ipsec_xform,
9208 .crypto_xform = &ut_params->aead_xform,
9211 /* Create security session */
9212 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9213 ts_params->session_mpool,
9214 ts_params->session_priv_mpool);
9216 if (ut_params->sec_session == NULL)
9217 return TEST_SKIPPED;
9219 for (i = 0; i < nb_td; i++) {
9220 /* Setup source mbuf payload */
9221 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9222 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9223 rte_pktmbuf_tailroom(ut_params->ibuf));
9225 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9226 td[i].input_text.len);
9228 memcpy(input_text, td[i].input_text.data,
9229 td[i].input_text.len);
9231 /* Generate crypto op data structure */
9232 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9233 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9234 if (!ut_params->op) {
9235 printf("TestCase %s line %d: %s\n",
9237 "failed to allocate crypto op");
9239 goto crypto_op_free;
9242 /* Attach session to operation */
9243 rte_security_attach_session(ut_params->op,
9244 ut_params->sec_session);
9246 /* Set crypto operation mbufs */
9247 ut_params->op->sym->m_src = ut_params->ibuf;
9248 ut_params->op->sym->m_dst = NULL;
9250 /* Copy IV in crypto operation when IV generation is disabled */
9251 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9252 ipsec_xform.options.iv_gen_disable == 1) {
9253 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9259 len = td[i].xform.aead.aead.iv.length;
9261 len = td[i].xform.chain.cipher.cipher.iv.length;
9263 memcpy(iv, td[i].iv.data, len);
9266 /* Process crypto operation */
9267 process_crypto_request(dev_id, ut_params->op);
9269 ret = test_ipsec_status_check(ut_params->op, flags, dir, i + 1);
9270 if (ret != TEST_SUCCESS)
9271 goto crypto_op_free;
9274 res_d_tmp = &res_d[i];
9276 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9277 res_d_tmp, silent, flags);
9278 if (ret != TEST_SUCCESS)
9279 goto crypto_op_free;
9281 rte_crypto_op_free(ut_params->op);
9282 ut_params->op = NULL;
9284 rte_pktmbuf_free(ut_params->ibuf);
9285 ut_params->ibuf = NULL;
9289 rte_crypto_op_free(ut_params->op);
9290 ut_params->op = NULL;
9292 rte_pktmbuf_free(ut_params->ibuf);
9293 ut_params->ibuf = NULL;
9295 if (ut_params->sec_session)
9296 rte_security_session_destroy(ctx, ut_params->sec_session);
9297 ut_params->sec_session = NULL;
9303 test_ipsec_proto_known_vec(const void *test_data)
9305 struct ipsec_test_data td_outb;
9306 struct ipsec_test_flags flags;
9308 memset(&flags, 0, sizeof(flags));
9310 memcpy(&td_outb, test_data, sizeof(td_outb));
9312 /* Disable IV gen to be able to test with known vectors */
9313 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9315 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9319 test_ipsec_proto_known_vec_inb(const void *td_outb)
9321 struct ipsec_test_flags flags;
9322 struct ipsec_test_data td_inb;
9324 memset(&flags, 0, sizeof(flags));
9326 test_ipsec_td_in_from_out(td_outb, &td_inb);
9328 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9332 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9334 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9335 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9336 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9339 if (flags->iv_gen ||
9340 flags->sa_expiry_pkts_soft ||
9341 flags->sa_expiry_pkts_hard)
9342 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9344 for (i = 0; i < RTE_DIM(aead_list); i++) {
9345 test_ipsec_td_prepare(&aead_list[i],
9351 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9353 if (ret == TEST_SKIPPED)
9356 if (ret == TEST_FAILED)
9359 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9361 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9363 if (ret == TEST_SKIPPED)
9366 if (ret == TEST_FAILED)
9369 if (flags->display_alg)
9370 test_ipsec_display_alg(&aead_list[i], NULL);
9376 return TEST_SUCCESS;
9378 return TEST_SKIPPED;
9382 test_ipsec_proto_display_list(const void *data __rte_unused)
9384 struct ipsec_test_flags flags;
9386 memset(&flags, 0, sizeof(flags));
9388 flags.display_alg = true;
9390 return test_ipsec_proto_all(&flags);
9394 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9396 struct ipsec_test_flags flags;
9398 memset(&flags, 0, sizeof(flags));
9400 flags.iv_gen = true;
9402 return test_ipsec_proto_all(&flags);
9406 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9408 struct ipsec_test_flags flags;
9410 memset(&flags, 0, sizeof(flags));
9412 flags.sa_expiry_pkts_soft = true;
9414 return test_ipsec_proto_all(&flags);
9418 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9420 struct ipsec_test_flags flags;
9422 memset(&flags, 0, sizeof(flags));
9424 flags.sa_expiry_pkts_hard = true;
9426 return test_ipsec_proto_all(&flags);
9430 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9432 struct ipsec_test_flags flags;
9434 memset(&flags, 0, sizeof(flags));
9436 flags.icv_corrupt = true;
9438 return test_ipsec_proto_all(&flags);
9442 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9444 struct ipsec_test_flags flags;
9446 memset(&flags, 0, sizeof(flags));
9448 flags.udp_encap = true;
9450 return test_ipsec_proto_all(&flags);
9454 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9456 struct ipsec_test_flags flags;
9458 memset(&flags, 0, sizeof(flags));
9460 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9462 return test_ipsec_proto_all(&flags);
9466 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9468 struct ipsec_test_flags flags;
9470 memset(&flags, 0, sizeof(flags));
9472 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9474 return test_ipsec_proto_all(&flags);
9478 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9480 struct ipsec_test_flags flags;
9482 memset(&flags, 0, sizeof(flags));
9484 flags.udp_encap = true;
9485 flags.udp_ports_verify = true;
9487 return test_ipsec_proto_all(&flags);
9491 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9493 struct ipsec_test_flags flags;
9495 memset(&flags, 0, sizeof(flags));
9497 flags.ip_csum = true;
9499 return test_ipsec_proto_all(&flags);
9503 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9505 struct ipsec_test_flags flags;
9507 memset(&flags, 0, sizeof(flags));
9509 flags.l4_csum = true;
9511 return test_ipsec_proto_all(&flags);
9515 test_PDCP_PROTO_all(void)
9517 struct crypto_testsuite_params *ts_params = &testsuite_params;
9518 struct crypto_unittest_params *ut_params = &unittest_params;
9519 struct rte_cryptodev_info dev_info;
9522 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9523 uint64_t feat_flags = dev_info.feature_flags;
9525 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9526 return TEST_SKIPPED;
9528 /* Set action type */
9529 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9530 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9533 if (security_proto_supported(ut_params->type,
9534 RTE_SECURITY_PROTOCOL_PDCP) < 0)
9535 return TEST_SKIPPED;
9537 status = test_PDCP_PROTO_cplane_encap_all();
9538 status += test_PDCP_PROTO_cplane_decap_all();
9539 status += test_PDCP_PROTO_uplane_encap_all();
9540 status += test_PDCP_PROTO_uplane_decap_all();
9541 status += test_PDCP_PROTO_SGL_in_place_32B();
9542 status += test_PDCP_PROTO_SGL_oop_32B_128B();
9543 status += test_PDCP_PROTO_SGL_oop_32B_40B();
9544 status += test_PDCP_PROTO_SGL_oop_128B_32B();
9545 status += test_PDCP_SDAP_PROTO_encap_all();
9546 status += test_PDCP_SDAP_PROTO_decap_all();
9547 status += test_PDCP_PROTO_short_mac();
9552 return TEST_SUCCESS;
9556 test_docsis_proto_uplink(const void *data)
9558 const struct docsis_test_data *d_td = data;
9559 struct crypto_testsuite_params *ts_params = &testsuite_params;
9560 struct crypto_unittest_params *ut_params = &unittest_params;
9561 uint8_t *plaintext = NULL;
9562 uint8_t *ciphertext = NULL;
9564 int32_t cipher_len, crc_len;
9565 uint32_t crc_data_len;
9566 int ret = TEST_SUCCESS;
9568 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9569 rte_cryptodev_get_sec_ctx(
9570 ts_params->valid_devs[0]);
9572 /* Verify the capabilities */
9573 struct rte_security_capability_idx sec_cap_idx;
9574 const struct rte_security_capability *sec_cap;
9575 const struct rte_cryptodev_capabilities *crypto_cap;
9576 const struct rte_cryptodev_symmetric_capability *sym_cap;
9579 /* Set action type */
9580 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9581 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9584 if (security_proto_supported(ut_params->type,
9585 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9586 return TEST_SKIPPED;
9588 sec_cap_idx.action = ut_params->type;
9589 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9590 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9592 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9593 if (sec_cap == NULL)
9594 return TEST_SKIPPED;
9596 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9597 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9598 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9599 crypto_cap->sym.xform_type ==
9600 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9601 crypto_cap->sym.cipher.algo ==
9602 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9603 sym_cap = &crypto_cap->sym;
9604 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9611 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9612 return TEST_SKIPPED;
9614 /* Setup source mbuf payload */
9615 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9616 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9617 rte_pktmbuf_tailroom(ut_params->ibuf));
9619 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9620 d_td->ciphertext.len);
9622 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
9624 /* Setup cipher session parameters */
9625 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9626 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9627 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
9628 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9629 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9630 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9631 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9632 ut_params->cipher_xform.next = NULL;
9634 /* Setup DOCSIS session parameters */
9635 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9637 struct rte_security_session_conf sess_conf = {
9638 .action_type = ut_params->type,
9639 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9640 .docsis = ut_params->docsis_xform,
9641 .crypto_xform = &ut_params->cipher_xform,
9644 /* Create security session */
9645 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9646 ts_params->session_mpool,
9647 ts_params->session_priv_mpool);
9649 if (!ut_params->sec_session) {
9650 printf("Test function %s line %u: failed to allocate session\n",
9651 __func__, __LINE__);
9656 /* Generate crypto op data structure */
9657 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9658 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9659 if (!ut_params->op) {
9660 printf("Test function %s line %u: failed to allocate symmetric "
9661 "crypto operation\n", __func__, __LINE__);
9666 /* Setup CRC operation parameters */
9667 crc_len = d_td->ciphertext.no_crc == false ?
9668 (d_td->ciphertext.len -
9669 d_td->ciphertext.crc_offset -
9670 RTE_ETHER_CRC_LEN) :
9672 crc_len = crc_len > 0 ? crc_len : 0;
9673 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9674 ut_params->op->sym->auth.data.length = crc_len;
9675 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9677 /* Setup cipher operation parameters */
9678 cipher_len = d_td->ciphertext.no_cipher == false ?
9679 (d_td->ciphertext.len -
9680 d_td->ciphertext.cipher_offset) :
9682 cipher_len = cipher_len > 0 ? cipher_len : 0;
9683 ut_params->op->sym->cipher.data.length = cipher_len;
9684 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9686 /* Setup cipher IV */
9687 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9688 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9690 /* Attach session to operation */
9691 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9693 /* Set crypto operation mbufs */
9694 ut_params->op->sym->m_src = ut_params->ibuf;
9695 ut_params->op->sym->m_dst = NULL;
9697 /* Process crypto operation */
9698 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9700 printf("Test function %s line %u: failed to process security "
9701 "crypto op\n", __func__, __LINE__);
9706 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9707 printf("Test function %s line %u: failed to process crypto op\n",
9708 __func__, __LINE__);
9713 /* Validate plaintext */
9714 plaintext = ciphertext;
9716 if (memcmp(plaintext, d_td->plaintext.data,
9717 d_td->plaintext.len - crc_data_len)) {
9718 printf("Test function %s line %u: plaintext not as expected\n",
9719 __func__, __LINE__);
9720 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9721 d_td->plaintext.len);
9722 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9728 rte_crypto_op_free(ut_params->op);
9729 ut_params->op = NULL;
9731 if (ut_params->sec_session)
9732 rte_security_session_destroy(ctx, ut_params->sec_session);
9733 ut_params->sec_session = NULL;
9735 rte_pktmbuf_free(ut_params->ibuf);
9736 ut_params->ibuf = NULL;
9742 test_docsis_proto_downlink(const void *data)
9744 const struct docsis_test_data *d_td = data;
9745 struct crypto_testsuite_params *ts_params = &testsuite_params;
9746 struct crypto_unittest_params *ut_params = &unittest_params;
9747 uint8_t *plaintext = NULL;
9748 uint8_t *ciphertext = NULL;
9750 int32_t cipher_len, crc_len;
9751 int ret = TEST_SUCCESS;
9753 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9754 rte_cryptodev_get_sec_ctx(
9755 ts_params->valid_devs[0]);
9757 /* Verify the capabilities */
9758 struct rte_security_capability_idx sec_cap_idx;
9759 const struct rte_security_capability *sec_cap;
9760 const struct rte_cryptodev_capabilities *crypto_cap;
9761 const struct rte_cryptodev_symmetric_capability *sym_cap;
9764 /* Set action type */
9765 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9766 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9769 if (security_proto_supported(ut_params->type,
9770 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9771 return TEST_SKIPPED;
9773 sec_cap_idx.action = ut_params->type;
9774 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9775 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9777 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9778 if (sec_cap == NULL)
9779 return TEST_SKIPPED;
9781 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9782 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9783 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9784 crypto_cap->sym.xform_type ==
9785 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9786 crypto_cap->sym.cipher.algo ==
9787 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9788 sym_cap = &crypto_cap->sym;
9789 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9796 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9797 return TEST_SKIPPED;
9799 /* Setup source mbuf payload */
9800 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9801 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9802 rte_pktmbuf_tailroom(ut_params->ibuf));
9804 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9805 d_td->plaintext.len);
9807 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9809 /* Setup cipher session parameters */
9810 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9811 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9812 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9813 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9814 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9815 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9816 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9817 ut_params->cipher_xform.next = NULL;
9819 /* Setup DOCSIS session parameters */
9820 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9822 struct rte_security_session_conf sess_conf = {
9823 .action_type = ut_params->type,
9824 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9825 .docsis = ut_params->docsis_xform,
9826 .crypto_xform = &ut_params->cipher_xform,
9829 /* Create security session */
9830 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9831 ts_params->session_mpool,
9832 ts_params->session_priv_mpool);
9834 if (!ut_params->sec_session) {
9835 printf("Test function %s line %u: failed to allocate session\n",
9836 __func__, __LINE__);
9841 /* Generate crypto op data structure */
9842 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9843 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9844 if (!ut_params->op) {
9845 printf("Test function %s line %u: failed to allocate symmetric "
9846 "crypto operation\n", __func__, __LINE__);
9851 /* Setup CRC operation parameters */
9852 crc_len = d_td->plaintext.no_crc == false ?
9853 (d_td->plaintext.len -
9854 d_td->plaintext.crc_offset -
9855 RTE_ETHER_CRC_LEN) :
9857 crc_len = crc_len > 0 ? crc_len : 0;
9858 ut_params->op->sym->auth.data.length = crc_len;
9859 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9861 /* Setup cipher operation parameters */
9862 cipher_len = d_td->plaintext.no_cipher == false ?
9863 (d_td->plaintext.len -
9864 d_td->plaintext.cipher_offset) :
9866 cipher_len = cipher_len > 0 ? cipher_len : 0;
9867 ut_params->op->sym->cipher.data.length = cipher_len;
9868 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9870 /* Setup cipher IV */
9871 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9872 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9874 /* Attach session to operation */
9875 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9877 /* Set crypto operation mbufs */
9878 ut_params->op->sym->m_src = ut_params->ibuf;
9879 ut_params->op->sym->m_dst = NULL;
9881 /* Process crypto operation */
9882 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9884 printf("Test function %s line %u: failed to process crypto op\n",
9885 __func__, __LINE__);
9890 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9891 printf("Test function %s line %u: crypto op processing failed\n",
9892 __func__, __LINE__);
9897 /* Validate ciphertext */
9898 ciphertext = plaintext;
9900 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9901 printf("Test function %s line %u: plaintext not as expected\n",
9902 __func__, __LINE__);
9903 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9904 d_td->ciphertext.len);
9905 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9911 rte_crypto_op_free(ut_params->op);
9912 ut_params->op = NULL;
9914 if (ut_params->sec_session)
9915 rte_security_session_destroy(ctx, ut_params->sec_session);
9916 ut_params->sec_session = NULL;
9918 rte_pktmbuf_free(ut_params->ibuf);
9919 ut_params->ibuf = NULL;
9926 test_AES_GCM_authenticated_encryption_test_case_1(void)
9928 return test_authenticated_encryption(&gcm_test_case_1);
9932 test_AES_GCM_authenticated_encryption_test_case_2(void)
9934 return test_authenticated_encryption(&gcm_test_case_2);
9938 test_AES_GCM_authenticated_encryption_test_case_3(void)
9940 return test_authenticated_encryption(&gcm_test_case_3);
9944 test_AES_GCM_authenticated_encryption_test_case_4(void)
9946 return test_authenticated_encryption(&gcm_test_case_4);
9950 test_AES_GCM_authenticated_encryption_test_case_5(void)
9952 return test_authenticated_encryption(&gcm_test_case_5);
9956 test_AES_GCM_authenticated_encryption_test_case_6(void)
9958 return test_authenticated_encryption(&gcm_test_case_6);
9962 test_AES_GCM_authenticated_encryption_test_case_7(void)
9964 return test_authenticated_encryption(&gcm_test_case_7);
9968 test_AES_GCM_authenticated_encryption_test_case_8(void)
9970 return test_authenticated_encryption(&gcm_test_case_8);
9974 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9976 return test_authenticated_encryption(&gcm_J0_test_case_1);
9980 test_AES_GCM_auth_encryption_test_case_192_1(void)
9982 return test_authenticated_encryption(&gcm_test_case_192_1);
9986 test_AES_GCM_auth_encryption_test_case_192_2(void)
9988 return test_authenticated_encryption(&gcm_test_case_192_2);
9992 test_AES_GCM_auth_encryption_test_case_192_3(void)
9994 return test_authenticated_encryption(&gcm_test_case_192_3);
9998 test_AES_GCM_auth_encryption_test_case_192_4(void)
10000 return test_authenticated_encryption(&gcm_test_case_192_4);
10004 test_AES_GCM_auth_encryption_test_case_192_5(void)
10006 return test_authenticated_encryption(&gcm_test_case_192_5);
10010 test_AES_GCM_auth_encryption_test_case_192_6(void)
10012 return test_authenticated_encryption(&gcm_test_case_192_6);
10016 test_AES_GCM_auth_encryption_test_case_192_7(void)
10018 return test_authenticated_encryption(&gcm_test_case_192_7);
10022 test_AES_GCM_auth_encryption_test_case_256_1(void)
10024 return test_authenticated_encryption(&gcm_test_case_256_1);
10028 test_AES_GCM_auth_encryption_test_case_256_2(void)
10030 return test_authenticated_encryption(&gcm_test_case_256_2);
10034 test_AES_GCM_auth_encryption_test_case_256_3(void)
10036 return test_authenticated_encryption(&gcm_test_case_256_3);
10040 test_AES_GCM_auth_encryption_test_case_256_4(void)
10042 return test_authenticated_encryption(&gcm_test_case_256_4);
10046 test_AES_GCM_auth_encryption_test_case_256_5(void)
10048 return test_authenticated_encryption(&gcm_test_case_256_5);
10052 test_AES_GCM_auth_encryption_test_case_256_6(void)
10054 return test_authenticated_encryption(&gcm_test_case_256_6);
10058 test_AES_GCM_auth_encryption_test_case_256_7(void)
10060 return test_authenticated_encryption(&gcm_test_case_256_7);
10064 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10066 return test_authenticated_encryption(&gcm_test_case_aad_1);
10070 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10072 return test_authenticated_encryption(&gcm_test_case_aad_2);
10076 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10078 struct aead_test_data tdata;
10081 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10082 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10083 tdata.iv.data[0] += 1;
10084 res = test_authenticated_encryption(&tdata);
10085 if (res == TEST_SKIPPED)
10087 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10088 return TEST_SUCCESS;
10092 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10094 struct aead_test_data tdata;
10097 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10098 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10099 tdata.plaintext.data[0] += 1;
10100 res = test_authenticated_encryption(&tdata);
10101 if (res == TEST_SKIPPED)
10103 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10104 return TEST_SUCCESS;
10108 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10110 struct aead_test_data tdata;
10113 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10114 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10115 tdata.ciphertext.data[0] += 1;
10116 res = test_authenticated_encryption(&tdata);
10117 if (res == TEST_SKIPPED)
10119 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10120 return TEST_SUCCESS;
10124 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10126 struct aead_test_data tdata;
10129 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10130 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10131 tdata.aad.len += 1;
10132 res = test_authenticated_encryption(&tdata);
10133 if (res == TEST_SKIPPED)
10135 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10136 return TEST_SUCCESS;
10140 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10142 struct aead_test_data tdata;
10143 uint8_t aad[gcm_test_case_7.aad.len];
10146 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10147 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10148 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10150 tdata.aad.data = aad;
10151 res = test_authenticated_encryption(&tdata);
10152 if (res == TEST_SKIPPED)
10154 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10155 return TEST_SUCCESS;
10159 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10161 struct aead_test_data tdata;
10164 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10165 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10166 tdata.auth_tag.data[0] += 1;
10167 res = test_authenticated_encryption(&tdata);
10168 if (res == TEST_SKIPPED)
10170 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10171 return TEST_SUCCESS;
10175 test_authenticated_decryption(const struct aead_test_data *tdata)
10177 struct crypto_testsuite_params *ts_params = &testsuite_params;
10178 struct crypto_unittest_params *ut_params = &unittest_params;
10181 uint8_t *plaintext;
10183 struct rte_cryptodev_info dev_info;
10185 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10186 uint64_t feat_flags = dev_info.feature_flags;
10188 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10189 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10190 printf("Device doesn't support RAW data-path APIs.\n");
10191 return TEST_SKIPPED;
10194 /* Verify the capabilities */
10195 struct rte_cryptodev_sym_capability_idx cap_idx;
10196 const struct rte_cryptodev_symmetric_capability *capability;
10197 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10198 cap_idx.algo.aead = tdata->algo;
10199 capability = rte_cryptodev_sym_capability_get(
10200 ts_params->valid_devs[0], &cap_idx);
10201 if (capability == NULL)
10202 return TEST_SKIPPED;
10203 if (rte_cryptodev_sym_capability_check_aead(
10204 capability, tdata->key.len, tdata->auth_tag.len,
10205 tdata->aad.len, tdata->iv.len))
10206 return TEST_SKIPPED;
10208 /* Create AEAD session */
10209 retval = create_aead_session(ts_params->valid_devs[0],
10211 RTE_CRYPTO_AEAD_OP_DECRYPT,
10212 tdata->key.data, tdata->key.len,
10213 tdata->aad.len, tdata->auth_tag.len,
10218 /* alloc mbuf and set payload */
10219 if (tdata->aad.len > MBUF_SIZE) {
10220 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10221 /* Populate full size of add data */
10222 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10223 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10225 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10227 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10228 rte_pktmbuf_tailroom(ut_params->ibuf));
10230 /* Create AEAD operation */
10231 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10235 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10237 ut_params->op->sym->m_src = ut_params->ibuf;
10239 /* Process crypto operation */
10240 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10241 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10242 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10243 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10244 ut_params->op, 0, 0, 0, 0);
10246 TEST_ASSERT_NOT_NULL(
10247 process_crypto_request(ts_params->valid_devs[0],
10248 ut_params->op), "failed to process sym crypto op");
10250 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10251 "crypto op processing failed");
10253 if (ut_params->op->sym->m_dst)
10254 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10257 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10259 ut_params->op->sym->cipher.data.offset);
10261 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10263 /* Validate obuf */
10264 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10266 tdata->plaintext.data,
10267 tdata->plaintext.len,
10268 "Plaintext data not as expected");
10270 TEST_ASSERT_EQUAL(ut_params->op->status,
10271 RTE_CRYPTO_OP_STATUS_SUCCESS,
10272 "Authentication failed");
10278 test_AES_GCM_authenticated_decryption_test_case_1(void)
10280 return test_authenticated_decryption(&gcm_test_case_1);
10284 test_AES_GCM_authenticated_decryption_test_case_2(void)
10286 return test_authenticated_decryption(&gcm_test_case_2);
10290 test_AES_GCM_authenticated_decryption_test_case_3(void)
10292 return test_authenticated_decryption(&gcm_test_case_3);
10296 test_AES_GCM_authenticated_decryption_test_case_4(void)
10298 return test_authenticated_decryption(&gcm_test_case_4);
10302 test_AES_GCM_authenticated_decryption_test_case_5(void)
10304 return test_authenticated_decryption(&gcm_test_case_5);
10308 test_AES_GCM_authenticated_decryption_test_case_6(void)
10310 return test_authenticated_decryption(&gcm_test_case_6);
10314 test_AES_GCM_authenticated_decryption_test_case_7(void)
10316 return test_authenticated_decryption(&gcm_test_case_7);
10320 test_AES_GCM_authenticated_decryption_test_case_8(void)
10322 return test_authenticated_decryption(&gcm_test_case_8);
10326 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10328 return test_authenticated_decryption(&gcm_J0_test_case_1);
10332 test_AES_GCM_auth_decryption_test_case_192_1(void)
10334 return test_authenticated_decryption(&gcm_test_case_192_1);
10338 test_AES_GCM_auth_decryption_test_case_192_2(void)
10340 return test_authenticated_decryption(&gcm_test_case_192_2);
10344 test_AES_GCM_auth_decryption_test_case_192_3(void)
10346 return test_authenticated_decryption(&gcm_test_case_192_3);
10350 test_AES_GCM_auth_decryption_test_case_192_4(void)
10352 return test_authenticated_decryption(&gcm_test_case_192_4);
10356 test_AES_GCM_auth_decryption_test_case_192_5(void)
10358 return test_authenticated_decryption(&gcm_test_case_192_5);
10362 test_AES_GCM_auth_decryption_test_case_192_6(void)
10364 return test_authenticated_decryption(&gcm_test_case_192_6);
10368 test_AES_GCM_auth_decryption_test_case_192_7(void)
10370 return test_authenticated_decryption(&gcm_test_case_192_7);
10374 test_AES_GCM_auth_decryption_test_case_256_1(void)
10376 return test_authenticated_decryption(&gcm_test_case_256_1);
10380 test_AES_GCM_auth_decryption_test_case_256_2(void)
10382 return test_authenticated_decryption(&gcm_test_case_256_2);
10386 test_AES_GCM_auth_decryption_test_case_256_3(void)
10388 return test_authenticated_decryption(&gcm_test_case_256_3);
10392 test_AES_GCM_auth_decryption_test_case_256_4(void)
10394 return test_authenticated_decryption(&gcm_test_case_256_4);
10398 test_AES_GCM_auth_decryption_test_case_256_5(void)
10400 return test_authenticated_decryption(&gcm_test_case_256_5);
10404 test_AES_GCM_auth_decryption_test_case_256_6(void)
10406 return test_authenticated_decryption(&gcm_test_case_256_6);
10410 test_AES_GCM_auth_decryption_test_case_256_7(void)
10412 return test_authenticated_decryption(&gcm_test_case_256_7);
10416 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10418 return test_authenticated_decryption(&gcm_test_case_aad_1);
10422 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10424 return test_authenticated_decryption(&gcm_test_case_aad_2);
10428 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10430 struct aead_test_data tdata;
10433 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10434 tdata.iv.data[0] += 1;
10435 res = test_authenticated_decryption(&tdata);
10436 if (res == TEST_SKIPPED)
10438 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10439 return TEST_SUCCESS;
10443 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10445 struct aead_test_data tdata;
10448 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10449 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10450 tdata.plaintext.data[0] += 1;
10451 res = test_authenticated_decryption(&tdata);
10452 if (res == TEST_SKIPPED)
10454 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10455 return TEST_SUCCESS;
10459 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10461 struct aead_test_data tdata;
10464 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10465 tdata.ciphertext.data[0] += 1;
10466 res = test_authenticated_decryption(&tdata);
10467 if (res == TEST_SKIPPED)
10469 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10470 return TEST_SUCCESS;
10474 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10476 struct aead_test_data tdata;
10479 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10480 tdata.aad.len += 1;
10481 res = test_authenticated_decryption(&tdata);
10482 if (res == TEST_SKIPPED)
10484 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10485 return TEST_SUCCESS;
10489 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10491 struct aead_test_data tdata;
10492 uint8_t aad[gcm_test_case_7.aad.len];
10495 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10496 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10498 tdata.aad.data = aad;
10499 res = test_authenticated_decryption(&tdata);
10500 if (res == TEST_SKIPPED)
10502 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10503 return TEST_SUCCESS;
10507 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10509 struct aead_test_data tdata;
10512 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10513 tdata.auth_tag.data[0] += 1;
10514 res = test_authenticated_decryption(&tdata);
10515 if (res == TEST_SKIPPED)
10517 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10518 return TEST_SUCCESS;
10522 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10524 struct crypto_testsuite_params *ts_params = &testsuite_params;
10525 struct crypto_unittest_params *ut_params = &unittest_params;
10528 uint8_t *ciphertext, *auth_tag;
10529 uint16_t plaintext_pad_len;
10530 struct rte_cryptodev_info dev_info;
10532 /* Verify the capabilities */
10533 struct rte_cryptodev_sym_capability_idx cap_idx;
10534 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10535 cap_idx.algo.aead = tdata->algo;
10536 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10538 return TEST_SKIPPED;
10540 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10541 uint64_t feat_flags = dev_info.feature_flags;
10543 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10544 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
10545 return TEST_SKIPPED;
10547 /* not supported with CPU crypto */
10548 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10549 return TEST_SKIPPED;
10551 /* Create AEAD session */
10552 retval = create_aead_session(ts_params->valid_devs[0],
10554 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10555 tdata->key.data, tdata->key.len,
10556 tdata->aad.len, tdata->auth_tag.len,
10561 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10562 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10564 /* clear mbuf payload */
10565 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10566 rte_pktmbuf_tailroom(ut_params->ibuf));
10567 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10568 rte_pktmbuf_tailroom(ut_params->obuf));
10570 /* Create AEAD operation */
10571 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10575 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10577 ut_params->op->sym->m_src = ut_params->ibuf;
10578 ut_params->op->sym->m_dst = ut_params->obuf;
10580 /* Process crypto operation */
10581 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10582 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10583 ut_params->op, 0, 0, 0, 0);
10585 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10586 ut_params->op), "failed to process sym crypto op");
10588 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10589 "crypto op processing failed");
10591 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10593 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10594 ut_params->op->sym->cipher.data.offset);
10595 auth_tag = ciphertext + plaintext_pad_len;
10597 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10598 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10600 /* Validate obuf */
10601 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10603 tdata->ciphertext.data,
10604 tdata->ciphertext.len,
10605 "Ciphertext data not as expected");
10607 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10609 tdata->auth_tag.data,
10610 tdata->auth_tag.len,
10611 "Generated auth tag not as expected");
10618 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10620 return test_authenticated_encryption_oop(&gcm_test_case_5);
10624 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10626 struct crypto_testsuite_params *ts_params = &testsuite_params;
10627 struct crypto_unittest_params *ut_params = &unittest_params;
10630 uint8_t *plaintext;
10631 struct rte_cryptodev_info dev_info;
10633 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10634 uint64_t feat_flags = dev_info.feature_flags;
10636 /* Verify the capabilities */
10637 struct rte_cryptodev_sym_capability_idx cap_idx;
10638 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10639 cap_idx.algo.aead = tdata->algo;
10640 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10642 return TEST_SKIPPED;
10644 /* not supported with CPU crypto and raw data-path APIs*/
10645 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10646 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10647 return TEST_SKIPPED;
10649 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10650 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10651 printf("Device does not support RAW data-path APIs.\n");
10652 return TEST_SKIPPED;
10655 /* Create AEAD session */
10656 retval = create_aead_session(ts_params->valid_devs[0],
10658 RTE_CRYPTO_AEAD_OP_DECRYPT,
10659 tdata->key.data, tdata->key.len,
10660 tdata->aad.len, tdata->auth_tag.len,
10665 /* alloc mbuf and set payload */
10666 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10667 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10669 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10670 rte_pktmbuf_tailroom(ut_params->ibuf));
10671 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10672 rte_pktmbuf_tailroom(ut_params->obuf));
10674 /* Create AEAD operation */
10675 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10679 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10681 ut_params->op->sym->m_src = ut_params->ibuf;
10682 ut_params->op->sym->m_dst = ut_params->obuf;
10684 /* Process crypto operation */
10685 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10686 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10687 ut_params->op, 0, 0, 0, 0);
10689 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10690 ut_params->op), "failed to process sym crypto op");
10692 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10693 "crypto op processing failed");
10695 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10696 ut_params->op->sym->cipher.data.offset);
10698 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10700 /* Validate obuf */
10701 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10703 tdata->plaintext.data,
10704 tdata->plaintext.len,
10705 "Plaintext data not as expected");
10707 TEST_ASSERT_EQUAL(ut_params->op->status,
10708 RTE_CRYPTO_OP_STATUS_SUCCESS,
10709 "Authentication failed");
10714 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10716 return test_authenticated_decryption_oop(&gcm_test_case_5);
10720 test_authenticated_encryption_sessionless(
10721 const struct aead_test_data *tdata)
10723 struct crypto_testsuite_params *ts_params = &testsuite_params;
10724 struct crypto_unittest_params *ut_params = &unittest_params;
10727 uint8_t *ciphertext, *auth_tag;
10728 uint16_t plaintext_pad_len;
10729 uint8_t key[tdata->key.len + 1];
10730 struct rte_cryptodev_info dev_info;
10732 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10733 uint64_t feat_flags = dev_info.feature_flags;
10735 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10736 printf("Device doesn't support Sessionless ops.\n");
10737 return TEST_SKIPPED;
10740 /* not supported with CPU crypto */
10741 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10742 return TEST_SKIPPED;
10744 /* Verify the capabilities */
10745 struct rte_cryptodev_sym_capability_idx cap_idx;
10746 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10747 cap_idx.algo.aead = tdata->algo;
10748 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10750 return TEST_SKIPPED;
10752 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10754 /* clear mbuf payload */
10755 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10756 rte_pktmbuf_tailroom(ut_params->ibuf));
10758 /* Create AEAD operation */
10759 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10763 /* Create GCM xform */
10764 memcpy(key, tdata->key.data, tdata->key.len);
10765 retval = create_aead_xform(ut_params->op,
10767 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10768 key, tdata->key.len,
10769 tdata->aad.len, tdata->auth_tag.len,
10774 ut_params->op->sym->m_src = ut_params->ibuf;
10776 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10777 RTE_CRYPTO_OP_SESSIONLESS,
10778 "crypto op session type not sessionless");
10780 /* Process crypto operation */
10781 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10782 ut_params->op), "failed to process sym crypto op");
10784 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10786 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10787 "crypto op status not success");
10789 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10791 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10792 ut_params->op->sym->cipher.data.offset);
10793 auth_tag = ciphertext + plaintext_pad_len;
10795 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10796 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10798 /* Validate obuf */
10799 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10801 tdata->ciphertext.data,
10802 tdata->ciphertext.len,
10803 "Ciphertext data not as expected");
10805 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10807 tdata->auth_tag.data,
10808 tdata->auth_tag.len,
10809 "Generated auth tag not as expected");
10816 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10818 return test_authenticated_encryption_sessionless(
10823 test_authenticated_decryption_sessionless(
10824 const struct aead_test_data *tdata)
10826 struct crypto_testsuite_params *ts_params = &testsuite_params;
10827 struct crypto_unittest_params *ut_params = &unittest_params;
10830 uint8_t *plaintext;
10831 uint8_t key[tdata->key.len + 1];
10832 struct rte_cryptodev_info dev_info;
10834 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10835 uint64_t feat_flags = dev_info.feature_flags;
10837 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10838 printf("Device doesn't support Sessionless ops.\n");
10839 return TEST_SKIPPED;
10842 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10843 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10844 printf("Device doesn't support RAW data-path APIs.\n");
10845 return TEST_SKIPPED;
10848 /* not supported with CPU crypto */
10849 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10850 return TEST_SKIPPED;
10852 /* Verify the capabilities */
10853 struct rte_cryptodev_sym_capability_idx cap_idx;
10854 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10855 cap_idx.algo.aead = tdata->algo;
10856 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10858 return TEST_SKIPPED;
10860 /* alloc mbuf and set payload */
10861 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10863 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10864 rte_pktmbuf_tailroom(ut_params->ibuf));
10866 /* Create AEAD operation */
10867 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10871 /* Create AEAD xform */
10872 memcpy(key, tdata->key.data, tdata->key.len);
10873 retval = create_aead_xform(ut_params->op,
10875 RTE_CRYPTO_AEAD_OP_DECRYPT,
10876 key, tdata->key.len,
10877 tdata->aad.len, tdata->auth_tag.len,
10882 ut_params->op->sym->m_src = ut_params->ibuf;
10884 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10885 RTE_CRYPTO_OP_SESSIONLESS,
10886 "crypto op session type not sessionless");
10888 /* Process crypto operation */
10889 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10890 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10891 ut_params->op, 0, 0, 0, 0);
10893 TEST_ASSERT_NOT_NULL(process_crypto_request(
10894 ts_params->valid_devs[0], ut_params->op),
10895 "failed to process sym crypto op");
10897 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10899 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10900 "crypto op status not success");
10902 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10903 ut_params->op->sym->cipher.data.offset);
10905 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10907 /* Validate obuf */
10908 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10910 tdata->plaintext.data,
10911 tdata->plaintext.len,
10912 "Plaintext data not as expected");
10914 TEST_ASSERT_EQUAL(ut_params->op->status,
10915 RTE_CRYPTO_OP_STATUS_SUCCESS,
10916 "Authentication failed");
10921 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10923 return test_authenticated_decryption_sessionless(
10928 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10930 return test_authenticated_encryption(&ccm_test_case_128_1);
10934 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10936 return test_authenticated_encryption(&ccm_test_case_128_2);
10940 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10942 return test_authenticated_encryption(&ccm_test_case_128_3);
10946 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10948 return test_authenticated_decryption(&ccm_test_case_128_1);
10952 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10954 return test_authenticated_decryption(&ccm_test_case_128_2);
10958 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10960 return test_authenticated_decryption(&ccm_test_case_128_3);
10964 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10966 return test_authenticated_encryption(&ccm_test_case_192_1);
10970 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10972 return test_authenticated_encryption(&ccm_test_case_192_2);
10976 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10978 return test_authenticated_encryption(&ccm_test_case_192_3);
10982 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10984 return test_authenticated_decryption(&ccm_test_case_192_1);
10988 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10990 return test_authenticated_decryption(&ccm_test_case_192_2);
10994 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10996 return test_authenticated_decryption(&ccm_test_case_192_3);
11000 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
11002 return test_authenticated_encryption(&ccm_test_case_256_1);
11006 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
11008 return test_authenticated_encryption(&ccm_test_case_256_2);
11012 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
11014 return test_authenticated_encryption(&ccm_test_case_256_3);
11018 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
11020 return test_authenticated_decryption(&ccm_test_case_256_1);
11024 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
11026 return test_authenticated_decryption(&ccm_test_case_256_2);
11030 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
11032 return test_authenticated_decryption(&ccm_test_case_256_3);
11038 struct crypto_testsuite_params *ts_params = &testsuite_params;
11039 struct rte_cryptodev_stats stats;
11041 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11042 return TEST_SKIPPED;
11044 /* Verify the capabilities */
11045 struct rte_cryptodev_sym_capability_idx cap_idx;
11046 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11047 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11048 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11050 return TEST_SKIPPED;
11051 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11052 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11053 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11055 return TEST_SKIPPED;
11057 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11059 return TEST_SKIPPED;
11061 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11062 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11063 &stats) == -ENODEV),
11064 "rte_cryptodev_stats_get invalid dev failed");
11065 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11066 "rte_cryptodev_stats_get invalid Param failed");
11068 /* Test expected values */
11069 test_AES_CBC_HMAC_SHA1_encrypt_digest();
11070 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11072 "rte_cryptodev_stats_get failed");
11073 TEST_ASSERT((stats.enqueued_count == 1),
11074 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11075 TEST_ASSERT((stats.dequeued_count == 1),
11076 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11077 TEST_ASSERT((stats.enqueue_err_count == 0),
11078 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11079 TEST_ASSERT((stats.dequeue_err_count == 0),
11080 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11082 /* invalid device but should ignore and not reset device stats*/
11083 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11084 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11086 "rte_cryptodev_stats_get failed");
11087 TEST_ASSERT((stats.enqueued_count == 1),
11088 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11090 /* check that a valid reset clears stats */
11091 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11092 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11094 "rte_cryptodev_stats_get failed");
11095 TEST_ASSERT((stats.enqueued_count == 0),
11096 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11097 TEST_ASSERT((stats.dequeued_count == 0),
11098 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11100 return TEST_SUCCESS;
11103 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11104 struct crypto_unittest_params *ut_params,
11105 enum rte_crypto_auth_operation op,
11106 const struct HMAC_MD5_vector *test_case)
11111 memcpy(key, test_case->key.data, test_case->key.len);
11113 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11114 ut_params->auth_xform.next = NULL;
11115 ut_params->auth_xform.auth.op = op;
11117 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11119 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11120 ut_params->auth_xform.auth.key.length = test_case->key.len;
11121 ut_params->auth_xform.auth.key.data = key;
11123 ut_params->sess = rte_cryptodev_sym_session_create(
11124 ts_params->session_mpool);
11125 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11126 if (ut_params->sess == NULL)
11127 return TEST_FAILED;
11129 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11130 ut_params->sess, &ut_params->auth_xform,
11131 ts_params->session_priv_mpool);
11132 if (status == -ENOTSUP)
11133 return TEST_SKIPPED;
11135 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11137 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11138 rte_pktmbuf_tailroom(ut_params->ibuf));
11143 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11144 const struct HMAC_MD5_vector *test_case,
11145 uint8_t **plaintext)
11147 uint16_t plaintext_pad_len;
11149 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11151 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11154 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11155 plaintext_pad_len);
11156 memcpy(*plaintext, test_case->plaintext.data,
11157 test_case->plaintext.len);
11159 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11160 ut_params->ibuf, MD5_DIGEST_LEN);
11161 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11162 "no room to append digest");
11163 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11164 ut_params->ibuf, plaintext_pad_len);
11166 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11167 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11168 test_case->auth_tag.len);
11171 sym_op->auth.data.offset = 0;
11172 sym_op->auth.data.length = test_case->plaintext.len;
11174 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11175 ut_params->op->sym->m_src = ut_params->ibuf;
11181 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11183 uint16_t plaintext_pad_len;
11184 uint8_t *plaintext, *auth_tag;
11186 struct crypto_testsuite_params *ts_params = &testsuite_params;
11187 struct crypto_unittest_params *ut_params = &unittest_params;
11188 struct rte_cryptodev_info dev_info;
11190 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11191 uint64_t feat_flags = dev_info.feature_flags;
11193 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11194 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11195 printf("Device doesn't support RAW data-path APIs.\n");
11196 return TEST_SKIPPED;
11199 /* Verify the capabilities */
11200 struct rte_cryptodev_sym_capability_idx cap_idx;
11201 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11202 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11203 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11205 return TEST_SKIPPED;
11207 if (MD5_HMAC_create_session(ts_params, ut_params,
11208 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11209 return TEST_FAILED;
11211 /* Generate Crypto op data structure */
11212 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11213 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11214 TEST_ASSERT_NOT_NULL(ut_params->op,
11215 "Failed to allocate symmetric crypto operation struct");
11217 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11220 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11221 return TEST_FAILED;
11223 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11224 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11226 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11227 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11228 ut_params->op, 0, 1, 0, 0);
11230 TEST_ASSERT_NOT_NULL(
11231 process_crypto_request(ts_params->valid_devs[0],
11233 "failed to process sym crypto op");
11235 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11236 "crypto op processing failed");
11238 if (ut_params->op->sym->m_dst) {
11239 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11240 uint8_t *, plaintext_pad_len);
11242 auth_tag = plaintext + plaintext_pad_len;
11245 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11247 test_case->auth_tag.data,
11248 test_case->auth_tag.len,
11249 "HMAC_MD5 generated tag not as expected");
11251 return TEST_SUCCESS;
11255 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11257 uint8_t *plaintext;
11259 struct crypto_testsuite_params *ts_params = &testsuite_params;
11260 struct crypto_unittest_params *ut_params = &unittest_params;
11261 struct rte_cryptodev_info dev_info;
11263 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11264 uint64_t feat_flags = dev_info.feature_flags;
11266 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11267 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11268 printf("Device doesn't support RAW data-path APIs.\n");
11269 return TEST_SKIPPED;
11272 /* Verify the capabilities */
11273 struct rte_cryptodev_sym_capability_idx cap_idx;
11274 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11275 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11276 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11278 return TEST_SKIPPED;
11280 if (MD5_HMAC_create_session(ts_params, ut_params,
11281 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11282 return TEST_FAILED;
11285 /* Generate Crypto op data structure */
11286 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11287 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11288 TEST_ASSERT_NOT_NULL(ut_params->op,
11289 "Failed to allocate symmetric crypto operation struct");
11291 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11292 return TEST_FAILED;
11294 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11295 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11297 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11298 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11299 ut_params->op, 0, 1, 0, 0);
11301 TEST_ASSERT_NOT_NULL(
11302 process_crypto_request(ts_params->valid_devs[0],
11304 "failed to process sym crypto op");
11306 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11307 "HMAC_MD5 crypto op processing failed");
11309 return TEST_SUCCESS;
11313 test_MD5_HMAC_generate_case_1(void)
11315 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11319 test_MD5_HMAC_verify_case_1(void)
11321 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11325 test_MD5_HMAC_generate_case_2(void)
11327 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11331 test_MD5_HMAC_verify_case_2(void)
11333 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11337 test_multi_session(void)
11339 struct crypto_testsuite_params *ts_params = &testsuite_params;
11340 struct crypto_unittest_params *ut_params = &unittest_params;
11342 struct rte_cryptodev_info dev_info;
11343 struct rte_cryptodev_sym_session **sessions;
11348 /* Verify the capabilities */
11349 struct rte_cryptodev_sym_capability_idx cap_idx;
11350 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11351 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11352 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11354 return TEST_SKIPPED;
11355 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11356 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11357 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11359 return TEST_SKIPPED;
11361 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11362 aes_cbc_key, hmac_sha512_key);
11365 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11367 sessions = rte_malloc(NULL,
11368 sizeof(struct rte_cryptodev_sym_session *) *
11369 (MAX_NB_SESSIONS + 1), 0);
11371 /* Create multiple crypto sessions*/
11372 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11374 sessions[i] = rte_cryptodev_sym_session_create(
11375 ts_params->session_mpool);
11376 TEST_ASSERT_NOT_NULL(sessions[i],
11377 "Session creation failed at session number %u",
11380 status = rte_cryptodev_sym_session_init(
11381 ts_params->valid_devs[0],
11382 sessions[i], &ut_params->auth_xform,
11383 ts_params->session_priv_mpool);
11384 if (status == -ENOTSUP)
11385 return TEST_SKIPPED;
11387 /* Attempt to send a request on each session */
11388 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11392 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11393 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11395 "Failed to perform decrypt on request number %u.", i);
11396 /* free crypto operation structure */
11398 rte_crypto_op_free(ut_params->op);
11401 * free mbuf - both obuf and ibuf are usually the same,
11402 * so check if they point at the same address is necessary,
11403 * to avoid freeing the mbuf twice.
11405 if (ut_params->obuf) {
11406 rte_pktmbuf_free(ut_params->obuf);
11407 if (ut_params->ibuf == ut_params->obuf)
11408 ut_params->ibuf = 0;
11409 ut_params->obuf = 0;
11411 if (ut_params->ibuf) {
11412 rte_pktmbuf_free(ut_params->ibuf);
11413 ut_params->ibuf = 0;
11417 sessions[i] = NULL;
11418 /* Next session create should fail */
11419 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11420 sessions[i], &ut_params->auth_xform,
11421 ts_params->session_priv_mpool);
11422 TEST_ASSERT_NULL(sessions[i],
11423 "Session creation succeeded unexpectedly!");
11425 for (i = 0; i < MAX_NB_SESSIONS; 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 struct multi_session_params {
11437 struct crypto_unittest_params ut_params;
11438 uint8_t *cipher_key;
11440 const uint8_t *cipher;
11441 const uint8_t *digest;
11445 #define MB_SESSION_NUMBER 3
11448 test_multi_session_random_usage(void)
11450 struct crypto_testsuite_params *ts_params = &testsuite_params;
11451 struct rte_cryptodev_info dev_info;
11452 struct rte_cryptodev_sym_session **sessions;
11454 struct multi_session_params ut_paramz[] = {
11457 .cipher_key = ms_aes_cbc_key0,
11458 .hmac_key = ms_hmac_key0,
11459 .cipher = ms_aes_cbc_cipher0,
11460 .digest = ms_hmac_digest0,
11461 .iv = ms_aes_cbc_iv0
11464 .cipher_key = ms_aes_cbc_key1,
11465 .hmac_key = ms_hmac_key1,
11466 .cipher = ms_aes_cbc_cipher1,
11467 .digest = ms_hmac_digest1,
11468 .iv = ms_aes_cbc_iv1
11471 .cipher_key = ms_aes_cbc_key2,
11472 .hmac_key = ms_hmac_key2,
11473 .cipher = ms_aes_cbc_cipher2,
11474 .digest = ms_hmac_digest2,
11475 .iv = ms_aes_cbc_iv2
11481 /* Verify the capabilities */
11482 struct rte_cryptodev_sym_capability_idx cap_idx;
11483 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11484 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11485 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11487 return TEST_SKIPPED;
11488 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11489 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11490 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11492 return TEST_SKIPPED;
11494 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11496 sessions = rte_malloc(NULL,
11497 (sizeof(struct rte_cryptodev_sym_session *)
11498 * MAX_NB_SESSIONS) + 1, 0);
11500 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11501 sessions[i] = rte_cryptodev_sym_session_create(
11502 ts_params->session_mpool);
11503 TEST_ASSERT_NOT_NULL(sessions[i],
11504 "Session creation failed at session number %u",
11507 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11508 sizeof(struct crypto_unittest_params));
11510 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11511 &ut_paramz[i].ut_params,
11512 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11514 /* Create multiple crypto sessions*/
11515 status = rte_cryptodev_sym_session_init(
11516 ts_params->valid_devs[0],
11518 &ut_paramz[i].ut_params.auth_xform,
11519 ts_params->session_priv_mpool);
11521 if (status == -ENOTSUP)
11522 return TEST_SKIPPED;
11524 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
11528 for (i = 0; i < 40000; i++) {
11530 j = rand() % MB_SESSION_NUMBER;
11532 TEST_ASSERT_SUCCESS(
11533 test_AES_CBC_HMAC_SHA512_decrypt_perform(
11535 &ut_paramz[j].ut_params,
11536 ts_params, ut_paramz[j].cipher,
11537 ut_paramz[j].digest,
11539 "Failed to perform decrypt on request number %u.", i);
11541 if (ut_paramz[j].ut_params.op)
11542 rte_crypto_op_free(ut_paramz[j].ut_params.op);
11545 * free mbuf - both obuf and ibuf are usually the same,
11546 * so check if they point at the same address is necessary,
11547 * to avoid freeing the mbuf twice.
11549 if (ut_paramz[j].ut_params.obuf) {
11550 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11551 if (ut_paramz[j].ut_params.ibuf
11552 == ut_paramz[j].ut_params.obuf)
11553 ut_paramz[j].ut_params.ibuf = 0;
11554 ut_paramz[j].ut_params.obuf = 0;
11556 if (ut_paramz[j].ut_params.ibuf) {
11557 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11558 ut_paramz[j].ut_params.ibuf = 0;
11562 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11563 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11565 rte_cryptodev_sym_session_free(sessions[i]);
11568 rte_free(sessions);
11570 return TEST_SUCCESS;
11573 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11574 0xab, 0xab, 0xab, 0xab,
11575 0xab, 0xab, 0xab, 0xab,
11576 0xab, 0xab, 0xab, 0xab};
11579 test_null_invalid_operation(void)
11581 struct crypto_testsuite_params *ts_params = &testsuite_params;
11582 struct crypto_unittest_params *ut_params = &unittest_params;
11585 /* This test is for NULL PMD only */
11586 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11587 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11588 return TEST_SKIPPED;
11590 /* Setup Cipher Parameters */
11591 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11592 ut_params->cipher_xform.next = NULL;
11594 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11595 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11597 ut_params->sess = rte_cryptodev_sym_session_create(
11598 ts_params->session_mpool);
11600 /* Create Crypto session*/
11601 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11602 ut_params->sess, &ut_params->cipher_xform,
11603 ts_params->session_priv_mpool);
11604 TEST_ASSERT(ret < 0,
11605 "Session creation succeeded unexpectedly");
11608 /* Setup HMAC Parameters */
11609 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11610 ut_params->auth_xform.next = NULL;
11612 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11613 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11615 ut_params->sess = rte_cryptodev_sym_session_create(
11616 ts_params->session_mpool);
11618 /* Create Crypto session*/
11619 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11620 ut_params->sess, &ut_params->auth_xform,
11621 ts_params->session_priv_mpool);
11622 TEST_ASSERT(ret < 0,
11623 "Session creation succeeded unexpectedly");
11625 return TEST_SUCCESS;
11629 #define NULL_BURST_LENGTH (32)
11632 test_null_burst_operation(void)
11634 struct crypto_testsuite_params *ts_params = &testsuite_params;
11635 struct crypto_unittest_params *ut_params = &unittest_params;
11638 unsigned i, burst_len = NULL_BURST_LENGTH;
11640 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11641 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11643 /* This test is for NULL PMD only */
11644 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11645 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11646 return TEST_SKIPPED;
11648 /* Setup Cipher Parameters */
11649 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11650 ut_params->cipher_xform.next = &ut_params->auth_xform;
11652 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11653 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11655 /* Setup HMAC Parameters */
11656 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11657 ut_params->auth_xform.next = NULL;
11659 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11660 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11662 ut_params->sess = rte_cryptodev_sym_session_create(
11663 ts_params->session_mpool);
11664 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11666 /* Create Crypto session*/
11667 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11668 ut_params->sess, &ut_params->cipher_xform,
11669 ts_params->session_priv_mpool);
11671 if (status == -ENOTSUP)
11672 return TEST_SKIPPED;
11674 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
11676 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11677 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11678 burst_len, "failed to generate burst of crypto ops");
11680 /* Generate an operation for each mbuf in burst */
11681 for (i = 0; i < burst_len; i++) {
11682 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11684 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11686 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11690 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11692 burst[i]->sym->m_src = m;
11695 /* Process crypto operation */
11696 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11697 0, burst, burst_len),
11699 "Error enqueuing burst");
11701 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11702 0, burst_dequeued, burst_len),
11704 "Error dequeuing burst");
11707 for (i = 0; i < burst_len; i++) {
11709 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11710 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11712 "data not as expected");
11714 rte_pktmbuf_free(burst[i]->sym->m_src);
11715 rte_crypto_op_free(burst[i]);
11718 return TEST_SUCCESS;
11722 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11723 uint16_t nb_ops, void *user_param)
11725 RTE_SET_USED(dev_id);
11726 RTE_SET_USED(qp_id);
11728 RTE_SET_USED(user_param);
11730 printf("crypto enqueue callback called\n");
11735 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11736 uint16_t nb_ops, void *user_param)
11738 RTE_SET_USED(dev_id);
11739 RTE_SET_USED(qp_id);
11741 RTE_SET_USED(user_param);
11743 printf("crypto dequeue callback called\n");
11748 * Thread using enqueue/dequeue callback with RCU.
11751 test_enqdeq_callback_thread(void *arg)
11754 /* DP thread calls rte_cryptodev_enqueue_burst()/
11755 * rte_cryptodev_dequeue_burst() and invokes callback.
11757 test_null_burst_operation();
11762 test_enq_callback_setup(void)
11764 struct crypto_testsuite_params *ts_params = &testsuite_params;
11765 struct rte_cryptodev_info dev_info;
11766 struct rte_cryptodev_qp_conf qp_conf = {
11767 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11770 struct rte_cryptodev_cb *cb;
11771 uint16_t qp_id = 0;
11773 /* Stop the device in case it's started so it can be configured */
11774 rte_cryptodev_stop(ts_params->valid_devs[0]);
11776 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11778 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11780 "Failed to configure cryptodev %u",
11781 ts_params->valid_devs[0]);
11783 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11784 qp_conf.mp_session = ts_params->session_mpool;
11785 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11787 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11788 ts_params->valid_devs[0], qp_id, &qp_conf,
11789 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11791 "rte_cryptodev_queue_pair_setup: num_inflights "
11792 "%u on qp %u on cryptodev %u",
11793 qp_conf.nb_descriptors, qp_id,
11794 ts_params->valid_devs[0]);
11796 /* Test with invalid crypto device */
11797 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11798 qp_id, test_enq_callback, NULL);
11799 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11800 "cryptodev %u did not fail",
11801 qp_id, RTE_CRYPTO_MAX_DEVS);
11803 /* Test with invalid queue pair */
11804 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11805 dev_info.max_nb_queue_pairs + 1,
11806 test_enq_callback, NULL);
11807 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11808 "cryptodev %u did not fail",
11809 dev_info.max_nb_queue_pairs + 1,
11810 ts_params->valid_devs[0]);
11812 /* Test with NULL callback */
11813 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11814 qp_id, NULL, NULL);
11815 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11816 "cryptodev %u did not fail",
11817 qp_id, ts_params->valid_devs[0]);
11819 /* Test with valid configuration */
11820 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11821 qp_id, test_enq_callback, NULL);
11822 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11823 "qp %u on cryptodev %u",
11824 qp_id, ts_params->valid_devs[0]);
11826 rte_cryptodev_start(ts_params->valid_devs[0]);
11828 /* Launch a thread */
11829 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11830 rte_get_next_lcore(-1, 1, 0));
11832 /* Wait until reader exited. */
11833 rte_eal_mp_wait_lcore();
11835 /* Test with invalid crypto device */
11836 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11837 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11838 "Expected call to fail as crypto device is invalid");
11840 /* Test with invalid queue pair */
11841 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11842 ts_params->valid_devs[0],
11843 dev_info.max_nb_queue_pairs + 1, cb),
11844 "Expected call to fail as queue pair is invalid");
11846 /* Test with NULL callback */
11847 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11848 ts_params->valid_devs[0], qp_id, NULL),
11849 "Expected call to fail as callback is NULL");
11851 /* Test with valid configuration */
11852 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11853 ts_params->valid_devs[0], qp_id, cb),
11854 "Failed test to remove callback on "
11855 "qp %u on cryptodev %u",
11856 qp_id, ts_params->valid_devs[0]);
11858 return TEST_SUCCESS;
11862 test_deq_callback_setup(void)
11864 struct crypto_testsuite_params *ts_params = &testsuite_params;
11865 struct rte_cryptodev_info dev_info;
11866 struct rte_cryptodev_qp_conf qp_conf = {
11867 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11870 struct rte_cryptodev_cb *cb;
11871 uint16_t qp_id = 0;
11873 /* Stop the device in case it's started so it can be configured */
11874 rte_cryptodev_stop(ts_params->valid_devs[0]);
11876 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11878 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11880 "Failed to configure cryptodev %u",
11881 ts_params->valid_devs[0]);
11883 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11884 qp_conf.mp_session = ts_params->session_mpool;
11885 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11887 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11888 ts_params->valid_devs[0], qp_id, &qp_conf,
11889 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11891 "rte_cryptodev_queue_pair_setup: num_inflights "
11892 "%u on qp %u on cryptodev %u",
11893 qp_conf.nb_descriptors, qp_id,
11894 ts_params->valid_devs[0]);
11896 /* Test with invalid crypto device */
11897 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11898 qp_id, test_deq_callback, NULL);
11899 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11900 "cryptodev %u did not fail",
11901 qp_id, RTE_CRYPTO_MAX_DEVS);
11903 /* Test with invalid queue pair */
11904 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11905 dev_info.max_nb_queue_pairs + 1,
11906 test_deq_callback, NULL);
11907 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11908 "cryptodev %u did not fail",
11909 dev_info.max_nb_queue_pairs + 1,
11910 ts_params->valid_devs[0]);
11912 /* Test with NULL callback */
11913 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11914 qp_id, NULL, NULL);
11915 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11916 "cryptodev %u did not fail",
11917 qp_id, ts_params->valid_devs[0]);
11919 /* Test with valid configuration */
11920 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11921 qp_id, test_deq_callback, NULL);
11922 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11923 "qp %u on cryptodev %u",
11924 qp_id, ts_params->valid_devs[0]);
11926 rte_cryptodev_start(ts_params->valid_devs[0]);
11928 /* Launch a thread */
11929 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11930 rte_get_next_lcore(-1, 1, 0));
11932 /* Wait until reader exited. */
11933 rte_eal_mp_wait_lcore();
11935 /* Test with invalid crypto device */
11936 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11937 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11938 "Expected call to fail as crypto device is invalid");
11940 /* Test with invalid queue pair */
11941 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11942 ts_params->valid_devs[0],
11943 dev_info.max_nb_queue_pairs + 1, cb),
11944 "Expected call to fail as queue pair is invalid");
11946 /* Test with NULL callback */
11947 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11948 ts_params->valid_devs[0], qp_id, NULL),
11949 "Expected call to fail as callback is NULL");
11951 /* Test with valid configuration */
11952 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11953 ts_params->valid_devs[0], qp_id, cb),
11954 "Failed test to remove callback on "
11955 "qp %u on cryptodev %u",
11956 qp_id, ts_params->valid_devs[0]);
11958 return TEST_SUCCESS;
11962 generate_gmac_large_plaintext(uint8_t *data)
11966 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11967 memcpy(&data[i], &data[0], 32);
11971 create_gmac_operation(enum rte_crypto_auth_operation op,
11972 const struct gmac_test_data *tdata)
11974 struct crypto_testsuite_params *ts_params = &testsuite_params;
11975 struct crypto_unittest_params *ut_params = &unittest_params;
11976 struct rte_crypto_sym_op *sym_op;
11978 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11980 /* Generate Crypto op data structure */
11981 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11982 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11983 TEST_ASSERT_NOT_NULL(ut_params->op,
11984 "Failed to allocate symmetric crypto operation struct");
11986 sym_op = ut_params->op->sym;
11988 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11989 ut_params->ibuf, tdata->gmac_tag.len);
11990 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11991 "no room to append digest");
11993 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11994 ut_params->ibuf, plaintext_pad_len);
11996 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11997 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11998 tdata->gmac_tag.len);
11999 debug_hexdump(stdout, "digest:",
12000 sym_op->auth.digest.data,
12001 tdata->gmac_tag.len);
12004 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12005 uint8_t *, IV_OFFSET);
12007 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12009 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12011 sym_op->cipher.data.length = 0;
12012 sym_op->cipher.data.offset = 0;
12014 sym_op->auth.data.offset = 0;
12015 sym_op->auth.data.length = tdata->plaintext.len;
12021 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
12022 const struct gmac_test_data *tdata,
12023 void *digest_mem, uint64_t digest_phys)
12025 struct crypto_testsuite_params *ts_params = &testsuite_params;
12026 struct crypto_unittest_params *ut_params = &unittest_params;
12027 struct rte_crypto_sym_op *sym_op;
12029 /* Generate Crypto op data structure */
12030 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12031 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12032 TEST_ASSERT_NOT_NULL(ut_params->op,
12033 "Failed to allocate symmetric crypto operation struct");
12035 sym_op = ut_params->op->sym;
12037 sym_op->auth.digest.data = digest_mem;
12038 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12039 "no room to append digest");
12041 sym_op->auth.digest.phys_addr = digest_phys;
12043 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12044 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12045 tdata->gmac_tag.len);
12046 debug_hexdump(stdout, "digest:",
12047 sym_op->auth.digest.data,
12048 tdata->gmac_tag.len);
12051 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12052 uint8_t *, IV_OFFSET);
12054 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12056 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12058 sym_op->cipher.data.length = 0;
12059 sym_op->cipher.data.offset = 0;
12061 sym_op->auth.data.offset = 0;
12062 sym_op->auth.data.length = tdata->plaintext.len;
12067 static int create_gmac_session(uint8_t dev_id,
12068 const struct gmac_test_data *tdata,
12069 enum rte_crypto_auth_operation auth_op)
12071 uint8_t auth_key[tdata->key.len];
12074 struct crypto_testsuite_params *ts_params = &testsuite_params;
12075 struct crypto_unittest_params *ut_params = &unittest_params;
12077 memcpy(auth_key, tdata->key.data, tdata->key.len);
12079 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12080 ut_params->auth_xform.next = NULL;
12082 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12083 ut_params->auth_xform.auth.op = auth_op;
12084 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12085 ut_params->auth_xform.auth.key.length = tdata->key.len;
12086 ut_params->auth_xform.auth.key.data = auth_key;
12087 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12088 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12091 ut_params->sess = rte_cryptodev_sym_session_create(
12092 ts_params->session_mpool);
12093 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12095 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12096 &ut_params->auth_xform,
12097 ts_params->session_priv_mpool);
12103 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12105 struct crypto_testsuite_params *ts_params = &testsuite_params;
12106 struct crypto_unittest_params *ut_params = &unittest_params;
12107 struct rte_cryptodev_info dev_info;
12109 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12110 uint64_t feat_flags = dev_info.feature_flags;
12112 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12113 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12114 printf("Device doesn't support RAW data-path APIs.\n");
12115 return TEST_SKIPPED;
12120 uint8_t *auth_tag, *plaintext;
12121 uint16_t plaintext_pad_len;
12123 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12124 "No GMAC length in the source data");
12126 /* Verify the capabilities */
12127 struct rte_cryptodev_sym_capability_idx cap_idx;
12128 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12129 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12130 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12132 return TEST_SKIPPED;
12134 retval = create_gmac_session(ts_params->valid_devs[0],
12135 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12137 if (retval == -ENOTSUP)
12138 return TEST_SKIPPED;
12142 if (tdata->plaintext.len > MBUF_SIZE)
12143 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12145 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12146 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12147 "Failed to allocate input buffer in mempool");
12149 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12150 rte_pktmbuf_tailroom(ut_params->ibuf));
12152 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12154 * Runtime generate the large plain text instead of use hard code
12155 * plain text vector. It is done to avoid create huge source file
12156 * with the test vector.
12158 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12159 generate_gmac_large_plaintext(tdata->plaintext.data);
12161 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12162 plaintext_pad_len);
12163 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12165 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12166 debug_hexdump(stdout, "plaintext:", plaintext,
12167 tdata->plaintext.len);
12169 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12175 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12177 ut_params->op->sym->m_src = ut_params->ibuf;
12179 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12180 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12182 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12183 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12184 ut_params->op, 0, 1, 0, 0);
12186 TEST_ASSERT_NOT_NULL(
12187 process_crypto_request(ts_params->valid_devs[0],
12188 ut_params->op), "failed to process sym crypto op");
12190 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12191 "crypto op processing failed");
12193 if (ut_params->op->sym->m_dst) {
12194 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12195 uint8_t *, plaintext_pad_len);
12197 auth_tag = plaintext + plaintext_pad_len;
12200 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12202 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12204 tdata->gmac_tag.data,
12205 tdata->gmac_tag.len,
12206 "GMAC Generated auth tag not as expected");
12212 test_AES_GMAC_authentication_test_case_1(void)
12214 return test_AES_GMAC_authentication(&gmac_test_case_1);
12218 test_AES_GMAC_authentication_test_case_2(void)
12220 return test_AES_GMAC_authentication(&gmac_test_case_2);
12224 test_AES_GMAC_authentication_test_case_3(void)
12226 return test_AES_GMAC_authentication(&gmac_test_case_3);
12230 test_AES_GMAC_authentication_test_case_4(void)
12232 return test_AES_GMAC_authentication(&gmac_test_case_4);
12236 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12238 struct crypto_testsuite_params *ts_params = &testsuite_params;
12239 struct crypto_unittest_params *ut_params = &unittest_params;
12241 uint32_t plaintext_pad_len;
12242 uint8_t *plaintext;
12243 struct rte_cryptodev_info dev_info;
12245 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12246 uint64_t feat_flags = dev_info.feature_flags;
12248 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12249 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12250 printf("Device doesn't support RAW data-path APIs.\n");
12251 return TEST_SKIPPED;
12254 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12255 "No GMAC length in the source data");
12257 /* Verify the capabilities */
12258 struct rte_cryptodev_sym_capability_idx cap_idx;
12259 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12260 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12261 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12263 return TEST_SKIPPED;
12265 retval = create_gmac_session(ts_params->valid_devs[0],
12266 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12268 if (retval == -ENOTSUP)
12269 return TEST_SKIPPED;
12273 if (tdata->plaintext.len > MBUF_SIZE)
12274 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12276 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12277 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12278 "Failed to allocate input buffer in mempool");
12280 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12281 rte_pktmbuf_tailroom(ut_params->ibuf));
12283 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12286 * Runtime generate the large plain text instead of use hard code
12287 * plain text vector. It is done to avoid create huge source file
12288 * with the test vector.
12290 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12291 generate_gmac_large_plaintext(tdata->plaintext.data);
12293 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12294 plaintext_pad_len);
12295 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12297 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12298 debug_hexdump(stdout, "plaintext:", plaintext,
12299 tdata->plaintext.len);
12301 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
12307 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12309 ut_params->op->sym->m_src = ut_params->ibuf;
12311 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12312 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12314 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12315 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12316 ut_params->op, 0, 1, 0, 0);
12318 TEST_ASSERT_NOT_NULL(
12319 process_crypto_request(ts_params->valid_devs[0],
12320 ut_params->op), "failed to process sym crypto op");
12322 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12323 "crypto op processing failed");
12330 test_AES_GMAC_authentication_verify_test_case_1(void)
12332 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12336 test_AES_GMAC_authentication_verify_test_case_2(void)
12338 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12342 test_AES_GMAC_authentication_verify_test_case_3(void)
12344 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12348 test_AES_GMAC_authentication_verify_test_case_4(void)
12350 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12354 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12357 struct crypto_testsuite_params *ts_params = &testsuite_params;
12358 struct crypto_unittest_params *ut_params = &unittest_params;
12359 struct rte_cryptodev_info dev_info;
12360 uint64_t feature_flags;
12361 unsigned int trn_data = 0;
12362 void *digest_mem = NULL;
12364 unsigned int to_trn = 0;
12365 struct rte_mbuf *buf = NULL;
12366 uint8_t *auth_tag, *plaintext;
12369 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12370 "No GMAC length in the source data");
12372 /* Verify the capabilities */
12373 struct rte_cryptodev_sym_capability_idx cap_idx;
12374 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12375 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12376 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12378 return TEST_SKIPPED;
12380 /* Check for any input SGL support */
12381 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12382 feature_flags = dev_info.feature_flags;
12384 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12385 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12386 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12387 return TEST_SKIPPED;
12389 if (fragsz > tdata->plaintext.len)
12390 fragsz = tdata->plaintext.len;
12392 uint16_t plaintext_len = fragsz;
12394 retval = create_gmac_session(ts_params->valid_devs[0],
12395 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12397 if (retval == -ENOTSUP)
12398 return TEST_SKIPPED;
12402 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12403 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12404 "Failed to allocate input buffer in mempool");
12406 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12407 rte_pktmbuf_tailroom(ut_params->ibuf));
12409 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12411 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12413 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12415 trn_data += plaintext_len;
12417 buf = ut_params->ibuf;
12420 * Loop until no more fragments
12423 while (trn_data < tdata->plaintext.len) {
12425 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12426 (tdata->plaintext.len - trn_data) : fragsz;
12428 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12431 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12432 rte_pktmbuf_tailroom(buf));
12434 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12437 memcpy(plaintext, tdata->plaintext.data + trn_data,
12439 trn_data += to_trn;
12440 if (trn_data == tdata->plaintext.len)
12441 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12442 tdata->gmac_tag.len);
12444 ut_params->ibuf->nb_segs = segs;
12447 * Place digest at the end of the last buffer
12449 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12452 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12453 + tdata->gmac_tag.len);
12454 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12455 tdata->plaintext.len);
12458 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12459 tdata, digest_mem, digest_phys);
12464 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12466 ut_params->op->sym->m_src = ut_params->ibuf;
12468 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12469 return TEST_SKIPPED;
12471 TEST_ASSERT_NOT_NULL(
12472 process_crypto_request(ts_params->valid_devs[0],
12473 ut_params->op), "failed to process sym crypto op");
12475 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12476 "crypto op processing failed");
12478 auth_tag = digest_mem;
12479 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12480 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12482 tdata->gmac_tag.data,
12483 tdata->gmac_tag.len,
12484 "GMAC Generated auth tag not as expected");
12489 /* Segment size not multiple of block size (16B) */
12491 test_AES_GMAC_authentication_SGL_40B(void)
12493 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12497 test_AES_GMAC_authentication_SGL_80B(void)
12499 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12503 test_AES_GMAC_authentication_SGL_2048B(void)
12505 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12508 /* Segment size not multiple of block size (16B) */
12510 test_AES_GMAC_authentication_SGL_2047B(void)
12512 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12515 struct test_crypto_vector {
12516 enum rte_crypto_cipher_algorithm crypto_algo;
12517 unsigned int cipher_offset;
12518 unsigned int cipher_len;
12531 const uint8_t *data;
12536 const uint8_t *data;
12540 enum rte_crypto_auth_algorithm auth_algo;
12541 unsigned int auth_offset;
12549 const uint8_t *data;
12559 static const struct test_crypto_vector
12560 hmac_sha1_test_crypto_vector = {
12561 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12563 .data = plaintext_hash,
12568 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12569 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12570 0xDE, 0xF4, 0xDE, 0xAD
12576 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12577 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12578 0x3F, 0x91, 0x64, 0x59
12584 static const struct test_crypto_vector
12585 aes128_gmac_test_vector = {
12586 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12588 .data = plaintext_hash,
12593 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12594 0x08, 0x09, 0x0A, 0x0B
12600 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12601 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12607 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12608 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12614 static const struct test_crypto_vector
12615 aes128cbc_hmac_sha1_test_vector = {
12616 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12617 .cipher_offset = 0,
12621 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12622 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12628 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12629 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12634 .data = plaintext_hash,
12638 .data = ciphertext512_aes128cbc,
12641 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12645 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12646 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12647 0xDE, 0xF4, 0xDE, 0xAD
12653 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12654 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12655 0x18, 0x8C, 0x1D, 0x32
12661 static const struct test_crypto_vector
12662 aes128cbc_hmac_sha1_aad_test_vector = {
12663 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12664 .cipher_offset = 8,
12668 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12669 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12675 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12676 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12681 .data = plaintext_hash,
12685 .data = ciphertext512_aes128cbc_aad,
12688 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12692 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12693 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12694 0xDE, 0xF4, 0xDE, 0xAD
12700 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12701 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12702 0x62, 0x0F, 0xFB, 0x10
12709 data_corruption(uint8_t *data)
12715 tag_corruption(uint8_t *data, unsigned int tag_offset)
12717 data[tag_offset] += 1;
12721 create_auth_session(struct crypto_unittest_params *ut_params,
12723 const struct test_crypto_vector *reference,
12724 enum rte_crypto_auth_operation auth_op)
12726 struct crypto_testsuite_params *ts_params = &testsuite_params;
12727 uint8_t auth_key[reference->auth_key.len + 1];
12730 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12732 /* Setup Authentication Parameters */
12733 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12734 ut_params->auth_xform.auth.op = auth_op;
12735 ut_params->auth_xform.next = NULL;
12736 ut_params->auth_xform.auth.algo = reference->auth_algo;
12737 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12738 ut_params->auth_xform.auth.key.data = auth_key;
12739 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12741 /* Create Crypto session*/
12742 ut_params->sess = rte_cryptodev_sym_session_create(
12743 ts_params->session_mpool);
12744 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12746 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12747 &ut_params->auth_xform,
12748 ts_params->session_priv_mpool);
12754 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12756 const struct test_crypto_vector *reference,
12757 enum rte_crypto_auth_operation auth_op,
12758 enum rte_crypto_cipher_operation cipher_op)
12760 struct crypto_testsuite_params *ts_params = &testsuite_params;
12761 uint8_t cipher_key[reference->cipher_key.len + 1];
12762 uint8_t auth_key[reference->auth_key.len + 1];
12765 memcpy(cipher_key, reference->cipher_key.data,
12766 reference->cipher_key.len);
12767 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12769 /* Setup Authentication Parameters */
12770 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12771 ut_params->auth_xform.auth.op = auth_op;
12772 ut_params->auth_xform.auth.algo = reference->auth_algo;
12773 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12774 ut_params->auth_xform.auth.key.data = auth_key;
12775 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12777 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12778 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12779 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12781 ut_params->auth_xform.next = &ut_params->cipher_xform;
12783 /* Setup Cipher Parameters */
12784 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12785 ut_params->cipher_xform.next = NULL;
12786 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12787 ut_params->cipher_xform.cipher.op = cipher_op;
12788 ut_params->cipher_xform.cipher.key.data = cipher_key;
12789 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12790 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12791 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12794 /* Create Crypto session*/
12795 ut_params->sess = rte_cryptodev_sym_session_create(
12796 ts_params->session_mpool);
12797 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12799 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12800 &ut_params->auth_xform,
12801 ts_params->session_priv_mpool);
12807 create_auth_operation(struct crypto_testsuite_params *ts_params,
12808 struct crypto_unittest_params *ut_params,
12809 const struct test_crypto_vector *reference,
12810 unsigned int auth_generate)
12812 /* Generate Crypto op data structure */
12813 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12814 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12815 TEST_ASSERT_NOT_NULL(ut_params->op,
12816 "Failed to allocate pktmbuf offload");
12818 /* Set crypto operation data parameters */
12819 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12821 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12823 /* set crypto operation source mbuf */
12824 sym_op->m_src = ut_params->ibuf;
12827 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12828 ut_params->ibuf, reference->digest.len);
12830 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12831 "no room to append auth tag");
12833 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12834 ut_params->ibuf, reference->plaintext.len);
12837 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12839 memcpy(sym_op->auth.digest.data,
12840 reference->digest.data,
12841 reference->digest.len);
12843 debug_hexdump(stdout, "digest:",
12844 sym_op->auth.digest.data,
12845 reference->digest.len);
12847 sym_op->auth.data.length = reference->plaintext.len;
12848 sym_op->auth.data.offset = 0;
12854 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12855 struct crypto_unittest_params *ut_params,
12856 const struct test_crypto_vector *reference,
12857 unsigned int auth_generate)
12859 /* Generate Crypto op data structure */
12860 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12861 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12862 TEST_ASSERT_NOT_NULL(ut_params->op,
12863 "Failed to allocate pktmbuf offload");
12865 /* Set crypto operation data parameters */
12866 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12868 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12870 /* set crypto operation source mbuf */
12871 sym_op->m_src = ut_params->ibuf;
12874 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12875 ut_params->ibuf, reference->digest.len);
12877 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12878 "no room to append auth tag");
12880 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12881 ut_params->ibuf, reference->ciphertext.len);
12884 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12886 memcpy(sym_op->auth.digest.data,
12887 reference->digest.data,
12888 reference->digest.len);
12890 debug_hexdump(stdout, "digest:",
12891 sym_op->auth.digest.data,
12892 reference->digest.len);
12894 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12895 reference->iv.data, reference->iv.len);
12897 sym_op->cipher.data.length = 0;
12898 sym_op->cipher.data.offset = 0;
12900 sym_op->auth.data.length = reference->plaintext.len;
12901 sym_op->auth.data.offset = 0;
12907 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12908 struct crypto_unittest_params *ut_params,
12909 const struct test_crypto_vector *reference,
12910 unsigned int auth_generate)
12912 /* Generate Crypto op data structure */
12913 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12914 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12915 TEST_ASSERT_NOT_NULL(ut_params->op,
12916 "Failed to allocate pktmbuf offload");
12918 /* Set crypto operation data parameters */
12919 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12921 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12923 /* set crypto operation source mbuf */
12924 sym_op->m_src = ut_params->ibuf;
12927 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12928 ut_params->ibuf, reference->digest.len);
12930 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12931 "no room to append auth tag");
12933 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12934 ut_params->ibuf, reference->ciphertext.len);
12937 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12939 memcpy(sym_op->auth.digest.data,
12940 reference->digest.data,
12941 reference->digest.len);
12943 debug_hexdump(stdout, "digest:",
12944 sym_op->auth.digest.data,
12945 reference->digest.len);
12947 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12948 reference->iv.data, reference->iv.len);
12950 sym_op->cipher.data.length = reference->cipher_len;
12951 sym_op->cipher.data.offset = reference->cipher_offset;
12953 sym_op->auth.data.length = reference->plaintext.len;
12954 sym_op->auth.data.offset = reference->auth_offset;
12960 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12961 struct crypto_unittest_params *ut_params,
12962 const struct test_crypto_vector *reference)
12964 return create_auth_operation(ts_params, ut_params, reference, 0);
12968 create_auth_verify_GMAC_operation(
12969 struct crypto_testsuite_params *ts_params,
12970 struct crypto_unittest_params *ut_params,
12971 const struct test_crypto_vector *reference)
12973 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12977 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12978 struct crypto_unittest_params *ut_params,
12979 const struct test_crypto_vector *reference)
12981 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12985 test_authentication_verify_fail_when_data_corruption(
12986 struct crypto_testsuite_params *ts_params,
12987 struct crypto_unittest_params *ut_params,
12988 const struct test_crypto_vector *reference,
12989 unsigned int data_corrupted)
12993 uint8_t *plaintext;
12994 struct rte_cryptodev_info dev_info;
12996 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12997 uint64_t feat_flags = dev_info.feature_flags;
12999 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13000 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13001 printf("Device doesn't support RAW data-path APIs.\n");
13002 return TEST_SKIPPED;
13005 /* Verify the capabilities */
13006 struct rte_cryptodev_sym_capability_idx cap_idx;
13007 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13008 cap_idx.algo.auth = reference->auth_algo;
13009 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13011 return TEST_SKIPPED;
13014 /* Create session */
13015 retval = create_auth_session(ut_params,
13016 ts_params->valid_devs[0],
13018 RTE_CRYPTO_AUTH_OP_VERIFY);
13020 if (retval == -ENOTSUP)
13021 return TEST_SKIPPED;
13025 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13026 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13027 "Failed to allocate input buffer in mempool");
13029 /* clear mbuf payload */
13030 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13031 rte_pktmbuf_tailroom(ut_params->ibuf));
13033 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13034 reference->plaintext.len);
13035 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13036 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13038 debug_hexdump(stdout, "plaintext:", plaintext,
13039 reference->plaintext.len);
13041 /* Create operation */
13042 retval = create_auth_verify_operation(ts_params, ut_params, reference);
13047 if (data_corrupted)
13048 data_corruption(plaintext);
13050 tag_corruption(plaintext, reference->plaintext.len);
13052 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13053 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13055 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13056 RTE_CRYPTO_OP_STATUS_SUCCESS,
13057 "authentication not failed");
13058 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13059 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13060 ut_params->op, 0, 1, 0, 0);
13062 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13065 if (ut_params->op == NULL)
13067 else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
13074 test_authentication_verify_GMAC_fail_when_corruption(
13075 struct crypto_testsuite_params *ts_params,
13076 struct crypto_unittest_params *ut_params,
13077 const struct test_crypto_vector *reference,
13078 unsigned int data_corrupted)
13081 uint8_t *plaintext;
13082 struct rte_cryptodev_info dev_info;
13084 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13085 uint64_t feat_flags = dev_info.feature_flags;
13087 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13088 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13089 printf("Device doesn't support RAW data-path APIs.\n");
13090 return TEST_SKIPPED;
13093 /* Verify the capabilities */
13094 struct rte_cryptodev_sym_capability_idx cap_idx;
13095 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13096 cap_idx.algo.auth = reference->auth_algo;
13097 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13099 return TEST_SKIPPED;
13101 /* Create session */
13102 retval = create_auth_cipher_session(ut_params,
13103 ts_params->valid_devs[0],
13105 RTE_CRYPTO_AUTH_OP_VERIFY,
13106 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13110 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13111 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13112 "Failed to allocate input buffer in mempool");
13114 /* clear mbuf payload */
13115 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13116 rte_pktmbuf_tailroom(ut_params->ibuf));
13118 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13119 reference->plaintext.len);
13120 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13121 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13123 debug_hexdump(stdout, "plaintext:", plaintext,
13124 reference->plaintext.len);
13126 /* Create operation */
13127 retval = create_auth_verify_GMAC_operation(ts_params,
13134 if (data_corrupted)
13135 data_corruption(plaintext);
13137 tag_corruption(plaintext, reference->aad.len);
13139 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13140 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13142 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13143 RTE_CRYPTO_OP_STATUS_SUCCESS,
13144 "authentication not failed");
13145 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13146 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13147 ut_params->op, 0, 1, 0, 0);
13149 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13151 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13158 test_authenticated_decryption_fail_when_corruption(
13159 struct crypto_testsuite_params *ts_params,
13160 struct crypto_unittest_params *ut_params,
13161 const struct test_crypto_vector *reference,
13162 unsigned int data_corrupted)
13166 uint8_t *ciphertext;
13167 struct rte_cryptodev_info dev_info;
13169 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13170 uint64_t feat_flags = dev_info.feature_flags;
13172 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13173 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13174 printf("Device doesn't support RAW data-path APIs.\n");
13175 return TEST_SKIPPED;
13178 /* Verify the capabilities */
13179 struct rte_cryptodev_sym_capability_idx cap_idx;
13180 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13181 cap_idx.algo.auth = reference->auth_algo;
13182 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13184 return TEST_SKIPPED;
13185 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13186 cap_idx.algo.cipher = reference->crypto_algo;
13187 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13189 return TEST_SKIPPED;
13191 /* Create session */
13192 retval = create_auth_cipher_session(ut_params,
13193 ts_params->valid_devs[0],
13195 RTE_CRYPTO_AUTH_OP_VERIFY,
13196 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13198 if (retval == -ENOTSUP)
13199 return TEST_SKIPPED;
13203 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13204 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13205 "Failed to allocate input buffer in mempool");
13207 /* clear mbuf payload */
13208 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13209 rte_pktmbuf_tailroom(ut_params->ibuf));
13211 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13212 reference->ciphertext.len);
13213 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13214 memcpy(ciphertext, reference->ciphertext.data,
13215 reference->ciphertext.len);
13217 /* Create operation */
13218 retval = create_cipher_auth_verify_operation(ts_params,
13225 if (data_corrupted)
13226 data_corruption(ciphertext);
13228 tag_corruption(ciphertext, reference->ciphertext.len);
13230 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13231 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13233 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13234 RTE_CRYPTO_OP_STATUS_SUCCESS,
13235 "authentication not failed");
13236 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13237 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13238 ut_params->op, 1, 1, 0, 0);
13240 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13242 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13249 test_authenticated_encrypt_with_esn(
13250 struct crypto_testsuite_params *ts_params,
13251 struct crypto_unittest_params *ut_params,
13252 const struct test_crypto_vector *reference)
13256 uint8_t *authciphertext, *plaintext, *auth_tag;
13257 uint16_t plaintext_pad_len;
13258 uint8_t cipher_key[reference->cipher_key.len + 1];
13259 uint8_t auth_key[reference->auth_key.len + 1];
13260 struct rte_cryptodev_info dev_info;
13263 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13264 uint64_t feat_flags = dev_info.feature_flags;
13266 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13267 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13268 printf("Device doesn't support RAW data-path APIs.\n");
13269 return TEST_SKIPPED;
13272 /* Verify the capabilities */
13273 struct rte_cryptodev_sym_capability_idx cap_idx;
13274 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13275 cap_idx.algo.auth = reference->auth_algo;
13276 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13278 return TEST_SKIPPED;
13279 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13280 cap_idx.algo.cipher = reference->crypto_algo;
13281 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13283 return TEST_SKIPPED;
13285 /* Create session */
13286 memcpy(cipher_key, reference->cipher_key.data,
13287 reference->cipher_key.len);
13288 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13290 /* Setup Cipher Parameters */
13291 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13292 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13293 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13294 ut_params->cipher_xform.cipher.key.data = cipher_key;
13295 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13296 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13297 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13299 ut_params->cipher_xform.next = &ut_params->auth_xform;
13301 /* Setup Authentication Parameters */
13302 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13303 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13304 ut_params->auth_xform.auth.algo = reference->auth_algo;
13305 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13306 ut_params->auth_xform.auth.key.data = auth_key;
13307 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13308 ut_params->auth_xform.next = NULL;
13310 /* Create Crypto session*/
13311 ut_params->sess = rte_cryptodev_sym_session_create(
13312 ts_params->session_mpool);
13313 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13315 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13317 &ut_params->cipher_xform,
13318 ts_params->session_priv_mpool);
13320 if (status == -ENOTSUP)
13321 return TEST_SKIPPED;
13323 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
13325 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13326 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13327 "Failed to allocate input buffer in mempool");
13329 /* clear mbuf payload */
13330 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13331 rte_pktmbuf_tailroom(ut_params->ibuf));
13333 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13334 reference->plaintext.len);
13335 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13336 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13338 /* Create operation */
13339 retval = create_cipher_auth_operation(ts_params,
13346 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13347 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13349 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13350 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13351 ut_params->op, 1, 1, 0, 0);
13353 ut_params->op = process_crypto_request(
13354 ts_params->valid_devs[0], ut_params->op);
13356 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13358 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13359 "crypto op processing failed");
13361 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13363 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13364 ut_params->op->sym->auth.data.offset);
13365 auth_tag = authciphertext + plaintext_pad_len;
13366 debug_hexdump(stdout, "ciphertext:", authciphertext,
13367 reference->ciphertext.len);
13368 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13370 /* Validate obuf */
13371 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13373 reference->ciphertext.data,
13374 reference->ciphertext.len,
13375 "Ciphertext data not as expected");
13377 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13379 reference->digest.data,
13380 reference->digest.len,
13381 "Generated digest not as expected");
13383 return TEST_SUCCESS;
13388 test_authenticated_decrypt_with_esn(
13389 struct crypto_testsuite_params *ts_params,
13390 struct crypto_unittest_params *ut_params,
13391 const struct test_crypto_vector *reference)
13395 uint8_t *ciphertext;
13396 uint8_t cipher_key[reference->cipher_key.len + 1];
13397 uint8_t auth_key[reference->auth_key.len + 1];
13398 struct rte_cryptodev_info dev_info;
13400 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13401 uint64_t feat_flags = dev_info.feature_flags;
13403 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13404 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13405 printf("Device doesn't support RAW data-path APIs.\n");
13406 return TEST_SKIPPED;
13409 /* Verify the capabilities */
13410 struct rte_cryptodev_sym_capability_idx cap_idx;
13411 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13412 cap_idx.algo.auth = reference->auth_algo;
13413 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13415 return TEST_SKIPPED;
13416 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13417 cap_idx.algo.cipher = reference->crypto_algo;
13418 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13420 return TEST_SKIPPED;
13422 /* Create session */
13423 memcpy(cipher_key, reference->cipher_key.data,
13424 reference->cipher_key.len);
13425 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13427 /* Setup Authentication Parameters */
13428 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13429 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13430 ut_params->auth_xform.auth.algo = reference->auth_algo;
13431 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13432 ut_params->auth_xform.auth.key.data = auth_key;
13433 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13434 ut_params->auth_xform.next = &ut_params->cipher_xform;
13436 /* Setup Cipher Parameters */
13437 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13438 ut_params->cipher_xform.next = NULL;
13439 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13440 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13441 ut_params->cipher_xform.cipher.key.data = cipher_key;
13442 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13443 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13444 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13446 /* Create Crypto session*/
13447 ut_params->sess = rte_cryptodev_sym_session_create(
13448 ts_params->session_mpool);
13449 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13451 retval = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13453 &ut_params->auth_xform,
13454 ts_params->session_priv_mpool);
13456 if (retval == -ENOTSUP)
13457 return TEST_SKIPPED;
13459 TEST_ASSERT_EQUAL(retval, 0, "Session init failed");
13461 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13462 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13463 "Failed to allocate input buffer in mempool");
13465 /* clear mbuf payload */
13466 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13467 rte_pktmbuf_tailroom(ut_params->ibuf));
13469 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13470 reference->ciphertext.len);
13471 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13472 memcpy(ciphertext, reference->ciphertext.data,
13473 reference->ciphertext.len);
13475 /* Create operation */
13476 retval = create_cipher_auth_verify_operation(ts_params,
13483 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13484 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13486 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13487 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13488 ut_params->op, 1, 1, 0, 0);
13490 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13493 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13494 TEST_ASSERT_EQUAL(ut_params->op->status,
13495 RTE_CRYPTO_OP_STATUS_SUCCESS,
13496 "crypto op processing passed");
13498 ut_params->obuf = ut_params->op->sym->m_src;
13499 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13505 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13506 const struct aead_test_data *tdata,
13507 void *digest_mem, uint64_t digest_phys)
13509 struct crypto_testsuite_params *ts_params = &testsuite_params;
13510 struct crypto_unittest_params *ut_params = &unittest_params;
13512 const unsigned int auth_tag_len = tdata->auth_tag.len;
13513 const unsigned int iv_len = tdata->iv.len;
13514 unsigned int aad_len = tdata->aad.len;
13515 unsigned int aad_len_pad = 0;
13517 /* Generate Crypto op data structure */
13518 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13519 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13520 TEST_ASSERT_NOT_NULL(ut_params->op,
13521 "Failed to allocate symmetric crypto operation struct");
13523 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13525 sym_op->aead.digest.data = digest_mem;
13527 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13528 "no room to append digest");
13530 sym_op->aead.digest.phys_addr = digest_phys;
13532 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13533 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13535 debug_hexdump(stdout, "digest:",
13536 sym_op->aead.digest.data,
13540 /* Append aad data */
13541 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13542 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13543 uint8_t *, IV_OFFSET);
13545 /* Copy IV 1 byte after the IV pointer, according to the API */
13546 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13548 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13550 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13551 ut_params->ibuf, aad_len);
13552 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13553 "no room to prepend aad");
13554 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13557 memset(sym_op->aead.aad.data, 0, aad_len);
13558 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
13559 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13561 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13562 debug_hexdump(stdout, "aad:",
13563 sym_op->aead.aad.data, aad_len);
13565 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13566 uint8_t *, IV_OFFSET);
13568 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13570 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13572 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13573 ut_params->ibuf, aad_len_pad);
13574 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13575 "no room to prepend aad");
13576 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13579 memset(sym_op->aead.aad.data, 0, aad_len);
13580 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13582 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13583 debug_hexdump(stdout, "aad:",
13584 sym_op->aead.aad.data, aad_len);
13587 sym_op->aead.data.length = tdata->plaintext.len;
13588 sym_op->aead.data.offset = aad_len_pad;
13593 #define SGL_MAX_NO 16
13596 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13597 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13599 struct crypto_testsuite_params *ts_params = &testsuite_params;
13600 struct crypto_unittest_params *ut_params = &unittest_params;
13601 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13604 int to_trn_tbl[SGL_MAX_NO];
13606 unsigned int trn_data = 0;
13607 uint8_t *plaintext, *ciphertext, *auth_tag;
13608 struct rte_cryptodev_info dev_info;
13610 /* Verify the capabilities */
13611 struct rte_cryptodev_sym_capability_idx cap_idx;
13612 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13613 cap_idx.algo.aead = tdata->algo;
13614 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13616 return TEST_SKIPPED;
13618 /* OOP not supported with CPU crypto */
13619 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13620 return TEST_SKIPPED;
13622 /* Detailed check for the particular SGL support flag */
13623 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13625 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13626 if (sgl_in && (!(dev_info.feature_flags &
13627 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13628 return TEST_SKIPPED;
13630 uint64_t feat_flags = dev_info.feature_flags;
13632 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13633 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13634 printf("Device doesn't support RAW data-path APIs.\n");
13635 return TEST_SKIPPED;
13638 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13639 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13640 tdata->plaintext.len;
13641 /* Raw data path API does not support OOP */
13642 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13643 return TEST_SKIPPED;
13644 if (sgl_in && !sgl_out) {
13645 if (!(dev_info.feature_flags &
13646 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13647 return TEST_SKIPPED;
13648 } else if (!sgl_in && sgl_out) {
13649 if (!(dev_info.feature_flags &
13650 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13651 return TEST_SKIPPED;
13652 } else if (sgl_in && sgl_out) {
13653 if (!(dev_info.feature_flags &
13654 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13655 return TEST_SKIPPED;
13659 if (fragsz > tdata->plaintext.len)
13660 fragsz = tdata->plaintext.len;
13662 uint16_t plaintext_len = fragsz;
13663 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13665 if (fragsz_oop > tdata->plaintext.len)
13666 frag_size_oop = tdata->plaintext.len;
13669 void *digest_mem = NULL;
13671 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13673 if (tdata->plaintext.len % fragsz != 0) {
13674 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13677 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13682 * For out-op-place we need to alloc another mbuf
13685 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13686 rte_pktmbuf_append(ut_params->obuf,
13687 frag_size_oop + prepend_len);
13688 buf_oop = ut_params->obuf;
13691 /* Create AEAD session */
13692 retval = create_aead_session(ts_params->valid_devs[0],
13694 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13695 tdata->key.data, tdata->key.len,
13696 tdata->aad.len, tdata->auth_tag.len,
13701 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13703 /* clear mbuf payload */
13704 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13705 rte_pktmbuf_tailroom(ut_params->ibuf));
13707 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13710 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13712 trn_data += plaintext_len;
13714 buf = ut_params->ibuf;
13717 * Loop until no more fragments
13720 while (trn_data < tdata->plaintext.len) {
13722 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13723 (tdata->plaintext.len - trn_data) : fragsz;
13725 to_trn_tbl[ecx++] = to_trn;
13727 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13730 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13731 rte_pktmbuf_tailroom(buf));
13734 if (oop && !fragsz_oop) {
13735 buf_last_oop = buf_oop->next =
13736 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13737 buf_oop = buf_oop->next;
13738 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13739 0, rte_pktmbuf_tailroom(buf_oop));
13740 rte_pktmbuf_append(buf_oop, to_trn);
13743 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13746 memcpy(plaintext, tdata->plaintext.data + trn_data,
13748 trn_data += to_trn;
13749 if (trn_data == tdata->plaintext.len) {
13752 digest_mem = rte_pktmbuf_append(buf_oop,
13753 tdata->auth_tag.len);
13755 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13756 tdata->auth_tag.len);
13760 uint64_t digest_phys = 0;
13762 ut_params->ibuf->nb_segs = segs;
13765 if (fragsz_oop && oop) {
13769 if (frag_size_oop == tdata->plaintext.len) {
13770 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13771 tdata->auth_tag.len);
13773 digest_phys = rte_pktmbuf_iova_offset(
13775 tdata->plaintext.len + prepend_len);
13778 trn_data = frag_size_oop;
13779 while (trn_data < tdata->plaintext.len) {
13782 (tdata->plaintext.len - trn_data <
13784 (tdata->plaintext.len - trn_data) :
13787 to_trn_tbl[ecx++] = to_trn;
13789 buf_last_oop = buf_oop->next =
13790 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13791 buf_oop = buf_oop->next;
13792 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13793 0, rte_pktmbuf_tailroom(buf_oop));
13794 rte_pktmbuf_append(buf_oop, to_trn);
13796 trn_data += to_trn;
13798 if (trn_data == tdata->plaintext.len) {
13799 digest_mem = rte_pktmbuf_append(buf_oop,
13800 tdata->auth_tag.len);
13804 ut_params->obuf->nb_segs = segs;
13808 * Place digest at the end of the last buffer
13811 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13812 if (oop && buf_last_oop)
13813 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13815 if (!digest_mem && !oop) {
13816 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13817 + tdata->auth_tag.len);
13818 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13819 tdata->plaintext.len);
13822 /* Create AEAD operation */
13823 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13824 tdata, digest_mem, digest_phys);
13829 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13831 ut_params->op->sym->m_src = ut_params->ibuf;
13833 ut_params->op->sym->m_dst = ut_params->obuf;
13835 /* Process crypto operation */
13836 if (oop == IN_PLACE &&
13837 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13838 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13839 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13840 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13841 ut_params->op, 0, 0, 0, 0);
13843 TEST_ASSERT_NOT_NULL(
13844 process_crypto_request(ts_params->valid_devs[0],
13845 ut_params->op), "failed to process sym crypto op");
13847 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13848 "crypto op processing failed");
13851 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13852 uint8_t *, prepend_len);
13854 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13855 uint8_t *, prepend_len);
13859 fragsz = fragsz_oop;
13861 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13863 tdata->ciphertext.data,
13865 "Ciphertext data not as expected");
13867 buf = ut_params->op->sym->m_src->next;
13869 buf = ut_params->op->sym->m_dst->next;
13871 unsigned int off = fragsz;
13875 ciphertext = rte_pktmbuf_mtod(buf,
13878 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13880 tdata->ciphertext.data + off,
13882 "Ciphertext data not as expected");
13884 off += to_trn_tbl[ecx++];
13888 auth_tag = digest_mem;
13889 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13891 tdata->auth_tag.data,
13892 tdata->auth_tag.len,
13893 "Generated auth tag not as expected");
13899 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13901 return test_authenticated_encryption_SGL(
13902 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13906 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13908 return test_authenticated_encryption_SGL(
13909 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13913 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13915 return test_authenticated_encryption_SGL(
13916 &gcm_test_case_8, OUT_OF_PLACE, 400,
13917 gcm_test_case_8.plaintext.len);
13921 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13923 /* This test is not for OPENSSL PMD */
13924 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13925 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13926 return TEST_SKIPPED;
13928 return test_authenticated_encryption_SGL(
13929 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13933 test_authentication_verify_fail_when_data_corrupted(
13934 struct crypto_testsuite_params *ts_params,
13935 struct crypto_unittest_params *ut_params,
13936 const struct test_crypto_vector *reference)
13938 return test_authentication_verify_fail_when_data_corruption(
13939 ts_params, ut_params, reference, 1);
13943 test_authentication_verify_fail_when_tag_corrupted(
13944 struct crypto_testsuite_params *ts_params,
13945 struct crypto_unittest_params *ut_params,
13946 const struct test_crypto_vector *reference)
13948 return test_authentication_verify_fail_when_data_corruption(
13949 ts_params, ut_params, reference, 0);
13953 test_authentication_verify_GMAC_fail_when_data_corrupted(
13954 struct crypto_testsuite_params *ts_params,
13955 struct crypto_unittest_params *ut_params,
13956 const struct test_crypto_vector *reference)
13958 return test_authentication_verify_GMAC_fail_when_corruption(
13959 ts_params, ut_params, reference, 1);
13963 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13964 struct crypto_testsuite_params *ts_params,
13965 struct crypto_unittest_params *ut_params,
13966 const struct test_crypto_vector *reference)
13968 return test_authentication_verify_GMAC_fail_when_corruption(
13969 ts_params, ut_params, reference, 0);
13973 test_authenticated_decryption_fail_when_data_corrupted(
13974 struct crypto_testsuite_params *ts_params,
13975 struct crypto_unittest_params *ut_params,
13976 const struct test_crypto_vector *reference)
13978 return test_authenticated_decryption_fail_when_corruption(
13979 ts_params, ut_params, reference, 1);
13983 test_authenticated_decryption_fail_when_tag_corrupted(
13984 struct crypto_testsuite_params *ts_params,
13985 struct crypto_unittest_params *ut_params,
13986 const struct test_crypto_vector *reference)
13988 return test_authenticated_decryption_fail_when_corruption(
13989 ts_params, ut_params, reference, 0);
13993 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13995 return test_authentication_verify_fail_when_data_corrupted(
13996 &testsuite_params, &unittest_params,
13997 &hmac_sha1_test_crypto_vector);
14001 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
14003 return test_authentication_verify_fail_when_tag_corrupted(
14004 &testsuite_params, &unittest_params,
14005 &hmac_sha1_test_crypto_vector);
14009 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
14011 return test_authentication_verify_GMAC_fail_when_data_corrupted(
14012 &testsuite_params, &unittest_params,
14013 &aes128_gmac_test_vector);
14017 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
14019 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
14020 &testsuite_params, &unittest_params,
14021 &aes128_gmac_test_vector);
14025 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
14027 return test_authenticated_decryption_fail_when_data_corrupted(
14030 &aes128cbc_hmac_sha1_test_vector);
14034 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
14036 return test_authenticated_decryption_fail_when_tag_corrupted(
14039 &aes128cbc_hmac_sha1_test_vector);
14043 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14045 return test_authenticated_encrypt_with_esn(
14048 &aes128cbc_hmac_sha1_aad_test_vector);
14052 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14054 return test_authenticated_decrypt_with_esn(
14057 &aes128cbc_hmac_sha1_aad_test_vector);
14061 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
14063 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
14067 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
14069 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
14073 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
14075 return test_authenticated_encryption_SGL(
14076 &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
14077 chacha20_poly1305_case_2.plaintext.len);
14080 #ifdef RTE_CRYPTO_SCHEDULER
14082 /* global AESNI worker IDs for the scheduler test */
14083 uint8_t aesni_ids[2];
14086 scheduler_testsuite_setup(void)
14089 int32_t nb_devs, ret;
14090 char vdev_args[VDEV_ARGS_SIZE] = {""};
14091 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14092 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
14093 uint16_t worker_core_count = 0;
14094 uint16_t socket_id = 0;
14096 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14097 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14099 /* Identify the Worker Cores
14100 * Use 2 worker cores for the device args
14102 RTE_LCORE_FOREACH_WORKER(i) {
14103 if (worker_core_count > 1)
14105 snprintf(vdev_args, sizeof(vdev_args),
14106 "%s%d", temp_str, i);
14107 strcpy(temp_str, vdev_args);
14108 strlcat(temp_str, ";", sizeof(temp_str));
14109 worker_core_count++;
14110 socket_id = rte_lcore_to_socket_id(i);
14112 if (worker_core_count != 2) {
14113 RTE_LOG(ERR, USER1,
14114 "Cryptodev scheduler test require at least "
14115 "two worker cores to run. "
14116 "Please use the correct coremask.\n");
14117 return TEST_FAILED;
14119 strcpy(temp_str, vdev_args);
14120 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14121 temp_str, socket_id);
14122 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14123 nb_devs = rte_cryptodev_device_count_by_driver(
14124 rte_cryptodev_driver_id_get(
14125 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14127 ret = rte_vdev_init(
14128 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14130 TEST_ASSERT(ret == 0,
14131 "Failed to create instance %u of pmd : %s",
14132 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14135 return testsuite_setup();
14139 test_scheduler_attach_worker_op(void)
14141 struct crypto_testsuite_params *ts_params = &testsuite_params;
14142 uint8_t sched_id = ts_params->valid_devs[0];
14143 uint32_t i, nb_devs_attached = 0;
14145 char vdev_name[32];
14146 unsigned int count = rte_cryptodev_count();
14148 /* create 2 AESNI_MB vdevs on top of existing devices */
14149 for (i = count; i < count + 2; i++) {
14150 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14151 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14153 ret = rte_vdev_init(vdev_name, NULL);
14155 TEST_ASSERT(ret == 0,
14156 "Failed to create instance %u of"
14158 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14161 RTE_LOG(ERR, USER1,
14162 "Failed to create 2 AESNI MB PMDs.\n");
14163 return TEST_SKIPPED;
14167 /* attach 2 AESNI_MB cdevs */
14168 for (i = count; i < count + 2; i++) {
14169 struct rte_cryptodev_info info;
14170 unsigned int session_size;
14172 rte_cryptodev_info_get(i, &info);
14173 if (info.driver_id != rte_cryptodev_driver_id_get(
14174 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14177 session_size = rte_cryptodev_sym_get_private_session_size(i);
14179 * Create the session mempool again, since now there are new devices
14180 * to use the mempool.
14182 if (ts_params->session_mpool) {
14183 rte_mempool_free(ts_params->session_mpool);
14184 ts_params->session_mpool = NULL;
14186 if (ts_params->session_priv_mpool) {
14187 rte_mempool_free(ts_params->session_priv_mpool);
14188 ts_params->session_priv_mpool = NULL;
14191 if (info.sym.max_nb_sessions != 0 &&
14192 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14193 RTE_LOG(ERR, USER1,
14194 "Device does not support "
14195 "at least %u sessions\n",
14197 return TEST_FAILED;
14200 * Create mempool with maximum number of sessions,
14201 * to include the session headers
14203 if (ts_params->session_mpool == NULL) {
14204 ts_params->session_mpool =
14205 rte_cryptodev_sym_session_pool_create(
14207 MAX_NB_SESSIONS, 0, 0, 0,
14209 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14210 "session mempool allocation failed");
14214 * Create mempool with maximum number of sessions,
14215 * to include device specific session private data
14217 if (ts_params->session_priv_mpool == NULL) {
14218 ts_params->session_priv_mpool = rte_mempool_create(
14219 "test_sess_mp_priv",
14222 0, 0, NULL, NULL, NULL,
14223 NULL, SOCKET_ID_ANY,
14226 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14227 "session mempool allocation failed");
14230 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14231 ts_params->qp_conf.mp_session_private =
14232 ts_params->session_priv_mpool;
14234 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14237 TEST_ASSERT(ret == 0,
14238 "Failed to attach device %u of pmd : %s", i,
14239 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14241 aesni_ids[nb_devs_attached] = (uint8_t)i;
14243 nb_devs_attached++;
14250 test_scheduler_detach_worker_op(void)
14252 struct crypto_testsuite_params *ts_params = &testsuite_params;
14253 uint8_t sched_id = ts_params->valid_devs[0];
14257 for (i = 0; i < 2; i++) {
14258 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14260 TEST_ASSERT(ret == 0,
14261 "Failed to detach device %u", aesni_ids[i]);
14268 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14270 struct crypto_testsuite_params *ts_params = &testsuite_params;
14271 uint8_t sched_id = ts_params->valid_devs[0];
14273 return rte_cryptodev_scheduler_mode_set(sched_id,
14278 test_scheduler_mode_roundrobin_op(void)
14280 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14281 0, "Failed to set roundrobin mode");
14287 test_scheduler_mode_multicore_op(void)
14289 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14290 0, "Failed to set multicore mode");
14296 test_scheduler_mode_failover_op(void)
14298 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
14299 0, "Failed to set failover mode");
14305 test_scheduler_mode_pkt_size_distr_op(void)
14307 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
14308 0, "Failed to set pktsize mode");
14314 scheduler_multicore_testsuite_setup(void)
14316 if (test_scheduler_attach_worker_op() < 0)
14317 return TEST_SKIPPED;
14318 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
14319 return TEST_SKIPPED;
14324 scheduler_roundrobin_testsuite_setup(void)
14326 if (test_scheduler_attach_worker_op() < 0)
14327 return TEST_SKIPPED;
14328 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
14329 return TEST_SKIPPED;
14334 scheduler_failover_testsuite_setup(void)
14336 if (test_scheduler_attach_worker_op() < 0)
14337 return TEST_SKIPPED;
14338 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
14339 return TEST_SKIPPED;
14344 scheduler_pkt_size_distr_testsuite_setup(void)
14346 if (test_scheduler_attach_worker_op() < 0)
14347 return TEST_SKIPPED;
14348 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14349 return TEST_SKIPPED;
14354 scheduler_mode_testsuite_teardown(void)
14356 test_scheduler_detach_worker_op();
14359 #endif /* RTE_CRYPTO_SCHEDULER */
14361 static struct unit_test_suite end_testsuite = {
14362 .suite_name = NULL,
14365 .unit_test_suites = NULL
14368 #ifdef RTE_LIB_SECURITY
14369 static struct unit_test_suite ipsec_proto_testsuite = {
14370 .suite_name = "IPsec Proto Unit Test Suite",
14371 .setup = ipsec_proto_testsuite_setup,
14372 .unit_test_cases = {
14373 TEST_CASE_NAMED_WITH_DATA(
14374 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14375 ut_setup_security, ut_teardown,
14376 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
14377 TEST_CASE_NAMED_WITH_DATA(
14378 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14379 ut_setup_security, ut_teardown,
14380 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
14381 TEST_CASE_NAMED_WITH_DATA(
14382 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14383 ut_setup_security, ut_teardown,
14384 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
14385 TEST_CASE_NAMED_WITH_DATA(
14386 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14387 ut_setup_security, ut_teardown,
14388 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14389 TEST_CASE_NAMED_WITH_DATA(
14390 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14391 ut_setup_security, ut_teardown,
14392 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14393 TEST_CASE_NAMED_WITH_DATA(
14394 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14395 ut_setup_security, ut_teardown,
14396 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14397 TEST_CASE_NAMED_ST(
14398 "Combined test alg list",
14399 ut_setup_security, ut_teardown,
14400 test_ipsec_proto_display_list),
14401 TEST_CASE_NAMED_ST(
14403 ut_setup_security, ut_teardown,
14404 test_ipsec_proto_iv_gen),
14405 TEST_CASE_NAMED_ST(
14406 "UDP encapsulation",
14407 ut_setup_security, ut_teardown,
14408 test_ipsec_proto_udp_encap),
14409 TEST_CASE_NAMED_ST(
14410 "UDP encapsulation ports verification test",
14411 ut_setup_security, ut_teardown,
14412 test_ipsec_proto_udp_ports_verify),
14413 TEST_CASE_NAMED_ST(
14414 "SA expiry packets soft",
14415 ut_setup_security, ut_teardown,
14416 test_ipsec_proto_sa_exp_pkts_soft),
14417 TEST_CASE_NAMED_ST(
14418 "SA expiry packets hard",
14419 ut_setup_security, ut_teardown,
14420 test_ipsec_proto_sa_exp_pkts_hard),
14421 TEST_CASE_NAMED_ST(
14422 "Negative test: ICV corruption",
14423 ut_setup_security, ut_teardown,
14424 test_ipsec_proto_err_icv_corrupt),
14425 TEST_CASE_NAMED_ST(
14426 "Tunnel dst addr verification",
14427 ut_setup_security, ut_teardown,
14428 test_ipsec_proto_tunnel_dst_addr_verify),
14429 TEST_CASE_NAMED_ST(
14430 "Tunnel src and dst addr verification",
14431 ut_setup_security, ut_teardown,
14432 test_ipsec_proto_tunnel_src_dst_addr_verify),
14433 TEST_CASE_NAMED_ST(
14434 "Inner IP checksum",
14435 ut_setup_security, ut_teardown,
14436 test_ipsec_proto_inner_ip_csum),
14437 TEST_CASE_NAMED_ST(
14438 "Inner L4 checksum",
14439 ut_setup_security, ut_teardown,
14440 test_ipsec_proto_inner_l4_csum),
14441 TEST_CASES_END() /**< NULL terminate unit test array */
14445 static struct unit_test_suite pdcp_proto_testsuite = {
14446 .suite_name = "PDCP Proto Unit Test Suite",
14447 .setup = pdcp_proto_testsuite_setup,
14448 .unit_test_cases = {
14449 TEST_CASE_ST(ut_setup_security, ut_teardown,
14450 test_PDCP_PROTO_all),
14451 TEST_CASES_END() /**< NULL terminate unit test array */
14455 #define ADD_UPLINK_TESTCASE(data) \
14456 TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
14457 ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
14459 #define ADD_DOWNLINK_TESTCASE(data) \
14460 TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
14461 ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
14463 static struct unit_test_suite docsis_proto_testsuite = {
14464 .suite_name = "DOCSIS Proto Unit Test Suite",
14465 .setup = docsis_proto_testsuite_setup,
14466 .unit_test_cases = {
14468 ADD_UPLINK_TESTCASE(docsis_test_case_1)
14469 ADD_UPLINK_TESTCASE(docsis_test_case_2)
14470 ADD_UPLINK_TESTCASE(docsis_test_case_3)
14471 ADD_UPLINK_TESTCASE(docsis_test_case_4)
14472 ADD_UPLINK_TESTCASE(docsis_test_case_5)
14473 ADD_UPLINK_TESTCASE(docsis_test_case_6)
14474 ADD_UPLINK_TESTCASE(docsis_test_case_7)
14475 ADD_UPLINK_TESTCASE(docsis_test_case_8)
14476 ADD_UPLINK_TESTCASE(docsis_test_case_9)
14477 ADD_UPLINK_TESTCASE(docsis_test_case_10)
14478 ADD_UPLINK_TESTCASE(docsis_test_case_11)
14479 ADD_UPLINK_TESTCASE(docsis_test_case_12)
14480 ADD_UPLINK_TESTCASE(docsis_test_case_13)
14481 ADD_UPLINK_TESTCASE(docsis_test_case_14)
14482 ADD_UPLINK_TESTCASE(docsis_test_case_15)
14483 ADD_UPLINK_TESTCASE(docsis_test_case_16)
14484 ADD_UPLINK_TESTCASE(docsis_test_case_17)
14485 ADD_UPLINK_TESTCASE(docsis_test_case_18)
14486 ADD_UPLINK_TESTCASE(docsis_test_case_19)
14487 ADD_UPLINK_TESTCASE(docsis_test_case_20)
14488 ADD_UPLINK_TESTCASE(docsis_test_case_21)
14489 ADD_UPLINK_TESTCASE(docsis_test_case_22)
14490 ADD_UPLINK_TESTCASE(docsis_test_case_23)
14491 ADD_UPLINK_TESTCASE(docsis_test_case_24)
14492 ADD_UPLINK_TESTCASE(docsis_test_case_25)
14493 ADD_UPLINK_TESTCASE(docsis_test_case_26)
14495 ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
14496 ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
14497 ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
14498 ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
14499 ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
14500 ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
14501 ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
14502 ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
14503 ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
14504 ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
14505 ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
14506 ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
14507 ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
14508 ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
14509 ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
14510 ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
14511 ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
14512 ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
14513 ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
14514 ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
14515 ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
14516 ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
14517 ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
14518 ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
14519 ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
14520 ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
14521 TEST_CASES_END() /**< NULL terminate unit test array */
14526 static struct unit_test_suite cryptodev_gen_testsuite = {
14527 .suite_name = "Crypto General Unit Test Suite",
14528 .setup = crypto_gen_testsuite_setup,
14529 .unit_test_cases = {
14530 TEST_CASE_ST(ut_setup, ut_teardown,
14531 test_device_configure_invalid_dev_id),
14532 TEST_CASE_ST(ut_setup, ut_teardown,
14533 test_queue_pair_descriptor_setup),
14534 TEST_CASE_ST(ut_setup, ut_teardown,
14535 test_device_configure_invalid_queue_pair_ids),
14536 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
14537 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
14538 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
14539 TEST_CASES_END() /**< NULL terminate unit test array */
14543 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
14544 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
14545 .setup = negative_hmac_sha1_testsuite_setup,
14546 .unit_test_cases = {
14547 /** Negative tests */
14548 TEST_CASE_ST(ut_setup, ut_teardown,
14549 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14550 TEST_CASE_ST(ut_setup, ut_teardown,
14551 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14552 TEST_CASE_ST(ut_setup, ut_teardown,
14553 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14554 TEST_CASE_ST(ut_setup, ut_teardown,
14555 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14557 TEST_CASES_END() /**< NULL terminate unit test array */
14561 static struct unit_test_suite cryptodev_multi_session_testsuite = {
14562 .suite_name = "Multi Session Unit Test Suite",
14563 .setup = multi_session_testsuite_setup,
14564 .unit_test_cases = {
14565 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14566 TEST_CASE_ST(ut_setup, ut_teardown,
14567 test_multi_session_random_usage),
14569 TEST_CASES_END() /**< NULL terminate unit test array */
14573 static struct unit_test_suite cryptodev_null_testsuite = {
14574 .suite_name = "NULL Test Suite",
14575 .setup = null_testsuite_setup,
14576 .unit_test_cases = {
14577 TEST_CASE_ST(ut_setup, ut_teardown,
14578 test_null_invalid_operation),
14579 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
14584 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
14585 .suite_name = "AES CCM Authenticated Test Suite",
14586 .setup = aes_ccm_auth_testsuite_setup,
14587 .unit_test_cases = {
14588 /** AES CCM Authenticated Encryption 128 bits key*/
14589 TEST_CASE_ST(ut_setup, ut_teardown,
14590 test_AES_CCM_authenticated_encryption_test_case_128_1),
14591 TEST_CASE_ST(ut_setup, ut_teardown,
14592 test_AES_CCM_authenticated_encryption_test_case_128_2),
14593 TEST_CASE_ST(ut_setup, ut_teardown,
14594 test_AES_CCM_authenticated_encryption_test_case_128_3),
14596 /** AES CCM Authenticated Decryption 128 bits key*/
14597 TEST_CASE_ST(ut_setup, ut_teardown,
14598 test_AES_CCM_authenticated_decryption_test_case_128_1),
14599 TEST_CASE_ST(ut_setup, ut_teardown,
14600 test_AES_CCM_authenticated_decryption_test_case_128_2),
14601 TEST_CASE_ST(ut_setup, ut_teardown,
14602 test_AES_CCM_authenticated_decryption_test_case_128_3),
14604 /** AES CCM Authenticated Encryption 192 bits key */
14605 TEST_CASE_ST(ut_setup, ut_teardown,
14606 test_AES_CCM_authenticated_encryption_test_case_192_1),
14607 TEST_CASE_ST(ut_setup, ut_teardown,
14608 test_AES_CCM_authenticated_encryption_test_case_192_2),
14609 TEST_CASE_ST(ut_setup, ut_teardown,
14610 test_AES_CCM_authenticated_encryption_test_case_192_3),
14612 /** AES CCM Authenticated Decryption 192 bits key*/
14613 TEST_CASE_ST(ut_setup, ut_teardown,
14614 test_AES_CCM_authenticated_decryption_test_case_192_1),
14615 TEST_CASE_ST(ut_setup, ut_teardown,
14616 test_AES_CCM_authenticated_decryption_test_case_192_2),
14617 TEST_CASE_ST(ut_setup, ut_teardown,
14618 test_AES_CCM_authenticated_decryption_test_case_192_3),
14620 /** AES CCM Authenticated Encryption 256 bits key */
14621 TEST_CASE_ST(ut_setup, ut_teardown,
14622 test_AES_CCM_authenticated_encryption_test_case_256_1),
14623 TEST_CASE_ST(ut_setup, ut_teardown,
14624 test_AES_CCM_authenticated_encryption_test_case_256_2),
14625 TEST_CASE_ST(ut_setup, ut_teardown,
14626 test_AES_CCM_authenticated_encryption_test_case_256_3),
14628 /** AES CCM Authenticated Decryption 256 bits key*/
14629 TEST_CASE_ST(ut_setup, ut_teardown,
14630 test_AES_CCM_authenticated_decryption_test_case_256_1),
14631 TEST_CASE_ST(ut_setup, ut_teardown,
14632 test_AES_CCM_authenticated_decryption_test_case_256_2),
14633 TEST_CASE_ST(ut_setup, ut_teardown,
14634 test_AES_CCM_authenticated_decryption_test_case_256_3),
14639 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
14640 .suite_name = "AES GCM Authenticated Test Suite",
14641 .setup = aes_gcm_auth_testsuite_setup,
14642 .unit_test_cases = {
14643 /** AES GCM Authenticated Encryption */
14644 TEST_CASE_ST(ut_setup, ut_teardown,
14645 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
14646 TEST_CASE_ST(ut_setup, ut_teardown,
14647 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
14648 TEST_CASE_ST(ut_setup, ut_teardown,
14649 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
14650 TEST_CASE_ST(ut_setup, ut_teardown,
14651 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
14652 TEST_CASE_ST(ut_setup, ut_teardown,
14653 test_AES_GCM_authenticated_encryption_test_case_1),
14654 TEST_CASE_ST(ut_setup, ut_teardown,
14655 test_AES_GCM_authenticated_encryption_test_case_2),
14656 TEST_CASE_ST(ut_setup, ut_teardown,
14657 test_AES_GCM_authenticated_encryption_test_case_3),
14658 TEST_CASE_ST(ut_setup, ut_teardown,
14659 test_AES_GCM_authenticated_encryption_test_case_4),
14660 TEST_CASE_ST(ut_setup, ut_teardown,
14661 test_AES_GCM_authenticated_encryption_test_case_5),
14662 TEST_CASE_ST(ut_setup, ut_teardown,
14663 test_AES_GCM_authenticated_encryption_test_case_6),
14664 TEST_CASE_ST(ut_setup, ut_teardown,
14665 test_AES_GCM_authenticated_encryption_test_case_7),
14666 TEST_CASE_ST(ut_setup, ut_teardown,
14667 test_AES_GCM_authenticated_encryption_test_case_8),
14668 TEST_CASE_ST(ut_setup, ut_teardown,
14669 test_AES_GCM_J0_authenticated_encryption_test_case_1),
14671 /** AES GCM Authenticated Decryption */
14672 TEST_CASE_ST(ut_setup, ut_teardown,
14673 test_AES_GCM_authenticated_decryption_test_case_1),
14674 TEST_CASE_ST(ut_setup, ut_teardown,
14675 test_AES_GCM_authenticated_decryption_test_case_2),
14676 TEST_CASE_ST(ut_setup, ut_teardown,
14677 test_AES_GCM_authenticated_decryption_test_case_3),
14678 TEST_CASE_ST(ut_setup, ut_teardown,
14679 test_AES_GCM_authenticated_decryption_test_case_4),
14680 TEST_CASE_ST(ut_setup, ut_teardown,
14681 test_AES_GCM_authenticated_decryption_test_case_5),
14682 TEST_CASE_ST(ut_setup, ut_teardown,
14683 test_AES_GCM_authenticated_decryption_test_case_6),
14684 TEST_CASE_ST(ut_setup, ut_teardown,
14685 test_AES_GCM_authenticated_decryption_test_case_7),
14686 TEST_CASE_ST(ut_setup, ut_teardown,
14687 test_AES_GCM_authenticated_decryption_test_case_8),
14688 TEST_CASE_ST(ut_setup, ut_teardown,
14689 test_AES_GCM_J0_authenticated_decryption_test_case_1),
14691 /** AES GCM Authenticated Encryption 192 bits key */
14692 TEST_CASE_ST(ut_setup, ut_teardown,
14693 test_AES_GCM_auth_encryption_test_case_192_1),
14694 TEST_CASE_ST(ut_setup, ut_teardown,
14695 test_AES_GCM_auth_encryption_test_case_192_2),
14696 TEST_CASE_ST(ut_setup, ut_teardown,
14697 test_AES_GCM_auth_encryption_test_case_192_3),
14698 TEST_CASE_ST(ut_setup, ut_teardown,
14699 test_AES_GCM_auth_encryption_test_case_192_4),
14700 TEST_CASE_ST(ut_setup, ut_teardown,
14701 test_AES_GCM_auth_encryption_test_case_192_5),
14702 TEST_CASE_ST(ut_setup, ut_teardown,
14703 test_AES_GCM_auth_encryption_test_case_192_6),
14704 TEST_CASE_ST(ut_setup, ut_teardown,
14705 test_AES_GCM_auth_encryption_test_case_192_7),
14707 /** AES GCM Authenticated Decryption 192 bits key */
14708 TEST_CASE_ST(ut_setup, ut_teardown,
14709 test_AES_GCM_auth_decryption_test_case_192_1),
14710 TEST_CASE_ST(ut_setup, ut_teardown,
14711 test_AES_GCM_auth_decryption_test_case_192_2),
14712 TEST_CASE_ST(ut_setup, ut_teardown,
14713 test_AES_GCM_auth_decryption_test_case_192_3),
14714 TEST_CASE_ST(ut_setup, ut_teardown,
14715 test_AES_GCM_auth_decryption_test_case_192_4),
14716 TEST_CASE_ST(ut_setup, ut_teardown,
14717 test_AES_GCM_auth_decryption_test_case_192_5),
14718 TEST_CASE_ST(ut_setup, ut_teardown,
14719 test_AES_GCM_auth_decryption_test_case_192_6),
14720 TEST_CASE_ST(ut_setup, ut_teardown,
14721 test_AES_GCM_auth_decryption_test_case_192_7),
14723 /** AES GCM Authenticated Encryption 256 bits key */
14724 TEST_CASE_ST(ut_setup, ut_teardown,
14725 test_AES_GCM_auth_encryption_test_case_256_1),
14726 TEST_CASE_ST(ut_setup, ut_teardown,
14727 test_AES_GCM_auth_encryption_test_case_256_2),
14728 TEST_CASE_ST(ut_setup, ut_teardown,
14729 test_AES_GCM_auth_encryption_test_case_256_3),
14730 TEST_CASE_ST(ut_setup, ut_teardown,
14731 test_AES_GCM_auth_encryption_test_case_256_4),
14732 TEST_CASE_ST(ut_setup, ut_teardown,
14733 test_AES_GCM_auth_encryption_test_case_256_5),
14734 TEST_CASE_ST(ut_setup, ut_teardown,
14735 test_AES_GCM_auth_encryption_test_case_256_6),
14736 TEST_CASE_ST(ut_setup, ut_teardown,
14737 test_AES_GCM_auth_encryption_test_case_256_7),
14739 /** AES GCM Authenticated Decryption 256 bits key */
14740 TEST_CASE_ST(ut_setup, ut_teardown,
14741 test_AES_GCM_auth_decryption_test_case_256_1),
14742 TEST_CASE_ST(ut_setup, ut_teardown,
14743 test_AES_GCM_auth_decryption_test_case_256_2),
14744 TEST_CASE_ST(ut_setup, ut_teardown,
14745 test_AES_GCM_auth_decryption_test_case_256_3),
14746 TEST_CASE_ST(ut_setup, ut_teardown,
14747 test_AES_GCM_auth_decryption_test_case_256_4),
14748 TEST_CASE_ST(ut_setup, ut_teardown,
14749 test_AES_GCM_auth_decryption_test_case_256_5),
14750 TEST_CASE_ST(ut_setup, ut_teardown,
14751 test_AES_GCM_auth_decryption_test_case_256_6),
14752 TEST_CASE_ST(ut_setup, ut_teardown,
14753 test_AES_GCM_auth_decryption_test_case_256_7),
14755 /** AES GCM Authenticated Encryption big aad size */
14756 TEST_CASE_ST(ut_setup, ut_teardown,
14757 test_AES_GCM_auth_encryption_test_case_aad_1),
14758 TEST_CASE_ST(ut_setup, ut_teardown,
14759 test_AES_GCM_auth_encryption_test_case_aad_2),
14761 /** AES GCM Authenticated Decryption big aad size */
14762 TEST_CASE_ST(ut_setup, ut_teardown,
14763 test_AES_GCM_auth_decryption_test_case_aad_1),
14764 TEST_CASE_ST(ut_setup, ut_teardown,
14765 test_AES_GCM_auth_decryption_test_case_aad_2),
14767 /** Out of place tests */
14768 TEST_CASE_ST(ut_setup, ut_teardown,
14769 test_AES_GCM_authenticated_encryption_oop_test_case_1),
14770 TEST_CASE_ST(ut_setup, ut_teardown,
14771 test_AES_GCM_authenticated_decryption_oop_test_case_1),
14773 /** Session-less tests */
14774 TEST_CASE_ST(ut_setup, ut_teardown,
14775 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
14776 TEST_CASE_ST(ut_setup, ut_teardown,
14777 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
14783 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
14784 .suite_name = "AES GMAC Authentication Test Suite",
14785 .setup = aes_gmac_auth_testsuite_setup,
14786 .unit_test_cases = {
14787 TEST_CASE_ST(ut_setup, ut_teardown,
14788 test_AES_GMAC_authentication_test_case_1),
14789 TEST_CASE_ST(ut_setup, ut_teardown,
14790 test_AES_GMAC_authentication_verify_test_case_1),
14791 TEST_CASE_ST(ut_setup, ut_teardown,
14792 test_AES_GMAC_authentication_test_case_2),
14793 TEST_CASE_ST(ut_setup, ut_teardown,
14794 test_AES_GMAC_authentication_verify_test_case_2),
14795 TEST_CASE_ST(ut_setup, ut_teardown,
14796 test_AES_GMAC_authentication_test_case_3),
14797 TEST_CASE_ST(ut_setup, ut_teardown,
14798 test_AES_GMAC_authentication_verify_test_case_3),
14799 TEST_CASE_ST(ut_setup, ut_teardown,
14800 test_AES_GMAC_authentication_test_case_4),
14801 TEST_CASE_ST(ut_setup, ut_teardown,
14802 test_AES_GMAC_authentication_verify_test_case_4),
14803 TEST_CASE_ST(ut_setup, ut_teardown,
14804 test_AES_GMAC_authentication_SGL_40B),
14805 TEST_CASE_ST(ut_setup, ut_teardown,
14806 test_AES_GMAC_authentication_SGL_80B),
14807 TEST_CASE_ST(ut_setup, ut_teardown,
14808 test_AES_GMAC_authentication_SGL_2048B),
14809 TEST_CASE_ST(ut_setup, ut_teardown,
14810 test_AES_GMAC_authentication_SGL_2047B),
14816 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14817 .suite_name = "Chacha20-Poly1305 Test Suite",
14818 .setup = chacha20_poly1305_testsuite_setup,
14819 .unit_test_cases = {
14820 TEST_CASE_ST(ut_setup, ut_teardown,
14821 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14822 TEST_CASE_ST(ut_setup, ut_teardown,
14823 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14824 TEST_CASE_ST(ut_setup, ut_teardown,
14825 test_chacha20_poly1305_encrypt_SGL_out_of_place),
14830 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14831 .suite_name = "SNOW 3G Test Suite",
14832 .setup = snow3g_testsuite_setup,
14833 .unit_test_cases = {
14834 /** SNOW 3G encrypt only (UEA2) */
14835 TEST_CASE_ST(ut_setup, ut_teardown,
14836 test_snow3g_encryption_test_case_1),
14837 TEST_CASE_ST(ut_setup, ut_teardown,
14838 test_snow3g_encryption_test_case_2),
14839 TEST_CASE_ST(ut_setup, ut_teardown,
14840 test_snow3g_encryption_test_case_3),
14841 TEST_CASE_ST(ut_setup, ut_teardown,
14842 test_snow3g_encryption_test_case_4),
14843 TEST_CASE_ST(ut_setup, ut_teardown,
14844 test_snow3g_encryption_test_case_5),
14846 TEST_CASE_ST(ut_setup, ut_teardown,
14847 test_snow3g_encryption_test_case_1_oop),
14848 TEST_CASE_ST(ut_setup, ut_teardown,
14849 test_snow3g_encryption_test_case_1_oop_sgl),
14850 TEST_CASE_ST(ut_setup, ut_teardown,
14851 test_snow3g_encryption_test_case_1_offset_oop),
14852 TEST_CASE_ST(ut_setup, ut_teardown,
14853 test_snow3g_decryption_test_case_1_oop),
14855 /** SNOW 3G generate auth, then encrypt (UEA2) */
14856 TEST_CASE_ST(ut_setup, ut_teardown,
14857 test_snow3g_auth_cipher_test_case_1),
14858 TEST_CASE_ST(ut_setup, ut_teardown,
14859 test_snow3g_auth_cipher_test_case_2),
14860 TEST_CASE_ST(ut_setup, ut_teardown,
14861 test_snow3g_auth_cipher_test_case_2_oop),
14862 TEST_CASE_ST(ut_setup, ut_teardown,
14863 test_snow3g_auth_cipher_part_digest_enc),
14864 TEST_CASE_ST(ut_setup, ut_teardown,
14865 test_snow3g_auth_cipher_part_digest_enc_oop),
14866 TEST_CASE_ST(ut_setup, ut_teardown,
14867 test_snow3g_auth_cipher_test_case_3_sgl),
14868 TEST_CASE_ST(ut_setup, ut_teardown,
14869 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14870 TEST_CASE_ST(ut_setup, ut_teardown,
14871 test_snow3g_auth_cipher_part_digest_enc_sgl),
14872 TEST_CASE_ST(ut_setup, ut_teardown,
14873 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14875 /** SNOW 3G decrypt (UEA2), then verify auth */
14876 TEST_CASE_ST(ut_setup, ut_teardown,
14877 test_snow3g_auth_cipher_verify_test_case_1),
14878 TEST_CASE_ST(ut_setup, ut_teardown,
14879 test_snow3g_auth_cipher_verify_test_case_2),
14880 TEST_CASE_ST(ut_setup, ut_teardown,
14881 test_snow3g_auth_cipher_verify_test_case_2_oop),
14882 TEST_CASE_ST(ut_setup, ut_teardown,
14883 test_snow3g_auth_cipher_verify_part_digest_enc),
14884 TEST_CASE_ST(ut_setup, ut_teardown,
14885 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14886 TEST_CASE_ST(ut_setup, ut_teardown,
14887 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14888 TEST_CASE_ST(ut_setup, ut_teardown,
14889 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14890 TEST_CASE_ST(ut_setup, ut_teardown,
14891 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14892 TEST_CASE_ST(ut_setup, ut_teardown,
14893 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14895 /** SNOW 3G decrypt only (UEA2) */
14896 TEST_CASE_ST(ut_setup, ut_teardown,
14897 test_snow3g_decryption_test_case_1),
14898 TEST_CASE_ST(ut_setup, ut_teardown,
14899 test_snow3g_decryption_test_case_2),
14900 TEST_CASE_ST(ut_setup, ut_teardown,
14901 test_snow3g_decryption_test_case_3),
14902 TEST_CASE_ST(ut_setup, ut_teardown,
14903 test_snow3g_decryption_test_case_4),
14904 TEST_CASE_ST(ut_setup, ut_teardown,
14905 test_snow3g_decryption_test_case_5),
14906 TEST_CASE_ST(ut_setup, ut_teardown,
14907 test_snow3g_decryption_with_digest_test_case_1),
14908 TEST_CASE_ST(ut_setup, ut_teardown,
14909 test_snow3g_hash_generate_test_case_1),
14910 TEST_CASE_ST(ut_setup, ut_teardown,
14911 test_snow3g_hash_generate_test_case_2),
14912 TEST_CASE_ST(ut_setup, ut_teardown,
14913 test_snow3g_hash_generate_test_case_3),
14915 /* Tests with buffers which length is not byte-aligned */
14916 TEST_CASE_ST(ut_setup, ut_teardown,
14917 test_snow3g_hash_generate_test_case_4),
14918 TEST_CASE_ST(ut_setup, ut_teardown,
14919 test_snow3g_hash_generate_test_case_5),
14920 TEST_CASE_ST(ut_setup, ut_teardown,
14921 test_snow3g_hash_generate_test_case_6),
14922 TEST_CASE_ST(ut_setup, ut_teardown,
14923 test_snow3g_hash_verify_test_case_1),
14924 TEST_CASE_ST(ut_setup, ut_teardown,
14925 test_snow3g_hash_verify_test_case_2),
14926 TEST_CASE_ST(ut_setup, ut_teardown,
14927 test_snow3g_hash_verify_test_case_3),
14929 /* Tests with buffers which length is not byte-aligned */
14930 TEST_CASE_ST(ut_setup, ut_teardown,
14931 test_snow3g_hash_verify_test_case_4),
14932 TEST_CASE_ST(ut_setup, ut_teardown,
14933 test_snow3g_hash_verify_test_case_5),
14934 TEST_CASE_ST(ut_setup, ut_teardown,
14935 test_snow3g_hash_verify_test_case_6),
14936 TEST_CASE_ST(ut_setup, ut_teardown,
14937 test_snow3g_cipher_auth_test_case_1),
14938 TEST_CASE_ST(ut_setup, ut_teardown,
14939 test_snow3g_auth_cipher_with_digest_test_case_1),
14944 static struct unit_test_suite cryptodev_zuc_testsuite = {
14945 .suite_name = "ZUC Test Suite",
14946 .setup = zuc_testsuite_setup,
14947 .unit_test_cases = {
14948 /** ZUC encrypt only (EEA3) */
14949 TEST_CASE_ST(ut_setup, ut_teardown,
14950 test_zuc_encryption_test_case_1),
14951 TEST_CASE_ST(ut_setup, ut_teardown,
14952 test_zuc_encryption_test_case_2),
14953 TEST_CASE_ST(ut_setup, ut_teardown,
14954 test_zuc_encryption_test_case_3),
14955 TEST_CASE_ST(ut_setup, ut_teardown,
14956 test_zuc_encryption_test_case_4),
14957 TEST_CASE_ST(ut_setup, ut_teardown,
14958 test_zuc_encryption_test_case_5),
14959 TEST_CASE_ST(ut_setup, ut_teardown,
14960 test_zuc_encryption_test_case_6_sgl),
14962 /** ZUC authenticate (EIA3) */
14963 TEST_CASE_ST(ut_setup, ut_teardown,
14964 test_zuc_hash_generate_test_case_1),
14965 TEST_CASE_ST(ut_setup, ut_teardown,
14966 test_zuc_hash_generate_test_case_2),
14967 TEST_CASE_ST(ut_setup, ut_teardown,
14968 test_zuc_hash_generate_test_case_3),
14969 TEST_CASE_ST(ut_setup, ut_teardown,
14970 test_zuc_hash_generate_test_case_4),
14971 TEST_CASE_ST(ut_setup, ut_teardown,
14972 test_zuc_hash_generate_test_case_5),
14973 TEST_CASE_ST(ut_setup, ut_teardown,
14974 test_zuc_hash_generate_test_case_6),
14975 TEST_CASE_ST(ut_setup, ut_teardown,
14976 test_zuc_hash_generate_test_case_7),
14977 TEST_CASE_ST(ut_setup, ut_teardown,
14978 test_zuc_hash_generate_test_case_8),
14979 TEST_CASE_ST(ut_setup, ut_teardown,
14980 test_zuc_hash_generate_test_case_9),
14981 TEST_CASE_ST(ut_setup, ut_teardown,
14982 test_zuc_hash_generate_test_case_10),
14983 TEST_CASE_ST(ut_setup, ut_teardown,
14984 test_zuc_hash_generate_test_case_11),
14987 /** ZUC alg-chain (EEA3/EIA3) */
14988 TEST_CASE_ST(ut_setup, ut_teardown,
14989 test_zuc_cipher_auth_test_case_1),
14990 TEST_CASE_ST(ut_setup, ut_teardown,
14991 test_zuc_cipher_auth_test_case_2),
14993 /** ZUC generate auth, then encrypt (EEA3) */
14994 TEST_CASE_ST(ut_setup, ut_teardown,
14995 test_zuc_auth_cipher_test_case_1),
14996 TEST_CASE_ST(ut_setup, ut_teardown,
14997 test_zuc_auth_cipher_test_case_1_oop),
14998 TEST_CASE_ST(ut_setup, ut_teardown,
14999 test_zuc_auth_cipher_test_case_1_sgl),
15000 TEST_CASE_ST(ut_setup, ut_teardown,
15001 test_zuc_auth_cipher_test_case_1_oop_sgl),
15003 /** ZUC decrypt (EEA3), then verify auth */
15004 TEST_CASE_ST(ut_setup, ut_teardown,
15005 test_zuc_auth_cipher_verify_test_case_1),
15006 TEST_CASE_ST(ut_setup, ut_teardown,
15007 test_zuc_auth_cipher_verify_test_case_1_oop),
15008 TEST_CASE_ST(ut_setup, ut_teardown,
15009 test_zuc_auth_cipher_verify_test_case_1_sgl),
15010 TEST_CASE_ST(ut_setup, ut_teardown,
15011 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
15013 /** ZUC-256 encrypt only **/
15014 TEST_CASE_ST(ut_setup, ut_teardown,
15015 test_zuc256_encryption_test_case_1),
15016 TEST_CASE_ST(ut_setup, ut_teardown,
15017 test_zuc256_encryption_test_case_2),
15019 /** ZUC-256 authentication only **/
15020 TEST_CASE_ST(ut_setup, ut_teardown,
15021 test_zuc256_authentication_test_case_1),
15022 TEST_CASE_ST(ut_setup, ut_teardown,
15023 test_zuc256_authentication_test_case_2),
15029 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
15030 .suite_name = "HMAC_MD5 Authentication Test Suite",
15031 .setup = hmac_md5_auth_testsuite_setup,
15032 .unit_test_cases = {
15033 TEST_CASE_ST(ut_setup, ut_teardown,
15034 test_MD5_HMAC_generate_case_1),
15035 TEST_CASE_ST(ut_setup, ut_teardown,
15036 test_MD5_HMAC_verify_case_1),
15037 TEST_CASE_ST(ut_setup, ut_teardown,
15038 test_MD5_HMAC_generate_case_2),
15039 TEST_CASE_ST(ut_setup, ut_teardown,
15040 test_MD5_HMAC_verify_case_2),
15045 static struct unit_test_suite cryptodev_kasumi_testsuite = {
15046 .suite_name = "Kasumi Test Suite",
15047 .setup = kasumi_testsuite_setup,
15048 .unit_test_cases = {
15049 /** KASUMI hash only (UIA1) */
15050 TEST_CASE_ST(ut_setup, ut_teardown,
15051 test_kasumi_hash_generate_test_case_1),
15052 TEST_CASE_ST(ut_setup, ut_teardown,
15053 test_kasumi_hash_generate_test_case_2),
15054 TEST_CASE_ST(ut_setup, ut_teardown,
15055 test_kasumi_hash_generate_test_case_3),
15056 TEST_CASE_ST(ut_setup, ut_teardown,
15057 test_kasumi_hash_generate_test_case_4),
15058 TEST_CASE_ST(ut_setup, ut_teardown,
15059 test_kasumi_hash_generate_test_case_5),
15060 TEST_CASE_ST(ut_setup, ut_teardown,
15061 test_kasumi_hash_generate_test_case_6),
15063 TEST_CASE_ST(ut_setup, ut_teardown,
15064 test_kasumi_hash_verify_test_case_1),
15065 TEST_CASE_ST(ut_setup, ut_teardown,
15066 test_kasumi_hash_verify_test_case_2),
15067 TEST_CASE_ST(ut_setup, ut_teardown,
15068 test_kasumi_hash_verify_test_case_3),
15069 TEST_CASE_ST(ut_setup, ut_teardown,
15070 test_kasumi_hash_verify_test_case_4),
15071 TEST_CASE_ST(ut_setup, ut_teardown,
15072 test_kasumi_hash_verify_test_case_5),
15074 /** KASUMI encrypt only (UEA1) */
15075 TEST_CASE_ST(ut_setup, ut_teardown,
15076 test_kasumi_encryption_test_case_1),
15077 TEST_CASE_ST(ut_setup, ut_teardown,
15078 test_kasumi_encryption_test_case_1_sgl),
15079 TEST_CASE_ST(ut_setup, ut_teardown,
15080 test_kasumi_encryption_test_case_1_oop),
15081 TEST_CASE_ST(ut_setup, ut_teardown,
15082 test_kasumi_encryption_test_case_1_oop_sgl),
15083 TEST_CASE_ST(ut_setup, ut_teardown,
15084 test_kasumi_encryption_test_case_2),
15085 TEST_CASE_ST(ut_setup, ut_teardown,
15086 test_kasumi_encryption_test_case_3),
15087 TEST_CASE_ST(ut_setup, ut_teardown,
15088 test_kasumi_encryption_test_case_4),
15089 TEST_CASE_ST(ut_setup, ut_teardown,
15090 test_kasumi_encryption_test_case_5),
15092 /** KASUMI decrypt only (UEA1) */
15093 TEST_CASE_ST(ut_setup, ut_teardown,
15094 test_kasumi_decryption_test_case_1),
15095 TEST_CASE_ST(ut_setup, ut_teardown,
15096 test_kasumi_decryption_test_case_2),
15097 TEST_CASE_ST(ut_setup, ut_teardown,
15098 test_kasumi_decryption_test_case_3),
15099 TEST_CASE_ST(ut_setup, ut_teardown,
15100 test_kasumi_decryption_test_case_4),
15101 TEST_CASE_ST(ut_setup, ut_teardown,
15102 test_kasumi_decryption_test_case_5),
15103 TEST_CASE_ST(ut_setup, ut_teardown,
15104 test_kasumi_decryption_test_case_1_oop),
15105 TEST_CASE_ST(ut_setup, ut_teardown,
15106 test_kasumi_cipher_auth_test_case_1),
15108 /** KASUMI generate auth, then encrypt (F8) */
15109 TEST_CASE_ST(ut_setup, ut_teardown,
15110 test_kasumi_auth_cipher_test_case_1),
15111 TEST_CASE_ST(ut_setup, ut_teardown,
15112 test_kasumi_auth_cipher_test_case_2),
15113 TEST_CASE_ST(ut_setup, ut_teardown,
15114 test_kasumi_auth_cipher_test_case_2_oop),
15115 TEST_CASE_ST(ut_setup, ut_teardown,
15116 test_kasumi_auth_cipher_test_case_2_sgl),
15117 TEST_CASE_ST(ut_setup, ut_teardown,
15118 test_kasumi_auth_cipher_test_case_2_oop_sgl),
15120 /** KASUMI decrypt (F8), then verify auth */
15121 TEST_CASE_ST(ut_setup, ut_teardown,
15122 test_kasumi_auth_cipher_verify_test_case_1),
15123 TEST_CASE_ST(ut_setup, ut_teardown,
15124 test_kasumi_auth_cipher_verify_test_case_2),
15125 TEST_CASE_ST(ut_setup, ut_teardown,
15126 test_kasumi_auth_cipher_verify_test_case_2_oop),
15127 TEST_CASE_ST(ut_setup, ut_teardown,
15128 test_kasumi_auth_cipher_verify_test_case_2_sgl),
15129 TEST_CASE_ST(ut_setup, ut_teardown,
15130 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
15136 static struct unit_test_suite cryptodev_esn_testsuite = {
15137 .suite_name = "ESN Test Suite",
15138 .setup = esn_testsuite_setup,
15139 .unit_test_cases = {
15140 TEST_CASE_ST(ut_setup, ut_teardown,
15141 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
15142 TEST_CASE_ST(ut_setup, ut_teardown,
15143 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
15148 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
15149 .suite_name = "Negative AES GCM Test Suite",
15150 .setup = negative_aes_gcm_testsuite_setup,
15151 .unit_test_cases = {
15152 TEST_CASE_ST(ut_setup, ut_teardown,
15153 test_AES_GCM_auth_encryption_fail_iv_corrupt),
15154 TEST_CASE_ST(ut_setup, ut_teardown,
15155 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
15156 TEST_CASE_ST(ut_setup, ut_teardown,
15157 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
15158 TEST_CASE_ST(ut_setup, ut_teardown,
15159 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
15160 TEST_CASE_ST(ut_setup, ut_teardown,
15161 test_AES_GCM_auth_encryption_fail_aad_corrupt),
15162 TEST_CASE_ST(ut_setup, ut_teardown,
15163 test_AES_GCM_auth_encryption_fail_tag_corrupt),
15164 TEST_CASE_ST(ut_setup, ut_teardown,
15165 test_AES_GCM_auth_decryption_fail_iv_corrupt),
15166 TEST_CASE_ST(ut_setup, ut_teardown,
15167 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
15168 TEST_CASE_ST(ut_setup, ut_teardown,
15169 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
15170 TEST_CASE_ST(ut_setup, ut_teardown,
15171 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
15172 TEST_CASE_ST(ut_setup, ut_teardown,
15173 test_AES_GCM_auth_decryption_fail_aad_corrupt),
15174 TEST_CASE_ST(ut_setup, ut_teardown,
15175 test_AES_GCM_auth_decryption_fail_tag_corrupt),
15181 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
15182 .suite_name = "Negative AES GMAC Test Suite",
15183 .setup = negative_aes_gmac_testsuite_setup,
15184 .unit_test_cases = {
15185 TEST_CASE_ST(ut_setup, ut_teardown,
15186 authentication_verify_AES128_GMAC_fail_data_corrupt),
15187 TEST_CASE_ST(ut_setup, ut_teardown,
15188 authentication_verify_AES128_GMAC_fail_tag_corrupt),
15194 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
15195 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
15196 .setup = mixed_cipher_hash_testsuite_setup,
15197 .unit_test_cases = {
15198 /** AUTH AES CMAC + CIPHER AES CTR */
15199 TEST_CASE_ST(ut_setup, ut_teardown,
15200 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
15201 TEST_CASE_ST(ut_setup, ut_teardown,
15202 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15203 TEST_CASE_ST(ut_setup, ut_teardown,
15204 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15205 TEST_CASE_ST(ut_setup, ut_teardown,
15206 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15207 TEST_CASE_ST(ut_setup, ut_teardown,
15208 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
15209 TEST_CASE_ST(ut_setup, ut_teardown,
15210 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15211 TEST_CASE_ST(ut_setup, ut_teardown,
15212 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15213 TEST_CASE_ST(ut_setup, ut_teardown,
15214 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15216 /** AUTH ZUC + CIPHER SNOW3G */
15217 TEST_CASE_ST(ut_setup, ut_teardown,
15218 test_auth_zuc_cipher_snow_test_case_1),
15219 TEST_CASE_ST(ut_setup, ut_teardown,
15220 test_verify_auth_zuc_cipher_snow_test_case_1),
15221 /** AUTH AES CMAC + CIPHER SNOW3G */
15222 TEST_CASE_ST(ut_setup, ut_teardown,
15223 test_auth_aes_cmac_cipher_snow_test_case_1),
15224 TEST_CASE_ST(ut_setup, ut_teardown,
15225 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
15226 /** AUTH ZUC + CIPHER AES CTR */
15227 TEST_CASE_ST(ut_setup, ut_teardown,
15228 test_auth_zuc_cipher_aes_ctr_test_case_1),
15229 TEST_CASE_ST(ut_setup, ut_teardown,
15230 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
15231 /** AUTH SNOW3G + CIPHER AES CTR */
15232 TEST_CASE_ST(ut_setup, ut_teardown,
15233 test_auth_snow_cipher_aes_ctr_test_case_1),
15234 TEST_CASE_ST(ut_setup, ut_teardown,
15235 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
15236 /** AUTH SNOW3G + CIPHER ZUC */
15237 TEST_CASE_ST(ut_setup, ut_teardown,
15238 test_auth_snow_cipher_zuc_test_case_1),
15239 TEST_CASE_ST(ut_setup, ut_teardown,
15240 test_verify_auth_snow_cipher_zuc_test_case_1),
15241 /** AUTH AES CMAC + CIPHER ZUC */
15242 TEST_CASE_ST(ut_setup, ut_teardown,
15243 test_auth_aes_cmac_cipher_zuc_test_case_1),
15244 TEST_CASE_ST(ut_setup, ut_teardown,
15245 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
15247 /** AUTH NULL + CIPHER SNOW3G */
15248 TEST_CASE_ST(ut_setup, ut_teardown,
15249 test_auth_null_cipher_snow_test_case_1),
15250 TEST_CASE_ST(ut_setup, ut_teardown,
15251 test_verify_auth_null_cipher_snow_test_case_1),
15252 /** AUTH NULL + CIPHER ZUC */
15253 TEST_CASE_ST(ut_setup, ut_teardown,
15254 test_auth_null_cipher_zuc_test_case_1),
15255 TEST_CASE_ST(ut_setup, ut_teardown,
15256 test_verify_auth_null_cipher_zuc_test_case_1),
15257 /** AUTH SNOW3G + CIPHER NULL */
15258 TEST_CASE_ST(ut_setup, ut_teardown,
15259 test_auth_snow_cipher_null_test_case_1),
15260 TEST_CASE_ST(ut_setup, ut_teardown,
15261 test_verify_auth_snow_cipher_null_test_case_1),
15262 /** AUTH ZUC + CIPHER NULL */
15263 TEST_CASE_ST(ut_setup, ut_teardown,
15264 test_auth_zuc_cipher_null_test_case_1),
15265 TEST_CASE_ST(ut_setup, ut_teardown,
15266 test_verify_auth_zuc_cipher_null_test_case_1),
15267 /** AUTH NULL + CIPHER AES CTR */
15268 TEST_CASE_ST(ut_setup, ut_teardown,
15269 test_auth_null_cipher_aes_ctr_test_case_1),
15270 TEST_CASE_ST(ut_setup, ut_teardown,
15271 test_verify_auth_null_cipher_aes_ctr_test_case_1),
15272 /** AUTH AES CMAC + CIPHER NULL */
15273 TEST_CASE_ST(ut_setup, ut_teardown,
15274 test_auth_aes_cmac_cipher_null_test_case_1),
15275 TEST_CASE_ST(ut_setup, ut_teardown,
15276 test_verify_auth_aes_cmac_cipher_null_test_case_1),
15282 run_cryptodev_testsuite(const char *pmd_name)
15284 uint8_t ret, j, i = 0, blk_start_idx = 0;
15285 const enum blockcipher_test_type blk_suites[] = {
15286 BLKCIPHER_AES_CHAIN_TYPE,
15287 BLKCIPHER_AES_CIPHERONLY_TYPE,
15288 BLKCIPHER_AES_DOCSIS_TYPE,
15289 BLKCIPHER_3DES_CHAIN_TYPE,
15290 BLKCIPHER_3DES_CIPHERONLY_TYPE,
15291 BLKCIPHER_DES_CIPHERONLY_TYPE,
15292 BLKCIPHER_DES_DOCSIS_TYPE,
15293 BLKCIPHER_AUTHONLY_TYPE};
15294 struct unit_test_suite *static_suites[] = {
15295 &cryptodev_multi_session_testsuite,
15296 &cryptodev_null_testsuite,
15297 &cryptodev_aes_ccm_auth_testsuite,
15298 &cryptodev_aes_gcm_auth_testsuite,
15299 &cryptodev_aes_gmac_auth_testsuite,
15300 &cryptodev_snow3g_testsuite,
15301 &cryptodev_chacha20_poly1305_testsuite,
15302 &cryptodev_zuc_testsuite,
15303 &cryptodev_hmac_md5_auth_testsuite,
15304 &cryptodev_kasumi_testsuite,
15305 &cryptodev_esn_testsuite,
15306 &cryptodev_negative_aes_gcm_testsuite,
15307 &cryptodev_negative_aes_gmac_testsuite,
15308 &cryptodev_mixed_cipher_hash_testsuite,
15309 &cryptodev_negative_hmac_sha1_testsuite,
15310 &cryptodev_gen_testsuite,
15311 #ifdef RTE_LIB_SECURITY
15312 &ipsec_proto_testsuite,
15313 &pdcp_proto_testsuite,
15314 &docsis_proto_testsuite,
15318 static struct unit_test_suite ts = {
15319 .suite_name = "Cryptodev Unit Test Suite",
15320 .setup = testsuite_setup,
15321 .teardown = testsuite_teardown,
15322 .unit_test_cases = {TEST_CASES_END()}
15325 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
15327 if (gbl_driver_id == -1) {
15328 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
15329 return TEST_SKIPPED;
15332 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15333 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
15335 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
15336 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15337 ret = unit_test_suite_runner(&ts);
15339 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
15340 free(ts.unit_test_suites);
15345 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
15347 struct rte_cryptodev_info dev_info;
15348 uint8_t i, nb_devs;
15351 driver_id = rte_cryptodev_driver_id_get(pmd_name);
15352 if (driver_id == -1) {
15353 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
15354 return TEST_SKIPPED;
15357 nb_devs = rte_cryptodev_count();
15359 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
15360 return TEST_SKIPPED;
15363 for (i = 0; i < nb_devs; i++) {
15364 rte_cryptodev_info_get(i, &dev_info);
15365 if (dev_info.driver_id == driver_id) {
15366 if (!(dev_info.feature_flags & flag)) {
15367 RTE_LOG(INFO, USER1, "%s not supported\n",
15369 return TEST_SKIPPED;
15371 return 0; /* found */
15375 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
15376 return TEST_SKIPPED;
15380 test_cryptodev_qat(void)
15382 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
15386 test_cryptodev_virtio(void)
15388 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
15392 test_cryptodev_aesni_mb(void)
15394 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15398 test_cryptodev_cpu_aesni_mb(void)
15401 enum rte_security_session_action_type at = gbl_action_type;
15402 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15403 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15404 gbl_action_type = at;
15409 test_cryptodev_chacha_poly_mb(void)
15412 enum rte_security_session_action_type at = gbl_action_type;
15413 rc = run_cryptodev_testsuite(
15414 RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
15415 gbl_action_type = at;
15420 test_cryptodev_openssl(void)
15422 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
15426 test_cryptodev_aesni_gcm(void)
15428 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15432 test_cryptodev_cpu_aesni_gcm(void)
15435 enum rte_security_session_action_type at = gbl_action_type;
15436 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15437 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15438 gbl_action_type = at;
15443 test_cryptodev_mlx5(void)
15445 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
15449 test_cryptodev_null(void)
15451 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
15455 test_cryptodev_sw_snow3g(void)
15457 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
15461 test_cryptodev_sw_kasumi(void)
15463 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
15467 test_cryptodev_sw_zuc(void)
15469 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
15473 test_cryptodev_armv8(void)
15475 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
15479 test_cryptodev_mrvl(void)
15481 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
15484 #ifdef RTE_CRYPTO_SCHEDULER
15487 test_cryptodev_scheduler(void)
15489 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
15490 const enum blockcipher_test_type blk_suites[] = {
15491 BLKCIPHER_AES_CHAIN_TYPE,
15492 BLKCIPHER_AES_CIPHERONLY_TYPE,
15493 BLKCIPHER_AUTHONLY_TYPE
15495 static struct unit_test_suite scheduler_multicore = {
15496 .suite_name = "Scheduler Multicore Unit Test Suite",
15497 .setup = scheduler_multicore_testsuite_setup,
15498 .teardown = scheduler_mode_testsuite_teardown,
15499 .unit_test_cases = {TEST_CASES_END()}
15501 static struct unit_test_suite scheduler_round_robin = {
15502 .suite_name = "Scheduler Round Robin Unit Test Suite",
15503 .setup = scheduler_roundrobin_testsuite_setup,
15504 .teardown = scheduler_mode_testsuite_teardown,
15505 .unit_test_cases = {TEST_CASES_END()}
15507 static struct unit_test_suite scheduler_failover = {
15508 .suite_name = "Scheduler Failover Unit Test Suite",
15509 .setup = scheduler_failover_testsuite_setup,
15510 .teardown = scheduler_mode_testsuite_teardown,
15511 .unit_test_cases = {TEST_CASES_END()}
15513 static struct unit_test_suite scheduler_pkt_size_distr = {
15514 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
15515 .setup = scheduler_pkt_size_distr_testsuite_setup,
15516 .teardown = scheduler_mode_testsuite_teardown,
15517 .unit_test_cases = {TEST_CASES_END()}
15519 struct unit_test_suite *sched_mode_suites[] = {
15520 &scheduler_multicore,
15521 &scheduler_round_robin,
15522 &scheduler_failover,
15523 &scheduler_pkt_size_distr
15525 static struct unit_test_suite scheduler_config = {
15526 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
15527 .unit_test_cases = {
15528 TEST_CASE(test_scheduler_attach_worker_op),
15529 TEST_CASE(test_scheduler_mode_multicore_op),
15530 TEST_CASE(test_scheduler_mode_roundrobin_op),
15531 TEST_CASE(test_scheduler_mode_failover_op),
15532 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
15533 TEST_CASE(test_scheduler_detach_worker_op),
15535 TEST_CASES_END() /**< NULL terminate array */
15538 struct unit_test_suite *static_suites[] = {
15542 static struct unit_test_suite ts = {
15543 .suite_name = "Scheduler Unit Test Suite",
15544 .setup = scheduler_testsuite_setup,
15545 .teardown = testsuite_teardown,
15546 .unit_test_cases = {TEST_CASES_END()}
15549 gbl_driver_id = rte_cryptodev_driver_id_get(
15550 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15552 if (gbl_driver_id == -1) {
15553 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
15554 return TEST_SKIPPED;
15557 if (rte_cryptodev_driver_id_get(
15558 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
15559 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
15560 return TEST_SKIPPED;
15563 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15565 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
15566 (struct unit_test_suite *) *
15567 (RTE_DIM(blk_suites) + 1));
15568 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
15569 blk_suites, RTE_DIM(blk_suites));
15570 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
15573 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15574 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
15575 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
15576 RTE_DIM(sched_mode_suites));
15577 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15578 ret = unit_test_suite_runner(&ts);
15580 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15581 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
15582 (*sched_mode_suites[sched_i]),
15583 RTE_DIM(blk_suites));
15584 free(sched_mode_suites[sched_i]->unit_test_suites);
15586 free(ts.unit_test_suites);
15590 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
15595 test_cryptodev_dpaa2_sec(void)
15597 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
15601 test_cryptodev_dpaa_sec(void)
15603 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
15607 test_cryptodev_ccp(void)
15609 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
15613 test_cryptodev_octeontx(void)
15615 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
15619 test_cryptodev_caam_jr(void)
15621 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
15625 test_cryptodev_nitrox(void)
15627 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
15631 test_cryptodev_bcmfs(void)
15633 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
15637 test_cryptodev_qat_raw_api(void)
15639 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
15642 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15647 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15648 ret = run_cryptodev_testsuite(pmd_name);
15649 global_api_test_type = CRYPTODEV_API_TEST;
15655 test_cryptodev_cn9k(void)
15657 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
15661 test_cryptodev_cn10k(void)
15663 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
15667 test_cryptodev_dpaa2_sec_raw_api(void)
15669 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
15672 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15677 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15678 ret = run_cryptodev_testsuite(pmd_name);
15679 global_api_test_type = CRYPTODEV_API_TEST;
15685 test_cryptodev_dpaa_sec_raw_api(void)
15687 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
15690 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15695 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15696 ret = run_cryptodev_testsuite(pmd_name);
15697 global_api_test_type = CRYPTODEV_API_TEST;
15702 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
15703 test_cryptodev_dpaa2_sec_raw_api);
15704 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
15705 test_cryptodev_dpaa_sec_raw_api);
15706 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
15707 test_cryptodev_qat_raw_api);
15708 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
15709 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
15710 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
15711 test_cryptodev_cpu_aesni_mb);
15712 REGISTER_TEST_COMMAND(cryptodev_chacha_poly_mb_autotest,
15713 test_cryptodev_chacha_poly_mb);
15714 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
15715 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
15716 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
15717 test_cryptodev_cpu_aesni_gcm);
15718 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
15719 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
15720 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
15721 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
15722 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
15723 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
15724 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
15725 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
15726 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
15727 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
15728 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
15729 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
15730 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
15731 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
15732 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
15733 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
15734 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);