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;
1420 struct rte_cryptodev_stats stats;
1422 /* free crypto session structure */
1423 #ifdef RTE_LIB_SECURITY
1424 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1425 if (ut_params->sec_session) {
1426 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1427 (ts_params->valid_devs[0]),
1428 ut_params->sec_session);
1429 ut_params->sec_session = NULL;
1434 if (ut_params->sess) {
1435 rte_cryptodev_sym_session_clear(
1436 ts_params->valid_devs[0],
1438 rte_cryptodev_sym_session_free(ut_params->sess);
1439 ut_params->sess = NULL;
1443 /* free crypto operation structure */
1445 rte_crypto_op_free(ut_params->op);
1448 * free mbuf - both obuf and ibuf are usually the same,
1449 * so check if they point at the same address is necessary,
1450 * to avoid freeing the mbuf twice.
1452 if (ut_params->obuf) {
1453 rte_pktmbuf_free(ut_params->obuf);
1454 if (ut_params->ibuf == ut_params->obuf)
1455 ut_params->ibuf = 0;
1456 ut_params->obuf = 0;
1458 if (ut_params->ibuf) {
1459 rte_pktmbuf_free(ut_params->ibuf);
1460 ut_params->ibuf = 0;
1463 if (ts_params->mbuf_pool != NULL)
1464 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1465 rte_mempool_avail_count(ts_params->mbuf_pool));
1467 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1469 /* Stop the device */
1470 rte_cryptodev_stop(ts_params->valid_devs[0]);
1474 test_device_configure_invalid_dev_id(void)
1476 struct crypto_testsuite_params *ts_params = &testsuite_params;
1477 uint16_t dev_id, num_devs = 0;
1479 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1480 "Need at least %d devices for test", 1);
1482 /* valid dev_id values */
1483 dev_id = ts_params->valid_devs[0];
1485 /* Stop the device in case it's started so it can be configured */
1486 rte_cryptodev_stop(dev_id);
1488 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1489 "Failed test for rte_cryptodev_configure: "
1490 "invalid dev_num %u", dev_id);
1492 /* invalid dev_id values */
1495 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1496 "Failed test for rte_cryptodev_configure: "
1497 "invalid dev_num %u", dev_id);
1501 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1502 "Failed test for rte_cryptodev_configure:"
1503 "invalid dev_num %u", dev_id);
1505 return TEST_SUCCESS;
1509 test_device_configure_invalid_queue_pair_ids(void)
1511 struct crypto_testsuite_params *ts_params = &testsuite_params;
1512 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1514 /* Stop the device in case it's started so it can be configured */
1515 rte_cryptodev_stop(ts_params->valid_devs[0]);
1517 /* valid - max value queue pairs */
1518 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1520 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1522 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1523 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1525 /* valid - one queue pairs */
1526 ts_params->conf.nb_queue_pairs = 1;
1528 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1530 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1531 ts_params->valid_devs[0],
1532 ts_params->conf.nb_queue_pairs);
1535 /* invalid - zero queue pairs */
1536 ts_params->conf.nb_queue_pairs = 0;
1538 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1540 "Failed test for rte_cryptodev_configure, dev_id %u,"
1542 ts_params->valid_devs[0],
1543 ts_params->conf.nb_queue_pairs);
1546 /* invalid - max value supported by field queue pairs */
1547 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1549 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1551 "Failed test for rte_cryptodev_configure, dev_id %u,"
1553 ts_params->valid_devs[0],
1554 ts_params->conf.nb_queue_pairs);
1557 /* invalid - max value + 1 queue pairs */
1558 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1560 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1562 "Failed test for rte_cryptodev_configure, dev_id %u,"
1564 ts_params->valid_devs[0],
1565 ts_params->conf.nb_queue_pairs);
1567 /* revert to original testsuite value */
1568 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1570 return TEST_SUCCESS;
1574 test_queue_pair_descriptor_setup(void)
1576 struct crypto_testsuite_params *ts_params = &testsuite_params;
1577 struct rte_cryptodev_qp_conf qp_conf = {
1578 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1582 /* Stop the device in case it's started so it can be configured */
1583 rte_cryptodev_stop(ts_params->valid_devs[0]);
1585 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1587 "Failed to configure cryptodev %u",
1588 ts_params->valid_devs[0]);
1591 * Test various ring sizes on this device. memzones can't be
1592 * freed so are re-used if ring is released and re-created.
1594 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1595 qp_conf.mp_session = ts_params->session_mpool;
1596 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1598 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1599 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1600 ts_params->valid_devs[0], qp_id, &qp_conf,
1601 rte_cryptodev_socket_id(
1602 ts_params->valid_devs[0])),
1604 "rte_cryptodev_queue_pair_setup: num_inflights "
1605 "%u on qp %u on cryptodev %u",
1606 qp_conf.nb_descriptors, qp_id,
1607 ts_params->valid_devs[0]);
1610 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1612 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1613 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1614 ts_params->valid_devs[0], qp_id, &qp_conf,
1615 rte_cryptodev_socket_id(
1616 ts_params->valid_devs[0])),
1618 " rte_cryptodev_queue_pair_setup: num_inflights"
1619 " %u on qp %u on cryptodev %u",
1620 qp_conf.nb_descriptors, qp_id,
1621 ts_params->valid_devs[0]);
1624 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1626 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1627 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1628 ts_params->valid_devs[0], qp_id, &qp_conf,
1629 rte_cryptodev_socket_id(
1630 ts_params->valid_devs[0])),
1632 "rte_cryptodev_queue_pair_setup: num_inflights"
1633 " %u on qp %u on cryptodev %u",
1634 qp_conf.nb_descriptors, qp_id,
1635 ts_params->valid_devs[0]);
1638 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1640 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1641 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1642 ts_params->valid_devs[0], qp_id, &qp_conf,
1643 rte_cryptodev_socket_id(
1644 ts_params->valid_devs[0])),
1646 " rte_cryptodev_queue_pair_setup:"
1647 "num_inflights %u on qp %u on cryptodev %u",
1648 qp_conf.nb_descriptors, qp_id,
1649 ts_params->valid_devs[0]);
1652 /* test invalid queue pair id */
1653 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1655 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1657 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1658 ts_params->valid_devs[0],
1660 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1661 "Failed test for rte_cryptodev_queue_pair_setup:"
1662 "invalid qp %u on cryptodev %u",
1663 qp_id, ts_params->valid_devs[0]);
1665 qp_id = 0xffff; /*invalid*/
1667 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1668 ts_params->valid_devs[0],
1670 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1671 "Failed test for rte_cryptodev_queue_pair_setup:"
1672 "invalid qp %u on cryptodev %u",
1673 qp_id, ts_params->valid_devs[0]);
1675 return TEST_SUCCESS;
1678 /* ***** Plaintext data for tests ***** */
1680 const char catch_22_quote_1[] =
1681 "There was only one catch and that was Catch-22, which "
1682 "specified that a concern for one's safety in the face of "
1683 "dangers that were real and immediate was the process of a "
1684 "rational mind. Orr was crazy and could be grounded. All he "
1685 "had to do was ask; and as soon as he did, he would no longer "
1686 "be crazy and would have to fly more missions. Orr would be "
1687 "crazy to fly more missions and sane if he didn't, but if he "
1688 "was sane he had to fly them. If he flew them he was crazy "
1689 "and didn't have to; but if he didn't want to he was sane and "
1690 "had to. Yossarian was moved very deeply by the absolute "
1691 "simplicity of this clause of Catch-22 and let out a "
1692 "respectful whistle. \"That's some catch, that Catch-22\", he "
1693 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1695 const char catch_22_quote[] =
1696 "What a lousy earth! He wondered how many people were "
1697 "destitute that same night even in his own prosperous country, "
1698 "how many homes were shanties, how many husbands were drunk "
1699 "and wives socked, and how many children were bullied, abused, "
1700 "or abandoned. How many families hungered for food they could "
1701 "not afford to buy? How many hearts were broken? How many "
1702 "suicides would take place that same night, how many people "
1703 "would go insane? How many cockroaches and landlords would "
1704 "triumph? How many winners were losers, successes failures, "
1705 "and rich men poor men? How many wise guys were stupid? How "
1706 "many happy endings were unhappy endings? How many honest men "
1707 "were liars, brave men cowards, loyal men traitors, how many "
1708 "sainted men were corrupt, how many people in positions of "
1709 "trust had sold their souls to bodyguards, how many had never "
1710 "had souls? How many straight-and-narrow paths were crooked "
1711 "paths? How many best families were worst families and how "
1712 "many good people were bad people? When you added them all up "
1713 "and then subtracted, you might be left with only the children, "
1714 "and perhaps with Albert Einstein and an old violinist or "
1715 "sculptor somewhere.";
1717 #define QUOTE_480_BYTES (480)
1718 #define QUOTE_512_BYTES (512)
1719 #define QUOTE_768_BYTES (768)
1720 #define QUOTE_1024_BYTES (1024)
1724 /* ***** SHA1 Hash Tests ***** */
1726 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1728 static uint8_t hmac_sha1_key[] = {
1729 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1730 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1731 0xDE, 0xF4, 0xDE, 0xAD };
1733 /* ***** SHA224 Hash Tests ***** */
1735 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1738 /* ***** AES-CBC Cipher Tests ***** */
1740 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1741 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1743 static uint8_t aes_cbc_key[] = {
1744 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1745 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1747 static uint8_t aes_cbc_iv[] = {
1748 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1749 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1752 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1754 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1755 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1756 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1757 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1758 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1759 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1760 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1761 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1762 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1763 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1764 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1765 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1766 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1767 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1768 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1769 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1770 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1771 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1772 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1773 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1774 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1775 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1776 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1777 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1778 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1779 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1780 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1781 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1782 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1783 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1784 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1785 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1786 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1787 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1788 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1789 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1790 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1791 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1792 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1793 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1794 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1795 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1796 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1797 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1798 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1799 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1800 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1801 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1802 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1803 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1804 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1805 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1806 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1807 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1808 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1809 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1810 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1811 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1812 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1813 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1814 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1815 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1816 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1817 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1818 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1821 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1822 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1823 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1824 0x18, 0x8c, 0x1d, 0x32
1828 /* Multisession Vector context Test */
1829 /*Begin Session 0 */
1830 static uint8_t ms_aes_cbc_key0[] = {
1831 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1832 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1835 static uint8_t ms_aes_cbc_iv0[] = {
1836 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1837 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1840 static const uint8_t ms_aes_cbc_cipher0[] = {
1841 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1842 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1843 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1844 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1845 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1846 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1847 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1848 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1849 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1850 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1851 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1852 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1853 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1854 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1855 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1856 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1857 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1858 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1859 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1860 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1861 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1862 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1863 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1864 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1865 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1866 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1867 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1868 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1869 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1870 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1871 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1872 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1873 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1874 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1875 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1876 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1877 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1878 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1879 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1880 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1881 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1882 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1883 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1884 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1885 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1886 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1887 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1888 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1889 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1890 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1891 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1892 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1893 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1894 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1895 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1896 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1897 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1898 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1899 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1900 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1901 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1902 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1903 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1904 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1908 static uint8_t ms_hmac_key0[] = {
1909 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1910 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1911 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1912 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1913 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1914 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1915 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1916 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1919 static const uint8_t ms_hmac_digest0[] = {
1920 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1921 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1922 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1923 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1924 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1925 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1926 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1927 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1931 /* Begin session 1 */
1933 static uint8_t ms_aes_cbc_key1[] = {
1934 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1935 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1938 static uint8_t ms_aes_cbc_iv1[] = {
1939 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1940 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1943 static const uint8_t ms_aes_cbc_cipher1[] = {
1944 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1945 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1946 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1947 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1948 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1949 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1950 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1951 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1952 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1953 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1954 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1955 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1956 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1957 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1958 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1959 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1960 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1961 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1962 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1963 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1964 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1965 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1966 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1967 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1968 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1969 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1970 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1971 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1972 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1973 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1974 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1975 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1976 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1977 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1978 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1979 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1980 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1981 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1982 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1983 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1984 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1985 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1986 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1987 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1988 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1989 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1990 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1991 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1992 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1993 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1994 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1995 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1996 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1997 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1998 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1999 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2000 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2001 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2002 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2003 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2004 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2005 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2006 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2007 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2011 static uint8_t ms_hmac_key1[] = {
2012 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2013 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2014 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2015 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2016 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2017 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2018 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2019 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2022 static const uint8_t ms_hmac_digest1[] = {
2023 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2024 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2025 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2026 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2027 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2028 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2029 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2030 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2033 /* Begin Session 2 */
2034 static uint8_t ms_aes_cbc_key2[] = {
2035 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2036 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2039 static uint8_t ms_aes_cbc_iv2[] = {
2040 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2041 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2044 static const uint8_t ms_aes_cbc_cipher2[] = {
2045 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2046 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2047 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2048 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2049 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2050 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2051 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2052 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2053 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2054 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2055 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2056 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2057 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2058 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2059 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2060 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2061 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2062 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2063 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2064 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2065 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2066 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2067 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2068 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2069 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2070 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2071 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2072 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2073 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2074 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2075 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2076 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2077 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2078 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2079 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2080 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2081 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2082 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2083 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2084 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2085 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2086 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2087 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2088 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2089 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2090 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2091 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2092 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2093 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2094 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2095 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2096 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2097 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2098 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2099 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2100 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2101 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2102 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2103 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2104 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2105 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2106 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2107 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2108 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2111 static uint8_t ms_hmac_key2[] = {
2112 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2113 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2114 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2115 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2116 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2117 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2118 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2119 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2122 static const uint8_t ms_hmac_digest2[] = {
2123 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2124 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2125 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2126 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2127 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2128 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2129 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2130 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2137 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2139 struct crypto_testsuite_params *ts_params = &testsuite_params;
2140 struct crypto_unittest_params *ut_params = &unittest_params;
2142 /* Verify the capabilities */
2143 struct rte_cryptodev_sym_capability_idx cap_idx;
2144 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2145 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2146 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2148 return TEST_SKIPPED;
2149 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2150 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2151 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2153 return TEST_SKIPPED;
2155 /* Generate test mbuf data and space for digest */
2156 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2157 catch_22_quote, QUOTE_512_BYTES, 0);
2159 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2160 DIGEST_BYTE_LENGTH_SHA1);
2161 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2163 /* Setup Cipher Parameters */
2164 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2165 ut_params->cipher_xform.next = &ut_params->auth_xform;
2167 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2168 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2169 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2170 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2171 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2172 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2174 /* Setup HMAC Parameters */
2175 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2177 ut_params->auth_xform.next = NULL;
2179 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2180 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2181 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2182 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2183 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2185 ut_params->sess = rte_cryptodev_sym_session_create(
2186 ts_params->session_mpool);
2188 /* Create crypto session*/
2189 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2190 ut_params->sess, &ut_params->cipher_xform,
2191 ts_params->session_priv_mpool);
2192 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2194 /* Generate crypto op data structure */
2195 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2196 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2197 TEST_ASSERT_NOT_NULL(ut_params->op,
2198 "Failed to allocate symmetric crypto operation struct");
2200 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2202 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2204 /* set crypto operation source mbuf */
2205 sym_op->m_src = ut_params->ibuf;
2207 /* Set crypto operation authentication parameters */
2208 sym_op->auth.digest.data = ut_params->digest;
2209 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2210 ut_params->ibuf, QUOTE_512_BYTES);
2212 sym_op->auth.data.offset = 0;
2213 sym_op->auth.data.length = QUOTE_512_BYTES;
2215 /* Copy IV at the end of the crypto operation */
2216 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2217 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2219 /* Set crypto operation cipher parameters */
2220 sym_op->cipher.data.offset = 0;
2221 sym_op->cipher.data.length = QUOTE_512_BYTES;
2223 /* Process crypto operation */
2224 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2225 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2228 TEST_ASSERT_NOT_NULL(
2229 process_crypto_request(ts_params->valid_devs[0],
2231 "failed to process sym crypto op");
2233 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2234 "crypto op processing failed");
2237 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2240 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2241 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2243 "ciphertext data not as expected");
2245 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2247 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2248 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2249 gbl_driver_id == rte_cryptodev_driver_id_get(
2250 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2251 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2252 DIGEST_BYTE_LENGTH_SHA1,
2253 "Generated digest data not as expected");
2255 return TEST_SUCCESS;
2258 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2260 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2262 static uint8_t hmac_sha512_key[] = {
2263 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2264 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2265 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2266 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2267 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2268 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2269 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2270 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2272 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2273 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2274 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2275 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2276 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2277 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2278 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2279 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2280 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2285 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2286 struct crypto_unittest_params *ut_params,
2287 uint8_t *cipher_key,
2291 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2292 struct crypto_unittest_params *ut_params,
2293 struct crypto_testsuite_params *ts_params,
2294 const uint8_t *cipher,
2295 const uint8_t *digest,
2300 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2301 struct crypto_unittest_params *ut_params,
2302 uint8_t *cipher_key,
2306 /* Setup Cipher Parameters */
2307 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2308 ut_params->cipher_xform.next = NULL;
2310 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2311 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2312 ut_params->cipher_xform.cipher.key.data = cipher_key;
2313 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2314 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2315 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2317 /* Setup HMAC Parameters */
2318 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2319 ut_params->auth_xform.next = &ut_params->cipher_xform;
2321 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2322 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2323 ut_params->auth_xform.auth.key.data = hmac_key;
2324 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2325 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2327 return TEST_SUCCESS;
2332 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2333 struct crypto_unittest_params *ut_params,
2334 struct crypto_testsuite_params *ts_params,
2335 const uint8_t *cipher,
2336 const uint8_t *digest,
2339 /* Generate test mbuf data and digest */
2340 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2343 QUOTE_512_BYTES, 0);
2345 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2346 DIGEST_BYTE_LENGTH_SHA512);
2347 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2349 rte_memcpy(ut_params->digest,
2351 DIGEST_BYTE_LENGTH_SHA512);
2353 /* Generate Crypto op data structure */
2354 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2355 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2356 TEST_ASSERT_NOT_NULL(ut_params->op,
2357 "Failed to allocate symmetric crypto operation struct");
2359 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2361 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2363 /* set crypto operation source mbuf */
2364 sym_op->m_src = ut_params->ibuf;
2366 sym_op->auth.digest.data = ut_params->digest;
2367 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2368 ut_params->ibuf, QUOTE_512_BYTES);
2370 sym_op->auth.data.offset = 0;
2371 sym_op->auth.data.length = QUOTE_512_BYTES;
2373 /* Copy IV at the end of the crypto operation */
2374 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2375 iv, CIPHER_IV_LENGTH_AES_CBC);
2377 sym_op->cipher.data.offset = 0;
2378 sym_op->cipher.data.length = QUOTE_512_BYTES;
2380 /* Process crypto operation */
2381 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2382 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2384 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2385 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2386 ut_params->op, 1, 1, 0, 0);
2388 TEST_ASSERT_NOT_NULL(
2389 process_crypto_request(ts_params->valid_devs[0],
2391 "failed to process sym crypto op");
2393 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2394 "crypto op processing failed");
2396 ut_params->obuf = ut_params->op->sym->m_src;
2399 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2400 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2403 "Plaintext data not as expected");
2406 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2407 "Digest verification failed");
2409 return TEST_SUCCESS;
2412 /* ***** SNOW 3G Tests ***** */
2414 create_wireless_algo_hash_session(uint8_t dev_id,
2415 const uint8_t *key, const uint8_t key_len,
2416 const uint8_t iv_len, const uint8_t auth_len,
2417 enum rte_crypto_auth_operation op,
2418 enum rte_crypto_auth_algorithm algo)
2420 uint8_t hash_key[key_len];
2423 struct crypto_testsuite_params *ts_params = &testsuite_params;
2424 struct crypto_unittest_params *ut_params = &unittest_params;
2426 memcpy(hash_key, key, key_len);
2428 debug_hexdump(stdout, "key:", key, key_len);
2430 /* Setup Authentication Parameters */
2431 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2432 ut_params->auth_xform.next = NULL;
2434 ut_params->auth_xform.auth.op = op;
2435 ut_params->auth_xform.auth.algo = algo;
2436 ut_params->auth_xform.auth.key.length = key_len;
2437 ut_params->auth_xform.auth.key.data = hash_key;
2438 ut_params->auth_xform.auth.digest_length = auth_len;
2439 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2440 ut_params->auth_xform.auth.iv.length = iv_len;
2441 ut_params->sess = rte_cryptodev_sym_session_create(
2442 ts_params->session_mpool);
2444 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2445 &ut_params->auth_xform,
2446 ts_params->session_priv_mpool);
2447 if (status == -ENOTSUP)
2448 return TEST_SKIPPED;
2450 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2451 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2456 create_wireless_algo_cipher_session(uint8_t dev_id,
2457 enum rte_crypto_cipher_operation op,
2458 enum rte_crypto_cipher_algorithm algo,
2459 const uint8_t *key, const uint8_t key_len,
2462 uint8_t cipher_key[key_len];
2464 struct crypto_testsuite_params *ts_params = &testsuite_params;
2465 struct crypto_unittest_params *ut_params = &unittest_params;
2467 memcpy(cipher_key, key, key_len);
2469 /* Setup Cipher Parameters */
2470 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2471 ut_params->cipher_xform.next = NULL;
2473 ut_params->cipher_xform.cipher.algo = algo;
2474 ut_params->cipher_xform.cipher.op = op;
2475 ut_params->cipher_xform.cipher.key.data = cipher_key;
2476 ut_params->cipher_xform.cipher.key.length = key_len;
2477 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2478 ut_params->cipher_xform.cipher.iv.length = iv_len;
2480 debug_hexdump(stdout, "key:", key, key_len);
2482 /* Create Crypto session */
2483 ut_params->sess = rte_cryptodev_sym_session_create(
2484 ts_params->session_mpool);
2486 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2487 &ut_params->cipher_xform,
2488 ts_params->session_priv_mpool);
2489 if (status == -ENOTSUP)
2490 return TEST_SKIPPED;
2492 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2493 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2498 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2499 unsigned int cipher_len,
2500 unsigned int cipher_offset)
2502 struct crypto_testsuite_params *ts_params = &testsuite_params;
2503 struct crypto_unittest_params *ut_params = &unittest_params;
2505 /* Generate Crypto op data structure */
2506 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2507 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2508 TEST_ASSERT_NOT_NULL(ut_params->op,
2509 "Failed to allocate pktmbuf offload");
2511 /* Set crypto operation data parameters */
2512 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2514 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2516 /* set crypto operation source mbuf */
2517 sym_op->m_src = ut_params->ibuf;
2520 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2522 sym_op->cipher.data.length = cipher_len;
2523 sym_op->cipher.data.offset = cipher_offset;
2528 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2529 unsigned int cipher_len,
2530 unsigned int cipher_offset)
2532 struct crypto_testsuite_params *ts_params = &testsuite_params;
2533 struct crypto_unittest_params *ut_params = &unittest_params;
2535 /* Generate Crypto op data structure */
2536 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2537 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2538 TEST_ASSERT_NOT_NULL(ut_params->op,
2539 "Failed to allocate pktmbuf offload");
2541 /* Set crypto operation data parameters */
2542 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2544 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2546 /* set crypto operation source mbuf */
2547 sym_op->m_src = ut_params->ibuf;
2548 sym_op->m_dst = ut_params->obuf;
2551 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2553 sym_op->cipher.data.length = cipher_len;
2554 sym_op->cipher.data.offset = cipher_offset;
2559 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2560 enum rte_crypto_cipher_operation cipher_op,
2561 enum rte_crypto_auth_operation auth_op,
2562 enum rte_crypto_auth_algorithm auth_algo,
2563 enum rte_crypto_cipher_algorithm cipher_algo,
2564 const uint8_t *key, uint8_t key_len,
2565 uint8_t auth_iv_len, uint8_t auth_len,
2566 uint8_t cipher_iv_len)
2569 uint8_t cipher_auth_key[key_len];
2572 struct crypto_testsuite_params *ts_params = &testsuite_params;
2573 struct crypto_unittest_params *ut_params = &unittest_params;
2575 memcpy(cipher_auth_key, key, key_len);
2577 /* Setup Authentication Parameters */
2578 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2579 ut_params->auth_xform.next = NULL;
2581 ut_params->auth_xform.auth.op = auth_op;
2582 ut_params->auth_xform.auth.algo = auth_algo;
2583 ut_params->auth_xform.auth.key.length = key_len;
2584 /* Hash key = cipher key */
2585 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2586 ut_params->auth_xform.auth.digest_length = auth_len;
2587 /* Auth IV will be after cipher IV */
2588 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2589 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2591 /* Setup Cipher Parameters */
2592 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2593 ut_params->cipher_xform.next = &ut_params->auth_xform;
2595 ut_params->cipher_xform.cipher.algo = cipher_algo;
2596 ut_params->cipher_xform.cipher.op = cipher_op;
2597 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2598 ut_params->cipher_xform.cipher.key.length = key_len;
2599 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2600 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2602 debug_hexdump(stdout, "key:", key, key_len);
2604 /* Create Crypto session*/
2605 ut_params->sess = rte_cryptodev_sym_session_create(
2606 ts_params->session_mpool);
2607 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2609 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2610 &ut_params->cipher_xform,
2611 ts_params->session_priv_mpool);
2612 if (status == -ENOTSUP)
2613 return TEST_SKIPPED;
2615 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2620 create_wireless_cipher_auth_session(uint8_t dev_id,
2621 enum rte_crypto_cipher_operation cipher_op,
2622 enum rte_crypto_auth_operation auth_op,
2623 enum rte_crypto_auth_algorithm auth_algo,
2624 enum rte_crypto_cipher_algorithm cipher_algo,
2625 const struct wireless_test_data *tdata)
2627 const uint8_t key_len = tdata->key.len;
2628 uint8_t cipher_auth_key[key_len];
2631 struct crypto_testsuite_params *ts_params = &testsuite_params;
2632 struct crypto_unittest_params *ut_params = &unittest_params;
2633 const uint8_t *key = tdata->key.data;
2634 const uint8_t auth_len = tdata->digest.len;
2635 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2636 uint8_t auth_iv_len = tdata->auth_iv.len;
2638 memcpy(cipher_auth_key, key, key_len);
2640 /* Setup Authentication Parameters */
2641 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2642 ut_params->auth_xform.next = NULL;
2644 ut_params->auth_xform.auth.op = auth_op;
2645 ut_params->auth_xform.auth.algo = auth_algo;
2646 ut_params->auth_xform.auth.key.length = key_len;
2647 /* Hash key = cipher key */
2648 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2649 ut_params->auth_xform.auth.digest_length = auth_len;
2650 /* Auth IV will be after cipher IV */
2651 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2652 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2654 /* Setup Cipher Parameters */
2655 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2656 ut_params->cipher_xform.next = &ut_params->auth_xform;
2658 ut_params->cipher_xform.cipher.algo = cipher_algo;
2659 ut_params->cipher_xform.cipher.op = cipher_op;
2660 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2661 ut_params->cipher_xform.cipher.key.length = key_len;
2662 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2663 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2666 debug_hexdump(stdout, "key:", key, key_len);
2668 /* Create Crypto session*/
2669 ut_params->sess = rte_cryptodev_sym_session_create(
2670 ts_params->session_mpool);
2672 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2673 &ut_params->cipher_xform,
2674 ts_params->session_priv_mpool);
2675 if (status == -ENOTSUP)
2676 return TEST_SKIPPED;
2678 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2679 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2684 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2685 const struct wireless_test_data *tdata)
2687 return create_wireless_cipher_auth_session(dev_id,
2688 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2689 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2690 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2694 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2695 enum rte_crypto_cipher_operation cipher_op,
2696 enum rte_crypto_auth_operation auth_op,
2697 enum rte_crypto_auth_algorithm auth_algo,
2698 enum rte_crypto_cipher_algorithm cipher_algo,
2699 const uint8_t *key, const uint8_t key_len,
2700 uint8_t auth_iv_len, uint8_t auth_len,
2701 uint8_t cipher_iv_len)
2703 uint8_t auth_cipher_key[key_len];
2705 struct crypto_testsuite_params *ts_params = &testsuite_params;
2706 struct crypto_unittest_params *ut_params = &unittest_params;
2708 memcpy(auth_cipher_key, key, key_len);
2710 /* Setup Authentication Parameters */
2711 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2712 ut_params->auth_xform.auth.op = auth_op;
2713 ut_params->auth_xform.next = &ut_params->cipher_xform;
2714 ut_params->auth_xform.auth.algo = auth_algo;
2715 ut_params->auth_xform.auth.key.length = key_len;
2716 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2717 ut_params->auth_xform.auth.digest_length = auth_len;
2718 /* Auth IV will be after cipher IV */
2719 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2720 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2722 /* Setup Cipher Parameters */
2723 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2724 ut_params->cipher_xform.next = NULL;
2725 ut_params->cipher_xform.cipher.algo = cipher_algo;
2726 ut_params->cipher_xform.cipher.op = cipher_op;
2727 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2728 ut_params->cipher_xform.cipher.key.length = key_len;
2729 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2730 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2732 debug_hexdump(stdout, "key:", key, key_len);
2734 /* Create Crypto session*/
2735 ut_params->sess = rte_cryptodev_sym_session_create(
2736 ts_params->session_mpool);
2737 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2739 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2740 ut_params->auth_xform.next = NULL;
2741 ut_params->cipher_xform.next = &ut_params->auth_xform;
2742 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2743 &ut_params->cipher_xform,
2744 ts_params->session_priv_mpool);
2747 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2748 &ut_params->auth_xform,
2749 ts_params->session_priv_mpool);
2751 if (status == -ENOTSUP)
2752 return TEST_SKIPPED;
2754 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2760 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2761 unsigned int auth_tag_len,
2762 const uint8_t *iv, unsigned int iv_len,
2763 unsigned int data_pad_len,
2764 enum rte_crypto_auth_operation op,
2765 unsigned int auth_len, unsigned int auth_offset)
2767 struct crypto_testsuite_params *ts_params = &testsuite_params;
2769 struct crypto_unittest_params *ut_params = &unittest_params;
2771 /* Generate Crypto op data structure */
2772 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2773 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2774 TEST_ASSERT_NOT_NULL(ut_params->op,
2775 "Failed to allocate pktmbuf offload");
2777 /* Set crypto operation data parameters */
2778 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2780 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2782 /* set crypto operation source mbuf */
2783 sym_op->m_src = ut_params->ibuf;
2786 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2789 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2790 ut_params->ibuf, auth_tag_len);
2792 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2793 "no room to append auth tag");
2794 ut_params->digest = sym_op->auth.digest.data;
2795 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2796 ut_params->ibuf, data_pad_len);
2797 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2798 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2800 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2802 debug_hexdump(stdout, "digest:",
2803 sym_op->auth.digest.data,
2806 sym_op->auth.data.length = auth_len;
2807 sym_op->auth.data.offset = auth_offset;
2813 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2814 enum rte_crypto_auth_operation op)
2816 struct crypto_testsuite_params *ts_params = &testsuite_params;
2817 struct crypto_unittest_params *ut_params = &unittest_params;
2819 const uint8_t *auth_tag = tdata->digest.data;
2820 const unsigned int auth_tag_len = tdata->digest.len;
2821 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2822 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2824 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2825 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2826 const uint8_t *auth_iv = tdata->auth_iv.data;
2827 const uint8_t auth_iv_len = tdata->auth_iv.len;
2828 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2829 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2831 /* Generate Crypto op data structure */
2832 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2833 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2834 TEST_ASSERT_NOT_NULL(ut_params->op,
2835 "Failed to allocate pktmbuf offload");
2836 /* Set crypto operation data parameters */
2837 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2839 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2841 /* set crypto operation source mbuf */
2842 sym_op->m_src = ut_params->ibuf;
2845 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2846 ut_params->ibuf, auth_tag_len);
2848 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2849 "no room to append auth tag");
2850 ut_params->digest = sym_op->auth.digest.data;
2851 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2852 ut_params->ibuf, data_pad_len);
2853 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2854 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2856 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2858 debug_hexdump(stdout, "digest:",
2859 sym_op->auth.digest.data,
2862 /* Copy cipher and auth IVs at the end of the crypto operation */
2863 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2865 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2866 iv_ptr += cipher_iv_len;
2867 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2869 sym_op->cipher.data.length = cipher_len;
2870 sym_op->cipher.data.offset = 0;
2871 sym_op->auth.data.length = auth_len;
2872 sym_op->auth.data.offset = 0;
2878 create_zuc_cipher_hash_generate_operation(
2879 const struct wireless_test_data *tdata)
2881 return create_wireless_cipher_hash_operation(tdata,
2882 RTE_CRYPTO_AUTH_OP_GENERATE);
2886 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2887 const unsigned auth_tag_len,
2888 const uint8_t *auth_iv, uint8_t auth_iv_len,
2889 unsigned data_pad_len,
2890 enum rte_crypto_auth_operation op,
2891 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2892 const unsigned cipher_len, const unsigned cipher_offset,
2893 const unsigned auth_len, const unsigned auth_offset)
2895 struct crypto_testsuite_params *ts_params = &testsuite_params;
2896 struct crypto_unittest_params *ut_params = &unittest_params;
2898 enum rte_crypto_cipher_algorithm cipher_algo =
2899 ut_params->cipher_xform.cipher.algo;
2900 enum rte_crypto_auth_algorithm auth_algo =
2901 ut_params->auth_xform.auth.algo;
2903 /* Generate Crypto op data structure */
2904 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2905 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2906 TEST_ASSERT_NOT_NULL(ut_params->op,
2907 "Failed to allocate pktmbuf offload");
2908 /* Set crypto operation data parameters */
2909 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2911 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2913 /* set crypto operation source mbuf */
2914 sym_op->m_src = ut_params->ibuf;
2917 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2918 ut_params->ibuf, auth_tag_len);
2920 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2921 "no room to append auth tag");
2922 ut_params->digest = sym_op->auth.digest.data;
2924 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2925 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2926 ut_params->ibuf, data_pad_len);
2928 struct rte_mbuf *m = ut_params->ibuf;
2929 unsigned int offset = data_pad_len;
2931 while (offset > m->data_len && m->next != NULL) {
2932 offset -= m->data_len;
2935 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2939 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2940 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2942 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2944 debug_hexdump(stdout, "digest:",
2945 sym_op->auth.digest.data,
2948 /* Copy cipher and auth IVs at the end of the crypto operation */
2949 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2951 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2952 iv_ptr += cipher_iv_len;
2953 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2955 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2956 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2957 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2958 sym_op->cipher.data.length = cipher_len;
2959 sym_op->cipher.data.offset = cipher_offset;
2961 sym_op->cipher.data.length = cipher_len >> 3;
2962 sym_op->cipher.data.offset = cipher_offset >> 3;
2965 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2966 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2967 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2968 sym_op->auth.data.length = auth_len;
2969 sym_op->auth.data.offset = auth_offset;
2971 sym_op->auth.data.length = auth_len >> 3;
2972 sym_op->auth.data.offset = auth_offset >> 3;
2979 create_wireless_algo_auth_cipher_operation(
2980 const uint8_t *auth_tag, unsigned int auth_tag_len,
2981 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2982 const uint8_t *auth_iv, uint8_t auth_iv_len,
2983 unsigned int data_pad_len,
2984 unsigned int cipher_len, unsigned int cipher_offset,
2985 unsigned int auth_len, unsigned int auth_offset,
2986 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2988 struct crypto_testsuite_params *ts_params = &testsuite_params;
2989 struct crypto_unittest_params *ut_params = &unittest_params;
2991 enum rte_crypto_cipher_algorithm cipher_algo =
2992 ut_params->cipher_xform.cipher.algo;
2993 enum rte_crypto_auth_algorithm auth_algo =
2994 ut_params->auth_xform.auth.algo;
2996 /* Generate Crypto op data structure */
2997 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2998 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2999 TEST_ASSERT_NOT_NULL(ut_params->op,
3000 "Failed to allocate pktmbuf offload");
3002 /* Set crypto operation data parameters */
3003 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3005 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3007 /* set crypto operation mbufs */
3008 sym_op->m_src = ut_params->ibuf;
3009 if (op_mode == OUT_OF_PLACE)
3010 sym_op->m_dst = ut_params->obuf;
3014 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3015 (op_mode == IN_PLACE ?
3016 ut_params->ibuf : ut_params->obuf),
3017 uint8_t *, data_pad_len);
3018 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3019 (op_mode == IN_PLACE ?
3020 ut_params->ibuf : ut_params->obuf),
3022 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3024 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3025 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3026 sym_op->m_src : sym_op->m_dst);
3027 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3028 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3029 sgl_buf = sgl_buf->next;
3031 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3032 uint8_t *, remaining_off);
3033 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3035 memset(sym_op->auth.digest.data, 0, remaining_off);
3036 while (sgl_buf->next != NULL) {
3037 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3038 0, rte_pktmbuf_data_len(sgl_buf));
3039 sgl_buf = sgl_buf->next;
3043 /* Copy digest for the verification */
3045 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3047 /* Copy cipher and auth IVs at the end of the crypto operation */
3048 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3049 ut_params->op, uint8_t *, IV_OFFSET);
3051 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3052 iv_ptr += cipher_iv_len;
3053 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3055 /* Only copy over the offset data needed from src to dst in OOP,
3056 * if the auth and cipher offsets are not aligned
3058 if (op_mode == OUT_OF_PLACE) {
3059 if (cipher_offset > auth_offset)
3061 rte_pktmbuf_mtod_offset(
3063 uint8_t *, auth_offset >> 3),
3064 rte_pktmbuf_mtod_offset(
3066 uint8_t *, auth_offset >> 3),
3067 ((cipher_offset >> 3) - (auth_offset >> 3)));
3070 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3071 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3072 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3073 sym_op->cipher.data.length = cipher_len;
3074 sym_op->cipher.data.offset = cipher_offset;
3076 sym_op->cipher.data.length = cipher_len >> 3;
3077 sym_op->cipher.data.offset = cipher_offset >> 3;
3080 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3081 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3082 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3083 sym_op->auth.data.length = auth_len;
3084 sym_op->auth.data.offset = auth_offset;
3086 sym_op->auth.data.length = auth_len >> 3;
3087 sym_op->auth.data.offset = auth_offset >> 3;
3094 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3096 struct crypto_testsuite_params *ts_params = &testsuite_params;
3097 struct crypto_unittest_params *ut_params = &unittest_params;
3100 unsigned plaintext_pad_len;
3101 unsigned plaintext_len;
3103 struct rte_cryptodev_info dev_info;
3105 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3106 uint64_t feat_flags = dev_info.feature_flags;
3108 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3109 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3110 printf("Device doesn't support NON-Byte Aligned Data.\n");
3111 return TEST_SKIPPED;
3114 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3115 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3116 printf("Device doesn't support RAW data-path APIs.\n");
3117 return TEST_SKIPPED;
3120 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3121 return TEST_SKIPPED;
3123 /* Verify the capabilities */
3124 struct rte_cryptodev_sym_capability_idx cap_idx;
3125 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3126 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3127 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3129 return TEST_SKIPPED;
3131 /* Create SNOW 3G session */
3132 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3133 tdata->key.data, tdata->key.len,
3134 tdata->auth_iv.len, tdata->digest.len,
3135 RTE_CRYPTO_AUTH_OP_GENERATE,
3136 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3140 /* alloc mbuf and set payload */
3141 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3143 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3144 rte_pktmbuf_tailroom(ut_params->ibuf));
3146 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3147 /* Append data which is padded to a multiple of */
3148 /* the algorithms block size */
3149 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3150 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3152 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3154 /* Create SNOW 3G operation */
3155 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3156 tdata->auth_iv.data, tdata->auth_iv.len,
3157 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3158 tdata->validAuthLenInBits.len,
3163 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3164 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3165 ut_params->op, 0, 1, 1, 0);
3167 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3169 ut_params->obuf = ut_params->op->sym->m_src;
3170 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3171 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3172 + plaintext_pad_len;
3175 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3178 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3179 "SNOW 3G Generated auth tag not as expected");
3185 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3187 struct crypto_testsuite_params *ts_params = &testsuite_params;
3188 struct crypto_unittest_params *ut_params = &unittest_params;
3191 unsigned plaintext_pad_len;
3192 unsigned plaintext_len;
3194 struct rte_cryptodev_info dev_info;
3196 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3197 uint64_t feat_flags = dev_info.feature_flags;
3199 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3200 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3201 printf("Device doesn't support NON-Byte Aligned Data.\n");
3202 return TEST_SKIPPED;
3205 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3206 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3207 printf("Device doesn't support RAW data-path APIs.\n");
3208 return TEST_SKIPPED;
3211 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3212 return TEST_SKIPPED;
3214 /* Verify the capabilities */
3215 struct rte_cryptodev_sym_capability_idx cap_idx;
3216 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3217 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3218 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3220 return TEST_SKIPPED;
3222 /* Create SNOW 3G session */
3223 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3224 tdata->key.data, tdata->key.len,
3225 tdata->auth_iv.len, tdata->digest.len,
3226 RTE_CRYPTO_AUTH_OP_VERIFY,
3227 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3230 /* alloc mbuf and set payload */
3231 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3233 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3234 rte_pktmbuf_tailroom(ut_params->ibuf));
3236 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3237 /* Append data which is padded to a multiple of */
3238 /* the algorithms block size */
3239 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3240 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3242 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3244 /* Create SNOW 3G operation */
3245 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3247 tdata->auth_iv.data, tdata->auth_iv.len,
3249 RTE_CRYPTO_AUTH_OP_VERIFY,
3250 tdata->validAuthLenInBits.len,
3255 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3256 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3257 ut_params->op, 0, 1, 1, 0);
3259 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3261 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3262 ut_params->obuf = ut_params->op->sym->m_src;
3263 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3264 + plaintext_pad_len;
3267 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3276 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3278 struct crypto_testsuite_params *ts_params = &testsuite_params;
3279 struct crypto_unittest_params *ut_params = &unittest_params;
3282 unsigned plaintext_pad_len;
3283 unsigned plaintext_len;
3285 struct rte_cryptodev_info dev_info;
3287 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3288 uint64_t feat_flags = dev_info.feature_flags;
3290 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3291 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3292 printf("Device doesn't support RAW data-path APIs.\n");
3293 return TEST_SKIPPED;
3296 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3297 return TEST_SKIPPED;
3299 /* Verify the capabilities */
3300 struct rte_cryptodev_sym_capability_idx cap_idx;
3301 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3302 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3303 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3305 return TEST_SKIPPED;
3307 /* Create KASUMI session */
3308 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3309 tdata->key.data, tdata->key.len,
3310 0, tdata->digest.len,
3311 RTE_CRYPTO_AUTH_OP_GENERATE,
3312 RTE_CRYPTO_AUTH_KASUMI_F9);
3316 /* alloc mbuf and set payload */
3317 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3319 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3320 rte_pktmbuf_tailroom(ut_params->ibuf));
3322 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3323 /* Append data which is padded to a multiple of */
3324 /* the algorithms block size */
3325 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3326 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3328 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3330 /* Create KASUMI operation */
3331 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3333 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3334 tdata->plaintext.len,
3339 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3340 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3342 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3343 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3344 ut_params->op, 0, 1, 1, 0);
3346 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3349 ut_params->obuf = ut_params->op->sym->m_src;
3350 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3351 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3352 + plaintext_pad_len;
3355 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3358 DIGEST_BYTE_LENGTH_KASUMI_F9,
3359 "KASUMI Generated auth tag not as expected");
3365 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3367 struct crypto_testsuite_params *ts_params = &testsuite_params;
3368 struct crypto_unittest_params *ut_params = &unittest_params;
3371 unsigned plaintext_pad_len;
3372 unsigned plaintext_len;
3374 struct rte_cryptodev_info dev_info;
3376 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3377 uint64_t feat_flags = dev_info.feature_flags;
3379 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3380 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3381 printf("Device doesn't support RAW data-path APIs.\n");
3382 return TEST_SKIPPED;
3385 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3386 return TEST_SKIPPED;
3388 /* Verify the capabilities */
3389 struct rte_cryptodev_sym_capability_idx cap_idx;
3390 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3391 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3392 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3394 return TEST_SKIPPED;
3396 /* Create KASUMI session */
3397 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3398 tdata->key.data, tdata->key.len,
3399 0, tdata->digest.len,
3400 RTE_CRYPTO_AUTH_OP_VERIFY,
3401 RTE_CRYPTO_AUTH_KASUMI_F9);
3404 /* alloc mbuf and set payload */
3405 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3407 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3408 rte_pktmbuf_tailroom(ut_params->ibuf));
3410 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3411 /* Append data which is padded to a multiple */
3412 /* of the algorithms block size */
3413 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3414 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3416 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3418 /* Create KASUMI operation */
3419 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3423 RTE_CRYPTO_AUTH_OP_VERIFY,
3424 tdata->plaintext.len,
3429 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3430 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3431 ut_params->op, 0, 1, 1, 0);
3433 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3435 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3436 ut_params->obuf = ut_params->op->sym->m_src;
3437 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3438 + plaintext_pad_len;
3441 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3450 test_snow3g_hash_generate_test_case_1(void)
3452 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3456 test_snow3g_hash_generate_test_case_2(void)
3458 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3462 test_snow3g_hash_generate_test_case_3(void)
3464 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3468 test_snow3g_hash_generate_test_case_4(void)
3470 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3474 test_snow3g_hash_generate_test_case_5(void)
3476 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3480 test_snow3g_hash_generate_test_case_6(void)
3482 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3486 test_snow3g_hash_verify_test_case_1(void)
3488 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3493 test_snow3g_hash_verify_test_case_2(void)
3495 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3499 test_snow3g_hash_verify_test_case_3(void)
3501 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3505 test_snow3g_hash_verify_test_case_4(void)
3507 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3511 test_snow3g_hash_verify_test_case_5(void)
3513 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3517 test_snow3g_hash_verify_test_case_6(void)
3519 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3523 test_kasumi_hash_generate_test_case_1(void)
3525 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3529 test_kasumi_hash_generate_test_case_2(void)
3531 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3535 test_kasumi_hash_generate_test_case_3(void)
3537 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3541 test_kasumi_hash_generate_test_case_4(void)
3543 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3547 test_kasumi_hash_generate_test_case_5(void)
3549 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3553 test_kasumi_hash_generate_test_case_6(void)
3555 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3559 test_kasumi_hash_verify_test_case_1(void)
3561 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3565 test_kasumi_hash_verify_test_case_2(void)
3567 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3571 test_kasumi_hash_verify_test_case_3(void)
3573 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3577 test_kasumi_hash_verify_test_case_4(void)
3579 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3583 test_kasumi_hash_verify_test_case_5(void)
3585 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3589 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3591 struct crypto_testsuite_params *ts_params = &testsuite_params;
3592 struct crypto_unittest_params *ut_params = &unittest_params;
3595 uint8_t *plaintext, *ciphertext;
3596 unsigned plaintext_pad_len;
3597 unsigned plaintext_len;
3598 struct rte_cryptodev_info dev_info;
3600 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3601 uint64_t feat_flags = dev_info.feature_flags;
3603 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3604 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3605 printf("Device doesn't support RAW data-path APIs.\n");
3606 return TEST_SKIPPED;
3609 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3610 return TEST_SKIPPED;
3612 /* Verify the capabilities */
3613 struct rte_cryptodev_sym_capability_idx cap_idx;
3614 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3615 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3616 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3618 return TEST_SKIPPED;
3620 /* Create KASUMI session */
3621 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3622 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3623 RTE_CRYPTO_CIPHER_KASUMI_F8,
3624 tdata->key.data, tdata->key.len,
3625 tdata->cipher_iv.len);
3629 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3631 /* Clear mbuf payload */
3632 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3633 rte_pktmbuf_tailroom(ut_params->ibuf));
3635 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3636 /* Append data which is padded to a multiple */
3637 /* of the algorithms block size */
3638 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3639 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3641 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3643 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3645 /* Create KASUMI operation */
3646 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3647 tdata->cipher_iv.len,
3648 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3649 tdata->validCipherOffsetInBits.len);
3653 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3654 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3655 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3657 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3659 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3661 ut_params->obuf = ut_params->op->sym->m_dst;
3662 if (ut_params->obuf)
3663 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3665 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3667 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3669 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3670 (tdata->validCipherOffsetInBits.len >> 3);
3672 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3674 reference_ciphertext,
3675 tdata->validCipherLenInBits.len,
3676 "KASUMI Ciphertext data not as expected");
3681 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3683 struct crypto_testsuite_params *ts_params = &testsuite_params;
3684 struct crypto_unittest_params *ut_params = &unittest_params;
3688 unsigned int plaintext_pad_len;
3689 unsigned int plaintext_len;
3691 uint8_t buffer[10000];
3692 const uint8_t *ciphertext;
3694 struct rte_cryptodev_info dev_info;
3696 /* Verify the capabilities */
3697 struct rte_cryptodev_sym_capability_idx cap_idx;
3698 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3699 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3700 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3702 return TEST_SKIPPED;
3704 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3706 uint64_t feat_flags = dev_info.feature_flags;
3708 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3709 printf("Device doesn't support in-place scatter-gather. "
3711 return TEST_SKIPPED;
3714 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3715 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3716 printf("Device doesn't support RAW data-path APIs.\n");
3717 return TEST_SKIPPED;
3720 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3721 return TEST_SKIPPED;
3723 /* Create KASUMI session */
3724 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3725 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3726 RTE_CRYPTO_CIPHER_KASUMI_F8,
3727 tdata->key.data, tdata->key.len,
3728 tdata->cipher_iv.len);
3732 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3735 /* Append data which is padded to a multiple */
3736 /* of the algorithms block size */
3737 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3739 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3740 plaintext_pad_len, 10, 0);
3742 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3744 /* Create KASUMI operation */
3745 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3746 tdata->cipher_iv.len,
3747 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3748 tdata->validCipherOffsetInBits.len);
3752 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3753 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3754 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3756 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3758 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3760 ut_params->obuf = ut_params->op->sym->m_dst;
3762 if (ut_params->obuf)
3763 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3764 plaintext_len, buffer);
3766 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3767 tdata->validCipherOffsetInBits.len >> 3,
3768 plaintext_len, buffer);
3771 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3773 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3774 (tdata->validCipherOffsetInBits.len >> 3);
3776 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3778 reference_ciphertext,
3779 tdata->validCipherLenInBits.len,
3780 "KASUMI Ciphertext data not as expected");
3785 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3787 struct crypto_testsuite_params *ts_params = &testsuite_params;
3788 struct crypto_unittest_params *ut_params = &unittest_params;
3791 uint8_t *plaintext, *ciphertext;
3792 unsigned plaintext_pad_len;
3793 unsigned plaintext_len;
3795 /* Verify the capabilities */
3796 struct rte_cryptodev_sym_capability_idx cap_idx;
3797 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3798 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3799 /* Data-path service does not support OOP */
3800 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3802 return TEST_SKIPPED;
3804 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3805 return TEST_SKIPPED;
3807 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3808 return TEST_SKIPPED;
3810 /* Create KASUMI session */
3811 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3812 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3813 RTE_CRYPTO_CIPHER_KASUMI_F8,
3814 tdata->key.data, tdata->key.len,
3815 tdata->cipher_iv.len);
3819 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3820 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3822 /* Clear mbuf payload */
3823 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3824 rte_pktmbuf_tailroom(ut_params->ibuf));
3826 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3827 /* Append data which is padded to a multiple */
3828 /* of the algorithms block size */
3829 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3830 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3832 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3833 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3835 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3837 /* Create KASUMI operation */
3838 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3839 tdata->cipher_iv.len,
3840 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3841 tdata->validCipherOffsetInBits.len);
3845 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3847 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3849 ut_params->obuf = ut_params->op->sym->m_dst;
3850 if (ut_params->obuf)
3851 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3853 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3855 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3857 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3858 (tdata->validCipherOffsetInBits.len >> 3);
3860 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3862 reference_ciphertext,
3863 tdata->validCipherLenInBits.len,
3864 "KASUMI Ciphertext data not as expected");
3869 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3871 struct crypto_testsuite_params *ts_params = &testsuite_params;
3872 struct crypto_unittest_params *ut_params = &unittest_params;
3875 unsigned int plaintext_pad_len;
3876 unsigned int plaintext_len;
3878 const uint8_t *ciphertext;
3879 uint8_t buffer[2048];
3881 struct rte_cryptodev_info dev_info;
3883 /* Verify the capabilities */
3884 struct rte_cryptodev_sym_capability_idx cap_idx;
3885 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3886 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3887 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3889 return TEST_SKIPPED;
3891 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3892 return TEST_SKIPPED;
3894 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3895 return TEST_SKIPPED;
3897 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3899 uint64_t feat_flags = dev_info.feature_flags;
3900 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3901 printf("Device doesn't support out-of-place scatter-gather "
3902 "in both input and output mbufs. "
3904 return TEST_SKIPPED;
3907 /* Create KASUMI session */
3908 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3909 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3910 RTE_CRYPTO_CIPHER_KASUMI_F8,
3911 tdata->key.data, tdata->key.len,
3912 tdata->cipher_iv.len);
3916 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3917 /* Append data which is padded to a multiple */
3918 /* of the algorithms block size */
3919 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3921 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3922 plaintext_pad_len, 10, 0);
3923 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3924 plaintext_pad_len, 3, 0);
3926 /* Append data which is padded to a multiple */
3927 /* of the algorithms block size */
3928 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3930 /* Create KASUMI operation */
3931 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3932 tdata->cipher_iv.len,
3933 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3934 tdata->validCipherOffsetInBits.len);
3938 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3940 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3942 ut_params->obuf = ut_params->op->sym->m_dst;
3943 if (ut_params->obuf)
3944 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3945 plaintext_pad_len, buffer);
3947 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3948 tdata->validCipherOffsetInBits.len >> 3,
3949 plaintext_pad_len, buffer);
3951 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3952 (tdata->validCipherOffsetInBits.len >> 3);
3954 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3956 reference_ciphertext,
3957 tdata->validCipherLenInBits.len,
3958 "KASUMI Ciphertext data not as expected");
3964 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3966 struct crypto_testsuite_params *ts_params = &testsuite_params;
3967 struct crypto_unittest_params *ut_params = &unittest_params;
3970 uint8_t *ciphertext, *plaintext;
3971 unsigned ciphertext_pad_len;
3972 unsigned ciphertext_len;
3974 /* Verify the capabilities */
3975 struct rte_cryptodev_sym_capability_idx cap_idx;
3976 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3977 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3978 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3980 return TEST_SKIPPED;
3982 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3983 return TEST_SKIPPED;
3985 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3986 return TEST_SKIPPED;
3988 /* Create KASUMI session */
3989 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3990 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3991 RTE_CRYPTO_CIPHER_KASUMI_F8,
3992 tdata->key.data, tdata->key.len,
3993 tdata->cipher_iv.len);
3997 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3998 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4000 /* Clear mbuf payload */
4001 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4002 rte_pktmbuf_tailroom(ut_params->ibuf));
4004 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4005 /* Append data which is padded to a multiple */
4006 /* of the algorithms block size */
4007 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4008 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4009 ciphertext_pad_len);
4010 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4011 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4013 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4015 /* Create KASUMI operation */
4016 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4017 tdata->cipher_iv.len,
4018 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4019 tdata->validCipherOffsetInBits.len);
4023 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4025 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4027 ut_params->obuf = ut_params->op->sym->m_dst;
4028 if (ut_params->obuf)
4029 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4031 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4033 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4035 const uint8_t *reference_plaintext = tdata->plaintext.data +
4036 (tdata->validCipherOffsetInBits.len >> 3);
4038 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4040 reference_plaintext,
4041 tdata->validCipherLenInBits.len,
4042 "KASUMI Plaintext data not as expected");
4047 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4049 struct crypto_testsuite_params *ts_params = &testsuite_params;
4050 struct crypto_unittest_params *ut_params = &unittest_params;
4053 uint8_t *ciphertext, *plaintext;
4054 unsigned ciphertext_pad_len;
4055 unsigned ciphertext_len;
4056 struct rte_cryptodev_info dev_info;
4058 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4059 uint64_t feat_flags = dev_info.feature_flags;
4061 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4062 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4063 printf("Device doesn't support RAW data-path APIs.\n");
4064 return TEST_SKIPPED;
4067 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4068 return TEST_SKIPPED;
4070 /* Verify the capabilities */
4071 struct rte_cryptodev_sym_capability_idx cap_idx;
4072 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4073 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4074 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4076 return TEST_SKIPPED;
4078 /* Create KASUMI session */
4079 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4080 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4081 RTE_CRYPTO_CIPHER_KASUMI_F8,
4082 tdata->key.data, tdata->key.len,
4083 tdata->cipher_iv.len);
4087 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4089 /* Clear mbuf payload */
4090 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4091 rte_pktmbuf_tailroom(ut_params->ibuf));
4093 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4094 /* Append data which is padded to a multiple */
4095 /* of the algorithms block size */
4096 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4097 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4098 ciphertext_pad_len);
4099 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4101 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4103 /* Create KASUMI operation */
4104 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4105 tdata->cipher_iv.len,
4106 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4107 tdata->validCipherOffsetInBits.len);
4111 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4112 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4113 ut_params->op, 1, 0, 1, 0);
4115 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4117 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4119 ut_params->obuf = ut_params->op->sym->m_dst;
4120 if (ut_params->obuf)
4121 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4123 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4125 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4127 const uint8_t *reference_plaintext = tdata->plaintext.data +
4128 (tdata->validCipherOffsetInBits.len >> 3);
4130 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4132 reference_plaintext,
4133 tdata->validCipherLenInBits.len,
4134 "KASUMI Plaintext data not as expected");
4139 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4141 struct crypto_testsuite_params *ts_params = &testsuite_params;
4142 struct crypto_unittest_params *ut_params = &unittest_params;
4145 uint8_t *plaintext, *ciphertext;
4146 unsigned plaintext_pad_len;
4147 unsigned plaintext_len;
4148 struct rte_cryptodev_info dev_info;
4150 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4151 uint64_t feat_flags = dev_info.feature_flags;
4153 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4154 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4155 printf("Device doesn't support RAW data-path APIs.\n");
4156 return TEST_SKIPPED;
4159 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4160 return TEST_SKIPPED;
4162 /* Verify the capabilities */
4163 struct rte_cryptodev_sym_capability_idx cap_idx;
4164 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4165 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4166 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4168 return TEST_SKIPPED;
4170 /* Create SNOW 3G session */
4171 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4172 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4173 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4174 tdata->key.data, tdata->key.len,
4175 tdata->cipher_iv.len);
4179 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4181 /* Clear mbuf payload */
4182 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4183 rte_pktmbuf_tailroom(ut_params->ibuf));
4185 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4186 /* Append data which is padded to a multiple of */
4187 /* the algorithms block size */
4188 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4189 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4191 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4193 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4195 /* Create SNOW 3G operation */
4196 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4197 tdata->cipher_iv.len,
4198 tdata->validCipherLenInBits.len,
4203 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4204 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4205 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4207 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4209 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4211 ut_params->obuf = ut_params->op->sym->m_dst;
4212 if (ut_params->obuf)
4213 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4215 ciphertext = plaintext;
4217 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4220 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4222 tdata->ciphertext.data,
4223 tdata->validDataLenInBits.len,
4224 "SNOW 3G Ciphertext data not as expected");
4230 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4232 struct crypto_testsuite_params *ts_params = &testsuite_params;
4233 struct crypto_unittest_params *ut_params = &unittest_params;
4234 uint8_t *plaintext, *ciphertext;
4237 unsigned plaintext_pad_len;
4238 unsigned plaintext_len;
4239 struct rte_cryptodev_info dev_info;
4241 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4242 uint64_t feat_flags = dev_info.feature_flags;
4244 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4245 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4246 printf("Device does not support RAW data-path APIs.\n");
4250 /* Verify the capabilities */
4251 struct rte_cryptodev_sym_capability_idx cap_idx;
4252 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4253 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4254 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4256 return TEST_SKIPPED;
4258 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4259 return TEST_SKIPPED;
4261 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4262 return TEST_SKIPPED;
4264 /* Create SNOW 3G session */
4265 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4266 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4267 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4268 tdata->key.data, tdata->key.len,
4269 tdata->cipher_iv.len);
4273 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4274 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4276 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4277 "Failed to allocate input buffer in mempool");
4278 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4279 "Failed to allocate output buffer in mempool");
4281 /* Clear mbuf payload */
4282 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4283 rte_pktmbuf_tailroom(ut_params->ibuf));
4285 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4286 /* Append data which is padded to a multiple of */
4287 /* the algorithms block size */
4288 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4289 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4291 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4292 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4294 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4296 /* Create SNOW 3G operation */
4297 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4298 tdata->cipher_iv.len,
4299 tdata->validCipherLenInBits.len,
4304 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4305 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4306 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4308 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4310 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4312 ut_params->obuf = ut_params->op->sym->m_dst;
4313 if (ut_params->obuf)
4314 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4316 ciphertext = plaintext;
4318 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4321 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4323 tdata->ciphertext.data,
4324 tdata->validDataLenInBits.len,
4325 "SNOW 3G Ciphertext data not as expected");
4330 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4332 struct crypto_testsuite_params *ts_params = &testsuite_params;
4333 struct crypto_unittest_params *ut_params = &unittest_params;
4336 unsigned int plaintext_pad_len;
4337 unsigned int plaintext_len;
4338 uint8_t buffer[10000];
4339 const uint8_t *ciphertext;
4341 struct rte_cryptodev_info dev_info;
4343 /* Verify the capabilities */
4344 struct rte_cryptodev_sym_capability_idx cap_idx;
4345 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4346 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4347 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4349 return TEST_SKIPPED;
4351 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4352 return TEST_SKIPPED;
4354 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4355 return TEST_SKIPPED;
4357 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4359 uint64_t feat_flags = dev_info.feature_flags;
4361 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4362 printf("Device doesn't support out-of-place scatter-gather "
4363 "in both input and output mbufs. "
4365 return TEST_SKIPPED;
4368 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4369 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4370 printf("Device does not support RAW data-path APIs.\n");
4374 /* Create SNOW 3G session */
4375 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4376 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4377 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4378 tdata->key.data, tdata->key.len,
4379 tdata->cipher_iv.len);
4383 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4384 /* Append data which is padded to a multiple of */
4385 /* the algorithms block size */
4386 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4388 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4389 plaintext_pad_len, 10, 0);
4390 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4391 plaintext_pad_len, 3, 0);
4393 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4394 "Failed to allocate input buffer in mempool");
4395 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4396 "Failed to allocate output buffer in mempool");
4398 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4400 /* Create SNOW 3G operation */
4401 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4402 tdata->cipher_iv.len,
4403 tdata->validCipherLenInBits.len,
4408 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4409 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4410 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4412 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4414 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4416 ut_params->obuf = ut_params->op->sym->m_dst;
4417 if (ut_params->obuf)
4418 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4419 plaintext_len, buffer);
4421 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4422 plaintext_len, buffer);
4424 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4427 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4429 tdata->ciphertext.data,
4430 tdata->validDataLenInBits.len,
4431 "SNOW 3G Ciphertext data not as expected");
4436 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4438 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4440 uint8_t curr_byte, prev_byte;
4441 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4442 uint8_t lower_byte_mask = (1 << offset) - 1;
4445 prev_byte = buffer[0];
4446 buffer[0] >>= offset;
4448 for (i = 1; i < length_in_bytes; i++) {
4449 curr_byte = buffer[i];
4450 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4451 (curr_byte >> offset);
4452 prev_byte = curr_byte;
4457 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4459 struct crypto_testsuite_params *ts_params = &testsuite_params;
4460 struct crypto_unittest_params *ut_params = &unittest_params;
4461 uint8_t *plaintext, *ciphertext;
4463 uint32_t plaintext_len;
4464 uint32_t plaintext_pad_len;
4465 uint8_t extra_offset = 4;
4466 uint8_t *expected_ciphertext_shifted;
4467 struct rte_cryptodev_info dev_info;
4469 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4470 uint64_t feat_flags = dev_info.feature_flags;
4472 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4473 ((tdata->validDataLenInBits.len % 8) != 0)) {
4474 printf("Device doesn't support NON-Byte Aligned Data.\n");
4475 return TEST_SKIPPED;
4478 /* Verify the capabilities */
4479 struct rte_cryptodev_sym_capability_idx cap_idx;
4480 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4481 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4482 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4484 return TEST_SKIPPED;
4486 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4487 return TEST_SKIPPED;
4489 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4490 return TEST_SKIPPED;
4492 /* Create SNOW 3G session */
4493 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4494 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4495 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4496 tdata->key.data, tdata->key.len,
4497 tdata->cipher_iv.len);
4501 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4502 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4504 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4505 "Failed to allocate input buffer in mempool");
4506 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4507 "Failed to allocate output buffer in mempool");
4509 /* Clear mbuf payload */
4510 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4511 rte_pktmbuf_tailroom(ut_params->ibuf));
4513 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4515 * Append data which is padded to a
4516 * multiple of the algorithms block size
4518 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4520 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4523 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4525 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4526 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4528 #ifdef RTE_APP_TEST_DEBUG
4529 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4531 /* Create SNOW 3G operation */
4532 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4533 tdata->cipher_iv.len,
4534 tdata->validCipherLenInBits.len,
4539 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4540 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4541 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4543 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4545 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4547 ut_params->obuf = ut_params->op->sym->m_dst;
4548 if (ut_params->obuf)
4549 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4551 ciphertext = plaintext;
4553 #ifdef RTE_APP_TEST_DEBUG
4554 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4557 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4559 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4560 "failed to reserve memory for ciphertext shifted\n");
4562 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4563 ceil_byte_length(tdata->ciphertext.len));
4564 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4567 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4569 expected_ciphertext_shifted,
4570 tdata->validDataLenInBits.len,
4572 "SNOW 3G Ciphertext data not as expected");
4576 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4578 struct crypto_testsuite_params *ts_params = &testsuite_params;
4579 struct crypto_unittest_params *ut_params = &unittest_params;
4583 uint8_t *plaintext, *ciphertext;
4584 unsigned ciphertext_pad_len;
4585 unsigned ciphertext_len;
4586 struct rte_cryptodev_info dev_info;
4588 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4589 uint64_t feat_flags = dev_info.feature_flags;
4591 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4592 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4593 printf("Device doesn't support RAW data-path APIs.\n");
4594 return TEST_SKIPPED;
4597 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4598 return TEST_SKIPPED;
4600 /* Verify the capabilities */
4601 struct rte_cryptodev_sym_capability_idx cap_idx;
4602 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4603 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4604 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4606 return TEST_SKIPPED;
4608 /* Create SNOW 3G session */
4609 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4610 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4611 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4612 tdata->key.data, tdata->key.len,
4613 tdata->cipher_iv.len);
4617 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4619 /* Clear mbuf payload */
4620 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4621 rte_pktmbuf_tailroom(ut_params->ibuf));
4623 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4624 /* Append data which is padded to a multiple of */
4625 /* the algorithms block size */
4626 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4627 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4628 ciphertext_pad_len);
4629 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4631 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4633 /* Create SNOW 3G operation */
4634 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4635 tdata->cipher_iv.len,
4636 tdata->validCipherLenInBits.len,
4637 tdata->cipher.offset_bits);
4641 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4642 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4643 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4645 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4647 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4648 ut_params->obuf = ut_params->op->sym->m_dst;
4649 if (ut_params->obuf)
4650 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4652 plaintext = ciphertext;
4654 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4657 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4658 tdata->plaintext.data,
4659 tdata->validDataLenInBits.len,
4660 "SNOW 3G Plaintext data not as expected");
4664 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4666 struct crypto_testsuite_params *ts_params = &testsuite_params;
4667 struct crypto_unittest_params *ut_params = &unittest_params;
4671 uint8_t *plaintext, *ciphertext;
4672 unsigned ciphertext_pad_len;
4673 unsigned ciphertext_len;
4674 struct rte_cryptodev_info dev_info;
4676 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4677 uint64_t feat_flags = dev_info.feature_flags;
4679 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4680 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4681 printf("Device does not support RAW data-path APIs.\n");
4684 /* Verify the capabilities */
4685 struct rte_cryptodev_sym_capability_idx cap_idx;
4686 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4687 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4688 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4690 return TEST_SKIPPED;
4692 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4693 return TEST_SKIPPED;
4695 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4696 return TEST_SKIPPED;
4698 /* Create SNOW 3G session */
4699 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4700 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4701 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4702 tdata->key.data, tdata->key.len,
4703 tdata->cipher_iv.len);
4707 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4708 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4710 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4711 "Failed to allocate input buffer");
4712 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4713 "Failed to allocate output buffer");
4715 /* Clear mbuf payload */
4716 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4717 rte_pktmbuf_tailroom(ut_params->ibuf));
4719 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4720 rte_pktmbuf_tailroom(ut_params->obuf));
4722 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4723 /* Append data which is padded to a multiple of */
4724 /* the algorithms block size */
4725 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4726 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4727 ciphertext_pad_len);
4728 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4729 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4731 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4733 /* Create SNOW 3G operation */
4734 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4735 tdata->cipher_iv.len,
4736 tdata->validCipherLenInBits.len,
4741 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4742 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4743 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4745 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4747 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4748 ut_params->obuf = ut_params->op->sym->m_dst;
4749 if (ut_params->obuf)
4750 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4752 plaintext = ciphertext;
4754 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4757 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4758 tdata->plaintext.data,
4759 tdata->validDataLenInBits.len,
4760 "SNOW 3G Plaintext data not as expected");
4765 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4767 struct crypto_testsuite_params *ts_params = &testsuite_params;
4768 struct crypto_unittest_params *ut_params = &unittest_params;
4772 uint8_t *plaintext, *ciphertext;
4773 unsigned int plaintext_pad_len;
4774 unsigned int plaintext_len;
4776 struct rte_cryptodev_info dev_info;
4777 struct rte_cryptodev_sym_capability_idx cap_idx;
4779 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4780 uint64_t feat_flags = dev_info.feature_flags;
4782 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4783 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4784 (tdata->validDataLenInBits.len % 8 != 0))) {
4785 printf("Device doesn't support NON-Byte Aligned Data.\n");
4786 return TEST_SKIPPED;
4789 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4790 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4791 printf("Device doesn't support RAW data-path APIs.\n");
4792 return TEST_SKIPPED;
4795 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4796 return TEST_SKIPPED;
4798 /* Check if device supports ZUC EEA3 */
4799 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4800 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4802 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4804 return TEST_SKIPPED;
4806 /* Check if device supports ZUC EIA3 */
4807 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4808 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4810 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4812 return TEST_SKIPPED;
4814 /* Create ZUC session */
4815 retval = create_zuc_cipher_auth_encrypt_generate_session(
4816 ts_params->valid_devs[0],
4820 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4822 /* clear mbuf payload */
4823 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4824 rte_pktmbuf_tailroom(ut_params->ibuf));
4826 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4827 /* Append data which is padded to a multiple of */
4828 /* the algorithms block size */
4829 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4830 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4832 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4834 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4836 /* Create ZUC operation */
4837 retval = create_zuc_cipher_hash_generate_operation(tdata);
4841 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4842 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4843 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4845 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4847 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4848 ut_params->obuf = ut_params->op->sym->m_src;
4849 if (ut_params->obuf)
4850 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4852 ciphertext = plaintext;
4854 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4856 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4858 tdata->ciphertext.data,
4859 tdata->validDataLenInBits.len,
4860 "ZUC Ciphertext data not as expected");
4862 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4863 + plaintext_pad_len;
4866 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4870 "ZUC Generated auth tag not as expected");
4875 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4877 struct crypto_testsuite_params *ts_params = &testsuite_params;
4878 struct crypto_unittest_params *ut_params = &unittest_params;
4882 uint8_t *plaintext, *ciphertext;
4883 unsigned plaintext_pad_len;
4884 unsigned plaintext_len;
4885 struct rte_cryptodev_info dev_info;
4887 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4888 uint64_t feat_flags = dev_info.feature_flags;
4890 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4891 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4892 printf("Device doesn't support RAW data-path APIs.\n");
4893 return TEST_SKIPPED;
4896 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4897 return TEST_SKIPPED;
4899 /* Verify the capabilities */
4900 struct rte_cryptodev_sym_capability_idx cap_idx;
4901 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4902 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4903 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4905 return TEST_SKIPPED;
4906 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4907 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4908 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4910 return TEST_SKIPPED;
4912 /* Create SNOW 3G session */
4913 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4914 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4915 RTE_CRYPTO_AUTH_OP_GENERATE,
4916 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4917 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4918 tdata->key.data, tdata->key.len,
4919 tdata->auth_iv.len, tdata->digest.len,
4920 tdata->cipher_iv.len);
4923 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4925 /* clear mbuf payload */
4926 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4927 rte_pktmbuf_tailroom(ut_params->ibuf));
4929 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4930 /* Append data which is padded to a multiple of */
4931 /* the algorithms block size */
4932 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4933 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4935 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4937 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4939 /* Create SNOW 3G operation */
4940 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4941 tdata->digest.len, tdata->auth_iv.data,
4943 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4944 tdata->cipher_iv.data, tdata->cipher_iv.len,
4945 tdata->validCipherLenInBits.len,
4947 tdata->validAuthLenInBits.len,
4953 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4954 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4955 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4957 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4959 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4960 ut_params->obuf = ut_params->op->sym->m_src;
4961 if (ut_params->obuf)
4962 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4964 ciphertext = plaintext;
4966 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4968 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4970 tdata->ciphertext.data,
4971 tdata->validDataLenInBits.len,
4972 "SNOW 3G Ciphertext data not as expected");
4974 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4975 + plaintext_pad_len;
4978 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4981 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4982 "SNOW 3G Generated auth tag not as expected");
4987 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4988 uint8_t op_mode, uint8_t verify)
4990 struct crypto_testsuite_params *ts_params = &testsuite_params;
4991 struct crypto_unittest_params *ut_params = &unittest_params;
4995 uint8_t *plaintext = NULL, *ciphertext = NULL;
4996 unsigned int plaintext_pad_len;
4997 unsigned int plaintext_len;
4998 unsigned int ciphertext_pad_len;
4999 unsigned int ciphertext_len;
5001 struct rte_cryptodev_info dev_info;
5003 /* Verify the capabilities */
5004 struct rte_cryptodev_sym_capability_idx cap_idx;
5005 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5006 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5007 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5009 return TEST_SKIPPED;
5010 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5011 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5012 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5014 return TEST_SKIPPED;
5016 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5017 return TEST_SKIPPED;
5019 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5021 uint64_t feat_flags = dev_info.feature_flags;
5023 if (op_mode == OUT_OF_PLACE) {
5024 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5025 printf("Device doesn't support digest encrypted.\n");
5026 return TEST_SKIPPED;
5028 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5029 return TEST_SKIPPED;
5032 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5033 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5034 printf("Device doesn't support RAW data-path APIs.\n");
5035 return TEST_SKIPPED;
5038 /* Create SNOW 3G session */
5039 retval = create_wireless_algo_auth_cipher_session(
5040 ts_params->valid_devs[0],
5041 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5042 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5043 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5044 : RTE_CRYPTO_AUTH_OP_GENERATE),
5045 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5046 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5047 tdata->key.data, tdata->key.len,
5048 tdata->auth_iv.len, tdata->digest.len,
5049 tdata->cipher_iv.len);
5053 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5054 if (op_mode == OUT_OF_PLACE)
5055 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5057 /* clear mbuf payload */
5058 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5059 rte_pktmbuf_tailroom(ut_params->ibuf));
5060 if (op_mode == OUT_OF_PLACE)
5061 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5062 rte_pktmbuf_tailroom(ut_params->obuf));
5064 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5065 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5066 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5067 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5070 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5071 ciphertext_pad_len);
5072 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5073 if (op_mode == OUT_OF_PLACE)
5074 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5075 debug_hexdump(stdout, "ciphertext:", ciphertext,
5078 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5080 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5081 if (op_mode == OUT_OF_PLACE)
5082 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5083 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5086 /* Create SNOW 3G operation */
5087 retval = create_wireless_algo_auth_cipher_operation(
5088 tdata->digest.data, tdata->digest.len,
5089 tdata->cipher_iv.data, tdata->cipher_iv.len,
5090 tdata->auth_iv.data, tdata->auth_iv.len,
5091 (tdata->digest.offset_bytes == 0 ?
5092 (verify ? ciphertext_pad_len : plaintext_pad_len)
5093 : tdata->digest.offset_bytes),
5094 tdata->validCipherLenInBits.len,
5095 tdata->cipher.offset_bits,
5096 tdata->validAuthLenInBits.len,
5097 tdata->auth.offset_bits,
5098 op_mode, 0, verify);
5103 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5104 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5105 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5107 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5110 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5112 ut_params->obuf = (op_mode == IN_PLACE ?
5113 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5116 if (ut_params->obuf)
5117 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5120 plaintext = ciphertext +
5121 (tdata->cipher.offset_bits >> 3);
5123 debug_hexdump(stdout, "plaintext:", plaintext,
5124 (tdata->plaintext.len >> 3) - tdata->digest.len);
5125 debug_hexdump(stdout, "plaintext expected:",
5126 tdata->plaintext.data,
5127 (tdata->plaintext.len >> 3) - tdata->digest.len);
5129 if (ut_params->obuf)
5130 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5133 ciphertext = plaintext;
5135 debug_hexdump(stdout, "ciphertext:", ciphertext,
5137 debug_hexdump(stdout, "ciphertext expected:",
5138 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5140 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5141 + (tdata->digest.offset_bytes == 0 ?
5142 plaintext_pad_len : tdata->digest.offset_bytes);
5144 debug_hexdump(stdout, "digest:", ut_params->digest,
5146 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5152 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5154 tdata->plaintext.data,
5155 (tdata->plaintext.len - tdata->cipher.offset_bits -
5156 (tdata->digest.len << 3)),
5157 tdata->cipher.offset_bits,
5158 "SNOW 3G Plaintext data not as expected");
5160 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5162 tdata->ciphertext.data,
5163 (tdata->validDataLenInBits.len -
5164 tdata->cipher.offset_bits),
5165 tdata->cipher.offset_bits,
5166 "SNOW 3G Ciphertext data not as expected");
5168 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5171 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5172 "SNOW 3G Generated auth tag not as expected");
5178 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5179 uint8_t op_mode, uint8_t verify)
5181 struct crypto_testsuite_params *ts_params = &testsuite_params;
5182 struct crypto_unittest_params *ut_params = &unittest_params;
5186 const uint8_t *plaintext = NULL;
5187 const uint8_t *ciphertext = NULL;
5188 const uint8_t *digest = NULL;
5189 unsigned int plaintext_pad_len;
5190 unsigned int plaintext_len;
5191 unsigned int ciphertext_pad_len;
5192 unsigned int ciphertext_len;
5193 uint8_t buffer[10000];
5194 uint8_t digest_buffer[10000];
5196 struct rte_cryptodev_info dev_info;
5198 /* Verify the capabilities */
5199 struct rte_cryptodev_sym_capability_idx cap_idx;
5200 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5201 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5202 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5204 return TEST_SKIPPED;
5205 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5206 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5207 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5209 return TEST_SKIPPED;
5211 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5212 return TEST_SKIPPED;
5214 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5216 uint64_t feat_flags = dev_info.feature_flags;
5218 if (op_mode == IN_PLACE) {
5219 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5220 printf("Device doesn't support in-place scatter-gather "
5221 "in both input and output mbufs.\n");
5222 return TEST_SKIPPED;
5224 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5225 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5226 printf("Device doesn't support RAW data-path APIs.\n");
5227 return TEST_SKIPPED;
5230 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5231 return TEST_SKIPPED;
5232 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5233 printf("Device doesn't support out-of-place scatter-gather "
5234 "in both input and output mbufs.\n");
5235 return TEST_SKIPPED;
5237 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5238 printf("Device doesn't support digest encrypted.\n");
5239 return TEST_SKIPPED;
5243 /* Create SNOW 3G session */
5244 retval = create_wireless_algo_auth_cipher_session(
5245 ts_params->valid_devs[0],
5246 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5247 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5248 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5249 : RTE_CRYPTO_AUTH_OP_GENERATE),
5250 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5251 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5252 tdata->key.data, tdata->key.len,
5253 tdata->auth_iv.len, tdata->digest.len,
5254 tdata->cipher_iv.len);
5259 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5260 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5261 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5262 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5264 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5265 plaintext_pad_len, 15, 0);
5266 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5267 "Failed to allocate input buffer in mempool");
5269 if (op_mode == OUT_OF_PLACE) {
5270 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5271 plaintext_pad_len, 15, 0);
5272 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5273 "Failed to allocate output buffer in mempool");
5277 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5278 tdata->ciphertext.data);
5279 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5280 ciphertext_len, buffer);
5281 debug_hexdump(stdout, "ciphertext:", ciphertext,
5284 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5285 tdata->plaintext.data);
5286 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5287 plaintext_len, buffer);
5288 debug_hexdump(stdout, "plaintext:", plaintext,
5291 memset(buffer, 0, sizeof(buffer));
5293 /* Create SNOW 3G operation */
5294 retval = create_wireless_algo_auth_cipher_operation(
5295 tdata->digest.data, tdata->digest.len,
5296 tdata->cipher_iv.data, tdata->cipher_iv.len,
5297 tdata->auth_iv.data, tdata->auth_iv.len,
5298 (tdata->digest.offset_bytes == 0 ?
5299 (verify ? ciphertext_pad_len : plaintext_pad_len)
5300 : tdata->digest.offset_bytes),
5301 tdata->validCipherLenInBits.len,
5302 tdata->cipher.offset_bits,
5303 tdata->validAuthLenInBits.len,
5304 tdata->auth.offset_bits,
5305 op_mode, 1, verify);
5310 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5311 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5312 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5314 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5317 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5319 ut_params->obuf = (op_mode == IN_PLACE ?
5320 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5323 if (ut_params->obuf)
5324 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5325 plaintext_len, buffer);
5327 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5328 plaintext_len, buffer);
5330 debug_hexdump(stdout, "plaintext:", plaintext,
5331 (tdata->plaintext.len >> 3) - tdata->digest.len);
5332 debug_hexdump(stdout, "plaintext expected:",
5333 tdata->plaintext.data,
5334 (tdata->plaintext.len >> 3) - tdata->digest.len);
5336 if (ut_params->obuf)
5337 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5338 ciphertext_len, buffer);
5340 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5341 ciphertext_len, buffer);
5343 debug_hexdump(stdout, "ciphertext:", ciphertext,
5345 debug_hexdump(stdout, "ciphertext expected:",
5346 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5348 if (ut_params->obuf)
5349 digest = rte_pktmbuf_read(ut_params->obuf,
5350 (tdata->digest.offset_bytes == 0 ?
5351 plaintext_pad_len : tdata->digest.offset_bytes),
5352 tdata->digest.len, digest_buffer);
5354 digest = rte_pktmbuf_read(ut_params->ibuf,
5355 (tdata->digest.offset_bytes == 0 ?
5356 plaintext_pad_len : tdata->digest.offset_bytes),
5357 tdata->digest.len, digest_buffer);
5359 debug_hexdump(stdout, "digest:", digest,
5361 debug_hexdump(stdout, "digest expected:",
5362 tdata->digest.data, tdata->digest.len);
5367 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5369 tdata->plaintext.data,
5370 (tdata->plaintext.len - tdata->cipher.offset_bits -
5371 (tdata->digest.len << 3)),
5372 tdata->cipher.offset_bits,
5373 "SNOW 3G Plaintext data not as expected");
5375 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5377 tdata->ciphertext.data,
5378 (tdata->validDataLenInBits.len -
5379 tdata->cipher.offset_bits),
5380 tdata->cipher.offset_bits,
5381 "SNOW 3G Ciphertext data not as expected");
5383 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5386 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5387 "SNOW 3G Generated auth tag not as expected");
5393 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5394 uint8_t op_mode, uint8_t verify)
5396 struct crypto_testsuite_params *ts_params = &testsuite_params;
5397 struct crypto_unittest_params *ut_params = &unittest_params;
5401 uint8_t *plaintext = NULL, *ciphertext = NULL;
5402 unsigned int plaintext_pad_len;
5403 unsigned int plaintext_len;
5404 unsigned int ciphertext_pad_len;
5405 unsigned int ciphertext_len;
5407 struct rte_cryptodev_info dev_info;
5409 /* Verify the capabilities */
5410 struct rte_cryptodev_sym_capability_idx cap_idx;
5411 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5412 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5413 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5415 return TEST_SKIPPED;
5416 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5417 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5418 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5420 return TEST_SKIPPED;
5422 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5424 uint64_t feat_flags = dev_info.feature_flags;
5426 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5427 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5428 printf("Device doesn't support RAW data-path APIs.\n");
5429 return TEST_SKIPPED;
5432 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5433 return TEST_SKIPPED;
5435 if (op_mode == OUT_OF_PLACE) {
5436 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5437 return TEST_SKIPPED;
5438 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5439 printf("Device doesn't support digest encrypted.\n");
5440 return TEST_SKIPPED;
5444 /* Create KASUMI session */
5445 retval = create_wireless_algo_auth_cipher_session(
5446 ts_params->valid_devs[0],
5447 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5448 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5449 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5450 : RTE_CRYPTO_AUTH_OP_GENERATE),
5451 RTE_CRYPTO_AUTH_KASUMI_F9,
5452 RTE_CRYPTO_CIPHER_KASUMI_F8,
5453 tdata->key.data, tdata->key.len,
5454 0, tdata->digest.len,
5455 tdata->cipher_iv.len);
5460 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5461 if (op_mode == OUT_OF_PLACE)
5462 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5464 /* clear mbuf payload */
5465 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5466 rte_pktmbuf_tailroom(ut_params->ibuf));
5467 if (op_mode == OUT_OF_PLACE)
5468 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5469 rte_pktmbuf_tailroom(ut_params->obuf));
5471 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5472 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5473 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5474 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5477 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5478 ciphertext_pad_len);
5479 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5480 if (op_mode == OUT_OF_PLACE)
5481 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5482 debug_hexdump(stdout, "ciphertext:", ciphertext,
5485 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5487 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5488 if (op_mode == OUT_OF_PLACE)
5489 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5490 debug_hexdump(stdout, "plaintext:", plaintext,
5494 /* Create KASUMI operation */
5495 retval = create_wireless_algo_auth_cipher_operation(
5496 tdata->digest.data, tdata->digest.len,
5497 tdata->cipher_iv.data, tdata->cipher_iv.len,
5499 (tdata->digest.offset_bytes == 0 ?
5500 (verify ? ciphertext_pad_len : plaintext_pad_len)
5501 : tdata->digest.offset_bytes),
5502 tdata->validCipherLenInBits.len,
5503 tdata->validCipherOffsetInBits.len,
5504 tdata->validAuthLenInBits.len,
5506 op_mode, 0, verify);
5511 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5512 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5513 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5515 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5518 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5520 ut_params->obuf = (op_mode == IN_PLACE ?
5521 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5525 if (ut_params->obuf)
5526 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5529 plaintext = ciphertext;
5531 debug_hexdump(stdout, "plaintext:", plaintext,
5532 (tdata->plaintext.len >> 3) - tdata->digest.len);
5533 debug_hexdump(stdout, "plaintext expected:",
5534 tdata->plaintext.data,
5535 (tdata->plaintext.len >> 3) - tdata->digest.len);
5537 if (ut_params->obuf)
5538 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5541 ciphertext = plaintext;
5543 debug_hexdump(stdout, "ciphertext:", ciphertext,
5545 debug_hexdump(stdout, "ciphertext expected:",
5546 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5548 ut_params->digest = rte_pktmbuf_mtod(
5549 ut_params->obuf, uint8_t *) +
5550 (tdata->digest.offset_bytes == 0 ?
5551 plaintext_pad_len : tdata->digest.offset_bytes);
5553 debug_hexdump(stdout, "digest:", ut_params->digest,
5555 debug_hexdump(stdout, "digest expected:",
5556 tdata->digest.data, tdata->digest.len);
5561 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5563 tdata->plaintext.data,
5564 tdata->plaintext.len >> 3,
5565 "KASUMI Plaintext data not as expected");
5567 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5569 tdata->ciphertext.data,
5570 tdata->ciphertext.len >> 3,
5571 "KASUMI Ciphertext data not as expected");
5573 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5576 DIGEST_BYTE_LENGTH_KASUMI_F9,
5577 "KASUMI Generated auth tag not as expected");
5583 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5584 uint8_t op_mode, uint8_t verify)
5586 struct crypto_testsuite_params *ts_params = &testsuite_params;
5587 struct crypto_unittest_params *ut_params = &unittest_params;
5591 const uint8_t *plaintext = NULL;
5592 const uint8_t *ciphertext = NULL;
5593 const uint8_t *digest = NULL;
5594 unsigned int plaintext_pad_len;
5595 unsigned int plaintext_len;
5596 unsigned int ciphertext_pad_len;
5597 unsigned int ciphertext_len;
5598 uint8_t buffer[10000];
5599 uint8_t digest_buffer[10000];
5601 struct rte_cryptodev_info dev_info;
5603 /* Verify the capabilities */
5604 struct rte_cryptodev_sym_capability_idx cap_idx;
5605 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5606 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5607 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5609 return TEST_SKIPPED;
5610 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5611 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5612 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5614 return TEST_SKIPPED;
5616 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5617 return TEST_SKIPPED;
5619 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5621 uint64_t feat_flags = dev_info.feature_flags;
5623 if (op_mode == IN_PLACE) {
5624 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5625 printf("Device doesn't support in-place scatter-gather "
5626 "in both input and output mbufs.\n");
5627 return TEST_SKIPPED;
5629 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5630 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5631 printf("Device doesn't support RAW data-path APIs.\n");
5632 return TEST_SKIPPED;
5635 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5636 return TEST_SKIPPED;
5637 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5638 printf("Device doesn't support out-of-place scatter-gather "
5639 "in both input and output mbufs.\n");
5640 return TEST_SKIPPED;
5642 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5643 printf("Device doesn't support digest encrypted.\n");
5644 return TEST_SKIPPED;
5648 /* Create KASUMI session */
5649 retval = create_wireless_algo_auth_cipher_session(
5650 ts_params->valid_devs[0],
5651 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5652 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5653 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5654 : RTE_CRYPTO_AUTH_OP_GENERATE),
5655 RTE_CRYPTO_AUTH_KASUMI_F9,
5656 RTE_CRYPTO_CIPHER_KASUMI_F8,
5657 tdata->key.data, tdata->key.len,
5658 0, tdata->digest.len,
5659 tdata->cipher_iv.len);
5664 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5665 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5666 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5667 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5669 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5670 plaintext_pad_len, 15, 0);
5671 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5672 "Failed to allocate input buffer in mempool");
5674 if (op_mode == OUT_OF_PLACE) {
5675 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5676 plaintext_pad_len, 15, 0);
5677 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5678 "Failed to allocate output buffer in mempool");
5682 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5683 tdata->ciphertext.data);
5684 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5685 ciphertext_len, buffer);
5686 debug_hexdump(stdout, "ciphertext:", ciphertext,
5689 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5690 tdata->plaintext.data);
5691 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5692 plaintext_len, buffer);
5693 debug_hexdump(stdout, "plaintext:", plaintext,
5696 memset(buffer, 0, sizeof(buffer));
5698 /* Create KASUMI operation */
5699 retval = create_wireless_algo_auth_cipher_operation(
5700 tdata->digest.data, tdata->digest.len,
5701 tdata->cipher_iv.data, tdata->cipher_iv.len,
5703 (tdata->digest.offset_bytes == 0 ?
5704 (verify ? ciphertext_pad_len : plaintext_pad_len)
5705 : tdata->digest.offset_bytes),
5706 tdata->validCipherLenInBits.len,
5707 tdata->validCipherOffsetInBits.len,
5708 tdata->validAuthLenInBits.len,
5710 op_mode, 1, verify);
5715 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5716 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5717 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5719 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5722 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5724 ut_params->obuf = (op_mode == IN_PLACE ?
5725 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5728 if (ut_params->obuf)
5729 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5730 plaintext_len, buffer);
5732 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5733 plaintext_len, buffer);
5735 debug_hexdump(stdout, "plaintext:", plaintext,
5736 (tdata->plaintext.len >> 3) - tdata->digest.len);
5737 debug_hexdump(stdout, "plaintext expected:",
5738 tdata->plaintext.data,
5739 (tdata->plaintext.len >> 3) - tdata->digest.len);
5741 if (ut_params->obuf)
5742 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5743 ciphertext_len, buffer);
5745 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5746 ciphertext_len, buffer);
5748 debug_hexdump(stdout, "ciphertext:", ciphertext,
5750 debug_hexdump(stdout, "ciphertext expected:",
5751 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5753 if (ut_params->obuf)
5754 digest = rte_pktmbuf_read(ut_params->obuf,
5755 (tdata->digest.offset_bytes == 0 ?
5756 plaintext_pad_len : tdata->digest.offset_bytes),
5757 tdata->digest.len, digest_buffer);
5759 digest = rte_pktmbuf_read(ut_params->ibuf,
5760 (tdata->digest.offset_bytes == 0 ?
5761 plaintext_pad_len : tdata->digest.offset_bytes),
5762 tdata->digest.len, digest_buffer);
5764 debug_hexdump(stdout, "digest:", digest,
5766 debug_hexdump(stdout, "digest expected:",
5767 tdata->digest.data, tdata->digest.len);
5772 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5774 tdata->plaintext.data,
5775 tdata->plaintext.len >> 3,
5776 "KASUMI Plaintext data not as expected");
5778 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5780 tdata->ciphertext.data,
5781 tdata->validDataLenInBits.len,
5782 "KASUMI Ciphertext data not as expected");
5784 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5787 DIGEST_BYTE_LENGTH_KASUMI_F9,
5788 "KASUMI Generated auth tag not as expected");
5794 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5796 struct crypto_testsuite_params *ts_params = &testsuite_params;
5797 struct crypto_unittest_params *ut_params = &unittest_params;
5801 uint8_t *plaintext, *ciphertext;
5802 unsigned plaintext_pad_len;
5803 unsigned plaintext_len;
5804 struct rte_cryptodev_info dev_info;
5806 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5807 uint64_t feat_flags = dev_info.feature_flags;
5809 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5810 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5811 printf("Device doesn't support RAW data-path APIs.\n");
5812 return TEST_SKIPPED;
5815 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5816 return TEST_SKIPPED;
5818 /* Verify the capabilities */
5819 struct rte_cryptodev_sym_capability_idx cap_idx;
5820 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5821 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5822 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5824 return TEST_SKIPPED;
5825 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5826 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5827 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5829 return TEST_SKIPPED;
5831 /* Create KASUMI session */
5832 retval = create_wireless_algo_cipher_auth_session(
5833 ts_params->valid_devs[0],
5834 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5835 RTE_CRYPTO_AUTH_OP_GENERATE,
5836 RTE_CRYPTO_AUTH_KASUMI_F9,
5837 RTE_CRYPTO_CIPHER_KASUMI_F8,
5838 tdata->key.data, tdata->key.len,
5839 0, tdata->digest.len,
5840 tdata->cipher_iv.len);
5844 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5846 /* clear mbuf payload */
5847 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5848 rte_pktmbuf_tailroom(ut_params->ibuf));
5850 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5851 /* Append data which is padded to a multiple of */
5852 /* the algorithms block size */
5853 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5854 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5856 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5858 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5860 /* Create KASUMI operation */
5861 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5862 tdata->digest.len, NULL, 0,
5863 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5864 tdata->cipher_iv.data, tdata->cipher_iv.len,
5865 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5866 tdata->validCipherOffsetInBits.len,
5867 tdata->validAuthLenInBits.len,
5873 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5874 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5875 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5877 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5879 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5881 if (ut_params->op->sym->m_dst)
5882 ut_params->obuf = ut_params->op->sym->m_dst;
5884 ut_params->obuf = ut_params->op->sym->m_src;
5886 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5887 tdata->validCipherOffsetInBits.len >> 3);
5889 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5890 + plaintext_pad_len;
5892 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5893 (tdata->validCipherOffsetInBits.len >> 3);
5895 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5897 reference_ciphertext,
5898 tdata->validCipherLenInBits.len,
5899 "KASUMI Ciphertext data not as expected");
5902 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5905 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5906 "KASUMI Generated auth tag not as expected");
5911 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
5912 const enum rte_crypto_cipher_algorithm cipher_algo,
5913 const uint16_t key_size, const uint16_t iv_size)
5915 struct rte_cryptodev_sym_capability_idx cap_idx;
5916 const struct rte_cryptodev_symmetric_capability *cap;
5918 /* Check if device supports the algorithm */
5919 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5920 cap_idx.algo.cipher = cipher_algo;
5922 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5928 /* Check if device supports key size and IV size */
5929 if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
5938 check_auth_capability(const struct crypto_testsuite_params *ts_params,
5939 const enum rte_crypto_auth_algorithm auth_algo,
5940 const uint16_t key_size, const uint16_t iv_size,
5941 const uint16_t tag_size)
5943 struct rte_cryptodev_sym_capability_idx cap_idx;
5944 const struct rte_cryptodev_symmetric_capability *cap;
5946 /* Check if device supports the algorithm */
5947 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5948 cap_idx.algo.auth = auth_algo;
5950 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5956 /* Check if device supports key size and IV size */
5957 if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
5958 tag_size, iv_size) < 0) {
5966 test_zuc_encryption(const struct wireless_test_data *tdata)
5968 struct crypto_testsuite_params *ts_params = &testsuite_params;
5969 struct crypto_unittest_params *ut_params = &unittest_params;
5972 uint8_t *plaintext, *ciphertext;
5973 unsigned plaintext_pad_len;
5974 unsigned plaintext_len;
5975 struct rte_cryptodev_info dev_info;
5977 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5978 uint64_t feat_flags = dev_info.feature_flags;
5980 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5981 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5982 printf("Device doesn't support RAW data-path APIs.\n");
5983 return TEST_SKIPPED;
5986 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5987 return TEST_SKIPPED;
5989 /* Check if device supports ZUC EEA3 */
5990 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5991 tdata->key.len, tdata->cipher_iv.len) < 0)
5992 return TEST_SKIPPED;
5994 /* Create ZUC session */
5995 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5996 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5997 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5998 tdata->key.data, tdata->key.len,
5999 tdata->cipher_iv.len);
6003 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6005 /* Clear mbuf payload */
6006 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6007 rte_pktmbuf_tailroom(ut_params->ibuf));
6009 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6010 /* Append data which is padded to a multiple */
6011 /* of the algorithms block size */
6012 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6013 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6015 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6017 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6019 /* Create ZUC operation */
6020 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6021 tdata->cipher_iv.len,
6022 tdata->plaintext.len,
6027 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6028 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6029 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6031 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6033 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6035 ut_params->obuf = ut_params->op->sym->m_dst;
6036 if (ut_params->obuf)
6037 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6039 ciphertext = plaintext;
6041 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6044 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6046 tdata->ciphertext.data,
6047 tdata->validCipherLenInBits.len,
6048 "ZUC Ciphertext data not as expected");
6053 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
6055 struct crypto_testsuite_params *ts_params = &testsuite_params;
6056 struct crypto_unittest_params *ut_params = &unittest_params;
6060 unsigned int plaintext_pad_len;
6061 unsigned int plaintext_len;
6062 const uint8_t *ciphertext;
6063 uint8_t ciphertext_buffer[2048];
6064 struct rte_cryptodev_info dev_info;
6066 /* Check if device supports ZUC EEA3 */
6067 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6068 tdata->key.len, tdata->cipher_iv.len) < 0)
6069 return TEST_SKIPPED;
6071 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6072 return TEST_SKIPPED;
6074 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6076 uint64_t feat_flags = dev_info.feature_flags;
6078 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6079 printf("Device doesn't support in-place scatter-gather. "
6081 return TEST_SKIPPED;
6084 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6085 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6086 printf("Device doesn't support RAW data-path APIs.\n");
6087 return TEST_SKIPPED;
6090 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6092 /* Append data which is padded to a multiple */
6093 /* of the algorithms block size */
6094 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6096 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6097 plaintext_pad_len, 10, 0);
6099 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6100 tdata->plaintext.data);
6102 /* Create ZUC session */
6103 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6104 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6105 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6106 tdata->key.data, tdata->key.len,
6107 tdata->cipher_iv.len);
6111 /* Clear mbuf payload */
6113 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6115 /* Create ZUC operation */
6116 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6117 tdata->cipher_iv.len, tdata->plaintext.len,
6122 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6123 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6124 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6126 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6128 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6130 ut_params->obuf = ut_params->op->sym->m_dst;
6131 if (ut_params->obuf)
6132 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6133 0, plaintext_len, ciphertext_buffer);
6135 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6136 0, plaintext_len, ciphertext_buffer);
6139 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6142 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6144 tdata->ciphertext.data,
6145 tdata->validCipherLenInBits.len,
6146 "ZUC Ciphertext data not as expected");
6152 test_zuc_authentication(const struct wireless_test_data *tdata)
6154 struct crypto_testsuite_params *ts_params = &testsuite_params;
6155 struct crypto_unittest_params *ut_params = &unittest_params;
6158 unsigned plaintext_pad_len;
6159 unsigned plaintext_len;
6162 struct rte_cryptodev_info dev_info;
6164 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6165 uint64_t feat_flags = dev_info.feature_flags;
6167 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6168 (tdata->validAuthLenInBits.len % 8 != 0)) {
6169 printf("Device doesn't support NON-Byte Aligned Data.\n");
6170 return TEST_SKIPPED;
6173 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6174 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6175 printf("Device doesn't support RAW data-path APIs.\n");
6176 return TEST_SKIPPED;
6179 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6180 return TEST_SKIPPED;
6182 /* Check if device supports ZUC EIA3 */
6183 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6184 tdata->key.len, tdata->auth_iv.len,
6185 tdata->digest.len) < 0)
6186 return TEST_SKIPPED;
6188 /* Create ZUC session */
6189 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6190 tdata->key.data, tdata->key.len,
6191 tdata->auth_iv.len, tdata->digest.len,
6192 RTE_CRYPTO_AUTH_OP_GENERATE,
6193 RTE_CRYPTO_AUTH_ZUC_EIA3);
6197 /* alloc mbuf and set payload */
6198 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6200 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6201 rte_pktmbuf_tailroom(ut_params->ibuf));
6203 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6204 /* Append data which is padded to a multiple of */
6205 /* the algorithms block size */
6206 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6207 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6209 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6211 /* Create ZUC operation */
6212 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6213 tdata->auth_iv.data, tdata->auth_iv.len,
6214 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6215 tdata->validAuthLenInBits.len,
6220 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6221 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6222 ut_params->op, 0, 1, 1, 0);
6224 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6226 ut_params->obuf = ut_params->op->sym->m_src;
6227 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6228 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6229 + plaintext_pad_len;
6232 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6236 "ZUC Generated auth tag not as expected");
6242 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6243 uint8_t op_mode, uint8_t verify)
6245 struct crypto_testsuite_params *ts_params = &testsuite_params;
6246 struct crypto_unittest_params *ut_params = &unittest_params;
6250 uint8_t *plaintext = NULL, *ciphertext = NULL;
6251 unsigned int plaintext_pad_len;
6252 unsigned int plaintext_len;
6253 unsigned int ciphertext_pad_len;
6254 unsigned int ciphertext_len;
6256 struct rte_cryptodev_info dev_info;
6258 /* Check if device supports ZUC EEA3 */
6259 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6260 tdata->key.len, tdata->cipher_iv.len) < 0)
6261 return TEST_SKIPPED;
6263 /* Check if device supports ZUC EIA3 */
6264 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6265 tdata->key.len, tdata->auth_iv.len,
6266 tdata->digest.len) < 0)
6267 return TEST_SKIPPED;
6269 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6271 uint64_t feat_flags = dev_info.feature_flags;
6273 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6274 printf("Device doesn't support digest encrypted.\n");
6275 return TEST_SKIPPED;
6277 if (op_mode == IN_PLACE) {
6278 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6279 printf("Device doesn't support in-place scatter-gather "
6280 "in both input and output mbufs.\n");
6281 return TEST_SKIPPED;
6284 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6285 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6286 printf("Device doesn't support RAW data-path APIs.\n");
6287 return TEST_SKIPPED;
6290 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6291 return TEST_SKIPPED;
6292 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6293 printf("Device doesn't support out-of-place scatter-gather "
6294 "in both input and output mbufs.\n");
6295 return TEST_SKIPPED;
6299 /* Create ZUC session */
6300 retval = create_wireless_algo_auth_cipher_session(
6301 ts_params->valid_devs[0],
6302 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6303 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6304 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6305 : RTE_CRYPTO_AUTH_OP_GENERATE),
6306 RTE_CRYPTO_AUTH_ZUC_EIA3,
6307 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6308 tdata->key.data, tdata->key.len,
6309 tdata->auth_iv.len, tdata->digest.len,
6310 tdata->cipher_iv.len);
6315 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6316 if (op_mode == OUT_OF_PLACE)
6317 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6319 /* clear mbuf payload */
6320 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6321 rte_pktmbuf_tailroom(ut_params->ibuf));
6322 if (op_mode == OUT_OF_PLACE)
6323 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6324 rte_pktmbuf_tailroom(ut_params->obuf));
6326 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6327 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6328 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6329 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6332 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6333 ciphertext_pad_len);
6334 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6335 debug_hexdump(stdout, "ciphertext:", ciphertext,
6338 /* make sure enough space to cover partial digest verify case */
6339 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6340 ciphertext_pad_len);
6341 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6342 debug_hexdump(stdout, "plaintext:", plaintext,
6346 if (op_mode == OUT_OF_PLACE)
6347 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6349 /* Create ZUC operation */
6350 retval = create_wireless_algo_auth_cipher_operation(
6351 tdata->digest.data, tdata->digest.len,
6352 tdata->cipher_iv.data, tdata->cipher_iv.len,
6353 tdata->auth_iv.data, tdata->auth_iv.len,
6354 (tdata->digest.offset_bytes == 0 ?
6355 (verify ? ciphertext_pad_len : plaintext_pad_len)
6356 : tdata->digest.offset_bytes),
6357 tdata->validCipherLenInBits.len,
6358 tdata->validCipherOffsetInBits.len,
6359 tdata->validAuthLenInBits.len,
6361 op_mode, 0, verify);
6366 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6367 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6368 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6370 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6373 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6375 ut_params->obuf = (op_mode == IN_PLACE ?
6376 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6380 if (ut_params->obuf)
6381 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6384 plaintext = ciphertext;
6386 debug_hexdump(stdout, "plaintext:", plaintext,
6387 (tdata->plaintext.len >> 3) - tdata->digest.len);
6388 debug_hexdump(stdout, "plaintext expected:",
6389 tdata->plaintext.data,
6390 (tdata->plaintext.len >> 3) - tdata->digest.len);
6392 if (ut_params->obuf)
6393 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6396 ciphertext = plaintext;
6398 debug_hexdump(stdout, "ciphertext:", ciphertext,
6400 debug_hexdump(stdout, "ciphertext expected:",
6401 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6403 ut_params->digest = rte_pktmbuf_mtod(
6404 ut_params->obuf, uint8_t *) +
6405 (tdata->digest.offset_bytes == 0 ?
6406 plaintext_pad_len : tdata->digest.offset_bytes);
6408 debug_hexdump(stdout, "digest:", ut_params->digest,
6410 debug_hexdump(stdout, "digest expected:",
6411 tdata->digest.data, tdata->digest.len);
6416 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6418 tdata->plaintext.data,
6419 tdata->plaintext.len >> 3,
6420 "ZUC Plaintext data not as expected");
6422 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6424 tdata->ciphertext.data,
6425 tdata->ciphertext.len >> 3,
6426 "ZUC Ciphertext data not as expected");
6428 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6431 DIGEST_BYTE_LENGTH_KASUMI_F9,
6432 "ZUC Generated auth tag not as expected");
6438 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6439 uint8_t op_mode, uint8_t verify)
6441 struct crypto_testsuite_params *ts_params = &testsuite_params;
6442 struct crypto_unittest_params *ut_params = &unittest_params;
6446 const uint8_t *plaintext = NULL;
6447 const uint8_t *ciphertext = NULL;
6448 const uint8_t *digest = NULL;
6449 unsigned int plaintext_pad_len;
6450 unsigned int plaintext_len;
6451 unsigned int ciphertext_pad_len;
6452 unsigned int ciphertext_len;
6453 uint8_t buffer[10000];
6454 uint8_t digest_buffer[10000];
6456 struct rte_cryptodev_info dev_info;
6458 /* Check if device supports ZUC EEA3 */
6459 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6460 tdata->key.len, tdata->cipher_iv.len) < 0)
6461 return TEST_SKIPPED;
6463 /* Check if device supports ZUC EIA3 */
6464 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6465 tdata->key.len, tdata->auth_iv.len,
6466 tdata->digest.len) < 0)
6467 return TEST_SKIPPED;
6469 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6471 uint64_t feat_flags = dev_info.feature_flags;
6473 if (op_mode == IN_PLACE) {
6474 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6475 printf("Device doesn't support in-place scatter-gather "
6476 "in both input and output mbufs.\n");
6477 return TEST_SKIPPED;
6480 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6481 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6482 printf("Device doesn't support RAW data-path APIs.\n");
6483 return TEST_SKIPPED;
6486 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6487 return TEST_SKIPPED;
6488 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6489 printf("Device doesn't support out-of-place scatter-gather "
6490 "in both input and output mbufs.\n");
6491 return TEST_SKIPPED;
6493 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6494 printf("Device doesn't support digest encrypted.\n");
6495 return TEST_SKIPPED;
6499 /* Create ZUC session */
6500 retval = create_wireless_algo_auth_cipher_session(
6501 ts_params->valid_devs[0],
6502 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6503 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6504 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6505 : RTE_CRYPTO_AUTH_OP_GENERATE),
6506 RTE_CRYPTO_AUTH_ZUC_EIA3,
6507 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6508 tdata->key.data, tdata->key.len,
6509 tdata->auth_iv.len, tdata->digest.len,
6510 tdata->cipher_iv.len);
6515 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6516 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6517 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6518 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6520 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6521 plaintext_pad_len, 15, 0);
6522 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6523 "Failed to allocate input buffer in mempool");
6525 if (op_mode == OUT_OF_PLACE) {
6526 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6527 plaintext_pad_len, 15, 0);
6528 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6529 "Failed to allocate output buffer in mempool");
6533 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6534 tdata->ciphertext.data);
6535 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6536 ciphertext_len, buffer);
6537 debug_hexdump(stdout, "ciphertext:", ciphertext,
6540 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6541 tdata->plaintext.data);
6542 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6543 plaintext_len, buffer);
6544 debug_hexdump(stdout, "plaintext:", plaintext,
6547 memset(buffer, 0, sizeof(buffer));
6549 /* Create ZUC operation */
6550 retval = create_wireless_algo_auth_cipher_operation(
6551 tdata->digest.data, tdata->digest.len,
6552 tdata->cipher_iv.data, tdata->cipher_iv.len,
6554 (tdata->digest.offset_bytes == 0 ?
6555 (verify ? ciphertext_pad_len : plaintext_pad_len)
6556 : tdata->digest.offset_bytes),
6557 tdata->validCipherLenInBits.len,
6558 tdata->validCipherOffsetInBits.len,
6559 tdata->validAuthLenInBits.len,
6561 op_mode, 1, verify);
6566 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6567 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6568 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6570 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6573 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6575 ut_params->obuf = (op_mode == IN_PLACE ?
6576 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6579 if (ut_params->obuf)
6580 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6581 plaintext_len, buffer);
6583 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6584 plaintext_len, buffer);
6586 debug_hexdump(stdout, "plaintext:", plaintext,
6587 (tdata->plaintext.len >> 3) - tdata->digest.len);
6588 debug_hexdump(stdout, "plaintext expected:",
6589 tdata->plaintext.data,
6590 (tdata->plaintext.len >> 3) - tdata->digest.len);
6592 if (ut_params->obuf)
6593 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6594 ciphertext_len, buffer);
6596 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6597 ciphertext_len, buffer);
6599 debug_hexdump(stdout, "ciphertext:", ciphertext,
6601 debug_hexdump(stdout, "ciphertext expected:",
6602 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6604 if (ut_params->obuf)
6605 digest = rte_pktmbuf_read(ut_params->obuf,
6606 (tdata->digest.offset_bytes == 0 ?
6607 plaintext_pad_len : tdata->digest.offset_bytes),
6608 tdata->digest.len, digest_buffer);
6610 digest = rte_pktmbuf_read(ut_params->ibuf,
6611 (tdata->digest.offset_bytes == 0 ?
6612 plaintext_pad_len : tdata->digest.offset_bytes),
6613 tdata->digest.len, digest_buffer);
6615 debug_hexdump(stdout, "digest:", digest,
6617 debug_hexdump(stdout, "digest expected:",
6618 tdata->digest.data, tdata->digest.len);
6623 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6625 tdata->plaintext.data,
6626 tdata->plaintext.len >> 3,
6627 "ZUC Plaintext data not as expected");
6629 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6631 tdata->ciphertext.data,
6632 tdata->validDataLenInBits.len,
6633 "ZUC Ciphertext data not as expected");
6635 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6638 DIGEST_BYTE_LENGTH_KASUMI_F9,
6639 "ZUC Generated auth tag not as expected");
6645 test_kasumi_encryption_test_case_1(void)
6647 return test_kasumi_encryption(&kasumi_test_case_1);
6651 test_kasumi_encryption_test_case_1_sgl(void)
6653 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6657 test_kasumi_encryption_test_case_1_oop(void)
6659 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6663 test_kasumi_encryption_test_case_1_oop_sgl(void)
6665 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6669 test_kasumi_encryption_test_case_2(void)
6671 return test_kasumi_encryption(&kasumi_test_case_2);
6675 test_kasumi_encryption_test_case_3(void)
6677 return test_kasumi_encryption(&kasumi_test_case_3);
6681 test_kasumi_encryption_test_case_4(void)
6683 return test_kasumi_encryption(&kasumi_test_case_4);
6687 test_kasumi_encryption_test_case_5(void)
6689 return test_kasumi_encryption(&kasumi_test_case_5);
6693 test_kasumi_decryption_test_case_1(void)
6695 return test_kasumi_decryption(&kasumi_test_case_1);
6699 test_kasumi_decryption_test_case_1_oop(void)
6701 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6705 test_kasumi_decryption_test_case_2(void)
6707 return test_kasumi_decryption(&kasumi_test_case_2);
6711 test_kasumi_decryption_test_case_3(void)
6713 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6714 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6715 return TEST_SKIPPED;
6716 return test_kasumi_decryption(&kasumi_test_case_3);
6720 test_kasumi_decryption_test_case_4(void)
6722 return test_kasumi_decryption(&kasumi_test_case_4);
6726 test_kasumi_decryption_test_case_5(void)
6728 return test_kasumi_decryption(&kasumi_test_case_5);
6731 test_snow3g_encryption_test_case_1(void)
6733 return test_snow3g_encryption(&snow3g_test_case_1);
6737 test_snow3g_encryption_test_case_1_oop(void)
6739 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6743 test_snow3g_encryption_test_case_1_oop_sgl(void)
6745 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6750 test_snow3g_encryption_test_case_1_offset_oop(void)
6752 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6756 test_snow3g_encryption_test_case_2(void)
6758 return test_snow3g_encryption(&snow3g_test_case_2);
6762 test_snow3g_encryption_test_case_3(void)
6764 return test_snow3g_encryption(&snow3g_test_case_3);
6768 test_snow3g_encryption_test_case_4(void)
6770 return test_snow3g_encryption(&snow3g_test_case_4);
6774 test_snow3g_encryption_test_case_5(void)
6776 return test_snow3g_encryption(&snow3g_test_case_5);
6780 test_snow3g_decryption_test_case_1(void)
6782 return test_snow3g_decryption(&snow3g_test_case_1);
6786 test_snow3g_decryption_test_case_1_oop(void)
6788 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6792 test_snow3g_decryption_test_case_2(void)
6794 return test_snow3g_decryption(&snow3g_test_case_2);
6798 test_snow3g_decryption_test_case_3(void)
6800 return test_snow3g_decryption(&snow3g_test_case_3);
6804 test_snow3g_decryption_test_case_4(void)
6806 return test_snow3g_decryption(&snow3g_test_case_4);
6810 test_snow3g_decryption_test_case_5(void)
6812 return test_snow3g_decryption(&snow3g_test_case_5);
6816 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6817 * Pattern digest from snow3g_test_data must be allocated as
6818 * 4 last bytes in plaintext.
6821 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6822 struct snow3g_hash_test_data *output)
6824 if ((pattern != NULL) && (output != NULL)) {
6825 output->key.len = pattern->key.len;
6827 memcpy(output->key.data,
6828 pattern->key.data, pattern->key.len);
6830 output->auth_iv.len = pattern->auth_iv.len;
6832 memcpy(output->auth_iv.data,
6833 pattern->auth_iv.data, pattern->auth_iv.len);
6835 output->plaintext.len = pattern->plaintext.len;
6837 memcpy(output->plaintext.data,
6838 pattern->plaintext.data, pattern->plaintext.len >> 3);
6840 output->digest.len = pattern->digest.len;
6842 memcpy(output->digest.data,
6843 &pattern->plaintext.data[pattern->digest.offset_bytes],
6844 pattern->digest.len);
6846 output->validAuthLenInBits.len =
6847 pattern->validAuthLenInBits.len;
6852 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6855 test_snow3g_decryption_with_digest_test_case_1(void)
6857 struct snow3g_hash_test_data snow3g_hash_data;
6858 struct rte_cryptodev_info dev_info;
6859 struct crypto_testsuite_params *ts_params = &testsuite_params;
6861 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6862 uint64_t feat_flags = dev_info.feature_flags;
6864 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6865 printf("Device doesn't support encrypted digest operations.\n");
6866 return TEST_SKIPPED;
6870 * Function prepare data for hash veryfication test case.
6871 * Digest is allocated in 4 last bytes in plaintext, pattern.
6873 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6875 return test_snow3g_decryption(&snow3g_test_case_7) &
6876 test_snow3g_authentication_verify(&snow3g_hash_data);
6880 test_snow3g_cipher_auth_test_case_1(void)
6882 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6886 test_snow3g_auth_cipher_test_case_1(void)
6888 return test_snow3g_auth_cipher(
6889 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6893 test_snow3g_auth_cipher_test_case_2(void)
6895 return test_snow3g_auth_cipher(
6896 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6900 test_snow3g_auth_cipher_test_case_2_oop(void)
6902 return test_snow3g_auth_cipher(
6903 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6907 test_snow3g_auth_cipher_part_digest_enc(void)
6909 return test_snow3g_auth_cipher(
6910 &snow3g_auth_cipher_partial_digest_encryption,
6915 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6917 return test_snow3g_auth_cipher(
6918 &snow3g_auth_cipher_partial_digest_encryption,
6923 test_snow3g_auth_cipher_test_case_3_sgl(void)
6925 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6926 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6927 return TEST_SKIPPED;
6928 return test_snow3g_auth_cipher_sgl(
6929 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6933 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6935 return test_snow3g_auth_cipher_sgl(
6936 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6940 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6942 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6943 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6944 return TEST_SKIPPED;
6945 return test_snow3g_auth_cipher_sgl(
6946 &snow3g_auth_cipher_partial_digest_encryption,
6951 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6953 return test_snow3g_auth_cipher_sgl(
6954 &snow3g_auth_cipher_partial_digest_encryption,
6959 test_snow3g_auth_cipher_verify_test_case_1(void)
6961 return test_snow3g_auth_cipher(
6962 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6966 test_snow3g_auth_cipher_verify_test_case_2(void)
6968 return test_snow3g_auth_cipher(
6969 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6973 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6975 return test_snow3g_auth_cipher(
6976 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6980 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6982 return test_snow3g_auth_cipher(
6983 &snow3g_auth_cipher_partial_digest_encryption,
6988 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6990 return test_snow3g_auth_cipher(
6991 &snow3g_auth_cipher_partial_digest_encryption,
6996 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6998 return test_snow3g_auth_cipher_sgl(
6999 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7003 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7005 return test_snow3g_auth_cipher_sgl(
7006 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7010 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7012 return test_snow3g_auth_cipher_sgl(
7013 &snow3g_auth_cipher_partial_digest_encryption,
7018 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7020 return test_snow3g_auth_cipher_sgl(
7021 &snow3g_auth_cipher_partial_digest_encryption,
7026 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7028 return test_snow3g_auth_cipher(
7029 &snow3g_test_case_7, IN_PLACE, 0);
7033 test_kasumi_auth_cipher_test_case_1(void)
7035 return test_kasumi_auth_cipher(
7036 &kasumi_test_case_3, IN_PLACE, 0);
7040 test_kasumi_auth_cipher_test_case_2(void)
7042 return test_kasumi_auth_cipher(
7043 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7047 test_kasumi_auth_cipher_test_case_2_oop(void)
7049 return test_kasumi_auth_cipher(
7050 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7054 test_kasumi_auth_cipher_test_case_2_sgl(void)
7056 return test_kasumi_auth_cipher_sgl(
7057 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7061 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7063 return test_kasumi_auth_cipher_sgl(
7064 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7068 test_kasumi_auth_cipher_verify_test_case_1(void)
7070 return test_kasumi_auth_cipher(
7071 &kasumi_test_case_3, IN_PLACE, 1);
7075 test_kasumi_auth_cipher_verify_test_case_2(void)
7077 return test_kasumi_auth_cipher(
7078 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7082 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7084 return test_kasumi_auth_cipher(
7085 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7089 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7091 return test_kasumi_auth_cipher_sgl(
7092 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7096 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7098 return test_kasumi_auth_cipher_sgl(
7099 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7103 test_kasumi_cipher_auth_test_case_1(void)
7105 return test_kasumi_cipher_auth(&kasumi_test_case_6);
7109 test_zuc_encryption_test_case_1(void)
7111 return test_zuc_encryption(&zuc_test_case_cipher_193b);
7115 test_zuc_encryption_test_case_2(void)
7117 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7121 test_zuc_encryption_test_case_3(void)
7123 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7127 test_zuc_encryption_test_case_4(void)
7129 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7133 test_zuc_encryption_test_case_5(void)
7135 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7139 test_zuc_encryption_test_case_6_sgl(void)
7141 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7145 test_zuc_hash_generate_test_case_1(void)
7147 return test_zuc_authentication(&zuc_test_case_auth_1b);
7151 test_zuc_hash_generate_test_case_2(void)
7153 return test_zuc_authentication(&zuc_test_case_auth_90b);
7157 test_zuc_hash_generate_test_case_3(void)
7159 return test_zuc_authentication(&zuc_test_case_auth_577b);
7163 test_zuc_hash_generate_test_case_4(void)
7165 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7169 test_zuc_hash_generate_test_case_5(void)
7171 return test_zuc_authentication(&zuc_test_auth_5670b);
7175 test_zuc_hash_generate_test_case_6(void)
7177 return test_zuc_authentication(&zuc_test_case_auth_128b);
7181 test_zuc_hash_generate_test_case_7(void)
7183 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7187 test_zuc_hash_generate_test_case_8(void)
7189 return test_zuc_authentication(&zuc_test_case_auth_584b);
7193 test_zuc_hash_generate_test_case_9(void)
7195 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b);
7199 test_zuc_hash_generate_test_case_10(void)
7201 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b);
7205 test_zuc_hash_generate_test_case_11(void)
7207 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b);
7211 test_zuc_cipher_auth_test_case_1(void)
7213 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7217 test_zuc_cipher_auth_test_case_2(void)
7219 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7223 test_zuc_auth_cipher_test_case_1(void)
7225 return test_zuc_auth_cipher(
7226 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7230 test_zuc_auth_cipher_test_case_1_oop(void)
7232 return test_zuc_auth_cipher(
7233 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7237 test_zuc_auth_cipher_test_case_1_sgl(void)
7239 return test_zuc_auth_cipher_sgl(
7240 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7244 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7246 return test_zuc_auth_cipher_sgl(
7247 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7251 test_zuc_auth_cipher_verify_test_case_1(void)
7253 return test_zuc_auth_cipher(
7254 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7258 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7260 return test_zuc_auth_cipher(
7261 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7265 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7267 return test_zuc_auth_cipher_sgl(
7268 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7272 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7274 return test_zuc_auth_cipher_sgl(
7275 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7279 test_zuc256_encryption_test_case_1(void)
7281 return test_zuc_encryption(&zuc256_test_case_cipher_1);
7285 test_zuc256_encryption_test_case_2(void)
7287 return test_zuc_encryption(&zuc256_test_case_cipher_2);
7291 test_zuc256_authentication_test_case_1(void)
7293 return test_zuc_authentication(&zuc256_test_case_auth_1);
7297 test_zuc256_authentication_test_case_2(void)
7299 return test_zuc_authentication(&zuc256_test_case_auth_2);
7303 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7305 uint8_t dev_id = testsuite_params.valid_devs[0];
7307 struct rte_cryptodev_sym_capability_idx cap_idx;
7309 /* Check if device supports particular cipher algorithm */
7310 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7311 cap_idx.algo.cipher = tdata->cipher_algo;
7312 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7313 return TEST_SKIPPED;
7315 /* Check if device supports particular hash algorithm */
7316 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7317 cap_idx.algo.auth = tdata->auth_algo;
7318 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7319 return TEST_SKIPPED;
7325 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7326 uint8_t op_mode, uint8_t verify)
7328 struct crypto_testsuite_params *ts_params = &testsuite_params;
7329 struct crypto_unittest_params *ut_params = &unittest_params;
7333 uint8_t *plaintext = NULL, *ciphertext = NULL;
7334 unsigned int plaintext_pad_len;
7335 unsigned int plaintext_len;
7336 unsigned int ciphertext_pad_len;
7337 unsigned int ciphertext_len;
7339 struct rte_cryptodev_info dev_info;
7340 struct rte_crypto_op *op;
7342 /* Check if device supports particular algorithms separately */
7343 if (test_mixed_check_if_unsupported(tdata))
7344 return TEST_SKIPPED;
7345 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7346 return TEST_SKIPPED;
7348 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7350 uint64_t feat_flags = dev_info.feature_flags;
7352 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7353 printf("Device doesn't support digest encrypted.\n");
7354 return TEST_SKIPPED;
7357 /* Create the session */
7359 retval = create_wireless_algo_cipher_auth_session(
7360 ts_params->valid_devs[0],
7361 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7362 RTE_CRYPTO_AUTH_OP_VERIFY,
7365 tdata->auth_key.data, tdata->auth_key.len,
7366 tdata->auth_iv.len, tdata->digest_enc.len,
7367 tdata->cipher_iv.len);
7369 retval = create_wireless_algo_auth_cipher_session(
7370 ts_params->valid_devs[0],
7371 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7372 RTE_CRYPTO_AUTH_OP_GENERATE,
7375 tdata->auth_key.data, tdata->auth_key.len,
7376 tdata->auth_iv.len, tdata->digest_enc.len,
7377 tdata->cipher_iv.len);
7381 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7382 if (op_mode == OUT_OF_PLACE)
7383 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7385 /* clear mbuf payload */
7386 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7387 rte_pktmbuf_tailroom(ut_params->ibuf));
7388 if (op_mode == OUT_OF_PLACE) {
7390 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7391 rte_pktmbuf_tailroom(ut_params->obuf));
7394 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7395 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7396 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7397 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7400 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7401 ciphertext_pad_len);
7402 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7403 debug_hexdump(stdout, "ciphertext:", ciphertext,
7406 /* make sure enough space to cover partial digest verify case */
7407 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7408 ciphertext_pad_len);
7409 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7410 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7413 if (op_mode == OUT_OF_PLACE)
7414 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7416 /* Create the operation */
7417 retval = create_wireless_algo_auth_cipher_operation(
7418 tdata->digest_enc.data, tdata->digest_enc.len,
7419 tdata->cipher_iv.data, tdata->cipher_iv.len,
7420 tdata->auth_iv.data, tdata->auth_iv.len,
7421 (tdata->digest_enc.offset == 0 ?
7423 : tdata->digest_enc.offset),
7424 tdata->validCipherLen.len_bits,
7425 tdata->cipher.offset_bits,
7426 tdata->validAuthLen.len_bits,
7427 tdata->auth.offset_bits,
7428 op_mode, 0, verify);
7433 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7435 /* Check if the op failed because the device doesn't */
7436 /* support this particular combination of algorithms */
7437 if (op == NULL && ut_params->op->status ==
7438 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7439 printf("Device doesn't support this mixed combination. "
7441 return TEST_SKIPPED;
7445 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7447 ut_params->obuf = (op_mode == IN_PLACE ?
7448 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7451 if (ut_params->obuf)
7452 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7455 plaintext = ciphertext +
7456 (tdata->cipher.offset_bits >> 3);
7458 debug_hexdump(stdout, "plaintext:", plaintext,
7459 tdata->plaintext.len_bits >> 3);
7460 debug_hexdump(stdout, "plaintext expected:",
7461 tdata->plaintext.data,
7462 tdata->plaintext.len_bits >> 3);
7464 if (ut_params->obuf)
7465 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7468 ciphertext = plaintext;
7470 debug_hexdump(stdout, "ciphertext:", ciphertext,
7472 debug_hexdump(stdout, "ciphertext expected:",
7473 tdata->ciphertext.data,
7474 tdata->ciphertext.len_bits >> 3);
7476 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7477 + (tdata->digest_enc.offset == 0 ?
7478 plaintext_pad_len : tdata->digest_enc.offset);
7480 debug_hexdump(stdout, "digest:", ut_params->digest,
7481 tdata->digest_enc.len);
7482 debug_hexdump(stdout, "digest expected:",
7483 tdata->digest_enc.data,
7484 tdata->digest_enc.len);
7488 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7490 tdata->digest_enc.data,
7491 tdata->digest_enc.len,
7492 "Generated auth tag not as expected");
7495 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7497 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7499 tdata->plaintext.data,
7500 tdata->plaintext.len_bits >> 3,
7501 "Plaintext data not as expected");
7503 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7505 tdata->ciphertext.data,
7506 tdata->validDataLen.len_bits,
7507 "Ciphertext data not as expected");
7511 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7512 "crypto op processing failed");
7518 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7519 uint8_t op_mode, uint8_t verify)
7521 struct crypto_testsuite_params *ts_params = &testsuite_params;
7522 struct crypto_unittest_params *ut_params = &unittest_params;
7526 const uint8_t *plaintext = NULL;
7527 const uint8_t *ciphertext = NULL;
7528 const uint8_t *digest = NULL;
7529 unsigned int plaintext_pad_len;
7530 unsigned int plaintext_len;
7531 unsigned int ciphertext_pad_len;
7532 unsigned int ciphertext_len;
7533 uint8_t buffer[10000];
7534 uint8_t digest_buffer[10000];
7536 struct rte_cryptodev_info dev_info;
7537 struct rte_crypto_op *op;
7539 /* Check if device supports particular algorithms */
7540 if (test_mixed_check_if_unsupported(tdata))
7541 return TEST_SKIPPED;
7542 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7543 return TEST_SKIPPED;
7545 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7547 uint64_t feat_flags = dev_info.feature_flags;
7549 if (op_mode == IN_PLACE) {
7550 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7551 printf("Device doesn't support in-place scatter-gather "
7552 "in both input and output mbufs.\n");
7553 return TEST_SKIPPED;
7556 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7557 printf("Device doesn't support out-of-place scatter-gather "
7558 "in both input and output mbufs.\n");
7559 return TEST_SKIPPED;
7561 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7562 printf("Device doesn't support digest encrypted.\n");
7563 return TEST_SKIPPED;
7567 /* Create the session */
7569 retval = create_wireless_algo_cipher_auth_session(
7570 ts_params->valid_devs[0],
7571 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7572 RTE_CRYPTO_AUTH_OP_VERIFY,
7575 tdata->auth_key.data, tdata->auth_key.len,
7576 tdata->auth_iv.len, tdata->digest_enc.len,
7577 tdata->cipher_iv.len);
7579 retval = create_wireless_algo_auth_cipher_session(
7580 ts_params->valid_devs[0],
7581 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7582 RTE_CRYPTO_AUTH_OP_GENERATE,
7585 tdata->auth_key.data, tdata->auth_key.len,
7586 tdata->auth_iv.len, tdata->digest_enc.len,
7587 tdata->cipher_iv.len);
7591 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7592 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7593 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7594 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7596 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7597 ciphertext_pad_len, 15, 0);
7598 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7599 "Failed to allocate input buffer in mempool");
7601 if (op_mode == OUT_OF_PLACE) {
7602 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7603 plaintext_pad_len, 15, 0);
7604 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7605 "Failed to allocate output buffer in mempool");
7609 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7610 tdata->ciphertext.data);
7611 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7612 ciphertext_len, buffer);
7613 debug_hexdump(stdout, "ciphertext:", ciphertext,
7616 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7617 tdata->plaintext.data);
7618 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7619 plaintext_len, buffer);
7620 debug_hexdump(stdout, "plaintext:", plaintext,
7623 memset(buffer, 0, sizeof(buffer));
7625 /* Create the operation */
7626 retval = create_wireless_algo_auth_cipher_operation(
7627 tdata->digest_enc.data, tdata->digest_enc.len,
7628 tdata->cipher_iv.data, tdata->cipher_iv.len,
7629 tdata->auth_iv.data, tdata->auth_iv.len,
7630 (tdata->digest_enc.offset == 0 ?
7632 : tdata->digest_enc.offset),
7633 tdata->validCipherLen.len_bits,
7634 tdata->cipher.offset_bits,
7635 tdata->validAuthLen.len_bits,
7636 tdata->auth.offset_bits,
7637 op_mode, 1, verify);
7642 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7644 /* Check if the op failed because the device doesn't */
7645 /* support this particular combination of algorithms */
7646 if (op == NULL && ut_params->op->status ==
7647 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7648 printf("Device doesn't support this mixed combination. "
7650 return TEST_SKIPPED;
7654 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7656 ut_params->obuf = (op_mode == IN_PLACE ?
7657 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7660 if (ut_params->obuf)
7661 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7662 plaintext_len, buffer);
7664 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7665 plaintext_len, buffer);
7667 debug_hexdump(stdout, "plaintext:", plaintext,
7668 (tdata->plaintext.len_bits >> 3) -
7669 tdata->digest_enc.len);
7670 debug_hexdump(stdout, "plaintext expected:",
7671 tdata->plaintext.data,
7672 (tdata->plaintext.len_bits >> 3) -
7673 tdata->digest_enc.len);
7675 if (ut_params->obuf)
7676 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7677 ciphertext_len, buffer);
7679 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7680 ciphertext_len, buffer);
7682 debug_hexdump(stdout, "ciphertext:", ciphertext,
7684 debug_hexdump(stdout, "ciphertext expected:",
7685 tdata->ciphertext.data,
7686 tdata->ciphertext.len_bits >> 3);
7688 if (ut_params->obuf)
7689 digest = rte_pktmbuf_read(ut_params->obuf,
7690 (tdata->digest_enc.offset == 0 ?
7692 tdata->digest_enc.offset),
7693 tdata->digest_enc.len, digest_buffer);
7695 digest = rte_pktmbuf_read(ut_params->ibuf,
7696 (tdata->digest_enc.offset == 0 ?
7698 tdata->digest_enc.offset),
7699 tdata->digest_enc.len, digest_buffer);
7701 debug_hexdump(stdout, "digest:", digest,
7702 tdata->digest_enc.len);
7703 debug_hexdump(stdout, "digest expected:",
7704 tdata->digest_enc.data, tdata->digest_enc.len);
7708 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7710 tdata->digest_enc.data,
7711 tdata->digest_enc.len,
7712 "Generated auth tag not as expected");
7715 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7717 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7719 tdata->plaintext.data,
7720 tdata->plaintext.len_bits >> 3,
7721 "Plaintext data not as expected");
7723 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7725 tdata->ciphertext.data,
7726 tdata->validDataLen.len_bits,
7727 "Ciphertext data not as expected");
7731 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7732 "crypto op processing failed");
7737 /** AUTH AES CMAC + CIPHER AES CTR */
7740 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7742 return test_mixed_auth_cipher(
7743 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7747 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7749 return test_mixed_auth_cipher(
7750 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7754 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7756 return test_mixed_auth_cipher_sgl(
7757 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7761 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7763 return test_mixed_auth_cipher_sgl(
7764 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7768 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7770 return test_mixed_auth_cipher(
7771 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7775 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7777 return test_mixed_auth_cipher(
7778 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7782 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7784 return test_mixed_auth_cipher_sgl(
7785 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7789 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7791 return test_mixed_auth_cipher_sgl(
7792 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7795 /** MIXED AUTH + CIPHER */
7798 test_auth_zuc_cipher_snow_test_case_1(void)
7800 return test_mixed_auth_cipher(
7801 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7805 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7807 return test_mixed_auth_cipher(
7808 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7812 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7814 return test_mixed_auth_cipher(
7815 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7819 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7821 return test_mixed_auth_cipher(
7822 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7826 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7828 return test_mixed_auth_cipher(
7829 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7833 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7835 return test_mixed_auth_cipher(
7836 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7840 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7842 return test_mixed_auth_cipher(
7843 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7847 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7849 return test_mixed_auth_cipher(
7850 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7854 test_auth_snow_cipher_zuc_test_case_1(void)
7856 return test_mixed_auth_cipher(
7857 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7861 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7863 return test_mixed_auth_cipher(
7864 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7868 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7870 return test_mixed_auth_cipher(
7871 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7875 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7877 return test_mixed_auth_cipher(
7878 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7882 test_auth_null_cipher_snow_test_case_1(void)
7884 return test_mixed_auth_cipher(
7885 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7889 test_verify_auth_null_cipher_snow_test_case_1(void)
7891 return test_mixed_auth_cipher(
7892 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7896 test_auth_null_cipher_zuc_test_case_1(void)
7898 return test_mixed_auth_cipher(
7899 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7903 test_verify_auth_null_cipher_zuc_test_case_1(void)
7905 return test_mixed_auth_cipher(
7906 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7910 test_auth_snow_cipher_null_test_case_1(void)
7912 return test_mixed_auth_cipher(
7913 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7917 test_verify_auth_snow_cipher_null_test_case_1(void)
7919 return test_mixed_auth_cipher(
7920 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7924 test_auth_zuc_cipher_null_test_case_1(void)
7926 return test_mixed_auth_cipher(
7927 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7931 test_verify_auth_zuc_cipher_null_test_case_1(void)
7933 return test_mixed_auth_cipher(
7934 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7938 test_auth_null_cipher_aes_ctr_test_case_1(void)
7940 return test_mixed_auth_cipher(
7941 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7945 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7947 return test_mixed_auth_cipher(
7948 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7952 test_auth_aes_cmac_cipher_null_test_case_1(void)
7954 return test_mixed_auth_cipher(
7955 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7959 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7961 return test_mixed_auth_cipher(
7962 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7965 /* ***** AEAD algorithm Tests ***** */
7968 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7969 enum rte_crypto_aead_operation op,
7970 const uint8_t *key, const uint8_t key_len,
7971 const uint16_t aad_len, const uint8_t auth_len,
7974 uint8_t aead_key[key_len];
7976 struct crypto_testsuite_params *ts_params = &testsuite_params;
7977 struct crypto_unittest_params *ut_params = &unittest_params;
7979 memcpy(aead_key, key, key_len);
7981 /* Setup AEAD Parameters */
7982 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7983 ut_params->aead_xform.next = NULL;
7984 ut_params->aead_xform.aead.algo = algo;
7985 ut_params->aead_xform.aead.op = op;
7986 ut_params->aead_xform.aead.key.data = aead_key;
7987 ut_params->aead_xform.aead.key.length = key_len;
7988 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7989 ut_params->aead_xform.aead.iv.length = iv_len;
7990 ut_params->aead_xform.aead.digest_length = auth_len;
7991 ut_params->aead_xform.aead.aad_length = aad_len;
7993 debug_hexdump(stdout, "key:", key, key_len);
7995 /* Create Crypto session*/
7996 ut_params->sess = rte_cryptodev_sym_session_create(
7997 ts_params->session_mpool);
7999 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8000 &ut_params->aead_xform,
8001 ts_params->session_priv_mpool);
8003 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8009 create_aead_xform(struct rte_crypto_op *op,
8010 enum rte_crypto_aead_algorithm algo,
8011 enum rte_crypto_aead_operation aead_op,
8012 uint8_t *key, const uint8_t key_len,
8013 const uint8_t aad_len, const uint8_t auth_len,
8016 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8017 "failed to allocate space for crypto transform");
8019 struct rte_crypto_sym_op *sym_op = op->sym;
8021 /* Setup AEAD Parameters */
8022 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8023 sym_op->xform->next = NULL;
8024 sym_op->xform->aead.algo = algo;
8025 sym_op->xform->aead.op = aead_op;
8026 sym_op->xform->aead.key.data = key;
8027 sym_op->xform->aead.key.length = key_len;
8028 sym_op->xform->aead.iv.offset = IV_OFFSET;
8029 sym_op->xform->aead.iv.length = iv_len;
8030 sym_op->xform->aead.digest_length = auth_len;
8031 sym_op->xform->aead.aad_length = aad_len;
8033 debug_hexdump(stdout, "key:", key, key_len);
8039 create_aead_operation(enum rte_crypto_aead_operation op,
8040 const struct aead_test_data *tdata)
8042 struct crypto_testsuite_params *ts_params = &testsuite_params;
8043 struct crypto_unittest_params *ut_params = &unittest_params;
8045 uint8_t *plaintext, *ciphertext;
8046 unsigned int aad_pad_len, plaintext_pad_len;
8048 /* Generate Crypto op data structure */
8049 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8050 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8051 TEST_ASSERT_NOT_NULL(ut_params->op,
8052 "Failed to allocate symmetric crypto operation struct");
8054 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8056 /* Append aad data */
8057 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8058 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8059 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8061 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8062 "no room to append aad");
8064 sym_op->aead.aad.phys_addr =
8065 rte_pktmbuf_iova(ut_params->ibuf);
8066 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8067 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8068 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8071 /* Append IV at the end of the crypto operation*/
8072 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8073 uint8_t *, IV_OFFSET);
8075 /* Copy IV 1 byte after the IV pointer, according to the API */
8076 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8077 debug_hexdump(stdout, "iv:", iv_ptr,
8080 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8081 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8083 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8084 "no room to append aad");
8086 sym_op->aead.aad.phys_addr =
8087 rte_pktmbuf_iova(ut_params->ibuf);
8088 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8089 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8092 /* Append IV at the end of the crypto operation*/
8093 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8094 uint8_t *, IV_OFFSET);
8096 if (tdata->iv.len == 0) {
8097 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8098 debug_hexdump(stdout, "iv:", iv_ptr,
8101 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8102 debug_hexdump(stdout, "iv:", iv_ptr,
8107 /* Append plaintext/ciphertext */
8108 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8109 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8110 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8112 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8114 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8115 debug_hexdump(stdout, "plaintext:", plaintext,
8116 tdata->plaintext.len);
8118 if (ut_params->obuf) {
8119 ciphertext = (uint8_t *)rte_pktmbuf_append(
8121 plaintext_pad_len + aad_pad_len);
8122 TEST_ASSERT_NOT_NULL(ciphertext,
8123 "no room to append ciphertext");
8125 memset(ciphertext + aad_pad_len, 0,
8126 tdata->ciphertext.len);
8129 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8130 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8132 TEST_ASSERT_NOT_NULL(ciphertext,
8133 "no room to append ciphertext");
8135 memcpy(ciphertext, tdata->ciphertext.data,
8136 tdata->ciphertext.len);
8137 debug_hexdump(stdout, "ciphertext:", ciphertext,
8138 tdata->ciphertext.len);
8140 if (ut_params->obuf) {
8141 plaintext = (uint8_t *)rte_pktmbuf_append(
8143 plaintext_pad_len + aad_pad_len);
8144 TEST_ASSERT_NOT_NULL(plaintext,
8145 "no room to append plaintext");
8147 memset(plaintext + aad_pad_len, 0,
8148 tdata->plaintext.len);
8152 /* Append digest data */
8153 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8154 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8155 ut_params->obuf ? ut_params->obuf :
8157 tdata->auth_tag.len);
8158 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8159 "no room to append digest");
8160 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8161 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8162 ut_params->obuf ? ut_params->obuf :
8167 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8168 ut_params->ibuf, tdata->auth_tag.len);
8169 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8170 "no room to append digest");
8171 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8173 plaintext_pad_len + aad_pad_len);
8175 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8176 tdata->auth_tag.len);
8177 debug_hexdump(stdout, "digest:",
8178 sym_op->aead.digest.data,
8179 tdata->auth_tag.len);
8182 sym_op->aead.data.length = tdata->plaintext.len;
8183 sym_op->aead.data.offset = aad_pad_len;
8189 test_authenticated_encryption(const struct aead_test_data *tdata)
8191 struct crypto_testsuite_params *ts_params = &testsuite_params;
8192 struct crypto_unittest_params *ut_params = &unittest_params;
8195 uint8_t *ciphertext, *auth_tag;
8196 uint16_t plaintext_pad_len;
8198 struct rte_cryptodev_info dev_info;
8200 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8201 uint64_t feat_flags = dev_info.feature_flags;
8203 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8204 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8205 printf("Device doesn't support RAW data-path APIs.\n");
8206 return TEST_SKIPPED;
8209 /* Verify the capabilities */
8210 struct rte_cryptodev_sym_capability_idx cap_idx;
8211 const struct rte_cryptodev_symmetric_capability *capability;
8212 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8213 cap_idx.algo.aead = tdata->algo;
8214 capability = rte_cryptodev_sym_capability_get(
8215 ts_params->valid_devs[0], &cap_idx);
8216 if (capability == NULL)
8217 return TEST_SKIPPED;
8218 if (rte_cryptodev_sym_capability_check_aead(
8219 capability, tdata->key.len, tdata->auth_tag.len,
8220 tdata->aad.len, tdata->iv.len))
8221 return TEST_SKIPPED;
8223 /* Create AEAD session */
8224 retval = create_aead_session(ts_params->valid_devs[0],
8226 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8227 tdata->key.data, tdata->key.len,
8228 tdata->aad.len, tdata->auth_tag.len,
8233 if (tdata->aad.len > MBUF_SIZE) {
8234 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8235 /* Populate full size of add data */
8236 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8237 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8239 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8241 /* clear mbuf payload */
8242 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8243 rte_pktmbuf_tailroom(ut_params->ibuf));
8245 /* Create AEAD operation */
8246 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8250 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8252 ut_params->op->sym->m_src = ut_params->ibuf;
8254 /* Process crypto operation */
8255 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8256 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8257 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8258 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8259 ut_params->op, 0, 0, 0, 0);
8261 TEST_ASSERT_NOT_NULL(
8262 process_crypto_request(ts_params->valid_devs[0],
8263 ut_params->op), "failed to process sym crypto op");
8265 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8266 "crypto op processing failed");
8268 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8270 if (ut_params->op->sym->m_dst) {
8271 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8273 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8274 uint8_t *, plaintext_pad_len);
8276 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8278 ut_params->op->sym->cipher.data.offset);
8279 auth_tag = ciphertext + plaintext_pad_len;
8282 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8283 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8286 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8288 tdata->ciphertext.data,
8289 tdata->ciphertext.len,
8290 "Ciphertext data not as expected");
8292 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8294 tdata->auth_tag.data,
8295 tdata->auth_tag.len,
8296 "Generated auth tag not as expected");
8302 #ifdef RTE_LIB_SECURITY
8304 security_proto_supported(enum rte_security_session_action_type action,
8305 enum rte_security_session_protocol proto)
8307 struct crypto_testsuite_params *ts_params = &testsuite_params;
8309 const struct rte_security_capability *capabilities;
8310 const struct rte_security_capability *capability;
8313 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8314 rte_cryptodev_get_sec_ctx(
8315 ts_params->valid_devs[0]);
8318 capabilities = rte_security_capabilities_get(ctx);
8320 if (capabilities == NULL)
8323 while ((capability = &capabilities[i++])->action !=
8324 RTE_SECURITY_ACTION_TYPE_NONE) {
8325 if (capability->action == action &&
8326 capability->protocol == proto)
8333 /* Basic algorithm run function for async inplace mode.
8334 * Creates a session from input parameters and runs one operation
8335 * on input_vec. Checks the output of the crypto operation against
8338 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8339 enum rte_crypto_auth_operation opa,
8340 const uint8_t *input_vec, unsigned int input_vec_len,
8341 const uint8_t *output_vec,
8342 unsigned int output_vec_len,
8343 enum rte_crypto_cipher_algorithm cipher_alg,
8344 const uint8_t *cipher_key, uint32_t cipher_key_len,
8345 enum rte_crypto_auth_algorithm auth_alg,
8346 const uint8_t *auth_key, uint32_t auth_key_len,
8347 uint8_t bearer, enum rte_security_pdcp_domain domain,
8348 uint8_t packet_direction, uint8_t sn_size,
8349 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8351 struct crypto_testsuite_params *ts_params = &testsuite_params;
8352 struct crypto_unittest_params *ut_params = &unittest_params;
8354 int ret = TEST_SUCCESS;
8355 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8356 rte_cryptodev_get_sec_ctx(
8357 ts_params->valid_devs[0]);
8359 /* Verify the capabilities */
8360 struct rte_security_capability_idx sec_cap_idx;
8362 sec_cap_idx.action = ut_params->type;
8363 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8364 sec_cap_idx.pdcp.domain = domain;
8365 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8366 return TEST_SKIPPED;
8368 /* Generate test mbuf data */
8369 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8371 /* clear mbuf payload */
8372 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8373 rte_pktmbuf_tailroom(ut_params->ibuf));
8375 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8377 memcpy(plaintext, input_vec, input_vec_len);
8379 /* Out of place support */
8382 * For out-op-place we need to alloc another mbuf
8384 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8385 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8388 /* Setup Cipher Parameters */
8389 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8390 ut_params->cipher_xform.cipher.algo = cipher_alg;
8391 ut_params->cipher_xform.cipher.op = opc;
8392 ut_params->cipher_xform.cipher.key.data = cipher_key;
8393 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8394 ut_params->cipher_xform.cipher.iv.length =
8395 packet_direction ? 4 : 0;
8396 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8398 /* Setup HMAC Parameters if ICV header is required */
8399 if (auth_alg != 0) {
8400 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8401 ut_params->auth_xform.next = NULL;
8402 ut_params->auth_xform.auth.algo = auth_alg;
8403 ut_params->auth_xform.auth.op = opa;
8404 ut_params->auth_xform.auth.key.data = auth_key;
8405 ut_params->auth_xform.auth.key.length = auth_key_len;
8407 ut_params->cipher_xform.next = &ut_params->auth_xform;
8409 ut_params->cipher_xform.next = NULL;
8412 struct rte_security_session_conf sess_conf = {
8413 .action_type = ut_params->type,
8414 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8418 .pkt_dir = packet_direction,
8420 .hfn = packet_direction ? 0 : hfn,
8422 * hfn can be set as pdcp_test_hfn[i]
8423 * if hfn_ovrd is not set. Here, PDCP
8424 * packet direction is just used to
8425 * run half of the cases with session
8426 * HFN and other half with per packet
8429 .hfn_threshold = hfn_threshold,
8430 .hfn_ovrd = packet_direction ? 1 : 0,
8431 .sdap_enabled = sdap,
8433 .crypto_xform = &ut_params->cipher_xform
8436 /* Create security session */
8437 ut_params->sec_session = rte_security_session_create(ctx,
8438 &sess_conf, ts_params->session_mpool,
8439 ts_params->session_priv_mpool);
8441 if (!ut_params->sec_session) {
8442 printf("TestCase %s()-%d line %d failed %s: ",
8443 __func__, i, __LINE__, "Failed to allocate session");
8448 /* Generate crypto op data structure */
8449 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8450 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8451 if (!ut_params->op) {
8452 printf("TestCase %s()-%d line %d failed %s: ",
8453 __func__, i, __LINE__,
8454 "Failed to allocate symmetric crypto operation struct");
8459 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8460 uint32_t *, IV_OFFSET);
8461 *per_pkt_hfn = packet_direction ? hfn : 0;
8463 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8465 /* set crypto operation source mbuf */
8466 ut_params->op->sym->m_src = ut_params->ibuf;
8468 ut_params->op->sym->m_dst = ut_params->obuf;
8470 /* Process crypto operation */
8471 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8473 printf("TestCase %s()-%d line %d failed %s: ",
8474 __func__, i, __LINE__,
8475 "failed to process sym crypto op");
8480 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8481 printf("TestCase %s()-%d line %d failed %s: ",
8482 __func__, i, __LINE__, "crypto op processing failed");
8488 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8491 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8495 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8496 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8497 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8498 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8504 rte_crypto_op_free(ut_params->op);
8505 ut_params->op = NULL;
8507 if (ut_params->sec_session)
8508 rte_security_session_destroy(ctx, ut_params->sec_session);
8509 ut_params->sec_session = NULL;
8511 rte_pktmbuf_free(ut_params->ibuf);
8512 ut_params->ibuf = NULL;
8514 rte_pktmbuf_free(ut_params->obuf);
8515 ut_params->obuf = NULL;
8522 test_pdcp_proto_SGL(int i, int oop,
8523 enum rte_crypto_cipher_operation opc,
8524 enum rte_crypto_auth_operation opa,
8526 unsigned int input_vec_len,
8527 uint8_t *output_vec,
8528 unsigned int output_vec_len,
8530 uint32_t fragsz_oop)
8532 struct crypto_testsuite_params *ts_params = &testsuite_params;
8533 struct crypto_unittest_params *ut_params = &unittest_params;
8535 struct rte_mbuf *buf, *buf_oop = NULL;
8536 int ret = TEST_SUCCESS;
8540 unsigned int trn_data = 0;
8541 struct rte_cryptodev_info dev_info;
8542 uint64_t feat_flags;
8543 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8544 rte_cryptodev_get_sec_ctx(
8545 ts_params->valid_devs[0]);
8546 struct rte_mbuf *temp_mbuf;
8548 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8549 feat_flags = dev_info.feature_flags;
8551 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8552 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8553 printf("Device does not support RAW data-path APIs.\n");
8556 /* Verify the capabilities */
8557 struct rte_security_capability_idx sec_cap_idx;
8559 sec_cap_idx.action = ut_params->type;
8560 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8561 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8562 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8563 return TEST_SKIPPED;
8565 if (fragsz > input_vec_len)
8566 fragsz = input_vec_len;
8568 uint16_t plaintext_len = fragsz;
8569 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8571 if (fragsz_oop > output_vec_len)
8572 frag_size_oop = output_vec_len;
8575 if (input_vec_len % fragsz != 0) {
8576 if (input_vec_len / fragsz + 1 > 16)
8578 } else if (input_vec_len / fragsz > 16)
8581 /* Out of place support */
8584 * For out-op-place we need to alloc another mbuf
8586 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8587 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8588 buf_oop = ut_params->obuf;
8591 /* Generate test mbuf data */
8592 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8594 /* clear mbuf payload */
8595 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8596 rte_pktmbuf_tailroom(ut_params->ibuf));
8598 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8600 memcpy(plaintext, input_vec, plaintext_len);
8601 trn_data += plaintext_len;
8603 buf = ut_params->ibuf;
8606 * Loop until no more fragments
8609 while (trn_data < input_vec_len) {
8611 to_trn = (input_vec_len - trn_data < fragsz) ?
8612 (input_vec_len - trn_data) : fragsz;
8614 to_trn_tbl[ecx++] = to_trn;
8616 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8619 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8620 rte_pktmbuf_tailroom(buf));
8623 if (oop && !fragsz_oop) {
8625 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8626 buf_oop = buf_oop->next;
8627 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8628 0, rte_pktmbuf_tailroom(buf_oop));
8629 rte_pktmbuf_append(buf_oop, to_trn);
8632 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8635 memcpy(plaintext, input_vec + trn_data, to_trn);
8639 ut_params->ibuf->nb_segs = segs;
8642 if (fragsz_oop && oop) {
8646 trn_data = frag_size_oop;
8647 while (trn_data < output_vec_len) {
8650 (output_vec_len - trn_data <
8652 (output_vec_len - trn_data) :
8655 to_trn_tbl[ecx++] = to_trn;
8658 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8659 buf_oop = buf_oop->next;
8660 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8661 0, rte_pktmbuf_tailroom(buf_oop));
8662 rte_pktmbuf_append(buf_oop, to_trn);
8666 ut_params->obuf->nb_segs = segs;
8669 /* Setup Cipher Parameters */
8670 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8671 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8672 ut_params->cipher_xform.cipher.op = opc;
8673 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8674 ut_params->cipher_xform.cipher.key.length =
8675 pdcp_test_params[i].cipher_key_len;
8676 ut_params->cipher_xform.cipher.iv.length = 0;
8678 /* Setup HMAC Parameters if ICV header is required */
8679 if (pdcp_test_params[i].auth_alg != 0) {
8680 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8681 ut_params->auth_xform.next = NULL;
8682 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8683 ut_params->auth_xform.auth.op = opa;
8684 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8685 ut_params->auth_xform.auth.key.length =
8686 pdcp_test_params[i].auth_key_len;
8688 ut_params->cipher_xform.next = &ut_params->auth_xform;
8690 ut_params->cipher_xform.next = NULL;
8693 struct rte_security_session_conf sess_conf = {
8694 .action_type = ut_params->type,
8695 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8697 .bearer = pdcp_test_bearer[i],
8698 .domain = pdcp_test_params[i].domain,
8699 .pkt_dir = pdcp_test_packet_direction[i],
8700 .sn_size = pdcp_test_data_sn_size[i],
8701 .hfn = pdcp_test_hfn[i],
8702 .hfn_threshold = pdcp_test_hfn_threshold[i],
8705 .crypto_xform = &ut_params->cipher_xform
8708 /* Create security session */
8709 ut_params->sec_session = rte_security_session_create(ctx,
8710 &sess_conf, ts_params->session_mpool,
8711 ts_params->session_priv_mpool);
8713 if (!ut_params->sec_session) {
8714 printf("TestCase %s()-%d line %d failed %s: ",
8715 __func__, i, __LINE__, "Failed to allocate session");
8720 /* Generate crypto op data structure */
8721 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8722 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8723 if (!ut_params->op) {
8724 printf("TestCase %s()-%d line %d failed %s: ",
8725 __func__, i, __LINE__,
8726 "Failed to allocate symmetric crypto operation struct");
8731 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8733 /* set crypto operation source mbuf */
8734 ut_params->op->sym->m_src = ut_params->ibuf;
8736 ut_params->op->sym->m_dst = ut_params->obuf;
8738 /* Process crypto operation */
8739 temp_mbuf = ut_params->op->sym->m_src;
8740 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8741 /* filling lengths */
8743 ut_params->op->sym->cipher.data.length
8744 += temp_mbuf->pkt_len;
8745 ut_params->op->sym->auth.data.length
8746 += temp_mbuf->pkt_len;
8747 temp_mbuf = temp_mbuf->next;
8749 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8750 ut_params->op, 1, 1, 0, 0);
8752 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8755 if (ut_params->op == NULL) {
8756 printf("TestCase %s()-%d line %d failed %s: ",
8757 __func__, i, __LINE__,
8758 "failed to process sym crypto op");
8763 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8764 printf("TestCase %s()-%d line %d failed %s: ",
8765 __func__, i, __LINE__, "crypto op processing failed");
8771 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8774 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8778 fragsz = frag_size_oop;
8779 if (memcmp(ciphertext, output_vec, fragsz)) {
8780 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8781 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8782 rte_hexdump(stdout, "reference", output_vec, fragsz);
8787 buf = ut_params->op->sym->m_src->next;
8789 buf = ut_params->op->sym->m_dst->next;
8791 unsigned int off = fragsz;
8795 ciphertext = rte_pktmbuf_mtod(buf,
8797 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8798 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8799 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8800 rte_hexdump(stdout, "reference", output_vec + off,
8805 off += to_trn_tbl[ecx++];
8809 rte_crypto_op_free(ut_params->op);
8810 ut_params->op = NULL;
8812 if (ut_params->sec_session)
8813 rte_security_session_destroy(ctx, ut_params->sec_session);
8814 ut_params->sec_session = NULL;
8816 rte_pktmbuf_free(ut_params->ibuf);
8817 ut_params->ibuf = NULL;
8819 rte_pktmbuf_free(ut_params->obuf);
8820 ut_params->obuf = NULL;
8827 test_pdcp_proto_cplane_encap(int i)
8829 return test_pdcp_proto(
8830 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8831 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8832 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8833 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8834 pdcp_test_params[i].cipher_key_len,
8835 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8836 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8837 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8838 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8839 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8843 test_pdcp_proto_uplane_encap(int i)
8845 return test_pdcp_proto(
8846 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8847 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8848 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8849 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8850 pdcp_test_params[i].cipher_key_len,
8851 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8852 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8853 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8854 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8855 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8859 test_pdcp_proto_uplane_encap_with_int(int i)
8861 return test_pdcp_proto(
8862 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8863 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8864 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8865 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8866 pdcp_test_params[i].cipher_key_len,
8867 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8868 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8869 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8870 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8871 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8875 test_pdcp_proto_cplane_decap(int i)
8877 return test_pdcp_proto(
8878 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8879 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8880 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8881 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8882 pdcp_test_params[i].cipher_key_len,
8883 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8884 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8885 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8886 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8887 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8891 test_pdcp_proto_uplane_decap(int i)
8893 return test_pdcp_proto(
8894 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8895 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8896 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8897 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8898 pdcp_test_params[i].cipher_key_len,
8899 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8900 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8901 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8902 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8903 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8907 test_pdcp_proto_uplane_decap_with_int(int i)
8909 return test_pdcp_proto(
8910 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8911 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8912 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8913 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8914 pdcp_test_params[i].cipher_key_len,
8915 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8916 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8917 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8918 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8919 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8923 test_PDCP_PROTO_SGL_in_place_32B(void)
8925 /* i can be used for running any PDCP case
8926 * In this case it is uplane 12-bit AES-SNOW DL encap
8928 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8929 return test_pdcp_proto_SGL(i, IN_PLACE,
8930 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8931 RTE_CRYPTO_AUTH_OP_GENERATE,
8932 pdcp_test_data_in[i],
8933 pdcp_test_data_in_len[i],
8934 pdcp_test_data_out[i],
8935 pdcp_test_data_in_len[i]+4,
8939 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8941 /* i can be used for running any PDCP case
8942 * In this case it is uplane 18-bit NULL-NULL DL encap
8944 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8945 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8946 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8947 RTE_CRYPTO_AUTH_OP_GENERATE,
8948 pdcp_test_data_in[i],
8949 pdcp_test_data_in_len[i],
8950 pdcp_test_data_out[i],
8951 pdcp_test_data_in_len[i]+4,
8955 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8957 /* i can be used for running any PDCP case
8958 * In this case it is uplane 18-bit AES DL encap
8960 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8962 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8963 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8964 RTE_CRYPTO_AUTH_OP_GENERATE,
8965 pdcp_test_data_in[i],
8966 pdcp_test_data_in_len[i],
8967 pdcp_test_data_out[i],
8968 pdcp_test_data_in_len[i],
8972 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8974 /* i can be used for running any PDCP case
8975 * In this case it is cplane 12-bit AES-ZUC DL encap
8977 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8978 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8979 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8980 RTE_CRYPTO_AUTH_OP_GENERATE,
8981 pdcp_test_data_in[i],
8982 pdcp_test_data_in_len[i],
8983 pdcp_test_data_out[i],
8984 pdcp_test_data_in_len[i]+4,
8989 test_PDCP_SDAP_PROTO_encap_all(void)
8991 int i = 0, size = 0;
8992 int err, all_err = TEST_SUCCESS;
8993 const struct pdcp_sdap_test *cur_test;
8995 size = RTE_DIM(list_pdcp_sdap_tests);
8997 for (i = 0; i < size; i++) {
8998 cur_test = &list_pdcp_sdap_tests[i];
8999 err = test_pdcp_proto(
9000 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9001 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9002 cur_test->in_len, cur_test->data_out,
9003 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9004 cur_test->param.cipher_alg, cur_test->cipher_key,
9005 cur_test->param.cipher_key_len,
9006 cur_test->param.auth_alg,
9007 cur_test->auth_key, cur_test->param.auth_key_len,
9008 cur_test->bearer, cur_test->param.domain,
9009 cur_test->packet_direction, cur_test->sn_size,
9011 cur_test->hfn_threshold, SDAP_ENABLED);
9013 printf("\t%d) %s: Encapsulation failed\n",
9015 cur_test->param.name);
9018 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9019 cur_test->param.name);
9025 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9027 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9031 test_PDCP_PROTO_short_mac(void)
9033 int i = 0, size = 0;
9034 int err, all_err = TEST_SUCCESS;
9035 const struct pdcp_short_mac_test *cur_test;
9037 size = RTE_DIM(list_pdcp_smac_tests);
9039 for (i = 0; i < size; i++) {
9040 cur_test = &list_pdcp_smac_tests[i];
9041 err = test_pdcp_proto(
9042 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9043 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9044 cur_test->in_len, cur_test->data_out,
9045 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9046 RTE_CRYPTO_CIPHER_NULL, NULL,
9047 0, cur_test->param.auth_alg,
9048 cur_test->auth_key, cur_test->param.auth_key_len,
9049 0, cur_test->param.domain, 0, 0,
9052 printf("\t%d) %s: Short MAC test failed\n",
9054 cur_test->param.name);
9057 printf("\t%d) %s: Short MAC test PASS\n",
9059 cur_test->param.name);
9060 rte_hexdump(stdout, "MAC I",
9061 cur_test->data_out + cur_test->in_len + 2,
9068 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9070 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9075 test_PDCP_SDAP_PROTO_decap_all(void)
9077 int i = 0, size = 0;
9078 int err, all_err = TEST_SUCCESS;
9079 const struct pdcp_sdap_test *cur_test;
9081 size = RTE_DIM(list_pdcp_sdap_tests);
9083 for (i = 0; i < size; i++) {
9084 cur_test = &list_pdcp_sdap_tests[i];
9085 err = test_pdcp_proto(
9086 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9087 RTE_CRYPTO_AUTH_OP_VERIFY,
9089 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9090 cur_test->data_in, cur_test->in_len,
9091 cur_test->param.cipher_alg,
9092 cur_test->cipher_key, cur_test->param.cipher_key_len,
9093 cur_test->param.auth_alg, cur_test->auth_key,
9094 cur_test->param.auth_key_len, cur_test->bearer,
9095 cur_test->param.domain, cur_test->packet_direction,
9096 cur_test->sn_size, cur_test->hfn,
9097 cur_test->hfn_threshold, SDAP_ENABLED);
9099 printf("\t%d) %s: Decapsulation failed\n",
9101 cur_test->param.name);
9104 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9105 cur_test->param.name);
9111 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9113 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9117 test_ipsec_proto_process(const struct ipsec_test_data td[],
9118 struct ipsec_test_data res_d[],
9121 const struct ipsec_test_flags *flags)
9123 struct crypto_testsuite_params *ts_params = &testsuite_params;
9124 struct crypto_unittest_params *ut_params = &unittest_params;
9125 struct rte_security_capability_idx sec_cap_idx;
9126 const struct rte_security_capability *sec_cap;
9127 struct rte_security_ipsec_xform ipsec_xform;
9128 uint8_t dev_id = ts_params->valid_devs[0];
9129 enum rte_security_ipsec_sa_direction dir;
9130 struct ipsec_test_data *res_d_tmp = NULL;
9131 uint32_t src = RTE_IPV4(192, 168, 1, 0);
9132 uint32_t dst = RTE_IPV4(192, 168, 1, 1);
9133 int salt_len, i, ret = TEST_SUCCESS;
9134 struct rte_security_ctx *ctx;
9135 uint8_t *input_text;
9138 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9139 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9141 /* Use first test data to create session */
9143 /* Copy IPsec xform */
9144 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9146 dir = ipsec_xform.direction;
9147 verify = flags->tunnel_hdr_verify;
9149 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9150 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9152 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9156 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src, sizeof(src));
9157 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst, sizeof(dst));
9159 ctx = rte_cryptodev_get_sec_ctx(dev_id);
9161 sec_cap_idx.action = ut_params->type;
9162 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9163 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9164 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9165 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9167 if (flags->udp_encap)
9168 ipsec_xform.options.udp_encap = 1;
9170 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9171 if (sec_cap == NULL)
9172 return TEST_SKIPPED;
9174 /* Copy cipher session parameters */
9176 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9177 sizeof(ut_params->aead_xform));
9178 ut_params->aead_xform.aead.key.data = td[0].key.data;
9179 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9181 /* Verify crypto capabilities */
9182 if (test_ipsec_crypto_caps_aead_verify(
9184 &ut_params->aead_xform) != 0) {
9186 RTE_LOG(INFO, USER1,
9187 "Crypto capabilities not supported\n");
9188 return TEST_SKIPPED;
9191 /* Only AEAD supported now */
9192 return TEST_SKIPPED;
9195 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9196 return TEST_SKIPPED;
9198 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9199 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9201 struct rte_security_session_conf sess_conf = {
9202 .action_type = ut_params->type,
9203 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9204 .ipsec = ipsec_xform,
9205 .crypto_xform = &ut_params->aead_xform,
9208 /* Create security session */
9209 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9210 ts_params->session_mpool,
9211 ts_params->session_priv_mpool);
9213 if (ut_params->sec_session == NULL)
9214 return TEST_SKIPPED;
9216 for (i = 0; i < nb_td; i++) {
9217 /* Setup source mbuf payload */
9218 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9219 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9220 rte_pktmbuf_tailroom(ut_params->ibuf));
9222 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9223 td[i].input_text.len);
9225 memcpy(input_text, td[i].input_text.data,
9226 td[i].input_text.len);
9228 /* Generate crypto op data structure */
9229 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9230 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9231 if (!ut_params->op) {
9232 printf("TestCase %s line %d: %s\n",
9234 "failed to allocate crypto op");
9236 goto crypto_op_free;
9239 /* Attach session to operation */
9240 rte_security_attach_session(ut_params->op,
9241 ut_params->sec_session);
9243 /* Set crypto operation mbufs */
9244 ut_params->op->sym->m_src = ut_params->ibuf;
9245 ut_params->op->sym->m_dst = NULL;
9247 /* Copy IV in crypto operation when IV generation is disabled */
9248 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9249 ipsec_xform.options.iv_gen_disable == 1) {
9250 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9256 len = td[i].xform.aead.aead.iv.length;
9258 len = td[i].xform.chain.cipher.cipher.iv.length;
9260 memcpy(iv, td[i].iv.data, len);
9263 /* Process crypto operation */
9264 process_crypto_request(dev_id, ut_params->op);
9266 ret = test_ipsec_status_check(ut_params->op, flags, dir, i + 1);
9267 if (ret != TEST_SUCCESS)
9268 goto crypto_op_free;
9271 res_d_tmp = &res_d[i];
9273 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9274 res_d_tmp, silent, flags);
9275 if (ret != TEST_SUCCESS)
9276 goto crypto_op_free;
9278 rte_crypto_op_free(ut_params->op);
9279 ut_params->op = NULL;
9281 rte_pktmbuf_free(ut_params->ibuf);
9282 ut_params->ibuf = NULL;
9286 rte_crypto_op_free(ut_params->op);
9287 ut_params->op = NULL;
9289 rte_pktmbuf_free(ut_params->ibuf);
9290 ut_params->ibuf = NULL;
9292 if (ut_params->sec_session)
9293 rte_security_session_destroy(ctx, ut_params->sec_session);
9294 ut_params->sec_session = NULL;
9300 test_ipsec_proto_known_vec(const void *test_data)
9302 struct ipsec_test_data td_outb;
9303 struct ipsec_test_flags flags;
9305 memset(&flags, 0, sizeof(flags));
9307 memcpy(&td_outb, test_data, sizeof(td_outb));
9309 /* Disable IV gen to be able to test with known vectors */
9310 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9312 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9316 test_ipsec_proto_known_vec_inb(const void *td_outb)
9318 struct ipsec_test_flags flags;
9319 struct ipsec_test_data td_inb;
9321 memset(&flags, 0, sizeof(flags));
9323 test_ipsec_td_in_from_out(td_outb, &td_inb);
9325 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9329 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9331 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9332 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9333 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9336 if (flags->iv_gen ||
9337 flags->sa_expiry_pkts_soft ||
9338 flags->sa_expiry_pkts_hard)
9339 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9341 for (i = 0; i < RTE_DIM(aead_list); i++) {
9342 test_ipsec_td_prepare(&aead_list[i],
9348 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9350 if (ret == TEST_SKIPPED)
9353 if (ret == TEST_FAILED)
9356 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9358 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9360 if (ret == TEST_SKIPPED)
9363 if (ret == TEST_FAILED)
9366 if (flags->display_alg)
9367 test_ipsec_display_alg(&aead_list[i], NULL);
9373 return TEST_SUCCESS;
9375 return TEST_SKIPPED;
9379 test_ipsec_proto_display_list(const void *data __rte_unused)
9381 struct ipsec_test_flags flags;
9383 memset(&flags, 0, sizeof(flags));
9385 flags.display_alg = true;
9387 return test_ipsec_proto_all(&flags);
9391 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9393 struct ipsec_test_flags flags;
9395 memset(&flags, 0, sizeof(flags));
9397 flags.iv_gen = true;
9399 return test_ipsec_proto_all(&flags);
9403 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9405 struct ipsec_test_flags flags;
9407 memset(&flags, 0, sizeof(flags));
9409 flags.sa_expiry_pkts_soft = true;
9411 return test_ipsec_proto_all(&flags);
9415 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9417 struct ipsec_test_flags flags;
9419 memset(&flags, 0, sizeof(flags));
9421 flags.sa_expiry_pkts_hard = true;
9423 return test_ipsec_proto_all(&flags);
9427 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9429 struct ipsec_test_flags flags;
9431 memset(&flags, 0, sizeof(flags));
9433 flags.icv_corrupt = true;
9435 return test_ipsec_proto_all(&flags);
9439 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9441 struct ipsec_test_flags flags;
9443 memset(&flags, 0, sizeof(flags));
9445 flags.udp_encap = true;
9447 return test_ipsec_proto_all(&flags);
9451 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9453 struct ipsec_test_flags flags;
9455 memset(&flags, 0, sizeof(flags));
9457 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9459 return test_ipsec_proto_all(&flags);
9463 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9465 struct ipsec_test_flags flags;
9467 memset(&flags, 0, sizeof(flags));
9469 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9471 return test_ipsec_proto_all(&flags);
9475 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9477 struct ipsec_test_flags flags;
9479 memset(&flags, 0, sizeof(flags));
9481 flags.udp_encap = true;
9482 flags.udp_ports_verify = true;
9484 return test_ipsec_proto_all(&flags);
9488 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9490 struct ipsec_test_flags flags;
9492 memset(&flags, 0, sizeof(flags));
9494 flags.ip_csum = true;
9496 return test_ipsec_proto_all(&flags);
9500 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9502 struct ipsec_test_flags flags;
9504 memset(&flags, 0, sizeof(flags));
9506 flags.l4_csum = true;
9508 return test_ipsec_proto_all(&flags);
9512 test_PDCP_PROTO_all(void)
9514 struct crypto_testsuite_params *ts_params = &testsuite_params;
9515 struct crypto_unittest_params *ut_params = &unittest_params;
9516 struct rte_cryptodev_info dev_info;
9519 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9520 uint64_t feat_flags = dev_info.feature_flags;
9522 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9523 return TEST_SKIPPED;
9525 /* Set action type */
9526 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9527 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9530 if (security_proto_supported(ut_params->type,
9531 RTE_SECURITY_PROTOCOL_PDCP) < 0)
9532 return TEST_SKIPPED;
9534 status = test_PDCP_PROTO_cplane_encap_all();
9535 status += test_PDCP_PROTO_cplane_decap_all();
9536 status += test_PDCP_PROTO_uplane_encap_all();
9537 status += test_PDCP_PROTO_uplane_decap_all();
9538 status += test_PDCP_PROTO_SGL_in_place_32B();
9539 status += test_PDCP_PROTO_SGL_oop_32B_128B();
9540 status += test_PDCP_PROTO_SGL_oop_32B_40B();
9541 status += test_PDCP_PROTO_SGL_oop_128B_32B();
9542 status += test_PDCP_SDAP_PROTO_encap_all();
9543 status += test_PDCP_SDAP_PROTO_decap_all();
9544 status += test_PDCP_PROTO_short_mac();
9549 return TEST_SUCCESS;
9553 test_docsis_proto_uplink(const void *data)
9555 const struct docsis_test_data *d_td = data;
9556 struct crypto_testsuite_params *ts_params = &testsuite_params;
9557 struct crypto_unittest_params *ut_params = &unittest_params;
9558 uint8_t *plaintext = NULL;
9559 uint8_t *ciphertext = NULL;
9561 int32_t cipher_len, crc_len;
9562 uint32_t crc_data_len;
9563 int ret = TEST_SUCCESS;
9565 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9566 rte_cryptodev_get_sec_ctx(
9567 ts_params->valid_devs[0]);
9569 /* Verify the capabilities */
9570 struct rte_security_capability_idx sec_cap_idx;
9571 const struct rte_security_capability *sec_cap;
9572 const struct rte_cryptodev_capabilities *crypto_cap;
9573 const struct rte_cryptodev_symmetric_capability *sym_cap;
9576 /* Set action type */
9577 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9578 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9581 if (security_proto_supported(ut_params->type,
9582 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9583 return TEST_SKIPPED;
9585 sec_cap_idx.action = ut_params->type;
9586 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9587 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9589 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9590 if (sec_cap == NULL)
9591 return TEST_SKIPPED;
9593 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9594 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9595 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9596 crypto_cap->sym.xform_type ==
9597 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9598 crypto_cap->sym.cipher.algo ==
9599 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9600 sym_cap = &crypto_cap->sym;
9601 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9608 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9609 return TEST_SKIPPED;
9611 /* Setup source mbuf payload */
9612 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9613 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9614 rte_pktmbuf_tailroom(ut_params->ibuf));
9616 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9617 d_td->ciphertext.len);
9619 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
9621 /* Setup cipher session parameters */
9622 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9623 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9624 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
9625 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9626 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9627 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9628 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9629 ut_params->cipher_xform.next = NULL;
9631 /* Setup DOCSIS session parameters */
9632 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9634 struct rte_security_session_conf sess_conf = {
9635 .action_type = ut_params->type,
9636 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9637 .docsis = ut_params->docsis_xform,
9638 .crypto_xform = &ut_params->cipher_xform,
9641 /* Create security session */
9642 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9643 ts_params->session_mpool,
9644 ts_params->session_priv_mpool);
9646 if (!ut_params->sec_session) {
9647 printf("Test function %s line %u: failed to allocate session\n",
9648 __func__, __LINE__);
9653 /* Generate crypto op data structure */
9654 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9655 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9656 if (!ut_params->op) {
9657 printf("Test function %s line %u: failed to allocate symmetric "
9658 "crypto operation\n", __func__, __LINE__);
9663 /* Setup CRC operation parameters */
9664 crc_len = d_td->ciphertext.no_crc == false ?
9665 (d_td->ciphertext.len -
9666 d_td->ciphertext.crc_offset -
9667 RTE_ETHER_CRC_LEN) :
9669 crc_len = crc_len > 0 ? crc_len : 0;
9670 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9671 ut_params->op->sym->auth.data.length = crc_len;
9672 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9674 /* Setup cipher operation parameters */
9675 cipher_len = d_td->ciphertext.no_cipher == false ?
9676 (d_td->ciphertext.len -
9677 d_td->ciphertext.cipher_offset) :
9679 cipher_len = cipher_len > 0 ? cipher_len : 0;
9680 ut_params->op->sym->cipher.data.length = cipher_len;
9681 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9683 /* Setup cipher IV */
9684 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9685 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9687 /* Attach session to operation */
9688 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9690 /* Set crypto operation mbufs */
9691 ut_params->op->sym->m_src = ut_params->ibuf;
9692 ut_params->op->sym->m_dst = NULL;
9694 /* Process crypto operation */
9695 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9697 printf("Test function %s line %u: failed to process security "
9698 "crypto op\n", __func__, __LINE__);
9703 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9704 printf("Test function %s line %u: failed to process crypto op\n",
9705 __func__, __LINE__);
9710 /* Validate plaintext */
9711 plaintext = ciphertext;
9713 if (memcmp(plaintext, d_td->plaintext.data,
9714 d_td->plaintext.len - crc_data_len)) {
9715 printf("Test function %s line %u: plaintext not as expected\n",
9716 __func__, __LINE__);
9717 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9718 d_td->plaintext.len);
9719 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9725 rte_crypto_op_free(ut_params->op);
9726 ut_params->op = NULL;
9728 if (ut_params->sec_session)
9729 rte_security_session_destroy(ctx, ut_params->sec_session);
9730 ut_params->sec_session = NULL;
9732 rte_pktmbuf_free(ut_params->ibuf);
9733 ut_params->ibuf = NULL;
9739 test_docsis_proto_downlink(const void *data)
9741 const struct docsis_test_data *d_td = data;
9742 struct crypto_testsuite_params *ts_params = &testsuite_params;
9743 struct crypto_unittest_params *ut_params = &unittest_params;
9744 uint8_t *plaintext = NULL;
9745 uint8_t *ciphertext = NULL;
9747 int32_t cipher_len, crc_len;
9748 int ret = TEST_SUCCESS;
9750 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9751 rte_cryptodev_get_sec_ctx(
9752 ts_params->valid_devs[0]);
9754 /* Verify the capabilities */
9755 struct rte_security_capability_idx sec_cap_idx;
9756 const struct rte_security_capability *sec_cap;
9757 const struct rte_cryptodev_capabilities *crypto_cap;
9758 const struct rte_cryptodev_symmetric_capability *sym_cap;
9761 /* Set action type */
9762 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9763 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9766 if (security_proto_supported(ut_params->type,
9767 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9768 return TEST_SKIPPED;
9770 sec_cap_idx.action = ut_params->type;
9771 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9772 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9774 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9775 if (sec_cap == NULL)
9776 return TEST_SKIPPED;
9778 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9779 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9780 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9781 crypto_cap->sym.xform_type ==
9782 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9783 crypto_cap->sym.cipher.algo ==
9784 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9785 sym_cap = &crypto_cap->sym;
9786 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9793 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9794 return TEST_SKIPPED;
9796 /* Setup source mbuf payload */
9797 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9798 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9799 rte_pktmbuf_tailroom(ut_params->ibuf));
9801 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9802 d_td->plaintext.len);
9804 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9806 /* Setup cipher session parameters */
9807 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9808 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9809 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9810 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9811 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9812 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9813 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9814 ut_params->cipher_xform.next = NULL;
9816 /* Setup DOCSIS session parameters */
9817 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9819 struct rte_security_session_conf sess_conf = {
9820 .action_type = ut_params->type,
9821 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9822 .docsis = ut_params->docsis_xform,
9823 .crypto_xform = &ut_params->cipher_xform,
9826 /* Create security session */
9827 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9828 ts_params->session_mpool,
9829 ts_params->session_priv_mpool);
9831 if (!ut_params->sec_session) {
9832 printf("Test function %s line %u: failed to allocate session\n",
9833 __func__, __LINE__);
9838 /* Generate crypto op data structure */
9839 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9840 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9841 if (!ut_params->op) {
9842 printf("Test function %s line %u: failed to allocate symmetric "
9843 "crypto operation\n", __func__, __LINE__);
9848 /* Setup CRC operation parameters */
9849 crc_len = d_td->plaintext.no_crc == false ?
9850 (d_td->plaintext.len -
9851 d_td->plaintext.crc_offset -
9852 RTE_ETHER_CRC_LEN) :
9854 crc_len = crc_len > 0 ? crc_len : 0;
9855 ut_params->op->sym->auth.data.length = crc_len;
9856 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9858 /* Setup cipher operation parameters */
9859 cipher_len = d_td->plaintext.no_cipher == false ?
9860 (d_td->plaintext.len -
9861 d_td->plaintext.cipher_offset) :
9863 cipher_len = cipher_len > 0 ? cipher_len : 0;
9864 ut_params->op->sym->cipher.data.length = cipher_len;
9865 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9867 /* Setup cipher IV */
9868 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9869 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9871 /* Attach session to operation */
9872 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9874 /* Set crypto operation mbufs */
9875 ut_params->op->sym->m_src = ut_params->ibuf;
9876 ut_params->op->sym->m_dst = NULL;
9878 /* Process crypto operation */
9879 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9881 printf("Test function %s line %u: failed to process crypto op\n",
9882 __func__, __LINE__);
9887 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9888 printf("Test function %s line %u: crypto op processing failed\n",
9889 __func__, __LINE__);
9894 /* Validate ciphertext */
9895 ciphertext = plaintext;
9897 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9898 printf("Test function %s line %u: plaintext not as expected\n",
9899 __func__, __LINE__);
9900 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9901 d_td->ciphertext.len);
9902 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9908 rte_crypto_op_free(ut_params->op);
9909 ut_params->op = NULL;
9911 if (ut_params->sec_session)
9912 rte_security_session_destroy(ctx, ut_params->sec_session);
9913 ut_params->sec_session = NULL;
9915 rte_pktmbuf_free(ut_params->ibuf);
9916 ut_params->ibuf = NULL;
9923 test_AES_GCM_authenticated_encryption_test_case_1(void)
9925 return test_authenticated_encryption(&gcm_test_case_1);
9929 test_AES_GCM_authenticated_encryption_test_case_2(void)
9931 return test_authenticated_encryption(&gcm_test_case_2);
9935 test_AES_GCM_authenticated_encryption_test_case_3(void)
9937 return test_authenticated_encryption(&gcm_test_case_3);
9941 test_AES_GCM_authenticated_encryption_test_case_4(void)
9943 return test_authenticated_encryption(&gcm_test_case_4);
9947 test_AES_GCM_authenticated_encryption_test_case_5(void)
9949 return test_authenticated_encryption(&gcm_test_case_5);
9953 test_AES_GCM_authenticated_encryption_test_case_6(void)
9955 return test_authenticated_encryption(&gcm_test_case_6);
9959 test_AES_GCM_authenticated_encryption_test_case_7(void)
9961 return test_authenticated_encryption(&gcm_test_case_7);
9965 test_AES_GCM_authenticated_encryption_test_case_8(void)
9967 return test_authenticated_encryption(&gcm_test_case_8);
9971 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9973 return test_authenticated_encryption(&gcm_J0_test_case_1);
9977 test_AES_GCM_auth_encryption_test_case_192_1(void)
9979 return test_authenticated_encryption(&gcm_test_case_192_1);
9983 test_AES_GCM_auth_encryption_test_case_192_2(void)
9985 return test_authenticated_encryption(&gcm_test_case_192_2);
9989 test_AES_GCM_auth_encryption_test_case_192_3(void)
9991 return test_authenticated_encryption(&gcm_test_case_192_3);
9995 test_AES_GCM_auth_encryption_test_case_192_4(void)
9997 return test_authenticated_encryption(&gcm_test_case_192_4);
10001 test_AES_GCM_auth_encryption_test_case_192_5(void)
10003 return test_authenticated_encryption(&gcm_test_case_192_5);
10007 test_AES_GCM_auth_encryption_test_case_192_6(void)
10009 return test_authenticated_encryption(&gcm_test_case_192_6);
10013 test_AES_GCM_auth_encryption_test_case_192_7(void)
10015 return test_authenticated_encryption(&gcm_test_case_192_7);
10019 test_AES_GCM_auth_encryption_test_case_256_1(void)
10021 return test_authenticated_encryption(&gcm_test_case_256_1);
10025 test_AES_GCM_auth_encryption_test_case_256_2(void)
10027 return test_authenticated_encryption(&gcm_test_case_256_2);
10031 test_AES_GCM_auth_encryption_test_case_256_3(void)
10033 return test_authenticated_encryption(&gcm_test_case_256_3);
10037 test_AES_GCM_auth_encryption_test_case_256_4(void)
10039 return test_authenticated_encryption(&gcm_test_case_256_4);
10043 test_AES_GCM_auth_encryption_test_case_256_5(void)
10045 return test_authenticated_encryption(&gcm_test_case_256_5);
10049 test_AES_GCM_auth_encryption_test_case_256_6(void)
10051 return test_authenticated_encryption(&gcm_test_case_256_6);
10055 test_AES_GCM_auth_encryption_test_case_256_7(void)
10057 return test_authenticated_encryption(&gcm_test_case_256_7);
10061 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10063 return test_authenticated_encryption(&gcm_test_case_aad_1);
10067 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10069 return test_authenticated_encryption(&gcm_test_case_aad_2);
10073 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10075 struct aead_test_data tdata;
10078 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10079 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10080 tdata.iv.data[0] += 1;
10081 res = test_authenticated_encryption(&tdata);
10082 if (res == TEST_SKIPPED)
10084 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10085 return TEST_SUCCESS;
10089 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10091 struct aead_test_data tdata;
10094 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10095 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10096 tdata.plaintext.data[0] += 1;
10097 res = test_authenticated_encryption(&tdata);
10098 if (res == TEST_SKIPPED)
10100 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10101 return TEST_SUCCESS;
10105 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10107 struct aead_test_data tdata;
10110 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10111 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10112 tdata.ciphertext.data[0] += 1;
10113 res = test_authenticated_encryption(&tdata);
10114 if (res == TEST_SKIPPED)
10116 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10117 return TEST_SUCCESS;
10121 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10123 struct aead_test_data tdata;
10126 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10127 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10128 tdata.aad.len += 1;
10129 res = test_authenticated_encryption(&tdata);
10130 if (res == TEST_SKIPPED)
10132 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10133 return TEST_SUCCESS;
10137 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10139 struct aead_test_data tdata;
10140 uint8_t aad[gcm_test_case_7.aad.len];
10143 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10144 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10145 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10147 tdata.aad.data = aad;
10148 res = test_authenticated_encryption(&tdata);
10149 if (res == TEST_SKIPPED)
10151 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10152 return TEST_SUCCESS;
10156 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10158 struct aead_test_data tdata;
10161 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10162 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10163 tdata.auth_tag.data[0] += 1;
10164 res = test_authenticated_encryption(&tdata);
10165 if (res == TEST_SKIPPED)
10167 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10168 return TEST_SUCCESS;
10172 test_authenticated_decryption(const struct aead_test_data *tdata)
10174 struct crypto_testsuite_params *ts_params = &testsuite_params;
10175 struct crypto_unittest_params *ut_params = &unittest_params;
10178 uint8_t *plaintext;
10180 struct rte_cryptodev_info dev_info;
10182 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10183 uint64_t feat_flags = dev_info.feature_flags;
10185 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10186 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10187 printf("Device doesn't support RAW data-path APIs.\n");
10188 return TEST_SKIPPED;
10191 /* Verify the capabilities */
10192 struct rte_cryptodev_sym_capability_idx cap_idx;
10193 const struct rte_cryptodev_symmetric_capability *capability;
10194 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10195 cap_idx.algo.aead = tdata->algo;
10196 capability = rte_cryptodev_sym_capability_get(
10197 ts_params->valid_devs[0], &cap_idx);
10198 if (capability == NULL)
10199 return TEST_SKIPPED;
10200 if (rte_cryptodev_sym_capability_check_aead(
10201 capability, tdata->key.len, tdata->auth_tag.len,
10202 tdata->aad.len, tdata->iv.len))
10203 return TEST_SKIPPED;
10205 /* Create AEAD session */
10206 retval = create_aead_session(ts_params->valid_devs[0],
10208 RTE_CRYPTO_AEAD_OP_DECRYPT,
10209 tdata->key.data, tdata->key.len,
10210 tdata->aad.len, tdata->auth_tag.len,
10215 /* alloc mbuf and set payload */
10216 if (tdata->aad.len > MBUF_SIZE) {
10217 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10218 /* Populate full size of add data */
10219 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10220 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10222 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10224 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10225 rte_pktmbuf_tailroom(ut_params->ibuf));
10227 /* Create AEAD operation */
10228 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10232 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10234 ut_params->op->sym->m_src = ut_params->ibuf;
10236 /* Process crypto operation */
10237 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10238 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10239 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10240 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10241 ut_params->op, 0, 0, 0, 0);
10243 TEST_ASSERT_NOT_NULL(
10244 process_crypto_request(ts_params->valid_devs[0],
10245 ut_params->op), "failed to process sym crypto op");
10247 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10248 "crypto op processing failed");
10250 if (ut_params->op->sym->m_dst)
10251 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10254 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10256 ut_params->op->sym->cipher.data.offset);
10258 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10260 /* Validate obuf */
10261 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10263 tdata->plaintext.data,
10264 tdata->plaintext.len,
10265 "Plaintext data not as expected");
10267 TEST_ASSERT_EQUAL(ut_params->op->status,
10268 RTE_CRYPTO_OP_STATUS_SUCCESS,
10269 "Authentication failed");
10275 test_AES_GCM_authenticated_decryption_test_case_1(void)
10277 return test_authenticated_decryption(&gcm_test_case_1);
10281 test_AES_GCM_authenticated_decryption_test_case_2(void)
10283 return test_authenticated_decryption(&gcm_test_case_2);
10287 test_AES_GCM_authenticated_decryption_test_case_3(void)
10289 return test_authenticated_decryption(&gcm_test_case_3);
10293 test_AES_GCM_authenticated_decryption_test_case_4(void)
10295 return test_authenticated_decryption(&gcm_test_case_4);
10299 test_AES_GCM_authenticated_decryption_test_case_5(void)
10301 return test_authenticated_decryption(&gcm_test_case_5);
10305 test_AES_GCM_authenticated_decryption_test_case_6(void)
10307 return test_authenticated_decryption(&gcm_test_case_6);
10311 test_AES_GCM_authenticated_decryption_test_case_7(void)
10313 return test_authenticated_decryption(&gcm_test_case_7);
10317 test_AES_GCM_authenticated_decryption_test_case_8(void)
10319 return test_authenticated_decryption(&gcm_test_case_8);
10323 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10325 return test_authenticated_decryption(&gcm_J0_test_case_1);
10329 test_AES_GCM_auth_decryption_test_case_192_1(void)
10331 return test_authenticated_decryption(&gcm_test_case_192_1);
10335 test_AES_GCM_auth_decryption_test_case_192_2(void)
10337 return test_authenticated_decryption(&gcm_test_case_192_2);
10341 test_AES_GCM_auth_decryption_test_case_192_3(void)
10343 return test_authenticated_decryption(&gcm_test_case_192_3);
10347 test_AES_GCM_auth_decryption_test_case_192_4(void)
10349 return test_authenticated_decryption(&gcm_test_case_192_4);
10353 test_AES_GCM_auth_decryption_test_case_192_5(void)
10355 return test_authenticated_decryption(&gcm_test_case_192_5);
10359 test_AES_GCM_auth_decryption_test_case_192_6(void)
10361 return test_authenticated_decryption(&gcm_test_case_192_6);
10365 test_AES_GCM_auth_decryption_test_case_192_7(void)
10367 return test_authenticated_decryption(&gcm_test_case_192_7);
10371 test_AES_GCM_auth_decryption_test_case_256_1(void)
10373 return test_authenticated_decryption(&gcm_test_case_256_1);
10377 test_AES_GCM_auth_decryption_test_case_256_2(void)
10379 return test_authenticated_decryption(&gcm_test_case_256_2);
10383 test_AES_GCM_auth_decryption_test_case_256_3(void)
10385 return test_authenticated_decryption(&gcm_test_case_256_3);
10389 test_AES_GCM_auth_decryption_test_case_256_4(void)
10391 return test_authenticated_decryption(&gcm_test_case_256_4);
10395 test_AES_GCM_auth_decryption_test_case_256_5(void)
10397 return test_authenticated_decryption(&gcm_test_case_256_5);
10401 test_AES_GCM_auth_decryption_test_case_256_6(void)
10403 return test_authenticated_decryption(&gcm_test_case_256_6);
10407 test_AES_GCM_auth_decryption_test_case_256_7(void)
10409 return test_authenticated_decryption(&gcm_test_case_256_7);
10413 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10415 return test_authenticated_decryption(&gcm_test_case_aad_1);
10419 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10421 return test_authenticated_decryption(&gcm_test_case_aad_2);
10425 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10427 struct aead_test_data tdata;
10430 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10431 tdata.iv.data[0] += 1;
10432 res = test_authenticated_decryption(&tdata);
10433 if (res == TEST_SKIPPED)
10435 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10436 return TEST_SUCCESS;
10440 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10442 struct aead_test_data tdata;
10445 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10446 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10447 tdata.plaintext.data[0] += 1;
10448 res = test_authenticated_decryption(&tdata);
10449 if (res == TEST_SKIPPED)
10451 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10452 return TEST_SUCCESS;
10456 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10458 struct aead_test_data tdata;
10461 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10462 tdata.ciphertext.data[0] += 1;
10463 res = test_authenticated_decryption(&tdata);
10464 if (res == TEST_SKIPPED)
10466 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10467 return TEST_SUCCESS;
10471 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10473 struct aead_test_data tdata;
10476 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10477 tdata.aad.len += 1;
10478 res = test_authenticated_decryption(&tdata);
10479 if (res == TEST_SKIPPED)
10481 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10482 return TEST_SUCCESS;
10486 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10488 struct aead_test_data tdata;
10489 uint8_t aad[gcm_test_case_7.aad.len];
10492 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10493 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10495 tdata.aad.data = aad;
10496 res = test_authenticated_decryption(&tdata);
10497 if (res == TEST_SKIPPED)
10499 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10500 return TEST_SUCCESS;
10504 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10506 struct aead_test_data tdata;
10509 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10510 tdata.auth_tag.data[0] += 1;
10511 res = test_authenticated_decryption(&tdata);
10512 if (res == TEST_SKIPPED)
10514 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10515 return TEST_SUCCESS;
10519 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10521 struct crypto_testsuite_params *ts_params = &testsuite_params;
10522 struct crypto_unittest_params *ut_params = &unittest_params;
10525 uint8_t *ciphertext, *auth_tag;
10526 uint16_t plaintext_pad_len;
10527 struct rte_cryptodev_info dev_info;
10529 /* Verify the capabilities */
10530 struct rte_cryptodev_sym_capability_idx cap_idx;
10531 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10532 cap_idx.algo.aead = tdata->algo;
10533 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10535 return TEST_SKIPPED;
10537 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10538 uint64_t feat_flags = dev_info.feature_flags;
10540 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10541 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
10542 return TEST_SKIPPED;
10544 /* not supported with CPU crypto */
10545 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10546 return TEST_SKIPPED;
10548 /* Create AEAD session */
10549 retval = create_aead_session(ts_params->valid_devs[0],
10551 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10552 tdata->key.data, tdata->key.len,
10553 tdata->aad.len, tdata->auth_tag.len,
10558 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10559 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10561 /* clear mbuf payload */
10562 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10563 rte_pktmbuf_tailroom(ut_params->ibuf));
10564 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10565 rte_pktmbuf_tailroom(ut_params->obuf));
10567 /* Create AEAD operation */
10568 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10572 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10574 ut_params->op->sym->m_src = ut_params->ibuf;
10575 ut_params->op->sym->m_dst = ut_params->obuf;
10577 /* Process crypto operation */
10578 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10579 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10580 ut_params->op, 0, 0, 0, 0);
10582 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10583 ut_params->op), "failed to process sym crypto op");
10585 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10586 "crypto op processing failed");
10588 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10590 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10591 ut_params->op->sym->cipher.data.offset);
10592 auth_tag = ciphertext + plaintext_pad_len;
10594 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10595 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10597 /* Validate obuf */
10598 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10600 tdata->ciphertext.data,
10601 tdata->ciphertext.len,
10602 "Ciphertext data not as expected");
10604 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10606 tdata->auth_tag.data,
10607 tdata->auth_tag.len,
10608 "Generated auth tag not as expected");
10615 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10617 return test_authenticated_encryption_oop(&gcm_test_case_5);
10621 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10623 struct crypto_testsuite_params *ts_params = &testsuite_params;
10624 struct crypto_unittest_params *ut_params = &unittest_params;
10627 uint8_t *plaintext;
10628 struct rte_cryptodev_info dev_info;
10630 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10631 uint64_t feat_flags = dev_info.feature_flags;
10633 /* Verify the capabilities */
10634 struct rte_cryptodev_sym_capability_idx cap_idx;
10635 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10636 cap_idx.algo.aead = tdata->algo;
10637 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10639 return TEST_SKIPPED;
10641 /* not supported with CPU crypto and raw data-path APIs*/
10642 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10643 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10644 return TEST_SKIPPED;
10646 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10647 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10648 printf("Device does not support RAW data-path APIs.\n");
10649 return TEST_SKIPPED;
10652 /* Create AEAD session */
10653 retval = create_aead_session(ts_params->valid_devs[0],
10655 RTE_CRYPTO_AEAD_OP_DECRYPT,
10656 tdata->key.data, tdata->key.len,
10657 tdata->aad.len, tdata->auth_tag.len,
10662 /* alloc mbuf and set payload */
10663 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10664 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10666 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10667 rte_pktmbuf_tailroom(ut_params->ibuf));
10668 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10669 rte_pktmbuf_tailroom(ut_params->obuf));
10671 /* Create AEAD operation */
10672 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10676 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10678 ut_params->op->sym->m_src = ut_params->ibuf;
10679 ut_params->op->sym->m_dst = ut_params->obuf;
10681 /* Process crypto operation */
10682 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10683 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10684 ut_params->op, 0, 0, 0, 0);
10686 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10687 ut_params->op), "failed to process sym crypto op");
10689 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10690 "crypto op processing failed");
10692 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10693 ut_params->op->sym->cipher.data.offset);
10695 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10697 /* Validate obuf */
10698 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10700 tdata->plaintext.data,
10701 tdata->plaintext.len,
10702 "Plaintext data not as expected");
10704 TEST_ASSERT_EQUAL(ut_params->op->status,
10705 RTE_CRYPTO_OP_STATUS_SUCCESS,
10706 "Authentication failed");
10711 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10713 return test_authenticated_decryption_oop(&gcm_test_case_5);
10717 test_authenticated_encryption_sessionless(
10718 const struct aead_test_data *tdata)
10720 struct crypto_testsuite_params *ts_params = &testsuite_params;
10721 struct crypto_unittest_params *ut_params = &unittest_params;
10724 uint8_t *ciphertext, *auth_tag;
10725 uint16_t plaintext_pad_len;
10726 uint8_t key[tdata->key.len + 1];
10727 struct rte_cryptodev_info dev_info;
10729 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10730 uint64_t feat_flags = dev_info.feature_flags;
10732 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10733 printf("Device doesn't support Sessionless ops.\n");
10734 return TEST_SKIPPED;
10737 /* not supported with CPU crypto */
10738 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10739 return TEST_SKIPPED;
10741 /* Verify the capabilities */
10742 struct rte_cryptodev_sym_capability_idx cap_idx;
10743 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10744 cap_idx.algo.aead = tdata->algo;
10745 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10747 return TEST_SKIPPED;
10749 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10751 /* clear mbuf payload */
10752 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10753 rte_pktmbuf_tailroom(ut_params->ibuf));
10755 /* Create AEAD operation */
10756 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10760 /* Create GCM xform */
10761 memcpy(key, tdata->key.data, tdata->key.len);
10762 retval = create_aead_xform(ut_params->op,
10764 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10765 key, tdata->key.len,
10766 tdata->aad.len, tdata->auth_tag.len,
10771 ut_params->op->sym->m_src = ut_params->ibuf;
10773 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10774 RTE_CRYPTO_OP_SESSIONLESS,
10775 "crypto op session type not sessionless");
10777 /* Process crypto operation */
10778 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10779 ut_params->op), "failed to process sym crypto op");
10781 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10783 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10784 "crypto op status not success");
10786 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10788 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10789 ut_params->op->sym->cipher.data.offset);
10790 auth_tag = ciphertext + plaintext_pad_len;
10792 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10793 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10795 /* Validate obuf */
10796 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10798 tdata->ciphertext.data,
10799 tdata->ciphertext.len,
10800 "Ciphertext data not as expected");
10802 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10804 tdata->auth_tag.data,
10805 tdata->auth_tag.len,
10806 "Generated auth tag not as expected");
10813 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10815 return test_authenticated_encryption_sessionless(
10820 test_authenticated_decryption_sessionless(
10821 const struct aead_test_data *tdata)
10823 struct crypto_testsuite_params *ts_params = &testsuite_params;
10824 struct crypto_unittest_params *ut_params = &unittest_params;
10827 uint8_t *plaintext;
10828 uint8_t key[tdata->key.len + 1];
10829 struct rte_cryptodev_info dev_info;
10831 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10832 uint64_t feat_flags = dev_info.feature_flags;
10834 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10835 printf("Device doesn't support Sessionless ops.\n");
10836 return TEST_SKIPPED;
10839 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10840 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10841 printf("Device doesn't support RAW data-path APIs.\n");
10842 return TEST_SKIPPED;
10845 /* not supported with CPU crypto */
10846 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10847 return TEST_SKIPPED;
10849 /* Verify the capabilities */
10850 struct rte_cryptodev_sym_capability_idx cap_idx;
10851 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10852 cap_idx.algo.aead = tdata->algo;
10853 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10855 return TEST_SKIPPED;
10857 /* alloc mbuf and set payload */
10858 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10860 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10861 rte_pktmbuf_tailroom(ut_params->ibuf));
10863 /* Create AEAD operation */
10864 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10868 /* Create AEAD xform */
10869 memcpy(key, tdata->key.data, tdata->key.len);
10870 retval = create_aead_xform(ut_params->op,
10872 RTE_CRYPTO_AEAD_OP_DECRYPT,
10873 key, tdata->key.len,
10874 tdata->aad.len, tdata->auth_tag.len,
10879 ut_params->op->sym->m_src = ut_params->ibuf;
10881 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10882 RTE_CRYPTO_OP_SESSIONLESS,
10883 "crypto op session type not sessionless");
10885 /* Process crypto operation */
10886 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10887 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10888 ut_params->op, 0, 0, 0, 0);
10890 TEST_ASSERT_NOT_NULL(process_crypto_request(
10891 ts_params->valid_devs[0], ut_params->op),
10892 "failed to process sym crypto op");
10894 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10896 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10897 "crypto op status not success");
10899 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10900 ut_params->op->sym->cipher.data.offset);
10902 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10904 /* Validate obuf */
10905 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10907 tdata->plaintext.data,
10908 tdata->plaintext.len,
10909 "Plaintext data not as expected");
10911 TEST_ASSERT_EQUAL(ut_params->op->status,
10912 RTE_CRYPTO_OP_STATUS_SUCCESS,
10913 "Authentication failed");
10918 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10920 return test_authenticated_decryption_sessionless(
10925 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10927 return test_authenticated_encryption(&ccm_test_case_128_1);
10931 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10933 return test_authenticated_encryption(&ccm_test_case_128_2);
10937 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10939 return test_authenticated_encryption(&ccm_test_case_128_3);
10943 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10945 return test_authenticated_decryption(&ccm_test_case_128_1);
10949 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10951 return test_authenticated_decryption(&ccm_test_case_128_2);
10955 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10957 return test_authenticated_decryption(&ccm_test_case_128_3);
10961 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10963 return test_authenticated_encryption(&ccm_test_case_192_1);
10967 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10969 return test_authenticated_encryption(&ccm_test_case_192_2);
10973 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10975 return test_authenticated_encryption(&ccm_test_case_192_3);
10979 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10981 return test_authenticated_decryption(&ccm_test_case_192_1);
10985 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10987 return test_authenticated_decryption(&ccm_test_case_192_2);
10991 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10993 return test_authenticated_decryption(&ccm_test_case_192_3);
10997 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10999 return test_authenticated_encryption(&ccm_test_case_256_1);
11003 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
11005 return test_authenticated_encryption(&ccm_test_case_256_2);
11009 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
11011 return test_authenticated_encryption(&ccm_test_case_256_3);
11015 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
11017 return test_authenticated_decryption(&ccm_test_case_256_1);
11021 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
11023 return test_authenticated_decryption(&ccm_test_case_256_2);
11027 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
11029 return test_authenticated_decryption(&ccm_test_case_256_3);
11035 struct crypto_testsuite_params *ts_params = &testsuite_params;
11036 struct rte_cryptodev_stats stats;
11038 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11039 return TEST_SKIPPED;
11041 /* Verify the capabilities */
11042 struct rte_cryptodev_sym_capability_idx cap_idx;
11043 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11044 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11045 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11047 return TEST_SKIPPED;
11048 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11049 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11050 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11052 return TEST_SKIPPED;
11054 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11056 return TEST_SKIPPED;
11058 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11059 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11060 &stats) == -ENODEV),
11061 "rte_cryptodev_stats_get invalid dev failed");
11062 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11063 "rte_cryptodev_stats_get invalid Param failed");
11065 /* Test expected values */
11066 test_AES_CBC_HMAC_SHA1_encrypt_digest();
11067 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11069 "rte_cryptodev_stats_get failed");
11070 TEST_ASSERT((stats.enqueued_count == 1),
11071 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11072 TEST_ASSERT((stats.dequeued_count == 1),
11073 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11074 TEST_ASSERT((stats.enqueue_err_count == 0),
11075 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11076 TEST_ASSERT((stats.dequeue_err_count == 0),
11077 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11079 /* invalid device but should ignore and not reset device stats*/
11080 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11081 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11083 "rte_cryptodev_stats_get failed");
11084 TEST_ASSERT((stats.enqueued_count == 1),
11085 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11087 /* check that a valid reset clears stats */
11088 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11089 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11091 "rte_cryptodev_stats_get failed");
11092 TEST_ASSERT((stats.enqueued_count == 0),
11093 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11094 TEST_ASSERT((stats.dequeued_count == 0),
11095 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11097 return TEST_SUCCESS;
11100 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11101 struct crypto_unittest_params *ut_params,
11102 enum rte_crypto_auth_operation op,
11103 const struct HMAC_MD5_vector *test_case)
11107 memcpy(key, test_case->key.data, test_case->key.len);
11109 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11110 ut_params->auth_xform.next = NULL;
11111 ut_params->auth_xform.auth.op = op;
11113 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11115 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11116 ut_params->auth_xform.auth.key.length = test_case->key.len;
11117 ut_params->auth_xform.auth.key.data = key;
11119 ut_params->sess = rte_cryptodev_sym_session_create(
11120 ts_params->session_mpool);
11122 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11123 ut_params->sess, &ut_params->auth_xform,
11124 ts_params->session_priv_mpool);
11126 if (ut_params->sess == NULL)
11127 return TEST_FAILED;
11129 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11131 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11132 rte_pktmbuf_tailroom(ut_params->ibuf));
11137 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11138 const struct HMAC_MD5_vector *test_case,
11139 uint8_t **plaintext)
11141 uint16_t plaintext_pad_len;
11143 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11145 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11148 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11149 plaintext_pad_len);
11150 memcpy(*plaintext, test_case->plaintext.data,
11151 test_case->plaintext.len);
11153 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11154 ut_params->ibuf, MD5_DIGEST_LEN);
11155 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11156 "no room to append digest");
11157 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11158 ut_params->ibuf, plaintext_pad_len);
11160 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11161 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11162 test_case->auth_tag.len);
11165 sym_op->auth.data.offset = 0;
11166 sym_op->auth.data.length = test_case->plaintext.len;
11168 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11169 ut_params->op->sym->m_src = ut_params->ibuf;
11175 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11177 uint16_t plaintext_pad_len;
11178 uint8_t *plaintext, *auth_tag;
11180 struct crypto_testsuite_params *ts_params = &testsuite_params;
11181 struct crypto_unittest_params *ut_params = &unittest_params;
11182 struct rte_cryptodev_info dev_info;
11184 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11185 uint64_t feat_flags = dev_info.feature_flags;
11187 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11188 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11189 printf("Device doesn't support RAW data-path APIs.\n");
11190 return TEST_SKIPPED;
11193 /* Verify the capabilities */
11194 struct rte_cryptodev_sym_capability_idx cap_idx;
11195 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11196 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11197 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11199 return TEST_SKIPPED;
11201 if (MD5_HMAC_create_session(ts_params, ut_params,
11202 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11203 return TEST_FAILED;
11205 /* Generate Crypto op data structure */
11206 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11207 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11208 TEST_ASSERT_NOT_NULL(ut_params->op,
11209 "Failed to allocate symmetric crypto operation struct");
11211 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11214 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11215 return TEST_FAILED;
11217 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11218 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11220 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11221 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11222 ut_params->op, 0, 1, 0, 0);
11224 TEST_ASSERT_NOT_NULL(
11225 process_crypto_request(ts_params->valid_devs[0],
11227 "failed to process sym crypto op");
11229 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11230 "crypto op processing failed");
11232 if (ut_params->op->sym->m_dst) {
11233 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11234 uint8_t *, plaintext_pad_len);
11236 auth_tag = plaintext + plaintext_pad_len;
11239 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11241 test_case->auth_tag.data,
11242 test_case->auth_tag.len,
11243 "HMAC_MD5 generated tag not as expected");
11245 return TEST_SUCCESS;
11249 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11251 uint8_t *plaintext;
11253 struct crypto_testsuite_params *ts_params = &testsuite_params;
11254 struct crypto_unittest_params *ut_params = &unittest_params;
11255 struct rte_cryptodev_info dev_info;
11257 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11258 uint64_t feat_flags = dev_info.feature_flags;
11260 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11261 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11262 printf("Device doesn't support RAW data-path APIs.\n");
11263 return TEST_SKIPPED;
11266 /* Verify the capabilities */
11267 struct rte_cryptodev_sym_capability_idx cap_idx;
11268 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11269 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11270 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11272 return TEST_SKIPPED;
11274 if (MD5_HMAC_create_session(ts_params, ut_params,
11275 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11276 return TEST_FAILED;
11279 /* Generate Crypto op data structure */
11280 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11281 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11282 TEST_ASSERT_NOT_NULL(ut_params->op,
11283 "Failed to allocate symmetric crypto operation struct");
11285 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11286 return TEST_FAILED;
11288 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11289 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11291 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11292 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11293 ut_params->op, 0, 1, 0, 0);
11295 TEST_ASSERT_NOT_NULL(
11296 process_crypto_request(ts_params->valid_devs[0],
11298 "failed to process sym crypto op");
11300 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11301 "HMAC_MD5 crypto op processing failed");
11303 return TEST_SUCCESS;
11307 test_MD5_HMAC_generate_case_1(void)
11309 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11313 test_MD5_HMAC_verify_case_1(void)
11315 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11319 test_MD5_HMAC_generate_case_2(void)
11321 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11325 test_MD5_HMAC_verify_case_2(void)
11327 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11331 test_multi_session(void)
11333 struct crypto_testsuite_params *ts_params = &testsuite_params;
11334 struct crypto_unittest_params *ut_params = &unittest_params;
11336 struct rte_cryptodev_info dev_info;
11337 struct rte_cryptodev_sym_session **sessions;
11341 /* Verify the capabilities */
11342 struct rte_cryptodev_sym_capability_idx cap_idx;
11343 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11344 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11345 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11347 return TEST_SKIPPED;
11348 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11349 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11350 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11352 return TEST_SKIPPED;
11354 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11355 aes_cbc_key, hmac_sha512_key);
11358 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11360 sessions = rte_malloc(NULL,
11361 sizeof(struct rte_cryptodev_sym_session *) *
11362 (MAX_NB_SESSIONS + 1), 0);
11364 /* Create multiple crypto sessions*/
11365 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11367 sessions[i] = rte_cryptodev_sym_session_create(
11368 ts_params->session_mpool);
11370 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11371 sessions[i], &ut_params->auth_xform,
11372 ts_params->session_priv_mpool);
11373 TEST_ASSERT_NOT_NULL(sessions[i],
11374 "Session creation failed at session number %u",
11377 /* Attempt to send a request on each session */
11378 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11382 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11383 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11385 "Failed to perform decrypt on request number %u.", i);
11386 /* free crypto operation structure */
11388 rte_crypto_op_free(ut_params->op);
11391 * free mbuf - both obuf and ibuf are usually the same,
11392 * so check if they point at the same address is necessary,
11393 * to avoid freeing the mbuf twice.
11395 if (ut_params->obuf) {
11396 rte_pktmbuf_free(ut_params->obuf);
11397 if (ut_params->ibuf == ut_params->obuf)
11398 ut_params->ibuf = 0;
11399 ut_params->obuf = 0;
11401 if (ut_params->ibuf) {
11402 rte_pktmbuf_free(ut_params->ibuf);
11403 ut_params->ibuf = 0;
11407 sessions[i] = NULL;
11408 /* Next session create should fail */
11409 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11410 sessions[i], &ut_params->auth_xform,
11411 ts_params->session_priv_mpool);
11412 TEST_ASSERT_NULL(sessions[i],
11413 "Session creation succeeded unexpectedly!");
11415 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11416 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11418 rte_cryptodev_sym_session_free(sessions[i]);
11421 rte_free(sessions);
11423 return TEST_SUCCESS;
11426 struct multi_session_params {
11427 struct crypto_unittest_params ut_params;
11428 uint8_t *cipher_key;
11430 const uint8_t *cipher;
11431 const uint8_t *digest;
11435 #define MB_SESSION_NUMBER 3
11438 test_multi_session_random_usage(void)
11440 struct crypto_testsuite_params *ts_params = &testsuite_params;
11441 struct rte_cryptodev_info dev_info;
11442 struct rte_cryptodev_sym_session **sessions;
11444 struct multi_session_params ut_paramz[] = {
11447 .cipher_key = ms_aes_cbc_key0,
11448 .hmac_key = ms_hmac_key0,
11449 .cipher = ms_aes_cbc_cipher0,
11450 .digest = ms_hmac_digest0,
11451 .iv = ms_aes_cbc_iv0
11454 .cipher_key = ms_aes_cbc_key1,
11455 .hmac_key = ms_hmac_key1,
11456 .cipher = ms_aes_cbc_cipher1,
11457 .digest = ms_hmac_digest1,
11458 .iv = ms_aes_cbc_iv1
11461 .cipher_key = ms_aes_cbc_key2,
11462 .hmac_key = ms_hmac_key2,
11463 .cipher = ms_aes_cbc_cipher2,
11464 .digest = ms_hmac_digest2,
11465 .iv = ms_aes_cbc_iv2
11470 /* Verify the capabilities */
11471 struct rte_cryptodev_sym_capability_idx cap_idx;
11472 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11473 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11474 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11476 return TEST_SKIPPED;
11477 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11478 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11479 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11481 return TEST_SKIPPED;
11483 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11485 sessions = rte_malloc(NULL,
11486 (sizeof(struct rte_cryptodev_sym_session *)
11487 * MAX_NB_SESSIONS) + 1, 0);
11489 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11490 sessions[i] = rte_cryptodev_sym_session_create(
11491 ts_params->session_mpool);
11493 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11494 sizeof(struct crypto_unittest_params));
11496 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11497 &ut_paramz[i].ut_params,
11498 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11500 /* Create multiple crypto sessions*/
11501 rte_cryptodev_sym_session_init(
11502 ts_params->valid_devs[0],
11504 &ut_paramz[i].ut_params.auth_xform,
11505 ts_params->session_priv_mpool);
11507 TEST_ASSERT_NOT_NULL(sessions[i],
11508 "Session creation failed at session number %u",
11514 for (i = 0; i < 40000; i++) {
11516 j = rand() % MB_SESSION_NUMBER;
11518 TEST_ASSERT_SUCCESS(
11519 test_AES_CBC_HMAC_SHA512_decrypt_perform(
11521 &ut_paramz[j].ut_params,
11522 ts_params, ut_paramz[j].cipher,
11523 ut_paramz[j].digest,
11525 "Failed to perform decrypt on request number %u.", i);
11527 if (ut_paramz[j].ut_params.op)
11528 rte_crypto_op_free(ut_paramz[j].ut_params.op);
11531 * free mbuf - both obuf and ibuf are usually the same,
11532 * so check if they point at the same address is necessary,
11533 * to avoid freeing the mbuf twice.
11535 if (ut_paramz[j].ut_params.obuf) {
11536 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11537 if (ut_paramz[j].ut_params.ibuf
11538 == ut_paramz[j].ut_params.obuf)
11539 ut_paramz[j].ut_params.ibuf = 0;
11540 ut_paramz[j].ut_params.obuf = 0;
11542 if (ut_paramz[j].ut_params.ibuf) {
11543 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11544 ut_paramz[j].ut_params.ibuf = 0;
11548 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11549 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11551 rte_cryptodev_sym_session_free(sessions[i]);
11554 rte_free(sessions);
11556 return TEST_SUCCESS;
11559 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11560 0xab, 0xab, 0xab, 0xab,
11561 0xab, 0xab, 0xab, 0xab,
11562 0xab, 0xab, 0xab, 0xab};
11565 test_null_invalid_operation(void)
11567 struct crypto_testsuite_params *ts_params = &testsuite_params;
11568 struct crypto_unittest_params *ut_params = &unittest_params;
11571 /* This test is for NULL PMD only */
11572 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11573 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11574 return TEST_SKIPPED;
11576 /* Setup Cipher Parameters */
11577 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11578 ut_params->cipher_xform.next = NULL;
11580 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11581 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11583 ut_params->sess = rte_cryptodev_sym_session_create(
11584 ts_params->session_mpool);
11586 /* Create Crypto session*/
11587 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11588 ut_params->sess, &ut_params->cipher_xform,
11589 ts_params->session_priv_mpool);
11590 TEST_ASSERT(ret < 0,
11591 "Session creation succeeded unexpectedly");
11594 /* Setup HMAC Parameters */
11595 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11596 ut_params->auth_xform.next = NULL;
11598 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11599 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11601 ut_params->sess = rte_cryptodev_sym_session_create(
11602 ts_params->session_mpool);
11604 /* Create Crypto session*/
11605 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11606 ut_params->sess, &ut_params->auth_xform,
11607 ts_params->session_priv_mpool);
11608 TEST_ASSERT(ret < 0,
11609 "Session creation succeeded unexpectedly");
11611 return TEST_SUCCESS;
11615 #define NULL_BURST_LENGTH (32)
11618 test_null_burst_operation(void)
11620 struct crypto_testsuite_params *ts_params = &testsuite_params;
11621 struct crypto_unittest_params *ut_params = &unittest_params;
11623 unsigned i, burst_len = NULL_BURST_LENGTH;
11625 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11626 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11628 /* This test is for NULL PMD only */
11629 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11630 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11631 return TEST_SKIPPED;
11633 /* Setup Cipher Parameters */
11634 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11635 ut_params->cipher_xform.next = &ut_params->auth_xform;
11637 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11638 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11640 /* Setup HMAC Parameters */
11641 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11642 ut_params->auth_xform.next = NULL;
11644 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11645 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11647 ut_params->sess = rte_cryptodev_sym_session_create(
11648 ts_params->session_mpool);
11650 /* Create Crypto session*/
11651 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11652 ut_params->sess, &ut_params->cipher_xform,
11653 ts_params->session_priv_mpool);
11654 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11656 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11657 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11658 burst_len, "failed to generate burst of crypto ops");
11660 /* Generate an operation for each mbuf in burst */
11661 for (i = 0; i < burst_len; i++) {
11662 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11664 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11666 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11670 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11672 burst[i]->sym->m_src = m;
11675 /* Process crypto operation */
11676 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11677 0, burst, burst_len),
11679 "Error enqueuing burst");
11681 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11682 0, burst_dequeued, burst_len),
11684 "Error dequeuing burst");
11687 for (i = 0; i < burst_len; i++) {
11689 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11690 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11692 "data not as expected");
11694 rte_pktmbuf_free(burst[i]->sym->m_src);
11695 rte_crypto_op_free(burst[i]);
11698 return TEST_SUCCESS;
11702 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11703 uint16_t nb_ops, void *user_param)
11705 RTE_SET_USED(dev_id);
11706 RTE_SET_USED(qp_id);
11708 RTE_SET_USED(user_param);
11710 printf("crypto enqueue callback called\n");
11715 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11716 uint16_t nb_ops, void *user_param)
11718 RTE_SET_USED(dev_id);
11719 RTE_SET_USED(qp_id);
11721 RTE_SET_USED(user_param);
11723 printf("crypto dequeue callback called\n");
11728 * Thread using enqueue/dequeue callback with RCU.
11731 test_enqdeq_callback_thread(void *arg)
11734 /* DP thread calls rte_cryptodev_enqueue_burst()/
11735 * rte_cryptodev_dequeue_burst() and invokes callback.
11737 test_null_burst_operation();
11742 test_enq_callback_setup(void)
11744 struct crypto_testsuite_params *ts_params = &testsuite_params;
11745 struct rte_cryptodev_info dev_info;
11746 struct rte_cryptodev_qp_conf qp_conf = {
11747 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11750 struct rte_cryptodev_cb *cb;
11751 uint16_t qp_id = 0;
11753 /* Stop the device in case it's started so it can be configured */
11754 rte_cryptodev_stop(ts_params->valid_devs[0]);
11756 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11758 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11760 "Failed to configure cryptodev %u",
11761 ts_params->valid_devs[0]);
11763 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11764 qp_conf.mp_session = ts_params->session_mpool;
11765 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11767 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11768 ts_params->valid_devs[0], qp_id, &qp_conf,
11769 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11771 "rte_cryptodev_queue_pair_setup: num_inflights "
11772 "%u on qp %u on cryptodev %u",
11773 qp_conf.nb_descriptors, qp_id,
11774 ts_params->valid_devs[0]);
11776 /* Test with invalid crypto device */
11777 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11778 qp_id, test_enq_callback, NULL);
11779 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11780 "cryptodev %u did not fail",
11781 qp_id, RTE_CRYPTO_MAX_DEVS);
11783 /* Test with invalid queue pair */
11784 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11785 dev_info.max_nb_queue_pairs + 1,
11786 test_enq_callback, NULL);
11787 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11788 "cryptodev %u did not fail",
11789 dev_info.max_nb_queue_pairs + 1,
11790 ts_params->valid_devs[0]);
11792 /* Test with NULL callback */
11793 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11794 qp_id, NULL, NULL);
11795 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11796 "cryptodev %u did not fail",
11797 qp_id, ts_params->valid_devs[0]);
11799 /* Test with valid configuration */
11800 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11801 qp_id, test_enq_callback, NULL);
11802 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11803 "qp %u on cryptodev %u",
11804 qp_id, ts_params->valid_devs[0]);
11806 rte_cryptodev_start(ts_params->valid_devs[0]);
11808 /* Launch a thread */
11809 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11810 rte_get_next_lcore(-1, 1, 0));
11812 /* Wait until reader exited. */
11813 rte_eal_mp_wait_lcore();
11815 /* Test with invalid crypto device */
11816 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11817 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11818 "Expected call to fail as crypto device is invalid");
11820 /* Test with invalid queue pair */
11821 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11822 ts_params->valid_devs[0],
11823 dev_info.max_nb_queue_pairs + 1, cb),
11824 "Expected call to fail as queue pair is invalid");
11826 /* Test with NULL callback */
11827 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11828 ts_params->valid_devs[0], qp_id, NULL),
11829 "Expected call to fail as callback is NULL");
11831 /* Test with valid configuration */
11832 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11833 ts_params->valid_devs[0], qp_id, cb),
11834 "Failed test to remove callback on "
11835 "qp %u on cryptodev %u",
11836 qp_id, ts_params->valid_devs[0]);
11838 return TEST_SUCCESS;
11842 test_deq_callback_setup(void)
11844 struct crypto_testsuite_params *ts_params = &testsuite_params;
11845 struct rte_cryptodev_info dev_info;
11846 struct rte_cryptodev_qp_conf qp_conf = {
11847 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11850 struct rte_cryptodev_cb *cb;
11851 uint16_t qp_id = 0;
11853 /* Stop the device in case it's started so it can be configured */
11854 rte_cryptodev_stop(ts_params->valid_devs[0]);
11856 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11858 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11860 "Failed to configure cryptodev %u",
11861 ts_params->valid_devs[0]);
11863 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11864 qp_conf.mp_session = ts_params->session_mpool;
11865 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11867 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11868 ts_params->valid_devs[0], qp_id, &qp_conf,
11869 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11871 "rte_cryptodev_queue_pair_setup: num_inflights "
11872 "%u on qp %u on cryptodev %u",
11873 qp_conf.nb_descriptors, qp_id,
11874 ts_params->valid_devs[0]);
11876 /* Test with invalid crypto device */
11877 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11878 qp_id, test_deq_callback, NULL);
11879 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11880 "cryptodev %u did not fail",
11881 qp_id, RTE_CRYPTO_MAX_DEVS);
11883 /* Test with invalid queue pair */
11884 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11885 dev_info.max_nb_queue_pairs + 1,
11886 test_deq_callback, NULL);
11887 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11888 "cryptodev %u did not fail",
11889 dev_info.max_nb_queue_pairs + 1,
11890 ts_params->valid_devs[0]);
11892 /* Test with NULL callback */
11893 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11894 qp_id, NULL, NULL);
11895 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11896 "cryptodev %u did not fail",
11897 qp_id, ts_params->valid_devs[0]);
11899 /* Test with valid configuration */
11900 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11901 qp_id, test_deq_callback, NULL);
11902 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11903 "qp %u on cryptodev %u",
11904 qp_id, ts_params->valid_devs[0]);
11906 rte_cryptodev_start(ts_params->valid_devs[0]);
11908 /* Launch a thread */
11909 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11910 rte_get_next_lcore(-1, 1, 0));
11912 /* Wait until reader exited. */
11913 rte_eal_mp_wait_lcore();
11915 /* Test with invalid crypto device */
11916 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11917 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11918 "Expected call to fail as crypto device is invalid");
11920 /* Test with invalid queue pair */
11921 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11922 ts_params->valid_devs[0],
11923 dev_info.max_nb_queue_pairs + 1, cb),
11924 "Expected call to fail as queue pair is invalid");
11926 /* Test with NULL callback */
11927 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11928 ts_params->valid_devs[0], qp_id, NULL),
11929 "Expected call to fail as callback is NULL");
11931 /* Test with valid configuration */
11932 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11933 ts_params->valid_devs[0], qp_id, cb),
11934 "Failed test to remove callback on "
11935 "qp %u on cryptodev %u",
11936 qp_id, ts_params->valid_devs[0]);
11938 return TEST_SUCCESS;
11942 generate_gmac_large_plaintext(uint8_t *data)
11946 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11947 memcpy(&data[i], &data[0], 32);
11951 create_gmac_operation(enum rte_crypto_auth_operation op,
11952 const struct gmac_test_data *tdata)
11954 struct crypto_testsuite_params *ts_params = &testsuite_params;
11955 struct crypto_unittest_params *ut_params = &unittest_params;
11956 struct rte_crypto_sym_op *sym_op;
11958 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11960 /* Generate Crypto op data structure */
11961 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11962 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11963 TEST_ASSERT_NOT_NULL(ut_params->op,
11964 "Failed to allocate symmetric crypto operation struct");
11966 sym_op = ut_params->op->sym;
11968 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11969 ut_params->ibuf, tdata->gmac_tag.len);
11970 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11971 "no room to append digest");
11973 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11974 ut_params->ibuf, plaintext_pad_len);
11976 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11977 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11978 tdata->gmac_tag.len);
11979 debug_hexdump(stdout, "digest:",
11980 sym_op->auth.digest.data,
11981 tdata->gmac_tag.len);
11984 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11985 uint8_t *, IV_OFFSET);
11987 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11989 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11991 sym_op->cipher.data.length = 0;
11992 sym_op->cipher.data.offset = 0;
11994 sym_op->auth.data.offset = 0;
11995 sym_op->auth.data.length = tdata->plaintext.len;
12001 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
12002 const struct gmac_test_data *tdata,
12003 void *digest_mem, uint64_t digest_phys)
12005 struct crypto_testsuite_params *ts_params = &testsuite_params;
12006 struct crypto_unittest_params *ut_params = &unittest_params;
12007 struct rte_crypto_sym_op *sym_op;
12009 /* Generate Crypto op data structure */
12010 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12011 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12012 TEST_ASSERT_NOT_NULL(ut_params->op,
12013 "Failed to allocate symmetric crypto operation struct");
12015 sym_op = ut_params->op->sym;
12017 sym_op->auth.digest.data = digest_mem;
12018 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12019 "no room to append digest");
12021 sym_op->auth.digest.phys_addr = digest_phys;
12023 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12024 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12025 tdata->gmac_tag.len);
12026 debug_hexdump(stdout, "digest:",
12027 sym_op->auth.digest.data,
12028 tdata->gmac_tag.len);
12031 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12032 uint8_t *, IV_OFFSET);
12034 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12036 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12038 sym_op->cipher.data.length = 0;
12039 sym_op->cipher.data.offset = 0;
12041 sym_op->auth.data.offset = 0;
12042 sym_op->auth.data.length = tdata->plaintext.len;
12047 static int create_gmac_session(uint8_t dev_id,
12048 const struct gmac_test_data *tdata,
12049 enum rte_crypto_auth_operation auth_op)
12051 uint8_t auth_key[tdata->key.len];
12053 struct crypto_testsuite_params *ts_params = &testsuite_params;
12054 struct crypto_unittest_params *ut_params = &unittest_params;
12056 memcpy(auth_key, tdata->key.data, tdata->key.len);
12058 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12059 ut_params->auth_xform.next = NULL;
12061 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12062 ut_params->auth_xform.auth.op = auth_op;
12063 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12064 ut_params->auth_xform.auth.key.length = tdata->key.len;
12065 ut_params->auth_xform.auth.key.data = auth_key;
12066 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12067 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12070 ut_params->sess = rte_cryptodev_sym_session_create(
12071 ts_params->session_mpool);
12073 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12074 &ut_params->auth_xform,
12075 ts_params->session_priv_mpool);
12077 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12083 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12085 struct crypto_testsuite_params *ts_params = &testsuite_params;
12086 struct crypto_unittest_params *ut_params = &unittest_params;
12087 struct rte_cryptodev_info dev_info;
12089 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12090 uint64_t feat_flags = dev_info.feature_flags;
12092 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12093 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12094 printf("Device doesn't support RAW data-path APIs.\n");
12095 return TEST_SKIPPED;
12100 uint8_t *auth_tag, *plaintext;
12101 uint16_t plaintext_pad_len;
12103 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12104 "No GMAC length in the source data");
12106 /* Verify the capabilities */
12107 struct rte_cryptodev_sym_capability_idx cap_idx;
12108 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12109 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12110 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12112 return TEST_SKIPPED;
12114 retval = create_gmac_session(ts_params->valid_devs[0],
12115 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12120 if (tdata->plaintext.len > MBUF_SIZE)
12121 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12123 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12124 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12125 "Failed to allocate input buffer in mempool");
12127 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12128 rte_pktmbuf_tailroom(ut_params->ibuf));
12130 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12132 * Runtime generate the large plain text instead of use hard code
12133 * plain text vector. It is done to avoid create huge source file
12134 * with the test vector.
12136 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12137 generate_gmac_large_plaintext(tdata->plaintext.data);
12139 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12140 plaintext_pad_len);
12141 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12143 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12144 debug_hexdump(stdout, "plaintext:", plaintext,
12145 tdata->plaintext.len);
12147 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12153 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12155 ut_params->op->sym->m_src = ut_params->ibuf;
12157 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12158 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12160 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12161 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12162 ut_params->op, 0, 1, 0, 0);
12164 TEST_ASSERT_NOT_NULL(
12165 process_crypto_request(ts_params->valid_devs[0],
12166 ut_params->op), "failed to process sym crypto op");
12168 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12169 "crypto op processing failed");
12171 if (ut_params->op->sym->m_dst) {
12172 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12173 uint8_t *, plaintext_pad_len);
12175 auth_tag = plaintext + plaintext_pad_len;
12178 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12180 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12182 tdata->gmac_tag.data,
12183 tdata->gmac_tag.len,
12184 "GMAC Generated auth tag not as expected");
12190 test_AES_GMAC_authentication_test_case_1(void)
12192 return test_AES_GMAC_authentication(&gmac_test_case_1);
12196 test_AES_GMAC_authentication_test_case_2(void)
12198 return test_AES_GMAC_authentication(&gmac_test_case_2);
12202 test_AES_GMAC_authentication_test_case_3(void)
12204 return test_AES_GMAC_authentication(&gmac_test_case_3);
12208 test_AES_GMAC_authentication_test_case_4(void)
12210 return test_AES_GMAC_authentication(&gmac_test_case_4);
12214 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12216 struct crypto_testsuite_params *ts_params = &testsuite_params;
12217 struct crypto_unittest_params *ut_params = &unittest_params;
12219 uint32_t plaintext_pad_len;
12220 uint8_t *plaintext;
12221 struct rte_cryptodev_info dev_info;
12223 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12224 uint64_t feat_flags = dev_info.feature_flags;
12226 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12227 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12228 printf("Device doesn't support RAW data-path APIs.\n");
12229 return TEST_SKIPPED;
12232 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12233 "No GMAC length in the source data");
12235 /* Verify the capabilities */
12236 struct rte_cryptodev_sym_capability_idx cap_idx;
12237 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12238 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12239 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12241 return TEST_SKIPPED;
12243 retval = create_gmac_session(ts_params->valid_devs[0],
12244 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12249 if (tdata->plaintext.len > MBUF_SIZE)
12250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12252 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12253 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12254 "Failed to allocate input buffer in mempool");
12256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12257 rte_pktmbuf_tailroom(ut_params->ibuf));
12259 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12262 * Runtime generate the large plain text instead of use hard code
12263 * plain text vector. It is done to avoid create huge source file
12264 * with the test vector.
12266 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12267 generate_gmac_large_plaintext(tdata->plaintext.data);
12269 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12270 plaintext_pad_len);
12271 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12273 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12274 debug_hexdump(stdout, "plaintext:", plaintext,
12275 tdata->plaintext.len);
12277 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
12283 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12285 ut_params->op->sym->m_src = ut_params->ibuf;
12287 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12288 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12290 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12291 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12292 ut_params->op, 0, 1, 0, 0);
12294 TEST_ASSERT_NOT_NULL(
12295 process_crypto_request(ts_params->valid_devs[0],
12296 ut_params->op), "failed to process sym crypto op");
12298 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12299 "crypto op processing failed");
12306 test_AES_GMAC_authentication_verify_test_case_1(void)
12308 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12312 test_AES_GMAC_authentication_verify_test_case_2(void)
12314 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12318 test_AES_GMAC_authentication_verify_test_case_3(void)
12320 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12324 test_AES_GMAC_authentication_verify_test_case_4(void)
12326 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12330 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12333 struct crypto_testsuite_params *ts_params = &testsuite_params;
12334 struct crypto_unittest_params *ut_params = &unittest_params;
12335 struct rte_cryptodev_info dev_info;
12336 uint64_t feature_flags;
12337 unsigned int trn_data = 0;
12338 void *digest_mem = NULL;
12340 unsigned int to_trn = 0;
12341 struct rte_mbuf *buf = NULL;
12342 uint8_t *auth_tag, *plaintext;
12345 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12346 "No GMAC length in the source data");
12348 /* Verify the capabilities */
12349 struct rte_cryptodev_sym_capability_idx cap_idx;
12350 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12351 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12352 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12354 return TEST_SKIPPED;
12356 /* Check for any input SGL support */
12357 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12358 feature_flags = dev_info.feature_flags;
12360 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12361 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12362 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12363 return TEST_SKIPPED;
12365 if (fragsz > tdata->plaintext.len)
12366 fragsz = tdata->plaintext.len;
12368 uint16_t plaintext_len = fragsz;
12370 retval = create_gmac_session(ts_params->valid_devs[0],
12371 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12377 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12378 "Failed to allocate input buffer in mempool");
12380 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12381 rte_pktmbuf_tailroom(ut_params->ibuf));
12383 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12385 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12387 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12389 trn_data += plaintext_len;
12391 buf = ut_params->ibuf;
12394 * Loop until no more fragments
12397 while (trn_data < tdata->plaintext.len) {
12399 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12400 (tdata->plaintext.len - trn_data) : fragsz;
12402 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12405 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12406 rte_pktmbuf_tailroom(buf));
12408 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12411 memcpy(plaintext, tdata->plaintext.data + trn_data,
12413 trn_data += to_trn;
12414 if (trn_data == tdata->plaintext.len)
12415 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12416 tdata->gmac_tag.len);
12418 ut_params->ibuf->nb_segs = segs;
12421 * Place digest at the end of the last buffer
12423 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12426 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12427 + tdata->gmac_tag.len);
12428 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12429 tdata->plaintext.len);
12432 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12433 tdata, digest_mem, digest_phys);
12438 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12440 ut_params->op->sym->m_src = ut_params->ibuf;
12442 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12443 return TEST_SKIPPED;
12445 TEST_ASSERT_NOT_NULL(
12446 process_crypto_request(ts_params->valid_devs[0],
12447 ut_params->op), "failed to process sym crypto op");
12449 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12450 "crypto op processing failed");
12452 auth_tag = digest_mem;
12453 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12456 tdata->gmac_tag.data,
12457 tdata->gmac_tag.len,
12458 "GMAC Generated auth tag not as expected");
12463 /* Segment size not multiple of block size (16B) */
12465 test_AES_GMAC_authentication_SGL_40B(void)
12467 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12471 test_AES_GMAC_authentication_SGL_80B(void)
12473 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12477 test_AES_GMAC_authentication_SGL_2048B(void)
12479 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12482 /* Segment size not multiple of block size (16B) */
12484 test_AES_GMAC_authentication_SGL_2047B(void)
12486 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12489 struct test_crypto_vector {
12490 enum rte_crypto_cipher_algorithm crypto_algo;
12491 unsigned int cipher_offset;
12492 unsigned int cipher_len;
12505 const uint8_t *data;
12510 const uint8_t *data;
12514 enum rte_crypto_auth_algorithm auth_algo;
12515 unsigned int auth_offset;
12523 const uint8_t *data;
12533 static const struct test_crypto_vector
12534 hmac_sha1_test_crypto_vector = {
12535 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12537 .data = plaintext_hash,
12542 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12543 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12544 0xDE, 0xF4, 0xDE, 0xAD
12550 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12551 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12552 0x3F, 0x91, 0x64, 0x59
12558 static const struct test_crypto_vector
12559 aes128_gmac_test_vector = {
12560 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12562 .data = plaintext_hash,
12567 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12568 0x08, 0x09, 0x0A, 0x0B
12574 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12575 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12581 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12582 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12588 static const struct test_crypto_vector
12589 aes128cbc_hmac_sha1_test_vector = {
12590 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12591 .cipher_offset = 0,
12595 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12596 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12602 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12603 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12608 .data = plaintext_hash,
12612 .data = ciphertext512_aes128cbc,
12615 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12619 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12620 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12621 0xDE, 0xF4, 0xDE, 0xAD
12627 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12628 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12629 0x18, 0x8C, 0x1D, 0x32
12635 static const struct test_crypto_vector
12636 aes128cbc_hmac_sha1_aad_test_vector = {
12637 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12638 .cipher_offset = 8,
12642 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12643 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12649 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12650 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12655 .data = plaintext_hash,
12659 .data = ciphertext512_aes128cbc_aad,
12662 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12666 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12667 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12668 0xDE, 0xF4, 0xDE, 0xAD
12674 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12675 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12676 0x62, 0x0F, 0xFB, 0x10
12683 data_corruption(uint8_t *data)
12689 tag_corruption(uint8_t *data, unsigned int tag_offset)
12691 data[tag_offset] += 1;
12695 create_auth_session(struct crypto_unittest_params *ut_params,
12697 const struct test_crypto_vector *reference,
12698 enum rte_crypto_auth_operation auth_op)
12700 struct crypto_testsuite_params *ts_params = &testsuite_params;
12701 uint8_t auth_key[reference->auth_key.len + 1];
12703 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12705 /* Setup Authentication Parameters */
12706 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12707 ut_params->auth_xform.auth.op = auth_op;
12708 ut_params->auth_xform.next = NULL;
12709 ut_params->auth_xform.auth.algo = reference->auth_algo;
12710 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12711 ut_params->auth_xform.auth.key.data = auth_key;
12712 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12714 /* Create Crypto session*/
12715 ut_params->sess = rte_cryptodev_sym_session_create(
12716 ts_params->session_mpool);
12718 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12719 &ut_params->auth_xform,
12720 ts_params->session_priv_mpool);
12722 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12728 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12730 const struct test_crypto_vector *reference,
12731 enum rte_crypto_auth_operation auth_op,
12732 enum rte_crypto_cipher_operation cipher_op)
12734 struct crypto_testsuite_params *ts_params = &testsuite_params;
12735 uint8_t cipher_key[reference->cipher_key.len + 1];
12736 uint8_t auth_key[reference->auth_key.len + 1];
12738 memcpy(cipher_key, reference->cipher_key.data,
12739 reference->cipher_key.len);
12740 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12742 /* Setup Authentication Parameters */
12743 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12744 ut_params->auth_xform.auth.op = auth_op;
12745 ut_params->auth_xform.auth.algo = reference->auth_algo;
12746 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12747 ut_params->auth_xform.auth.key.data = auth_key;
12748 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12750 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12751 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12752 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12754 ut_params->auth_xform.next = &ut_params->cipher_xform;
12756 /* Setup Cipher Parameters */
12757 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12758 ut_params->cipher_xform.next = NULL;
12759 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12760 ut_params->cipher_xform.cipher.op = cipher_op;
12761 ut_params->cipher_xform.cipher.key.data = cipher_key;
12762 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12763 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12764 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12767 /* Create Crypto session*/
12768 ut_params->sess = rte_cryptodev_sym_session_create(
12769 ts_params->session_mpool);
12771 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12772 &ut_params->auth_xform,
12773 ts_params->session_priv_mpool);
12775 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12781 create_auth_operation(struct crypto_testsuite_params *ts_params,
12782 struct crypto_unittest_params *ut_params,
12783 const struct test_crypto_vector *reference,
12784 unsigned int auth_generate)
12786 /* Generate Crypto op data structure */
12787 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12788 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12789 TEST_ASSERT_NOT_NULL(ut_params->op,
12790 "Failed to allocate pktmbuf offload");
12792 /* Set crypto operation data parameters */
12793 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12795 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12797 /* set crypto operation source mbuf */
12798 sym_op->m_src = ut_params->ibuf;
12801 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12802 ut_params->ibuf, reference->digest.len);
12804 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12805 "no room to append auth tag");
12807 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12808 ut_params->ibuf, reference->plaintext.len);
12811 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12813 memcpy(sym_op->auth.digest.data,
12814 reference->digest.data,
12815 reference->digest.len);
12817 debug_hexdump(stdout, "digest:",
12818 sym_op->auth.digest.data,
12819 reference->digest.len);
12821 sym_op->auth.data.length = reference->plaintext.len;
12822 sym_op->auth.data.offset = 0;
12828 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12829 struct crypto_unittest_params *ut_params,
12830 const struct test_crypto_vector *reference,
12831 unsigned int auth_generate)
12833 /* Generate Crypto op data structure */
12834 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12835 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12836 TEST_ASSERT_NOT_NULL(ut_params->op,
12837 "Failed to allocate pktmbuf offload");
12839 /* Set crypto operation data parameters */
12840 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12842 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12844 /* set crypto operation source mbuf */
12845 sym_op->m_src = ut_params->ibuf;
12848 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12849 ut_params->ibuf, reference->digest.len);
12851 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12852 "no room to append auth tag");
12854 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12855 ut_params->ibuf, reference->ciphertext.len);
12858 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12860 memcpy(sym_op->auth.digest.data,
12861 reference->digest.data,
12862 reference->digest.len);
12864 debug_hexdump(stdout, "digest:",
12865 sym_op->auth.digest.data,
12866 reference->digest.len);
12868 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12869 reference->iv.data, reference->iv.len);
12871 sym_op->cipher.data.length = 0;
12872 sym_op->cipher.data.offset = 0;
12874 sym_op->auth.data.length = reference->plaintext.len;
12875 sym_op->auth.data.offset = 0;
12881 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12882 struct crypto_unittest_params *ut_params,
12883 const struct test_crypto_vector *reference,
12884 unsigned int auth_generate)
12886 /* Generate Crypto op data structure */
12887 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12888 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12889 TEST_ASSERT_NOT_NULL(ut_params->op,
12890 "Failed to allocate pktmbuf offload");
12892 /* Set crypto operation data parameters */
12893 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12895 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12897 /* set crypto operation source mbuf */
12898 sym_op->m_src = ut_params->ibuf;
12901 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12902 ut_params->ibuf, reference->digest.len);
12904 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12905 "no room to append auth tag");
12907 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12908 ut_params->ibuf, reference->ciphertext.len);
12911 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12913 memcpy(sym_op->auth.digest.data,
12914 reference->digest.data,
12915 reference->digest.len);
12917 debug_hexdump(stdout, "digest:",
12918 sym_op->auth.digest.data,
12919 reference->digest.len);
12921 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12922 reference->iv.data, reference->iv.len);
12924 sym_op->cipher.data.length = reference->cipher_len;
12925 sym_op->cipher.data.offset = reference->cipher_offset;
12927 sym_op->auth.data.length = reference->plaintext.len;
12928 sym_op->auth.data.offset = reference->auth_offset;
12934 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12935 struct crypto_unittest_params *ut_params,
12936 const struct test_crypto_vector *reference)
12938 return create_auth_operation(ts_params, ut_params, reference, 0);
12942 create_auth_verify_GMAC_operation(
12943 struct crypto_testsuite_params *ts_params,
12944 struct crypto_unittest_params *ut_params,
12945 const struct test_crypto_vector *reference)
12947 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12951 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12952 struct crypto_unittest_params *ut_params,
12953 const struct test_crypto_vector *reference)
12955 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12959 test_authentication_verify_fail_when_data_corruption(
12960 struct crypto_testsuite_params *ts_params,
12961 struct crypto_unittest_params *ut_params,
12962 const struct test_crypto_vector *reference,
12963 unsigned int data_corrupted)
12967 uint8_t *plaintext;
12968 struct rte_cryptodev_info dev_info;
12970 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12971 uint64_t feat_flags = dev_info.feature_flags;
12973 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12974 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12975 printf("Device doesn't support RAW data-path APIs.\n");
12976 return TEST_SKIPPED;
12979 /* Verify the capabilities */
12980 struct rte_cryptodev_sym_capability_idx cap_idx;
12981 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12982 cap_idx.algo.auth = reference->auth_algo;
12983 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12985 return TEST_SKIPPED;
12988 /* Create session */
12989 retval = create_auth_session(ut_params,
12990 ts_params->valid_devs[0],
12992 RTE_CRYPTO_AUTH_OP_VERIFY);
12996 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12997 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12998 "Failed to allocate input buffer in mempool");
13000 /* clear mbuf payload */
13001 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13002 rte_pktmbuf_tailroom(ut_params->ibuf));
13004 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13005 reference->plaintext.len);
13006 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13007 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13009 debug_hexdump(stdout, "plaintext:", plaintext,
13010 reference->plaintext.len);
13012 /* Create operation */
13013 retval = create_auth_verify_operation(ts_params, ut_params, reference);
13018 if (data_corrupted)
13019 data_corruption(plaintext);
13021 tag_corruption(plaintext, reference->plaintext.len);
13023 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13024 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13026 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13027 RTE_CRYPTO_OP_STATUS_SUCCESS,
13028 "authentication not failed");
13029 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13030 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13031 ut_params->op, 0, 1, 0, 0);
13033 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13036 if (ut_params->op == NULL)
13038 else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
13045 test_authentication_verify_GMAC_fail_when_corruption(
13046 struct crypto_testsuite_params *ts_params,
13047 struct crypto_unittest_params *ut_params,
13048 const struct test_crypto_vector *reference,
13049 unsigned int data_corrupted)
13052 uint8_t *plaintext;
13053 struct rte_cryptodev_info dev_info;
13055 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13056 uint64_t feat_flags = dev_info.feature_flags;
13058 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13059 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13060 printf("Device doesn't support RAW data-path APIs.\n");
13061 return TEST_SKIPPED;
13064 /* Verify the capabilities */
13065 struct rte_cryptodev_sym_capability_idx cap_idx;
13066 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13067 cap_idx.algo.auth = reference->auth_algo;
13068 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13070 return TEST_SKIPPED;
13072 /* Create session */
13073 retval = create_auth_cipher_session(ut_params,
13074 ts_params->valid_devs[0],
13076 RTE_CRYPTO_AUTH_OP_VERIFY,
13077 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13081 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13082 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13083 "Failed to allocate input buffer in mempool");
13085 /* clear mbuf payload */
13086 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13087 rte_pktmbuf_tailroom(ut_params->ibuf));
13089 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13090 reference->plaintext.len);
13091 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13092 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13094 debug_hexdump(stdout, "plaintext:", plaintext,
13095 reference->plaintext.len);
13097 /* Create operation */
13098 retval = create_auth_verify_GMAC_operation(ts_params,
13105 if (data_corrupted)
13106 data_corruption(plaintext);
13108 tag_corruption(plaintext, reference->aad.len);
13110 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13111 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13113 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13114 RTE_CRYPTO_OP_STATUS_SUCCESS,
13115 "authentication not failed");
13116 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13117 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13118 ut_params->op, 0, 1, 0, 0);
13120 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13122 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13129 test_authenticated_decryption_fail_when_corruption(
13130 struct crypto_testsuite_params *ts_params,
13131 struct crypto_unittest_params *ut_params,
13132 const struct test_crypto_vector *reference,
13133 unsigned int data_corrupted)
13137 uint8_t *ciphertext;
13138 struct rte_cryptodev_info dev_info;
13140 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13141 uint64_t feat_flags = dev_info.feature_flags;
13143 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13144 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13145 printf("Device doesn't support RAW data-path APIs.\n");
13146 return TEST_SKIPPED;
13149 /* Verify the capabilities */
13150 struct rte_cryptodev_sym_capability_idx cap_idx;
13151 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13152 cap_idx.algo.auth = reference->auth_algo;
13153 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13155 return TEST_SKIPPED;
13156 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13157 cap_idx.algo.cipher = reference->crypto_algo;
13158 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13160 return TEST_SKIPPED;
13162 /* Create session */
13163 retval = create_auth_cipher_session(ut_params,
13164 ts_params->valid_devs[0],
13166 RTE_CRYPTO_AUTH_OP_VERIFY,
13167 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13171 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13172 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13173 "Failed to allocate input buffer in mempool");
13175 /* clear mbuf payload */
13176 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13177 rte_pktmbuf_tailroom(ut_params->ibuf));
13179 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13180 reference->ciphertext.len);
13181 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13182 memcpy(ciphertext, reference->ciphertext.data,
13183 reference->ciphertext.len);
13185 /* Create operation */
13186 retval = create_cipher_auth_verify_operation(ts_params,
13193 if (data_corrupted)
13194 data_corruption(ciphertext);
13196 tag_corruption(ciphertext, reference->ciphertext.len);
13198 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13199 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13201 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13202 RTE_CRYPTO_OP_STATUS_SUCCESS,
13203 "authentication not failed");
13204 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13205 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13206 ut_params->op, 1, 1, 0, 0);
13208 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13210 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13217 test_authenticated_encrypt_with_esn(
13218 struct crypto_testsuite_params *ts_params,
13219 struct crypto_unittest_params *ut_params,
13220 const struct test_crypto_vector *reference)
13224 uint8_t *authciphertext, *plaintext, *auth_tag;
13225 uint16_t plaintext_pad_len;
13226 uint8_t cipher_key[reference->cipher_key.len + 1];
13227 uint8_t auth_key[reference->auth_key.len + 1];
13228 struct rte_cryptodev_info dev_info;
13230 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13231 uint64_t feat_flags = dev_info.feature_flags;
13233 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13234 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13235 printf("Device doesn't support RAW data-path APIs.\n");
13236 return TEST_SKIPPED;
13239 /* Verify the capabilities */
13240 struct rte_cryptodev_sym_capability_idx cap_idx;
13241 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13242 cap_idx.algo.auth = reference->auth_algo;
13243 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13245 return TEST_SKIPPED;
13246 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13247 cap_idx.algo.cipher = reference->crypto_algo;
13248 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13250 return TEST_SKIPPED;
13252 /* Create session */
13253 memcpy(cipher_key, reference->cipher_key.data,
13254 reference->cipher_key.len);
13255 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13257 /* Setup Cipher Parameters */
13258 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13259 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13260 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13261 ut_params->cipher_xform.cipher.key.data = cipher_key;
13262 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13263 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13264 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13266 ut_params->cipher_xform.next = &ut_params->auth_xform;
13268 /* Setup Authentication Parameters */
13269 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13270 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13271 ut_params->auth_xform.auth.algo = reference->auth_algo;
13272 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13273 ut_params->auth_xform.auth.key.data = auth_key;
13274 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13275 ut_params->auth_xform.next = NULL;
13277 /* Create Crypto session*/
13278 ut_params->sess = rte_cryptodev_sym_session_create(
13279 ts_params->session_mpool);
13281 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13283 &ut_params->cipher_xform,
13284 ts_params->session_priv_mpool);
13286 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13288 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13289 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13290 "Failed to allocate input buffer in mempool");
13292 /* clear mbuf payload */
13293 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13294 rte_pktmbuf_tailroom(ut_params->ibuf));
13296 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13297 reference->plaintext.len);
13298 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13299 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13301 /* Create operation */
13302 retval = create_cipher_auth_operation(ts_params,
13309 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13310 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13312 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13313 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13314 ut_params->op, 1, 1, 0, 0);
13316 ut_params->op = process_crypto_request(
13317 ts_params->valid_devs[0], ut_params->op);
13319 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13321 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13322 "crypto op processing failed");
13324 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13326 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13327 ut_params->op->sym->auth.data.offset);
13328 auth_tag = authciphertext + plaintext_pad_len;
13329 debug_hexdump(stdout, "ciphertext:", authciphertext,
13330 reference->ciphertext.len);
13331 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13333 /* Validate obuf */
13334 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13336 reference->ciphertext.data,
13337 reference->ciphertext.len,
13338 "Ciphertext data not as expected");
13340 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13342 reference->digest.data,
13343 reference->digest.len,
13344 "Generated digest not as expected");
13346 return TEST_SUCCESS;
13351 test_authenticated_decrypt_with_esn(
13352 struct crypto_testsuite_params *ts_params,
13353 struct crypto_unittest_params *ut_params,
13354 const struct test_crypto_vector *reference)
13358 uint8_t *ciphertext;
13359 uint8_t cipher_key[reference->cipher_key.len + 1];
13360 uint8_t auth_key[reference->auth_key.len + 1];
13361 struct rte_cryptodev_info dev_info;
13363 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13364 uint64_t feat_flags = dev_info.feature_flags;
13366 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13367 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13368 printf("Device doesn't support RAW data-path APIs.\n");
13369 return TEST_SKIPPED;
13372 /* Verify the capabilities */
13373 struct rte_cryptodev_sym_capability_idx cap_idx;
13374 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13375 cap_idx.algo.auth = reference->auth_algo;
13376 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13378 return TEST_SKIPPED;
13379 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13380 cap_idx.algo.cipher = reference->crypto_algo;
13381 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13383 return TEST_SKIPPED;
13385 /* Create session */
13386 memcpy(cipher_key, reference->cipher_key.data,
13387 reference->cipher_key.len);
13388 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13390 /* Setup Authentication Parameters */
13391 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13392 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13393 ut_params->auth_xform.auth.algo = reference->auth_algo;
13394 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13395 ut_params->auth_xform.auth.key.data = auth_key;
13396 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13397 ut_params->auth_xform.next = &ut_params->cipher_xform;
13399 /* Setup Cipher Parameters */
13400 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13401 ut_params->cipher_xform.next = NULL;
13402 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13403 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13404 ut_params->cipher_xform.cipher.key.data = cipher_key;
13405 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13406 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13407 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13409 /* Create Crypto session*/
13410 ut_params->sess = rte_cryptodev_sym_session_create(
13411 ts_params->session_mpool);
13413 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13415 &ut_params->auth_xform,
13416 ts_params->session_priv_mpool);
13418 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13420 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13421 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13422 "Failed to allocate input buffer in mempool");
13424 /* clear mbuf payload */
13425 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13426 rte_pktmbuf_tailroom(ut_params->ibuf));
13428 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13429 reference->ciphertext.len);
13430 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13431 memcpy(ciphertext, reference->ciphertext.data,
13432 reference->ciphertext.len);
13434 /* Create operation */
13435 retval = create_cipher_auth_verify_operation(ts_params,
13442 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13443 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13445 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13446 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13447 ut_params->op, 1, 1, 0, 0);
13449 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13452 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13453 TEST_ASSERT_EQUAL(ut_params->op->status,
13454 RTE_CRYPTO_OP_STATUS_SUCCESS,
13455 "crypto op processing passed");
13457 ut_params->obuf = ut_params->op->sym->m_src;
13458 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13464 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13465 const struct aead_test_data *tdata,
13466 void *digest_mem, uint64_t digest_phys)
13468 struct crypto_testsuite_params *ts_params = &testsuite_params;
13469 struct crypto_unittest_params *ut_params = &unittest_params;
13471 const unsigned int auth_tag_len = tdata->auth_tag.len;
13472 const unsigned int iv_len = tdata->iv.len;
13473 unsigned int aad_len = tdata->aad.len;
13474 unsigned int aad_len_pad = 0;
13476 /* Generate Crypto op data structure */
13477 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13478 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13479 TEST_ASSERT_NOT_NULL(ut_params->op,
13480 "Failed to allocate symmetric crypto operation struct");
13482 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13484 sym_op->aead.digest.data = digest_mem;
13486 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13487 "no room to append digest");
13489 sym_op->aead.digest.phys_addr = digest_phys;
13491 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13492 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13494 debug_hexdump(stdout, "digest:",
13495 sym_op->aead.digest.data,
13499 /* Append aad data */
13500 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13501 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13502 uint8_t *, IV_OFFSET);
13504 /* Copy IV 1 byte after the IV pointer, according to the API */
13505 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13507 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13509 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13510 ut_params->ibuf, aad_len);
13511 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13512 "no room to prepend aad");
13513 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13516 memset(sym_op->aead.aad.data, 0, aad_len);
13517 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
13518 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13520 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13521 debug_hexdump(stdout, "aad:",
13522 sym_op->aead.aad.data, aad_len);
13524 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13525 uint8_t *, IV_OFFSET);
13527 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13529 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13531 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13532 ut_params->ibuf, aad_len_pad);
13533 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13534 "no room to prepend aad");
13535 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13538 memset(sym_op->aead.aad.data, 0, aad_len);
13539 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13541 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13542 debug_hexdump(stdout, "aad:",
13543 sym_op->aead.aad.data, aad_len);
13546 sym_op->aead.data.length = tdata->plaintext.len;
13547 sym_op->aead.data.offset = aad_len_pad;
13552 #define SGL_MAX_NO 16
13555 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13556 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13558 struct crypto_testsuite_params *ts_params = &testsuite_params;
13559 struct crypto_unittest_params *ut_params = &unittest_params;
13560 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13563 int to_trn_tbl[SGL_MAX_NO];
13565 unsigned int trn_data = 0;
13566 uint8_t *plaintext, *ciphertext, *auth_tag;
13567 struct rte_cryptodev_info dev_info;
13569 /* Verify the capabilities */
13570 struct rte_cryptodev_sym_capability_idx cap_idx;
13571 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13572 cap_idx.algo.aead = tdata->algo;
13573 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13575 return TEST_SKIPPED;
13577 /* OOP not supported with CPU crypto */
13578 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13579 return TEST_SKIPPED;
13581 /* Detailed check for the particular SGL support flag */
13582 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13584 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13585 if (sgl_in && (!(dev_info.feature_flags &
13586 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13587 return TEST_SKIPPED;
13589 uint64_t feat_flags = dev_info.feature_flags;
13591 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13592 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13593 printf("Device doesn't support RAW data-path APIs.\n");
13594 return TEST_SKIPPED;
13597 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13598 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13599 tdata->plaintext.len;
13600 /* Raw data path API does not support OOP */
13601 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13602 return TEST_SKIPPED;
13603 if (sgl_in && !sgl_out) {
13604 if (!(dev_info.feature_flags &
13605 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13606 return TEST_SKIPPED;
13607 } else if (!sgl_in && sgl_out) {
13608 if (!(dev_info.feature_flags &
13609 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13610 return TEST_SKIPPED;
13611 } else if (sgl_in && sgl_out) {
13612 if (!(dev_info.feature_flags &
13613 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13614 return TEST_SKIPPED;
13618 if (fragsz > tdata->plaintext.len)
13619 fragsz = tdata->plaintext.len;
13621 uint16_t plaintext_len = fragsz;
13622 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13624 if (fragsz_oop > tdata->plaintext.len)
13625 frag_size_oop = tdata->plaintext.len;
13628 void *digest_mem = NULL;
13630 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13632 if (tdata->plaintext.len % fragsz != 0) {
13633 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13636 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13641 * For out-op-place we need to alloc another mbuf
13644 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13645 rte_pktmbuf_append(ut_params->obuf,
13646 frag_size_oop + prepend_len);
13647 buf_oop = ut_params->obuf;
13650 /* Create AEAD session */
13651 retval = create_aead_session(ts_params->valid_devs[0],
13653 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13654 tdata->key.data, tdata->key.len,
13655 tdata->aad.len, tdata->auth_tag.len,
13660 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13662 /* clear mbuf payload */
13663 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13664 rte_pktmbuf_tailroom(ut_params->ibuf));
13666 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13669 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13671 trn_data += plaintext_len;
13673 buf = ut_params->ibuf;
13676 * Loop until no more fragments
13679 while (trn_data < tdata->plaintext.len) {
13681 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13682 (tdata->plaintext.len - trn_data) : fragsz;
13684 to_trn_tbl[ecx++] = to_trn;
13686 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13689 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13690 rte_pktmbuf_tailroom(buf));
13693 if (oop && !fragsz_oop) {
13694 buf_last_oop = buf_oop->next =
13695 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13696 buf_oop = buf_oop->next;
13697 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13698 0, rte_pktmbuf_tailroom(buf_oop));
13699 rte_pktmbuf_append(buf_oop, to_trn);
13702 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13705 memcpy(plaintext, tdata->plaintext.data + trn_data,
13707 trn_data += to_trn;
13708 if (trn_data == tdata->plaintext.len) {
13711 digest_mem = rte_pktmbuf_append(buf_oop,
13712 tdata->auth_tag.len);
13714 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13715 tdata->auth_tag.len);
13719 uint64_t digest_phys = 0;
13721 ut_params->ibuf->nb_segs = segs;
13724 if (fragsz_oop && oop) {
13728 if (frag_size_oop == tdata->plaintext.len) {
13729 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13730 tdata->auth_tag.len);
13732 digest_phys = rte_pktmbuf_iova_offset(
13734 tdata->plaintext.len + prepend_len);
13737 trn_data = frag_size_oop;
13738 while (trn_data < tdata->plaintext.len) {
13741 (tdata->plaintext.len - trn_data <
13743 (tdata->plaintext.len - trn_data) :
13746 to_trn_tbl[ecx++] = to_trn;
13748 buf_last_oop = buf_oop->next =
13749 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13750 buf_oop = buf_oop->next;
13751 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13752 0, rte_pktmbuf_tailroom(buf_oop));
13753 rte_pktmbuf_append(buf_oop, to_trn);
13755 trn_data += to_trn;
13757 if (trn_data == tdata->plaintext.len) {
13758 digest_mem = rte_pktmbuf_append(buf_oop,
13759 tdata->auth_tag.len);
13763 ut_params->obuf->nb_segs = segs;
13767 * Place digest at the end of the last buffer
13770 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13771 if (oop && buf_last_oop)
13772 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13774 if (!digest_mem && !oop) {
13775 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13776 + tdata->auth_tag.len);
13777 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13778 tdata->plaintext.len);
13781 /* Create AEAD operation */
13782 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13783 tdata, digest_mem, digest_phys);
13788 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13790 ut_params->op->sym->m_src = ut_params->ibuf;
13792 ut_params->op->sym->m_dst = ut_params->obuf;
13794 /* Process crypto operation */
13795 if (oop == IN_PLACE &&
13796 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13797 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13798 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13799 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13800 ut_params->op, 0, 0, 0, 0);
13802 TEST_ASSERT_NOT_NULL(
13803 process_crypto_request(ts_params->valid_devs[0],
13804 ut_params->op), "failed to process sym crypto op");
13806 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13807 "crypto op processing failed");
13810 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13811 uint8_t *, prepend_len);
13813 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13814 uint8_t *, prepend_len);
13818 fragsz = fragsz_oop;
13820 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13822 tdata->ciphertext.data,
13824 "Ciphertext data not as expected");
13826 buf = ut_params->op->sym->m_src->next;
13828 buf = ut_params->op->sym->m_dst->next;
13830 unsigned int off = fragsz;
13834 ciphertext = rte_pktmbuf_mtod(buf,
13837 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13839 tdata->ciphertext.data + off,
13841 "Ciphertext data not as expected");
13843 off += to_trn_tbl[ecx++];
13847 auth_tag = digest_mem;
13848 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13850 tdata->auth_tag.data,
13851 tdata->auth_tag.len,
13852 "Generated auth tag not as expected");
13858 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13860 return test_authenticated_encryption_SGL(
13861 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13865 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13867 return test_authenticated_encryption_SGL(
13868 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13872 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13874 return test_authenticated_encryption_SGL(
13875 &gcm_test_case_8, OUT_OF_PLACE, 400,
13876 gcm_test_case_8.plaintext.len);
13880 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13882 /* This test is not for OPENSSL PMD */
13883 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13884 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13885 return TEST_SKIPPED;
13887 return test_authenticated_encryption_SGL(
13888 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13892 test_authentication_verify_fail_when_data_corrupted(
13893 struct crypto_testsuite_params *ts_params,
13894 struct crypto_unittest_params *ut_params,
13895 const struct test_crypto_vector *reference)
13897 return test_authentication_verify_fail_when_data_corruption(
13898 ts_params, ut_params, reference, 1);
13902 test_authentication_verify_fail_when_tag_corrupted(
13903 struct crypto_testsuite_params *ts_params,
13904 struct crypto_unittest_params *ut_params,
13905 const struct test_crypto_vector *reference)
13907 return test_authentication_verify_fail_when_data_corruption(
13908 ts_params, ut_params, reference, 0);
13912 test_authentication_verify_GMAC_fail_when_data_corrupted(
13913 struct crypto_testsuite_params *ts_params,
13914 struct crypto_unittest_params *ut_params,
13915 const struct test_crypto_vector *reference)
13917 return test_authentication_verify_GMAC_fail_when_corruption(
13918 ts_params, ut_params, reference, 1);
13922 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13923 struct crypto_testsuite_params *ts_params,
13924 struct crypto_unittest_params *ut_params,
13925 const struct test_crypto_vector *reference)
13927 return test_authentication_verify_GMAC_fail_when_corruption(
13928 ts_params, ut_params, reference, 0);
13932 test_authenticated_decryption_fail_when_data_corrupted(
13933 struct crypto_testsuite_params *ts_params,
13934 struct crypto_unittest_params *ut_params,
13935 const struct test_crypto_vector *reference)
13937 return test_authenticated_decryption_fail_when_corruption(
13938 ts_params, ut_params, reference, 1);
13942 test_authenticated_decryption_fail_when_tag_corrupted(
13943 struct crypto_testsuite_params *ts_params,
13944 struct crypto_unittest_params *ut_params,
13945 const struct test_crypto_vector *reference)
13947 return test_authenticated_decryption_fail_when_corruption(
13948 ts_params, ut_params, reference, 0);
13952 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13954 return test_authentication_verify_fail_when_data_corrupted(
13955 &testsuite_params, &unittest_params,
13956 &hmac_sha1_test_crypto_vector);
13960 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13962 return test_authentication_verify_fail_when_tag_corrupted(
13963 &testsuite_params, &unittest_params,
13964 &hmac_sha1_test_crypto_vector);
13968 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13970 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13971 &testsuite_params, &unittest_params,
13972 &aes128_gmac_test_vector);
13976 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13978 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13979 &testsuite_params, &unittest_params,
13980 &aes128_gmac_test_vector);
13984 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13986 return test_authenticated_decryption_fail_when_data_corrupted(
13989 &aes128cbc_hmac_sha1_test_vector);
13993 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13995 return test_authenticated_decryption_fail_when_tag_corrupted(
13998 &aes128cbc_hmac_sha1_test_vector);
14002 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14004 return test_authenticated_encrypt_with_esn(
14007 &aes128cbc_hmac_sha1_aad_test_vector);
14011 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14013 return test_authenticated_decrypt_with_esn(
14016 &aes128cbc_hmac_sha1_aad_test_vector);
14020 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
14022 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
14026 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
14028 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
14032 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
14034 return test_authenticated_encryption_SGL(
14035 &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
14036 chacha20_poly1305_case_2.plaintext.len);
14039 #ifdef RTE_CRYPTO_SCHEDULER
14041 /* global AESNI worker IDs for the scheduler test */
14042 uint8_t aesni_ids[2];
14045 scheduler_testsuite_setup(void)
14048 int32_t nb_devs, ret;
14049 char vdev_args[VDEV_ARGS_SIZE] = {""};
14050 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14051 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
14052 uint16_t worker_core_count = 0;
14053 uint16_t socket_id = 0;
14055 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14056 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14058 /* Identify the Worker Cores
14059 * Use 2 worker cores for the device args
14061 RTE_LCORE_FOREACH_WORKER(i) {
14062 if (worker_core_count > 1)
14064 snprintf(vdev_args, sizeof(vdev_args),
14065 "%s%d", temp_str, i);
14066 strcpy(temp_str, vdev_args);
14067 strlcat(temp_str, ";", sizeof(temp_str));
14068 worker_core_count++;
14069 socket_id = rte_lcore_to_socket_id(i);
14071 if (worker_core_count != 2) {
14072 RTE_LOG(ERR, USER1,
14073 "Cryptodev scheduler test require at least "
14074 "two worker cores to run. "
14075 "Please use the correct coremask.\n");
14076 return TEST_FAILED;
14078 strcpy(temp_str, vdev_args);
14079 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14080 temp_str, socket_id);
14081 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14082 nb_devs = rte_cryptodev_device_count_by_driver(
14083 rte_cryptodev_driver_id_get(
14084 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14086 ret = rte_vdev_init(
14087 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14089 TEST_ASSERT(ret == 0,
14090 "Failed to create instance %u of pmd : %s",
14091 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14094 return testsuite_setup();
14098 test_scheduler_attach_worker_op(void)
14100 struct crypto_testsuite_params *ts_params = &testsuite_params;
14101 uint8_t sched_id = ts_params->valid_devs[0];
14102 uint32_t i, nb_devs_attached = 0;
14104 char vdev_name[32];
14105 unsigned int count = rte_cryptodev_count();
14107 /* create 2 AESNI_MB vdevs on top of existing devices */
14108 for (i = count; i < count + 2; i++) {
14109 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14110 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14112 ret = rte_vdev_init(vdev_name, NULL);
14114 TEST_ASSERT(ret == 0,
14115 "Failed to create instance %u of"
14117 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14120 RTE_LOG(ERR, USER1,
14121 "Failed to create 2 AESNI MB PMDs.\n");
14122 return TEST_SKIPPED;
14126 /* attach 2 AESNI_MB cdevs */
14127 for (i = count; i < count + 2; i++) {
14128 struct rte_cryptodev_info info;
14129 unsigned int session_size;
14131 rte_cryptodev_info_get(i, &info);
14132 if (info.driver_id != rte_cryptodev_driver_id_get(
14133 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14136 session_size = rte_cryptodev_sym_get_private_session_size(i);
14138 * Create the session mempool again, since now there are new devices
14139 * to use the mempool.
14141 if (ts_params->session_mpool) {
14142 rte_mempool_free(ts_params->session_mpool);
14143 ts_params->session_mpool = NULL;
14145 if (ts_params->session_priv_mpool) {
14146 rte_mempool_free(ts_params->session_priv_mpool);
14147 ts_params->session_priv_mpool = NULL;
14150 if (info.sym.max_nb_sessions != 0 &&
14151 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14152 RTE_LOG(ERR, USER1,
14153 "Device does not support "
14154 "at least %u sessions\n",
14156 return TEST_FAILED;
14159 * Create mempool with maximum number of sessions,
14160 * to include the session headers
14162 if (ts_params->session_mpool == NULL) {
14163 ts_params->session_mpool =
14164 rte_cryptodev_sym_session_pool_create(
14166 MAX_NB_SESSIONS, 0, 0, 0,
14168 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14169 "session mempool allocation failed");
14173 * Create mempool with maximum number of sessions,
14174 * to include device specific session private data
14176 if (ts_params->session_priv_mpool == NULL) {
14177 ts_params->session_priv_mpool = rte_mempool_create(
14178 "test_sess_mp_priv",
14181 0, 0, NULL, NULL, NULL,
14182 NULL, SOCKET_ID_ANY,
14185 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14186 "session mempool allocation failed");
14189 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14190 ts_params->qp_conf.mp_session_private =
14191 ts_params->session_priv_mpool;
14193 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14196 TEST_ASSERT(ret == 0,
14197 "Failed to attach device %u of pmd : %s", i,
14198 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14200 aesni_ids[nb_devs_attached] = (uint8_t)i;
14202 nb_devs_attached++;
14209 test_scheduler_detach_worker_op(void)
14211 struct crypto_testsuite_params *ts_params = &testsuite_params;
14212 uint8_t sched_id = ts_params->valid_devs[0];
14216 for (i = 0; i < 2; i++) {
14217 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14219 TEST_ASSERT(ret == 0,
14220 "Failed to detach device %u", aesni_ids[i]);
14227 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14229 struct crypto_testsuite_params *ts_params = &testsuite_params;
14230 uint8_t sched_id = ts_params->valid_devs[0];
14232 return rte_cryptodev_scheduler_mode_set(sched_id,
14237 test_scheduler_mode_roundrobin_op(void)
14239 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14240 0, "Failed to set roundrobin mode");
14246 test_scheduler_mode_multicore_op(void)
14248 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14249 0, "Failed to set multicore mode");
14255 test_scheduler_mode_failover_op(void)
14257 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
14258 0, "Failed to set failover mode");
14264 test_scheduler_mode_pkt_size_distr_op(void)
14266 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
14267 0, "Failed to set pktsize mode");
14273 scheduler_multicore_testsuite_setup(void)
14275 if (test_scheduler_attach_worker_op() < 0)
14276 return TEST_SKIPPED;
14277 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
14278 return TEST_SKIPPED;
14283 scheduler_roundrobin_testsuite_setup(void)
14285 if (test_scheduler_attach_worker_op() < 0)
14286 return TEST_SKIPPED;
14287 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
14288 return TEST_SKIPPED;
14293 scheduler_failover_testsuite_setup(void)
14295 if (test_scheduler_attach_worker_op() < 0)
14296 return TEST_SKIPPED;
14297 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
14298 return TEST_SKIPPED;
14303 scheduler_pkt_size_distr_testsuite_setup(void)
14305 if (test_scheduler_attach_worker_op() < 0)
14306 return TEST_SKIPPED;
14307 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14308 return TEST_SKIPPED;
14313 scheduler_mode_testsuite_teardown(void)
14315 test_scheduler_detach_worker_op();
14318 #endif /* RTE_CRYPTO_SCHEDULER */
14320 static struct unit_test_suite end_testsuite = {
14321 .suite_name = NULL,
14324 .unit_test_suites = NULL
14327 #ifdef RTE_LIB_SECURITY
14328 static struct unit_test_suite ipsec_proto_testsuite = {
14329 .suite_name = "IPsec Proto Unit Test Suite",
14330 .setup = ipsec_proto_testsuite_setup,
14331 .unit_test_cases = {
14332 TEST_CASE_NAMED_WITH_DATA(
14333 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14334 ut_setup_security, ut_teardown,
14335 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
14336 TEST_CASE_NAMED_WITH_DATA(
14337 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14338 ut_setup_security, ut_teardown,
14339 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
14340 TEST_CASE_NAMED_WITH_DATA(
14341 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14342 ut_setup_security, ut_teardown,
14343 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
14344 TEST_CASE_NAMED_WITH_DATA(
14345 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14346 ut_setup_security, ut_teardown,
14347 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14348 TEST_CASE_NAMED_WITH_DATA(
14349 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14350 ut_setup_security, ut_teardown,
14351 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14352 TEST_CASE_NAMED_WITH_DATA(
14353 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14354 ut_setup_security, ut_teardown,
14355 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14356 TEST_CASE_NAMED_ST(
14357 "Combined test alg list",
14358 ut_setup_security, ut_teardown,
14359 test_ipsec_proto_display_list),
14360 TEST_CASE_NAMED_ST(
14362 ut_setup_security, ut_teardown,
14363 test_ipsec_proto_iv_gen),
14364 TEST_CASE_NAMED_ST(
14365 "UDP encapsulation",
14366 ut_setup_security, ut_teardown,
14367 test_ipsec_proto_udp_encap),
14368 TEST_CASE_NAMED_ST(
14369 "UDP encapsulation ports verification test",
14370 ut_setup_security, ut_teardown,
14371 test_ipsec_proto_udp_ports_verify),
14372 TEST_CASE_NAMED_ST(
14373 "SA expiry packets soft",
14374 ut_setup_security, ut_teardown,
14375 test_ipsec_proto_sa_exp_pkts_soft),
14376 TEST_CASE_NAMED_ST(
14377 "SA expiry packets hard",
14378 ut_setup_security, ut_teardown,
14379 test_ipsec_proto_sa_exp_pkts_hard),
14380 TEST_CASE_NAMED_ST(
14381 "Negative test: ICV corruption",
14382 ut_setup_security, ut_teardown,
14383 test_ipsec_proto_err_icv_corrupt),
14384 TEST_CASE_NAMED_ST(
14385 "Tunnel dst addr verification",
14386 ut_setup_security, ut_teardown,
14387 test_ipsec_proto_tunnel_dst_addr_verify),
14388 TEST_CASE_NAMED_ST(
14389 "Tunnel src and dst addr verification",
14390 ut_setup_security, ut_teardown,
14391 test_ipsec_proto_tunnel_src_dst_addr_verify),
14392 TEST_CASE_NAMED_ST(
14393 "Inner IP checksum",
14394 ut_setup_security, ut_teardown,
14395 test_ipsec_proto_inner_ip_csum),
14396 TEST_CASE_NAMED_ST(
14397 "Inner L4 checksum",
14398 ut_setup_security, ut_teardown,
14399 test_ipsec_proto_inner_l4_csum),
14400 TEST_CASES_END() /**< NULL terminate unit test array */
14404 static struct unit_test_suite pdcp_proto_testsuite = {
14405 .suite_name = "PDCP Proto Unit Test Suite",
14406 .setup = pdcp_proto_testsuite_setup,
14407 .unit_test_cases = {
14408 TEST_CASE_ST(ut_setup_security, ut_teardown,
14409 test_PDCP_PROTO_all),
14410 TEST_CASES_END() /**< NULL terminate unit test array */
14414 #define ADD_UPLINK_TESTCASE(data) \
14415 TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
14416 ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
14418 #define ADD_DOWNLINK_TESTCASE(data) \
14419 TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
14420 ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
14422 static struct unit_test_suite docsis_proto_testsuite = {
14423 .suite_name = "DOCSIS Proto Unit Test Suite",
14424 .setup = docsis_proto_testsuite_setup,
14425 .unit_test_cases = {
14427 ADD_UPLINK_TESTCASE(docsis_test_case_1)
14428 ADD_UPLINK_TESTCASE(docsis_test_case_2)
14429 ADD_UPLINK_TESTCASE(docsis_test_case_3)
14430 ADD_UPLINK_TESTCASE(docsis_test_case_4)
14431 ADD_UPLINK_TESTCASE(docsis_test_case_5)
14432 ADD_UPLINK_TESTCASE(docsis_test_case_6)
14433 ADD_UPLINK_TESTCASE(docsis_test_case_7)
14434 ADD_UPLINK_TESTCASE(docsis_test_case_8)
14435 ADD_UPLINK_TESTCASE(docsis_test_case_9)
14436 ADD_UPLINK_TESTCASE(docsis_test_case_10)
14437 ADD_UPLINK_TESTCASE(docsis_test_case_11)
14438 ADD_UPLINK_TESTCASE(docsis_test_case_12)
14439 ADD_UPLINK_TESTCASE(docsis_test_case_13)
14440 ADD_UPLINK_TESTCASE(docsis_test_case_14)
14441 ADD_UPLINK_TESTCASE(docsis_test_case_15)
14442 ADD_UPLINK_TESTCASE(docsis_test_case_16)
14443 ADD_UPLINK_TESTCASE(docsis_test_case_17)
14444 ADD_UPLINK_TESTCASE(docsis_test_case_18)
14445 ADD_UPLINK_TESTCASE(docsis_test_case_19)
14446 ADD_UPLINK_TESTCASE(docsis_test_case_20)
14447 ADD_UPLINK_TESTCASE(docsis_test_case_21)
14448 ADD_UPLINK_TESTCASE(docsis_test_case_22)
14449 ADD_UPLINK_TESTCASE(docsis_test_case_23)
14450 ADD_UPLINK_TESTCASE(docsis_test_case_24)
14451 ADD_UPLINK_TESTCASE(docsis_test_case_25)
14452 ADD_UPLINK_TESTCASE(docsis_test_case_26)
14454 ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
14455 ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
14456 ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
14457 ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
14458 ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
14459 ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
14460 ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
14461 ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
14462 ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
14463 ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
14464 ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
14465 ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
14466 ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
14467 ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
14468 ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
14469 ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
14470 ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
14471 ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
14472 ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
14473 ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
14474 ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
14475 ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
14476 ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
14477 ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
14478 ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
14479 ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
14480 TEST_CASES_END() /**< NULL terminate unit test array */
14485 static struct unit_test_suite cryptodev_gen_testsuite = {
14486 .suite_name = "Crypto General Unit Test Suite",
14487 .setup = crypto_gen_testsuite_setup,
14488 .unit_test_cases = {
14489 TEST_CASE_ST(ut_setup, ut_teardown,
14490 test_device_configure_invalid_dev_id),
14491 TEST_CASE_ST(ut_setup, ut_teardown,
14492 test_queue_pair_descriptor_setup),
14493 TEST_CASE_ST(ut_setup, ut_teardown,
14494 test_device_configure_invalid_queue_pair_ids),
14495 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
14496 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
14497 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
14498 TEST_CASES_END() /**< NULL terminate unit test array */
14502 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
14503 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
14504 .setup = negative_hmac_sha1_testsuite_setup,
14505 .unit_test_cases = {
14506 /** Negative tests */
14507 TEST_CASE_ST(ut_setup, ut_teardown,
14508 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14509 TEST_CASE_ST(ut_setup, ut_teardown,
14510 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14511 TEST_CASE_ST(ut_setup, ut_teardown,
14512 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14513 TEST_CASE_ST(ut_setup, ut_teardown,
14514 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14516 TEST_CASES_END() /**< NULL terminate unit test array */
14520 static struct unit_test_suite cryptodev_multi_session_testsuite = {
14521 .suite_name = "Multi Session Unit Test Suite",
14522 .setup = multi_session_testsuite_setup,
14523 .unit_test_cases = {
14524 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14525 TEST_CASE_ST(ut_setup, ut_teardown,
14526 test_multi_session_random_usage),
14528 TEST_CASES_END() /**< NULL terminate unit test array */
14532 static struct unit_test_suite cryptodev_null_testsuite = {
14533 .suite_name = "NULL Test Suite",
14534 .setup = null_testsuite_setup,
14535 .unit_test_cases = {
14536 TEST_CASE_ST(ut_setup, ut_teardown,
14537 test_null_invalid_operation),
14538 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
14543 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
14544 .suite_name = "AES CCM Authenticated Test Suite",
14545 .setup = aes_ccm_auth_testsuite_setup,
14546 .unit_test_cases = {
14547 /** AES CCM Authenticated Encryption 128 bits key*/
14548 TEST_CASE_ST(ut_setup, ut_teardown,
14549 test_AES_CCM_authenticated_encryption_test_case_128_1),
14550 TEST_CASE_ST(ut_setup, ut_teardown,
14551 test_AES_CCM_authenticated_encryption_test_case_128_2),
14552 TEST_CASE_ST(ut_setup, ut_teardown,
14553 test_AES_CCM_authenticated_encryption_test_case_128_3),
14555 /** AES CCM Authenticated Decryption 128 bits key*/
14556 TEST_CASE_ST(ut_setup, ut_teardown,
14557 test_AES_CCM_authenticated_decryption_test_case_128_1),
14558 TEST_CASE_ST(ut_setup, ut_teardown,
14559 test_AES_CCM_authenticated_decryption_test_case_128_2),
14560 TEST_CASE_ST(ut_setup, ut_teardown,
14561 test_AES_CCM_authenticated_decryption_test_case_128_3),
14563 /** AES CCM Authenticated Encryption 192 bits key */
14564 TEST_CASE_ST(ut_setup, ut_teardown,
14565 test_AES_CCM_authenticated_encryption_test_case_192_1),
14566 TEST_CASE_ST(ut_setup, ut_teardown,
14567 test_AES_CCM_authenticated_encryption_test_case_192_2),
14568 TEST_CASE_ST(ut_setup, ut_teardown,
14569 test_AES_CCM_authenticated_encryption_test_case_192_3),
14571 /** AES CCM Authenticated Decryption 192 bits key*/
14572 TEST_CASE_ST(ut_setup, ut_teardown,
14573 test_AES_CCM_authenticated_decryption_test_case_192_1),
14574 TEST_CASE_ST(ut_setup, ut_teardown,
14575 test_AES_CCM_authenticated_decryption_test_case_192_2),
14576 TEST_CASE_ST(ut_setup, ut_teardown,
14577 test_AES_CCM_authenticated_decryption_test_case_192_3),
14579 /** AES CCM Authenticated Encryption 256 bits key */
14580 TEST_CASE_ST(ut_setup, ut_teardown,
14581 test_AES_CCM_authenticated_encryption_test_case_256_1),
14582 TEST_CASE_ST(ut_setup, ut_teardown,
14583 test_AES_CCM_authenticated_encryption_test_case_256_2),
14584 TEST_CASE_ST(ut_setup, ut_teardown,
14585 test_AES_CCM_authenticated_encryption_test_case_256_3),
14587 /** AES CCM Authenticated Decryption 256 bits key*/
14588 TEST_CASE_ST(ut_setup, ut_teardown,
14589 test_AES_CCM_authenticated_decryption_test_case_256_1),
14590 TEST_CASE_ST(ut_setup, ut_teardown,
14591 test_AES_CCM_authenticated_decryption_test_case_256_2),
14592 TEST_CASE_ST(ut_setup, ut_teardown,
14593 test_AES_CCM_authenticated_decryption_test_case_256_3),
14598 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
14599 .suite_name = "AES GCM Authenticated Test Suite",
14600 .setup = aes_gcm_auth_testsuite_setup,
14601 .unit_test_cases = {
14602 /** AES GCM Authenticated Encryption */
14603 TEST_CASE_ST(ut_setup, ut_teardown,
14604 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
14605 TEST_CASE_ST(ut_setup, ut_teardown,
14606 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
14607 TEST_CASE_ST(ut_setup, ut_teardown,
14608 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
14609 TEST_CASE_ST(ut_setup, ut_teardown,
14610 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
14611 TEST_CASE_ST(ut_setup, ut_teardown,
14612 test_AES_GCM_authenticated_encryption_test_case_1),
14613 TEST_CASE_ST(ut_setup, ut_teardown,
14614 test_AES_GCM_authenticated_encryption_test_case_2),
14615 TEST_CASE_ST(ut_setup, ut_teardown,
14616 test_AES_GCM_authenticated_encryption_test_case_3),
14617 TEST_CASE_ST(ut_setup, ut_teardown,
14618 test_AES_GCM_authenticated_encryption_test_case_4),
14619 TEST_CASE_ST(ut_setup, ut_teardown,
14620 test_AES_GCM_authenticated_encryption_test_case_5),
14621 TEST_CASE_ST(ut_setup, ut_teardown,
14622 test_AES_GCM_authenticated_encryption_test_case_6),
14623 TEST_CASE_ST(ut_setup, ut_teardown,
14624 test_AES_GCM_authenticated_encryption_test_case_7),
14625 TEST_CASE_ST(ut_setup, ut_teardown,
14626 test_AES_GCM_authenticated_encryption_test_case_8),
14627 TEST_CASE_ST(ut_setup, ut_teardown,
14628 test_AES_GCM_J0_authenticated_encryption_test_case_1),
14630 /** AES GCM Authenticated Decryption */
14631 TEST_CASE_ST(ut_setup, ut_teardown,
14632 test_AES_GCM_authenticated_decryption_test_case_1),
14633 TEST_CASE_ST(ut_setup, ut_teardown,
14634 test_AES_GCM_authenticated_decryption_test_case_2),
14635 TEST_CASE_ST(ut_setup, ut_teardown,
14636 test_AES_GCM_authenticated_decryption_test_case_3),
14637 TEST_CASE_ST(ut_setup, ut_teardown,
14638 test_AES_GCM_authenticated_decryption_test_case_4),
14639 TEST_CASE_ST(ut_setup, ut_teardown,
14640 test_AES_GCM_authenticated_decryption_test_case_5),
14641 TEST_CASE_ST(ut_setup, ut_teardown,
14642 test_AES_GCM_authenticated_decryption_test_case_6),
14643 TEST_CASE_ST(ut_setup, ut_teardown,
14644 test_AES_GCM_authenticated_decryption_test_case_7),
14645 TEST_CASE_ST(ut_setup, ut_teardown,
14646 test_AES_GCM_authenticated_decryption_test_case_8),
14647 TEST_CASE_ST(ut_setup, ut_teardown,
14648 test_AES_GCM_J0_authenticated_decryption_test_case_1),
14650 /** AES GCM Authenticated Encryption 192 bits key */
14651 TEST_CASE_ST(ut_setup, ut_teardown,
14652 test_AES_GCM_auth_encryption_test_case_192_1),
14653 TEST_CASE_ST(ut_setup, ut_teardown,
14654 test_AES_GCM_auth_encryption_test_case_192_2),
14655 TEST_CASE_ST(ut_setup, ut_teardown,
14656 test_AES_GCM_auth_encryption_test_case_192_3),
14657 TEST_CASE_ST(ut_setup, ut_teardown,
14658 test_AES_GCM_auth_encryption_test_case_192_4),
14659 TEST_CASE_ST(ut_setup, ut_teardown,
14660 test_AES_GCM_auth_encryption_test_case_192_5),
14661 TEST_CASE_ST(ut_setup, ut_teardown,
14662 test_AES_GCM_auth_encryption_test_case_192_6),
14663 TEST_CASE_ST(ut_setup, ut_teardown,
14664 test_AES_GCM_auth_encryption_test_case_192_7),
14666 /** AES GCM Authenticated Decryption 192 bits key */
14667 TEST_CASE_ST(ut_setup, ut_teardown,
14668 test_AES_GCM_auth_decryption_test_case_192_1),
14669 TEST_CASE_ST(ut_setup, ut_teardown,
14670 test_AES_GCM_auth_decryption_test_case_192_2),
14671 TEST_CASE_ST(ut_setup, ut_teardown,
14672 test_AES_GCM_auth_decryption_test_case_192_3),
14673 TEST_CASE_ST(ut_setup, ut_teardown,
14674 test_AES_GCM_auth_decryption_test_case_192_4),
14675 TEST_CASE_ST(ut_setup, ut_teardown,
14676 test_AES_GCM_auth_decryption_test_case_192_5),
14677 TEST_CASE_ST(ut_setup, ut_teardown,
14678 test_AES_GCM_auth_decryption_test_case_192_6),
14679 TEST_CASE_ST(ut_setup, ut_teardown,
14680 test_AES_GCM_auth_decryption_test_case_192_7),
14682 /** AES GCM Authenticated Encryption 256 bits key */
14683 TEST_CASE_ST(ut_setup, ut_teardown,
14684 test_AES_GCM_auth_encryption_test_case_256_1),
14685 TEST_CASE_ST(ut_setup, ut_teardown,
14686 test_AES_GCM_auth_encryption_test_case_256_2),
14687 TEST_CASE_ST(ut_setup, ut_teardown,
14688 test_AES_GCM_auth_encryption_test_case_256_3),
14689 TEST_CASE_ST(ut_setup, ut_teardown,
14690 test_AES_GCM_auth_encryption_test_case_256_4),
14691 TEST_CASE_ST(ut_setup, ut_teardown,
14692 test_AES_GCM_auth_encryption_test_case_256_5),
14693 TEST_CASE_ST(ut_setup, ut_teardown,
14694 test_AES_GCM_auth_encryption_test_case_256_6),
14695 TEST_CASE_ST(ut_setup, ut_teardown,
14696 test_AES_GCM_auth_encryption_test_case_256_7),
14698 /** AES GCM Authenticated Decryption 256 bits key */
14699 TEST_CASE_ST(ut_setup, ut_teardown,
14700 test_AES_GCM_auth_decryption_test_case_256_1),
14701 TEST_CASE_ST(ut_setup, ut_teardown,
14702 test_AES_GCM_auth_decryption_test_case_256_2),
14703 TEST_CASE_ST(ut_setup, ut_teardown,
14704 test_AES_GCM_auth_decryption_test_case_256_3),
14705 TEST_CASE_ST(ut_setup, ut_teardown,
14706 test_AES_GCM_auth_decryption_test_case_256_4),
14707 TEST_CASE_ST(ut_setup, ut_teardown,
14708 test_AES_GCM_auth_decryption_test_case_256_5),
14709 TEST_CASE_ST(ut_setup, ut_teardown,
14710 test_AES_GCM_auth_decryption_test_case_256_6),
14711 TEST_CASE_ST(ut_setup, ut_teardown,
14712 test_AES_GCM_auth_decryption_test_case_256_7),
14714 /** AES GCM Authenticated Encryption big aad size */
14715 TEST_CASE_ST(ut_setup, ut_teardown,
14716 test_AES_GCM_auth_encryption_test_case_aad_1),
14717 TEST_CASE_ST(ut_setup, ut_teardown,
14718 test_AES_GCM_auth_encryption_test_case_aad_2),
14720 /** AES GCM Authenticated Decryption big aad size */
14721 TEST_CASE_ST(ut_setup, ut_teardown,
14722 test_AES_GCM_auth_decryption_test_case_aad_1),
14723 TEST_CASE_ST(ut_setup, ut_teardown,
14724 test_AES_GCM_auth_decryption_test_case_aad_2),
14726 /** Out of place tests */
14727 TEST_CASE_ST(ut_setup, ut_teardown,
14728 test_AES_GCM_authenticated_encryption_oop_test_case_1),
14729 TEST_CASE_ST(ut_setup, ut_teardown,
14730 test_AES_GCM_authenticated_decryption_oop_test_case_1),
14732 /** Session-less tests */
14733 TEST_CASE_ST(ut_setup, ut_teardown,
14734 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
14735 TEST_CASE_ST(ut_setup, ut_teardown,
14736 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
14742 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
14743 .suite_name = "AES GMAC Authentication Test Suite",
14744 .setup = aes_gmac_auth_testsuite_setup,
14745 .unit_test_cases = {
14746 TEST_CASE_ST(ut_setup, ut_teardown,
14747 test_AES_GMAC_authentication_test_case_1),
14748 TEST_CASE_ST(ut_setup, ut_teardown,
14749 test_AES_GMAC_authentication_verify_test_case_1),
14750 TEST_CASE_ST(ut_setup, ut_teardown,
14751 test_AES_GMAC_authentication_test_case_2),
14752 TEST_CASE_ST(ut_setup, ut_teardown,
14753 test_AES_GMAC_authentication_verify_test_case_2),
14754 TEST_CASE_ST(ut_setup, ut_teardown,
14755 test_AES_GMAC_authentication_test_case_3),
14756 TEST_CASE_ST(ut_setup, ut_teardown,
14757 test_AES_GMAC_authentication_verify_test_case_3),
14758 TEST_CASE_ST(ut_setup, ut_teardown,
14759 test_AES_GMAC_authentication_test_case_4),
14760 TEST_CASE_ST(ut_setup, ut_teardown,
14761 test_AES_GMAC_authentication_verify_test_case_4),
14762 TEST_CASE_ST(ut_setup, ut_teardown,
14763 test_AES_GMAC_authentication_SGL_40B),
14764 TEST_CASE_ST(ut_setup, ut_teardown,
14765 test_AES_GMAC_authentication_SGL_80B),
14766 TEST_CASE_ST(ut_setup, ut_teardown,
14767 test_AES_GMAC_authentication_SGL_2048B),
14768 TEST_CASE_ST(ut_setup, ut_teardown,
14769 test_AES_GMAC_authentication_SGL_2047B),
14775 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14776 .suite_name = "Chacha20-Poly1305 Test Suite",
14777 .setup = chacha20_poly1305_testsuite_setup,
14778 .unit_test_cases = {
14779 TEST_CASE_ST(ut_setup, ut_teardown,
14780 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14781 TEST_CASE_ST(ut_setup, ut_teardown,
14782 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14783 TEST_CASE_ST(ut_setup, ut_teardown,
14784 test_chacha20_poly1305_encrypt_SGL_out_of_place),
14789 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14790 .suite_name = "SNOW 3G Test Suite",
14791 .setup = snow3g_testsuite_setup,
14792 .unit_test_cases = {
14793 /** SNOW 3G encrypt only (UEA2) */
14794 TEST_CASE_ST(ut_setup, ut_teardown,
14795 test_snow3g_encryption_test_case_1),
14796 TEST_CASE_ST(ut_setup, ut_teardown,
14797 test_snow3g_encryption_test_case_2),
14798 TEST_CASE_ST(ut_setup, ut_teardown,
14799 test_snow3g_encryption_test_case_3),
14800 TEST_CASE_ST(ut_setup, ut_teardown,
14801 test_snow3g_encryption_test_case_4),
14802 TEST_CASE_ST(ut_setup, ut_teardown,
14803 test_snow3g_encryption_test_case_5),
14805 TEST_CASE_ST(ut_setup, ut_teardown,
14806 test_snow3g_encryption_test_case_1_oop),
14807 TEST_CASE_ST(ut_setup, ut_teardown,
14808 test_snow3g_encryption_test_case_1_oop_sgl),
14809 TEST_CASE_ST(ut_setup, ut_teardown,
14810 test_snow3g_encryption_test_case_1_offset_oop),
14811 TEST_CASE_ST(ut_setup, ut_teardown,
14812 test_snow3g_decryption_test_case_1_oop),
14814 /** SNOW 3G generate auth, then encrypt (UEA2) */
14815 TEST_CASE_ST(ut_setup, ut_teardown,
14816 test_snow3g_auth_cipher_test_case_1),
14817 TEST_CASE_ST(ut_setup, ut_teardown,
14818 test_snow3g_auth_cipher_test_case_2),
14819 TEST_CASE_ST(ut_setup, ut_teardown,
14820 test_snow3g_auth_cipher_test_case_2_oop),
14821 TEST_CASE_ST(ut_setup, ut_teardown,
14822 test_snow3g_auth_cipher_part_digest_enc),
14823 TEST_CASE_ST(ut_setup, ut_teardown,
14824 test_snow3g_auth_cipher_part_digest_enc_oop),
14825 TEST_CASE_ST(ut_setup, ut_teardown,
14826 test_snow3g_auth_cipher_test_case_3_sgl),
14827 TEST_CASE_ST(ut_setup, ut_teardown,
14828 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14829 TEST_CASE_ST(ut_setup, ut_teardown,
14830 test_snow3g_auth_cipher_part_digest_enc_sgl),
14831 TEST_CASE_ST(ut_setup, ut_teardown,
14832 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14834 /** SNOW 3G decrypt (UEA2), then verify auth */
14835 TEST_CASE_ST(ut_setup, ut_teardown,
14836 test_snow3g_auth_cipher_verify_test_case_1),
14837 TEST_CASE_ST(ut_setup, ut_teardown,
14838 test_snow3g_auth_cipher_verify_test_case_2),
14839 TEST_CASE_ST(ut_setup, ut_teardown,
14840 test_snow3g_auth_cipher_verify_test_case_2_oop),
14841 TEST_CASE_ST(ut_setup, ut_teardown,
14842 test_snow3g_auth_cipher_verify_part_digest_enc),
14843 TEST_CASE_ST(ut_setup, ut_teardown,
14844 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14845 TEST_CASE_ST(ut_setup, ut_teardown,
14846 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14847 TEST_CASE_ST(ut_setup, ut_teardown,
14848 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14849 TEST_CASE_ST(ut_setup, ut_teardown,
14850 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14851 TEST_CASE_ST(ut_setup, ut_teardown,
14852 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14854 /** SNOW 3G decrypt only (UEA2) */
14855 TEST_CASE_ST(ut_setup, ut_teardown,
14856 test_snow3g_decryption_test_case_1),
14857 TEST_CASE_ST(ut_setup, ut_teardown,
14858 test_snow3g_decryption_test_case_2),
14859 TEST_CASE_ST(ut_setup, ut_teardown,
14860 test_snow3g_decryption_test_case_3),
14861 TEST_CASE_ST(ut_setup, ut_teardown,
14862 test_snow3g_decryption_test_case_4),
14863 TEST_CASE_ST(ut_setup, ut_teardown,
14864 test_snow3g_decryption_test_case_5),
14865 TEST_CASE_ST(ut_setup, ut_teardown,
14866 test_snow3g_decryption_with_digest_test_case_1),
14867 TEST_CASE_ST(ut_setup, ut_teardown,
14868 test_snow3g_hash_generate_test_case_1),
14869 TEST_CASE_ST(ut_setup, ut_teardown,
14870 test_snow3g_hash_generate_test_case_2),
14871 TEST_CASE_ST(ut_setup, ut_teardown,
14872 test_snow3g_hash_generate_test_case_3),
14874 /* Tests with buffers which length is not byte-aligned */
14875 TEST_CASE_ST(ut_setup, ut_teardown,
14876 test_snow3g_hash_generate_test_case_4),
14877 TEST_CASE_ST(ut_setup, ut_teardown,
14878 test_snow3g_hash_generate_test_case_5),
14879 TEST_CASE_ST(ut_setup, ut_teardown,
14880 test_snow3g_hash_generate_test_case_6),
14881 TEST_CASE_ST(ut_setup, ut_teardown,
14882 test_snow3g_hash_verify_test_case_1),
14883 TEST_CASE_ST(ut_setup, ut_teardown,
14884 test_snow3g_hash_verify_test_case_2),
14885 TEST_CASE_ST(ut_setup, ut_teardown,
14886 test_snow3g_hash_verify_test_case_3),
14888 /* Tests with buffers which length is not byte-aligned */
14889 TEST_CASE_ST(ut_setup, ut_teardown,
14890 test_snow3g_hash_verify_test_case_4),
14891 TEST_CASE_ST(ut_setup, ut_teardown,
14892 test_snow3g_hash_verify_test_case_5),
14893 TEST_CASE_ST(ut_setup, ut_teardown,
14894 test_snow3g_hash_verify_test_case_6),
14895 TEST_CASE_ST(ut_setup, ut_teardown,
14896 test_snow3g_cipher_auth_test_case_1),
14897 TEST_CASE_ST(ut_setup, ut_teardown,
14898 test_snow3g_auth_cipher_with_digest_test_case_1),
14903 static struct unit_test_suite cryptodev_zuc_testsuite = {
14904 .suite_name = "ZUC Test Suite",
14905 .setup = zuc_testsuite_setup,
14906 .unit_test_cases = {
14907 /** ZUC encrypt only (EEA3) */
14908 TEST_CASE_ST(ut_setup, ut_teardown,
14909 test_zuc_encryption_test_case_1),
14910 TEST_CASE_ST(ut_setup, ut_teardown,
14911 test_zuc_encryption_test_case_2),
14912 TEST_CASE_ST(ut_setup, ut_teardown,
14913 test_zuc_encryption_test_case_3),
14914 TEST_CASE_ST(ut_setup, ut_teardown,
14915 test_zuc_encryption_test_case_4),
14916 TEST_CASE_ST(ut_setup, ut_teardown,
14917 test_zuc_encryption_test_case_5),
14918 TEST_CASE_ST(ut_setup, ut_teardown,
14919 test_zuc_encryption_test_case_6_sgl),
14921 /** ZUC authenticate (EIA3) */
14922 TEST_CASE_ST(ut_setup, ut_teardown,
14923 test_zuc_hash_generate_test_case_1),
14924 TEST_CASE_ST(ut_setup, ut_teardown,
14925 test_zuc_hash_generate_test_case_2),
14926 TEST_CASE_ST(ut_setup, ut_teardown,
14927 test_zuc_hash_generate_test_case_3),
14928 TEST_CASE_ST(ut_setup, ut_teardown,
14929 test_zuc_hash_generate_test_case_4),
14930 TEST_CASE_ST(ut_setup, ut_teardown,
14931 test_zuc_hash_generate_test_case_5),
14932 TEST_CASE_ST(ut_setup, ut_teardown,
14933 test_zuc_hash_generate_test_case_6),
14934 TEST_CASE_ST(ut_setup, ut_teardown,
14935 test_zuc_hash_generate_test_case_7),
14936 TEST_CASE_ST(ut_setup, ut_teardown,
14937 test_zuc_hash_generate_test_case_8),
14938 TEST_CASE_ST(ut_setup, ut_teardown,
14939 test_zuc_hash_generate_test_case_9),
14940 TEST_CASE_ST(ut_setup, ut_teardown,
14941 test_zuc_hash_generate_test_case_10),
14942 TEST_CASE_ST(ut_setup, ut_teardown,
14943 test_zuc_hash_generate_test_case_11),
14946 /** ZUC alg-chain (EEA3/EIA3) */
14947 TEST_CASE_ST(ut_setup, ut_teardown,
14948 test_zuc_cipher_auth_test_case_1),
14949 TEST_CASE_ST(ut_setup, ut_teardown,
14950 test_zuc_cipher_auth_test_case_2),
14952 /** ZUC generate auth, then encrypt (EEA3) */
14953 TEST_CASE_ST(ut_setup, ut_teardown,
14954 test_zuc_auth_cipher_test_case_1),
14955 TEST_CASE_ST(ut_setup, ut_teardown,
14956 test_zuc_auth_cipher_test_case_1_oop),
14957 TEST_CASE_ST(ut_setup, ut_teardown,
14958 test_zuc_auth_cipher_test_case_1_sgl),
14959 TEST_CASE_ST(ut_setup, ut_teardown,
14960 test_zuc_auth_cipher_test_case_1_oop_sgl),
14962 /** ZUC decrypt (EEA3), then verify auth */
14963 TEST_CASE_ST(ut_setup, ut_teardown,
14964 test_zuc_auth_cipher_verify_test_case_1),
14965 TEST_CASE_ST(ut_setup, ut_teardown,
14966 test_zuc_auth_cipher_verify_test_case_1_oop),
14967 TEST_CASE_ST(ut_setup, ut_teardown,
14968 test_zuc_auth_cipher_verify_test_case_1_sgl),
14969 TEST_CASE_ST(ut_setup, ut_teardown,
14970 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14972 /** ZUC-256 encrypt only **/
14973 TEST_CASE_ST(ut_setup, ut_teardown,
14974 test_zuc256_encryption_test_case_1),
14975 TEST_CASE_ST(ut_setup, ut_teardown,
14976 test_zuc256_encryption_test_case_2),
14978 /** ZUC-256 authentication only **/
14979 TEST_CASE_ST(ut_setup, ut_teardown,
14980 test_zuc256_authentication_test_case_1),
14981 TEST_CASE_ST(ut_setup, ut_teardown,
14982 test_zuc256_authentication_test_case_2),
14988 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14989 .suite_name = "HMAC_MD5 Authentication Test Suite",
14990 .setup = hmac_md5_auth_testsuite_setup,
14991 .unit_test_cases = {
14992 TEST_CASE_ST(ut_setup, ut_teardown,
14993 test_MD5_HMAC_generate_case_1),
14994 TEST_CASE_ST(ut_setup, ut_teardown,
14995 test_MD5_HMAC_verify_case_1),
14996 TEST_CASE_ST(ut_setup, ut_teardown,
14997 test_MD5_HMAC_generate_case_2),
14998 TEST_CASE_ST(ut_setup, ut_teardown,
14999 test_MD5_HMAC_verify_case_2),
15004 static struct unit_test_suite cryptodev_kasumi_testsuite = {
15005 .suite_name = "Kasumi Test Suite",
15006 .setup = kasumi_testsuite_setup,
15007 .unit_test_cases = {
15008 /** KASUMI hash only (UIA1) */
15009 TEST_CASE_ST(ut_setup, ut_teardown,
15010 test_kasumi_hash_generate_test_case_1),
15011 TEST_CASE_ST(ut_setup, ut_teardown,
15012 test_kasumi_hash_generate_test_case_2),
15013 TEST_CASE_ST(ut_setup, ut_teardown,
15014 test_kasumi_hash_generate_test_case_3),
15015 TEST_CASE_ST(ut_setup, ut_teardown,
15016 test_kasumi_hash_generate_test_case_4),
15017 TEST_CASE_ST(ut_setup, ut_teardown,
15018 test_kasumi_hash_generate_test_case_5),
15019 TEST_CASE_ST(ut_setup, ut_teardown,
15020 test_kasumi_hash_generate_test_case_6),
15022 TEST_CASE_ST(ut_setup, ut_teardown,
15023 test_kasumi_hash_verify_test_case_1),
15024 TEST_CASE_ST(ut_setup, ut_teardown,
15025 test_kasumi_hash_verify_test_case_2),
15026 TEST_CASE_ST(ut_setup, ut_teardown,
15027 test_kasumi_hash_verify_test_case_3),
15028 TEST_CASE_ST(ut_setup, ut_teardown,
15029 test_kasumi_hash_verify_test_case_4),
15030 TEST_CASE_ST(ut_setup, ut_teardown,
15031 test_kasumi_hash_verify_test_case_5),
15033 /** KASUMI encrypt only (UEA1) */
15034 TEST_CASE_ST(ut_setup, ut_teardown,
15035 test_kasumi_encryption_test_case_1),
15036 TEST_CASE_ST(ut_setup, ut_teardown,
15037 test_kasumi_encryption_test_case_1_sgl),
15038 TEST_CASE_ST(ut_setup, ut_teardown,
15039 test_kasumi_encryption_test_case_1_oop),
15040 TEST_CASE_ST(ut_setup, ut_teardown,
15041 test_kasumi_encryption_test_case_1_oop_sgl),
15042 TEST_CASE_ST(ut_setup, ut_teardown,
15043 test_kasumi_encryption_test_case_2),
15044 TEST_CASE_ST(ut_setup, ut_teardown,
15045 test_kasumi_encryption_test_case_3),
15046 TEST_CASE_ST(ut_setup, ut_teardown,
15047 test_kasumi_encryption_test_case_4),
15048 TEST_CASE_ST(ut_setup, ut_teardown,
15049 test_kasumi_encryption_test_case_5),
15051 /** KASUMI decrypt only (UEA1) */
15052 TEST_CASE_ST(ut_setup, ut_teardown,
15053 test_kasumi_decryption_test_case_1),
15054 TEST_CASE_ST(ut_setup, ut_teardown,
15055 test_kasumi_decryption_test_case_2),
15056 TEST_CASE_ST(ut_setup, ut_teardown,
15057 test_kasumi_decryption_test_case_3),
15058 TEST_CASE_ST(ut_setup, ut_teardown,
15059 test_kasumi_decryption_test_case_4),
15060 TEST_CASE_ST(ut_setup, ut_teardown,
15061 test_kasumi_decryption_test_case_5),
15062 TEST_CASE_ST(ut_setup, ut_teardown,
15063 test_kasumi_decryption_test_case_1_oop),
15064 TEST_CASE_ST(ut_setup, ut_teardown,
15065 test_kasumi_cipher_auth_test_case_1),
15067 /** KASUMI generate auth, then encrypt (F8) */
15068 TEST_CASE_ST(ut_setup, ut_teardown,
15069 test_kasumi_auth_cipher_test_case_1),
15070 TEST_CASE_ST(ut_setup, ut_teardown,
15071 test_kasumi_auth_cipher_test_case_2),
15072 TEST_CASE_ST(ut_setup, ut_teardown,
15073 test_kasumi_auth_cipher_test_case_2_oop),
15074 TEST_CASE_ST(ut_setup, ut_teardown,
15075 test_kasumi_auth_cipher_test_case_2_sgl),
15076 TEST_CASE_ST(ut_setup, ut_teardown,
15077 test_kasumi_auth_cipher_test_case_2_oop_sgl),
15079 /** KASUMI decrypt (F8), then verify auth */
15080 TEST_CASE_ST(ut_setup, ut_teardown,
15081 test_kasumi_auth_cipher_verify_test_case_1),
15082 TEST_CASE_ST(ut_setup, ut_teardown,
15083 test_kasumi_auth_cipher_verify_test_case_2),
15084 TEST_CASE_ST(ut_setup, ut_teardown,
15085 test_kasumi_auth_cipher_verify_test_case_2_oop),
15086 TEST_CASE_ST(ut_setup, ut_teardown,
15087 test_kasumi_auth_cipher_verify_test_case_2_sgl),
15088 TEST_CASE_ST(ut_setup, ut_teardown,
15089 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
15095 static struct unit_test_suite cryptodev_esn_testsuite = {
15096 .suite_name = "ESN Test Suite",
15097 .setup = esn_testsuite_setup,
15098 .unit_test_cases = {
15099 TEST_CASE_ST(ut_setup, ut_teardown,
15100 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
15101 TEST_CASE_ST(ut_setup, ut_teardown,
15102 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
15107 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
15108 .suite_name = "Negative AES GCM Test Suite",
15109 .setup = negative_aes_gcm_testsuite_setup,
15110 .unit_test_cases = {
15111 TEST_CASE_ST(ut_setup, ut_teardown,
15112 test_AES_GCM_auth_encryption_fail_iv_corrupt),
15113 TEST_CASE_ST(ut_setup, ut_teardown,
15114 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
15115 TEST_CASE_ST(ut_setup, ut_teardown,
15116 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
15117 TEST_CASE_ST(ut_setup, ut_teardown,
15118 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
15119 TEST_CASE_ST(ut_setup, ut_teardown,
15120 test_AES_GCM_auth_encryption_fail_aad_corrupt),
15121 TEST_CASE_ST(ut_setup, ut_teardown,
15122 test_AES_GCM_auth_encryption_fail_tag_corrupt),
15123 TEST_CASE_ST(ut_setup, ut_teardown,
15124 test_AES_GCM_auth_decryption_fail_iv_corrupt),
15125 TEST_CASE_ST(ut_setup, ut_teardown,
15126 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
15127 TEST_CASE_ST(ut_setup, ut_teardown,
15128 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
15129 TEST_CASE_ST(ut_setup, ut_teardown,
15130 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
15131 TEST_CASE_ST(ut_setup, ut_teardown,
15132 test_AES_GCM_auth_decryption_fail_aad_corrupt),
15133 TEST_CASE_ST(ut_setup, ut_teardown,
15134 test_AES_GCM_auth_decryption_fail_tag_corrupt),
15140 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
15141 .suite_name = "Negative AES GMAC Test Suite",
15142 .setup = negative_aes_gmac_testsuite_setup,
15143 .unit_test_cases = {
15144 TEST_CASE_ST(ut_setup, ut_teardown,
15145 authentication_verify_AES128_GMAC_fail_data_corrupt),
15146 TEST_CASE_ST(ut_setup, ut_teardown,
15147 authentication_verify_AES128_GMAC_fail_tag_corrupt),
15153 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
15154 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
15155 .setup = mixed_cipher_hash_testsuite_setup,
15156 .unit_test_cases = {
15157 /** AUTH AES CMAC + CIPHER AES CTR */
15158 TEST_CASE_ST(ut_setup, ut_teardown,
15159 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
15160 TEST_CASE_ST(ut_setup, ut_teardown,
15161 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15162 TEST_CASE_ST(ut_setup, ut_teardown,
15163 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15164 TEST_CASE_ST(ut_setup, ut_teardown,
15165 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15166 TEST_CASE_ST(ut_setup, ut_teardown,
15167 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
15168 TEST_CASE_ST(ut_setup, ut_teardown,
15169 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15170 TEST_CASE_ST(ut_setup, ut_teardown,
15171 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15172 TEST_CASE_ST(ut_setup, ut_teardown,
15173 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15175 /** AUTH ZUC + CIPHER SNOW3G */
15176 TEST_CASE_ST(ut_setup, ut_teardown,
15177 test_auth_zuc_cipher_snow_test_case_1),
15178 TEST_CASE_ST(ut_setup, ut_teardown,
15179 test_verify_auth_zuc_cipher_snow_test_case_1),
15180 /** AUTH AES CMAC + CIPHER SNOW3G */
15181 TEST_CASE_ST(ut_setup, ut_teardown,
15182 test_auth_aes_cmac_cipher_snow_test_case_1),
15183 TEST_CASE_ST(ut_setup, ut_teardown,
15184 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
15185 /** AUTH ZUC + CIPHER AES CTR */
15186 TEST_CASE_ST(ut_setup, ut_teardown,
15187 test_auth_zuc_cipher_aes_ctr_test_case_1),
15188 TEST_CASE_ST(ut_setup, ut_teardown,
15189 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
15190 /** AUTH SNOW3G + CIPHER AES CTR */
15191 TEST_CASE_ST(ut_setup, ut_teardown,
15192 test_auth_snow_cipher_aes_ctr_test_case_1),
15193 TEST_CASE_ST(ut_setup, ut_teardown,
15194 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
15195 /** AUTH SNOW3G + CIPHER ZUC */
15196 TEST_CASE_ST(ut_setup, ut_teardown,
15197 test_auth_snow_cipher_zuc_test_case_1),
15198 TEST_CASE_ST(ut_setup, ut_teardown,
15199 test_verify_auth_snow_cipher_zuc_test_case_1),
15200 /** AUTH AES CMAC + CIPHER ZUC */
15201 TEST_CASE_ST(ut_setup, ut_teardown,
15202 test_auth_aes_cmac_cipher_zuc_test_case_1),
15203 TEST_CASE_ST(ut_setup, ut_teardown,
15204 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
15206 /** AUTH NULL + CIPHER SNOW3G */
15207 TEST_CASE_ST(ut_setup, ut_teardown,
15208 test_auth_null_cipher_snow_test_case_1),
15209 TEST_CASE_ST(ut_setup, ut_teardown,
15210 test_verify_auth_null_cipher_snow_test_case_1),
15211 /** AUTH NULL + CIPHER ZUC */
15212 TEST_CASE_ST(ut_setup, ut_teardown,
15213 test_auth_null_cipher_zuc_test_case_1),
15214 TEST_CASE_ST(ut_setup, ut_teardown,
15215 test_verify_auth_null_cipher_zuc_test_case_1),
15216 /** AUTH SNOW3G + CIPHER NULL */
15217 TEST_CASE_ST(ut_setup, ut_teardown,
15218 test_auth_snow_cipher_null_test_case_1),
15219 TEST_CASE_ST(ut_setup, ut_teardown,
15220 test_verify_auth_snow_cipher_null_test_case_1),
15221 /** AUTH ZUC + CIPHER NULL */
15222 TEST_CASE_ST(ut_setup, ut_teardown,
15223 test_auth_zuc_cipher_null_test_case_1),
15224 TEST_CASE_ST(ut_setup, ut_teardown,
15225 test_verify_auth_zuc_cipher_null_test_case_1),
15226 /** AUTH NULL + CIPHER AES CTR */
15227 TEST_CASE_ST(ut_setup, ut_teardown,
15228 test_auth_null_cipher_aes_ctr_test_case_1),
15229 TEST_CASE_ST(ut_setup, ut_teardown,
15230 test_verify_auth_null_cipher_aes_ctr_test_case_1),
15231 /** AUTH AES CMAC + CIPHER NULL */
15232 TEST_CASE_ST(ut_setup, ut_teardown,
15233 test_auth_aes_cmac_cipher_null_test_case_1),
15234 TEST_CASE_ST(ut_setup, ut_teardown,
15235 test_verify_auth_aes_cmac_cipher_null_test_case_1),
15241 run_cryptodev_testsuite(const char *pmd_name)
15243 uint8_t ret, j, i = 0, blk_start_idx = 0;
15244 const enum blockcipher_test_type blk_suites[] = {
15245 BLKCIPHER_AES_CHAIN_TYPE,
15246 BLKCIPHER_AES_CIPHERONLY_TYPE,
15247 BLKCIPHER_AES_DOCSIS_TYPE,
15248 BLKCIPHER_3DES_CHAIN_TYPE,
15249 BLKCIPHER_3DES_CIPHERONLY_TYPE,
15250 BLKCIPHER_DES_CIPHERONLY_TYPE,
15251 BLKCIPHER_DES_DOCSIS_TYPE,
15252 BLKCIPHER_AUTHONLY_TYPE};
15253 struct unit_test_suite *static_suites[] = {
15254 &cryptodev_multi_session_testsuite,
15255 &cryptodev_null_testsuite,
15256 &cryptodev_aes_ccm_auth_testsuite,
15257 &cryptodev_aes_gcm_auth_testsuite,
15258 &cryptodev_aes_gmac_auth_testsuite,
15259 &cryptodev_snow3g_testsuite,
15260 &cryptodev_chacha20_poly1305_testsuite,
15261 &cryptodev_zuc_testsuite,
15262 &cryptodev_hmac_md5_auth_testsuite,
15263 &cryptodev_kasumi_testsuite,
15264 &cryptodev_esn_testsuite,
15265 &cryptodev_negative_aes_gcm_testsuite,
15266 &cryptodev_negative_aes_gmac_testsuite,
15267 &cryptodev_mixed_cipher_hash_testsuite,
15268 &cryptodev_negative_hmac_sha1_testsuite,
15269 &cryptodev_gen_testsuite,
15270 #ifdef RTE_LIB_SECURITY
15271 &ipsec_proto_testsuite,
15272 &pdcp_proto_testsuite,
15273 &docsis_proto_testsuite,
15277 static struct unit_test_suite ts = {
15278 .suite_name = "Cryptodev Unit Test Suite",
15279 .setup = testsuite_setup,
15280 .teardown = testsuite_teardown,
15281 .unit_test_cases = {TEST_CASES_END()}
15284 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
15286 if (gbl_driver_id == -1) {
15287 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
15288 return TEST_SKIPPED;
15291 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15292 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
15294 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
15295 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15296 ret = unit_test_suite_runner(&ts);
15298 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
15299 free(ts.unit_test_suites);
15304 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
15306 struct rte_cryptodev_info dev_info;
15307 uint8_t i, nb_devs;
15310 driver_id = rte_cryptodev_driver_id_get(pmd_name);
15311 if (driver_id == -1) {
15312 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
15313 return TEST_SKIPPED;
15316 nb_devs = rte_cryptodev_count();
15318 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
15319 return TEST_SKIPPED;
15322 for (i = 0; i < nb_devs; i++) {
15323 rte_cryptodev_info_get(i, &dev_info);
15324 if (dev_info.driver_id == driver_id) {
15325 if (!(dev_info.feature_flags & flag)) {
15326 RTE_LOG(INFO, USER1, "%s not supported\n",
15328 return TEST_SKIPPED;
15330 return 0; /* found */
15334 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
15335 return TEST_SKIPPED;
15339 test_cryptodev_qat(void)
15341 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
15345 test_cryptodev_virtio(void)
15347 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
15351 test_cryptodev_aesni_mb(void)
15353 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15357 test_cryptodev_cpu_aesni_mb(void)
15360 enum rte_security_session_action_type at = gbl_action_type;
15361 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15362 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15363 gbl_action_type = at;
15368 test_cryptodev_chacha_poly_mb(void)
15371 enum rte_security_session_action_type at = gbl_action_type;
15372 rc = run_cryptodev_testsuite(
15373 RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
15374 gbl_action_type = at;
15379 test_cryptodev_openssl(void)
15381 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
15385 test_cryptodev_aesni_gcm(void)
15387 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15391 test_cryptodev_cpu_aesni_gcm(void)
15394 enum rte_security_session_action_type at = gbl_action_type;
15395 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15396 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15397 gbl_action_type = at;
15402 test_cryptodev_mlx5(void)
15404 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
15408 test_cryptodev_null(void)
15410 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
15414 test_cryptodev_sw_snow3g(void)
15416 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
15420 test_cryptodev_sw_kasumi(void)
15422 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
15426 test_cryptodev_sw_zuc(void)
15428 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
15432 test_cryptodev_armv8(void)
15434 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
15438 test_cryptodev_mrvl(void)
15440 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
15443 #ifdef RTE_CRYPTO_SCHEDULER
15446 test_cryptodev_scheduler(void)
15448 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
15449 const enum blockcipher_test_type blk_suites[] = {
15450 BLKCIPHER_AES_CHAIN_TYPE,
15451 BLKCIPHER_AES_CIPHERONLY_TYPE,
15452 BLKCIPHER_AUTHONLY_TYPE
15454 static struct unit_test_suite scheduler_multicore = {
15455 .suite_name = "Scheduler Multicore Unit Test Suite",
15456 .setup = scheduler_multicore_testsuite_setup,
15457 .teardown = scheduler_mode_testsuite_teardown,
15458 .unit_test_cases = {TEST_CASES_END()}
15460 static struct unit_test_suite scheduler_round_robin = {
15461 .suite_name = "Scheduler Round Robin Unit Test Suite",
15462 .setup = scheduler_roundrobin_testsuite_setup,
15463 .teardown = scheduler_mode_testsuite_teardown,
15464 .unit_test_cases = {TEST_CASES_END()}
15466 static struct unit_test_suite scheduler_failover = {
15467 .suite_name = "Scheduler Failover Unit Test Suite",
15468 .setup = scheduler_failover_testsuite_setup,
15469 .teardown = scheduler_mode_testsuite_teardown,
15470 .unit_test_cases = {TEST_CASES_END()}
15472 static struct unit_test_suite scheduler_pkt_size_distr = {
15473 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
15474 .setup = scheduler_pkt_size_distr_testsuite_setup,
15475 .teardown = scheduler_mode_testsuite_teardown,
15476 .unit_test_cases = {TEST_CASES_END()}
15478 struct unit_test_suite *sched_mode_suites[] = {
15479 &scheduler_multicore,
15480 &scheduler_round_robin,
15481 &scheduler_failover,
15482 &scheduler_pkt_size_distr
15484 static struct unit_test_suite scheduler_config = {
15485 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
15486 .unit_test_cases = {
15487 TEST_CASE(test_scheduler_attach_worker_op),
15488 TEST_CASE(test_scheduler_mode_multicore_op),
15489 TEST_CASE(test_scheduler_mode_roundrobin_op),
15490 TEST_CASE(test_scheduler_mode_failover_op),
15491 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
15492 TEST_CASE(test_scheduler_detach_worker_op),
15494 TEST_CASES_END() /**< NULL terminate array */
15497 struct unit_test_suite *static_suites[] = {
15501 static struct unit_test_suite ts = {
15502 .suite_name = "Scheduler Unit Test Suite",
15503 .setup = scheduler_testsuite_setup,
15504 .teardown = testsuite_teardown,
15505 .unit_test_cases = {TEST_CASES_END()}
15508 gbl_driver_id = rte_cryptodev_driver_id_get(
15509 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15511 if (gbl_driver_id == -1) {
15512 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
15513 return TEST_SKIPPED;
15516 if (rte_cryptodev_driver_id_get(
15517 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
15518 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
15519 return TEST_SKIPPED;
15522 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15524 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
15525 (struct unit_test_suite *) *
15526 (RTE_DIM(blk_suites) + 1));
15527 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
15528 blk_suites, RTE_DIM(blk_suites));
15529 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
15532 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15533 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
15534 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
15535 RTE_DIM(sched_mode_suites));
15536 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15537 ret = unit_test_suite_runner(&ts);
15539 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15540 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
15541 (*sched_mode_suites[sched_i]),
15542 RTE_DIM(blk_suites));
15543 free(sched_mode_suites[sched_i]->unit_test_suites);
15545 free(ts.unit_test_suites);
15549 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
15554 test_cryptodev_dpaa2_sec(void)
15556 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
15560 test_cryptodev_dpaa_sec(void)
15562 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
15566 test_cryptodev_ccp(void)
15568 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
15572 test_cryptodev_octeontx(void)
15574 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
15578 test_cryptodev_octeontx2(void)
15580 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
15584 test_cryptodev_caam_jr(void)
15586 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
15590 test_cryptodev_nitrox(void)
15592 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
15596 test_cryptodev_bcmfs(void)
15598 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
15602 test_cryptodev_qat_raw_api(void)
15604 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
15607 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15612 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15613 ret = run_cryptodev_testsuite(pmd_name);
15614 global_api_test_type = CRYPTODEV_API_TEST;
15620 test_cryptodev_cn9k(void)
15622 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
15626 test_cryptodev_cn10k(void)
15628 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
15632 test_cryptodev_dpaa2_sec_raw_api(void)
15634 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
15637 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15642 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15643 ret = run_cryptodev_testsuite(pmd_name);
15644 global_api_test_type = CRYPTODEV_API_TEST;
15650 test_cryptodev_dpaa_sec_raw_api(void)
15652 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
15655 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
15660 global_api_test_type = CRYPTODEV_RAW_API_TEST;
15661 ret = run_cryptodev_testsuite(pmd_name);
15662 global_api_test_type = CRYPTODEV_API_TEST;
15667 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
15668 test_cryptodev_dpaa2_sec_raw_api);
15669 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
15670 test_cryptodev_dpaa_sec_raw_api);
15671 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
15672 test_cryptodev_qat_raw_api);
15673 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
15674 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
15675 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
15676 test_cryptodev_cpu_aesni_mb);
15677 REGISTER_TEST_COMMAND(cryptodev_chacha_poly_mb_autotest,
15678 test_cryptodev_chacha_poly_mb);
15679 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
15680 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
15681 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
15682 test_cryptodev_cpu_aesni_gcm);
15683 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
15684 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
15685 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
15686 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
15687 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
15688 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
15689 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
15690 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
15691 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
15692 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
15693 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
15694 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
15695 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
15696 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
15697 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
15698 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
15699 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
15700 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);