1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
6 #ifndef RTE_EXEC_ENV_WINDOWS
10 #include <rte_common.h>
11 #include <rte_hexdump.h>
13 #include <rte_malloc.h>
14 #include <rte_memcpy.h>
15 #include <rte_pause.h>
16 #include <rte_bus_vdev.h>
17 #include <rte_ether.h>
19 #include <rte_crypto.h>
20 #include <rte_cryptodev.h>
22 #include <rte_string_fns.h>
26 #ifdef RTE_CRYPTO_SCHEDULER
27 #include <rte_cryptodev_scheduler.h>
28 #include <rte_cryptodev_scheduler_operations.h>
31 #include <rte_lcore.h>
34 #include "test_cryptodev.h"
36 #include "test_cryptodev_blockcipher.h"
37 #include "test_cryptodev_aes_test_vectors.h"
38 #include "test_cryptodev_des_test_vectors.h"
39 #include "test_cryptodev_hash_test_vectors.h"
40 #include "test_cryptodev_kasumi_test_vectors.h"
41 #include "test_cryptodev_kasumi_hash_test_vectors.h"
42 #include "test_cryptodev_snow3g_test_vectors.h"
43 #include "test_cryptodev_snow3g_hash_test_vectors.h"
44 #include "test_cryptodev_zuc_test_vectors.h"
45 #include "test_cryptodev_aead_test_vectors.h"
46 #include "test_cryptodev_hmac_test_vectors.h"
47 #include "test_cryptodev_mixed_test_vectors.h"
48 #ifdef RTE_LIB_SECURITY
49 #include "test_cryptodev_security_ipsec.h"
50 #include "test_cryptodev_security_ipsec_test_vectors.h"
51 #include "test_cryptodev_security_pdcp_test_vectors.h"
52 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
53 #include "test_cryptodev_security_pdcp_test_func.h"
54 #include "test_cryptodev_security_docsis_test_vectors.h"
56 #define SDAP_DISABLED 0
57 #define SDAP_ENABLED 1
60 #define VDEV_ARGS_SIZE 100
61 #define MAX_NB_SESSIONS 4
63 #define MAX_DRV_SERVICE_CTX_SIZE 256
65 #define MAX_RAW_DEQUEUE_COUNT 65535
68 #define OUT_OF_PLACE 1
70 static int gbl_driver_id;
72 static enum rte_security_session_action_type gbl_action_type =
73 RTE_SECURITY_ACTION_TYPE_NONE;
75 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
77 struct crypto_unittest_params {
78 struct rte_crypto_sym_xform cipher_xform;
79 struct rte_crypto_sym_xform auth_xform;
80 struct rte_crypto_sym_xform aead_xform;
81 #ifdef RTE_LIB_SECURITY
82 struct rte_security_docsis_xform docsis_xform;
86 struct rte_cryptodev_sym_session *sess;
87 #ifdef RTE_LIB_SECURITY
88 struct rte_security_session *sec_session;
91 #ifdef RTE_LIB_SECURITY
92 enum rte_security_session_action_type type;
94 struct rte_crypto_op *op;
96 struct rte_mbuf *obuf, *ibuf;
101 #define ALIGN_POW2_ROUNDUP(num, align) \
102 (((num) + (align) - 1) & ~((align) - 1))
104 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
105 for (j = 0; j < num_child_ts; index++, j++) \
106 parent_ts.unit_test_suites[index] = child_ts[j]
108 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
109 for (j = 0; j < num_blk_types; index++, j++) \
110 parent_ts.unit_test_suites[index] = \
111 build_blockcipher_test_suite(blk_types[j])
113 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
114 for (j = index; j < index + num_blk_types; j++) \
115 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
118 * Forward declarations.
121 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
122 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
126 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
127 struct crypto_unittest_params *ut_params,
128 struct crypto_testsuite_params *ts_param,
129 const uint8_t *cipher,
130 const uint8_t *digest,
134 security_proto_supported(enum rte_security_session_action_type action,
135 enum rte_security_session_protocol proto);
138 dev_configure_and_start(uint64_t ff_disable);
140 static struct rte_mbuf *
141 setup_test_string(struct rte_mempool *mpool,
142 const char *string, size_t len, uint8_t blocksize)
144 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
145 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
150 memset(m->buf_addr, 0, m->buf_len);
151 dst = rte_pktmbuf_append(m, t_len);
157 rte_memcpy(dst, string, t_len);
159 memset(dst, 0, t_len);
165 /* Get number of bytes in X bits (rounding up) */
167 ceil_byte_length(uint32_t num_bits)
170 return ((num_bits >> 3) + 1);
172 return (num_bits >> 3);
176 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
177 uint8_t is_op_success)
179 struct rte_crypto_op *op = user_data;
180 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
181 RTE_CRYPTO_OP_STATUS_ERROR;
184 static struct crypto_testsuite_params testsuite_params = { NULL };
185 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
186 static struct crypto_unittest_params unittest_params;
189 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
190 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
191 uint8_t len_in_bits, uint8_t cipher_iv_len)
193 struct rte_crypto_sym_op *sop = op->sym;
194 struct rte_crypto_op *ret_op = NULL;
195 struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
196 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
197 union rte_crypto_sym_ofs ofs;
198 struct rte_crypto_sym_vec vec;
199 struct rte_crypto_sgl sgl, dest_sgl;
201 union rte_cryptodev_session_ctx sess;
202 uint64_t auth_end_iova;
204 struct rte_crypto_raw_dp_ctx *ctx;
205 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
209 int ctx_service_size;
211 int enqueue_status, dequeue_status;
212 struct crypto_unittest_params *ut_params = &unittest_params;
213 int is_sgl = sop->m_src->nb_segs > 1;
216 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
217 if (ctx_service_size < 0) {
218 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
222 ctx = malloc(ctx_service_size);
224 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
228 /* Both are enums, setting crypto_sess will suit any session type */
229 sess.crypto_sess = op->sym->session;
231 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
232 op->sess_type, sess, 0) < 0) {
233 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
239 aad_auth_iv.iova = 0;
240 aad_auth_iv.va = NULL;
247 vec.digest = &digest;
248 vec.aad = &aad_auth_iv;
249 vec.status = &status;
253 if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
256 if (is_cipher && is_auth) {
257 cipher_offset = sop->cipher.data.offset;
258 cipher_len = sop->cipher.data.length;
259 auth_offset = sop->auth.data.offset;
260 auth_len = sop->auth.data.length;
261 max_len = RTE_MAX(cipher_offset + cipher_len,
262 auth_offset + auth_len);
264 max_len = max_len >> 3;
265 cipher_offset = cipher_offset >> 3;
266 auth_offset = auth_offset >> 3;
267 cipher_len = cipher_len >> 3;
268 auth_len = auth_len >> 3;
270 ofs.ofs.cipher.head = cipher_offset;
271 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
272 ofs.ofs.auth.head = auth_offset;
273 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
274 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
275 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
276 aad_auth_iv.va = rte_crypto_op_ctod_offset(
277 op, void *, IV_OFFSET + cipher_iv_len);
278 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
280 digest.va = (void *)sop->auth.digest.data;
281 digest.iova = sop->auth.digest.phys_addr;
284 uint32_t remaining_off = auth_offset + auth_len;
285 struct rte_mbuf *sgl_buf = sop->m_src;
287 sgl_buf = sop->m_dst;
289 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
290 && sgl_buf->next != NULL) {
291 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
292 sgl_buf = sgl_buf->next;
295 auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
296 sgl_buf, remaining_off);
298 auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
299 auth_offset + auth_len;
301 /* Then check if digest-encrypted conditions are met */
302 if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
303 (digest.iova == auth_end_iova) && is_sgl)
304 max_len = RTE_MAX(max_len,
305 auth_offset + auth_len +
306 ut_params->auth_xform.auth.digest_length);
308 } else if (is_cipher) {
309 cipher_offset = sop->cipher.data.offset;
310 cipher_len = sop->cipher.data.length;
311 max_len = cipher_len + cipher_offset;
313 max_len = max_len >> 3;
314 cipher_offset = cipher_offset >> 3;
315 cipher_len = cipher_len >> 3;
317 ofs.ofs.cipher.head = cipher_offset;
318 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
319 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
320 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
322 } else if (is_auth) {
323 auth_offset = sop->auth.data.offset;
324 auth_len = sop->auth.data.length;
325 max_len = auth_len + auth_offset;
327 max_len = max_len >> 3;
328 auth_offset = auth_offset >> 3;
329 auth_len = auth_len >> 3;
331 ofs.ofs.auth.head = auth_offset;
332 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
333 aad_auth_iv.va = rte_crypto_op_ctod_offset(
334 op, void *, IV_OFFSET + cipher_iv_len);
335 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
337 digest.va = (void *)sop->auth.digest.data;
338 digest.iova = sop->auth.digest.phys_addr;
341 cipher_offset = sop->aead.data.offset;
342 cipher_len = sop->aead.data.length;
343 max_len = cipher_len + cipher_offset;
345 max_len = max_len >> 3;
346 cipher_offset = cipher_offset >> 3;
347 cipher_len = cipher_len >> 3;
349 ofs.ofs.cipher.head = cipher_offset;
350 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
351 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
352 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
353 aad_auth_iv.va = (void *)sop->aead.aad.data;
354 aad_auth_iv.iova = sop->aead.aad.phys_addr;
355 digest.va = (void *)sop->aead.digest.data;
356 digest.iova = sop->aead.digest.phys_addr;
359 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
360 data_vec, RTE_DIM(data_vec));
361 if (n < 0 || n > sop->m_src->nb_segs) {
362 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
369 dest_sgl.vec = dest_data_vec;
370 vec.dest_sgl = &dest_sgl;
371 n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
372 dest_data_vec, RTE_DIM(dest_data_vec));
373 if (n < 0 || n > sop->m_dst->nb_segs) {
374 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
381 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
382 &enqueue_status) < 1) {
383 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
387 if (enqueue_status == 0) {
388 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
390 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
393 } else if (enqueue_status < 0) {
394 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
399 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
400 n = rte_cryptodev_raw_dequeue_burst(ctx,
401 NULL, 1, post_process_raw_dp_op,
402 (void **)&ret_op, 0, &n_success,
404 if (dequeue_status < 0) {
405 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
412 if (n == 1 && dequeue_status == 0) {
413 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
414 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
419 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
420 ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
421 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
422 RTE_CRYPTO_OP_STATUS_SUCCESS;
429 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
432 struct rte_crypto_sym_op *sop;
433 union rte_crypto_sym_ofs ofs;
434 struct rte_crypto_sgl sgl;
435 struct rte_crypto_sym_vec symvec;
436 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
437 struct rte_crypto_vec vec[UINT8_MAX];
441 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
442 sop->aead.data.length, vec, RTE_DIM(vec));
444 if (n < 0 || n != sop->m_src->nb_segs) {
445 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
451 symvec.src_sgl = &sgl;
453 symvec.digest = &digest_ptr;
454 symvec.aad = &aad_ptr;
458 /* for CPU crypto the IOVA address is not required */
459 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
460 digest_ptr.va = (void *)sop->aead.digest.data;
461 aad_ptr.va = (void *)sop->aead.aad.data;
465 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
469 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
471 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
475 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
478 struct rte_crypto_sym_op *sop;
479 union rte_crypto_sym_ofs ofs;
480 struct rte_crypto_sgl sgl;
481 struct rte_crypto_sym_vec symvec;
482 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
483 struct rte_crypto_vec vec[UINT8_MAX];
487 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
488 sop->auth.data.length, vec, RTE_DIM(vec));
490 if (n < 0 || n != sop->m_src->nb_segs) {
491 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
497 symvec.src_sgl = &sgl;
499 symvec.digest = &digest_ptr;
503 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
504 digest_ptr.va = (void *)sop->auth.digest.data;
507 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
508 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
509 (sop->cipher.data.offset + sop->cipher.data.length);
511 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
515 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
517 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
520 static struct rte_crypto_op *
521 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
524 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
526 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
527 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
533 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
536 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
537 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
545 testsuite_setup(void)
547 struct crypto_testsuite_params *ts_params = &testsuite_params;
548 struct rte_cryptodev_info info;
549 uint32_t i = 0, nb_devs, dev_id;
552 memset(ts_params, 0, sizeof(*ts_params));
554 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
555 if (ts_params->mbuf_pool == NULL) {
556 /* Not already created so create */
557 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
559 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
561 if (ts_params->mbuf_pool == NULL) {
562 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
567 ts_params->large_mbuf_pool = rte_mempool_lookup(
568 "CRYPTO_LARGE_MBUFPOOL");
569 if (ts_params->large_mbuf_pool == NULL) {
570 /* Not already created so create */
571 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
572 "CRYPTO_LARGE_MBUFPOOL",
575 if (ts_params->large_mbuf_pool == NULL) {
577 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
582 ts_params->op_mpool = rte_crypto_op_pool_create(
583 "MBUF_CRYPTO_SYM_OP_POOL",
584 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
585 NUM_MBUFS, MBUF_CACHE_SIZE,
587 sizeof(struct rte_crypto_sym_xform) +
590 if (ts_params->op_mpool == NULL) {
591 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
595 nb_devs = rte_cryptodev_count();
597 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
601 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
602 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
603 rte_cryptodev_driver_name_get(gbl_driver_id));
607 /* Create list of valid crypto devs */
608 for (i = 0; i < nb_devs; i++) {
609 rte_cryptodev_info_get(i, &info);
610 if (info.driver_id == gbl_driver_id)
611 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
614 if (ts_params->valid_dev_count < 1)
617 /* Set up all the qps on the first of the valid devices found */
619 dev_id = ts_params->valid_devs[0];
621 rte_cryptodev_info_get(dev_id, &info);
623 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
624 ts_params->conf.socket_id = SOCKET_ID_ANY;
625 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
627 unsigned int session_size =
628 rte_cryptodev_sym_get_private_session_size(dev_id);
630 #ifdef RTE_LIB_SECURITY
631 unsigned int security_session_size = rte_security_session_get_size(
632 rte_cryptodev_get_sec_ctx(dev_id));
634 if (session_size < security_session_size)
635 session_size = security_session_size;
638 * Create mempool with maximum number of sessions.
640 if (info.sym.max_nb_sessions != 0 &&
641 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
642 RTE_LOG(ERR, USER1, "Device does not support "
643 "at least %u sessions\n",
648 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
649 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
651 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
652 "session mempool allocation failed");
654 ts_params->session_priv_mpool = rte_mempool_create(
658 0, 0, NULL, NULL, NULL,
661 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
662 "session mempool allocation failed");
666 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
668 "Failed to configure cryptodev %u with %u qps",
669 dev_id, ts_params->conf.nb_queue_pairs);
671 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
672 ts_params->qp_conf.mp_session = ts_params->session_mpool;
673 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
675 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
676 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
677 dev_id, qp_id, &ts_params->qp_conf,
678 rte_cryptodev_socket_id(dev_id)),
679 "Failed to setup queue pair %u on cryptodev %u",
687 testsuite_teardown(void)
689 struct crypto_testsuite_params *ts_params = &testsuite_params;
692 if (ts_params->mbuf_pool != NULL) {
693 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
694 rte_mempool_avail_count(ts_params->mbuf_pool));
697 if (ts_params->op_mpool != NULL) {
698 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
699 rte_mempool_avail_count(ts_params->op_mpool));
702 /* Free session mempools */
703 if (ts_params->session_priv_mpool != NULL) {
704 rte_mempool_free(ts_params->session_priv_mpool);
705 ts_params->session_priv_mpool = NULL;
708 if (ts_params->session_mpool != NULL) {
709 rte_mempool_free(ts_params->session_mpool);
710 ts_params->session_mpool = NULL;
713 res = rte_cryptodev_close(ts_params->valid_devs[0]);
715 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
719 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
720 const int *algs, uint16_t num_algs)
722 uint8_t dev_id = testsuite_params.valid_devs[0];
723 bool some_alg_supported = FALSE;
726 for (i = 0; i < num_algs && !some_alg_supported; i++) {
727 struct rte_cryptodev_sym_capability_idx alg = {
730 if (rte_cryptodev_sym_capability_get(dev_id,
732 some_alg_supported = TRUE;
734 if (!some_alg_supported)
741 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
742 uint16_t num_ciphers)
744 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
745 (const int *) ciphers, num_ciphers);
749 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
752 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
753 (const int *) auths, num_auths);
757 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
760 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
761 (const int *) aeads, num_aeads);
765 null_testsuite_setup(void)
767 struct crypto_testsuite_params *ts_params = &testsuite_params;
768 uint8_t dev_id = ts_params->valid_devs[0];
769 struct rte_cryptodev_info dev_info;
770 const enum rte_crypto_cipher_algorithm ciphers[] = {
771 RTE_CRYPTO_CIPHER_NULL
773 const enum rte_crypto_auth_algorithm auths[] = {
777 rte_cryptodev_info_get(dev_id, &dev_info);
779 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
780 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
781 "testsuite not met\n");
785 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
786 && check_auth_capabilities_supported(auths,
787 RTE_DIM(auths)) != 0) {
788 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
789 "testsuite not met\n");
797 crypto_gen_testsuite_setup(void)
799 struct crypto_testsuite_params *ts_params = &testsuite_params;
800 uint8_t dev_id = ts_params->valid_devs[0];
801 struct rte_cryptodev_info dev_info;
803 rte_cryptodev_info_get(dev_id, &dev_info);
805 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
806 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
807 "testsuite not met\n");
814 #ifdef RTE_LIB_SECURITY
816 ipsec_proto_testsuite_setup(void)
818 struct crypto_testsuite_params *ts_params = &testsuite_params;
819 struct crypto_unittest_params *ut_params = &unittest_params;
820 struct rte_cryptodev_info dev_info;
823 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
825 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
826 RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
827 "testsuite not met\n");
831 /* Reconfigure to enable security */
832 ret = dev_configure_and_start(0);
833 if (ret != TEST_SUCCESS)
836 /* Set action type */
837 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
839 if (security_proto_supported(
840 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
841 RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
842 RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
847 test_ipsec_alg_list_populate();
850 * Stop the device. Device would be started again by individual test
851 * case setup routine.
853 rte_cryptodev_stop(ts_params->valid_devs[0]);
859 pdcp_proto_testsuite_setup(void)
861 struct crypto_testsuite_params *ts_params = &testsuite_params;
862 uint8_t dev_id = ts_params->valid_devs[0];
863 struct rte_cryptodev_info dev_info;
864 const enum rte_crypto_cipher_algorithm ciphers[] = {
865 RTE_CRYPTO_CIPHER_NULL,
866 RTE_CRYPTO_CIPHER_AES_CTR,
867 RTE_CRYPTO_CIPHER_ZUC_EEA3,
868 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
870 const enum rte_crypto_auth_algorithm auths[] = {
871 RTE_CRYPTO_AUTH_NULL,
872 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
873 RTE_CRYPTO_AUTH_AES_CMAC,
874 RTE_CRYPTO_AUTH_ZUC_EIA3
877 rte_cryptodev_info_get(dev_id, &dev_info);
879 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
880 !(dev_info.feature_flags &
881 RTE_CRYPTODEV_FF_SECURITY)) {
882 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
883 "testsuite not met\n");
887 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
888 && check_auth_capabilities_supported(auths,
889 RTE_DIM(auths)) != 0) {
890 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
891 "testsuite not met\n");
899 docsis_proto_testsuite_setup(void)
901 struct crypto_testsuite_params *ts_params = &testsuite_params;
902 uint8_t dev_id = ts_params->valid_devs[0];
903 struct rte_cryptodev_info dev_info;
904 const enum rte_crypto_cipher_algorithm ciphers[] = {
905 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
908 rte_cryptodev_info_get(dev_id, &dev_info);
910 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
911 !(dev_info.feature_flags &
912 RTE_CRYPTODEV_FF_SECURITY)) {
913 RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
914 "Proto testsuite not met\n");
918 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
919 RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
920 "testsuite not met\n");
929 aes_ccm_auth_testsuite_setup(void)
931 struct crypto_testsuite_params *ts_params = &testsuite_params;
932 uint8_t dev_id = ts_params->valid_devs[0];
933 struct rte_cryptodev_info dev_info;
934 const enum rte_crypto_aead_algorithm aeads[] = {
935 RTE_CRYPTO_AEAD_AES_CCM
938 rte_cryptodev_info_get(dev_id, &dev_info);
940 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
941 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
942 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
943 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
944 "testsuite not met\n");
948 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
949 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
950 "testsuite not met\n");
958 aes_gcm_auth_testsuite_setup(void)
960 struct crypto_testsuite_params *ts_params = &testsuite_params;
961 uint8_t dev_id = ts_params->valid_devs[0];
962 struct rte_cryptodev_info dev_info;
963 const enum rte_crypto_aead_algorithm aeads[] = {
964 RTE_CRYPTO_AEAD_AES_GCM
967 rte_cryptodev_info_get(dev_id, &dev_info);
969 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
970 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
971 "testsuite not met\n");
975 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
976 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
977 "testsuite not met\n");
985 aes_gmac_auth_testsuite_setup(void)
987 struct crypto_testsuite_params *ts_params = &testsuite_params;
988 uint8_t dev_id = ts_params->valid_devs[0];
989 struct rte_cryptodev_info dev_info;
990 const enum rte_crypto_auth_algorithm auths[] = {
991 RTE_CRYPTO_AUTH_AES_GMAC
994 rte_cryptodev_info_get(dev_id, &dev_info);
996 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
997 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
998 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
999 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1000 "testsuite not met\n");
1001 return TEST_SKIPPED;
1004 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1005 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1006 "testsuite not met\n");
1007 return TEST_SKIPPED;
1014 chacha20_poly1305_testsuite_setup(void)
1016 struct crypto_testsuite_params *ts_params = &testsuite_params;
1017 uint8_t dev_id = ts_params->valid_devs[0];
1018 struct rte_cryptodev_info dev_info;
1019 const enum rte_crypto_aead_algorithm aeads[] = {
1020 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1023 rte_cryptodev_info_get(dev_id, &dev_info);
1025 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1026 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1027 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1028 RTE_LOG(INFO, USER1, "Feature flag requirements for "
1029 "Chacha20-Poly1305 testsuite not met\n");
1030 return TEST_SKIPPED;
1033 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1034 RTE_LOG(INFO, USER1, "Capability requirements for "
1035 "Chacha20-Poly1305 testsuite not met\n");
1036 return TEST_SKIPPED;
1043 snow3g_testsuite_setup(void)
1045 struct crypto_testsuite_params *ts_params = &testsuite_params;
1046 uint8_t dev_id = ts_params->valid_devs[0];
1047 struct rte_cryptodev_info dev_info;
1048 const enum rte_crypto_cipher_algorithm ciphers[] = {
1049 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1052 const enum rte_crypto_auth_algorithm auths[] = {
1053 RTE_CRYPTO_AUTH_SNOW3G_UIA2
1056 rte_cryptodev_info_get(dev_id, &dev_info);
1058 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1059 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1060 "testsuite not met\n");
1061 return TEST_SKIPPED;
1064 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1065 && check_auth_capabilities_supported(auths,
1066 RTE_DIM(auths)) != 0) {
1067 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1068 "testsuite not met\n");
1069 return TEST_SKIPPED;
1076 zuc_testsuite_setup(void)
1078 struct crypto_testsuite_params *ts_params = &testsuite_params;
1079 uint8_t dev_id = ts_params->valid_devs[0];
1080 struct rte_cryptodev_info dev_info;
1081 const enum rte_crypto_cipher_algorithm ciphers[] = {
1082 RTE_CRYPTO_CIPHER_ZUC_EEA3
1084 const enum rte_crypto_auth_algorithm auths[] = {
1085 RTE_CRYPTO_AUTH_ZUC_EIA3
1088 rte_cryptodev_info_get(dev_id, &dev_info);
1090 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1091 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1092 "testsuite not met\n");
1093 return TEST_SKIPPED;
1096 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1097 && check_auth_capabilities_supported(auths,
1098 RTE_DIM(auths)) != 0) {
1099 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1100 "testsuite not met\n");
1101 return TEST_SKIPPED;
1108 hmac_md5_auth_testsuite_setup(void)
1110 struct crypto_testsuite_params *ts_params = &testsuite_params;
1111 uint8_t dev_id = ts_params->valid_devs[0];
1112 struct rte_cryptodev_info dev_info;
1113 const enum rte_crypto_auth_algorithm auths[] = {
1114 RTE_CRYPTO_AUTH_MD5_HMAC
1117 rte_cryptodev_info_get(dev_id, &dev_info);
1119 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1120 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1121 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1122 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1123 "Auth testsuite not met\n");
1124 return TEST_SKIPPED;
1127 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1128 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1129 "testsuite not met\n");
1130 return TEST_SKIPPED;
1137 kasumi_testsuite_setup(void)
1139 struct crypto_testsuite_params *ts_params = &testsuite_params;
1140 uint8_t dev_id = ts_params->valid_devs[0];
1141 struct rte_cryptodev_info dev_info;
1142 const enum rte_crypto_cipher_algorithm ciphers[] = {
1143 RTE_CRYPTO_CIPHER_KASUMI_F8
1145 const enum rte_crypto_auth_algorithm auths[] = {
1146 RTE_CRYPTO_AUTH_KASUMI_F9
1149 rte_cryptodev_info_get(dev_id, &dev_info);
1151 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1152 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1153 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1154 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1155 "testsuite not met\n");
1156 return TEST_SKIPPED;
1159 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1160 && check_auth_capabilities_supported(auths,
1161 RTE_DIM(auths)) != 0) {
1162 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1163 "testsuite not met\n");
1164 return TEST_SKIPPED;
1171 negative_aes_gcm_testsuite_setup(void)
1173 struct crypto_testsuite_params *ts_params = &testsuite_params;
1174 uint8_t dev_id = ts_params->valid_devs[0];
1175 struct rte_cryptodev_info dev_info;
1176 const enum rte_crypto_aead_algorithm aeads[] = {
1177 RTE_CRYPTO_AEAD_AES_GCM
1180 rte_cryptodev_info_get(dev_id, &dev_info);
1182 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1183 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1184 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1185 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1186 "AES GCM testsuite not met\n");
1187 return TEST_SKIPPED;
1190 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1191 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1192 "AES GCM testsuite not met\n");
1193 return TEST_SKIPPED;
1200 negative_aes_gmac_testsuite_setup(void)
1202 struct crypto_testsuite_params *ts_params = &testsuite_params;
1203 uint8_t dev_id = ts_params->valid_devs[0];
1204 struct rte_cryptodev_info dev_info;
1205 const enum rte_crypto_auth_algorithm auths[] = {
1206 RTE_CRYPTO_AUTH_AES_GMAC
1209 rte_cryptodev_info_get(dev_id, &dev_info);
1211 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1212 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1213 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1214 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1215 "AES GMAC testsuite not met\n");
1216 return TEST_SKIPPED;
1219 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1220 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1221 "AES GMAC testsuite not met\n");
1222 return TEST_SKIPPED;
1229 mixed_cipher_hash_testsuite_setup(void)
1231 struct crypto_testsuite_params *ts_params = &testsuite_params;
1232 uint8_t dev_id = ts_params->valid_devs[0];
1233 struct rte_cryptodev_info dev_info;
1234 uint64_t feat_flags;
1235 const enum rte_crypto_cipher_algorithm ciphers[] = {
1236 RTE_CRYPTO_CIPHER_NULL,
1237 RTE_CRYPTO_CIPHER_AES_CTR,
1238 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1239 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1241 const enum rte_crypto_auth_algorithm auths[] = {
1242 RTE_CRYPTO_AUTH_NULL,
1243 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1244 RTE_CRYPTO_AUTH_AES_CMAC,
1245 RTE_CRYPTO_AUTH_ZUC_EIA3
1248 rte_cryptodev_info_get(dev_id, &dev_info);
1249 feat_flags = dev_info.feature_flags;
1251 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1252 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1253 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1254 "Cipher Hash testsuite not met\n");
1255 return TEST_SKIPPED;
1258 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1259 && check_auth_capabilities_supported(auths,
1260 RTE_DIM(auths)) != 0) {
1261 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1262 "Cipher Hash testsuite not met\n");
1263 return TEST_SKIPPED;
1270 esn_testsuite_setup(void)
1272 struct crypto_testsuite_params *ts_params = &testsuite_params;
1273 uint8_t dev_id = ts_params->valid_devs[0];
1274 struct rte_cryptodev_info dev_info;
1275 const enum rte_crypto_cipher_algorithm ciphers[] = {
1276 RTE_CRYPTO_CIPHER_AES_CBC
1278 const enum rte_crypto_auth_algorithm auths[] = {
1279 RTE_CRYPTO_AUTH_SHA1_HMAC
1282 rte_cryptodev_info_get(dev_id, &dev_info);
1284 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1285 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1286 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1287 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1288 "testsuite not met\n");
1289 return TEST_SKIPPED;
1292 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1293 && check_auth_capabilities_supported(auths,
1294 RTE_DIM(auths)) != 0) {
1295 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1296 "testsuite not met\n");
1297 return TEST_SKIPPED;
1304 multi_session_testsuite_setup(void)
1306 struct crypto_testsuite_params *ts_params = &testsuite_params;
1307 uint8_t dev_id = ts_params->valid_devs[0];
1308 struct rte_cryptodev_info dev_info;
1309 const enum rte_crypto_cipher_algorithm ciphers[] = {
1310 RTE_CRYPTO_CIPHER_AES_CBC
1312 const enum rte_crypto_auth_algorithm auths[] = {
1313 RTE_CRYPTO_AUTH_SHA512_HMAC
1316 rte_cryptodev_info_get(dev_id, &dev_info);
1318 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1319 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1320 "Session testsuite not met\n");
1321 return TEST_SKIPPED;
1324 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1325 && check_auth_capabilities_supported(auths,
1326 RTE_DIM(auths)) != 0) {
1327 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1328 "Session testsuite not met\n");
1329 return TEST_SKIPPED;
1336 negative_hmac_sha1_testsuite_setup(void)
1338 struct crypto_testsuite_params *ts_params = &testsuite_params;
1339 uint8_t dev_id = ts_params->valid_devs[0];
1340 struct rte_cryptodev_info dev_info;
1341 const enum rte_crypto_cipher_algorithm ciphers[] = {
1342 RTE_CRYPTO_CIPHER_AES_CBC
1344 const enum rte_crypto_auth_algorithm auths[] = {
1345 RTE_CRYPTO_AUTH_SHA1_HMAC
1348 rte_cryptodev_info_get(dev_id, &dev_info);
1350 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1351 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1352 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1353 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1354 "HMAC SHA1 testsuite not met\n");
1355 return TEST_SKIPPED;
1358 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1359 && check_auth_capabilities_supported(auths,
1360 RTE_DIM(auths)) != 0) {
1361 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1362 "HMAC SHA1 testsuite not met\n");
1363 return TEST_SKIPPED;
1370 dev_configure_and_start(uint64_t ff_disable)
1372 struct crypto_testsuite_params *ts_params = &testsuite_params;
1373 struct crypto_unittest_params *ut_params = &unittest_params;
1377 /* Clear unit test parameters before running test */
1378 memset(ut_params, 0, sizeof(*ut_params));
1380 /* Reconfigure device to default parameters */
1381 ts_params->conf.socket_id = SOCKET_ID_ANY;
1382 ts_params->conf.ff_disable = ff_disable;
1383 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1384 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1385 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1387 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1389 "Failed to configure cryptodev %u",
1390 ts_params->valid_devs[0]);
1392 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1393 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1394 ts_params->valid_devs[0], qp_id,
1395 &ts_params->qp_conf,
1396 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1397 "Failed to setup queue pair %u on cryptodev %u",
1398 qp_id, ts_params->valid_devs[0]);
1402 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1404 /* Start the device */
1405 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1406 "Failed to start cryptodev %u",
1407 ts_params->valid_devs[0]);
1409 return TEST_SUCCESS;
1415 /* Configure and start the device with security feature disabled */
1416 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1420 ut_setup_security(void)
1422 /* Configure and start the device with no features disabled */
1423 return dev_configure_and_start(0);
1429 struct crypto_testsuite_params *ts_params = &testsuite_params;
1430 struct crypto_unittest_params *ut_params = &unittest_params;
1432 /* free crypto session structure */
1433 #ifdef RTE_LIB_SECURITY
1434 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1435 if (ut_params->sec_session) {
1436 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1437 (ts_params->valid_devs[0]),
1438 ut_params->sec_session);
1439 ut_params->sec_session = NULL;
1444 if (ut_params->sess) {
1445 rte_cryptodev_sym_session_clear(
1446 ts_params->valid_devs[0],
1448 rte_cryptodev_sym_session_free(ut_params->sess);
1449 ut_params->sess = NULL;
1453 /* free crypto operation structure */
1455 rte_crypto_op_free(ut_params->op);
1458 * free mbuf - both obuf and ibuf are usually the same,
1459 * so check if they point at the same address is necessary,
1460 * to avoid freeing the mbuf twice.
1462 if (ut_params->obuf) {
1463 rte_pktmbuf_free(ut_params->obuf);
1464 if (ut_params->ibuf == ut_params->obuf)
1465 ut_params->ibuf = 0;
1466 ut_params->obuf = 0;
1468 if (ut_params->ibuf) {
1469 rte_pktmbuf_free(ut_params->ibuf);
1470 ut_params->ibuf = 0;
1473 if (ts_params->mbuf_pool != NULL)
1474 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1475 rte_mempool_avail_count(ts_params->mbuf_pool));
1477 /* Stop the device */
1478 rte_cryptodev_stop(ts_params->valid_devs[0]);
1482 test_device_configure_invalid_dev_id(void)
1484 struct crypto_testsuite_params *ts_params = &testsuite_params;
1485 uint16_t dev_id, num_devs = 0;
1487 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1488 "Need at least %d devices for test", 1);
1490 /* valid dev_id values */
1491 dev_id = ts_params->valid_devs[0];
1493 /* Stop the device in case it's started so it can be configured */
1494 rte_cryptodev_stop(dev_id);
1496 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1497 "Failed test for rte_cryptodev_configure: "
1498 "invalid dev_num %u", dev_id);
1500 /* invalid dev_id values */
1503 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1504 "Failed test for rte_cryptodev_configure: "
1505 "invalid dev_num %u", dev_id);
1509 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1510 "Failed test for rte_cryptodev_configure:"
1511 "invalid dev_num %u", dev_id);
1513 return TEST_SUCCESS;
1517 test_device_configure_invalid_queue_pair_ids(void)
1519 struct crypto_testsuite_params *ts_params = &testsuite_params;
1520 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1522 /* Stop the device in case it's started so it can be configured */
1523 rte_cryptodev_stop(ts_params->valid_devs[0]);
1525 /* valid - max value queue pairs */
1526 ts_params->conf.nb_queue_pairs = orig_nb_qps;
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], ts_params->conf.nb_queue_pairs);
1533 /* valid - one queue pairs */
1534 ts_params->conf.nb_queue_pairs = 1;
1536 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1538 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1539 ts_params->valid_devs[0],
1540 ts_params->conf.nb_queue_pairs);
1543 /* invalid - zero queue pairs */
1544 ts_params->conf.nb_queue_pairs = 0;
1546 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1548 "Failed test for rte_cryptodev_configure, dev_id %u,"
1550 ts_params->valid_devs[0],
1551 ts_params->conf.nb_queue_pairs);
1554 /* invalid - max value supported by field queue pairs */
1555 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1557 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1559 "Failed test for rte_cryptodev_configure, dev_id %u,"
1561 ts_params->valid_devs[0],
1562 ts_params->conf.nb_queue_pairs);
1565 /* invalid - max value + 1 queue pairs */
1566 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1568 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1570 "Failed test for rte_cryptodev_configure, dev_id %u,"
1572 ts_params->valid_devs[0],
1573 ts_params->conf.nb_queue_pairs);
1575 /* revert to original testsuite value */
1576 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1578 return TEST_SUCCESS;
1582 test_queue_pair_descriptor_setup(void)
1584 struct crypto_testsuite_params *ts_params = &testsuite_params;
1585 struct rte_cryptodev_qp_conf qp_conf = {
1586 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1590 /* Stop the device in case it's started so it can be configured */
1591 rte_cryptodev_stop(ts_params->valid_devs[0]);
1593 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1595 "Failed to configure cryptodev %u",
1596 ts_params->valid_devs[0]);
1599 * Test various ring sizes on this device. memzones can't be
1600 * freed so are re-used if ring is released and re-created.
1602 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1603 qp_conf.mp_session = ts_params->session_mpool;
1604 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1606 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1607 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1608 ts_params->valid_devs[0], qp_id, &qp_conf,
1609 rte_cryptodev_socket_id(
1610 ts_params->valid_devs[0])),
1612 "rte_cryptodev_queue_pair_setup: num_inflights "
1613 "%u on qp %u on cryptodev %u",
1614 qp_conf.nb_descriptors, qp_id,
1615 ts_params->valid_devs[0]);
1618 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1620 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1621 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1622 ts_params->valid_devs[0], qp_id, &qp_conf,
1623 rte_cryptodev_socket_id(
1624 ts_params->valid_devs[0])),
1626 " rte_cryptodev_queue_pair_setup: num_inflights"
1627 " %u on qp %u on cryptodev %u",
1628 qp_conf.nb_descriptors, qp_id,
1629 ts_params->valid_devs[0]);
1632 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1634 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1635 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1636 ts_params->valid_devs[0], qp_id, &qp_conf,
1637 rte_cryptodev_socket_id(
1638 ts_params->valid_devs[0])),
1640 "rte_cryptodev_queue_pair_setup: num_inflights"
1641 " %u on qp %u on cryptodev %u",
1642 qp_conf.nb_descriptors, qp_id,
1643 ts_params->valid_devs[0]);
1646 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1648 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1649 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1650 ts_params->valid_devs[0], qp_id, &qp_conf,
1651 rte_cryptodev_socket_id(
1652 ts_params->valid_devs[0])),
1654 " rte_cryptodev_queue_pair_setup:"
1655 "num_inflights %u on qp %u on cryptodev %u",
1656 qp_conf.nb_descriptors, qp_id,
1657 ts_params->valid_devs[0]);
1660 /* test invalid queue pair id */
1661 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1663 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1665 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1666 ts_params->valid_devs[0],
1668 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1669 "Failed test for rte_cryptodev_queue_pair_setup:"
1670 "invalid qp %u on cryptodev %u",
1671 qp_id, ts_params->valid_devs[0]);
1673 qp_id = 0xffff; /*invalid*/
1675 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1676 ts_params->valid_devs[0],
1678 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1679 "Failed test for rte_cryptodev_queue_pair_setup:"
1680 "invalid qp %u on cryptodev %u",
1681 qp_id, ts_params->valid_devs[0]);
1683 return TEST_SUCCESS;
1686 /* ***** Plaintext data for tests ***** */
1688 const char catch_22_quote_1[] =
1689 "There was only one catch and that was Catch-22, which "
1690 "specified that a concern for one's safety in the face of "
1691 "dangers that were real and immediate was the process of a "
1692 "rational mind. Orr was crazy and could be grounded. All he "
1693 "had to do was ask; and as soon as he did, he would no longer "
1694 "be crazy and would have to fly more missions. Orr would be "
1695 "crazy to fly more missions and sane if he didn't, but if he "
1696 "was sane he had to fly them. If he flew them he was crazy "
1697 "and didn't have to; but if he didn't want to he was sane and "
1698 "had to. Yossarian was moved very deeply by the absolute "
1699 "simplicity of this clause of Catch-22 and let out a "
1700 "respectful whistle. \"That's some catch, that Catch-22\", he "
1701 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1703 const char catch_22_quote[] =
1704 "What a lousy earth! He wondered how many people were "
1705 "destitute that same night even in his own prosperous country, "
1706 "how many homes were shanties, how many husbands were drunk "
1707 "and wives socked, and how many children were bullied, abused, "
1708 "or abandoned. How many families hungered for food they could "
1709 "not afford to buy? How many hearts were broken? How many "
1710 "suicides would take place that same night, how many people "
1711 "would go insane? How many cockroaches and landlords would "
1712 "triumph? How many winners were losers, successes failures, "
1713 "and rich men poor men? How many wise guys were stupid? How "
1714 "many happy endings were unhappy endings? How many honest men "
1715 "were liars, brave men cowards, loyal men traitors, how many "
1716 "sainted men were corrupt, how many people in positions of "
1717 "trust had sold their souls to bodyguards, how many had never "
1718 "had souls? How many straight-and-narrow paths were crooked "
1719 "paths? How many best families were worst families and how "
1720 "many good people were bad people? When you added them all up "
1721 "and then subtracted, you might be left with only the children, "
1722 "and perhaps with Albert Einstein and an old violinist or "
1723 "sculptor somewhere.";
1725 #define QUOTE_480_BYTES (480)
1726 #define QUOTE_512_BYTES (512)
1727 #define QUOTE_768_BYTES (768)
1728 #define QUOTE_1024_BYTES (1024)
1732 /* ***** SHA1 Hash Tests ***** */
1734 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1736 static uint8_t hmac_sha1_key[] = {
1737 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1738 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1739 0xDE, 0xF4, 0xDE, 0xAD };
1741 /* ***** SHA224 Hash Tests ***** */
1743 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1746 /* ***** AES-CBC Cipher Tests ***** */
1748 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1749 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1751 static uint8_t aes_cbc_key[] = {
1752 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1753 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1755 static uint8_t aes_cbc_iv[] = {
1756 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1757 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1760 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1762 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1763 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1764 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1765 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1766 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1767 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1768 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1769 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1770 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1771 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1772 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1773 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1774 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1775 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1776 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1777 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1778 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1779 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1780 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1781 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1782 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1783 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1784 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1785 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1786 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1787 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1788 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1789 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1790 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1791 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1792 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1793 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1794 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1795 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1796 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1797 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1798 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1799 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1800 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1801 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1802 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1803 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1804 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1805 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1806 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1807 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1808 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1809 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1810 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1811 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1812 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1813 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1814 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1815 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1816 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1817 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1818 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1819 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1820 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1821 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1822 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1823 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1824 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1825 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1826 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1829 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1830 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1831 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1832 0x18, 0x8c, 0x1d, 0x32
1836 /* Multisession Vector context Test */
1837 /*Begin Session 0 */
1838 static uint8_t ms_aes_cbc_key0[] = {
1839 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1840 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1843 static uint8_t ms_aes_cbc_iv0[] = {
1844 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1845 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1848 static const uint8_t ms_aes_cbc_cipher0[] = {
1849 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1850 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1851 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1852 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1853 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1854 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1855 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1856 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1857 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1858 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1859 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1860 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1861 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1862 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1863 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1864 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1865 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1866 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1867 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1868 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1869 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1870 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1871 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1872 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1873 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1874 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1875 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1876 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1877 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1878 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1879 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1880 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1881 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1882 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1883 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1884 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1885 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1886 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1887 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1888 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1889 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1890 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1891 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1892 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1893 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1894 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1895 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1896 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1897 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1898 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1899 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1900 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1901 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1902 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1903 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1904 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1905 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1906 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1907 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1908 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1909 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1910 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1911 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1912 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1916 static uint8_t ms_hmac_key0[] = {
1917 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1918 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1919 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1920 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1921 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1922 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1923 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1924 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1927 static const uint8_t ms_hmac_digest0[] = {
1928 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1929 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1930 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1931 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1932 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1933 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1934 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1935 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1939 /* Begin session 1 */
1941 static uint8_t ms_aes_cbc_key1[] = {
1942 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1943 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1946 static uint8_t ms_aes_cbc_iv1[] = {
1947 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1948 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1951 static const uint8_t ms_aes_cbc_cipher1[] = {
1952 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1953 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1954 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1955 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1956 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1957 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1958 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1959 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1960 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1961 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1962 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1963 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1964 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1965 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1966 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1967 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1968 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1969 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1970 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1971 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1972 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1973 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1974 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1975 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1976 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1977 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1978 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1979 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1980 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1981 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1982 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1983 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1984 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1985 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1986 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1987 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1988 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1989 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1990 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1991 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1992 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1993 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1994 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1995 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1996 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1997 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1998 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1999 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2000 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2001 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2002 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2003 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2004 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2005 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2006 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2007 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2008 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2009 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2010 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2011 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2012 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2013 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2014 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2015 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2019 static uint8_t ms_hmac_key1[] = {
2020 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2021 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2022 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2023 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2024 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2025 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2026 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2027 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2030 static const uint8_t ms_hmac_digest1[] = {
2031 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2032 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2033 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2034 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2035 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2036 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2037 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2038 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2041 /* Begin Session 2 */
2042 static uint8_t ms_aes_cbc_key2[] = {
2043 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2044 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2047 static uint8_t ms_aes_cbc_iv2[] = {
2048 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2049 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2052 static const uint8_t ms_aes_cbc_cipher2[] = {
2053 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2054 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2055 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2056 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2057 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2058 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2059 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2060 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2061 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2062 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2063 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2064 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2065 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2066 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2067 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2068 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2069 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2070 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2071 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2072 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2073 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2074 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2075 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2076 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2077 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2078 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2079 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2080 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2081 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2082 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2083 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2084 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2085 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2086 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2087 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2088 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2089 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2090 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2091 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2092 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2093 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2094 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2095 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2096 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2097 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2098 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2099 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2100 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2101 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2102 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2103 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2104 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2105 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2106 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2107 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2108 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2109 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2110 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2111 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2112 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2113 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2114 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2115 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2116 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2119 static uint8_t ms_hmac_key2[] = {
2120 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2121 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2122 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2123 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2124 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2125 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2126 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2127 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2130 static const uint8_t ms_hmac_digest2[] = {
2131 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2132 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2133 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2134 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2135 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2136 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2137 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2138 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2145 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2147 struct crypto_testsuite_params *ts_params = &testsuite_params;
2148 struct crypto_unittest_params *ut_params = &unittest_params;
2151 /* Verify the capabilities */
2152 struct rte_cryptodev_sym_capability_idx cap_idx;
2153 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2154 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2155 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2157 return TEST_SKIPPED;
2158 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2159 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2160 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2162 return TEST_SKIPPED;
2164 /* Generate test mbuf data and space for digest */
2165 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2166 catch_22_quote, QUOTE_512_BYTES, 0);
2168 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2169 DIGEST_BYTE_LENGTH_SHA1);
2170 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2172 /* Setup Cipher Parameters */
2173 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2174 ut_params->cipher_xform.next = &ut_params->auth_xform;
2176 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2177 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2178 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2179 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2180 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2181 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2183 /* Setup HMAC Parameters */
2184 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2186 ut_params->auth_xform.next = NULL;
2188 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2189 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2190 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2191 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2192 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2194 ut_params->sess = rte_cryptodev_sym_session_create(
2195 ts_params->session_mpool);
2196 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2198 /* Create crypto session*/
2199 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2200 ut_params->sess, &ut_params->cipher_xform,
2201 ts_params->session_priv_mpool);
2203 if (status == -ENOTSUP)
2204 return TEST_SKIPPED;
2206 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
2208 /* Generate crypto op data structure */
2209 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2210 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2211 TEST_ASSERT_NOT_NULL(ut_params->op,
2212 "Failed to allocate symmetric crypto operation struct");
2214 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2216 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2218 /* set crypto operation source mbuf */
2219 sym_op->m_src = ut_params->ibuf;
2221 /* Set crypto operation authentication parameters */
2222 sym_op->auth.digest.data = ut_params->digest;
2223 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2224 ut_params->ibuf, QUOTE_512_BYTES);
2226 sym_op->auth.data.offset = 0;
2227 sym_op->auth.data.length = QUOTE_512_BYTES;
2229 /* Copy IV at the end of the crypto operation */
2230 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2231 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2233 /* Set crypto operation cipher parameters */
2234 sym_op->cipher.data.offset = 0;
2235 sym_op->cipher.data.length = QUOTE_512_BYTES;
2237 /* Process crypto operation */
2238 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2239 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2242 TEST_ASSERT_NOT_NULL(
2243 process_crypto_request(ts_params->valid_devs[0],
2245 "failed to process sym crypto op");
2247 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2248 "crypto op processing failed");
2251 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2254 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2255 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2257 "ciphertext data not as expected");
2259 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2261 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2262 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2263 gbl_driver_id == rte_cryptodev_driver_id_get(
2264 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2265 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2266 DIGEST_BYTE_LENGTH_SHA1,
2267 "Generated digest data not as expected");
2269 return TEST_SUCCESS;
2272 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2274 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2276 static uint8_t hmac_sha512_key[] = {
2277 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2278 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2279 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2280 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2281 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2282 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2283 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2284 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2286 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2287 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2288 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2289 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2290 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2291 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2292 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2293 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2294 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2299 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2300 struct crypto_unittest_params *ut_params,
2301 uint8_t *cipher_key,
2305 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2306 struct crypto_unittest_params *ut_params,
2307 struct crypto_testsuite_params *ts_params,
2308 const uint8_t *cipher,
2309 const uint8_t *digest,
2314 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2315 struct crypto_unittest_params *ut_params,
2316 uint8_t *cipher_key,
2320 /* Setup Cipher Parameters */
2321 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2322 ut_params->cipher_xform.next = NULL;
2324 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2325 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2326 ut_params->cipher_xform.cipher.key.data = cipher_key;
2327 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2328 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2329 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2331 /* Setup HMAC Parameters */
2332 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2333 ut_params->auth_xform.next = &ut_params->cipher_xform;
2335 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2336 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2337 ut_params->auth_xform.auth.key.data = hmac_key;
2338 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2339 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2341 return TEST_SUCCESS;
2346 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2347 struct crypto_unittest_params *ut_params,
2348 struct crypto_testsuite_params *ts_params,
2349 const uint8_t *cipher,
2350 const uint8_t *digest,
2353 /* Generate test mbuf data and digest */
2354 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2357 QUOTE_512_BYTES, 0);
2359 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2360 DIGEST_BYTE_LENGTH_SHA512);
2361 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2363 rte_memcpy(ut_params->digest,
2365 DIGEST_BYTE_LENGTH_SHA512);
2367 /* Generate Crypto op data structure */
2368 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2369 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2370 TEST_ASSERT_NOT_NULL(ut_params->op,
2371 "Failed to allocate symmetric crypto operation struct");
2373 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2375 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2377 /* set crypto operation source mbuf */
2378 sym_op->m_src = ut_params->ibuf;
2380 sym_op->auth.digest.data = ut_params->digest;
2381 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2382 ut_params->ibuf, QUOTE_512_BYTES);
2384 sym_op->auth.data.offset = 0;
2385 sym_op->auth.data.length = QUOTE_512_BYTES;
2387 /* Copy IV at the end of the crypto operation */
2388 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2389 iv, CIPHER_IV_LENGTH_AES_CBC);
2391 sym_op->cipher.data.offset = 0;
2392 sym_op->cipher.data.length = QUOTE_512_BYTES;
2394 /* Process crypto operation */
2395 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2396 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2398 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2399 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2400 ut_params->op, 1, 1, 0, 0);
2402 TEST_ASSERT_NOT_NULL(
2403 process_crypto_request(ts_params->valid_devs[0],
2405 "failed to process sym crypto op");
2407 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2408 "crypto op processing failed");
2410 ut_params->obuf = ut_params->op->sym->m_src;
2413 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2414 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2417 "Plaintext data not as expected");
2420 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2421 "Digest verification failed");
2423 return TEST_SUCCESS;
2426 /* ***** SNOW 3G Tests ***** */
2428 create_wireless_algo_hash_session(uint8_t dev_id,
2429 const uint8_t *key, const uint8_t key_len,
2430 const uint8_t iv_len, const uint8_t auth_len,
2431 enum rte_crypto_auth_operation op,
2432 enum rte_crypto_auth_algorithm algo)
2434 uint8_t hash_key[key_len];
2437 struct crypto_testsuite_params *ts_params = &testsuite_params;
2438 struct crypto_unittest_params *ut_params = &unittest_params;
2440 memcpy(hash_key, key, key_len);
2442 debug_hexdump(stdout, "key:", key, key_len);
2444 /* Setup Authentication Parameters */
2445 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2446 ut_params->auth_xform.next = NULL;
2448 ut_params->auth_xform.auth.op = op;
2449 ut_params->auth_xform.auth.algo = algo;
2450 ut_params->auth_xform.auth.key.length = key_len;
2451 ut_params->auth_xform.auth.key.data = hash_key;
2452 ut_params->auth_xform.auth.digest_length = auth_len;
2453 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2454 ut_params->auth_xform.auth.iv.length = iv_len;
2455 ut_params->sess = rte_cryptodev_sym_session_create(
2456 ts_params->session_mpool);
2458 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2459 &ut_params->auth_xform,
2460 ts_params->session_priv_mpool);
2461 if (status == -ENOTSUP)
2462 return TEST_SKIPPED;
2464 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2465 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2470 create_wireless_algo_cipher_session(uint8_t dev_id,
2471 enum rte_crypto_cipher_operation op,
2472 enum rte_crypto_cipher_algorithm algo,
2473 const uint8_t *key, const uint8_t key_len,
2476 uint8_t cipher_key[key_len];
2478 struct crypto_testsuite_params *ts_params = &testsuite_params;
2479 struct crypto_unittest_params *ut_params = &unittest_params;
2481 memcpy(cipher_key, key, key_len);
2483 /* Setup Cipher Parameters */
2484 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2485 ut_params->cipher_xform.next = NULL;
2487 ut_params->cipher_xform.cipher.algo = algo;
2488 ut_params->cipher_xform.cipher.op = op;
2489 ut_params->cipher_xform.cipher.key.data = cipher_key;
2490 ut_params->cipher_xform.cipher.key.length = key_len;
2491 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2492 ut_params->cipher_xform.cipher.iv.length = iv_len;
2494 debug_hexdump(stdout, "key:", key, key_len);
2496 /* Create Crypto session */
2497 ut_params->sess = rte_cryptodev_sym_session_create(
2498 ts_params->session_mpool);
2500 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2501 &ut_params->cipher_xform,
2502 ts_params->session_priv_mpool);
2503 if (status == -ENOTSUP)
2504 return TEST_SKIPPED;
2506 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2507 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2512 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2513 unsigned int cipher_len,
2514 unsigned int cipher_offset)
2516 struct crypto_testsuite_params *ts_params = &testsuite_params;
2517 struct crypto_unittest_params *ut_params = &unittest_params;
2519 /* Generate Crypto op data structure */
2520 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2521 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2522 TEST_ASSERT_NOT_NULL(ut_params->op,
2523 "Failed to allocate pktmbuf offload");
2525 /* Set crypto operation data parameters */
2526 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2528 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2530 /* set crypto operation source mbuf */
2531 sym_op->m_src = ut_params->ibuf;
2534 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2536 sym_op->cipher.data.length = cipher_len;
2537 sym_op->cipher.data.offset = cipher_offset;
2542 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2543 unsigned int cipher_len,
2544 unsigned int cipher_offset)
2546 struct crypto_testsuite_params *ts_params = &testsuite_params;
2547 struct crypto_unittest_params *ut_params = &unittest_params;
2549 /* Generate Crypto op data structure */
2550 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2551 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2552 TEST_ASSERT_NOT_NULL(ut_params->op,
2553 "Failed to allocate pktmbuf offload");
2555 /* Set crypto operation data parameters */
2556 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2558 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2560 /* set crypto operation source mbuf */
2561 sym_op->m_src = ut_params->ibuf;
2562 sym_op->m_dst = ut_params->obuf;
2565 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2567 sym_op->cipher.data.length = cipher_len;
2568 sym_op->cipher.data.offset = cipher_offset;
2573 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2574 enum rte_crypto_cipher_operation cipher_op,
2575 enum rte_crypto_auth_operation auth_op,
2576 enum rte_crypto_auth_algorithm auth_algo,
2577 enum rte_crypto_cipher_algorithm cipher_algo,
2578 const uint8_t *key, uint8_t key_len,
2579 uint8_t auth_iv_len, uint8_t auth_len,
2580 uint8_t cipher_iv_len)
2583 uint8_t cipher_auth_key[key_len];
2586 struct crypto_testsuite_params *ts_params = &testsuite_params;
2587 struct crypto_unittest_params *ut_params = &unittest_params;
2589 memcpy(cipher_auth_key, key, key_len);
2591 /* Setup Authentication Parameters */
2592 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2593 ut_params->auth_xform.next = NULL;
2595 ut_params->auth_xform.auth.op = auth_op;
2596 ut_params->auth_xform.auth.algo = auth_algo;
2597 ut_params->auth_xform.auth.key.length = key_len;
2598 /* Hash key = cipher key */
2599 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2600 ut_params->auth_xform.auth.digest_length = auth_len;
2601 /* Auth IV will be after cipher IV */
2602 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2603 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2605 /* Setup Cipher Parameters */
2606 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2607 ut_params->cipher_xform.next = &ut_params->auth_xform;
2609 ut_params->cipher_xform.cipher.algo = cipher_algo;
2610 ut_params->cipher_xform.cipher.op = cipher_op;
2611 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2612 ut_params->cipher_xform.cipher.key.length = key_len;
2613 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2614 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2616 debug_hexdump(stdout, "key:", key, key_len);
2618 /* Create Crypto session*/
2619 ut_params->sess = rte_cryptodev_sym_session_create(
2620 ts_params->session_mpool);
2621 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2623 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2624 &ut_params->cipher_xform,
2625 ts_params->session_priv_mpool);
2626 if (status == -ENOTSUP)
2627 return TEST_SKIPPED;
2629 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2634 create_wireless_cipher_auth_session(uint8_t dev_id,
2635 enum rte_crypto_cipher_operation cipher_op,
2636 enum rte_crypto_auth_operation auth_op,
2637 enum rte_crypto_auth_algorithm auth_algo,
2638 enum rte_crypto_cipher_algorithm cipher_algo,
2639 const struct wireless_test_data *tdata)
2641 const uint8_t key_len = tdata->key.len;
2642 uint8_t cipher_auth_key[key_len];
2645 struct crypto_testsuite_params *ts_params = &testsuite_params;
2646 struct crypto_unittest_params *ut_params = &unittest_params;
2647 const uint8_t *key = tdata->key.data;
2648 const uint8_t auth_len = tdata->digest.len;
2649 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2650 uint8_t auth_iv_len = tdata->auth_iv.len;
2652 memcpy(cipher_auth_key, key, key_len);
2654 /* Setup Authentication Parameters */
2655 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2656 ut_params->auth_xform.next = NULL;
2658 ut_params->auth_xform.auth.op = auth_op;
2659 ut_params->auth_xform.auth.algo = auth_algo;
2660 ut_params->auth_xform.auth.key.length = key_len;
2661 /* Hash key = cipher key */
2662 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2663 ut_params->auth_xform.auth.digest_length = auth_len;
2664 /* Auth IV will be after cipher IV */
2665 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2666 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2668 /* Setup Cipher Parameters */
2669 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2670 ut_params->cipher_xform.next = &ut_params->auth_xform;
2672 ut_params->cipher_xform.cipher.algo = cipher_algo;
2673 ut_params->cipher_xform.cipher.op = cipher_op;
2674 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2675 ut_params->cipher_xform.cipher.key.length = key_len;
2676 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2677 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2680 debug_hexdump(stdout, "key:", key, key_len);
2682 /* Create Crypto session*/
2683 ut_params->sess = rte_cryptodev_sym_session_create(
2684 ts_params->session_mpool);
2686 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2687 &ut_params->cipher_xform,
2688 ts_params->session_priv_mpool);
2689 if (status == -ENOTSUP)
2690 return TEST_SKIPPED;
2692 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2693 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2698 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2699 const struct wireless_test_data *tdata)
2701 return create_wireless_cipher_auth_session(dev_id,
2702 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2703 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2704 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2708 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2709 enum rte_crypto_cipher_operation cipher_op,
2710 enum rte_crypto_auth_operation auth_op,
2711 enum rte_crypto_auth_algorithm auth_algo,
2712 enum rte_crypto_cipher_algorithm cipher_algo,
2713 const uint8_t *key, const uint8_t key_len,
2714 uint8_t auth_iv_len, uint8_t auth_len,
2715 uint8_t cipher_iv_len)
2717 uint8_t auth_cipher_key[key_len];
2719 struct crypto_testsuite_params *ts_params = &testsuite_params;
2720 struct crypto_unittest_params *ut_params = &unittest_params;
2722 memcpy(auth_cipher_key, key, key_len);
2724 /* Setup Authentication Parameters */
2725 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2726 ut_params->auth_xform.auth.op = auth_op;
2727 ut_params->auth_xform.next = &ut_params->cipher_xform;
2728 ut_params->auth_xform.auth.algo = auth_algo;
2729 ut_params->auth_xform.auth.key.length = key_len;
2730 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2731 ut_params->auth_xform.auth.digest_length = auth_len;
2732 /* Auth IV will be after cipher IV */
2733 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2734 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2736 /* Setup Cipher Parameters */
2737 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2738 ut_params->cipher_xform.next = NULL;
2739 ut_params->cipher_xform.cipher.algo = cipher_algo;
2740 ut_params->cipher_xform.cipher.op = cipher_op;
2741 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2742 ut_params->cipher_xform.cipher.key.length = key_len;
2743 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2744 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2746 debug_hexdump(stdout, "key:", key, key_len);
2748 /* Create Crypto session*/
2749 ut_params->sess = rte_cryptodev_sym_session_create(
2750 ts_params->session_mpool);
2751 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2753 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2754 ut_params->auth_xform.next = NULL;
2755 ut_params->cipher_xform.next = &ut_params->auth_xform;
2756 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2757 &ut_params->cipher_xform,
2758 ts_params->session_priv_mpool);
2761 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2762 &ut_params->auth_xform,
2763 ts_params->session_priv_mpool);
2765 if (status == -ENOTSUP)
2766 return TEST_SKIPPED;
2768 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2774 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2775 unsigned int auth_tag_len,
2776 const uint8_t *iv, unsigned int iv_len,
2777 unsigned int data_pad_len,
2778 enum rte_crypto_auth_operation op,
2779 unsigned int auth_len, unsigned int auth_offset)
2781 struct crypto_testsuite_params *ts_params = &testsuite_params;
2783 struct crypto_unittest_params *ut_params = &unittest_params;
2785 /* Generate Crypto op data structure */
2786 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2787 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2788 TEST_ASSERT_NOT_NULL(ut_params->op,
2789 "Failed to allocate pktmbuf offload");
2791 /* Set crypto operation data parameters */
2792 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2794 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2796 /* set crypto operation source mbuf */
2797 sym_op->m_src = ut_params->ibuf;
2800 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2803 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2804 ut_params->ibuf, auth_tag_len);
2806 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2807 "no room to append auth tag");
2808 ut_params->digest = sym_op->auth.digest.data;
2809 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2810 ut_params->ibuf, data_pad_len);
2811 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2812 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2814 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2816 debug_hexdump(stdout, "digest:",
2817 sym_op->auth.digest.data,
2820 sym_op->auth.data.length = auth_len;
2821 sym_op->auth.data.offset = auth_offset;
2827 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2828 enum rte_crypto_auth_operation op)
2830 struct crypto_testsuite_params *ts_params = &testsuite_params;
2831 struct crypto_unittest_params *ut_params = &unittest_params;
2833 const uint8_t *auth_tag = tdata->digest.data;
2834 const unsigned int auth_tag_len = tdata->digest.len;
2835 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2836 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2838 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2839 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2840 const uint8_t *auth_iv = tdata->auth_iv.data;
2841 const uint8_t auth_iv_len = tdata->auth_iv.len;
2842 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2843 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2845 /* Generate Crypto op data structure */
2846 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2847 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2848 TEST_ASSERT_NOT_NULL(ut_params->op,
2849 "Failed to allocate pktmbuf offload");
2850 /* Set crypto operation data parameters */
2851 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2853 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2855 /* set crypto operation source mbuf */
2856 sym_op->m_src = ut_params->ibuf;
2859 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2860 ut_params->ibuf, auth_tag_len);
2862 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2863 "no room to append auth tag");
2864 ut_params->digest = sym_op->auth.digest.data;
2865 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2866 ut_params->ibuf, data_pad_len);
2867 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2868 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2870 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2872 debug_hexdump(stdout, "digest:",
2873 sym_op->auth.digest.data,
2876 /* Copy cipher and auth IVs at the end of the crypto operation */
2877 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2879 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2880 iv_ptr += cipher_iv_len;
2881 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2883 sym_op->cipher.data.length = cipher_len;
2884 sym_op->cipher.data.offset = 0;
2885 sym_op->auth.data.length = auth_len;
2886 sym_op->auth.data.offset = 0;
2892 create_zuc_cipher_hash_generate_operation(
2893 const struct wireless_test_data *tdata)
2895 return create_wireless_cipher_hash_operation(tdata,
2896 RTE_CRYPTO_AUTH_OP_GENERATE);
2900 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2901 const unsigned auth_tag_len,
2902 const uint8_t *auth_iv, uint8_t auth_iv_len,
2903 unsigned data_pad_len,
2904 enum rte_crypto_auth_operation op,
2905 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2906 const unsigned cipher_len, const unsigned cipher_offset,
2907 const unsigned auth_len, const unsigned auth_offset)
2909 struct crypto_testsuite_params *ts_params = &testsuite_params;
2910 struct crypto_unittest_params *ut_params = &unittest_params;
2912 enum rte_crypto_cipher_algorithm cipher_algo =
2913 ut_params->cipher_xform.cipher.algo;
2914 enum rte_crypto_auth_algorithm auth_algo =
2915 ut_params->auth_xform.auth.algo;
2917 /* Generate Crypto op data structure */
2918 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2919 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2920 TEST_ASSERT_NOT_NULL(ut_params->op,
2921 "Failed to allocate pktmbuf offload");
2922 /* Set crypto operation data parameters */
2923 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2925 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2927 /* set crypto operation source mbuf */
2928 sym_op->m_src = ut_params->ibuf;
2931 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2932 ut_params->ibuf, auth_tag_len);
2934 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2935 "no room to append auth tag");
2936 ut_params->digest = sym_op->auth.digest.data;
2938 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2939 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2940 ut_params->ibuf, data_pad_len);
2942 struct rte_mbuf *m = ut_params->ibuf;
2943 unsigned int offset = data_pad_len;
2945 while (offset > m->data_len && m->next != NULL) {
2946 offset -= m->data_len;
2949 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2953 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2954 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2956 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2958 debug_hexdump(stdout, "digest:",
2959 sym_op->auth.digest.data,
2962 /* Copy cipher and auth IVs at the end of the crypto operation */
2963 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2965 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2966 iv_ptr += cipher_iv_len;
2967 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2969 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2970 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2971 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2972 sym_op->cipher.data.length = cipher_len;
2973 sym_op->cipher.data.offset = cipher_offset;
2975 sym_op->cipher.data.length = cipher_len >> 3;
2976 sym_op->cipher.data.offset = cipher_offset >> 3;
2979 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2980 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2981 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2982 sym_op->auth.data.length = auth_len;
2983 sym_op->auth.data.offset = auth_offset;
2985 sym_op->auth.data.length = auth_len >> 3;
2986 sym_op->auth.data.offset = auth_offset >> 3;
2993 create_wireless_algo_auth_cipher_operation(
2994 const uint8_t *auth_tag, unsigned int auth_tag_len,
2995 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2996 const uint8_t *auth_iv, uint8_t auth_iv_len,
2997 unsigned int data_pad_len,
2998 unsigned int cipher_len, unsigned int cipher_offset,
2999 unsigned int auth_len, unsigned int auth_offset,
3000 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3002 struct crypto_testsuite_params *ts_params = &testsuite_params;
3003 struct crypto_unittest_params *ut_params = &unittest_params;
3005 enum rte_crypto_cipher_algorithm cipher_algo =
3006 ut_params->cipher_xform.cipher.algo;
3007 enum rte_crypto_auth_algorithm auth_algo =
3008 ut_params->auth_xform.auth.algo;
3010 /* Generate Crypto op data structure */
3011 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3012 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3013 TEST_ASSERT_NOT_NULL(ut_params->op,
3014 "Failed to allocate pktmbuf offload");
3016 /* Set crypto operation data parameters */
3017 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3019 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3021 /* set crypto operation mbufs */
3022 sym_op->m_src = ut_params->ibuf;
3023 if (op_mode == OUT_OF_PLACE)
3024 sym_op->m_dst = ut_params->obuf;
3028 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3029 (op_mode == IN_PLACE ?
3030 ut_params->ibuf : ut_params->obuf),
3031 uint8_t *, data_pad_len);
3032 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3033 (op_mode == IN_PLACE ?
3034 ut_params->ibuf : ut_params->obuf),
3036 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3038 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3039 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3040 sym_op->m_src : sym_op->m_dst);
3041 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3042 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3043 sgl_buf = sgl_buf->next;
3045 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3046 uint8_t *, remaining_off);
3047 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3049 memset(sym_op->auth.digest.data, 0, remaining_off);
3050 while (sgl_buf->next != NULL) {
3051 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3052 0, rte_pktmbuf_data_len(sgl_buf));
3053 sgl_buf = sgl_buf->next;
3057 /* Copy digest for the verification */
3059 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3061 /* Copy cipher and auth IVs at the end of the crypto operation */
3062 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3063 ut_params->op, uint8_t *, IV_OFFSET);
3065 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3066 iv_ptr += cipher_iv_len;
3067 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3069 /* Only copy over the offset data needed from src to dst in OOP,
3070 * if the auth and cipher offsets are not aligned
3072 if (op_mode == OUT_OF_PLACE) {
3073 if (cipher_offset > auth_offset)
3075 rte_pktmbuf_mtod_offset(
3077 uint8_t *, auth_offset >> 3),
3078 rte_pktmbuf_mtod_offset(
3080 uint8_t *, auth_offset >> 3),
3081 ((cipher_offset >> 3) - (auth_offset >> 3)));
3084 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3085 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3086 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3087 sym_op->cipher.data.length = cipher_len;
3088 sym_op->cipher.data.offset = cipher_offset;
3090 sym_op->cipher.data.length = cipher_len >> 3;
3091 sym_op->cipher.data.offset = cipher_offset >> 3;
3094 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3095 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3096 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3097 sym_op->auth.data.length = auth_len;
3098 sym_op->auth.data.offset = auth_offset;
3100 sym_op->auth.data.length = auth_len >> 3;
3101 sym_op->auth.data.offset = auth_offset >> 3;
3108 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3110 struct crypto_testsuite_params *ts_params = &testsuite_params;
3111 struct crypto_unittest_params *ut_params = &unittest_params;
3114 unsigned plaintext_pad_len;
3115 unsigned plaintext_len;
3117 struct rte_cryptodev_info dev_info;
3119 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3120 uint64_t feat_flags = dev_info.feature_flags;
3122 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3123 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3124 printf("Device doesn't support NON-Byte Aligned Data.\n");
3125 return TEST_SKIPPED;
3128 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3129 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3130 printf("Device doesn't support RAW data-path APIs.\n");
3131 return TEST_SKIPPED;
3134 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3135 return TEST_SKIPPED;
3137 /* Verify the capabilities */
3138 struct rte_cryptodev_sym_capability_idx cap_idx;
3139 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3140 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3141 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3143 return TEST_SKIPPED;
3145 /* Create SNOW 3G session */
3146 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3147 tdata->key.data, tdata->key.len,
3148 tdata->auth_iv.len, tdata->digest.len,
3149 RTE_CRYPTO_AUTH_OP_GENERATE,
3150 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3154 /* alloc mbuf and set payload */
3155 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3157 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3158 rte_pktmbuf_tailroom(ut_params->ibuf));
3160 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3161 /* Append data which is padded to a multiple of */
3162 /* the algorithms block size */
3163 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3164 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3166 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3168 /* Create SNOW 3G operation */
3169 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3170 tdata->auth_iv.data, tdata->auth_iv.len,
3171 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3172 tdata->validAuthLenInBits.len,
3177 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3178 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3179 ut_params->op, 0, 1, 1, 0);
3181 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3183 ut_params->obuf = ut_params->op->sym->m_src;
3184 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3185 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3186 + plaintext_pad_len;
3189 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3192 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3193 "SNOW 3G Generated auth tag not as expected");
3199 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3201 struct crypto_testsuite_params *ts_params = &testsuite_params;
3202 struct crypto_unittest_params *ut_params = &unittest_params;
3205 unsigned plaintext_pad_len;
3206 unsigned plaintext_len;
3208 struct rte_cryptodev_info dev_info;
3210 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3211 uint64_t feat_flags = dev_info.feature_flags;
3213 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3214 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3215 printf("Device doesn't support NON-Byte Aligned Data.\n");
3216 return TEST_SKIPPED;
3219 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3220 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3221 printf("Device doesn't support RAW data-path APIs.\n");
3222 return TEST_SKIPPED;
3225 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3226 return TEST_SKIPPED;
3228 /* Verify the capabilities */
3229 struct rte_cryptodev_sym_capability_idx cap_idx;
3230 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3231 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3232 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3234 return TEST_SKIPPED;
3236 /* Create SNOW 3G session */
3237 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3238 tdata->key.data, tdata->key.len,
3239 tdata->auth_iv.len, tdata->digest.len,
3240 RTE_CRYPTO_AUTH_OP_VERIFY,
3241 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3244 /* alloc mbuf and set payload */
3245 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3247 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3248 rte_pktmbuf_tailroom(ut_params->ibuf));
3250 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3251 /* Append data which is padded to a multiple of */
3252 /* the algorithms block size */
3253 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3254 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3256 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3258 /* Create SNOW 3G operation */
3259 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3261 tdata->auth_iv.data, tdata->auth_iv.len,
3263 RTE_CRYPTO_AUTH_OP_VERIFY,
3264 tdata->validAuthLenInBits.len,
3269 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3270 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3271 ut_params->op, 0, 1, 1, 0);
3273 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3275 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3276 ut_params->obuf = ut_params->op->sym->m_src;
3277 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3278 + plaintext_pad_len;
3281 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3290 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3292 struct crypto_testsuite_params *ts_params = &testsuite_params;
3293 struct crypto_unittest_params *ut_params = &unittest_params;
3296 unsigned plaintext_pad_len;
3297 unsigned plaintext_len;
3299 struct rte_cryptodev_info dev_info;
3301 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3302 uint64_t feat_flags = dev_info.feature_flags;
3304 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3305 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3306 printf("Device doesn't support RAW data-path APIs.\n");
3307 return TEST_SKIPPED;
3310 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3311 return TEST_SKIPPED;
3313 /* Verify the capabilities */
3314 struct rte_cryptodev_sym_capability_idx cap_idx;
3315 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3316 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3317 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3319 return TEST_SKIPPED;
3321 /* Create KASUMI session */
3322 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3323 tdata->key.data, tdata->key.len,
3324 0, tdata->digest.len,
3325 RTE_CRYPTO_AUTH_OP_GENERATE,
3326 RTE_CRYPTO_AUTH_KASUMI_F9);
3330 /* alloc mbuf and set payload */
3331 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3333 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3334 rte_pktmbuf_tailroom(ut_params->ibuf));
3336 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3337 /* Append data which is padded to a multiple of */
3338 /* the algorithms block size */
3339 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3340 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3342 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3344 /* Create KASUMI operation */
3345 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3347 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3348 tdata->plaintext.len,
3353 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3354 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3356 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3357 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3358 ut_params->op, 0, 1, 1, 0);
3360 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3363 ut_params->obuf = ut_params->op->sym->m_src;
3364 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3365 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3366 + plaintext_pad_len;
3369 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3372 DIGEST_BYTE_LENGTH_KASUMI_F9,
3373 "KASUMI Generated auth tag not as expected");
3379 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3381 struct crypto_testsuite_params *ts_params = &testsuite_params;
3382 struct crypto_unittest_params *ut_params = &unittest_params;
3385 unsigned plaintext_pad_len;
3386 unsigned plaintext_len;
3388 struct rte_cryptodev_info dev_info;
3390 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3391 uint64_t feat_flags = dev_info.feature_flags;
3393 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3394 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3395 printf("Device doesn't support RAW data-path APIs.\n");
3396 return TEST_SKIPPED;
3399 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3400 return TEST_SKIPPED;
3402 /* Verify the capabilities */
3403 struct rte_cryptodev_sym_capability_idx cap_idx;
3404 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3405 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3406 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3408 return TEST_SKIPPED;
3410 /* Create KASUMI session */
3411 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3412 tdata->key.data, tdata->key.len,
3413 0, tdata->digest.len,
3414 RTE_CRYPTO_AUTH_OP_VERIFY,
3415 RTE_CRYPTO_AUTH_KASUMI_F9);
3418 /* alloc mbuf and set payload */
3419 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3421 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3422 rte_pktmbuf_tailroom(ut_params->ibuf));
3424 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3425 /* Append data which is padded to a multiple */
3426 /* of the algorithms block size */
3427 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3428 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3430 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3432 /* Create KASUMI operation */
3433 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3437 RTE_CRYPTO_AUTH_OP_VERIFY,
3438 tdata->plaintext.len,
3443 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3444 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3445 ut_params->op, 0, 1, 1, 0);
3447 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3449 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3450 ut_params->obuf = ut_params->op->sym->m_src;
3451 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3452 + plaintext_pad_len;
3455 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3464 test_snow3g_hash_generate_test_case_1(void)
3466 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3470 test_snow3g_hash_generate_test_case_2(void)
3472 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3476 test_snow3g_hash_generate_test_case_3(void)
3478 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3482 test_snow3g_hash_generate_test_case_4(void)
3484 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3488 test_snow3g_hash_generate_test_case_5(void)
3490 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3494 test_snow3g_hash_generate_test_case_6(void)
3496 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3500 test_snow3g_hash_verify_test_case_1(void)
3502 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3507 test_snow3g_hash_verify_test_case_2(void)
3509 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3513 test_snow3g_hash_verify_test_case_3(void)
3515 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3519 test_snow3g_hash_verify_test_case_4(void)
3521 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3525 test_snow3g_hash_verify_test_case_5(void)
3527 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3531 test_snow3g_hash_verify_test_case_6(void)
3533 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3537 test_kasumi_hash_generate_test_case_1(void)
3539 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3543 test_kasumi_hash_generate_test_case_2(void)
3545 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3549 test_kasumi_hash_generate_test_case_3(void)
3551 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3555 test_kasumi_hash_generate_test_case_4(void)
3557 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3561 test_kasumi_hash_generate_test_case_5(void)
3563 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3567 test_kasumi_hash_generate_test_case_6(void)
3569 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3573 test_kasumi_hash_verify_test_case_1(void)
3575 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3579 test_kasumi_hash_verify_test_case_2(void)
3581 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3585 test_kasumi_hash_verify_test_case_3(void)
3587 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3591 test_kasumi_hash_verify_test_case_4(void)
3593 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3597 test_kasumi_hash_verify_test_case_5(void)
3599 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3603 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3605 struct crypto_testsuite_params *ts_params = &testsuite_params;
3606 struct crypto_unittest_params *ut_params = &unittest_params;
3609 uint8_t *plaintext, *ciphertext;
3610 unsigned plaintext_pad_len;
3611 unsigned plaintext_len;
3612 struct rte_cryptodev_info dev_info;
3614 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3615 uint64_t feat_flags = dev_info.feature_flags;
3617 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3618 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3619 printf("Device doesn't support RAW data-path APIs.\n");
3620 return TEST_SKIPPED;
3623 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3624 return TEST_SKIPPED;
3626 /* Verify the capabilities */
3627 struct rte_cryptodev_sym_capability_idx cap_idx;
3628 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3629 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3630 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3632 return TEST_SKIPPED;
3634 /* Create KASUMI session */
3635 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3636 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3637 RTE_CRYPTO_CIPHER_KASUMI_F8,
3638 tdata->key.data, tdata->key.len,
3639 tdata->cipher_iv.len);
3643 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3645 /* Clear mbuf payload */
3646 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3647 rte_pktmbuf_tailroom(ut_params->ibuf));
3649 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3650 /* Append data which is padded to a multiple */
3651 /* of the algorithms block size */
3652 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3653 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3655 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3657 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3659 /* Create KASUMI operation */
3660 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3661 tdata->cipher_iv.len,
3662 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3663 tdata->validCipherOffsetInBits.len);
3667 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3668 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3669 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3671 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3673 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3675 ut_params->obuf = ut_params->op->sym->m_dst;
3676 if (ut_params->obuf)
3677 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3679 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3681 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3683 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3684 (tdata->validCipherOffsetInBits.len >> 3);
3686 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3688 reference_ciphertext,
3689 tdata->validCipherLenInBits.len,
3690 "KASUMI Ciphertext data not as expected");
3695 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3697 struct crypto_testsuite_params *ts_params = &testsuite_params;
3698 struct crypto_unittest_params *ut_params = &unittest_params;
3702 unsigned int plaintext_pad_len;
3703 unsigned int plaintext_len;
3705 uint8_t buffer[10000];
3706 const uint8_t *ciphertext;
3708 struct rte_cryptodev_info dev_info;
3710 /* Verify the capabilities */
3711 struct rte_cryptodev_sym_capability_idx cap_idx;
3712 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3713 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3714 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3716 return TEST_SKIPPED;
3718 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3720 uint64_t feat_flags = dev_info.feature_flags;
3722 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3723 printf("Device doesn't support in-place scatter-gather. "
3725 return TEST_SKIPPED;
3728 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3729 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3730 printf("Device doesn't support RAW data-path APIs.\n");
3731 return TEST_SKIPPED;
3734 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3735 return TEST_SKIPPED;
3737 /* Create KASUMI session */
3738 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3739 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3740 RTE_CRYPTO_CIPHER_KASUMI_F8,
3741 tdata->key.data, tdata->key.len,
3742 tdata->cipher_iv.len);
3746 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3749 /* Append data which is padded to a multiple */
3750 /* of the algorithms block size */
3751 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3753 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3754 plaintext_pad_len, 10, 0);
3756 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3758 /* Create KASUMI operation */
3759 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3760 tdata->cipher_iv.len,
3761 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3762 tdata->validCipherOffsetInBits.len);
3766 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3767 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3768 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3770 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3772 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3774 ut_params->obuf = ut_params->op->sym->m_dst;
3776 if (ut_params->obuf)
3777 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3778 plaintext_len, buffer);
3780 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3781 tdata->validCipherOffsetInBits.len >> 3,
3782 plaintext_len, buffer);
3785 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3787 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3788 (tdata->validCipherOffsetInBits.len >> 3);
3790 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3792 reference_ciphertext,
3793 tdata->validCipherLenInBits.len,
3794 "KASUMI Ciphertext data not as expected");
3799 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3801 struct crypto_testsuite_params *ts_params = &testsuite_params;
3802 struct crypto_unittest_params *ut_params = &unittest_params;
3805 uint8_t *plaintext, *ciphertext;
3806 unsigned plaintext_pad_len;
3807 unsigned plaintext_len;
3809 /* Verify the capabilities */
3810 struct rte_cryptodev_sym_capability_idx cap_idx;
3811 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3812 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3813 /* Data-path service does not support OOP */
3814 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3816 return TEST_SKIPPED;
3818 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3819 return TEST_SKIPPED;
3821 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3822 return TEST_SKIPPED;
3824 /* Create KASUMI session */
3825 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3826 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3827 RTE_CRYPTO_CIPHER_KASUMI_F8,
3828 tdata->key.data, tdata->key.len,
3829 tdata->cipher_iv.len);
3833 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3834 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3836 /* Clear mbuf payload */
3837 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3838 rte_pktmbuf_tailroom(ut_params->ibuf));
3840 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3841 /* Append data which is padded to a multiple */
3842 /* of the algorithms block size */
3843 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3844 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3846 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3847 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3849 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3851 /* Create KASUMI operation */
3852 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3853 tdata->cipher_iv.len,
3854 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3855 tdata->validCipherOffsetInBits.len);
3859 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3861 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3863 ut_params->obuf = ut_params->op->sym->m_dst;
3864 if (ut_params->obuf)
3865 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3867 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3869 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3871 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3872 (tdata->validCipherOffsetInBits.len >> 3);
3874 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3876 reference_ciphertext,
3877 tdata->validCipherLenInBits.len,
3878 "KASUMI Ciphertext data not as expected");
3883 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3885 struct crypto_testsuite_params *ts_params = &testsuite_params;
3886 struct crypto_unittest_params *ut_params = &unittest_params;
3889 unsigned int plaintext_pad_len;
3890 unsigned int plaintext_len;
3892 const uint8_t *ciphertext;
3893 uint8_t buffer[2048];
3895 struct rte_cryptodev_info dev_info;
3897 /* Verify the capabilities */
3898 struct rte_cryptodev_sym_capability_idx cap_idx;
3899 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3900 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3901 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3903 return TEST_SKIPPED;
3905 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3906 return TEST_SKIPPED;
3908 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3909 return TEST_SKIPPED;
3911 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3913 uint64_t feat_flags = dev_info.feature_flags;
3914 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3915 printf("Device doesn't support out-of-place scatter-gather "
3916 "in both input and output mbufs. "
3918 return TEST_SKIPPED;
3921 /* Create KASUMI session */
3922 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3923 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3924 RTE_CRYPTO_CIPHER_KASUMI_F8,
3925 tdata->key.data, tdata->key.len,
3926 tdata->cipher_iv.len);
3930 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3931 /* Append data which is padded to a multiple */
3932 /* of the algorithms block size */
3933 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3935 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3936 plaintext_pad_len, 10, 0);
3937 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3938 plaintext_pad_len, 3, 0);
3940 /* Append data which is padded to a multiple */
3941 /* of the algorithms block size */
3942 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3944 /* Create KASUMI operation */
3945 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3946 tdata->cipher_iv.len,
3947 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3948 tdata->validCipherOffsetInBits.len);
3952 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3954 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3956 ut_params->obuf = ut_params->op->sym->m_dst;
3957 if (ut_params->obuf)
3958 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3959 plaintext_pad_len, buffer);
3961 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3962 tdata->validCipherOffsetInBits.len >> 3,
3963 plaintext_pad_len, buffer);
3965 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3966 (tdata->validCipherOffsetInBits.len >> 3);
3968 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3970 reference_ciphertext,
3971 tdata->validCipherLenInBits.len,
3972 "KASUMI Ciphertext data not as expected");
3978 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3980 struct crypto_testsuite_params *ts_params = &testsuite_params;
3981 struct crypto_unittest_params *ut_params = &unittest_params;
3984 uint8_t *ciphertext, *plaintext;
3985 unsigned ciphertext_pad_len;
3986 unsigned ciphertext_len;
3988 /* Verify the capabilities */
3989 struct rte_cryptodev_sym_capability_idx cap_idx;
3990 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3991 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3992 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3994 return TEST_SKIPPED;
3996 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3997 return TEST_SKIPPED;
3999 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4000 return TEST_SKIPPED;
4002 /* Create KASUMI session */
4003 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4004 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4005 RTE_CRYPTO_CIPHER_KASUMI_F8,
4006 tdata->key.data, tdata->key.len,
4007 tdata->cipher_iv.len);
4011 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4012 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4014 /* Clear mbuf payload */
4015 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4016 rte_pktmbuf_tailroom(ut_params->ibuf));
4018 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4019 /* Append data which is padded to a multiple */
4020 /* of the algorithms block size */
4021 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4022 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4023 ciphertext_pad_len);
4024 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4025 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4027 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4029 /* Create KASUMI operation */
4030 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4031 tdata->cipher_iv.len,
4032 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4033 tdata->validCipherOffsetInBits.len);
4037 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4039 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4041 ut_params->obuf = ut_params->op->sym->m_dst;
4042 if (ut_params->obuf)
4043 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4045 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4047 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4049 const uint8_t *reference_plaintext = tdata->plaintext.data +
4050 (tdata->validCipherOffsetInBits.len >> 3);
4052 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4054 reference_plaintext,
4055 tdata->validCipherLenInBits.len,
4056 "KASUMI Plaintext data not as expected");
4061 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4063 struct crypto_testsuite_params *ts_params = &testsuite_params;
4064 struct crypto_unittest_params *ut_params = &unittest_params;
4067 uint8_t *ciphertext, *plaintext;
4068 unsigned ciphertext_pad_len;
4069 unsigned ciphertext_len;
4070 struct rte_cryptodev_info dev_info;
4072 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4073 uint64_t feat_flags = dev_info.feature_flags;
4075 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4076 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4077 printf("Device doesn't support RAW data-path APIs.\n");
4078 return TEST_SKIPPED;
4081 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4082 return TEST_SKIPPED;
4084 /* Verify the capabilities */
4085 struct rte_cryptodev_sym_capability_idx cap_idx;
4086 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4087 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4088 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4090 return TEST_SKIPPED;
4092 /* Create KASUMI session */
4093 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4094 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4095 RTE_CRYPTO_CIPHER_KASUMI_F8,
4096 tdata->key.data, tdata->key.len,
4097 tdata->cipher_iv.len);
4101 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4103 /* Clear mbuf payload */
4104 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4105 rte_pktmbuf_tailroom(ut_params->ibuf));
4107 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4108 /* Append data which is padded to a multiple */
4109 /* of the algorithms block size */
4110 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4111 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4112 ciphertext_pad_len);
4113 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4115 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4117 /* Create KASUMI operation */
4118 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4119 tdata->cipher_iv.len,
4120 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4121 tdata->validCipherOffsetInBits.len);
4125 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4126 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4127 ut_params->op, 1, 0, 1, 0);
4129 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4131 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4133 ut_params->obuf = ut_params->op->sym->m_dst;
4134 if (ut_params->obuf)
4135 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4137 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4139 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4141 const uint8_t *reference_plaintext = tdata->plaintext.data +
4142 (tdata->validCipherOffsetInBits.len >> 3);
4144 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4146 reference_plaintext,
4147 tdata->validCipherLenInBits.len,
4148 "KASUMI Plaintext data not as expected");
4153 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4155 struct crypto_testsuite_params *ts_params = &testsuite_params;
4156 struct crypto_unittest_params *ut_params = &unittest_params;
4159 uint8_t *plaintext, *ciphertext;
4160 unsigned plaintext_pad_len;
4161 unsigned plaintext_len;
4162 struct rte_cryptodev_info dev_info;
4164 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4165 uint64_t feat_flags = dev_info.feature_flags;
4167 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4168 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4169 printf("Device doesn't support RAW data-path APIs.\n");
4170 return TEST_SKIPPED;
4173 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4174 return TEST_SKIPPED;
4176 /* Verify the capabilities */
4177 struct rte_cryptodev_sym_capability_idx cap_idx;
4178 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4179 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4180 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4182 return TEST_SKIPPED;
4184 /* Create SNOW 3G session */
4185 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4186 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4187 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4188 tdata->key.data, tdata->key.len,
4189 tdata->cipher_iv.len);
4193 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4195 /* Clear mbuf payload */
4196 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4197 rte_pktmbuf_tailroom(ut_params->ibuf));
4199 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4200 /* Append data which is padded to a multiple of */
4201 /* the algorithms block size */
4202 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4203 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4205 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4207 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4209 /* Create SNOW 3G operation */
4210 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4211 tdata->cipher_iv.len,
4212 tdata->validCipherLenInBits.len,
4217 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4218 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4219 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4221 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4223 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4225 ut_params->obuf = ut_params->op->sym->m_dst;
4226 if (ut_params->obuf)
4227 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4229 ciphertext = plaintext;
4231 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4234 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4236 tdata->ciphertext.data,
4237 tdata->validDataLenInBits.len,
4238 "SNOW 3G Ciphertext data not as expected");
4244 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4246 struct crypto_testsuite_params *ts_params = &testsuite_params;
4247 struct crypto_unittest_params *ut_params = &unittest_params;
4248 uint8_t *plaintext, *ciphertext;
4251 unsigned plaintext_pad_len;
4252 unsigned plaintext_len;
4253 struct rte_cryptodev_info dev_info;
4255 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4256 uint64_t feat_flags = dev_info.feature_flags;
4258 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4259 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4260 printf("Device does not support RAW data-path APIs.\n");
4264 /* Verify the capabilities */
4265 struct rte_cryptodev_sym_capability_idx cap_idx;
4266 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4267 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4268 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4270 return TEST_SKIPPED;
4272 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4273 return TEST_SKIPPED;
4275 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4276 return TEST_SKIPPED;
4278 /* Create SNOW 3G session */
4279 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4280 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4281 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4282 tdata->key.data, tdata->key.len,
4283 tdata->cipher_iv.len);
4287 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4288 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4290 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4291 "Failed to allocate input buffer in mempool");
4292 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4293 "Failed to allocate output buffer in mempool");
4295 /* Clear mbuf payload */
4296 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4297 rte_pktmbuf_tailroom(ut_params->ibuf));
4299 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4300 /* Append data which is padded to a multiple of */
4301 /* the algorithms block size */
4302 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4303 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4305 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4306 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4308 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4310 /* Create SNOW 3G operation */
4311 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4312 tdata->cipher_iv.len,
4313 tdata->validCipherLenInBits.len,
4318 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4319 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4320 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4322 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4324 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4326 ut_params->obuf = ut_params->op->sym->m_dst;
4327 if (ut_params->obuf)
4328 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4330 ciphertext = plaintext;
4332 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4335 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4337 tdata->ciphertext.data,
4338 tdata->validDataLenInBits.len,
4339 "SNOW 3G Ciphertext data not as expected");
4344 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4346 struct crypto_testsuite_params *ts_params = &testsuite_params;
4347 struct crypto_unittest_params *ut_params = &unittest_params;
4350 unsigned int plaintext_pad_len;
4351 unsigned int plaintext_len;
4352 uint8_t buffer[10000];
4353 const uint8_t *ciphertext;
4355 struct rte_cryptodev_info dev_info;
4357 /* Verify the capabilities */
4358 struct rte_cryptodev_sym_capability_idx cap_idx;
4359 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4360 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4361 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4363 return TEST_SKIPPED;
4365 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4366 return TEST_SKIPPED;
4368 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4369 return TEST_SKIPPED;
4371 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4373 uint64_t feat_flags = dev_info.feature_flags;
4375 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4376 printf("Device doesn't support out-of-place scatter-gather "
4377 "in both input and output mbufs. "
4379 return TEST_SKIPPED;
4382 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4383 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4384 printf("Device does not support RAW data-path APIs.\n");
4388 /* Create SNOW 3G session */
4389 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4390 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4391 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4392 tdata->key.data, tdata->key.len,
4393 tdata->cipher_iv.len);
4397 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4398 /* Append data which is padded to a multiple of */
4399 /* the algorithms block size */
4400 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4402 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4403 plaintext_pad_len, 10, 0);
4404 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4405 plaintext_pad_len, 3, 0);
4407 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4408 "Failed to allocate input buffer in mempool");
4409 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4410 "Failed to allocate output buffer in mempool");
4412 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4414 /* Create SNOW 3G operation */
4415 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4416 tdata->cipher_iv.len,
4417 tdata->validCipherLenInBits.len,
4422 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4423 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4424 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4426 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4428 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4430 ut_params->obuf = ut_params->op->sym->m_dst;
4431 if (ut_params->obuf)
4432 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4433 plaintext_len, buffer);
4435 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4436 plaintext_len, buffer);
4438 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4441 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4443 tdata->ciphertext.data,
4444 tdata->validDataLenInBits.len,
4445 "SNOW 3G Ciphertext data not as expected");
4450 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4452 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4454 uint8_t curr_byte, prev_byte;
4455 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4456 uint8_t lower_byte_mask = (1 << offset) - 1;
4459 prev_byte = buffer[0];
4460 buffer[0] >>= offset;
4462 for (i = 1; i < length_in_bytes; i++) {
4463 curr_byte = buffer[i];
4464 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4465 (curr_byte >> offset);
4466 prev_byte = curr_byte;
4471 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4473 struct crypto_testsuite_params *ts_params = &testsuite_params;
4474 struct crypto_unittest_params *ut_params = &unittest_params;
4475 uint8_t *plaintext, *ciphertext;
4477 uint32_t plaintext_len;
4478 uint32_t plaintext_pad_len;
4479 uint8_t extra_offset = 4;
4480 uint8_t *expected_ciphertext_shifted;
4481 struct rte_cryptodev_info dev_info;
4483 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4484 uint64_t feat_flags = dev_info.feature_flags;
4486 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4487 ((tdata->validDataLenInBits.len % 8) != 0)) {
4488 printf("Device doesn't support NON-Byte Aligned Data.\n");
4489 return TEST_SKIPPED;
4492 /* Verify the capabilities */
4493 struct rte_cryptodev_sym_capability_idx cap_idx;
4494 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4495 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4496 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4498 return TEST_SKIPPED;
4500 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4501 return TEST_SKIPPED;
4503 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4504 return TEST_SKIPPED;
4506 /* Create SNOW 3G session */
4507 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4508 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4509 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4510 tdata->key.data, tdata->key.len,
4511 tdata->cipher_iv.len);
4515 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4516 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4518 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4519 "Failed to allocate input buffer in mempool");
4520 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4521 "Failed to allocate output buffer in mempool");
4523 /* Clear mbuf payload */
4524 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4525 rte_pktmbuf_tailroom(ut_params->ibuf));
4527 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4529 * Append data which is padded to a
4530 * multiple of the algorithms block size
4532 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4534 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4537 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4539 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4540 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4542 #ifdef RTE_APP_TEST_DEBUG
4543 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4545 /* Create SNOW 3G operation */
4546 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4547 tdata->cipher_iv.len,
4548 tdata->validCipherLenInBits.len,
4553 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4554 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4555 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4557 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4559 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4561 ut_params->obuf = ut_params->op->sym->m_dst;
4562 if (ut_params->obuf)
4563 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4565 ciphertext = plaintext;
4567 #ifdef RTE_APP_TEST_DEBUG
4568 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4571 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4573 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4574 "failed to reserve memory for ciphertext shifted\n");
4576 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4577 ceil_byte_length(tdata->ciphertext.len));
4578 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4581 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4583 expected_ciphertext_shifted,
4584 tdata->validDataLenInBits.len,
4586 "SNOW 3G Ciphertext data not as expected");
4590 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4592 struct crypto_testsuite_params *ts_params = &testsuite_params;
4593 struct crypto_unittest_params *ut_params = &unittest_params;
4597 uint8_t *plaintext, *ciphertext;
4598 unsigned ciphertext_pad_len;
4599 unsigned ciphertext_len;
4600 struct rte_cryptodev_info dev_info;
4602 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4603 uint64_t feat_flags = dev_info.feature_flags;
4605 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4606 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4607 printf("Device doesn't support RAW data-path APIs.\n");
4608 return TEST_SKIPPED;
4611 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4612 return TEST_SKIPPED;
4614 /* Verify the capabilities */
4615 struct rte_cryptodev_sym_capability_idx cap_idx;
4616 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4617 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4618 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4620 return TEST_SKIPPED;
4622 /* Create SNOW 3G session */
4623 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4624 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4625 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4626 tdata->key.data, tdata->key.len,
4627 tdata->cipher_iv.len);
4631 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4633 /* Clear mbuf payload */
4634 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4635 rte_pktmbuf_tailroom(ut_params->ibuf));
4637 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4638 /* Append data which is padded to a multiple of */
4639 /* the algorithms block size */
4640 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4641 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4642 ciphertext_pad_len);
4643 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4645 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4647 /* Create SNOW 3G operation */
4648 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4649 tdata->cipher_iv.len,
4650 tdata->validCipherLenInBits.len,
4651 tdata->cipher.offset_bits);
4655 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4656 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4657 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4659 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4661 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4662 ut_params->obuf = ut_params->op->sym->m_dst;
4663 if (ut_params->obuf)
4664 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4666 plaintext = ciphertext;
4668 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4671 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4672 tdata->plaintext.data,
4673 tdata->validDataLenInBits.len,
4674 "SNOW 3G Plaintext data not as expected");
4678 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4680 struct crypto_testsuite_params *ts_params = &testsuite_params;
4681 struct crypto_unittest_params *ut_params = &unittest_params;
4685 uint8_t *plaintext, *ciphertext;
4686 unsigned ciphertext_pad_len;
4687 unsigned ciphertext_len;
4688 struct rte_cryptodev_info dev_info;
4690 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4691 uint64_t feat_flags = dev_info.feature_flags;
4693 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4694 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4695 printf("Device does not support RAW data-path APIs.\n");
4698 /* Verify the capabilities */
4699 struct rte_cryptodev_sym_capability_idx cap_idx;
4700 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4701 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4702 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4704 return TEST_SKIPPED;
4706 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4707 return TEST_SKIPPED;
4709 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4710 return TEST_SKIPPED;
4712 /* Create SNOW 3G session */
4713 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4714 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4715 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4716 tdata->key.data, tdata->key.len,
4717 tdata->cipher_iv.len);
4721 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4722 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4724 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4725 "Failed to allocate input buffer");
4726 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4727 "Failed to allocate output buffer");
4729 /* Clear mbuf payload */
4730 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4731 rte_pktmbuf_tailroom(ut_params->ibuf));
4733 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4734 rte_pktmbuf_tailroom(ut_params->obuf));
4736 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4737 /* Append data which is padded to a multiple of */
4738 /* the algorithms block size */
4739 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4740 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4741 ciphertext_pad_len);
4742 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4743 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4745 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4747 /* Create SNOW 3G operation */
4748 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4749 tdata->cipher_iv.len,
4750 tdata->validCipherLenInBits.len,
4755 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4756 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4757 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4759 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4761 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4762 ut_params->obuf = ut_params->op->sym->m_dst;
4763 if (ut_params->obuf)
4764 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4766 plaintext = ciphertext;
4768 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4771 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4772 tdata->plaintext.data,
4773 tdata->validDataLenInBits.len,
4774 "SNOW 3G Plaintext data not as expected");
4779 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4781 struct crypto_testsuite_params *ts_params = &testsuite_params;
4782 struct crypto_unittest_params *ut_params = &unittest_params;
4786 uint8_t *plaintext, *ciphertext;
4787 unsigned int plaintext_pad_len;
4788 unsigned int plaintext_len;
4790 struct rte_cryptodev_info dev_info;
4791 struct rte_cryptodev_sym_capability_idx cap_idx;
4793 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4794 uint64_t feat_flags = dev_info.feature_flags;
4796 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4797 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4798 (tdata->validDataLenInBits.len % 8 != 0))) {
4799 printf("Device doesn't support NON-Byte Aligned Data.\n");
4800 return TEST_SKIPPED;
4803 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4804 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4805 printf("Device doesn't support RAW data-path APIs.\n");
4806 return TEST_SKIPPED;
4809 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4810 return TEST_SKIPPED;
4812 /* Check if device supports ZUC EEA3 */
4813 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4814 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4816 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4818 return TEST_SKIPPED;
4820 /* Check if device supports ZUC EIA3 */
4821 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4822 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4824 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4826 return TEST_SKIPPED;
4828 /* Create ZUC session */
4829 retval = create_zuc_cipher_auth_encrypt_generate_session(
4830 ts_params->valid_devs[0],
4834 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4836 /* clear mbuf payload */
4837 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4838 rte_pktmbuf_tailroom(ut_params->ibuf));
4840 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4841 /* Append data which is padded to a multiple of */
4842 /* the algorithms block size */
4843 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4844 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4846 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4848 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4850 /* Create ZUC operation */
4851 retval = create_zuc_cipher_hash_generate_operation(tdata);
4855 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4856 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4857 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4859 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4861 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4862 ut_params->obuf = ut_params->op->sym->m_src;
4863 if (ut_params->obuf)
4864 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4866 ciphertext = plaintext;
4868 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4870 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4872 tdata->ciphertext.data,
4873 tdata->validDataLenInBits.len,
4874 "ZUC Ciphertext data not as expected");
4876 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4877 + plaintext_pad_len;
4880 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4884 "ZUC Generated auth tag not as expected");
4889 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4891 struct crypto_testsuite_params *ts_params = &testsuite_params;
4892 struct crypto_unittest_params *ut_params = &unittest_params;
4896 uint8_t *plaintext, *ciphertext;
4897 unsigned plaintext_pad_len;
4898 unsigned plaintext_len;
4899 struct rte_cryptodev_info dev_info;
4901 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4902 uint64_t feat_flags = dev_info.feature_flags;
4904 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4905 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4906 printf("Device doesn't support RAW data-path APIs.\n");
4907 return TEST_SKIPPED;
4910 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4911 return TEST_SKIPPED;
4913 /* Verify the capabilities */
4914 struct rte_cryptodev_sym_capability_idx cap_idx;
4915 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4916 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4917 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4919 return TEST_SKIPPED;
4920 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4921 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4922 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4924 return TEST_SKIPPED;
4926 /* Create SNOW 3G session */
4927 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4928 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4929 RTE_CRYPTO_AUTH_OP_GENERATE,
4930 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4931 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4932 tdata->key.data, tdata->key.len,
4933 tdata->auth_iv.len, tdata->digest.len,
4934 tdata->cipher_iv.len);
4937 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4939 /* clear mbuf payload */
4940 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4941 rte_pktmbuf_tailroom(ut_params->ibuf));
4943 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4944 /* Append data which is padded to a multiple of */
4945 /* the algorithms block size */
4946 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4947 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4949 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4951 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4953 /* Create SNOW 3G operation */
4954 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4955 tdata->digest.len, tdata->auth_iv.data,
4957 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4958 tdata->cipher_iv.data, tdata->cipher_iv.len,
4959 tdata->validCipherLenInBits.len,
4961 tdata->validAuthLenInBits.len,
4967 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4968 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4969 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4971 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4973 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4974 ut_params->obuf = ut_params->op->sym->m_src;
4975 if (ut_params->obuf)
4976 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4978 ciphertext = plaintext;
4980 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4982 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4984 tdata->ciphertext.data,
4985 tdata->validDataLenInBits.len,
4986 "SNOW 3G Ciphertext data not as expected");
4988 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4989 + plaintext_pad_len;
4992 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4995 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4996 "SNOW 3G Generated auth tag not as expected");
5001 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5002 uint8_t op_mode, uint8_t verify)
5004 struct crypto_testsuite_params *ts_params = &testsuite_params;
5005 struct crypto_unittest_params *ut_params = &unittest_params;
5009 uint8_t *plaintext = NULL, *ciphertext = NULL;
5010 unsigned int plaintext_pad_len;
5011 unsigned int plaintext_len;
5012 unsigned int ciphertext_pad_len;
5013 unsigned int ciphertext_len;
5015 struct rte_cryptodev_info dev_info;
5017 /* Verify the capabilities */
5018 struct rte_cryptodev_sym_capability_idx cap_idx;
5019 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5020 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5021 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5023 return TEST_SKIPPED;
5024 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5025 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5026 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5028 return TEST_SKIPPED;
5030 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5031 return TEST_SKIPPED;
5033 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5035 uint64_t feat_flags = dev_info.feature_flags;
5037 if (op_mode == OUT_OF_PLACE) {
5038 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5039 printf("Device doesn't support digest encrypted.\n");
5040 return TEST_SKIPPED;
5042 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5043 return TEST_SKIPPED;
5046 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5047 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5048 printf("Device doesn't support RAW data-path APIs.\n");
5049 return TEST_SKIPPED;
5052 /* Create SNOW 3G session */
5053 retval = create_wireless_algo_auth_cipher_session(
5054 ts_params->valid_devs[0],
5055 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5056 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5057 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5058 : RTE_CRYPTO_AUTH_OP_GENERATE),
5059 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5060 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5061 tdata->key.data, tdata->key.len,
5062 tdata->auth_iv.len, tdata->digest.len,
5063 tdata->cipher_iv.len);
5067 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5068 if (op_mode == OUT_OF_PLACE)
5069 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5071 /* clear mbuf payload */
5072 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5073 rte_pktmbuf_tailroom(ut_params->ibuf));
5074 if (op_mode == OUT_OF_PLACE)
5075 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5076 rte_pktmbuf_tailroom(ut_params->obuf));
5078 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5079 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5080 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5081 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5084 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5085 ciphertext_pad_len);
5086 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5087 if (op_mode == OUT_OF_PLACE)
5088 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5089 debug_hexdump(stdout, "ciphertext:", ciphertext,
5092 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5094 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5095 if (op_mode == OUT_OF_PLACE)
5096 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5097 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5100 /* Create SNOW 3G operation */
5101 retval = create_wireless_algo_auth_cipher_operation(
5102 tdata->digest.data, tdata->digest.len,
5103 tdata->cipher_iv.data, tdata->cipher_iv.len,
5104 tdata->auth_iv.data, tdata->auth_iv.len,
5105 (tdata->digest.offset_bytes == 0 ?
5106 (verify ? ciphertext_pad_len : plaintext_pad_len)
5107 : tdata->digest.offset_bytes),
5108 tdata->validCipherLenInBits.len,
5109 tdata->cipher.offset_bits,
5110 tdata->validAuthLenInBits.len,
5111 tdata->auth.offset_bits,
5112 op_mode, 0, verify);
5117 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5118 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5119 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5121 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5124 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5126 ut_params->obuf = (op_mode == IN_PLACE ?
5127 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5130 if (ut_params->obuf)
5131 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5134 plaintext = ciphertext +
5135 (tdata->cipher.offset_bits >> 3);
5137 debug_hexdump(stdout, "plaintext:", plaintext,
5138 (tdata->plaintext.len >> 3) - tdata->digest.len);
5139 debug_hexdump(stdout, "plaintext expected:",
5140 tdata->plaintext.data,
5141 (tdata->plaintext.len >> 3) - tdata->digest.len);
5143 if (ut_params->obuf)
5144 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5147 ciphertext = plaintext;
5149 debug_hexdump(stdout, "ciphertext:", ciphertext,
5151 debug_hexdump(stdout, "ciphertext expected:",
5152 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5154 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5155 + (tdata->digest.offset_bytes == 0 ?
5156 plaintext_pad_len : tdata->digest.offset_bytes);
5158 debug_hexdump(stdout, "digest:", ut_params->digest,
5160 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5166 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5168 tdata->plaintext.data,
5169 (tdata->plaintext.len - tdata->cipher.offset_bits -
5170 (tdata->digest.len << 3)),
5171 tdata->cipher.offset_bits,
5172 "SNOW 3G Plaintext data not as expected");
5174 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5176 tdata->ciphertext.data,
5177 (tdata->validDataLenInBits.len -
5178 tdata->cipher.offset_bits),
5179 tdata->cipher.offset_bits,
5180 "SNOW 3G Ciphertext data not as expected");
5182 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5185 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5186 "SNOW 3G Generated auth tag not as expected");
5192 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5193 uint8_t op_mode, uint8_t verify)
5195 struct crypto_testsuite_params *ts_params = &testsuite_params;
5196 struct crypto_unittest_params *ut_params = &unittest_params;
5200 const uint8_t *plaintext = NULL;
5201 const uint8_t *ciphertext = NULL;
5202 const uint8_t *digest = NULL;
5203 unsigned int plaintext_pad_len;
5204 unsigned int plaintext_len;
5205 unsigned int ciphertext_pad_len;
5206 unsigned int ciphertext_len;
5207 uint8_t buffer[10000];
5208 uint8_t digest_buffer[10000];
5210 struct rte_cryptodev_info dev_info;
5212 /* Verify the capabilities */
5213 struct rte_cryptodev_sym_capability_idx cap_idx;
5214 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5215 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5216 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5218 return TEST_SKIPPED;
5219 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5220 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5221 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5223 return TEST_SKIPPED;
5225 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5226 return TEST_SKIPPED;
5228 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5230 uint64_t feat_flags = dev_info.feature_flags;
5232 if (op_mode == IN_PLACE) {
5233 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5234 printf("Device doesn't support in-place scatter-gather "
5235 "in both input and output mbufs.\n");
5236 return TEST_SKIPPED;
5238 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5239 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5240 printf("Device doesn't support RAW data-path APIs.\n");
5241 return TEST_SKIPPED;
5244 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5245 return TEST_SKIPPED;
5246 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5247 printf("Device doesn't support out-of-place scatter-gather "
5248 "in both input and output mbufs.\n");
5249 return TEST_SKIPPED;
5251 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5252 printf("Device doesn't support digest encrypted.\n");
5253 return TEST_SKIPPED;
5257 /* Create SNOW 3G session */
5258 retval = create_wireless_algo_auth_cipher_session(
5259 ts_params->valid_devs[0],
5260 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5261 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5262 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5263 : RTE_CRYPTO_AUTH_OP_GENERATE),
5264 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5265 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5266 tdata->key.data, tdata->key.len,
5267 tdata->auth_iv.len, tdata->digest.len,
5268 tdata->cipher_iv.len);
5273 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5274 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5275 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5276 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5278 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5279 plaintext_pad_len, 15, 0);
5280 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5281 "Failed to allocate input buffer in mempool");
5283 if (op_mode == OUT_OF_PLACE) {
5284 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5285 plaintext_pad_len, 15, 0);
5286 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5287 "Failed to allocate output buffer in mempool");
5291 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5292 tdata->ciphertext.data);
5293 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5294 ciphertext_len, buffer);
5295 debug_hexdump(stdout, "ciphertext:", ciphertext,
5298 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5299 tdata->plaintext.data);
5300 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5301 plaintext_len, buffer);
5302 debug_hexdump(stdout, "plaintext:", plaintext,
5305 memset(buffer, 0, sizeof(buffer));
5307 /* Create SNOW 3G operation */
5308 retval = create_wireless_algo_auth_cipher_operation(
5309 tdata->digest.data, tdata->digest.len,
5310 tdata->cipher_iv.data, tdata->cipher_iv.len,
5311 tdata->auth_iv.data, tdata->auth_iv.len,
5312 (tdata->digest.offset_bytes == 0 ?
5313 (verify ? ciphertext_pad_len : plaintext_pad_len)
5314 : tdata->digest.offset_bytes),
5315 tdata->validCipherLenInBits.len,
5316 tdata->cipher.offset_bits,
5317 tdata->validAuthLenInBits.len,
5318 tdata->auth.offset_bits,
5319 op_mode, 1, verify);
5324 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5325 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5326 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5328 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5331 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5333 ut_params->obuf = (op_mode == IN_PLACE ?
5334 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5337 if (ut_params->obuf)
5338 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5339 plaintext_len, buffer);
5341 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5342 plaintext_len, buffer);
5344 debug_hexdump(stdout, "plaintext:", plaintext,
5345 (tdata->plaintext.len >> 3) - tdata->digest.len);
5346 debug_hexdump(stdout, "plaintext expected:",
5347 tdata->plaintext.data,
5348 (tdata->plaintext.len >> 3) - tdata->digest.len);
5350 if (ut_params->obuf)
5351 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5352 ciphertext_len, buffer);
5354 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5355 ciphertext_len, buffer);
5357 debug_hexdump(stdout, "ciphertext:", ciphertext,
5359 debug_hexdump(stdout, "ciphertext expected:",
5360 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5362 if (ut_params->obuf)
5363 digest = rte_pktmbuf_read(ut_params->obuf,
5364 (tdata->digest.offset_bytes == 0 ?
5365 plaintext_pad_len : tdata->digest.offset_bytes),
5366 tdata->digest.len, digest_buffer);
5368 digest = rte_pktmbuf_read(ut_params->ibuf,
5369 (tdata->digest.offset_bytes == 0 ?
5370 plaintext_pad_len : tdata->digest.offset_bytes),
5371 tdata->digest.len, digest_buffer);
5373 debug_hexdump(stdout, "digest:", digest,
5375 debug_hexdump(stdout, "digest expected:",
5376 tdata->digest.data, tdata->digest.len);
5381 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5383 tdata->plaintext.data,
5384 (tdata->plaintext.len - tdata->cipher.offset_bits -
5385 (tdata->digest.len << 3)),
5386 tdata->cipher.offset_bits,
5387 "SNOW 3G Plaintext data not as expected");
5389 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5391 tdata->ciphertext.data,
5392 (tdata->validDataLenInBits.len -
5393 tdata->cipher.offset_bits),
5394 tdata->cipher.offset_bits,
5395 "SNOW 3G Ciphertext data not as expected");
5397 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5400 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5401 "SNOW 3G Generated auth tag not as expected");
5407 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5408 uint8_t op_mode, uint8_t verify)
5410 struct crypto_testsuite_params *ts_params = &testsuite_params;
5411 struct crypto_unittest_params *ut_params = &unittest_params;
5415 uint8_t *plaintext = NULL, *ciphertext = NULL;
5416 unsigned int plaintext_pad_len;
5417 unsigned int plaintext_len;
5418 unsigned int ciphertext_pad_len;
5419 unsigned int ciphertext_len;
5421 struct rte_cryptodev_info dev_info;
5423 /* Verify the capabilities */
5424 struct rte_cryptodev_sym_capability_idx cap_idx;
5425 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5426 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5427 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5429 return TEST_SKIPPED;
5430 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5431 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5432 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5434 return TEST_SKIPPED;
5436 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5438 uint64_t feat_flags = dev_info.feature_flags;
5440 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5441 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5442 printf("Device doesn't support RAW data-path APIs.\n");
5443 return TEST_SKIPPED;
5446 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5447 return TEST_SKIPPED;
5449 if (op_mode == OUT_OF_PLACE) {
5450 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5451 return TEST_SKIPPED;
5452 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5453 printf("Device doesn't support digest encrypted.\n");
5454 return TEST_SKIPPED;
5458 /* Create KASUMI session */
5459 retval = create_wireless_algo_auth_cipher_session(
5460 ts_params->valid_devs[0],
5461 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5462 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5463 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5464 : RTE_CRYPTO_AUTH_OP_GENERATE),
5465 RTE_CRYPTO_AUTH_KASUMI_F9,
5466 RTE_CRYPTO_CIPHER_KASUMI_F8,
5467 tdata->key.data, tdata->key.len,
5468 0, tdata->digest.len,
5469 tdata->cipher_iv.len);
5474 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5475 if (op_mode == OUT_OF_PLACE)
5476 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5478 /* clear mbuf payload */
5479 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5480 rte_pktmbuf_tailroom(ut_params->ibuf));
5481 if (op_mode == OUT_OF_PLACE)
5482 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5483 rte_pktmbuf_tailroom(ut_params->obuf));
5485 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5486 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5487 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5488 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5491 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5492 ciphertext_pad_len);
5493 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5494 if (op_mode == OUT_OF_PLACE)
5495 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5496 debug_hexdump(stdout, "ciphertext:", ciphertext,
5499 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5501 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5502 if (op_mode == OUT_OF_PLACE)
5503 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5504 debug_hexdump(stdout, "plaintext:", plaintext,
5508 /* Create KASUMI operation */
5509 retval = create_wireless_algo_auth_cipher_operation(
5510 tdata->digest.data, tdata->digest.len,
5511 tdata->cipher_iv.data, tdata->cipher_iv.len,
5513 (tdata->digest.offset_bytes == 0 ?
5514 (verify ? ciphertext_pad_len : plaintext_pad_len)
5515 : tdata->digest.offset_bytes),
5516 tdata->validCipherLenInBits.len,
5517 tdata->validCipherOffsetInBits.len,
5518 tdata->validAuthLenInBits.len,
5520 op_mode, 0, verify);
5525 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5526 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5527 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5529 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5532 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5534 ut_params->obuf = (op_mode == IN_PLACE ?
5535 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5539 if (ut_params->obuf)
5540 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5543 plaintext = ciphertext;
5545 debug_hexdump(stdout, "plaintext:", plaintext,
5546 (tdata->plaintext.len >> 3) - tdata->digest.len);
5547 debug_hexdump(stdout, "plaintext expected:",
5548 tdata->plaintext.data,
5549 (tdata->plaintext.len >> 3) - tdata->digest.len);
5551 if (ut_params->obuf)
5552 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5555 ciphertext = plaintext;
5557 debug_hexdump(stdout, "ciphertext:", ciphertext,
5559 debug_hexdump(stdout, "ciphertext expected:",
5560 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5562 ut_params->digest = rte_pktmbuf_mtod(
5563 ut_params->obuf, uint8_t *) +
5564 (tdata->digest.offset_bytes == 0 ?
5565 plaintext_pad_len : tdata->digest.offset_bytes);
5567 debug_hexdump(stdout, "digest:", ut_params->digest,
5569 debug_hexdump(stdout, "digest expected:",
5570 tdata->digest.data, tdata->digest.len);
5575 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5577 tdata->plaintext.data,
5578 tdata->plaintext.len >> 3,
5579 "KASUMI Plaintext data not as expected");
5581 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5583 tdata->ciphertext.data,
5584 tdata->ciphertext.len >> 3,
5585 "KASUMI Ciphertext data not as expected");
5587 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5590 DIGEST_BYTE_LENGTH_KASUMI_F9,
5591 "KASUMI Generated auth tag not as expected");
5597 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5598 uint8_t op_mode, uint8_t verify)
5600 struct crypto_testsuite_params *ts_params = &testsuite_params;
5601 struct crypto_unittest_params *ut_params = &unittest_params;
5605 const uint8_t *plaintext = NULL;
5606 const uint8_t *ciphertext = NULL;
5607 const uint8_t *digest = NULL;
5608 unsigned int plaintext_pad_len;
5609 unsigned int plaintext_len;
5610 unsigned int ciphertext_pad_len;
5611 unsigned int ciphertext_len;
5612 uint8_t buffer[10000];
5613 uint8_t digest_buffer[10000];
5615 struct rte_cryptodev_info dev_info;
5617 /* Verify the capabilities */
5618 struct rte_cryptodev_sym_capability_idx cap_idx;
5619 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5620 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5621 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5623 return TEST_SKIPPED;
5624 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5625 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5626 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5628 return TEST_SKIPPED;
5630 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5631 return TEST_SKIPPED;
5633 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5635 uint64_t feat_flags = dev_info.feature_flags;
5637 if (op_mode == IN_PLACE) {
5638 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5639 printf("Device doesn't support in-place scatter-gather "
5640 "in both input and output mbufs.\n");
5641 return TEST_SKIPPED;
5643 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5644 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5645 printf("Device doesn't support RAW data-path APIs.\n");
5646 return TEST_SKIPPED;
5649 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5650 return TEST_SKIPPED;
5651 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5652 printf("Device doesn't support out-of-place scatter-gather "
5653 "in both input and output mbufs.\n");
5654 return TEST_SKIPPED;
5656 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5657 printf("Device doesn't support digest encrypted.\n");
5658 return TEST_SKIPPED;
5662 /* Create KASUMI session */
5663 retval = create_wireless_algo_auth_cipher_session(
5664 ts_params->valid_devs[0],
5665 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5666 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5667 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5668 : RTE_CRYPTO_AUTH_OP_GENERATE),
5669 RTE_CRYPTO_AUTH_KASUMI_F9,
5670 RTE_CRYPTO_CIPHER_KASUMI_F8,
5671 tdata->key.data, tdata->key.len,
5672 0, tdata->digest.len,
5673 tdata->cipher_iv.len);
5678 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5679 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5680 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5681 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5683 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5684 plaintext_pad_len, 15, 0);
5685 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5686 "Failed to allocate input buffer in mempool");
5688 if (op_mode == OUT_OF_PLACE) {
5689 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5690 plaintext_pad_len, 15, 0);
5691 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5692 "Failed to allocate output buffer in mempool");
5696 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5697 tdata->ciphertext.data);
5698 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5699 ciphertext_len, buffer);
5700 debug_hexdump(stdout, "ciphertext:", ciphertext,
5703 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5704 tdata->plaintext.data);
5705 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5706 plaintext_len, buffer);
5707 debug_hexdump(stdout, "plaintext:", plaintext,
5710 memset(buffer, 0, sizeof(buffer));
5712 /* Create KASUMI operation */
5713 retval = create_wireless_algo_auth_cipher_operation(
5714 tdata->digest.data, tdata->digest.len,
5715 tdata->cipher_iv.data, tdata->cipher_iv.len,
5717 (tdata->digest.offset_bytes == 0 ?
5718 (verify ? ciphertext_pad_len : plaintext_pad_len)
5719 : tdata->digest.offset_bytes),
5720 tdata->validCipherLenInBits.len,
5721 tdata->validCipherOffsetInBits.len,
5722 tdata->validAuthLenInBits.len,
5724 op_mode, 1, verify);
5729 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5730 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5731 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5733 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5736 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5738 ut_params->obuf = (op_mode == IN_PLACE ?
5739 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5742 if (ut_params->obuf)
5743 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5744 plaintext_len, buffer);
5746 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5747 plaintext_len, buffer);
5749 debug_hexdump(stdout, "plaintext:", plaintext,
5750 (tdata->plaintext.len >> 3) - tdata->digest.len);
5751 debug_hexdump(stdout, "plaintext expected:",
5752 tdata->plaintext.data,
5753 (tdata->plaintext.len >> 3) - tdata->digest.len);
5755 if (ut_params->obuf)
5756 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5757 ciphertext_len, buffer);
5759 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5760 ciphertext_len, buffer);
5762 debug_hexdump(stdout, "ciphertext:", ciphertext,
5764 debug_hexdump(stdout, "ciphertext expected:",
5765 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5767 if (ut_params->obuf)
5768 digest = rte_pktmbuf_read(ut_params->obuf,
5769 (tdata->digest.offset_bytes == 0 ?
5770 plaintext_pad_len : tdata->digest.offset_bytes),
5771 tdata->digest.len, digest_buffer);
5773 digest = rte_pktmbuf_read(ut_params->ibuf,
5774 (tdata->digest.offset_bytes == 0 ?
5775 plaintext_pad_len : tdata->digest.offset_bytes),
5776 tdata->digest.len, digest_buffer);
5778 debug_hexdump(stdout, "digest:", digest,
5780 debug_hexdump(stdout, "digest expected:",
5781 tdata->digest.data, tdata->digest.len);
5786 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5788 tdata->plaintext.data,
5789 tdata->plaintext.len >> 3,
5790 "KASUMI Plaintext data not as expected");
5792 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5794 tdata->ciphertext.data,
5795 tdata->validDataLenInBits.len,
5796 "KASUMI Ciphertext data not as expected");
5798 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5801 DIGEST_BYTE_LENGTH_KASUMI_F9,
5802 "KASUMI Generated auth tag not as expected");
5808 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5810 struct crypto_testsuite_params *ts_params = &testsuite_params;
5811 struct crypto_unittest_params *ut_params = &unittest_params;
5815 uint8_t *plaintext, *ciphertext;
5816 unsigned plaintext_pad_len;
5817 unsigned plaintext_len;
5818 struct rte_cryptodev_info dev_info;
5820 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5821 uint64_t feat_flags = dev_info.feature_flags;
5823 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5824 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5825 printf("Device doesn't support RAW data-path APIs.\n");
5826 return TEST_SKIPPED;
5829 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5830 return TEST_SKIPPED;
5832 /* Verify the capabilities */
5833 struct rte_cryptodev_sym_capability_idx cap_idx;
5834 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5835 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5836 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5838 return TEST_SKIPPED;
5839 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5840 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5841 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5843 return TEST_SKIPPED;
5845 /* Create KASUMI session */
5846 retval = create_wireless_algo_cipher_auth_session(
5847 ts_params->valid_devs[0],
5848 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5849 RTE_CRYPTO_AUTH_OP_GENERATE,
5850 RTE_CRYPTO_AUTH_KASUMI_F9,
5851 RTE_CRYPTO_CIPHER_KASUMI_F8,
5852 tdata->key.data, tdata->key.len,
5853 0, tdata->digest.len,
5854 tdata->cipher_iv.len);
5858 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5860 /* clear mbuf payload */
5861 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5862 rte_pktmbuf_tailroom(ut_params->ibuf));
5864 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5865 /* Append data which is padded to a multiple of */
5866 /* the algorithms block size */
5867 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5868 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5870 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5872 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5874 /* Create KASUMI operation */
5875 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5876 tdata->digest.len, NULL, 0,
5877 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5878 tdata->cipher_iv.data, tdata->cipher_iv.len,
5879 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5880 tdata->validCipherOffsetInBits.len,
5881 tdata->validAuthLenInBits.len,
5887 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5888 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5889 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5891 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5893 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5895 if (ut_params->op->sym->m_dst)
5896 ut_params->obuf = ut_params->op->sym->m_dst;
5898 ut_params->obuf = ut_params->op->sym->m_src;
5900 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5901 tdata->validCipherOffsetInBits.len >> 3);
5903 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5904 + plaintext_pad_len;
5906 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5907 (tdata->validCipherOffsetInBits.len >> 3);
5909 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5911 reference_ciphertext,
5912 tdata->validCipherLenInBits.len,
5913 "KASUMI Ciphertext data not as expected");
5916 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5919 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5920 "KASUMI Generated auth tag not as expected");
5925 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
5926 const enum rte_crypto_cipher_algorithm cipher_algo,
5927 const uint16_t key_size, const uint16_t iv_size)
5929 struct rte_cryptodev_sym_capability_idx cap_idx;
5930 const struct rte_cryptodev_symmetric_capability *cap;
5932 /* Check if device supports the algorithm */
5933 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5934 cap_idx.algo.cipher = cipher_algo;
5936 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5942 /* Check if device supports key size and IV size */
5943 if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
5952 check_auth_capability(const struct crypto_testsuite_params *ts_params,
5953 const enum rte_crypto_auth_algorithm auth_algo,
5954 const uint16_t key_size, const uint16_t iv_size,
5955 const uint16_t tag_size)
5957 struct rte_cryptodev_sym_capability_idx cap_idx;
5958 const struct rte_cryptodev_symmetric_capability *cap;
5960 /* Check if device supports the algorithm */
5961 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5962 cap_idx.algo.auth = auth_algo;
5964 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5970 /* Check if device supports key size and IV size */
5971 if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
5972 tag_size, iv_size) < 0) {
5980 test_zuc_encryption(const struct wireless_test_data *tdata)
5982 struct crypto_testsuite_params *ts_params = &testsuite_params;
5983 struct crypto_unittest_params *ut_params = &unittest_params;
5986 uint8_t *plaintext, *ciphertext;
5987 unsigned plaintext_pad_len;
5988 unsigned plaintext_len;
5989 struct rte_cryptodev_info dev_info;
5991 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5992 uint64_t feat_flags = dev_info.feature_flags;
5994 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5995 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5996 printf("Device doesn't support RAW data-path APIs.\n");
5997 return TEST_SKIPPED;
6000 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6001 return TEST_SKIPPED;
6003 /* Check if device supports ZUC EEA3 */
6004 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6005 tdata->key.len, tdata->cipher_iv.len) < 0)
6006 return TEST_SKIPPED;
6008 /* Create ZUC session */
6009 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6010 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6011 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6012 tdata->key.data, tdata->key.len,
6013 tdata->cipher_iv.len);
6017 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6019 /* Clear mbuf payload */
6020 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6021 rte_pktmbuf_tailroom(ut_params->ibuf));
6023 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6024 /* Append data which is padded to a multiple */
6025 /* of the algorithms block size */
6026 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6027 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6029 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6031 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6033 /* Create ZUC operation */
6034 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6035 tdata->cipher_iv.len,
6036 tdata->plaintext.len,
6041 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6042 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6043 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6045 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6047 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6049 ut_params->obuf = ut_params->op->sym->m_dst;
6050 if (ut_params->obuf)
6051 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6053 ciphertext = plaintext;
6055 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6058 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6060 tdata->ciphertext.data,
6061 tdata->validCipherLenInBits.len,
6062 "ZUC Ciphertext data not as expected");
6067 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
6069 struct crypto_testsuite_params *ts_params = &testsuite_params;
6070 struct crypto_unittest_params *ut_params = &unittest_params;
6074 unsigned int plaintext_pad_len;
6075 unsigned int plaintext_len;
6076 const uint8_t *ciphertext;
6077 uint8_t ciphertext_buffer[2048];
6078 struct rte_cryptodev_info dev_info;
6080 /* Check if device supports ZUC EEA3 */
6081 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6082 tdata->key.len, tdata->cipher_iv.len) < 0)
6083 return TEST_SKIPPED;
6085 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6086 return TEST_SKIPPED;
6088 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6090 uint64_t feat_flags = dev_info.feature_flags;
6092 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6093 printf("Device doesn't support in-place scatter-gather. "
6095 return TEST_SKIPPED;
6098 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6099 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6100 printf("Device doesn't support RAW data-path APIs.\n");
6101 return TEST_SKIPPED;
6104 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6106 /* Append data which is padded to a multiple */
6107 /* of the algorithms block size */
6108 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6110 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6111 plaintext_pad_len, 10, 0);
6113 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6114 tdata->plaintext.data);
6116 /* Create ZUC session */
6117 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6118 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6119 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6120 tdata->key.data, tdata->key.len,
6121 tdata->cipher_iv.len);
6125 /* Clear mbuf payload */
6127 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6129 /* Create ZUC operation */
6130 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6131 tdata->cipher_iv.len, tdata->plaintext.len,
6136 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6137 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6138 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6140 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6142 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6144 ut_params->obuf = ut_params->op->sym->m_dst;
6145 if (ut_params->obuf)
6146 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6147 0, plaintext_len, ciphertext_buffer);
6149 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6150 0, plaintext_len, ciphertext_buffer);
6153 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6156 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6158 tdata->ciphertext.data,
6159 tdata->validCipherLenInBits.len,
6160 "ZUC Ciphertext data not as expected");
6166 test_zuc_authentication(const struct wireless_test_data *tdata)
6168 struct crypto_testsuite_params *ts_params = &testsuite_params;
6169 struct crypto_unittest_params *ut_params = &unittest_params;
6172 unsigned plaintext_pad_len;
6173 unsigned plaintext_len;
6176 struct rte_cryptodev_info dev_info;
6178 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6179 uint64_t feat_flags = dev_info.feature_flags;
6181 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6182 (tdata->validAuthLenInBits.len % 8 != 0)) {
6183 printf("Device doesn't support NON-Byte Aligned Data.\n");
6184 return TEST_SKIPPED;
6187 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6188 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6189 printf("Device doesn't support RAW data-path APIs.\n");
6190 return TEST_SKIPPED;
6193 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6194 return TEST_SKIPPED;
6196 /* Check if device supports ZUC EIA3 */
6197 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6198 tdata->key.len, tdata->auth_iv.len,
6199 tdata->digest.len) < 0)
6200 return TEST_SKIPPED;
6202 /* Create ZUC session */
6203 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6204 tdata->key.data, tdata->key.len,
6205 tdata->auth_iv.len, tdata->digest.len,
6206 RTE_CRYPTO_AUTH_OP_GENERATE,
6207 RTE_CRYPTO_AUTH_ZUC_EIA3);
6211 /* alloc mbuf and set payload */
6212 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6214 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6215 rte_pktmbuf_tailroom(ut_params->ibuf));
6217 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6218 /* Append data which is padded to a multiple of */
6219 /* the algorithms block size */
6220 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6221 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6223 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6225 /* Create ZUC operation */
6226 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6227 tdata->auth_iv.data, tdata->auth_iv.len,
6228 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6229 tdata->validAuthLenInBits.len,
6234 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6235 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6236 ut_params->op, 0, 1, 1, 0);
6238 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6240 ut_params->obuf = ut_params->op->sym->m_src;
6241 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6242 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6243 + plaintext_pad_len;
6246 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6250 "ZUC Generated auth tag not as expected");
6256 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6257 uint8_t op_mode, uint8_t verify)
6259 struct crypto_testsuite_params *ts_params = &testsuite_params;
6260 struct crypto_unittest_params *ut_params = &unittest_params;
6264 uint8_t *plaintext = NULL, *ciphertext = NULL;
6265 unsigned int plaintext_pad_len;
6266 unsigned int plaintext_len;
6267 unsigned int ciphertext_pad_len;
6268 unsigned int ciphertext_len;
6270 struct rte_cryptodev_info dev_info;
6272 /* Check if device supports ZUC EEA3 */
6273 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6274 tdata->key.len, tdata->cipher_iv.len) < 0)
6275 return TEST_SKIPPED;
6277 /* Check if device supports ZUC EIA3 */
6278 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6279 tdata->key.len, tdata->auth_iv.len,
6280 tdata->digest.len) < 0)
6281 return TEST_SKIPPED;
6283 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6285 uint64_t feat_flags = dev_info.feature_flags;
6287 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6288 printf("Device doesn't support digest encrypted.\n");
6289 return TEST_SKIPPED;
6291 if (op_mode == IN_PLACE) {
6292 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6293 printf("Device doesn't support in-place scatter-gather "
6294 "in both input and output mbufs.\n");
6295 return TEST_SKIPPED;
6298 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6299 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6300 printf("Device doesn't support RAW data-path APIs.\n");
6301 return TEST_SKIPPED;
6304 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6305 return TEST_SKIPPED;
6306 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6307 printf("Device doesn't support out-of-place scatter-gather "
6308 "in both input and output mbufs.\n");
6309 return TEST_SKIPPED;
6313 /* Create ZUC session */
6314 retval = create_wireless_algo_auth_cipher_session(
6315 ts_params->valid_devs[0],
6316 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6317 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6318 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6319 : RTE_CRYPTO_AUTH_OP_GENERATE),
6320 RTE_CRYPTO_AUTH_ZUC_EIA3,
6321 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6322 tdata->key.data, tdata->key.len,
6323 tdata->auth_iv.len, tdata->digest.len,
6324 tdata->cipher_iv.len);
6329 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6330 if (op_mode == OUT_OF_PLACE)
6331 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6333 /* clear mbuf payload */
6334 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6335 rte_pktmbuf_tailroom(ut_params->ibuf));
6336 if (op_mode == OUT_OF_PLACE)
6337 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6338 rte_pktmbuf_tailroom(ut_params->obuf));
6340 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6341 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6342 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6343 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6346 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6347 ciphertext_pad_len);
6348 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6349 debug_hexdump(stdout, "ciphertext:", ciphertext,
6352 /* make sure enough space to cover partial digest verify case */
6353 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6354 ciphertext_pad_len);
6355 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6356 debug_hexdump(stdout, "plaintext:", plaintext,
6360 if (op_mode == OUT_OF_PLACE)
6361 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6363 /* Create ZUC operation */
6364 retval = create_wireless_algo_auth_cipher_operation(
6365 tdata->digest.data, tdata->digest.len,
6366 tdata->cipher_iv.data, tdata->cipher_iv.len,
6367 tdata->auth_iv.data, tdata->auth_iv.len,
6368 (tdata->digest.offset_bytes == 0 ?
6369 (verify ? ciphertext_pad_len : plaintext_pad_len)
6370 : tdata->digest.offset_bytes),
6371 tdata->validCipherLenInBits.len,
6372 tdata->validCipherOffsetInBits.len,
6373 tdata->validAuthLenInBits.len,
6375 op_mode, 0, verify);
6380 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6381 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6382 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6384 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6387 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6389 ut_params->obuf = (op_mode == IN_PLACE ?
6390 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6394 if (ut_params->obuf)
6395 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6398 plaintext = ciphertext;
6400 debug_hexdump(stdout, "plaintext:", plaintext,
6401 (tdata->plaintext.len >> 3) - tdata->digest.len);
6402 debug_hexdump(stdout, "plaintext expected:",
6403 tdata->plaintext.data,
6404 (tdata->plaintext.len >> 3) - tdata->digest.len);
6406 if (ut_params->obuf)
6407 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6410 ciphertext = plaintext;
6412 debug_hexdump(stdout, "ciphertext:", ciphertext,
6414 debug_hexdump(stdout, "ciphertext expected:",
6415 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6417 ut_params->digest = rte_pktmbuf_mtod(
6418 ut_params->obuf, uint8_t *) +
6419 (tdata->digest.offset_bytes == 0 ?
6420 plaintext_pad_len : tdata->digest.offset_bytes);
6422 debug_hexdump(stdout, "digest:", ut_params->digest,
6424 debug_hexdump(stdout, "digest expected:",
6425 tdata->digest.data, tdata->digest.len);
6430 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6432 tdata->plaintext.data,
6433 tdata->plaintext.len >> 3,
6434 "ZUC Plaintext data not as expected");
6436 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6438 tdata->ciphertext.data,
6439 tdata->ciphertext.len >> 3,
6440 "ZUC Ciphertext data not as expected");
6442 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6445 DIGEST_BYTE_LENGTH_KASUMI_F9,
6446 "ZUC Generated auth tag not as expected");
6452 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6453 uint8_t op_mode, uint8_t verify)
6455 struct crypto_testsuite_params *ts_params = &testsuite_params;
6456 struct crypto_unittest_params *ut_params = &unittest_params;
6460 const uint8_t *plaintext = NULL;
6461 const uint8_t *ciphertext = NULL;
6462 const uint8_t *digest = NULL;
6463 unsigned int plaintext_pad_len;
6464 unsigned int plaintext_len;
6465 unsigned int ciphertext_pad_len;
6466 unsigned int ciphertext_len;
6467 uint8_t buffer[10000];
6468 uint8_t digest_buffer[10000];
6470 struct rte_cryptodev_info dev_info;
6472 /* Check if device supports ZUC EEA3 */
6473 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6474 tdata->key.len, tdata->cipher_iv.len) < 0)
6475 return TEST_SKIPPED;
6477 /* Check if device supports ZUC EIA3 */
6478 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6479 tdata->key.len, tdata->auth_iv.len,
6480 tdata->digest.len) < 0)
6481 return TEST_SKIPPED;
6483 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6485 uint64_t feat_flags = dev_info.feature_flags;
6487 if (op_mode == IN_PLACE) {
6488 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6489 printf("Device doesn't support in-place scatter-gather "
6490 "in both input and output mbufs.\n");
6491 return TEST_SKIPPED;
6494 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6495 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6496 printf("Device doesn't support RAW data-path APIs.\n");
6497 return TEST_SKIPPED;
6500 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6501 return TEST_SKIPPED;
6502 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6503 printf("Device doesn't support out-of-place scatter-gather "
6504 "in both input and output mbufs.\n");
6505 return TEST_SKIPPED;
6507 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6508 printf("Device doesn't support digest encrypted.\n");
6509 return TEST_SKIPPED;
6513 /* Create ZUC session */
6514 retval = create_wireless_algo_auth_cipher_session(
6515 ts_params->valid_devs[0],
6516 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6517 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6518 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6519 : RTE_CRYPTO_AUTH_OP_GENERATE),
6520 RTE_CRYPTO_AUTH_ZUC_EIA3,
6521 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6522 tdata->key.data, tdata->key.len,
6523 tdata->auth_iv.len, tdata->digest.len,
6524 tdata->cipher_iv.len);
6529 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6530 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6531 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6532 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6534 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6535 plaintext_pad_len, 15, 0);
6536 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6537 "Failed to allocate input buffer in mempool");
6539 if (op_mode == OUT_OF_PLACE) {
6540 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6541 plaintext_pad_len, 15, 0);
6542 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6543 "Failed to allocate output buffer in mempool");
6547 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6548 tdata->ciphertext.data);
6549 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6550 ciphertext_len, buffer);
6551 debug_hexdump(stdout, "ciphertext:", ciphertext,
6554 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6555 tdata->plaintext.data);
6556 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6557 plaintext_len, buffer);
6558 debug_hexdump(stdout, "plaintext:", plaintext,
6561 memset(buffer, 0, sizeof(buffer));
6563 /* Create ZUC operation */
6564 retval = create_wireless_algo_auth_cipher_operation(
6565 tdata->digest.data, tdata->digest.len,
6566 tdata->cipher_iv.data, tdata->cipher_iv.len,
6568 (tdata->digest.offset_bytes == 0 ?
6569 (verify ? ciphertext_pad_len : plaintext_pad_len)
6570 : tdata->digest.offset_bytes),
6571 tdata->validCipherLenInBits.len,
6572 tdata->validCipherOffsetInBits.len,
6573 tdata->validAuthLenInBits.len,
6575 op_mode, 1, verify);
6580 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6581 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6582 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6584 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6587 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6589 ut_params->obuf = (op_mode == IN_PLACE ?
6590 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6593 if (ut_params->obuf)
6594 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6595 plaintext_len, buffer);
6597 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6598 plaintext_len, buffer);
6600 debug_hexdump(stdout, "plaintext:", plaintext,
6601 (tdata->plaintext.len >> 3) - tdata->digest.len);
6602 debug_hexdump(stdout, "plaintext expected:",
6603 tdata->plaintext.data,
6604 (tdata->plaintext.len >> 3) - tdata->digest.len);
6606 if (ut_params->obuf)
6607 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6608 ciphertext_len, buffer);
6610 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6611 ciphertext_len, buffer);
6613 debug_hexdump(stdout, "ciphertext:", ciphertext,
6615 debug_hexdump(stdout, "ciphertext expected:",
6616 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6618 if (ut_params->obuf)
6619 digest = rte_pktmbuf_read(ut_params->obuf,
6620 (tdata->digest.offset_bytes == 0 ?
6621 plaintext_pad_len : tdata->digest.offset_bytes),
6622 tdata->digest.len, digest_buffer);
6624 digest = rte_pktmbuf_read(ut_params->ibuf,
6625 (tdata->digest.offset_bytes == 0 ?
6626 plaintext_pad_len : tdata->digest.offset_bytes),
6627 tdata->digest.len, digest_buffer);
6629 debug_hexdump(stdout, "digest:", digest,
6631 debug_hexdump(stdout, "digest expected:",
6632 tdata->digest.data, tdata->digest.len);
6637 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6639 tdata->plaintext.data,
6640 tdata->plaintext.len >> 3,
6641 "ZUC Plaintext data not as expected");
6643 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6645 tdata->ciphertext.data,
6646 tdata->validDataLenInBits.len,
6647 "ZUC Ciphertext data not as expected");
6649 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6652 DIGEST_BYTE_LENGTH_KASUMI_F9,
6653 "ZUC Generated auth tag not as expected");
6659 test_kasumi_encryption_test_case_1(void)
6661 return test_kasumi_encryption(&kasumi_test_case_1);
6665 test_kasumi_encryption_test_case_1_sgl(void)
6667 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6671 test_kasumi_encryption_test_case_1_oop(void)
6673 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6677 test_kasumi_encryption_test_case_1_oop_sgl(void)
6679 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6683 test_kasumi_encryption_test_case_2(void)
6685 return test_kasumi_encryption(&kasumi_test_case_2);
6689 test_kasumi_encryption_test_case_3(void)
6691 return test_kasumi_encryption(&kasumi_test_case_3);
6695 test_kasumi_encryption_test_case_4(void)
6697 return test_kasumi_encryption(&kasumi_test_case_4);
6701 test_kasumi_encryption_test_case_5(void)
6703 return test_kasumi_encryption(&kasumi_test_case_5);
6707 test_kasumi_decryption_test_case_1(void)
6709 return test_kasumi_decryption(&kasumi_test_case_1);
6713 test_kasumi_decryption_test_case_1_oop(void)
6715 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6719 test_kasumi_decryption_test_case_2(void)
6721 return test_kasumi_decryption(&kasumi_test_case_2);
6725 test_kasumi_decryption_test_case_3(void)
6727 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6728 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6729 return TEST_SKIPPED;
6730 return test_kasumi_decryption(&kasumi_test_case_3);
6734 test_kasumi_decryption_test_case_4(void)
6736 return test_kasumi_decryption(&kasumi_test_case_4);
6740 test_kasumi_decryption_test_case_5(void)
6742 return test_kasumi_decryption(&kasumi_test_case_5);
6745 test_snow3g_encryption_test_case_1(void)
6747 return test_snow3g_encryption(&snow3g_test_case_1);
6751 test_snow3g_encryption_test_case_1_oop(void)
6753 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6757 test_snow3g_encryption_test_case_1_oop_sgl(void)
6759 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6764 test_snow3g_encryption_test_case_1_offset_oop(void)
6766 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6770 test_snow3g_encryption_test_case_2(void)
6772 return test_snow3g_encryption(&snow3g_test_case_2);
6776 test_snow3g_encryption_test_case_3(void)
6778 return test_snow3g_encryption(&snow3g_test_case_3);
6782 test_snow3g_encryption_test_case_4(void)
6784 return test_snow3g_encryption(&snow3g_test_case_4);
6788 test_snow3g_encryption_test_case_5(void)
6790 return test_snow3g_encryption(&snow3g_test_case_5);
6794 test_snow3g_decryption_test_case_1(void)
6796 return test_snow3g_decryption(&snow3g_test_case_1);
6800 test_snow3g_decryption_test_case_1_oop(void)
6802 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6806 test_snow3g_decryption_test_case_2(void)
6808 return test_snow3g_decryption(&snow3g_test_case_2);
6812 test_snow3g_decryption_test_case_3(void)
6814 return test_snow3g_decryption(&snow3g_test_case_3);
6818 test_snow3g_decryption_test_case_4(void)
6820 return test_snow3g_decryption(&snow3g_test_case_4);
6824 test_snow3g_decryption_test_case_5(void)
6826 return test_snow3g_decryption(&snow3g_test_case_5);
6830 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6831 * Pattern digest from snow3g_test_data must be allocated as
6832 * 4 last bytes in plaintext.
6835 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6836 struct snow3g_hash_test_data *output)
6838 if ((pattern != NULL) && (output != NULL)) {
6839 output->key.len = pattern->key.len;
6841 memcpy(output->key.data,
6842 pattern->key.data, pattern->key.len);
6844 output->auth_iv.len = pattern->auth_iv.len;
6846 memcpy(output->auth_iv.data,
6847 pattern->auth_iv.data, pattern->auth_iv.len);
6849 output->plaintext.len = pattern->plaintext.len;
6851 memcpy(output->plaintext.data,
6852 pattern->plaintext.data, pattern->plaintext.len >> 3);
6854 output->digest.len = pattern->digest.len;
6856 memcpy(output->digest.data,
6857 &pattern->plaintext.data[pattern->digest.offset_bytes],
6858 pattern->digest.len);
6860 output->validAuthLenInBits.len =
6861 pattern->validAuthLenInBits.len;
6866 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6869 test_snow3g_decryption_with_digest_test_case_1(void)
6871 struct snow3g_hash_test_data snow3g_hash_data;
6872 struct rte_cryptodev_info dev_info;
6873 struct crypto_testsuite_params *ts_params = &testsuite_params;
6875 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6876 uint64_t feat_flags = dev_info.feature_flags;
6878 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6879 printf("Device doesn't support encrypted digest operations.\n");
6880 return TEST_SKIPPED;
6884 * Function prepare data for hash verification test case.
6885 * Digest is allocated in 4 last bytes in plaintext, pattern.
6887 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6889 return test_snow3g_decryption(&snow3g_test_case_7) &
6890 test_snow3g_authentication_verify(&snow3g_hash_data);
6894 test_snow3g_cipher_auth_test_case_1(void)
6896 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6900 test_snow3g_auth_cipher_test_case_1(void)
6902 return test_snow3g_auth_cipher(
6903 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6907 test_snow3g_auth_cipher_test_case_2(void)
6909 return test_snow3g_auth_cipher(
6910 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6914 test_snow3g_auth_cipher_test_case_2_oop(void)
6916 return test_snow3g_auth_cipher(
6917 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6921 test_snow3g_auth_cipher_part_digest_enc(void)
6923 return test_snow3g_auth_cipher(
6924 &snow3g_auth_cipher_partial_digest_encryption,
6929 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6931 return test_snow3g_auth_cipher(
6932 &snow3g_auth_cipher_partial_digest_encryption,
6937 test_snow3g_auth_cipher_test_case_3_sgl(void)
6939 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6940 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6941 return TEST_SKIPPED;
6942 return test_snow3g_auth_cipher_sgl(
6943 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6947 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6949 return test_snow3g_auth_cipher_sgl(
6950 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6954 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6956 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6957 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6958 return TEST_SKIPPED;
6959 return test_snow3g_auth_cipher_sgl(
6960 &snow3g_auth_cipher_partial_digest_encryption,
6965 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6967 return test_snow3g_auth_cipher_sgl(
6968 &snow3g_auth_cipher_partial_digest_encryption,
6973 test_snow3g_auth_cipher_verify_test_case_1(void)
6975 return test_snow3g_auth_cipher(
6976 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6980 test_snow3g_auth_cipher_verify_test_case_2(void)
6982 return test_snow3g_auth_cipher(
6983 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6987 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6989 return test_snow3g_auth_cipher(
6990 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6994 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6996 return test_snow3g_auth_cipher(
6997 &snow3g_auth_cipher_partial_digest_encryption,
7002 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7004 return test_snow3g_auth_cipher(
7005 &snow3g_auth_cipher_partial_digest_encryption,
7010 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7012 return test_snow3g_auth_cipher_sgl(
7013 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7017 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7019 return test_snow3g_auth_cipher_sgl(
7020 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7024 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7026 return test_snow3g_auth_cipher_sgl(
7027 &snow3g_auth_cipher_partial_digest_encryption,
7032 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7034 return test_snow3g_auth_cipher_sgl(
7035 &snow3g_auth_cipher_partial_digest_encryption,
7040 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7042 return test_snow3g_auth_cipher(
7043 &snow3g_test_case_7, IN_PLACE, 0);
7047 test_kasumi_auth_cipher_test_case_1(void)
7049 return test_kasumi_auth_cipher(
7050 &kasumi_test_case_3, IN_PLACE, 0);
7054 test_kasumi_auth_cipher_test_case_2(void)
7056 return test_kasumi_auth_cipher(
7057 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7061 test_kasumi_auth_cipher_test_case_2_oop(void)
7063 return test_kasumi_auth_cipher(
7064 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7068 test_kasumi_auth_cipher_test_case_2_sgl(void)
7070 return test_kasumi_auth_cipher_sgl(
7071 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7075 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7077 return test_kasumi_auth_cipher_sgl(
7078 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7082 test_kasumi_auth_cipher_verify_test_case_1(void)
7084 return test_kasumi_auth_cipher(
7085 &kasumi_test_case_3, IN_PLACE, 1);
7089 test_kasumi_auth_cipher_verify_test_case_2(void)
7091 return test_kasumi_auth_cipher(
7092 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7096 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7098 return test_kasumi_auth_cipher(
7099 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7103 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7105 return test_kasumi_auth_cipher_sgl(
7106 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7110 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7112 return test_kasumi_auth_cipher_sgl(
7113 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7117 test_kasumi_cipher_auth_test_case_1(void)
7119 return test_kasumi_cipher_auth(&kasumi_test_case_6);
7123 test_zuc_encryption_test_case_1(void)
7125 return test_zuc_encryption(&zuc_test_case_cipher_193b);
7129 test_zuc_encryption_test_case_2(void)
7131 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7135 test_zuc_encryption_test_case_3(void)
7137 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7141 test_zuc_encryption_test_case_4(void)
7143 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7147 test_zuc_encryption_test_case_5(void)
7149 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7153 test_zuc_encryption_test_case_6_sgl(void)
7155 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7159 test_zuc_hash_generate_test_case_1(void)
7161 return test_zuc_authentication(&zuc_test_case_auth_1b);
7165 test_zuc_hash_generate_test_case_2(void)
7167 return test_zuc_authentication(&zuc_test_case_auth_90b);
7171 test_zuc_hash_generate_test_case_3(void)
7173 return test_zuc_authentication(&zuc_test_case_auth_577b);
7177 test_zuc_hash_generate_test_case_4(void)
7179 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7183 test_zuc_hash_generate_test_case_5(void)
7185 return test_zuc_authentication(&zuc_test_auth_5670b);
7189 test_zuc_hash_generate_test_case_6(void)
7191 return test_zuc_authentication(&zuc_test_case_auth_128b);
7195 test_zuc_hash_generate_test_case_7(void)
7197 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7201 test_zuc_hash_generate_test_case_8(void)
7203 return test_zuc_authentication(&zuc_test_case_auth_584b);
7207 test_zuc_hash_generate_test_case_9(void)
7209 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b);
7213 test_zuc_hash_generate_test_case_10(void)
7215 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b);
7219 test_zuc_hash_generate_test_case_11(void)
7221 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b);
7225 test_zuc_cipher_auth_test_case_1(void)
7227 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7231 test_zuc_cipher_auth_test_case_2(void)
7233 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7237 test_zuc_auth_cipher_test_case_1(void)
7239 return test_zuc_auth_cipher(
7240 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7244 test_zuc_auth_cipher_test_case_1_oop(void)
7246 return test_zuc_auth_cipher(
7247 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7251 test_zuc_auth_cipher_test_case_1_sgl(void)
7253 return test_zuc_auth_cipher_sgl(
7254 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7258 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7260 return test_zuc_auth_cipher_sgl(
7261 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7265 test_zuc_auth_cipher_verify_test_case_1(void)
7267 return test_zuc_auth_cipher(
7268 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7272 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7274 return test_zuc_auth_cipher(
7275 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7279 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7281 return test_zuc_auth_cipher_sgl(
7282 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7286 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7288 return test_zuc_auth_cipher_sgl(
7289 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7293 test_zuc256_encryption_test_case_1(void)
7295 return test_zuc_encryption(&zuc256_test_case_cipher_1);
7299 test_zuc256_encryption_test_case_2(void)
7301 return test_zuc_encryption(&zuc256_test_case_cipher_2);
7305 test_zuc256_authentication_test_case_1(void)
7307 return test_zuc_authentication(&zuc256_test_case_auth_1);
7311 test_zuc256_authentication_test_case_2(void)
7313 return test_zuc_authentication(&zuc256_test_case_auth_2);
7317 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7319 uint8_t dev_id = testsuite_params.valid_devs[0];
7321 struct rte_cryptodev_sym_capability_idx cap_idx;
7323 /* Check if device supports particular cipher algorithm */
7324 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7325 cap_idx.algo.cipher = tdata->cipher_algo;
7326 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7327 return TEST_SKIPPED;
7329 /* Check if device supports particular hash algorithm */
7330 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7331 cap_idx.algo.auth = tdata->auth_algo;
7332 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7333 return TEST_SKIPPED;
7339 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7340 uint8_t op_mode, uint8_t verify)
7342 struct crypto_testsuite_params *ts_params = &testsuite_params;
7343 struct crypto_unittest_params *ut_params = &unittest_params;
7347 uint8_t *plaintext = NULL, *ciphertext = NULL;
7348 unsigned int plaintext_pad_len;
7349 unsigned int plaintext_len;
7350 unsigned int ciphertext_pad_len;
7351 unsigned int ciphertext_len;
7353 struct rte_cryptodev_info dev_info;
7354 struct rte_crypto_op *op;
7356 /* Check if device supports particular algorithms separately */
7357 if (test_mixed_check_if_unsupported(tdata))
7358 return TEST_SKIPPED;
7359 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7360 return TEST_SKIPPED;
7362 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7364 uint64_t feat_flags = dev_info.feature_flags;
7366 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7367 printf("Device doesn't support digest encrypted.\n");
7368 return TEST_SKIPPED;
7371 /* Create the session */
7373 retval = create_wireless_algo_cipher_auth_session(
7374 ts_params->valid_devs[0],
7375 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7376 RTE_CRYPTO_AUTH_OP_VERIFY,
7379 tdata->auth_key.data, tdata->auth_key.len,
7380 tdata->auth_iv.len, tdata->digest_enc.len,
7381 tdata->cipher_iv.len);
7383 retval = create_wireless_algo_auth_cipher_session(
7384 ts_params->valid_devs[0],
7385 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7386 RTE_CRYPTO_AUTH_OP_GENERATE,
7389 tdata->auth_key.data, tdata->auth_key.len,
7390 tdata->auth_iv.len, tdata->digest_enc.len,
7391 tdata->cipher_iv.len);
7395 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7396 if (op_mode == OUT_OF_PLACE)
7397 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7399 /* clear mbuf payload */
7400 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7401 rte_pktmbuf_tailroom(ut_params->ibuf));
7402 if (op_mode == OUT_OF_PLACE) {
7404 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7405 rte_pktmbuf_tailroom(ut_params->obuf));
7408 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7409 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7410 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7411 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7414 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7415 ciphertext_pad_len);
7416 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7417 debug_hexdump(stdout, "ciphertext:", ciphertext,
7420 /* make sure enough space to cover partial digest verify case */
7421 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7422 ciphertext_pad_len);
7423 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7424 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7427 if (op_mode == OUT_OF_PLACE)
7428 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7430 /* Create the operation */
7431 retval = create_wireless_algo_auth_cipher_operation(
7432 tdata->digest_enc.data, tdata->digest_enc.len,
7433 tdata->cipher_iv.data, tdata->cipher_iv.len,
7434 tdata->auth_iv.data, tdata->auth_iv.len,
7435 (tdata->digest_enc.offset == 0 ?
7437 : tdata->digest_enc.offset),
7438 tdata->validCipherLen.len_bits,
7439 tdata->cipher.offset_bits,
7440 tdata->validAuthLen.len_bits,
7441 tdata->auth.offset_bits,
7442 op_mode, 0, verify);
7447 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7449 /* Check if the op failed because the device doesn't */
7450 /* support this particular combination of algorithms */
7451 if (op == NULL && ut_params->op->status ==
7452 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7453 printf("Device doesn't support this mixed combination. "
7455 return TEST_SKIPPED;
7459 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7461 ut_params->obuf = (op_mode == IN_PLACE ?
7462 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7465 if (ut_params->obuf)
7466 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7469 plaintext = ciphertext +
7470 (tdata->cipher.offset_bits >> 3);
7472 debug_hexdump(stdout, "plaintext:", plaintext,
7473 tdata->plaintext.len_bits >> 3);
7474 debug_hexdump(stdout, "plaintext expected:",
7475 tdata->plaintext.data,
7476 tdata->plaintext.len_bits >> 3);
7478 if (ut_params->obuf)
7479 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7482 ciphertext = plaintext;
7484 debug_hexdump(stdout, "ciphertext:", ciphertext,
7486 debug_hexdump(stdout, "ciphertext expected:",
7487 tdata->ciphertext.data,
7488 tdata->ciphertext.len_bits >> 3);
7490 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7491 + (tdata->digest_enc.offset == 0 ?
7492 plaintext_pad_len : tdata->digest_enc.offset);
7494 debug_hexdump(stdout, "digest:", ut_params->digest,
7495 tdata->digest_enc.len);
7496 debug_hexdump(stdout, "digest expected:",
7497 tdata->digest_enc.data,
7498 tdata->digest_enc.len);
7502 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7504 tdata->digest_enc.data,
7505 tdata->digest_enc.len,
7506 "Generated auth tag not as expected");
7509 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7511 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7513 tdata->plaintext.data,
7514 tdata->plaintext.len_bits >> 3,
7515 "Plaintext data not as expected");
7517 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7519 tdata->ciphertext.data,
7520 tdata->validDataLen.len_bits,
7521 "Ciphertext data not as expected");
7525 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7526 "crypto op processing failed");
7532 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7533 uint8_t op_mode, uint8_t verify)
7535 struct crypto_testsuite_params *ts_params = &testsuite_params;
7536 struct crypto_unittest_params *ut_params = &unittest_params;
7540 const uint8_t *plaintext = NULL;
7541 const uint8_t *ciphertext = NULL;
7542 const uint8_t *digest = NULL;
7543 unsigned int plaintext_pad_len;
7544 unsigned int plaintext_len;
7545 unsigned int ciphertext_pad_len;
7546 unsigned int ciphertext_len;
7547 uint8_t buffer[10000];
7548 uint8_t digest_buffer[10000];
7550 struct rte_cryptodev_info dev_info;
7551 struct rte_crypto_op *op;
7553 /* Check if device supports particular algorithms */
7554 if (test_mixed_check_if_unsupported(tdata))
7555 return TEST_SKIPPED;
7556 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7557 return TEST_SKIPPED;
7559 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7561 uint64_t feat_flags = dev_info.feature_flags;
7563 if (op_mode == IN_PLACE) {
7564 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7565 printf("Device doesn't support in-place scatter-gather "
7566 "in both input and output mbufs.\n");
7567 return TEST_SKIPPED;
7570 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7571 printf("Device doesn't support out-of-place scatter-gather "
7572 "in both input and output mbufs.\n");
7573 return TEST_SKIPPED;
7575 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7576 printf("Device doesn't support digest encrypted.\n");
7577 return TEST_SKIPPED;
7581 /* Create the session */
7583 retval = create_wireless_algo_cipher_auth_session(
7584 ts_params->valid_devs[0],
7585 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7586 RTE_CRYPTO_AUTH_OP_VERIFY,
7589 tdata->auth_key.data, tdata->auth_key.len,
7590 tdata->auth_iv.len, tdata->digest_enc.len,
7591 tdata->cipher_iv.len);
7593 retval = create_wireless_algo_auth_cipher_session(
7594 ts_params->valid_devs[0],
7595 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7596 RTE_CRYPTO_AUTH_OP_GENERATE,
7599 tdata->auth_key.data, tdata->auth_key.len,
7600 tdata->auth_iv.len, tdata->digest_enc.len,
7601 tdata->cipher_iv.len);
7605 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7606 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7607 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7608 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7610 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7611 ciphertext_pad_len, 15, 0);
7612 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7613 "Failed to allocate input buffer in mempool");
7615 if (op_mode == OUT_OF_PLACE) {
7616 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7617 plaintext_pad_len, 15, 0);
7618 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7619 "Failed to allocate output buffer in mempool");
7623 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7624 tdata->ciphertext.data);
7625 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7626 ciphertext_len, buffer);
7627 debug_hexdump(stdout, "ciphertext:", ciphertext,
7630 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7631 tdata->plaintext.data);
7632 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7633 plaintext_len, buffer);
7634 debug_hexdump(stdout, "plaintext:", plaintext,
7637 memset(buffer, 0, sizeof(buffer));
7639 /* Create the operation */
7640 retval = create_wireless_algo_auth_cipher_operation(
7641 tdata->digest_enc.data, tdata->digest_enc.len,
7642 tdata->cipher_iv.data, tdata->cipher_iv.len,
7643 tdata->auth_iv.data, tdata->auth_iv.len,
7644 (tdata->digest_enc.offset == 0 ?
7646 : tdata->digest_enc.offset),
7647 tdata->validCipherLen.len_bits,
7648 tdata->cipher.offset_bits,
7649 tdata->validAuthLen.len_bits,
7650 tdata->auth.offset_bits,
7651 op_mode, 1, verify);
7656 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7658 /* Check if the op failed because the device doesn't */
7659 /* support this particular combination of algorithms */
7660 if (op == NULL && ut_params->op->status ==
7661 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7662 printf("Device doesn't support this mixed combination. "
7664 return TEST_SKIPPED;
7668 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7670 ut_params->obuf = (op_mode == IN_PLACE ?
7671 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7674 if (ut_params->obuf)
7675 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7676 plaintext_len, buffer);
7678 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7679 plaintext_len, buffer);
7681 debug_hexdump(stdout, "plaintext:", plaintext,
7682 (tdata->plaintext.len_bits >> 3) -
7683 tdata->digest_enc.len);
7684 debug_hexdump(stdout, "plaintext expected:",
7685 tdata->plaintext.data,
7686 (tdata->plaintext.len_bits >> 3) -
7687 tdata->digest_enc.len);
7689 if (ut_params->obuf)
7690 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7691 ciphertext_len, buffer);
7693 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7694 ciphertext_len, buffer);
7696 debug_hexdump(stdout, "ciphertext:", ciphertext,
7698 debug_hexdump(stdout, "ciphertext expected:",
7699 tdata->ciphertext.data,
7700 tdata->ciphertext.len_bits >> 3);
7702 if (ut_params->obuf)
7703 digest = rte_pktmbuf_read(ut_params->obuf,
7704 (tdata->digest_enc.offset == 0 ?
7706 tdata->digest_enc.offset),
7707 tdata->digest_enc.len, digest_buffer);
7709 digest = rte_pktmbuf_read(ut_params->ibuf,
7710 (tdata->digest_enc.offset == 0 ?
7712 tdata->digest_enc.offset),
7713 tdata->digest_enc.len, digest_buffer);
7715 debug_hexdump(stdout, "digest:", digest,
7716 tdata->digest_enc.len);
7717 debug_hexdump(stdout, "digest expected:",
7718 tdata->digest_enc.data, tdata->digest_enc.len);
7722 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7724 tdata->digest_enc.data,
7725 tdata->digest_enc.len,
7726 "Generated auth tag not as expected");
7729 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7731 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7733 tdata->plaintext.data,
7734 tdata->plaintext.len_bits >> 3,
7735 "Plaintext data not as expected");
7737 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7739 tdata->ciphertext.data,
7740 tdata->validDataLen.len_bits,
7741 "Ciphertext data not as expected");
7745 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7746 "crypto op processing failed");
7751 /** AUTH AES CMAC + CIPHER AES CTR */
7754 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7756 return test_mixed_auth_cipher(
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(void)
7763 return test_mixed_auth_cipher(
7764 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7768 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7770 return test_mixed_auth_cipher_sgl(
7771 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7775 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7777 return test_mixed_auth_cipher_sgl(
7778 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7782 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7784 return test_mixed_auth_cipher(
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(void)
7791 return test_mixed_auth_cipher(
7792 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7796 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7798 return test_mixed_auth_cipher_sgl(
7799 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7803 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7805 return test_mixed_auth_cipher_sgl(
7806 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7809 /** MIXED AUTH + CIPHER */
7812 test_auth_zuc_cipher_snow_test_case_1(void)
7814 return test_mixed_auth_cipher(
7815 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7819 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7821 return test_mixed_auth_cipher(
7822 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7826 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7828 return test_mixed_auth_cipher(
7829 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7833 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7835 return test_mixed_auth_cipher(
7836 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7840 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7842 return test_mixed_auth_cipher(
7843 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7847 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7849 return test_mixed_auth_cipher(
7850 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7854 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7856 return test_mixed_auth_cipher(
7857 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7861 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7863 return test_mixed_auth_cipher(
7864 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7868 test_auth_snow_cipher_zuc_test_case_1(void)
7870 return test_mixed_auth_cipher(
7871 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7875 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7877 return test_mixed_auth_cipher(
7878 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7882 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7884 return test_mixed_auth_cipher(
7885 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7889 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7891 return test_mixed_auth_cipher(
7892 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7896 test_auth_null_cipher_snow_test_case_1(void)
7898 return test_mixed_auth_cipher(
7899 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7903 test_verify_auth_null_cipher_snow_test_case_1(void)
7905 return test_mixed_auth_cipher(
7906 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7910 test_auth_null_cipher_zuc_test_case_1(void)
7912 return test_mixed_auth_cipher(
7913 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7917 test_verify_auth_null_cipher_zuc_test_case_1(void)
7919 return test_mixed_auth_cipher(
7920 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7924 test_auth_snow_cipher_null_test_case_1(void)
7926 return test_mixed_auth_cipher(
7927 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7931 test_verify_auth_snow_cipher_null_test_case_1(void)
7933 return test_mixed_auth_cipher(
7934 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7938 test_auth_zuc_cipher_null_test_case_1(void)
7940 return test_mixed_auth_cipher(
7941 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7945 test_verify_auth_zuc_cipher_null_test_case_1(void)
7947 return test_mixed_auth_cipher(
7948 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7952 test_auth_null_cipher_aes_ctr_test_case_1(void)
7954 return test_mixed_auth_cipher(
7955 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7959 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7961 return test_mixed_auth_cipher(
7962 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7966 test_auth_aes_cmac_cipher_null_test_case_1(void)
7968 return test_mixed_auth_cipher(
7969 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7973 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7975 return test_mixed_auth_cipher(
7976 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7979 /* ***** AEAD algorithm Tests ***** */
7982 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7983 enum rte_crypto_aead_operation op,
7984 const uint8_t *key, const uint8_t key_len,
7985 const uint16_t aad_len, const uint8_t auth_len,
7988 uint8_t aead_key[key_len];
7991 struct crypto_testsuite_params *ts_params = &testsuite_params;
7992 struct crypto_unittest_params *ut_params = &unittest_params;
7994 memcpy(aead_key, key, key_len);
7996 /* Setup AEAD Parameters */
7997 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7998 ut_params->aead_xform.next = NULL;
7999 ut_params->aead_xform.aead.algo = algo;
8000 ut_params->aead_xform.aead.op = op;
8001 ut_params->aead_xform.aead.key.data = aead_key;
8002 ut_params->aead_xform.aead.key.length = key_len;
8003 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8004 ut_params->aead_xform.aead.iv.length = iv_len;
8005 ut_params->aead_xform.aead.digest_length = auth_len;
8006 ut_params->aead_xform.aead.aad_length = aad_len;
8008 debug_hexdump(stdout, "key:", key, key_len);
8010 /* Create Crypto session*/
8011 ut_params->sess = rte_cryptodev_sym_session_create(
8012 ts_params->session_mpool);
8013 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8015 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8016 &ut_params->aead_xform,
8017 ts_params->session_priv_mpool);
8023 create_aead_xform(struct rte_crypto_op *op,
8024 enum rte_crypto_aead_algorithm algo,
8025 enum rte_crypto_aead_operation aead_op,
8026 uint8_t *key, const uint8_t key_len,
8027 const uint8_t aad_len, const uint8_t auth_len,
8030 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8031 "failed to allocate space for crypto transform");
8033 struct rte_crypto_sym_op *sym_op = op->sym;
8035 /* Setup AEAD Parameters */
8036 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8037 sym_op->xform->next = NULL;
8038 sym_op->xform->aead.algo = algo;
8039 sym_op->xform->aead.op = aead_op;
8040 sym_op->xform->aead.key.data = key;
8041 sym_op->xform->aead.key.length = key_len;
8042 sym_op->xform->aead.iv.offset = IV_OFFSET;
8043 sym_op->xform->aead.iv.length = iv_len;
8044 sym_op->xform->aead.digest_length = auth_len;
8045 sym_op->xform->aead.aad_length = aad_len;
8047 debug_hexdump(stdout, "key:", key, key_len);
8053 create_aead_operation(enum rte_crypto_aead_operation op,
8054 const struct aead_test_data *tdata)
8056 struct crypto_testsuite_params *ts_params = &testsuite_params;
8057 struct crypto_unittest_params *ut_params = &unittest_params;
8059 uint8_t *plaintext, *ciphertext;
8060 unsigned int aad_pad_len, plaintext_pad_len;
8062 /* Generate Crypto op data structure */
8063 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8064 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8065 TEST_ASSERT_NOT_NULL(ut_params->op,
8066 "Failed to allocate symmetric crypto operation struct");
8068 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8070 /* Append aad data */
8071 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8072 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8073 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8075 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8076 "no room to append aad");
8078 sym_op->aead.aad.phys_addr =
8079 rte_pktmbuf_iova(ut_params->ibuf);
8080 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8081 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8082 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8085 /* Append IV at the end of the crypto operation*/
8086 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8087 uint8_t *, IV_OFFSET);
8089 /* Copy IV 1 byte after the IV pointer, according to the API */
8090 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8091 debug_hexdump(stdout, "iv:", iv_ptr,
8094 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8095 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8097 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8098 "no room to append aad");
8100 sym_op->aead.aad.phys_addr =
8101 rte_pktmbuf_iova(ut_params->ibuf);
8102 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8103 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8106 /* Append IV at the end of the crypto operation*/
8107 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8108 uint8_t *, IV_OFFSET);
8110 if (tdata->iv.len == 0) {
8111 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8112 debug_hexdump(stdout, "iv:", iv_ptr,
8115 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8116 debug_hexdump(stdout, "iv:", iv_ptr,
8121 /* Append plaintext/ciphertext */
8122 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8123 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8124 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8126 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8128 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8129 debug_hexdump(stdout, "plaintext:", plaintext,
8130 tdata->plaintext.len);
8132 if (ut_params->obuf) {
8133 ciphertext = (uint8_t *)rte_pktmbuf_append(
8135 plaintext_pad_len + aad_pad_len);
8136 TEST_ASSERT_NOT_NULL(ciphertext,
8137 "no room to append ciphertext");
8139 memset(ciphertext + aad_pad_len, 0,
8140 tdata->ciphertext.len);
8143 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8144 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8146 TEST_ASSERT_NOT_NULL(ciphertext,
8147 "no room to append ciphertext");
8149 memcpy(ciphertext, tdata->ciphertext.data,
8150 tdata->ciphertext.len);
8151 debug_hexdump(stdout, "ciphertext:", ciphertext,
8152 tdata->ciphertext.len);
8154 if (ut_params->obuf) {
8155 plaintext = (uint8_t *)rte_pktmbuf_append(
8157 plaintext_pad_len + aad_pad_len);
8158 TEST_ASSERT_NOT_NULL(plaintext,
8159 "no room to append plaintext");
8161 memset(plaintext + aad_pad_len, 0,
8162 tdata->plaintext.len);
8166 /* Append digest data */
8167 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8168 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8169 ut_params->obuf ? ut_params->obuf :
8171 tdata->auth_tag.len);
8172 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8173 "no room to append digest");
8174 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8175 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8176 ut_params->obuf ? ut_params->obuf :
8181 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8182 ut_params->ibuf, tdata->auth_tag.len);
8183 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8184 "no room to append digest");
8185 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8187 plaintext_pad_len + aad_pad_len);
8189 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8190 tdata->auth_tag.len);
8191 debug_hexdump(stdout, "digest:",
8192 sym_op->aead.digest.data,
8193 tdata->auth_tag.len);
8196 sym_op->aead.data.length = tdata->plaintext.len;
8197 sym_op->aead.data.offset = aad_pad_len;
8203 test_authenticated_encryption(const struct aead_test_data *tdata)
8205 struct crypto_testsuite_params *ts_params = &testsuite_params;
8206 struct crypto_unittest_params *ut_params = &unittest_params;
8209 uint8_t *ciphertext, *auth_tag;
8210 uint16_t plaintext_pad_len;
8212 struct rte_cryptodev_info dev_info;
8214 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8215 uint64_t feat_flags = dev_info.feature_flags;
8217 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8218 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8219 printf("Device doesn't support RAW data-path APIs.\n");
8220 return TEST_SKIPPED;
8223 /* Verify the capabilities */
8224 struct rte_cryptodev_sym_capability_idx cap_idx;
8225 const struct rte_cryptodev_symmetric_capability *capability;
8226 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8227 cap_idx.algo.aead = tdata->algo;
8228 capability = rte_cryptodev_sym_capability_get(
8229 ts_params->valid_devs[0], &cap_idx);
8230 if (capability == NULL)
8231 return TEST_SKIPPED;
8232 if (rte_cryptodev_sym_capability_check_aead(
8233 capability, tdata->key.len, tdata->auth_tag.len,
8234 tdata->aad.len, tdata->iv.len))
8235 return TEST_SKIPPED;
8237 /* Create AEAD session */
8238 retval = create_aead_session(ts_params->valid_devs[0],
8240 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8241 tdata->key.data, tdata->key.len,
8242 tdata->aad.len, tdata->auth_tag.len,
8247 if (tdata->aad.len > MBUF_SIZE) {
8248 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8249 /* Populate full size of add data */
8250 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8251 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8253 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8255 /* clear mbuf payload */
8256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8257 rte_pktmbuf_tailroom(ut_params->ibuf));
8259 /* Create AEAD operation */
8260 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8264 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8266 ut_params->op->sym->m_src = ut_params->ibuf;
8268 /* Process crypto operation */
8269 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8270 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8271 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8272 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8273 ut_params->op, 0, 0, 0, 0);
8275 TEST_ASSERT_NOT_NULL(
8276 process_crypto_request(ts_params->valid_devs[0],
8277 ut_params->op), "failed to process sym crypto op");
8279 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8280 "crypto op processing failed");
8282 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8284 if (ut_params->op->sym->m_dst) {
8285 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8287 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8288 uint8_t *, plaintext_pad_len);
8290 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8292 ut_params->op->sym->cipher.data.offset);
8293 auth_tag = ciphertext + plaintext_pad_len;
8296 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8297 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8300 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8302 tdata->ciphertext.data,
8303 tdata->ciphertext.len,
8304 "Ciphertext data not as expected");
8306 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8308 tdata->auth_tag.data,
8309 tdata->auth_tag.len,
8310 "Generated auth tag not as expected");
8316 #ifdef RTE_LIB_SECURITY
8318 security_proto_supported(enum rte_security_session_action_type action,
8319 enum rte_security_session_protocol proto)
8321 struct crypto_testsuite_params *ts_params = &testsuite_params;
8323 const struct rte_security_capability *capabilities;
8324 const struct rte_security_capability *capability;
8327 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8328 rte_cryptodev_get_sec_ctx(
8329 ts_params->valid_devs[0]);
8332 capabilities = rte_security_capabilities_get(ctx);
8334 if (capabilities == NULL)
8337 while ((capability = &capabilities[i++])->action !=
8338 RTE_SECURITY_ACTION_TYPE_NONE) {
8339 if (capability->action == action &&
8340 capability->protocol == proto)
8347 /* Basic algorithm run function for async inplace mode.
8348 * Creates a session from input parameters and runs one operation
8349 * on input_vec. Checks the output of the crypto operation against
8352 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8353 enum rte_crypto_auth_operation opa,
8354 const uint8_t *input_vec, unsigned int input_vec_len,
8355 const uint8_t *output_vec,
8356 unsigned int output_vec_len,
8357 enum rte_crypto_cipher_algorithm cipher_alg,
8358 const uint8_t *cipher_key, uint32_t cipher_key_len,
8359 enum rte_crypto_auth_algorithm auth_alg,
8360 const uint8_t *auth_key, uint32_t auth_key_len,
8361 uint8_t bearer, enum rte_security_pdcp_domain domain,
8362 uint8_t packet_direction, uint8_t sn_size,
8363 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8365 struct crypto_testsuite_params *ts_params = &testsuite_params;
8366 struct crypto_unittest_params *ut_params = &unittest_params;
8368 int ret = TEST_SUCCESS;
8369 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8370 rte_cryptodev_get_sec_ctx(
8371 ts_params->valid_devs[0]);
8373 /* Verify the capabilities */
8374 struct rte_security_capability_idx sec_cap_idx;
8376 sec_cap_idx.action = ut_params->type;
8377 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8378 sec_cap_idx.pdcp.domain = domain;
8379 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8380 return TEST_SKIPPED;
8382 /* Generate test mbuf data */
8383 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8385 /* clear mbuf payload */
8386 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8387 rte_pktmbuf_tailroom(ut_params->ibuf));
8389 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8391 memcpy(plaintext, input_vec, input_vec_len);
8393 /* Out of place support */
8396 * For out-op-place we need to alloc another mbuf
8398 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8399 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8402 /* Setup Cipher Parameters */
8403 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8404 ut_params->cipher_xform.cipher.algo = cipher_alg;
8405 ut_params->cipher_xform.cipher.op = opc;
8406 ut_params->cipher_xform.cipher.key.data = cipher_key;
8407 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8408 ut_params->cipher_xform.cipher.iv.length =
8409 packet_direction ? 4 : 0;
8410 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8412 /* Setup HMAC Parameters if ICV header is required */
8413 if (auth_alg != 0) {
8414 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8415 ut_params->auth_xform.next = NULL;
8416 ut_params->auth_xform.auth.algo = auth_alg;
8417 ut_params->auth_xform.auth.op = opa;
8418 ut_params->auth_xform.auth.key.data = auth_key;
8419 ut_params->auth_xform.auth.key.length = auth_key_len;
8421 ut_params->cipher_xform.next = &ut_params->auth_xform;
8423 ut_params->cipher_xform.next = NULL;
8426 struct rte_security_session_conf sess_conf = {
8427 .action_type = ut_params->type,
8428 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8432 .pkt_dir = packet_direction,
8434 .hfn = packet_direction ? 0 : hfn,
8436 * hfn can be set as pdcp_test_hfn[i]
8437 * if hfn_ovrd is not set. Here, PDCP
8438 * packet direction is just used to
8439 * run half of the cases with session
8440 * HFN and other half with per packet
8443 .hfn_threshold = hfn_threshold,
8444 .hfn_ovrd = packet_direction ? 1 : 0,
8445 .sdap_enabled = sdap,
8447 .crypto_xform = &ut_params->cipher_xform
8450 /* Create security session */
8451 ut_params->sec_session = rte_security_session_create(ctx,
8452 &sess_conf, ts_params->session_mpool,
8453 ts_params->session_priv_mpool);
8455 if (!ut_params->sec_session) {
8456 printf("TestCase %s()-%d line %d failed %s: ",
8457 __func__, i, __LINE__, "Failed to allocate session");
8462 /* Generate crypto op data structure */
8463 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8464 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8465 if (!ut_params->op) {
8466 printf("TestCase %s()-%d line %d failed %s: ",
8467 __func__, i, __LINE__,
8468 "Failed to allocate symmetric crypto operation struct");
8473 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8474 uint32_t *, IV_OFFSET);
8475 *per_pkt_hfn = packet_direction ? hfn : 0;
8477 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8479 /* set crypto operation source mbuf */
8480 ut_params->op->sym->m_src = ut_params->ibuf;
8482 ut_params->op->sym->m_dst = ut_params->obuf;
8484 /* Process crypto operation */
8485 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8487 printf("TestCase %s()-%d line %d failed %s: ",
8488 __func__, i, __LINE__,
8489 "failed to process sym crypto op");
8494 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8495 printf("TestCase %s()-%d line %d failed %s: ",
8496 __func__, i, __LINE__, "crypto op processing failed");
8502 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8505 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8509 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8510 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8511 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8512 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8518 rte_crypto_op_free(ut_params->op);
8519 ut_params->op = NULL;
8521 if (ut_params->sec_session)
8522 rte_security_session_destroy(ctx, ut_params->sec_session);
8523 ut_params->sec_session = NULL;
8525 rte_pktmbuf_free(ut_params->ibuf);
8526 ut_params->ibuf = NULL;
8528 rte_pktmbuf_free(ut_params->obuf);
8529 ut_params->obuf = NULL;
8536 test_pdcp_proto_SGL(int i, int oop,
8537 enum rte_crypto_cipher_operation opc,
8538 enum rte_crypto_auth_operation opa,
8540 unsigned int input_vec_len,
8541 uint8_t *output_vec,
8542 unsigned int output_vec_len,
8544 uint32_t fragsz_oop)
8546 struct crypto_testsuite_params *ts_params = &testsuite_params;
8547 struct crypto_unittest_params *ut_params = &unittest_params;
8549 struct rte_mbuf *buf, *buf_oop = NULL;
8550 int ret = TEST_SUCCESS;
8554 unsigned int trn_data = 0;
8555 struct rte_cryptodev_info dev_info;
8556 uint64_t feat_flags;
8557 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8558 rte_cryptodev_get_sec_ctx(
8559 ts_params->valid_devs[0]);
8560 struct rte_mbuf *temp_mbuf;
8562 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8563 feat_flags = dev_info.feature_flags;
8565 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8566 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8567 printf("Device does not support RAW data-path APIs.\n");
8570 /* Verify the capabilities */
8571 struct rte_security_capability_idx sec_cap_idx;
8573 sec_cap_idx.action = ut_params->type;
8574 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8575 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8576 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8577 return TEST_SKIPPED;
8579 if (fragsz > input_vec_len)
8580 fragsz = input_vec_len;
8582 uint16_t plaintext_len = fragsz;
8583 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8585 if (fragsz_oop > output_vec_len)
8586 frag_size_oop = output_vec_len;
8589 if (input_vec_len % fragsz != 0) {
8590 if (input_vec_len / fragsz + 1 > 16)
8592 } else if (input_vec_len / fragsz > 16)
8595 /* Out of place support */
8598 * For out-op-place we need to alloc another mbuf
8600 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8601 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8602 buf_oop = ut_params->obuf;
8605 /* Generate test mbuf data */
8606 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8608 /* clear mbuf payload */
8609 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8610 rte_pktmbuf_tailroom(ut_params->ibuf));
8612 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8614 memcpy(plaintext, input_vec, plaintext_len);
8615 trn_data += plaintext_len;
8617 buf = ut_params->ibuf;
8620 * Loop until no more fragments
8623 while (trn_data < input_vec_len) {
8625 to_trn = (input_vec_len - trn_data < fragsz) ?
8626 (input_vec_len - trn_data) : fragsz;
8628 to_trn_tbl[ecx++] = to_trn;
8630 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8633 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8634 rte_pktmbuf_tailroom(buf));
8637 if (oop && !fragsz_oop) {
8639 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8640 buf_oop = buf_oop->next;
8641 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8642 0, rte_pktmbuf_tailroom(buf_oop));
8643 rte_pktmbuf_append(buf_oop, to_trn);
8646 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8649 memcpy(plaintext, input_vec + trn_data, to_trn);
8653 ut_params->ibuf->nb_segs = segs;
8656 if (fragsz_oop && oop) {
8660 trn_data = frag_size_oop;
8661 while (trn_data < output_vec_len) {
8664 (output_vec_len - trn_data <
8666 (output_vec_len - trn_data) :
8669 to_trn_tbl[ecx++] = to_trn;
8672 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8673 buf_oop = buf_oop->next;
8674 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8675 0, rte_pktmbuf_tailroom(buf_oop));
8676 rte_pktmbuf_append(buf_oop, to_trn);
8680 ut_params->obuf->nb_segs = segs;
8683 /* Setup Cipher Parameters */
8684 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8685 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8686 ut_params->cipher_xform.cipher.op = opc;
8687 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8688 ut_params->cipher_xform.cipher.key.length =
8689 pdcp_test_params[i].cipher_key_len;
8690 ut_params->cipher_xform.cipher.iv.length = 0;
8692 /* Setup HMAC Parameters if ICV header is required */
8693 if (pdcp_test_params[i].auth_alg != 0) {
8694 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8695 ut_params->auth_xform.next = NULL;
8696 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8697 ut_params->auth_xform.auth.op = opa;
8698 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8699 ut_params->auth_xform.auth.key.length =
8700 pdcp_test_params[i].auth_key_len;
8702 ut_params->cipher_xform.next = &ut_params->auth_xform;
8704 ut_params->cipher_xform.next = NULL;
8707 struct rte_security_session_conf sess_conf = {
8708 .action_type = ut_params->type,
8709 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8711 .bearer = pdcp_test_bearer[i],
8712 .domain = pdcp_test_params[i].domain,
8713 .pkt_dir = pdcp_test_packet_direction[i],
8714 .sn_size = pdcp_test_data_sn_size[i],
8715 .hfn = pdcp_test_hfn[i],
8716 .hfn_threshold = pdcp_test_hfn_threshold[i],
8719 .crypto_xform = &ut_params->cipher_xform
8722 /* Create security session */
8723 ut_params->sec_session = rte_security_session_create(ctx,
8724 &sess_conf, ts_params->session_mpool,
8725 ts_params->session_priv_mpool);
8727 if (!ut_params->sec_session) {
8728 printf("TestCase %s()-%d line %d failed %s: ",
8729 __func__, i, __LINE__, "Failed to allocate session");
8734 /* Generate crypto op data structure */
8735 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8736 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8737 if (!ut_params->op) {
8738 printf("TestCase %s()-%d line %d failed %s: ",
8739 __func__, i, __LINE__,
8740 "Failed to allocate symmetric crypto operation struct");
8745 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8747 /* set crypto operation source mbuf */
8748 ut_params->op->sym->m_src = ut_params->ibuf;
8750 ut_params->op->sym->m_dst = ut_params->obuf;
8752 /* Process crypto operation */
8753 temp_mbuf = ut_params->op->sym->m_src;
8754 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8755 /* filling lengths */
8757 ut_params->op->sym->cipher.data.length
8758 += temp_mbuf->pkt_len;
8759 ut_params->op->sym->auth.data.length
8760 += temp_mbuf->pkt_len;
8761 temp_mbuf = temp_mbuf->next;
8763 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8764 ut_params->op, 1, 1, 0, 0);
8766 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8769 if (ut_params->op == NULL) {
8770 printf("TestCase %s()-%d line %d failed %s: ",
8771 __func__, i, __LINE__,
8772 "failed to process sym crypto op");
8777 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8778 printf("TestCase %s()-%d line %d failed %s: ",
8779 __func__, i, __LINE__, "crypto op processing failed");
8785 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8788 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8792 fragsz = frag_size_oop;
8793 if (memcmp(ciphertext, output_vec, fragsz)) {
8794 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8795 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8796 rte_hexdump(stdout, "reference", output_vec, fragsz);
8801 buf = ut_params->op->sym->m_src->next;
8803 buf = ut_params->op->sym->m_dst->next;
8805 unsigned int off = fragsz;
8809 ciphertext = rte_pktmbuf_mtod(buf,
8811 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8812 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8813 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8814 rte_hexdump(stdout, "reference", output_vec + off,
8819 off += to_trn_tbl[ecx++];
8823 rte_crypto_op_free(ut_params->op);
8824 ut_params->op = NULL;
8826 if (ut_params->sec_session)
8827 rte_security_session_destroy(ctx, ut_params->sec_session);
8828 ut_params->sec_session = NULL;
8830 rte_pktmbuf_free(ut_params->ibuf);
8831 ut_params->ibuf = NULL;
8833 rte_pktmbuf_free(ut_params->obuf);
8834 ut_params->obuf = NULL;
8841 test_pdcp_proto_cplane_encap(int i)
8843 return test_pdcp_proto(
8844 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8845 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8846 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8847 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8848 pdcp_test_params[i].cipher_key_len,
8849 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8850 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8851 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8852 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8853 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8857 test_pdcp_proto_uplane_encap(int i)
8859 return test_pdcp_proto(
8860 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8861 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8862 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8863 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8864 pdcp_test_params[i].cipher_key_len,
8865 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8866 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8867 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8868 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8869 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8873 test_pdcp_proto_uplane_encap_with_int(int i)
8875 return test_pdcp_proto(
8876 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8877 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8878 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8879 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8880 pdcp_test_params[i].cipher_key_len,
8881 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8882 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8883 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8884 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8885 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8889 test_pdcp_proto_cplane_decap(int i)
8891 return test_pdcp_proto(
8892 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8893 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8894 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8895 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8896 pdcp_test_params[i].cipher_key_len,
8897 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8898 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8899 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8900 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8901 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8905 test_pdcp_proto_uplane_decap(int i)
8907 return test_pdcp_proto(
8908 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8909 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8910 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8911 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8912 pdcp_test_params[i].cipher_key_len,
8913 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8914 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8915 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8916 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8917 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8921 test_pdcp_proto_uplane_decap_with_int(int i)
8923 return test_pdcp_proto(
8924 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8925 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8926 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8927 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8928 pdcp_test_params[i].cipher_key_len,
8929 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8930 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8931 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8932 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8933 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8937 test_PDCP_PROTO_SGL_in_place_32B(void)
8939 /* i can be used for running any PDCP case
8940 * In this case it is uplane 12-bit AES-SNOW DL encap
8942 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8943 return test_pdcp_proto_SGL(i, IN_PLACE,
8944 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8945 RTE_CRYPTO_AUTH_OP_GENERATE,
8946 pdcp_test_data_in[i],
8947 pdcp_test_data_in_len[i],
8948 pdcp_test_data_out[i],
8949 pdcp_test_data_in_len[i]+4,
8953 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8955 /* i can be used for running any PDCP case
8956 * In this case it is uplane 18-bit NULL-NULL DL encap
8958 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8959 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8960 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8961 RTE_CRYPTO_AUTH_OP_GENERATE,
8962 pdcp_test_data_in[i],
8963 pdcp_test_data_in_len[i],
8964 pdcp_test_data_out[i],
8965 pdcp_test_data_in_len[i]+4,
8969 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8971 /* i can be used for running any PDCP case
8972 * In this case it is uplane 18-bit AES DL encap
8974 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8976 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8977 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8978 RTE_CRYPTO_AUTH_OP_GENERATE,
8979 pdcp_test_data_in[i],
8980 pdcp_test_data_in_len[i],
8981 pdcp_test_data_out[i],
8982 pdcp_test_data_in_len[i],
8986 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8988 /* i can be used for running any PDCP case
8989 * In this case it is cplane 12-bit AES-ZUC DL encap
8991 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8992 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8993 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8994 RTE_CRYPTO_AUTH_OP_GENERATE,
8995 pdcp_test_data_in[i],
8996 pdcp_test_data_in_len[i],
8997 pdcp_test_data_out[i],
8998 pdcp_test_data_in_len[i]+4,
9003 test_PDCP_SDAP_PROTO_encap_all(void)
9005 int i = 0, size = 0;
9006 int err, all_err = TEST_SUCCESS;
9007 const struct pdcp_sdap_test *cur_test;
9009 size = RTE_DIM(list_pdcp_sdap_tests);
9011 for (i = 0; i < size; i++) {
9012 cur_test = &list_pdcp_sdap_tests[i];
9013 err = test_pdcp_proto(
9014 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9015 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9016 cur_test->in_len, cur_test->data_out,
9017 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9018 cur_test->param.cipher_alg, cur_test->cipher_key,
9019 cur_test->param.cipher_key_len,
9020 cur_test->param.auth_alg,
9021 cur_test->auth_key, cur_test->param.auth_key_len,
9022 cur_test->bearer, cur_test->param.domain,
9023 cur_test->packet_direction, cur_test->sn_size,
9025 cur_test->hfn_threshold, SDAP_ENABLED);
9027 printf("\t%d) %s: Encapsulation failed\n",
9029 cur_test->param.name);
9032 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9033 cur_test->param.name);
9039 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9041 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9045 test_PDCP_PROTO_short_mac(void)
9047 int i = 0, size = 0;
9048 int err, all_err = TEST_SUCCESS;
9049 const struct pdcp_short_mac_test *cur_test;
9051 size = RTE_DIM(list_pdcp_smac_tests);
9053 for (i = 0; i < size; i++) {
9054 cur_test = &list_pdcp_smac_tests[i];
9055 err = test_pdcp_proto(
9056 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9057 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9058 cur_test->in_len, cur_test->data_out,
9059 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9060 RTE_CRYPTO_CIPHER_NULL, NULL,
9061 0, cur_test->param.auth_alg,
9062 cur_test->auth_key, cur_test->param.auth_key_len,
9063 0, cur_test->param.domain, 0, 0,
9066 printf("\t%d) %s: Short MAC test failed\n",
9068 cur_test->param.name);
9071 printf("\t%d) %s: Short MAC test PASS\n",
9073 cur_test->param.name);
9074 rte_hexdump(stdout, "MAC I",
9075 cur_test->data_out + cur_test->in_len + 2,
9082 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9084 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9089 test_PDCP_SDAP_PROTO_decap_all(void)
9091 int i = 0, size = 0;
9092 int err, all_err = TEST_SUCCESS;
9093 const struct pdcp_sdap_test *cur_test;
9095 size = RTE_DIM(list_pdcp_sdap_tests);
9097 for (i = 0; i < size; i++) {
9098 cur_test = &list_pdcp_sdap_tests[i];
9099 err = test_pdcp_proto(
9100 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9101 RTE_CRYPTO_AUTH_OP_VERIFY,
9103 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9104 cur_test->data_in, cur_test->in_len,
9105 cur_test->param.cipher_alg,
9106 cur_test->cipher_key, cur_test->param.cipher_key_len,
9107 cur_test->param.auth_alg, cur_test->auth_key,
9108 cur_test->param.auth_key_len, cur_test->bearer,
9109 cur_test->param.domain, cur_test->packet_direction,
9110 cur_test->sn_size, cur_test->hfn,
9111 cur_test->hfn_threshold, SDAP_ENABLED);
9113 printf("\t%d) %s: Decapsulation failed\n",
9115 cur_test->param.name);
9118 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9119 cur_test->param.name);
9125 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9127 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9131 test_ipsec_proto_process(const struct ipsec_test_data td[],
9132 struct ipsec_test_data res_d[],
9135 const struct ipsec_test_flags *flags)
9137 uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
9139 uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
9141 struct crypto_testsuite_params *ts_params = &testsuite_params;
9142 struct crypto_unittest_params *ut_params = &unittest_params;
9143 struct rte_security_capability_idx sec_cap_idx;
9144 const struct rte_security_capability *sec_cap;
9145 struct rte_security_ipsec_xform ipsec_xform;
9146 uint8_t dev_id = ts_params->valid_devs[0];
9147 enum rte_security_ipsec_sa_direction dir;
9148 struct ipsec_test_data *res_d_tmp = NULL;
9149 uint32_t src = RTE_IPV4(192, 168, 1, 0);
9150 uint32_t dst = RTE_IPV4(192, 168, 1, 1);
9151 int salt_len, i, ret = TEST_SUCCESS;
9152 struct rte_security_ctx *ctx;
9153 uint8_t *input_text;
9156 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9157 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9159 /* Use first test data to create session */
9161 /* Copy IPsec xform */
9162 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9164 dir = ipsec_xform.direction;
9165 verify = flags->tunnel_hdr_verify;
9167 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9168 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9170 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9174 if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
9175 if (td->ipsec_xform.tunnel.type ==
9176 RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
9177 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
9179 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
9182 if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
9183 ipsec_xform.tunnel.ipv4.df = 0;
9185 if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
9186 ipsec_xform.tunnel.ipv4.df = 1;
9188 if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
9189 ipsec_xform.tunnel.ipv4.dscp = 0;
9191 if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
9192 ipsec_xform.tunnel.ipv4.dscp =
9193 TEST_IPSEC_DSCP_VAL;
9196 if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
9197 ipsec_xform.tunnel.ipv6.dscp = 0;
9199 if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
9200 ipsec_xform.tunnel.ipv6.dscp =
9201 TEST_IPSEC_DSCP_VAL;
9203 memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
9205 memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
9210 ctx = rte_cryptodev_get_sec_ctx(dev_id);
9212 sec_cap_idx.action = ut_params->type;
9213 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9214 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9215 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9216 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9218 if (flags->udp_encap)
9219 ipsec_xform.options.udp_encap = 1;
9221 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9222 if (sec_cap == NULL)
9223 return TEST_SKIPPED;
9225 /* Copy cipher session parameters */
9227 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9228 sizeof(ut_params->aead_xform));
9229 ut_params->aead_xform.aead.key.data = td[0].key.data;
9230 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9232 /* Verify crypto capabilities */
9233 if (test_ipsec_crypto_caps_aead_verify(
9235 &ut_params->aead_xform) != 0) {
9237 RTE_LOG(INFO, USER1,
9238 "Crypto capabilities not supported\n");
9239 return TEST_SKIPPED;
9242 memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
9243 sizeof(ut_params->cipher_xform));
9244 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
9245 sizeof(ut_params->auth_xform));
9246 ut_params->cipher_xform.cipher.key.data = td[0].key.data;
9247 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9248 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
9250 /* Verify crypto capabilities */
9252 if (test_ipsec_crypto_caps_cipher_verify(
9254 &ut_params->cipher_xform) != 0) {
9256 RTE_LOG(INFO, USER1,
9257 "Cipher crypto capabilities not supported\n");
9258 return TEST_SKIPPED;
9261 if (test_ipsec_crypto_caps_auth_verify(
9263 &ut_params->auth_xform) != 0) {
9265 RTE_LOG(INFO, USER1,
9266 "Auth crypto capabilities not supported\n");
9267 return TEST_SKIPPED;
9271 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9272 return TEST_SKIPPED;
9274 struct rte_security_session_conf sess_conf = {
9275 .action_type = ut_params->type,
9276 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9280 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9281 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9282 sess_conf.ipsec = ipsec_xform;
9283 sess_conf.crypto_xform = &ut_params->aead_xform;
9285 sess_conf.ipsec = ipsec_xform;
9286 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
9287 sess_conf.crypto_xform = &ut_params->cipher_xform;
9288 ut_params->cipher_xform.next = &ut_params->auth_xform;
9290 sess_conf.crypto_xform = &ut_params->auth_xform;
9291 ut_params->auth_xform.next = &ut_params->cipher_xform;
9295 /* Create security session */
9296 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9297 ts_params->session_mpool,
9298 ts_params->session_priv_mpool);
9300 if (ut_params->sec_session == NULL)
9301 return TEST_SKIPPED;
9303 for (i = 0; i < nb_td; i++) {
9304 /* Setup source mbuf payload */
9305 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9306 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9307 rte_pktmbuf_tailroom(ut_params->ibuf));
9309 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9310 td[i].input_text.len);
9312 memcpy(input_text, td[i].input_text.data,
9313 td[i].input_text.len);
9315 if (test_ipsec_pkt_update(input_text, flags))
9318 /* Generate crypto op data structure */
9319 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9320 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9321 if (!ut_params->op) {
9322 printf("TestCase %s line %d: %s\n",
9324 "failed to allocate crypto op");
9326 goto crypto_op_free;
9329 /* Attach session to operation */
9330 rte_security_attach_session(ut_params->op,
9331 ut_params->sec_session);
9333 /* Set crypto operation mbufs */
9334 ut_params->op->sym->m_src = ut_params->ibuf;
9335 ut_params->op->sym->m_dst = NULL;
9337 /* Copy IV in crypto operation when IV generation is disabled */
9338 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9339 ipsec_xform.options.iv_gen_disable == 1) {
9340 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9346 len = td[i].xform.aead.aead.iv.length;
9348 len = td[i].xform.chain.cipher.cipher.iv.length;
9350 memcpy(iv, td[i].iv.data, len);
9353 /* Process crypto operation */
9354 process_crypto_request(dev_id, ut_params->op);
9356 ret = test_ipsec_status_check(ut_params->op, flags, dir, i + 1);
9357 if (ret != TEST_SUCCESS)
9358 goto crypto_op_free;
9361 res_d_tmp = &res_d[i];
9363 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9364 res_d_tmp, silent, flags);
9365 if (ret != TEST_SUCCESS)
9366 goto crypto_op_free;
9368 ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
9370 if (ret != TEST_SUCCESS)
9371 goto crypto_op_free;
9373 rte_crypto_op_free(ut_params->op);
9374 ut_params->op = NULL;
9376 rte_pktmbuf_free(ut_params->ibuf);
9377 ut_params->ibuf = NULL;
9381 rte_crypto_op_free(ut_params->op);
9382 ut_params->op = NULL;
9384 rte_pktmbuf_free(ut_params->ibuf);
9385 ut_params->ibuf = NULL;
9387 if (ut_params->sec_session)
9388 rte_security_session_destroy(ctx, ut_params->sec_session);
9389 ut_params->sec_session = NULL;
9395 test_ipsec_proto_known_vec(const void *test_data)
9397 struct ipsec_test_data td_outb;
9398 struct ipsec_test_flags flags;
9400 memset(&flags, 0, sizeof(flags));
9402 memcpy(&td_outb, test_data, sizeof(td_outb));
9405 td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL) {
9406 /* Disable IV gen to be able to test with known vectors */
9407 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9410 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9414 test_ipsec_proto_known_vec_inb(const void *test_data)
9416 const struct ipsec_test_data *td = test_data;
9417 struct ipsec_test_flags flags;
9418 struct ipsec_test_data td_inb;
9420 memset(&flags, 0, sizeof(flags));
9422 if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
9423 test_ipsec_td_in_from_out(td, &td_inb);
9425 memcpy(&td_inb, td, sizeof(td_inb));
9427 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9431 test_ipsec_proto_known_vec_fragmented(const void *test_data)
9433 struct ipsec_test_data td_outb;
9434 struct ipsec_test_flags flags;
9436 memset(&flags, 0, sizeof(flags));
9437 flags.fragment = true;
9439 memcpy(&td_outb, test_data, sizeof(td_outb));
9441 /* Disable IV gen to be able to test with known vectors */
9442 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9444 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9448 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9450 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9451 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9452 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9455 if (flags->iv_gen ||
9456 flags->sa_expiry_pkts_soft ||
9457 flags->sa_expiry_pkts_hard)
9458 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9460 for (i = 0; i < RTE_DIM(alg_list); i++) {
9461 test_ipsec_td_prepare(alg_list[i].param1,
9467 if (!td_outb->aead) {
9468 enum rte_crypto_cipher_algorithm cipher_alg;
9469 enum rte_crypto_auth_algorithm auth_alg;
9471 cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
9472 auth_alg = td_outb->xform.chain.auth.auth.algo;
9474 /* ICV is not applicable for NULL auth */
9475 if (flags->icv_corrupt &&
9476 auth_alg == RTE_CRYPTO_AUTH_NULL)
9479 /* IV is not applicable for NULL cipher */
9480 if (flags->iv_gen &&
9481 cipher_alg == RTE_CRYPTO_CIPHER_NULL)
9485 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9487 if (ret == TEST_SKIPPED)
9490 if (ret == TEST_FAILED)
9493 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9495 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9497 if (ret == TEST_SKIPPED)
9500 if (ret == TEST_FAILED)
9503 if (flags->display_alg)
9504 test_ipsec_display_alg(alg_list[i].param1,
9505 alg_list[i].param2);
9511 return TEST_SUCCESS;
9513 return TEST_SKIPPED;
9517 test_ipsec_proto_display_list(const void *data __rte_unused)
9519 struct ipsec_test_flags flags;
9521 memset(&flags, 0, sizeof(flags));
9523 flags.display_alg = true;
9525 return test_ipsec_proto_all(&flags);
9529 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9531 struct ipsec_test_flags flags;
9533 memset(&flags, 0, sizeof(flags));
9535 flags.iv_gen = true;
9537 return test_ipsec_proto_all(&flags);
9541 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9543 struct ipsec_test_flags flags;
9545 memset(&flags, 0, sizeof(flags));
9547 flags.sa_expiry_pkts_soft = true;
9549 return test_ipsec_proto_all(&flags);
9553 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9555 struct ipsec_test_flags flags;
9557 memset(&flags, 0, sizeof(flags));
9559 flags.sa_expiry_pkts_hard = true;
9561 return test_ipsec_proto_all(&flags);
9565 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9567 struct ipsec_test_flags flags;
9569 memset(&flags, 0, sizeof(flags));
9571 flags.icv_corrupt = true;
9573 return test_ipsec_proto_all(&flags);
9577 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9579 struct ipsec_test_flags flags;
9581 memset(&flags, 0, sizeof(flags));
9583 flags.udp_encap = true;
9585 return test_ipsec_proto_all(&flags);
9589 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9591 struct ipsec_test_flags flags;
9593 memset(&flags, 0, sizeof(flags));
9595 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9597 return test_ipsec_proto_all(&flags);
9601 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9603 struct ipsec_test_flags flags;
9605 memset(&flags, 0, sizeof(flags));
9607 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9609 return test_ipsec_proto_all(&flags);
9613 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9615 struct ipsec_test_flags flags;
9617 memset(&flags, 0, sizeof(flags));
9619 flags.udp_encap = true;
9620 flags.udp_ports_verify = true;
9622 return test_ipsec_proto_all(&flags);
9626 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9628 struct ipsec_test_flags flags;
9630 memset(&flags, 0, sizeof(flags));
9632 flags.ip_csum = true;
9634 return test_ipsec_proto_all(&flags);
9638 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9640 struct ipsec_test_flags flags;
9642 memset(&flags, 0, sizeof(flags));
9644 flags.l4_csum = true;
9646 return test_ipsec_proto_all(&flags);
9650 test_ipsec_proto_tunnel_v4_in_v4(const void *data __rte_unused)
9652 struct ipsec_test_flags flags;
9654 memset(&flags, 0, sizeof(flags));
9657 flags.tunnel_ipv6 = false;
9659 return test_ipsec_proto_all(&flags);
9663 test_ipsec_proto_tunnel_v6_in_v6(const void *data __rte_unused)
9665 struct ipsec_test_flags flags;
9667 memset(&flags, 0, sizeof(flags));
9670 flags.tunnel_ipv6 = true;
9672 return test_ipsec_proto_all(&flags);
9676 test_ipsec_proto_tunnel_v4_in_v6(const void *data __rte_unused)
9678 struct ipsec_test_flags flags;
9680 memset(&flags, 0, sizeof(flags));
9683 flags.tunnel_ipv6 = true;
9685 return test_ipsec_proto_all(&flags);
9689 test_ipsec_proto_tunnel_v6_in_v4(const void *data __rte_unused)
9691 struct ipsec_test_flags flags;
9693 memset(&flags, 0, sizeof(flags));
9696 flags.tunnel_ipv6 = false;
9698 return test_ipsec_proto_all(&flags);
9702 test_ipsec_proto_transport_v4(const void *data __rte_unused)
9704 struct ipsec_test_flags flags;
9706 memset(&flags, 0, sizeof(flags));
9709 flags.transport = true;
9711 return test_ipsec_proto_all(&flags);
9715 test_ipsec_proto_stats(const void *data __rte_unused)
9717 struct ipsec_test_flags flags;
9719 memset(&flags, 0, sizeof(flags));
9721 flags.stats_success = true;
9723 return test_ipsec_proto_all(&flags);
9727 test_ipsec_proto_pkt_fragment(const void *data __rte_unused)
9729 struct ipsec_test_flags flags;
9731 memset(&flags, 0, sizeof(flags));
9733 flags.fragment = true;
9735 return test_ipsec_proto_all(&flags);
9740 test_ipsec_proto_copy_df_inner_0(const void *data __rte_unused)
9742 struct ipsec_test_flags flags;
9744 memset(&flags, 0, sizeof(flags));
9746 flags.df = TEST_IPSEC_COPY_DF_INNER_0;
9748 return test_ipsec_proto_all(&flags);
9752 test_ipsec_proto_copy_df_inner_1(const void *data __rte_unused)
9754 struct ipsec_test_flags flags;
9756 memset(&flags, 0, sizeof(flags));
9758 flags.df = TEST_IPSEC_COPY_DF_INNER_1;
9760 return test_ipsec_proto_all(&flags);
9764 test_ipsec_proto_set_df_0_inner_1(const void *data __rte_unused)
9766 struct ipsec_test_flags flags;
9768 memset(&flags, 0, sizeof(flags));
9770 flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
9772 return test_ipsec_proto_all(&flags);
9776 test_ipsec_proto_set_df_1_inner_0(const void *data __rte_unused)
9778 struct ipsec_test_flags flags;
9780 memset(&flags, 0, sizeof(flags));
9782 flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
9784 return test_ipsec_proto_all(&flags);
9788 test_ipsec_proto_ipv4_copy_dscp_inner_0(const void *data __rte_unused)
9790 struct ipsec_test_flags flags;
9792 memset(&flags, 0, sizeof(flags));
9794 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
9796 return test_ipsec_proto_all(&flags);
9800 test_ipsec_proto_ipv4_copy_dscp_inner_1(const void *data __rte_unused)
9802 struct ipsec_test_flags flags;
9804 memset(&flags, 0, sizeof(flags));
9806 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
9808 return test_ipsec_proto_all(&flags);
9812 test_ipsec_proto_ipv4_set_dscp_0_inner_1(const void *data __rte_unused)
9814 struct ipsec_test_flags flags;
9816 if (gbl_driver_id == rte_cryptodev_driver_id_get(
9817 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
9818 return TEST_SKIPPED;
9820 memset(&flags, 0, sizeof(flags));
9822 flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
9824 return test_ipsec_proto_all(&flags);
9828 test_ipsec_proto_ipv4_set_dscp_1_inner_0(const void *data __rte_unused)
9830 struct ipsec_test_flags flags;
9832 if (gbl_driver_id == rte_cryptodev_driver_id_get(
9833 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
9834 return TEST_SKIPPED;
9836 memset(&flags, 0, sizeof(flags));
9838 flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
9840 return test_ipsec_proto_all(&flags);
9844 test_ipsec_proto_ipv6_copy_dscp_inner_0(const void *data __rte_unused)
9846 struct ipsec_test_flags flags;
9848 memset(&flags, 0, sizeof(flags));
9851 flags.tunnel_ipv6 = true;
9852 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
9854 return test_ipsec_proto_all(&flags);
9858 test_ipsec_proto_ipv6_copy_dscp_inner_1(const void *data __rte_unused)
9860 struct ipsec_test_flags flags;
9862 memset(&flags, 0, sizeof(flags));
9865 flags.tunnel_ipv6 = true;
9866 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
9868 return test_ipsec_proto_all(&flags);
9872 test_ipsec_proto_ipv6_set_dscp_0_inner_1(const void *data __rte_unused)
9874 struct ipsec_test_flags flags;
9876 if (gbl_driver_id == rte_cryptodev_driver_id_get(
9877 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
9878 return TEST_SKIPPED;
9880 memset(&flags, 0, sizeof(flags));
9883 flags.tunnel_ipv6 = true;
9884 flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
9886 return test_ipsec_proto_all(&flags);
9890 test_ipsec_proto_ipv6_set_dscp_1_inner_0(const void *data __rte_unused)
9892 struct ipsec_test_flags flags;
9894 if (gbl_driver_id == rte_cryptodev_driver_id_get(
9895 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
9896 return TEST_SKIPPED;
9898 memset(&flags, 0, sizeof(flags));
9901 flags.tunnel_ipv6 = true;
9902 flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
9904 return test_ipsec_proto_all(&flags);
9908 test_PDCP_PROTO_all(void)
9910 struct crypto_testsuite_params *ts_params = &testsuite_params;
9911 struct crypto_unittest_params *ut_params = &unittest_params;
9912 struct rte_cryptodev_info dev_info;
9915 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9916 uint64_t feat_flags = dev_info.feature_flags;
9918 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9919 return TEST_SKIPPED;
9921 /* Set action type */
9922 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9923 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9926 if (security_proto_supported(ut_params->type,
9927 RTE_SECURITY_PROTOCOL_PDCP) < 0)
9928 return TEST_SKIPPED;
9930 status = test_PDCP_PROTO_cplane_encap_all();
9931 status += test_PDCP_PROTO_cplane_decap_all();
9932 status += test_PDCP_PROTO_uplane_encap_all();
9933 status += test_PDCP_PROTO_uplane_decap_all();
9934 status += test_PDCP_PROTO_SGL_in_place_32B();
9935 status += test_PDCP_PROTO_SGL_oop_32B_128B();
9936 status += test_PDCP_PROTO_SGL_oop_32B_40B();
9937 status += test_PDCP_PROTO_SGL_oop_128B_32B();
9938 status += test_PDCP_SDAP_PROTO_encap_all();
9939 status += test_PDCP_SDAP_PROTO_decap_all();
9940 status += test_PDCP_PROTO_short_mac();
9945 return TEST_SUCCESS;
9949 test_docsis_proto_uplink(const void *data)
9951 const struct docsis_test_data *d_td = data;
9952 struct crypto_testsuite_params *ts_params = &testsuite_params;
9953 struct crypto_unittest_params *ut_params = &unittest_params;
9954 uint8_t *plaintext = NULL;
9955 uint8_t *ciphertext = NULL;
9957 int32_t cipher_len, crc_len;
9958 uint32_t crc_data_len;
9959 int ret = TEST_SUCCESS;
9961 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9962 rte_cryptodev_get_sec_ctx(
9963 ts_params->valid_devs[0]);
9965 /* Verify the capabilities */
9966 struct rte_security_capability_idx sec_cap_idx;
9967 const struct rte_security_capability *sec_cap;
9968 const struct rte_cryptodev_capabilities *crypto_cap;
9969 const struct rte_cryptodev_symmetric_capability *sym_cap;
9972 /* Set action type */
9973 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9974 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9977 if (security_proto_supported(ut_params->type,
9978 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9979 return TEST_SKIPPED;
9981 sec_cap_idx.action = ut_params->type;
9982 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9983 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9985 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9986 if (sec_cap == NULL)
9987 return TEST_SKIPPED;
9989 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9990 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9991 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9992 crypto_cap->sym.xform_type ==
9993 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9994 crypto_cap->sym.cipher.algo ==
9995 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9996 sym_cap = &crypto_cap->sym;
9997 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10004 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10005 return TEST_SKIPPED;
10007 /* Setup source mbuf payload */
10008 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10009 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10010 rte_pktmbuf_tailroom(ut_params->ibuf));
10012 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10013 d_td->ciphertext.len);
10015 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
10017 /* Setup cipher session parameters */
10018 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10019 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10020 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10021 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10022 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10023 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10024 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10025 ut_params->cipher_xform.next = NULL;
10027 /* Setup DOCSIS session parameters */
10028 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
10030 struct rte_security_session_conf sess_conf = {
10031 .action_type = ut_params->type,
10032 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10033 .docsis = ut_params->docsis_xform,
10034 .crypto_xform = &ut_params->cipher_xform,
10037 /* Create security session */
10038 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10039 ts_params->session_mpool,
10040 ts_params->session_priv_mpool);
10042 if (!ut_params->sec_session) {
10043 printf("Test function %s line %u: failed to allocate session\n",
10044 __func__, __LINE__);
10049 /* Generate crypto op data structure */
10050 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10051 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10052 if (!ut_params->op) {
10053 printf("Test function %s line %u: failed to allocate symmetric "
10054 "crypto operation\n", __func__, __LINE__);
10059 /* Setup CRC operation parameters */
10060 crc_len = d_td->ciphertext.no_crc == false ?
10061 (d_td->ciphertext.len -
10062 d_td->ciphertext.crc_offset -
10063 RTE_ETHER_CRC_LEN) :
10065 crc_len = crc_len > 0 ? crc_len : 0;
10066 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
10067 ut_params->op->sym->auth.data.length = crc_len;
10068 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
10070 /* Setup cipher operation parameters */
10071 cipher_len = d_td->ciphertext.no_cipher == false ?
10072 (d_td->ciphertext.len -
10073 d_td->ciphertext.cipher_offset) :
10075 cipher_len = cipher_len > 0 ? cipher_len : 0;
10076 ut_params->op->sym->cipher.data.length = cipher_len;
10077 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
10079 /* Setup cipher IV */
10080 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10081 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10083 /* Attach session to operation */
10084 rte_security_attach_session(ut_params->op, ut_params->sec_session);
10086 /* Set crypto operation mbufs */
10087 ut_params->op->sym->m_src = ut_params->ibuf;
10088 ut_params->op->sym->m_dst = NULL;
10090 /* Process crypto operation */
10091 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10093 printf("Test function %s line %u: failed to process security "
10094 "crypto op\n", __func__, __LINE__);
10099 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10100 printf("Test function %s line %u: failed to process crypto op\n",
10101 __func__, __LINE__);
10106 /* Validate plaintext */
10107 plaintext = ciphertext;
10109 if (memcmp(plaintext, d_td->plaintext.data,
10110 d_td->plaintext.len - crc_data_len)) {
10111 printf("Test function %s line %u: plaintext not as expected\n",
10112 __func__, __LINE__);
10113 rte_hexdump(stdout, "expected", d_td->plaintext.data,
10114 d_td->plaintext.len);
10115 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
10121 rte_crypto_op_free(ut_params->op);
10122 ut_params->op = NULL;
10124 if (ut_params->sec_session)
10125 rte_security_session_destroy(ctx, ut_params->sec_session);
10126 ut_params->sec_session = NULL;
10128 rte_pktmbuf_free(ut_params->ibuf);
10129 ut_params->ibuf = NULL;
10135 test_docsis_proto_downlink(const void *data)
10137 const struct docsis_test_data *d_td = data;
10138 struct crypto_testsuite_params *ts_params = &testsuite_params;
10139 struct crypto_unittest_params *ut_params = &unittest_params;
10140 uint8_t *plaintext = NULL;
10141 uint8_t *ciphertext = NULL;
10143 int32_t cipher_len, crc_len;
10144 int ret = TEST_SUCCESS;
10146 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
10147 rte_cryptodev_get_sec_ctx(
10148 ts_params->valid_devs[0]);
10150 /* Verify the capabilities */
10151 struct rte_security_capability_idx sec_cap_idx;
10152 const struct rte_security_capability *sec_cap;
10153 const struct rte_cryptodev_capabilities *crypto_cap;
10154 const struct rte_cryptodev_symmetric_capability *sym_cap;
10157 /* Set action type */
10158 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10159 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10162 if (security_proto_supported(ut_params->type,
10163 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
10164 return TEST_SKIPPED;
10166 sec_cap_idx.action = ut_params->type;
10167 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
10168 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10170 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10171 if (sec_cap == NULL)
10172 return TEST_SKIPPED;
10174 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
10175 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
10176 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
10177 crypto_cap->sym.xform_type ==
10178 RTE_CRYPTO_SYM_XFORM_CIPHER &&
10179 crypto_cap->sym.cipher.algo ==
10180 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
10181 sym_cap = &crypto_cap->sym;
10182 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10184 d_td->iv.len) == 0)
10189 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10190 return TEST_SKIPPED;
10192 /* Setup source mbuf payload */
10193 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10195 rte_pktmbuf_tailroom(ut_params->ibuf));
10197 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10198 d_td->plaintext.len);
10200 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
10202 /* Setup cipher session parameters */
10203 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10204 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10205 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10206 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10207 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10208 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10209 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10210 ut_params->cipher_xform.next = NULL;
10212 /* Setup DOCSIS session parameters */
10213 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10215 struct rte_security_session_conf sess_conf = {
10216 .action_type = ut_params->type,
10217 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10218 .docsis = ut_params->docsis_xform,
10219 .crypto_xform = &ut_params->cipher_xform,
10222 /* Create security session */
10223 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10224 ts_params->session_mpool,
10225 ts_params->session_priv_mpool);
10227 if (!ut_params->sec_session) {
10228 printf("Test function %s line %u: failed to allocate session\n",
10229 __func__, __LINE__);
10234 /* Generate crypto op data structure */
10235 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10236 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10237 if (!ut_params->op) {
10238 printf("Test function %s line %u: failed to allocate symmetric "
10239 "crypto operation\n", __func__, __LINE__);
10244 /* Setup CRC operation parameters */
10245 crc_len = d_td->plaintext.no_crc == false ?
10246 (d_td->plaintext.len -
10247 d_td->plaintext.crc_offset -
10248 RTE_ETHER_CRC_LEN) :
10250 crc_len = crc_len > 0 ? crc_len : 0;
10251 ut_params->op->sym->auth.data.length = crc_len;
10252 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
10254 /* Setup cipher operation parameters */
10255 cipher_len = d_td->plaintext.no_cipher == false ?
10256 (d_td->plaintext.len -
10257 d_td->plaintext.cipher_offset) :
10259 cipher_len = cipher_len > 0 ? cipher_len : 0;
10260 ut_params->op->sym->cipher.data.length = cipher_len;
10261 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
10263 /* Setup cipher IV */
10264 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10265 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10267 /* Attach session to operation */
10268 rte_security_attach_session(ut_params->op, ut_params->sec_session);
10270 /* Set crypto operation mbufs */
10271 ut_params->op->sym->m_src = ut_params->ibuf;
10272 ut_params->op->sym->m_dst = NULL;
10274 /* Process crypto operation */
10275 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10277 printf("Test function %s line %u: failed to process crypto op\n",
10278 __func__, __LINE__);
10283 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10284 printf("Test function %s line %u: crypto op processing failed\n",
10285 __func__, __LINE__);
10290 /* Validate ciphertext */
10291 ciphertext = plaintext;
10293 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
10294 printf("Test function %s line %u: plaintext not as expected\n",
10295 __func__, __LINE__);
10296 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
10297 d_td->ciphertext.len);
10298 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
10304 rte_crypto_op_free(ut_params->op);
10305 ut_params->op = NULL;
10307 if (ut_params->sec_session)
10308 rte_security_session_destroy(ctx, ut_params->sec_session);
10309 ut_params->sec_session = NULL;
10311 rte_pktmbuf_free(ut_params->ibuf);
10312 ut_params->ibuf = NULL;
10319 test_AES_GCM_authenticated_encryption_test_case_1(void)
10321 return test_authenticated_encryption(&gcm_test_case_1);
10325 test_AES_GCM_authenticated_encryption_test_case_2(void)
10327 return test_authenticated_encryption(&gcm_test_case_2);
10331 test_AES_GCM_authenticated_encryption_test_case_3(void)
10333 return test_authenticated_encryption(&gcm_test_case_3);
10337 test_AES_GCM_authenticated_encryption_test_case_4(void)
10339 return test_authenticated_encryption(&gcm_test_case_4);
10343 test_AES_GCM_authenticated_encryption_test_case_5(void)
10345 return test_authenticated_encryption(&gcm_test_case_5);
10349 test_AES_GCM_authenticated_encryption_test_case_6(void)
10351 return test_authenticated_encryption(&gcm_test_case_6);
10355 test_AES_GCM_authenticated_encryption_test_case_7(void)
10357 return test_authenticated_encryption(&gcm_test_case_7);
10361 test_AES_GCM_authenticated_encryption_test_case_8(void)
10363 return test_authenticated_encryption(&gcm_test_case_8);
10367 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
10369 return test_authenticated_encryption(&gcm_J0_test_case_1);
10373 test_AES_GCM_auth_encryption_test_case_192_1(void)
10375 return test_authenticated_encryption(&gcm_test_case_192_1);
10379 test_AES_GCM_auth_encryption_test_case_192_2(void)
10381 return test_authenticated_encryption(&gcm_test_case_192_2);
10385 test_AES_GCM_auth_encryption_test_case_192_3(void)
10387 return test_authenticated_encryption(&gcm_test_case_192_3);
10391 test_AES_GCM_auth_encryption_test_case_192_4(void)
10393 return test_authenticated_encryption(&gcm_test_case_192_4);
10397 test_AES_GCM_auth_encryption_test_case_192_5(void)
10399 return test_authenticated_encryption(&gcm_test_case_192_5);
10403 test_AES_GCM_auth_encryption_test_case_192_6(void)
10405 return test_authenticated_encryption(&gcm_test_case_192_6);
10409 test_AES_GCM_auth_encryption_test_case_192_7(void)
10411 return test_authenticated_encryption(&gcm_test_case_192_7);
10415 test_AES_GCM_auth_encryption_test_case_256_1(void)
10417 return test_authenticated_encryption(&gcm_test_case_256_1);
10421 test_AES_GCM_auth_encryption_test_case_256_2(void)
10423 return test_authenticated_encryption(&gcm_test_case_256_2);
10427 test_AES_GCM_auth_encryption_test_case_256_3(void)
10429 return test_authenticated_encryption(&gcm_test_case_256_3);
10433 test_AES_GCM_auth_encryption_test_case_256_4(void)
10435 return test_authenticated_encryption(&gcm_test_case_256_4);
10439 test_AES_GCM_auth_encryption_test_case_256_5(void)
10441 return test_authenticated_encryption(&gcm_test_case_256_5);
10445 test_AES_GCM_auth_encryption_test_case_256_6(void)
10447 return test_authenticated_encryption(&gcm_test_case_256_6);
10451 test_AES_GCM_auth_encryption_test_case_256_7(void)
10453 return test_authenticated_encryption(&gcm_test_case_256_7);
10457 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10459 return test_authenticated_encryption(&gcm_test_case_aad_1);
10463 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10465 return test_authenticated_encryption(&gcm_test_case_aad_2);
10469 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10471 struct aead_test_data tdata;
10474 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10475 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10476 tdata.iv.data[0] += 1;
10477 res = test_authenticated_encryption(&tdata);
10478 if (res == TEST_SKIPPED)
10480 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10481 return TEST_SUCCESS;
10485 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10487 struct aead_test_data tdata;
10490 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10491 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10492 tdata.plaintext.data[0] += 1;
10493 res = test_authenticated_encryption(&tdata);
10494 if (res == TEST_SKIPPED)
10496 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10497 return TEST_SUCCESS;
10501 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10503 struct aead_test_data tdata;
10506 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10507 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10508 tdata.ciphertext.data[0] += 1;
10509 res = test_authenticated_encryption(&tdata);
10510 if (res == TEST_SKIPPED)
10512 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10513 return TEST_SUCCESS;
10517 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10519 struct aead_test_data tdata;
10522 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10523 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10524 tdata.aad.len += 1;
10525 res = test_authenticated_encryption(&tdata);
10526 if (res == TEST_SKIPPED)
10528 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10529 return TEST_SUCCESS;
10533 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10535 struct aead_test_data tdata;
10536 uint8_t aad[gcm_test_case_7.aad.len];
10539 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10540 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10541 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10543 tdata.aad.data = aad;
10544 res = test_authenticated_encryption(&tdata);
10545 if (res == TEST_SKIPPED)
10547 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10548 return TEST_SUCCESS;
10552 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10554 struct aead_test_data tdata;
10557 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10558 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10559 tdata.auth_tag.data[0] += 1;
10560 res = test_authenticated_encryption(&tdata);
10561 if (res == TEST_SKIPPED)
10563 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10564 return TEST_SUCCESS;
10568 test_authenticated_decryption(const struct aead_test_data *tdata)
10570 struct crypto_testsuite_params *ts_params = &testsuite_params;
10571 struct crypto_unittest_params *ut_params = &unittest_params;
10574 uint8_t *plaintext;
10576 struct rte_cryptodev_info dev_info;
10578 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10579 uint64_t feat_flags = dev_info.feature_flags;
10581 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10582 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10583 printf("Device doesn't support RAW data-path APIs.\n");
10584 return TEST_SKIPPED;
10587 /* Verify the capabilities */
10588 struct rte_cryptodev_sym_capability_idx cap_idx;
10589 const struct rte_cryptodev_symmetric_capability *capability;
10590 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10591 cap_idx.algo.aead = tdata->algo;
10592 capability = rte_cryptodev_sym_capability_get(
10593 ts_params->valid_devs[0], &cap_idx);
10594 if (capability == NULL)
10595 return TEST_SKIPPED;
10596 if (rte_cryptodev_sym_capability_check_aead(
10597 capability, tdata->key.len, tdata->auth_tag.len,
10598 tdata->aad.len, tdata->iv.len))
10599 return TEST_SKIPPED;
10601 /* Create AEAD session */
10602 retval = create_aead_session(ts_params->valid_devs[0],
10604 RTE_CRYPTO_AEAD_OP_DECRYPT,
10605 tdata->key.data, tdata->key.len,
10606 tdata->aad.len, tdata->auth_tag.len,
10611 /* alloc mbuf and set payload */
10612 if (tdata->aad.len > MBUF_SIZE) {
10613 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10614 /* Populate full size of add data */
10615 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10616 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10618 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10620 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10621 rte_pktmbuf_tailroom(ut_params->ibuf));
10623 /* Create AEAD operation */
10624 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10628 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10630 ut_params->op->sym->m_src = ut_params->ibuf;
10632 /* Process crypto operation */
10633 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10634 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10635 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10636 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10637 ut_params->op, 0, 0, 0, 0);
10639 TEST_ASSERT_NOT_NULL(
10640 process_crypto_request(ts_params->valid_devs[0],
10641 ut_params->op), "failed to process sym crypto op");
10643 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10644 "crypto op processing failed");
10646 if (ut_params->op->sym->m_dst)
10647 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10650 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10652 ut_params->op->sym->cipher.data.offset);
10654 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10656 /* Validate obuf */
10657 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10659 tdata->plaintext.data,
10660 tdata->plaintext.len,
10661 "Plaintext data not as expected");
10663 TEST_ASSERT_EQUAL(ut_params->op->status,
10664 RTE_CRYPTO_OP_STATUS_SUCCESS,
10665 "Authentication failed");
10671 test_AES_GCM_authenticated_decryption_test_case_1(void)
10673 return test_authenticated_decryption(&gcm_test_case_1);
10677 test_AES_GCM_authenticated_decryption_test_case_2(void)
10679 return test_authenticated_decryption(&gcm_test_case_2);
10683 test_AES_GCM_authenticated_decryption_test_case_3(void)
10685 return test_authenticated_decryption(&gcm_test_case_3);
10689 test_AES_GCM_authenticated_decryption_test_case_4(void)
10691 return test_authenticated_decryption(&gcm_test_case_4);
10695 test_AES_GCM_authenticated_decryption_test_case_5(void)
10697 return test_authenticated_decryption(&gcm_test_case_5);
10701 test_AES_GCM_authenticated_decryption_test_case_6(void)
10703 return test_authenticated_decryption(&gcm_test_case_6);
10707 test_AES_GCM_authenticated_decryption_test_case_7(void)
10709 return test_authenticated_decryption(&gcm_test_case_7);
10713 test_AES_GCM_authenticated_decryption_test_case_8(void)
10715 return test_authenticated_decryption(&gcm_test_case_8);
10719 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10721 return test_authenticated_decryption(&gcm_J0_test_case_1);
10725 test_AES_GCM_auth_decryption_test_case_192_1(void)
10727 return test_authenticated_decryption(&gcm_test_case_192_1);
10731 test_AES_GCM_auth_decryption_test_case_192_2(void)
10733 return test_authenticated_decryption(&gcm_test_case_192_2);
10737 test_AES_GCM_auth_decryption_test_case_192_3(void)
10739 return test_authenticated_decryption(&gcm_test_case_192_3);
10743 test_AES_GCM_auth_decryption_test_case_192_4(void)
10745 return test_authenticated_decryption(&gcm_test_case_192_4);
10749 test_AES_GCM_auth_decryption_test_case_192_5(void)
10751 return test_authenticated_decryption(&gcm_test_case_192_5);
10755 test_AES_GCM_auth_decryption_test_case_192_6(void)
10757 return test_authenticated_decryption(&gcm_test_case_192_6);
10761 test_AES_GCM_auth_decryption_test_case_192_7(void)
10763 return test_authenticated_decryption(&gcm_test_case_192_7);
10767 test_AES_GCM_auth_decryption_test_case_256_1(void)
10769 return test_authenticated_decryption(&gcm_test_case_256_1);
10773 test_AES_GCM_auth_decryption_test_case_256_2(void)
10775 return test_authenticated_decryption(&gcm_test_case_256_2);
10779 test_AES_GCM_auth_decryption_test_case_256_3(void)
10781 return test_authenticated_decryption(&gcm_test_case_256_3);
10785 test_AES_GCM_auth_decryption_test_case_256_4(void)
10787 return test_authenticated_decryption(&gcm_test_case_256_4);
10791 test_AES_GCM_auth_decryption_test_case_256_5(void)
10793 return test_authenticated_decryption(&gcm_test_case_256_5);
10797 test_AES_GCM_auth_decryption_test_case_256_6(void)
10799 return test_authenticated_decryption(&gcm_test_case_256_6);
10803 test_AES_GCM_auth_decryption_test_case_256_7(void)
10805 return test_authenticated_decryption(&gcm_test_case_256_7);
10809 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10811 return test_authenticated_decryption(&gcm_test_case_aad_1);
10815 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10817 return test_authenticated_decryption(&gcm_test_case_aad_2);
10821 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10823 struct aead_test_data tdata;
10826 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10827 tdata.iv.data[0] += 1;
10828 res = test_authenticated_decryption(&tdata);
10829 if (res == TEST_SKIPPED)
10831 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10832 return TEST_SUCCESS;
10836 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10838 struct aead_test_data tdata;
10841 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10842 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10843 tdata.plaintext.data[0] += 1;
10844 res = test_authenticated_decryption(&tdata);
10845 if (res == TEST_SKIPPED)
10847 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10848 return TEST_SUCCESS;
10852 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10854 struct aead_test_data tdata;
10857 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10858 tdata.ciphertext.data[0] += 1;
10859 res = test_authenticated_decryption(&tdata);
10860 if (res == TEST_SKIPPED)
10862 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10863 return TEST_SUCCESS;
10867 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10869 struct aead_test_data tdata;
10872 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10873 tdata.aad.len += 1;
10874 res = test_authenticated_decryption(&tdata);
10875 if (res == TEST_SKIPPED)
10877 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10878 return TEST_SUCCESS;
10882 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10884 struct aead_test_data tdata;
10885 uint8_t aad[gcm_test_case_7.aad.len];
10888 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10889 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10891 tdata.aad.data = aad;
10892 res = test_authenticated_decryption(&tdata);
10893 if (res == TEST_SKIPPED)
10895 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10896 return TEST_SUCCESS;
10900 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10902 struct aead_test_data tdata;
10905 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10906 tdata.auth_tag.data[0] += 1;
10907 res = test_authenticated_decryption(&tdata);
10908 if (res == TEST_SKIPPED)
10910 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10911 return TEST_SUCCESS;
10915 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10917 struct crypto_testsuite_params *ts_params = &testsuite_params;
10918 struct crypto_unittest_params *ut_params = &unittest_params;
10921 uint8_t *ciphertext, *auth_tag;
10922 uint16_t plaintext_pad_len;
10923 struct rte_cryptodev_info dev_info;
10925 /* Verify the capabilities */
10926 struct rte_cryptodev_sym_capability_idx cap_idx;
10927 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10928 cap_idx.algo.aead = tdata->algo;
10929 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10931 return TEST_SKIPPED;
10933 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10934 uint64_t feat_flags = dev_info.feature_flags;
10936 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10937 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
10938 return TEST_SKIPPED;
10940 /* not supported with CPU crypto */
10941 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10942 return TEST_SKIPPED;
10944 /* Create AEAD session */
10945 retval = create_aead_session(ts_params->valid_devs[0],
10947 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10948 tdata->key.data, tdata->key.len,
10949 tdata->aad.len, tdata->auth_tag.len,
10954 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10955 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10957 /* clear mbuf payload */
10958 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10959 rte_pktmbuf_tailroom(ut_params->ibuf));
10960 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10961 rte_pktmbuf_tailroom(ut_params->obuf));
10963 /* Create AEAD operation */
10964 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10968 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10970 ut_params->op->sym->m_src = ut_params->ibuf;
10971 ut_params->op->sym->m_dst = ut_params->obuf;
10973 /* Process crypto operation */
10974 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10975 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10976 ut_params->op, 0, 0, 0, 0);
10978 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10979 ut_params->op), "failed to process sym crypto op");
10981 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10982 "crypto op processing failed");
10984 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10986 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10987 ut_params->op->sym->cipher.data.offset);
10988 auth_tag = ciphertext + plaintext_pad_len;
10990 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10991 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10993 /* Validate obuf */
10994 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10996 tdata->ciphertext.data,
10997 tdata->ciphertext.len,
10998 "Ciphertext data not as expected");
11000 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11002 tdata->auth_tag.data,
11003 tdata->auth_tag.len,
11004 "Generated auth tag not as expected");
11011 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
11013 return test_authenticated_encryption_oop(&gcm_test_case_5);
11017 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
11019 struct crypto_testsuite_params *ts_params = &testsuite_params;
11020 struct crypto_unittest_params *ut_params = &unittest_params;
11023 uint8_t *plaintext;
11024 struct rte_cryptodev_info dev_info;
11026 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11027 uint64_t feat_flags = dev_info.feature_flags;
11029 /* Verify the capabilities */
11030 struct rte_cryptodev_sym_capability_idx cap_idx;
11031 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11032 cap_idx.algo.aead = tdata->algo;
11033 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11035 return TEST_SKIPPED;
11037 /* not supported with CPU crypto and raw data-path APIs*/
11038 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
11039 global_api_test_type == CRYPTODEV_RAW_API_TEST)
11040 return TEST_SKIPPED;
11042 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11043 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11044 printf("Device does not support RAW data-path APIs.\n");
11045 return TEST_SKIPPED;
11048 /* Create AEAD session */
11049 retval = create_aead_session(ts_params->valid_devs[0],
11051 RTE_CRYPTO_AEAD_OP_DECRYPT,
11052 tdata->key.data, tdata->key.len,
11053 tdata->aad.len, tdata->auth_tag.len,
11058 /* alloc mbuf and set payload */
11059 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11060 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11062 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11063 rte_pktmbuf_tailroom(ut_params->ibuf));
11064 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
11065 rte_pktmbuf_tailroom(ut_params->obuf));
11067 /* Create AEAD operation */
11068 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11072 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11074 ut_params->op->sym->m_src = ut_params->ibuf;
11075 ut_params->op->sym->m_dst = ut_params->obuf;
11077 /* Process crypto operation */
11078 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11079 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11080 ut_params->op, 0, 0, 0, 0);
11082 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11083 ut_params->op), "failed to process sym crypto op");
11085 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11086 "crypto op processing failed");
11088 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
11089 ut_params->op->sym->cipher.data.offset);
11091 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11093 /* Validate obuf */
11094 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11096 tdata->plaintext.data,
11097 tdata->plaintext.len,
11098 "Plaintext data not as expected");
11100 TEST_ASSERT_EQUAL(ut_params->op->status,
11101 RTE_CRYPTO_OP_STATUS_SUCCESS,
11102 "Authentication failed");
11107 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
11109 return test_authenticated_decryption_oop(&gcm_test_case_5);
11113 test_authenticated_encryption_sessionless(
11114 const struct aead_test_data *tdata)
11116 struct crypto_testsuite_params *ts_params = &testsuite_params;
11117 struct crypto_unittest_params *ut_params = &unittest_params;
11120 uint8_t *ciphertext, *auth_tag;
11121 uint16_t plaintext_pad_len;
11122 uint8_t key[tdata->key.len + 1];
11123 struct rte_cryptodev_info dev_info;
11125 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11126 uint64_t feat_flags = dev_info.feature_flags;
11128 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11129 printf("Device doesn't support Sessionless ops.\n");
11130 return TEST_SKIPPED;
11133 /* not supported with CPU crypto */
11134 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11135 return TEST_SKIPPED;
11137 /* Verify the capabilities */
11138 struct rte_cryptodev_sym_capability_idx cap_idx;
11139 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11140 cap_idx.algo.aead = tdata->algo;
11141 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11143 return TEST_SKIPPED;
11145 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11147 /* clear mbuf payload */
11148 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11149 rte_pktmbuf_tailroom(ut_params->ibuf));
11151 /* Create AEAD operation */
11152 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
11156 /* Create GCM xform */
11157 memcpy(key, tdata->key.data, tdata->key.len);
11158 retval = create_aead_xform(ut_params->op,
11160 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11161 key, tdata->key.len,
11162 tdata->aad.len, tdata->auth_tag.len,
11167 ut_params->op->sym->m_src = ut_params->ibuf;
11169 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11170 RTE_CRYPTO_OP_SESSIONLESS,
11171 "crypto op session type not sessionless");
11173 /* Process crypto operation */
11174 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11175 ut_params->op), "failed to process sym crypto op");
11177 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11179 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11180 "crypto op status not success");
11182 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11184 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11185 ut_params->op->sym->cipher.data.offset);
11186 auth_tag = ciphertext + plaintext_pad_len;
11188 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
11189 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
11191 /* Validate obuf */
11192 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11194 tdata->ciphertext.data,
11195 tdata->ciphertext.len,
11196 "Ciphertext data not as expected");
11198 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11200 tdata->auth_tag.data,
11201 tdata->auth_tag.len,
11202 "Generated auth tag not as expected");
11209 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
11211 return test_authenticated_encryption_sessionless(
11216 test_authenticated_decryption_sessionless(
11217 const struct aead_test_data *tdata)
11219 struct crypto_testsuite_params *ts_params = &testsuite_params;
11220 struct crypto_unittest_params *ut_params = &unittest_params;
11223 uint8_t *plaintext;
11224 uint8_t key[tdata->key.len + 1];
11225 struct rte_cryptodev_info dev_info;
11227 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11228 uint64_t feat_flags = dev_info.feature_flags;
11230 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11231 printf("Device doesn't support Sessionless ops.\n");
11232 return TEST_SKIPPED;
11235 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11236 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11237 printf("Device doesn't support RAW data-path APIs.\n");
11238 return TEST_SKIPPED;
11241 /* not supported with CPU crypto */
11242 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11243 return TEST_SKIPPED;
11245 /* Verify the capabilities */
11246 struct rte_cryptodev_sym_capability_idx cap_idx;
11247 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11248 cap_idx.algo.aead = tdata->algo;
11249 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11251 return TEST_SKIPPED;
11253 /* alloc mbuf and set payload */
11254 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11257 rte_pktmbuf_tailroom(ut_params->ibuf));
11259 /* Create AEAD operation */
11260 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11264 /* Create AEAD xform */
11265 memcpy(key, tdata->key.data, tdata->key.len);
11266 retval = create_aead_xform(ut_params->op,
11268 RTE_CRYPTO_AEAD_OP_DECRYPT,
11269 key, tdata->key.len,
11270 tdata->aad.len, tdata->auth_tag.len,
11275 ut_params->op->sym->m_src = ut_params->ibuf;
11277 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11278 RTE_CRYPTO_OP_SESSIONLESS,
11279 "crypto op session type not sessionless");
11281 /* Process crypto operation */
11282 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11283 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11284 ut_params->op, 0, 0, 0, 0);
11286 TEST_ASSERT_NOT_NULL(process_crypto_request(
11287 ts_params->valid_devs[0], ut_params->op),
11288 "failed to process sym crypto op");
11290 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11292 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11293 "crypto op status not success");
11295 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11296 ut_params->op->sym->cipher.data.offset);
11298 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11300 /* Validate obuf */
11301 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11303 tdata->plaintext.data,
11304 tdata->plaintext.len,
11305 "Plaintext data not as expected");
11307 TEST_ASSERT_EQUAL(ut_params->op->status,
11308 RTE_CRYPTO_OP_STATUS_SUCCESS,
11309 "Authentication failed");
11314 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
11316 return test_authenticated_decryption_sessionless(
11321 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
11323 return test_authenticated_encryption(&ccm_test_case_128_1);
11327 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
11329 return test_authenticated_encryption(&ccm_test_case_128_2);
11333 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
11335 return test_authenticated_encryption(&ccm_test_case_128_3);
11339 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
11341 return test_authenticated_decryption(&ccm_test_case_128_1);
11345 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
11347 return test_authenticated_decryption(&ccm_test_case_128_2);
11351 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
11353 return test_authenticated_decryption(&ccm_test_case_128_3);
11357 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
11359 return test_authenticated_encryption(&ccm_test_case_192_1);
11363 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
11365 return test_authenticated_encryption(&ccm_test_case_192_2);
11369 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
11371 return test_authenticated_encryption(&ccm_test_case_192_3);
11375 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
11377 return test_authenticated_decryption(&ccm_test_case_192_1);
11381 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
11383 return test_authenticated_decryption(&ccm_test_case_192_2);
11387 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
11389 return test_authenticated_decryption(&ccm_test_case_192_3);
11393 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
11395 return test_authenticated_encryption(&ccm_test_case_256_1);
11399 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
11401 return test_authenticated_encryption(&ccm_test_case_256_2);
11405 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
11407 return test_authenticated_encryption(&ccm_test_case_256_3);
11411 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
11413 return test_authenticated_decryption(&ccm_test_case_256_1);
11417 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
11419 return test_authenticated_decryption(&ccm_test_case_256_2);
11423 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
11425 return test_authenticated_decryption(&ccm_test_case_256_3);
11431 struct crypto_testsuite_params *ts_params = &testsuite_params;
11432 struct rte_cryptodev_stats stats;
11434 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11435 return TEST_SKIPPED;
11437 /* Verify the capabilities */
11438 struct rte_cryptodev_sym_capability_idx cap_idx;
11439 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11440 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11441 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11443 return TEST_SKIPPED;
11444 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11445 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11446 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11448 return TEST_SKIPPED;
11450 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11452 return TEST_SKIPPED;
11454 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11455 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11456 &stats) == -ENODEV),
11457 "rte_cryptodev_stats_get invalid dev failed");
11458 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11459 "rte_cryptodev_stats_get invalid Param failed");
11461 /* Test expected values */
11462 test_AES_CBC_HMAC_SHA1_encrypt_digest();
11463 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11465 "rte_cryptodev_stats_get failed");
11466 TEST_ASSERT((stats.enqueued_count == 1),
11467 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11468 TEST_ASSERT((stats.dequeued_count == 1),
11469 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11470 TEST_ASSERT((stats.enqueue_err_count == 0),
11471 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11472 TEST_ASSERT((stats.dequeue_err_count == 0),
11473 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11475 /* invalid device but should ignore and not reset device stats*/
11476 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11477 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11479 "rte_cryptodev_stats_get failed");
11480 TEST_ASSERT((stats.enqueued_count == 1),
11481 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11483 /* check that a valid reset clears stats */
11484 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11485 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11487 "rte_cryptodev_stats_get failed");
11488 TEST_ASSERT((stats.enqueued_count == 0),
11489 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11490 TEST_ASSERT((stats.dequeued_count == 0),
11491 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11493 return TEST_SUCCESS;
11496 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11497 struct crypto_unittest_params *ut_params,
11498 enum rte_crypto_auth_operation op,
11499 const struct HMAC_MD5_vector *test_case)
11504 memcpy(key, test_case->key.data, test_case->key.len);
11506 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11507 ut_params->auth_xform.next = NULL;
11508 ut_params->auth_xform.auth.op = op;
11510 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11512 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11513 ut_params->auth_xform.auth.key.length = test_case->key.len;
11514 ut_params->auth_xform.auth.key.data = key;
11516 ut_params->sess = rte_cryptodev_sym_session_create(
11517 ts_params->session_mpool);
11518 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11519 if (ut_params->sess == NULL)
11520 return TEST_FAILED;
11522 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11523 ut_params->sess, &ut_params->auth_xform,
11524 ts_params->session_priv_mpool);
11525 if (status == -ENOTSUP)
11526 return TEST_SKIPPED;
11528 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11530 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11531 rte_pktmbuf_tailroom(ut_params->ibuf));
11536 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11537 const struct HMAC_MD5_vector *test_case,
11538 uint8_t **plaintext)
11540 uint16_t plaintext_pad_len;
11542 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11544 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11547 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11548 plaintext_pad_len);
11549 memcpy(*plaintext, test_case->plaintext.data,
11550 test_case->plaintext.len);
11552 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11553 ut_params->ibuf, MD5_DIGEST_LEN);
11554 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11555 "no room to append digest");
11556 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11557 ut_params->ibuf, plaintext_pad_len);
11559 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11560 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11561 test_case->auth_tag.len);
11564 sym_op->auth.data.offset = 0;
11565 sym_op->auth.data.length = test_case->plaintext.len;
11567 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11568 ut_params->op->sym->m_src = ut_params->ibuf;
11574 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11576 uint16_t plaintext_pad_len;
11577 uint8_t *plaintext, *auth_tag;
11579 struct crypto_testsuite_params *ts_params = &testsuite_params;
11580 struct crypto_unittest_params *ut_params = &unittest_params;
11581 struct rte_cryptodev_info dev_info;
11583 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11584 uint64_t feat_flags = dev_info.feature_flags;
11586 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11587 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11588 printf("Device doesn't support RAW data-path APIs.\n");
11589 return TEST_SKIPPED;
11592 /* Verify the capabilities */
11593 struct rte_cryptodev_sym_capability_idx cap_idx;
11594 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11595 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11596 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11598 return TEST_SKIPPED;
11600 if (MD5_HMAC_create_session(ts_params, ut_params,
11601 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11602 return TEST_FAILED;
11604 /* Generate Crypto op data structure */
11605 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11606 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11607 TEST_ASSERT_NOT_NULL(ut_params->op,
11608 "Failed to allocate symmetric crypto operation struct");
11610 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11613 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11614 return TEST_FAILED;
11616 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11617 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11619 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11620 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11621 ut_params->op, 0, 1, 0, 0);
11623 TEST_ASSERT_NOT_NULL(
11624 process_crypto_request(ts_params->valid_devs[0],
11626 "failed to process sym crypto op");
11628 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11629 "crypto op processing failed");
11631 if (ut_params->op->sym->m_dst) {
11632 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11633 uint8_t *, plaintext_pad_len);
11635 auth_tag = plaintext + plaintext_pad_len;
11638 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11640 test_case->auth_tag.data,
11641 test_case->auth_tag.len,
11642 "HMAC_MD5 generated tag not as expected");
11644 return TEST_SUCCESS;
11648 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11650 uint8_t *plaintext;
11652 struct crypto_testsuite_params *ts_params = &testsuite_params;
11653 struct crypto_unittest_params *ut_params = &unittest_params;
11654 struct rte_cryptodev_info dev_info;
11656 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11657 uint64_t feat_flags = dev_info.feature_flags;
11659 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11660 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11661 printf("Device doesn't support RAW data-path APIs.\n");
11662 return TEST_SKIPPED;
11665 /* Verify the capabilities */
11666 struct rte_cryptodev_sym_capability_idx cap_idx;
11667 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11668 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11669 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11671 return TEST_SKIPPED;
11673 if (MD5_HMAC_create_session(ts_params, ut_params,
11674 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11675 return TEST_FAILED;
11678 /* Generate Crypto op data structure */
11679 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11680 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11681 TEST_ASSERT_NOT_NULL(ut_params->op,
11682 "Failed to allocate symmetric crypto operation struct");
11684 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11685 return TEST_FAILED;
11687 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11688 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11690 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11691 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11692 ut_params->op, 0, 1, 0, 0);
11694 TEST_ASSERT_NOT_NULL(
11695 process_crypto_request(ts_params->valid_devs[0],
11697 "failed to process sym crypto op");
11699 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11700 "HMAC_MD5 crypto op processing failed");
11702 return TEST_SUCCESS;
11706 test_MD5_HMAC_generate_case_1(void)
11708 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11712 test_MD5_HMAC_verify_case_1(void)
11714 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11718 test_MD5_HMAC_generate_case_2(void)
11720 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11724 test_MD5_HMAC_verify_case_2(void)
11726 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11730 test_multi_session(void)
11732 struct crypto_testsuite_params *ts_params = &testsuite_params;
11733 struct crypto_unittest_params *ut_params = &unittest_params;
11735 struct rte_cryptodev_info dev_info;
11736 struct rte_cryptodev_sym_session **sessions;
11741 /* Verify the capabilities */
11742 struct rte_cryptodev_sym_capability_idx cap_idx;
11743 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11744 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11745 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11747 return TEST_SKIPPED;
11748 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11749 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11750 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11752 return TEST_SKIPPED;
11754 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11755 aes_cbc_key, hmac_sha512_key);
11758 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11760 sessions = rte_malloc(NULL,
11761 sizeof(struct rte_cryptodev_sym_session *) *
11762 (MAX_NB_SESSIONS + 1), 0);
11764 /* Create multiple crypto sessions*/
11765 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11767 sessions[i] = rte_cryptodev_sym_session_create(
11768 ts_params->session_mpool);
11769 TEST_ASSERT_NOT_NULL(sessions[i],
11770 "Session creation failed at session number %u",
11773 status = rte_cryptodev_sym_session_init(
11774 ts_params->valid_devs[0],
11775 sessions[i], &ut_params->auth_xform,
11776 ts_params->session_priv_mpool);
11777 if (status == -ENOTSUP)
11778 return TEST_SKIPPED;
11780 /* Attempt to send a request on each session */
11781 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11785 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11786 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11788 "Failed to perform decrypt on request number %u.", i);
11789 /* free crypto operation structure */
11791 rte_crypto_op_free(ut_params->op);
11794 * free mbuf - both obuf and ibuf are usually the same,
11795 * so check if they point at the same address is necessary,
11796 * to avoid freeing the mbuf twice.
11798 if (ut_params->obuf) {
11799 rte_pktmbuf_free(ut_params->obuf);
11800 if (ut_params->ibuf == ut_params->obuf)
11801 ut_params->ibuf = 0;
11802 ut_params->obuf = 0;
11804 if (ut_params->ibuf) {
11805 rte_pktmbuf_free(ut_params->ibuf);
11806 ut_params->ibuf = 0;
11810 sessions[i] = NULL;
11811 /* Next session create should fail */
11812 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11813 sessions[i], &ut_params->auth_xform,
11814 ts_params->session_priv_mpool);
11815 TEST_ASSERT_NULL(sessions[i],
11816 "Session creation succeeded unexpectedly!");
11818 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11819 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11821 rte_cryptodev_sym_session_free(sessions[i]);
11824 rte_free(sessions);
11826 return TEST_SUCCESS;
11829 struct multi_session_params {
11830 struct crypto_unittest_params ut_params;
11831 uint8_t *cipher_key;
11833 const uint8_t *cipher;
11834 const uint8_t *digest;
11838 #define MB_SESSION_NUMBER 3
11841 test_multi_session_random_usage(void)
11843 struct crypto_testsuite_params *ts_params = &testsuite_params;
11844 struct rte_cryptodev_info dev_info;
11845 struct rte_cryptodev_sym_session **sessions;
11847 struct multi_session_params ut_paramz[] = {
11850 .cipher_key = ms_aes_cbc_key0,
11851 .hmac_key = ms_hmac_key0,
11852 .cipher = ms_aes_cbc_cipher0,
11853 .digest = ms_hmac_digest0,
11854 .iv = ms_aes_cbc_iv0
11857 .cipher_key = ms_aes_cbc_key1,
11858 .hmac_key = ms_hmac_key1,
11859 .cipher = ms_aes_cbc_cipher1,
11860 .digest = ms_hmac_digest1,
11861 .iv = ms_aes_cbc_iv1
11864 .cipher_key = ms_aes_cbc_key2,
11865 .hmac_key = ms_hmac_key2,
11866 .cipher = ms_aes_cbc_cipher2,
11867 .digest = ms_hmac_digest2,
11868 .iv = ms_aes_cbc_iv2
11874 /* Verify the capabilities */
11875 struct rte_cryptodev_sym_capability_idx cap_idx;
11876 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11877 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11878 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11880 return TEST_SKIPPED;
11881 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11882 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11883 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11885 return TEST_SKIPPED;
11887 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11889 sessions = rte_malloc(NULL,
11890 (sizeof(struct rte_cryptodev_sym_session *)
11891 * MAX_NB_SESSIONS) + 1, 0);
11893 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11894 sessions[i] = rte_cryptodev_sym_session_create(
11895 ts_params->session_mpool);
11896 TEST_ASSERT_NOT_NULL(sessions[i],
11897 "Session creation failed at session number %u",
11900 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11901 sizeof(struct crypto_unittest_params));
11903 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11904 &ut_paramz[i].ut_params,
11905 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11907 /* Create multiple crypto sessions*/
11908 status = rte_cryptodev_sym_session_init(
11909 ts_params->valid_devs[0],
11911 &ut_paramz[i].ut_params.auth_xform,
11912 ts_params->session_priv_mpool);
11914 if (status == -ENOTSUP)
11915 return TEST_SKIPPED;
11917 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
11921 for (i = 0; i < 40000; i++) {
11923 j = rand() % MB_SESSION_NUMBER;
11925 TEST_ASSERT_SUCCESS(
11926 test_AES_CBC_HMAC_SHA512_decrypt_perform(
11928 &ut_paramz[j].ut_params,
11929 ts_params, ut_paramz[j].cipher,
11930 ut_paramz[j].digest,
11932 "Failed to perform decrypt on request number %u.", i);
11934 if (ut_paramz[j].ut_params.op)
11935 rte_crypto_op_free(ut_paramz[j].ut_params.op);
11938 * free mbuf - both obuf and ibuf are usually the same,
11939 * so check if they point at the same address is necessary,
11940 * to avoid freeing the mbuf twice.
11942 if (ut_paramz[j].ut_params.obuf) {
11943 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11944 if (ut_paramz[j].ut_params.ibuf
11945 == ut_paramz[j].ut_params.obuf)
11946 ut_paramz[j].ut_params.ibuf = 0;
11947 ut_paramz[j].ut_params.obuf = 0;
11949 if (ut_paramz[j].ut_params.ibuf) {
11950 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11951 ut_paramz[j].ut_params.ibuf = 0;
11955 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11956 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11958 rte_cryptodev_sym_session_free(sessions[i]);
11961 rte_free(sessions);
11963 return TEST_SUCCESS;
11966 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11967 0xab, 0xab, 0xab, 0xab,
11968 0xab, 0xab, 0xab, 0xab,
11969 0xab, 0xab, 0xab, 0xab};
11972 test_null_invalid_operation(void)
11974 struct crypto_testsuite_params *ts_params = &testsuite_params;
11975 struct crypto_unittest_params *ut_params = &unittest_params;
11978 /* This test is for NULL PMD only */
11979 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11980 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11981 return TEST_SKIPPED;
11983 /* Setup Cipher Parameters */
11984 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11985 ut_params->cipher_xform.next = NULL;
11987 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11988 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11990 ut_params->sess = rte_cryptodev_sym_session_create(
11991 ts_params->session_mpool);
11993 /* Create Crypto session*/
11994 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11995 ut_params->sess, &ut_params->cipher_xform,
11996 ts_params->session_priv_mpool);
11997 TEST_ASSERT(ret < 0,
11998 "Session creation succeeded unexpectedly");
12001 /* Setup HMAC Parameters */
12002 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12003 ut_params->auth_xform.next = NULL;
12005 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
12006 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12008 ut_params->sess = rte_cryptodev_sym_session_create(
12009 ts_params->session_mpool);
12011 /* Create Crypto session*/
12012 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12013 ut_params->sess, &ut_params->auth_xform,
12014 ts_params->session_priv_mpool);
12015 TEST_ASSERT(ret < 0,
12016 "Session creation succeeded unexpectedly");
12018 return TEST_SUCCESS;
12022 #define NULL_BURST_LENGTH (32)
12025 test_null_burst_operation(void)
12027 struct crypto_testsuite_params *ts_params = &testsuite_params;
12028 struct crypto_unittest_params *ut_params = &unittest_params;
12031 unsigned i, burst_len = NULL_BURST_LENGTH;
12033 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
12034 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
12036 /* This test is for NULL PMD only */
12037 if (gbl_driver_id != rte_cryptodev_driver_id_get(
12038 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
12039 return TEST_SKIPPED;
12041 /* Setup Cipher Parameters */
12042 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12043 ut_params->cipher_xform.next = &ut_params->auth_xform;
12045 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
12046 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12048 /* Setup HMAC Parameters */
12049 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12050 ut_params->auth_xform.next = NULL;
12052 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
12053 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12055 ut_params->sess = rte_cryptodev_sym_session_create(
12056 ts_params->session_mpool);
12057 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12059 /* Create Crypto session*/
12060 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12061 ut_params->sess, &ut_params->cipher_xform,
12062 ts_params->session_priv_mpool);
12064 if (status == -ENOTSUP)
12065 return TEST_SKIPPED;
12067 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
12069 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
12070 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
12071 burst_len, "failed to generate burst of crypto ops");
12073 /* Generate an operation for each mbuf in burst */
12074 for (i = 0; i < burst_len; i++) {
12075 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12077 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
12079 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
12083 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
12085 burst[i]->sym->m_src = m;
12088 /* Process crypto operation */
12089 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
12090 0, burst, burst_len),
12092 "Error enqueuing burst");
12094 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
12095 0, burst_dequeued, burst_len),
12097 "Error dequeuing burst");
12100 for (i = 0; i < burst_len; i++) {
12102 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
12103 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
12105 "data not as expected");
12107 rte_pktmbuf_free(burst[i]->sym->m_src);
12108 rte_crypto_op_free(burst[i]);
12111 return TEST_SUCCESS;
12115 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
12116 uint16_t nb_ops, void *user_param)
12118 RTE_SET_USED(dev_id);
12119 RTE_SET_USED(qp_id);
12121 RTE_SET_USED(user_param);
12123 printf("crypto enqueue callback called\n");
12128 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
12129 uint16_t nb_ops, void *user_param)
12131 RTE_SET_USED(dev_id);
12132 RTE_SET_USED(qp_id);
12134 RTE_SET_USED(user_param);
12136 printf("crypto dequeue callback called\n");
12141 * Thread using enqueue/dequeue callback with RCU.
12144 test_enqdeq_callback_thread(void *arg)
12147 /* DP thread calls rte_cryptodev_enqueue_burst()/
12148 * rte_cryptodev_dequeue_burst() and invokes callback.
12150 test_null_burst_operation();
12155 test_enq_callback_setup(void)
12157 struct crypto_testsuite_params *ts_params = &testsuite_params;
12158 struct rte_cryptodev_info dev_info;
12159 struct rte_cryptodev_qp_conf qp_conf = {
12160 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
12163 struct rte_cryptodev_cb *cb;
12164 uint16_t qp_id = 0;
12166 /* Stop the device in case it's started so it can be configured */
12167 rte_cryptodev_stop(ts_params->valid_devs[0]);
12169 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12171 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12173 "Failed to configure cryptodev %u",
12174 ts_params->valid_devs[0]);
12176 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12177 qp_conf.mp_session = ts_params->session_mpool;
12178 qp_conf.mp_session_private = ts_params->session_priv_mpool;
12180 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12181 ts_params->valid_devs[0], qp_id, &qp_conf,
12182 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12184 "rte_cryptodev_queue_pair_setup: num_inflights "
12185 "%u on qp %u on cryptodev %u",
12186 qp_conf.nb_descriptors, qp_id,
12187 ts_params->valid_devs[0]);
12189 /* Test with invalid crypto device */
12190 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
12191 qp_id, test_enq_callback, NULL);
12192 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12193 "cryptodev %u did not fail",
12194 qp_id, RTE_CRYPTO_MAX_DEVS);
12196 /* Test with invalid queue pair */
12197 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12198 dev_info.max_nb_queue_pairs + 1,
12199 test_enq_callback, NULL);
12200 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12201 "cryptodev %u did not fail",
12202 dev_info.max_nb_queue_pairs + 1,
12203 ts_params->valid_devs[0]);
12205 /* Test with NULL callback */
12206 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12207 qp_id, NULL, NULL);
12208 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12209 "cryptodev %u did not fail",
12210 qp_id, ts_params->valid_devs[0]);
12212 /* Test with valid configuration */
12213 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12214 qp_id, test_enq_callback, NULL);
12215 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12216 "qp %u on cryptodev %u",
12217 qp_id, ts_params->valid_devs[0]);
12219 rte_cryptodev_start(ts_params->valid_devs[0]);
12221 /* Launch a thread */
12222 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12223 rte_get_next_lcore(-1, 1, 0));
12225 /* Wait until reader exited. */
12226 rte_eal_mp_wait_lcore();
12228 /* Test with invalid crypto device */
12229 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12230 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12231 "Expected call to fail as crypto device is invalid");
12233 /* Test with invalid queue pair */
12234 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12235 ts_params->valid_devs[0],
12236 dev_info.max_nb_queue_pairs + 1, cb),
12237 "Expected call to fail as queue pair is invalid");
12239 /* Test with NULL callback */
12240 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12241 ts_params->valid_devs[0], qp_id, NULL),
12242 "Expected call to fail as callback is NULL");
12244 /* Test with valid configuration */
12245 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
12246 ts_params->valid_devs[0], qp_id, cb),
12247 "Failed test to remove callback on "
12248 "qp %u on cryptodev %u",
12249 qp_id, ts_params->valid_devs[0]);
12251 return TEST_SUCCESS;
12255 test_deq_callback_setup(void)
12257 struct crypto_testsuite_params *ts_params = &testsuite_params;
12258 struct rte_cryptodev_info dev_info;
12259 struct rte_cryptodev_qp_conf qp_conf = {
12260 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
12263 struct rte_cryptodev_cb *cb;
12264 uint16_t qp_id = 0;
12266 /* Stop the device in case it's started so it can be configured */
12267 rte_cryptodev_stop(ts_params->valid_devs[0]);
12269 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12271 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12273 "Failed to configure cryptodev %u",
12274 ts_params->valid_devs[0]);
12276 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12277 qp_conf.mp_session = ts_params->session_mpool;
12278 qp_conf.mp_session_private = ts_params->session_priv_mpool;
12280 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12281 ts_params->valid_devs[0], qp_id, &qp_conf,
12282 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12284 "rte_cryptodev_queue_pair_setup: num_inflights "
12285 "%u on qp %u on cryptodev %u",
12286 qp_conf.nb_descriptors, qp_id,
12287 ts_params->valid_devs[0]);
12289 /* Test with invalid crypto device */
12290 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
12291 qp_id, test_deq_callback, NULL);
12292 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12293 "cryptodev %u did not fail",
12294 qp_id, RTE_CRYPTO_MAX_DEVS);
12296 /* Test with invalid queue pair */
12297 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12298 dev_info.max_nb_queue_pairs + 1,
12299 test_deq_callback, NULL);
12300 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12301 "cryptodev %u did not fail",
12302 dev_info.max_nb_queue_pairs + 1,
12303 ts_params->valid_devs[0]);
12305 /* Test with NULL callback */
12306 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12307 qp_id, NULL, NULL);
12308 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12309 "cryptodev %u did not fail",
12310 qp_id, ts_params->valid_devs[0]);
12312 /* Test with valid configuration */
12313 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12314 qp_id, test_deq_callback, NULL);
12315 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12316 "qp %u on cryptodev %u",
12317 qp_id, ts_params->valid_devs[0]);
12319 rte_cryptodev_start(ts_params->valid_devs[0]);
12321 /* Launch a thread */
12322 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12323 rte_get_next_lcore(-1, 1, 0));
12325 /* Wait until reader exited. */
12326 rte_eal_mp_wait_lcore();
12328 /* Test with invalid crypto device */
12329 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12330 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12331 "Expected call to fail as crypto device is invalid");
12333 /* Test with invalid queue pair */
12334 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12335 ts_params->valid_devs[0],
12336 dev_info.max_nb_queue_pairs + 1, cb),
12337 "Expected call to fail as queue pair is invalid");
12339 /* Test with NULL callback */
12340 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12341 ts_params->valid_devs[0], qp_id, NULL),
12342 "Expected call to fail as callback is NULL");
12344 /* Test with valid configuration */
12345 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
12346 ts_params->valid_devs[0], qp_id, cb),
12347 "Failed test to remove callback on "
12348 "qp %u on cryptodev %u",
12349 qp_id, ts_params->valid_devs[0]);
12351 return TEST_SUCCESS;
12355 generate_gmac_large_plaintext(uint8_t *data)
12359 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
12360 memcpy(&data[i], &data[0], 32);
12364 create_gmac_operation(enum rte_crypto_auth_operation op,
12365 const struct gmac_test_data *tdata)
12367 struct crypto_testsuite_params *ts_params = &testsuite_params;
12368 struct crypto_unittest_params *ut_params = &unittest_params;
12369 struct rte_crypto_sym_op *sym_op;
12371 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12373 /* Generate Crypto op data structure */
12374 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12375 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12376 TEST_ASSERT_NOT_NULL(ut_params->op,
12377 "Failed to allocate symmetric crypto operation struct");
12379 sym_op = ut_params->op->sym;
12381 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12382 ut_params->ibuf, tdata->gmac_tag.len);
12383 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12384 "no room to append digest");
12386 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12387 ut_params->ibuf, plaintext_pad_len);
12389 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12390 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12391 tdata->gmac_tag.len);
12392 debug_hexdump(stdout, "digest:",
12393 sym_op->auth.digest.data,
12394 tdata->gmac_tag.len);
12397 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12398 uint8_t *, IV_OFFSET);
12400 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12402 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12404 sym_op->cipher.data.length = 0;
12405 sym_op->cipher.data.offset = 0;
12407 sym_op->auth.data.offset = 0;
12408 sym_op->auth.data.length = tdata->plaintext.len;
12414 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
12415 const struct gmac_test_data *tdata,
12416 void *digest_mem, uint64_t digest_phys)
12418 struct crypto_testsuite_params *ts_params = &testsuite_params;
12419 struct crypto_unittest_params *ut_params = &unittest_params;
12420 struct rte_crypto_sym_op *sym_op;
12422 /* Generate Crypto op data structure */
12423 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12424 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12425 TEST_ASSERT_NOT_NULL(ut_params->op,
12426 "Failed to allocate symmetric crypto operation struct");
12428 sym_op = ut_params->op->sym;
12430 sym_op->auth.digest.data = digest_mem;
12431 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12432 "no room to append digest");
12434 sym_op->auth.digest.phys_addr = digest_phys;
12436 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12437 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12438 tdata->gmac_tag.len);
12439 debug_hexdump(stdout, "digest:",
12440 sym_op->auth.digest.data,
12441 tdata->gmac_tag.len);
12444 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12445 uint8_t *, IV_OFFSET);
12447 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12449 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12451 sym_op->cipher.data.length = 0;
12452 sym_op->cipher.data.offset = 0;
12454 sym_op->auth.data.offset = 0;
12455 sym_op->auth.data.length = tdata->plaintext.len;
12460 static int create_gmac_session(uint8_t dev_id,
12461 const struct gmac_test_data *tdata,
12462 enum rte_crypto_auth_operation auth_op)
12464 uint8_t auth_key[tdata->key.len];
12467 struct crypto_testsuite_params *ts_params = &testsuite_params;
12468 struct crypto_unittest_params *ut_params = &unittest_params;
12470 memcpy(auth_key, tdata->key.data, tdata->key.len);
12472 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12473 ut_params->auth_xform.next = NULL;
12475 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12476 ut_params->auth_xform.auth.op = auth_op;
12477 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12478 ut_params->auth_xform.auth.key.length = tdata->key.len;
12479 ut_params->auth_xform.auth.key.data = auth_key;
12480 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12481 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12484 ut_params->sess = rte_cryptodev_sym_session_create(
12485 ts_params->session_mpool);
12486 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12488 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12489 &ut_params->auth_xform,
12490 ts_params->session_priv_mpool);
12496 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12498 struct crypto_testsuite_params *ts_params = &testsuite_params;
12499 struct crypto_unittest_params *ut_params = &unittest_params;
12500 struct rte_cryptodev_info dev_info;
12502 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12503 uint64_t feat_flags = dev_info.feature_flags;
12505 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12506 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12507 printf("Device doesn't support RAW data-path APIs.\n");
12508 return TEST_SKIPPED;
12513 uint8_t *auth_tag, *plaintext;
12514 uint16_t plaintext_pad_len;
12516 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12517 "No GMAC length in the source data");
12519 /* Verify the capabilities */
12520 struct rte_cryptodev_sym_capability_idx cap_idx;
12521 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12522 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12523 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12525 return TEST_SKIPPED;
12527 retval = create_gmac_session(ts_params->valid_devs[0],
12528 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12530 if (retval == -ENOTSUP)
12531 return TEST_SKIPPED;
12535 if (tdata->plaintext.len > MBUF_SIZE)
12536 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12538 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12539 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12540 "Failed to allocate input buffer in mempool");
12542 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12543 rte_pktmbuf_tailroom(ut_params->ibuf));
12545 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12547 * Runtime generate the large plain text instead of use hard code
12548 * plain text vector. It is done to avoid create huge source file
12549 * with the test vector.
12551 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12552 generate_gmac_large_plaintext(tdata->plaintext.data);
12554 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12555 plaintext_pad_len);
12556 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12558 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12559 debug_hexdump(stdout, "plaintext:", plaintext,
12560 tdata->plaintext.len);
12562 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12568 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12570 ut_params->op->sym->m_src = ut_params->ibuf;
12572 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12573 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12575 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12576 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12577 ut_params->op, 0, 1, 0, 0);
12579 TEST_ASSERT_NOT_NULL(
12580 process_crypto_request(ts_params->valid_devs[0],
12581 ut_params->op), "failed to process sym crypto op");
12583 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12584 "crypto op processing failed");
12586 if (ut_params->op->sym->m_dst) {
12587 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12588 uint8_t *, plaintext_pad_len);
12590 auth_tag = plaintext + plaintext_pad_len;
12593 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12595 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12597 tdata->gmac_tag.data,
12598 tdata->gmac_tag.len,
12599 "GMAC Generated auth tag not as expected");
12605 test_AES_GMAC_authentication_test_case_1(void)
12607 return test_AES_GMAC_authentication(&gmac_test_case_1);
12611 test_AES_GMAC_authentication_test_case_2(void)
12613 return test_AES_GMAC_authentication(&gmac_test_case_2);
12617 test_AES_GMAC_authentication_test_case_3(void)
12619 return test_AES_GMAC_authentication(&gmac_test_case_3);
12623 test_AES_GMAC_authentication_test_case_4(void)
12625 return test_AES_GMAC_authentication(&gmac_test_case_4);
12629 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12631 struct crypto_testsuite_params *ts_params = &testsuite_params;
12632 struct crypto_unittest_params *ut_params = &unittest_params;
12634 uint32_t plaintext_pad_len;
12635 uint8_t *plaintext;
12636 struct rte_cryptodev_info dev_info;
12638 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12639 uint64_t feat_flags = dev_info.feature_flags;
12641 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12642 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12643 printf("Device doesn't support RAW data-path APIs.\n");
12644 return TEST_SKIPPED;
12647 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12648 "No GMAC length in the source data");
12650 /* Verify the capabilities */
12651 struct rte_cryptodev_sym_capability_idx cap_idx;
12652 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12653 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12654 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12656 return TEST_SKIPPED;
12658 retval = create_gmac_session(ts_params->valid_devs[0],
12659 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12661 if (retval == -ENOTSUP)
12662 return TEST_SKIPPED;
12666 if (tdata->plaintext.len > MBUF_SIZE)
12667 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12669 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12670 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12671 "Failed to allocate input buffer in mempool");
12673 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12674 rte_pktmbuf_tailroom(ut_params->ibuf));
12676 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12679 * Runtime generate the large plain text instead of use hard code
12680 * plain text vector. It is done to avoid create huge source file
12681 * with the test vector.
12683 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12684 generate_gmac_large_plaintext(tdata->plaintext.data);
12686 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12687 plaintext_pad_len);
12688 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12690 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12691 debug_hexdump(stdout, "plaintext:", plaintext,
12692 tdata->plaintext.len);
12694 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
12700 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12702 ut_params->op->sym->m_src = ut_params->ibuf;
12704 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12705 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12707 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12708 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12709 ut_params->op, 0, 1, 0, 0);
12711 TEST_ASSERT_NOT_NULL(
12712 process_crypto_request(ts_params->valid_devs[0],
12713 ut_params->op), "failed to process sym crypto op");
12715 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12716 "crypto op processing failed");
12723 test_AES_GMAC_authentication_verify_test_case_1(void)
12725 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12729 test_AES_GMAC_authentication_verify_test_case_2(void)
12731 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12735 test_AES_GMAC_authentication_verify_test_case_3(void)
12737 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12741 test_AES_GMAC_authentication_verify_test_case_4(void)
12743 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12747 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12750 struct crypto_testsuite_params *ts_params = &testsuite_params;
12751 struct crypto_unittest_params *ut_params = &unittest_params;
12752 struct rte_cryptodev_info dev_info;
12753 uint64_t feature_flags;
12754 unsigned int trn_data = 0;
12755 void *digest_mem = NULL;
12757 unsigned int to_trn = 0;
12758 struct rte_mbuf *buf = NULL;
12759 uint8_t *auth_tag, *plaintext;
12762 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12763 "No GMAC length in the source data");
12765 /* Verify the capabilities */
12766 struct rte_cryptodev_sym_capability_idx cap_idx;
12767 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12768 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12769 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12771 return TEST_SKIPPED;
12773 /* Check for any input SGL support */
12774 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12775 feature_flags = dev_info.feature_flags;
12777 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12778 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12779 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12780 return TEST_SKIPPED;
12782 if (fragsz > tdata->plaintext.len)
12783 fragsz = tdata->plaintext.len;
12785 uint16_t plaintext_len = fragsz;
12787 retval = create_gmac_session(ts_params->valid_devs[0],
12788 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12790 if (retval == -ENOTSUP)
12791 return TEST_SKIPPED;
12795 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12796 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12797 "Failed to allocate input buffer in mempool");
12799 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12800 rte_pktmbuf_tailroom(ut_params->ibuf));
12802 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12804 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12806 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12808 trn_data += plaintext_len;
12810 buf = ut_params->ibuf;
12813 * Loop until no more fragments
12816 while (trn_data < tdata->plaintext.len) {
12818 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12819 (tdata->plaintext.len - trn_data) : fragsz;
12821 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12824 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12825 rte_pktmbuf_tailroom(buf));
12827 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12830 memcpy(plaintext, tdata->plaintext.data + trn_data,
12832 trn_data += to_trn;
12833 if (trn_data == tdata->plaintext.len)
12834 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12835 tdata->gmac_tag.len);
12837 ut_params->ibuf->nb_segs = segs;
12840 * Place digest at the end of the last buffer
12842 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12845 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12846 + tdata->gmac_tag.len);
12847 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12848 tdata->plaintext.len);
12851 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12852 tdata, digest_mem, digest_phys);
12857 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12859 ut_params->op->sym->m_src = ut_params->ibuf;
12861 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12862 return TEST_SKIPPED;
12864 TEST_ASSERT_NOT_NULL(
12865 process_crypto_request(ts_params->valid_devs[0],
12866 ut_params->op), "failed to process sym crypto op");
12868 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12869 "crypto op processing failed");
12871 auth_tag = digest_mem;
12872 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12873 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12875 tdata->gmac_tag.data,
12876 tdata->gmac_tag.len,
12877 "GMAC Generated auth tag not as expected");
12882 /* Segment size not multiple of block size (16B) */
12884 test_AES_GMAC_authentication_SGL_40B(void)
12886 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12890 test_AES_GMAC_authentication_SGL_80B(void)
12892 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12896 test_AES_GMAC_authentication_SGL_2048B(void)
12898 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12901 /* Segment size not multiple of block size (16B) */
12903 test_AES_GMAC_authentication_SGL_2047B(void)
12905 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12908 struct test_crypto_vector {
12909 enum rte_crypto_cipher_algorithm crypto_algo;
12910 unsigned int cipher_offset;
12911 unsigned int cipher_len;
12924 const uint8_t *data;
12929 const uint8_t *data;
12933 enum rte_crypto_auth_algorithm auth_algo;
12934 unsigned int auth_offset;
12942 const uint8_t *data;
12952 static const struct test_crypto_vector
12953 hmac_sha1_test_crypto_vector = {
12954 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12956 .data = plaintext_hash,
12961 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12962 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12963 0xDE, 0xF4, 0xDE, 0xAD
12969 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12970 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12971 0x3F, 0x91, 0x64, 0x59
12977 static const struct test_crypto_vector
12978 aes128_gmac_test_vector = {
12979 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12981 .data = plaintext_hash,
12986 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12987 0x08, 0x09, 0x0A, 0x0B
12993 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12994 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
13000 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
13001 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
13007 static const struct test_crypto_vector
13008 aes128cbc_hmac_sha1_test_vector = {
13009 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
13010 .cipher_offset = 0,
13014 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
13015 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
13021 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13022 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
13027 .data = plaintext_hash,
13031 .data = ciphertext512_aes128cbc,
13034 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13038 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13039 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13040 0xDE, 0xF4, 0xDE, 0xAD
13046 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
13047 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
13048 0x18, 0x8C, 0x1D, 0x32
13054 static const struct test_crypto_vector
13055 aes128cbc_hmac_sha1_aad_test_vector = {
13056 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
13057 .cipher_offset = 8,
13061 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
13062 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
13068 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13069 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
13074 .data = plaintext_hash,
13078 .data = ciphertext512_aes128cbc_aad,
13081 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13085 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13086 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13087 0xDE, 0xF4, 0xDE, 0xAD
13093 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
13094 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
13095 0x62, 0x0F, 0xFB, 0x10
13102 data_corruption(uint8_t *data)
13108 tag_corruption(uint8_t *data, unsigned int tag_offset)
13110 data[tag_offset] += 1;
13114 create_auth_session(struct crypto_unittest_params *ut_params,
13116 const struct test_crypto_vector *reference,
13117 enum rte_crypto_auth_operation auth_op)
13119 struct crypto_testsuite_params *ts_params = &testsuite_params;
13120 uint8_t auth_key[reference->auth_key.len + 1];
13123 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13125 /* Setup Authentication Parameters */
13126 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13127 ut_params->auth_xform.auth.op = auth_op;
13128 ut_params->auth_xform.next = NULL;
13129 ut_params->auth_xform.auth.algo = reference->auth_algo;
13130 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13131 ut_params->auth_xform.auth.key.data = auth_key;
13132 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13134 /* Create Crypto session*/
13135 ut_params->sess = rte_cryptodev_sym_session_create(
13136 ts_params->session_mpool);
13137 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13139 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
13140 &ut_params->auth_xform,
13141 ts_params->session_priv_mpool);
13147 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
13149 const struct test_crypto_vector *reference,
13150 enum rte_crypto_auth_operation auth_op,
13151 enum rte_crypto_cipher_operation cipher_op)
13153 struct crypto_testsuite_params *ts_params = &testsuite_params;
13154 uint8_t cipher_key[reference->cipher_key.len + 1];
13155 uint8_t auth_key[reference->auth_key.len + 1];
13158 memcpy(cipher_key, reference->cipher_key.data,
13159 reference->cipher_key.len);
13160 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13162 /* Setup Authentication Parameters */
13163 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13164 ut_params->auth_xform.auth.op = auth_op;
13165 ut_params->auth_xform.auth.algo = reference->auth_algo;
13166 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13167 ut_params->auth_xform.auth.key.data = auth_key;
13168 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13170 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
13171 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
13172 ut_params->auth_xform.auth.iv.length = reference->iv.len;
13174 ut_params->auth_xform.next = &ut_params->cipher_xform;
13176 /* Setup Cipher Parameters */
13177 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13178 ut_params->cipher_xform.next = NULL;
13179 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13180 ut_params->cipher_xform.cipher.op = cipher_op;
13181 ut_params->cipher_xform.cipher.key.data = cipher_key;
13182 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13183 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13184 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13187 /* Create Crypto session*/
13188 ut_params->sess = rte_cryptodev_sym_session_create(
13189 ts_params->session_mpool);
13190 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13192 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
13193 &ut_params->auth_xform,
13194 ts_params->session_priv_mpool);
13200 create_auth_operation(struct crypto_testsuite_params *ts_params,
13201 struct crypto_unittest_params *ut_params,
13202 const struct test_crypto_vector *reference,
13203 unsigned int auth_generate)
13205 /* Generate Crypto op data structure */
13206 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13207 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13208 TEST_ASSERT_NOT_NULL(ut_params->op,
13209 "Failed to allocate pktmbuf offload");
13211 /* Set crypto operation data parameters */
13212 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13214 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13216 /* set crypto operation source mbuf */
13217 sym_op->m_src = ut_params->ibuf;
13220 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13221 ut_params->ibuf, reference->digest.len);
13223 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13224 "no room to append auth tag");
13226 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13227 ut_params->ibuf, reference->plaintext.len);
13230 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13232 memcpy(sym_op->auth.digest.data,
13233 reference->digest.data,
13234 reference->digest.len);
13236 debug_hexdump(stdout, "digest:",
13237 sym_op->auth.digest.data,
13238 reference->digest.len);
13240 sym_op->auth.data.length = reference->plaintext.len;
13241 sym_op->auth.data.offset = 0;
13247 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
13248 struct crypto_unittest_params *ut_params,
13249 const struct test_crypto_vector *reference,
13250 unsigned int auth_generate)
13252 /* Generate Crypto op data structure */
13253 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13254 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13255 TEST_ASSERT_NOT_NULL(ut_params->op,
13256 "Failed to allocate pktmbuf offload");
13258 /* Set crypto operation data parameters */
13259 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13261 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13263 /* set crypto operation source mbuf */
13264 sym_op->m_src = ut_params->ibuf;
13267 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13268 ut_params->ibuf, reference->digest.len);
13270 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13271 "no room to append auth tag");
13273 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13274 ut_params->ibuf, reference->ciphertext.len);
13277 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13279 memcpy(sym_op->auth.digest.data,
13280 reference->digest.data,
13281 reference->digest.len);
13283 debug_hexdump(stdout, "digest:",
13284 sym_op->auth.digest.data,
13285 reference->digest.len);
13287 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13288 reference->iv.data, reference->iv.len);
13290 sym_op->cipher.data.length = 0;
13291 sym_op->cipher.data.offset = 0;
13293 sym_op->auth.data.length = reference->plaintext.len;
13294 sym_op->auth.data.offset = 0;
13300 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
13301 struct crypto_unittest_params *ut_params,
13302 const struct test_crypto_vector *reference,
13303 unsigned int auth_generate)
13305 /* Generate Crypto op data structure */
13306 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13307 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13308 TEST_ASSERT_NOT_NULL(ut_params->op,
13309 "Failed to allocate pktmbuf offload");
13311 /* Set crypto operation data parameters */
13312 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13314 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13316 /* set crypto operation source mbuf */
13317 sym_op->m_src = ut_params->ibuf;
13320 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13321 ut_params->ibuf, reference->digest.len);
13323 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13324 "no room to append auth tag");
13326 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13327 ut_params->ibuf, reference->ciphertext.len);
13330 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13332 memcpy(sym_op->auth.digest.data,
13333 reference->digest.data,
13334 reference->digest.len);
13336 debug_hexdump(stdout, "digest:",
13337 sym_op->auth.digest.data,
13338 reference->digest.len);
13340 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13341 reference->iv.data, reference->iv.len);
13343 sym_op->cipher.data.length = reference->cipher_len;
13344 sym_op->cipher.data.offset = reference->cipher_offset;
13346 sym_op->auth.data.length = reference->plaintext.len;
13347 sym_op->auth.data.offset = reference->auth_offset;
13353 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13354 struct crypto_unittest_params *ut_params,
13355 const struct test_crypto_vector *reference)
13357 return create_auth_operation(ts_params, ut_params, reference, 0);
13361 create_auth_verify_GMAC_operation(
13362 struct crypto_testsuite_params *ts_params,
13363 struct crypto_unittest_params *ut_params,
13364 const struct test_crypto_vector *reference)
13366 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
13370 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13371 struct crypto_unittest_params *ut_params,
13372 const struct test_crypto_vector *reference)
13374 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
13378 test_authentication_verify_fail_when_data_corruption(
13379 struct crypto_testsuite_params *ts_params,
13380 struct crypto_unittest_params *ut_params,
13381 const struct test_crypto_vector *reference,
13382 unsigned int data_corrupted)
13386 uint8_t *plaintext;
13387 struct rte_cryptodev_info dev_info;
13389 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13390 uint64_t feat_flags = dev_info.feature_flags;
13392 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13393 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13394 printf("Device doesn't support RAW data-path APIs.\n");
13395 return TEST_SKIPPED;
13398 /* Verify the capabilities */
13399 struct rte_cryptodev_sym_capability_idx cap_idx;
13400 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13401 cap_idx.algo.auth = reference->auth_algo;
13402 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13404 return TEST_SKIPPED;
13407 /* Create session */
13408 retval = create_auth_session(ut_params,
13409 ts_params->valid_devs[0],
13411 RTE_CRYPTO_AUTH_OP_VERIFY);
13413 if (retval == -ENOTSUP)
13414 return TEST_SKIPPED;
13418 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13419 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13420 "Failed to allocate input buffer in mempool");
13422 /* clear mbuf payload */
13423 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13424 rte_pktmbuf_tailroom(ut_params->ibuf));
13426 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13427 reference->plaintext.len);
13428 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13429 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13431 debug_hexdump(stdout, "plaintext:", plaintext,
13432 reference->plaintext.len);
13434 /* Create operation */
13435 retval = create_auth_verify_operation(ts_params, ut_params, reference);
13440 if (data_corrupted)
13441 data_corruption(plaintext);
13443 tag_corruption(plaintext, reference->plaintext.len);
13445 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13446 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13448 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13449 RTE_CRYPTO_OP_STATUS_SUCCESS,
13450 "authentication not failed");
13451 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13452 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13453 ut_params->op, 0, 1, 0, 0);
13455 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13458 if (ut_params->op == NULL)
13460 else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
13467 test_authentication_verify_GMAC_fail_when_corruption(
13468 struct crypto_testsuite_params *ts_params,
13469 struct crypto_unittest_params *ut_params,
13470 const struct test_crypto_vector *reference,
13471 unsigned int data_corrupted)
13474 uint8_t *plaintext;
13475 struct rte_cryptodev_info dev_info;
13477 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13478 uint64_t feat_flags = dev_info.feature_flags;
13480 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13481 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13482 printf("Device doesn't support RAW data-path APIs.\n");
13483 return TEST_SKIPPED;
13486 /* Verify the capabilities */
13487 struct rte_cryptodev_sym_capability_idx cap_idx;
13488 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13489 cap_idx.algo.auth = reference->auth_algo;
13490 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13492 return TEST_SKIPPED;
13494 /* Create session */
13495 retval = create_auth_cipher_session(ut_params,
13496 ts_params->valid_devs[0],
13498 RTE_CRYPTO_AUTH_OP_VERIFY,
13499 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13503 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13504 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13505 "Failed to allocate input buffer in mempool");
13507 /* clear mbuf payload */
13508 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13509 rte_pktmbuf_tailroom(ut_params->ibuf));
13511 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13512 reference->plaintext.len);
13513 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13514 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13516 debug_hexdump(stdout, "plaintext:", plaintext,
13517 reference->plaintext.len);
13519 /* Create operation */
13520 retval = create_auth_verify_GMAC_operation(ts_params,
13527 if (data_corrupted)
13528 data_corruption(plaintext);
13530 tag_corruption(plaintext, reference->aad.len);
13532 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13533 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13535 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13536 RTE_CRYPTO_OP_STATUS_SUCCESS,
13537 "authentication not failed");
13538 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13539 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13540 ut_params->op, 0, 1, 0, 0);
13542 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13544 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13551 test_authenticated_decryption_fail_when_corruption(
13552 struct crypto_testsuite_params *ts_params,
13553 struct crypto_unittest_params *ut_params,
13554 const struct test_crypto_vector *reference,
13555 unsigned int data_corrupted)
13559 uint8_t *ciphertext;
13560 struct rte_cryptodev_info dev_info;
13562 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13563 uint64_t feat_flags = dev_info.feature_flags;
13565 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13566 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13567 printf("Device doesn't support RAW data-path APIs.\n");
13568 return TEST_SKIPPED;
13571 /* Verify the capabilities */
13572 struct rte_cryptodev_sym_capability_idx cap_idx;
13573 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13574 cap_idx.algo.auth = reference->auth_algo;
13575 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13577 return TEST_SKIPPED;
13578 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13579 cap_idx.algo.cipher = reference->crypto_algo;
13580 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13582 return TEST_SKIPPED;
13584 /* Create session */
13585 retval = create_auth_cipher_session(ut_params,
13586 ts_params->valid_devs[0],
13588 RTE_CRYPTO_AUTH_OP_VERIFY,
13589 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13591 if (retval == -ENOTSUP)
13592 return TEST_SKIPPED;
13596 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13597 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13598 "Failed to allocate input buffer in mempool");
13600 /* clear mbuf payload */
13601 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13602 rte_pktmbuf_tailroom(ut_params->ibuf));
13604 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13605 reference->ciphertext.len);
13606 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13607 memcpy(ciphertext, reference->ciphertext.data,
13608 reference->ciphertext.len);
13610 /* Create operation */
13611 retval = create_cipher_auth_verify_operation(ts_params,
13618 if (data_corrupted)
13619 data_corruption(ciphertext);
13621 tag_corruption(ciphertext, reference->ciphertext.len);
13623 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13624 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13626 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13627 RTE_CRYPTO_OP_STATUS_SUCCESS,
13628 "authentication not failed");
13629 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13630 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13631 ut_params->op, 1, 1, 0, 0);
13633 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13635 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13642 test_authenticated_encrypt_with_esn(
13643 struct crypto_testsuite_params *ts_params,
13644 struct crypto_unittest_params *ut_params,
13645 const struct test_crypto_vector *reference)
13649 uint8_t *authciphertext, *plaintext, *auth_tag;
13650 uint16_t plaintext_pad_len;
13651 uint8_t cipher_key[reference->cipher_key.len + 1];
13652 uint8_t auth_key[reference->auth_key.len + 1];
13653 struct rte_cryptodev_info dev_info;
13656 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13657 uint64_t feat_flags = dev_info.feature_flags;
13659 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13660 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13661 printf("Device doesn't support RAW data-path APIs.\n");
13662 return TEST_SKIPPED;
13665 /* Verify the capabilities */
13666 struct rte_cryptodev_sym_capability_idx cap_idx;
13667 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13668 cap_idx.algo.auth = reference->auth_algo;
13669 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13671 return TEST_SKIPPED;
13672 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13673 cap_idx.algo.cipher = reference->crypto_algo;
13674 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13676 return TEST_SKIPPED;
13678 /* Create session */
13679 memcpy(cipher_key, reference->cipher_key.data,
13680 reference->cipher_key.len);
13681 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13683 /* Setup Cipher Parameters */
13684 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13685 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13686 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13687 ut_params->cipher_xform.cipher.key.data = cipher_key;
13688 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13689 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13690 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13692 ut_params->cipher_xform.next = &ut_params->auth_xform;
13694 /* Setup Authentication Parameters */
13695 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13696 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13697 ut_params->auth_xform.auth.algo = reference->auth_algo;
13698 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13699 ut_params->auth_xform.auth.key.data = auth_key;
13700 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13701 ut_params->auth_xform.next = NULL;
13703 /* Create Crypto session*/
13704 ut_params->sess = rte_cryptodev_sym_session_create(
13705 ts_params->session_mpool);
13706 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13708 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13710 &ut_params->cipher_xform,
13711 ts_params->session_priv_mpool);
13713 if (status == -ENOTSUP)
13714 return TEST_SKIPPED;
13716 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
13718 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13719 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13720 "Failed to allocate input buffer in mempool");
13722 /* clear mbuf payload */
13723 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13724 rte_pktmbuf_tailroom(ut_params->ibuf));
13726 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13727 reference->plaintext.len);
13728 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13729 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13731 /* Create operation */
13732 retval = create_cipher_auth_operation(ts_params,
13739 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13740 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13742 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13743 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13744 ut_params->op, 1, 1, 0, 0);
13746 ut_params->op = process_crypto_request(
13747 ts_params->valid_devs[0], ut_params->op);
13749 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13751 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13752 "crypto op processing failed");
13754 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13756 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13757 ut_params->op->sym->auth.data.offset);
13758 auth_tag = authciphertext + plaintext_pad_len;
13759 debug_hexdump(stdout, "ciphertext:", authciphertext,
13760 reference->ciphertext.len);
13761 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13763 /* Validate obuf */
13764 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13766 reference->ciphertext.data,
13767 reference->ciphertext.len,
13768 "Ciphertext data not as expected");
13770 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13772 reference->digest.data,
13773 reference->digest.len,
13774 "Generated digest not as expected");
13776 return TEST_SUCCESS;
13781 test_authenticated_decrypt_with_esn(
13782 struct crypto_testsuite_params *ts_params,
13783 struct crypto_unittest_params *ut_params,
13784 const struct test_crypto_vector *reference)
13788 uint8_t *ciphertext;
13789 uint8_t cipher_key[reference->cipher_key.len + 1];
13790 uint8_t auth_key[reference->auth_key.len + 1];
13791 struct rte_cryptodev_info dev_info;
13793 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13794 uint64_t feat_flags = dev_info.feature_flags;
13796 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13797 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13798 printf("Device doesn't support RAW data-path APIs.\n");
13799 return TEST_SKIPPED;
13802 /* Verify the capabilities */
13803 struct rte_cryptodev_sym_capability_idx cap_idx;
13804 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13805 cap_idx.algo.auth = reference->auth_algo;
13806 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13808 return TEST_SKIPPED;
13809 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13810 cap_idx.algo.cipher = reference->crypto_algo;
13811 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13813 return TEST_SKIPPED;
13815 /* Create session */
13816 memcpy(cipher_key, reference->cipher_key.data,
13817 reference->cipher_key.len);
13818 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13820 /* Setup Authentication Parameters */
13821 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13822 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13823 ut_params->auth_xform.auth.algo = reference->auth_algo;
13824 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13825 ut_params->auth_xform.auth.key.data = auth_key;
13826 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13827 ut_params->auth_xform.next = &ut_params->cipher_xform;
13829 /* Setup Cipher Parameters */
13830 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13831 ut_params->cipher_xform.next = NULL;
13832 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13833 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13834 ut_params->cipher_xform.cipher.key.data = cipher_key;
13835 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13836 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13837 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13839 /* Create Crypto session*/
13840 ut_params->sess = rte_cryptodev_sym_session_create(
13841 ts_params->session_mpool);
13842 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13844 retval = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13846 &ut_params->auth_xform,
13847 ts_params->session_priv_mpool);
13849 if (retval == -ENOTSUP)
13850 return TEST_SKIPPED;
13852 TEST_ASSERT_EQUAL(retval, 0, "Session init failed");
13854 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13855 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13856 "Failed to allocate input buffer in mempool");
13858 /* clear mbuf payload */
13859 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13860 rte_pktmbuf_tailroom(ut_params->ibuf));
13862 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13863 reference->ciphertext.len);
13864 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13865 memcpy(ciphertext, reference->ciphertext.data,
13866 reference->ciphertext.len);
13868 /* Create operation */
13869 retval = create_cipher_auth_verify_operation(ts_params,
13876 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13877 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13879 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13880 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13881 ut_params->op, 1, 1, 0, 0);
13883 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13886 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13887 TEST_ASSERT_EQUAL(ut_params->op->status,
13888 RTE_CRYPTO_OP_STATUS_SUCCESS,
13889 "crypto op processing passed");
13891 ut_params->obuf = ut_params->op->sym->m_src;
13892 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13898 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13899 const struct aead_test_data *tdata,
13900 void *digest_mem, uint64_t digest_phys)
13902 struct crypto_testsuite_params *ts_params = &testsuite_params;
13903 struct crypto_unittest_params *ut_params = &unittest_params;
13905 const unsigned int auth_tag_len = tdata->auth_tag.len;
13906 const unsigned int iv_len = tdata->iv.len;
13907 unsigned int aad_len = tdata->aad.len;
13908 unsigned int aad_len_pad = 0;
13910 /* Generate Crypto op data structure */
13911 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13912 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13913 TEST_ASSERT_NOT_NULL(ut_params->op,
13914 "Failed to allocate symmetric crypto operation struct");
13916 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13918 sym_op->aead.digest.data = digest_mem;
13920 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13921 "no room to append digest");
13923 sym_op->aead.digest.phys_addr = digest_phys;
13925 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13926 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13928 debug_hexdump(stdout, "digest:",
13929 sym_op->aead.digest.data,
13933 /* Append aad data */
13934 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13935 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13936 uint8_t *, IV_OFFSET);
13938 /* Copy IV 1 byte after the IV pointer, according to the API */
13939 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13941 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13943 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13944 ut_params->ibuf, aad_len);
13945 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13946 "no room to prepend aad");
13947 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13950 memset(sym_op->aead.aad.data, 0, aad_len);
13951 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
13952 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13954 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13955 debug_hexdump(stdout, "aad:",
13956 sym_op->aead.aad.data, aad_len);
13958 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13959 uint8_t *, IV_OFFSET);
13961 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13963 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13965 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13966 ut_params->ibuf, aad_len_pad);
13967 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13968 "no room to prepend aad");
13969 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13972 memset(sym_op->aead.aad.data, 0, aad_len);
13973 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13975 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13976 debug_hexdump(stdout, "aad:",
13977 sym_op->aead.aad.data, aad_len);
13980 sym_op->aead.data.length = tdata->plaintext.len;
13981 sym_op->aead.data.offset = aad_len_pad;
13986 #define SGL_MAX_NO 16
13989 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13990 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13992 struct crypto_testsuite_params *ts_params = &testsuite_params;
13993 struct crypto_unittest_params *ut_params = &unittest_params;
13994 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13997 int to_trn_tbl[SGL_MAX_NO];
13999 unsigned int trn_data = 0;
14000 uint8_t *plaintext, *ciphertext, *auth_tag;
14001 struct rte_cryptodev_info dev_info;
14003 /* Verify the capabilities */
14004 struct rte_cryptodev_sym_capability_idx cap_idx;
14005 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14006 cap_idx.algo.aead = tdata->algo;
14007 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14009 return TEST_SKIPPED;
14011 /* OOP not supported with CPU crypto */
14012 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14013 return TEST_SKIPPED;
14015 /* Detailed check for the particular SGL support flag */
14016 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14018 unsigned int sgl_in = fragsz < tdata->plaintext.len;
14019 if (sgl_in && (!(dev_info.feature_flags &
14020 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
14021 return TEST_SKIPPED;
14023 uint64_t feat_flags = dev_info.feature_flags;
14025 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14026 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14027 printf("Device doesn't support RAW data-path APIs.\n");
14028 return TEST_SKIPPED;
14031 unsigned int sgl_in = fragsz < tdata->plaintext.len;
14032 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
14033 tdata->plaintext.len;
14034 /* Raw data path API does not support OOP */
14035 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14036 return TEST_SKIPPED;
14037 if (sgl_in && !sgl_out) {
14038 if (!(dev_info.feature_flags &
14039 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
14040 return TEST_SKIPPED;
14041 } else if (!sgl_in && sgl_out) {
14042 if (!(dev_info.feature_flags &
14043 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
14044 return TEST_SKIPPED;
14045 } else if (sgl_in && sgl_out) {
14046 if (!(dev_info.feature_flags &
14047 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
14048 return TEST_SKIPPED;
14052 if (fragsz > tdata->plaintext.len)
14053 fragsz = tdata->plaintext.len;
14055 uint16_t plaintext_len = fragsz;
14056 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
14058 if (fragsz_oop > tdata->plaintext.len)
14059 frag_size_oop = tdata->plaintext.len;
14062 void *digest_mem = NULL;
14064 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
14066 if (tdata->plaintext.len % fragsz != 0) {
14067 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
14070 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
14075 * For out-op-place we need to alloc another mbuf
14078 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14079 rte_pktmbuf_append(ut_params->obuf,
14080 frag_size_oop + prepend_len);
14081 buf_oop = ut_params->obuf;
14084 /* Create AEAD session */
14085 retval = create_aead_session(ts_params->valid_devs[0],
14087 RTE_CRYPTO_AEAD_OP_ENCRYPT,
14088 tdata->key.data, tdata->key.len,
14089 tdata->aad.len, tdata->auth_tag.len,
14094 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14096 /* clear mbuf payload */
14097 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14098 rte_pktmbuf_tailroom(ut_params->ibuf));
14100 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14103 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
14105 trn_data += plaintext_len;
14107 buf = ut_params->ibuf;
14110 * Loop until no more fragments
14113 while (trn_data < tdata->plaintext.len) {
14115 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
14116 (tdata->plaintext.len - trn_data) : fragsz;
14118 to_trn_tbl[ecx++] = to_trn;
14120 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14123 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
14124 rte_pktmbuf_tailroom(buf));
14127 if (oop && !fragsz_oop) {
14128 buf_last_oop = buf_oop->next =
14129 rte_pktmbuf_alloc(ts_params->mbuf_pool);
14130 buf_oop = buf_oop->next;
14131 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14132 0, rte_pktmbuf_tailroom(buf_oop));
14133 rte_pktmbuf_append(buf_oop, to_trn);
14136 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
14139 memcpy(plaintext, tdata->plaintext.data + trn_data,
14141 trn_data += to_trn;
14142 if (trn_data == tdata->plaintext.len) {
14145 digest_mem = rte_pktmbuf_append(buf_oop,
14146 tdata->auth_tag.len);
14148 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14149 tdata->auth_tag.len);
14153 uint64_t digest_phys = 0;
14155 ut_params->ibuf->nb_segs = segs;
14158 if (fragsz_oop && oop) {
14162 if (frag_size_oop == tdata->plaintext.len) {
14163 digest_mem = rte_pktmbuf_append(ut_params->obuf,
14164 tdata->auth_tag.len);
14166 digest_phys = rte_pktmbuf_iova_offset(
14168 tdata->plaintext.len + prepend_len);
14171 trn_data = frag_size_oop;
14172 while (trn_data < tdata->plaintext.len) {
14175 (tdata->plaintext.len - trn_data <
14177 (tdata->plaintext.len - trn_data) :
14180 to_trn_tbl[ecx++] = to_trn;
14182 buf_last_oop = buf_oop->next =
14183 rte_pktmbuf_alloc(ts_params->mbuf_pool);
14184 buf_oop = buf_oop->next;
14185 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14186 0, rte_pktmbuf_tailroom(buf_oop));
14187 rte_pktmbuf_append(buf_oop, to_trn);
14189 trn_data += to_trn;
14191 if (trn_data == tdata->plaintext.len) {
14192 digest_mem = rte_pktmbuf_append(buf_oop,
14193 tdata->auth_tag.len);
14197 ut_params->obuf->nb_segs = segs;
14201 * Place digest at the end of the last buffer
14204 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14205 if (oop && buf_last_oop)
14206 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
14208 if (!digest_mem && !oop) {
14209 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14210 + tdata->auth_tag.len);
14211 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14212 tdata->plaintext.len);
14215 /* Create AEAD operation */
14216 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
14217 tdata, digest_mem, digest_phys);
14222 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14224 ut_params->op->sym->m_src = ut_params->ibuf;
14226 ut_params->op->sym->m_dst = ut_params->obuf;
14228 /* Process crypto operation */
14229 if (oop == IN_PLACE &&
14230 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14231 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
14232 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14233 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14234 ut_params->op, 0, 0, 0, 0);
14236 TEST_ASSERT_NOT_NULL(
14237 process_crypto_request(ts_params->valid_devs[0],
14238 ut_params->op), "failed to process sym crypto op");
14240 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14241 "crypto op processing failed");
14244 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
14245 uint8_t *, prepend_len);
14247 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14248 uint8_t *, prepend_len);
14252 fragsz = fragsz_oop;
14254 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14256 tdata->ciphertext.data,
14258 "Ciphertext data not as expected");
14260 buf = ut_params->op->sym->m_src->next;
14262 buf = ut_params->op->sym->m_dst->next;
14264 unsigned int off = fragsz;
14268 ciphertext = rte_pktmbuf_mtod(buf,
14271 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14273 tdata->ciphertext.data + off,
14275 "Ciphertext data not as expected");
14277 off += to_trn_tbl[ecx++];
14281 auth_tag = digest_mem;
14282 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14284 tdata->auth_tag.data,
14285 tdata->auth_tag.len,
14286 "Generated auth tag not as expected");
14292 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
14294 return test_authenticated_encryption_SGL(
14295 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
14299 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
14301 return test_authenticated_encryption_SGL(
14302 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
14306 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
14308 return test_authenticated_encryption_SGL(
14309 &gcm_test_case_8, OUT_OF_PLACE, 400,
14310 gcm_test_case_8.plaintext.len);
14314 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
14316 /* This test is not for OPENSSL PMD */
14317 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14318 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
14319 return TEST_SKIPPED;
14321 return test_authenticated_encryption_SGL(
14322 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
14326 test_authentication_verify_fail_when_data_corrupted(
14327 struct crypto_testsuite_params *ts_params,
14328 struct crypto_unittest_params *ut_params,
14329 const struct test_crypto_vector *reference)
14331 return test_authentication_verify_fail_when_data_corruption(
14332 ts_params, ut_params, reference, 1);
14336 test_authentication_verify_fail_when_tag_corrupted(
14337 struct crypto_testsuite_params *ts_params,
14338 struct crypto_unittest_params *ut_params,
14339 const struct test_crypto_vector *reference)
14341 return test_authentication_verify_fail_when_data_corruption(
14342 ts_params, ut_params, reference, 0);
14346 test_authentication_verify_GMAC_fail_when_data_corrupted(
14347 struct crypto_testsuite_params *ts_params,
14348 struct crypto_unittest_params *ut_params,
14349 const struct test_crypto_vector *reference)
14351 return test_authentication_verify_GMAC_fail_when_corruption(
14352 ts_params, ut_params, reference, 1);
14356 test_authentication_verify_GMAC_fail_when_tag_corrupted(
14357 struct crypto_testsuite_params *ts_params,
14358 struct crypto_unittest_params *ut_params,
14359 const struct test_crypto_vector *reference)
14361 return test_authentication_verify_GMAC_fail_when_corruption(
14362 ts_params, ut_params, reference, 0);
14366 test_authenticated_decryption_fail_when_data_corrupted(
14367 struct crypto_testsuite_params *ts_params,
14368 struct crypto_unittest_params *ut_params,
14369 const struct test_crypto_vector *reference)
14371 return test_authenticated_decryption_fail_when_corruption(
14372 ts_params, ut_params, reference, 1);
14376 test_authenticated_decryption_fail_when_tag_corrupted(
14377 struct crypto_testsuite_params *ts_params,
14378 struct crypto_unittest_params *ut_params,
14379 const struct test_crypto_vector *reference)
14381 return test_authenticated_decryption_fail_when_corruption(
14382 ts_params, ut_params, reference, 0);
14386 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
14388 return test_authentication_verify_fail_when_data_corrupted(
14389 &testsuite_params, &unittest_params,
14390 &hmac_sha1_test_crypto_vector);
14394 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
14396 return test_authentication_verify_fail_when_tag_corrupted(
14397 &testsuite_params, &unittest_params,
14398 &hmac_sha1_test_crypto_vector);
14402 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
14404 return test_authentication_verify_GMAC_fail_when_data_corrupted(
14405 &testsuite_params, &unittest_params,
14406 &aes128_gmac_test_vector);
14410 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
14412 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
14413 &testsuite_params, &unittest_params,
14414 &aes128_gmac_test_vector);
14418 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
14420 return test_authenticated_decryption_fail_when_data_corrupted(
14423 &aes128cbc_hmac_sha1_test_vector);
14427 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
14429 return test_authenticated_decryption_fail_when_tag_corrupted(
14432 &aes128cbc_hmac_sha1_test_vector);
14436 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14438 return test_authenticated_encrypt_with_esn(
14441 &aes128cbc_hmac_sha1_aad_test_vector);
14445 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14447 return test_authenticated_decrypt_with_esn(
14450 &aes128cbc_hmac_sha1_aad_test_vector);
14454 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
14456 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
14460 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
14462 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
14466 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
14468 return test_authenticated_encryption_SGL(
14469 &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
14470 chacha20_poly1305_case_2.plaintext.len);
14473 #ifdef RTE_CRYPTO_SCHEDULER
14475 /* global AESNI worker IDs for the scheduler test */
14476 uint8_t aesni_ids[2];
14479 scheduler_testsuite_setup(void)
14482 int32_t nb_devs, ret;
14483 char vdev_args[VDEV_ARGS_SIZE] = {""};
14484 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14485 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
14486 uint16_t worker_core_count = 0;
14487 uint16_t socket_id = 0;
14489 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14490 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14492 /* Identify the Worker Cores
14493 * Use 2 worker cores for the device args
14495 RTE_LCORE_FOREACH_WORKER(i) {
14496 if (worker_core_count > 1)
14498 snprintf(vdev_args, sizeof(vdev_args),
14499 "%s%d", temp_str, i);
14500 strcpy(temp_str, vdev_args);
14501 strlcat(temp_str, ";", sizeof(temp_str));
14502 worker_core_count++;
14503 socket_id = rte_lcore_to_socket_id(i);
14505 if (worker_core_count != 2) {
14506 RTE_LOG(ERR, USER1,
14507 "Cryptodev scheduler test require at least "
14508 "two worker cores to run. "
14509 "Please use the correct coremask.\n");
14510 return TEST_FAILED;
14512 strcpy(temp_str, vdev_args);
14513 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14514 temp_str, socket_id);
14515 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14516 nb_devs = rte_cryptodev_device_count_by_driver(
14517 rte_cryptodev_driver_id_get(
14518 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14520 ret = rte_vdev_init(
14521 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14523 TEST_ASSERT(ret == 0,
14524 "Failed to create instance %u of pmd : %s",
14525 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14528 return testsuite_setup();
14532 test_scheduler_attach_worker_op(void)
14534 struct crypto_testsuite_params *ts_params = &testsuite_params;
14535 uint8_t sched_id = ts_params->valid_devs[0];
14536 uint32_t i, nb_devs_attached = 0;
14538 char vdev_name[32];
14539 unsigned int count = rte_cryptodev_count();
14541 /* create 2 AESNI_MB vdevs on top of existing devices */
14542 for (i = count; i < count + 2; i++) {
14543 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14544 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14546 ret = rte_vdev_init(vdev_name, NULL);
14548 TEST_ASSERT(ret == 0,
14549 "Failed to create instance %u of"
14551 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14554 RTE_LOG(ERR, USER1,
14555 "Failed to create 2 AESNI MB PMDs.\n");
14556 return TEST_SKIPPED;
14560 /* attach 2 AESNI_MB cdevs */
14561 for (i = count; i < count + 2; i++) {
14562 struct rte_cryptodev_info info;
14563 unsigned int session_size;
14565 rte_cryptodev_info_get(i, &info);
14566 if (info.driver_id != rte_cryptodev_driver_id_get(
14567 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14570 session_size = rte_cryptodev_sym_get_private_session_size(i);
14572 * Create the session mempool again, since now there are new devices
14573 * to use the mempool.
14575 if (ts_params->session_mpool) {
14576 rte_mempool_free(ts_params->session_mpool);
14577 ts_params->session_mpool = NULL;
14579 if (ts_params->session_priv_mpool) {
14580 rte_mempool_free(ts_params->session_priv_mpool);
14581 ts_params->session_priv_mpool = NULL;
14584 if (info.sym.max_nb_sessions != 0 &&
14585 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14586 RTE_LOG(ERR, USER1,
14587 "Device does not support "
14588 "at least %u sessions\n",
14590 return TEST_FAILED;
14593 * Create mempool with maximum number of sessions,
14594 * to include the session headers
14596 if (ts_params->session_mpool == NULL) {
14597 ts_params->session_mpool =
14598 rte_cryptodev_sym_session_pool_create(
14600 MAX_NB_SESSIONS, 0, 0, 0,
14602 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14603 "session mempool allocation failed");
14607 * Create mempool with maximum number of sessions,
14608 * to include device specific session private data
14610 if (ts_params->session_priv_mpool == NULL) {
14611 ts_params->session_priv_mpool = rte_mempool_create(
14612 "test_sess_mp_priv",
14615 0, 0, NULL, NULL, NULL,
14616 NULL, SOCKET_ID_ANY,
14619 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14620 "session mempool allocation failed");
14623 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14624 ts_params->qp_conf.mp_session_private =
14625 ts_params->session_priv_mpool;
14627 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14630 TEST_ASSERT(ret == 0,
14631 "Failed to attach device %u of pmd : %s", i,
14632 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14634 aesni_ids[nb_devs_attached] = (uint8_t)i;
14636 nb_devs_attached++;
14643 test_scheduler_detach_worker_op(void)
14645 struct crypto_testsuite_params *ts_params = &testsuite_params;
14646 uint8_t sched_id = ts_params->valid_devs[0];
14650 for (i = 0; i < 2; i++) {
14651 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14653 TEST_ASSERT(ret == 0,
14654 "Failed to detach device %u", aesni_ids[i]);
14661 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14663 struct crypto_testsuite_params *ts_params = &testsuite_params;
14664 uint8_t sched_id = ts_params->valid_devs[0];
14666 return rte_cryptodev_scheduler_mode_set(sched_id,
14671 test_scheduler_mode_roundrobin_op(void)
14673 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14674 0, "Failed to set roundrobin mode");
14680 test_scheduler_mode_multicore_op(void)
14682 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14683 0, "Failed to set multicore mode");
14689 test_scheduler_mode_failover_op(void)
14691 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
14692 0, "Failed to set failover mode");
14698 test_scheduler_mode_pkt_size_distr_op(void)
14700 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
14701 0, "Failed to set pktsize mode");
14707 scheduler_multicore_testsuite_setup(void)
14709 if (test_scheduler_attach_worker_op() < 0)
14710 return TEST_SKIPPED;
14711 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
14712 return TEST_SKIPPED;
14717 scheduler_roundrobin_testsuite_setup(void)
14719 if (test_scheduler_attach_worker_op() < 0)
14720 return TEST_SKIPPED;
14721 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
14722 return TEST_SKIPPED;
14727 scheduler_failover_testsuite_setup(void)
14729 if (test_scheduler_attach_worker_op() < 0)
14730 return TEST_SKIPPED;
14731 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
14732 return TEST_SKIPPED;
14737 scheduler_pkt_size_distr_testsuite_setup(void)
14739 if (test_scheduler_attach_worker_op() < 0)
14740 return TEST_SKIPPED;
14741 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14742 return TEST_SKIPPED;
14747 scheduler_mode_testsuite_teardown(void)
14749 test_scheduler_detach_worker_op();
14752 #endif /* RTE_CRYPTO_SCHEDULER */
14754 static struct unit_test_suite end_testsuite = {
14755 .suite_name = NULL,
14758 .unit_test_suites = NULL
14761 #ifdef RTE_LIB_SECURITY
14762 static struct unit_test_suite ipsec_proto_testsuite = {
14763 .suite_name = "IPsec Proto Unit Test Suite",
14764 .setup = ipsec_proto_testsuite_setup,
14765 .unit_test_cases = {
14766 TEST_CASE_NAMED_WITH_DATA(
14767 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14768 ut_setup_security, ut_teardown,
14769 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
14770 TEST_CASE_NAMED_WITH_DATA(
14771 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14772 ut_setup_security, ut_teardown,
14773 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
14774 TEST_CASE_NAMED_WITH_DATA(
14775 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14776 ut_setup_security, ut_teardown,
14777 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
14778 TEST_CASE_NAMED_WITH_DATA(
14779 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14780 ut_setup_security, ut_teardown,
14781 test_ipsec_proto_known_vec,
14782 &pkt_aes_128_cbc_hmac_sha256),
14783 TEST_CASE_NAMED_WITH_DATA(
14784 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
14785 ut_setup_security, ut_teardown,
14786 test_ipsec_proto_known_vec,
14787 &pkt_aes_128_cbc_hmac_sha384),
14788 TEST_CASE_NAMED_WITH_DATA(
14789 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
14790 ut_setup_security, ut_teardown,
14791 test_ipsec_proto_known_vec,
14792 &pkt_aes_128_cbc_hmac_sha512),
14793 TEST_CASE_NAMED_WITH_DATA(
14794 "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
14795 ut_setup_security, ut_teardown,
14796 test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
14797 TEST_CASE_NAMED_WITH_DATA(
14798 "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14799 ut_setup_security, ut_teardown,
14800 test_ipsec_proto_known_vec,
14801 &pkt_aes_128_cbc_hmac_sha256_v6),
14802 TEST_CASE_NAMED_WITH_DATA(
14803 "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
14804 ut_setup_security, ut_teardown,
14805 test_ipsec_proto_known_vec,
14806 &pkt_null_aes_xcbc),
14807 TEST_CASE_NAMED_WITH_DATA(
14808 "Outbound fragmented packet",
14809 ut_setup_security, ut_teardown,
14810 test_ipsec_proto_known_vec_fragmented,
14811 &pkt_aes_128_gcm_frag),
14812 TEST_CASE_NAMED_WITH_DATA(
14813 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14814 ut_setup_security, ut_teardown,
14815 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14816 TEST_CASE_NAMED_WITH_DATA(
14817 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14818 ut_setup_security, ut_teardown,
14819 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14820 TEST_CASE_NAMED_WITH_DATA(
14821 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14822 ut_setup_security, ut_teardown,
14823 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14824 TEST_CASE_NAMED_WITH_DATA(
14825 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
14826 ut_setup_security, ut_teardown,
14827 test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
14828 TEST_CASE_NAMED_WITH_DATA(
14829 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14830 ut_setup_security, ut_teardown,
14831 test_ipsec_proto_known_vec_inb,
14832 &pkt_aes_128_cbc_hmac_sha256),
14833 TEST_CASE_NAMED_WITH_DATA(
14834 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
14835 ut_setup_security, ut_teardown,
14836 test_ipsec_proto_known_vec_inb,
14837 &pkt_aes_128_cbc_hmac_sha384),
14838 TEST_CASE_NAMED_WITH_DATA(
14839 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
14840 ut_setup_security, ut_teardown,
14841 test_ipsec_proto_known_vec_inb,
14842 &pkt_aes_128_cbc_hmac_sha512),
14843 TEST_CASE_NAMED_WITH_DATA(
14844 "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
14845 ut_setup_security, ut_teardown,
14846 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
14847 TEST_CASE_NAMED_WITH_DATA(
14848 "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14849 ut_setup_security, ut_teardown,
14850 test_ipsec_proto_known_vec_inb,
14851 &pkt_aes_128_cbc_hmac_sha256_v6),
14852 TEST_CASE_NAMED_WITH_DATA(
14853 "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
14854 ut_setup_security, ut_teardown,
14855 test_ipsec_proto_known_vec_inb,
14856 &pkt_null_aes_xcbc),
14857 TEST_CASE_NAMED_ST(
14858 "Combined test alg list",
14859 ut_setup_security, ut_teardown,
14860 test_ipsec_proto_display_list),
14861 TEST_CASE_NAMED_ST(
14863 ut_setup_security, ut_teardown,
14864 test_ipsec_proto_iv_gen),
14865 TEST_CASE_NAMED_ST(
14866 "UDP encapsulation",
14867 ut_setup_security, ut_teardown,
14868 test_ipsec_proto_udp_encap),
14869 TEST_CASE_NAMED_ST(
14870 "UDP encapsulation ports verification test",
14871 ut_setup_security, ut_teardown,
14872 test_ipsec_proto_udp_ports_verify),
14873 TEST_CASE_NAMED_ST(
14874 "SA expiry packets soft",
14875 ut_setup_security, ut_teardown,
14876 test_ipsec_proto_sa_exp_pkts_soft),
14877 TEST_CASE_NAMED_ST(
14878 "SA expiry packets hard",
14879 ut_setup_security, ut_teardown,
14880 test_ipsec_proto_sa_exp_pkts_hard),
14881 TEST_CASE_NAMED_ST(
14882 "Negative test: ICV corruption",
14883 ut_setup_security, ut_teardown,
14884 test_ipsec_proto_err_icv_corrupt),
14885 TEST_CASE_NAMED_ST(
14886 "Tunnel dst addr verification",
14887 ut_setup_security, ut_teardown,
14888 test_ipsec_proto_tunnel_dst_addr_verify),
14889 TEST_CASE_NAMED_ST(
14890 "Tunnel src and dst addr verification",
14891 ut_setup_security, ut_teardown,
14892 test_ipsec_proto_tunnel_src_dst_addr_verify),
14893 TEST_CASE_NAMED_ST(
14894 "Inner IP checksum",
14895 ut_setup_security, ut_teardown,
14896 test_ipsec_proto_inner_ip_csum),
14897 TEST_CASE_NAMED_ST(
14898 "Inner L4 checksum",
14899 ut_setup_security, ut_teardown,
14900 test_ipsec_proto_inner_l4_csum),
14901 TEST_CASE_NAMED_ST(
14902 "Tunnel IPv4 in IPv4",
14903 ut_setup_security, ut_teardown,
14904 test_ipsec_proto_tunnel_v4_in_v4),
14905 TEST_CASE_NAMED_ST(
14906 "Tunnel IPv6 in IPv6",
14907 ut_setup_security, ut_teardown,
14908 test_ipsec_proto_tunnel_v6_in_v6),
14909 TEST_CASE_NAMED_ST(
14910 "Tunnel IPv4 in IPv6",
14911 ut_setup_security, ut_teardown,
14912 test_ipsec_proto_tunnel_v4_in_v6),
14913 TEST_CASE_NAMED_ST(
14914 "Tunnel IPv6 in IPv4",
14915 ut_setup_security, ut_teardown,
14916 test_ipsec_proto_tunnel_v6_in_v4),
14917 TEST_CASE_NAMED_ST(
14919 ut_setup_security, ut_teardown,
14920 test_ipsec_proto_transport_v4),
14921 TEST_CASE_NAMED_ST(
14922 "Statistics: success",
14923 ut_setup_security, ut_teardown,
14924 test_ipsec_proto_stats),
14925 TEST_CASE_NAMED_ST(
14926 "Fragmented packet",
14927 ut_setup_security, ut_teardown,
14928 test_ipsec_proto_pkt_fragment),
14929 TEST_CASE_NAMED_ST(
14930 "Tunnel header copy DF (inner 0)",
14931 ut_setup_security, ut_teardown,
14932 test_ipsec_proto_copy_df_inner_0),
14933 TEST_CASE_NAMED_ST(
14934 "Tunnel header copy DF (inner 1)",
14935 ut_setup_security, ut_teardown,
14936 test_ipsec_proto_copy_df_inner_1),
14937 TEST_CASE_NAMED_ST(
14938 "Tunnel header set DF 0 (inner 1)",
14939 ut_setup_security, ut_teardown,
14940 test_ipsec_proto_set_df_0_inner_1),
14941 TEST_CASE_NAMED_ST(
14942 "Tunnel header set DF 1 (inner 0)",
14943 ut_setup_security, ut_teardown,
14944 test_ipsec_proto_set_df_1_inner_0),
14945 TEST_CASE_NAMED_ST(
14946 "Tunnel header IPv4 copy DSCP (inner 0)",
14947 ut_setup_security, ut_teardown,
14948 test_ipsec_proto_ipv4_copy_dscp_inner_0),
14949 TEST_CASE_NAMED_ST(
14950 "Tunnel header IPv4 copy DSCP (inner 1)",
14951 ut_setup_security, ut_teardown,
14952 test_ipsec_proto_ipv4_copy_dscp_inner_1),
14953 TEST_CASE_NAMED_ST(
14954 "Tunnel header IPv4 set DSCP 0 (inner 1)",
14955 ut_setup_security, ut_teardown,
14956 test_ipsec_proto_ipv4_set_dscp_0_inner_1),
14957 TEST_CASE_NAMED_ST(
14958 "Tunnel header IPv4 set DSCP 1 (inner 0)",
14959 ut_setup_security, ut_teardown,
14960 test_ipsec_proto_ipv4_set_dscp_1_inner_0),
14961 TEST_CASE_NAMED_ST(
14962 "Tunnel header IPv6 copy DSCP (inner 0)",
14963 ut_setup_security, ut_teardown,
14964 test_ipsec_proto_ipv6_copy_dscp_inner_0),
14965 TEST_CASE_NAMED_ST(
14966 "Tunnel header IPv6 copy DSCP (inner 1)",
14967 ut_setup_security, ut_teardown,
14968 test_ipsec_proto_ipv6_copy_dscp_inner_1),
14969 TEST_CASE_NAMED_ST(
14970 "Tunnel header IPv6 set DSCP 0 (inner 1)",
14971 ut_setup_security, ut_teardown,
14972 test_ipsec_proto_ipv6_set_dscp_0_inner_1),
14973 TEST_CASE_NAMED_ST(
14974 "Tunnel header IPv6 set DSCP 1 (inner 0)",
14975 ut_setup_security, ut_teardown,
14976 test_ipsec_proto_ipv6_set_dscp_1_inner_0),
14977 TEST_CASES_END() /**< NULL terminate unit test array */
14981 static struct unit_test_suite pdcp_proto_testsuite = {
14982 .suite_name = "PDCP Proto Unit Test Suite",
14983 .setup = pdcp_proto_testsuite_setup,
14984 .unit_test_cases = {
14985 TEST_CASE_ST(ut_setup_security, ut_teardown,
14986 test_PDCP_PROTO_all),
14987 TEST_CASES_END() /**< NULL terminate unit test array */
14991 #define ADD_UPLINK_TESTCASE(data) \
14992 TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
14993 ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
14995 #define ADD_DOWNLINK_TESTCASE(data) \
14996 TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
14997 ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
14999 static struct unit_test_suite docsis_proto_testsuite = {
15000 .suite_name = "DOCSIS Proto Unit Test Suite",
15001 .setup = docsis_proto_testsuite_setup,
15002 .unit_test_cases = {
15004 ADD_UPLINK_TESTCASE(docsis_test_case_1)
15005 ADD_UPLINK_TESTCASE(docsis_test_case_2)
15006 ADD_UPLINK_TESTCASE(docsis_test_case_3)
15007 ADD_UPLINK_TESTCASE(docsis_test_case_4)
15008 ADD_UPLINK_TESTCASE(docsis_test_case_5)
15009 ADD_UPLINK_TESTCASE(docsis_test_case_6)
15010 ADD_UPLINK_TESTCASE(docsis_test_case_7)
15011 ADD_UPLINK_TESTCASE(docsis_test_case_8)
15012 ADD_UPLINK_TESTCASE(docsis_test_case_9)
15013 ADD_UPLINK_TESTCASE(docsis_test_case_10)
15014 ADD_UPLINK_TESTCASE(docsis_test_case_11)
15015 ADD_UPLINK_TESTCASE(docsis_test_case_12)
15016 ADD_UPLINK_TESTCASE(docsis_test_case_13)
15017 ADD_UPLINK_TESTCASE(docsis_test_case_14)
15018 ADD_UPLINK_TESTCASE(docsis_test_case_15)
15019 ADD_UPLINK_TESTCASE(docsis_test_case_16)
15020 ADD_UPLINK_TESTCASE(docsis_test_case_17)
15021 ADD_UPLINK_TESTCASE(docsis_test_case_18)
15022 ADD_UPLINK_TESTCASE(docsis_test_case_19)
15023 ADD_UPLINK_TESTCASE(docsis_test_case_20)
15024 ADD_UPLINK_TESTCASE(docsis_test_case_21)
15025 ADD_UPLINK_TESTCASE(docsis_test_case_22)
15026 ADD_UPLINK_TESTCASE(docsis_test_case_23)
15027 ADD_UPLINK_TESTCASE(docsis_test_case_24)
15028 ADD_UPLINK_TESTCASE(docsis_test_case_25)
15029 ADD_UPLINK_TESTCASE(docsis_test_case_26)
15031 ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
15032 ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
15033 ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
15034 ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
15035 ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
15036 ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
15037 ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
15038 ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
15039 ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
15040 ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
15041 ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
15042 ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
15043 ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
15044 ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
15045 ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
15046 ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
15047 ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
15048 ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
15049 ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
15050 ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
15051 ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
15052 ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
15053 ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
15054 ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
15055 ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
15056 ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
15057 TEST_CASES_END() /**< NULL terminate unit test array */
15062 static struct unit_test_suite cryptodev_gen_testsuite = {
15063 .suite_name = "Crypto General Unit Test Suite",
15064 .setup = crypto_gen_testsuite_setup,
15065 .unit_test_cases = {
15066 TEST_CASE_ST(ut_setup, ut_teardown,
15067 test_device_configure_invalid_dev_id),
15068 TEST_CASE_ST(ut_setup, ut_teardown,
15069 test_queue_pair_descriptor_setup),
15070 TEST_CASE_ST(ut_setup, ut_teardown,
15071 test_device_configure_invalid_queue_pair_ids),
15072 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
15073 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
15074 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
15075 TEST_CASES_END() /**< NULL terminate unit test array */
15079 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
15080 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
15081 .setup = negative_hmac_sha1_testsuite_setup,
15082 .unit_test_cases = {
15083 /** Negative tests */
15084 TEST_CASE_ST(ut_setup, ut_teardown,
15085 authentication_verify_HMAC_SHA1_fail_data_corrupt),
15086 TEST_CASE_ST(ut_setup, ut_teardown,
15087 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
15088 TEST_CASE_ST(ut_setup, ut_teardown,
15089 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
15090 TEST_CASE_ST(ut_setup, ut_teardown,
15091 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
15093 TEST_CASES_END() /**< NULL terminate unit test array */
15097 static struct unit_test_suite cryptodev_multi_session_testsuite = {
15098 .suite_name = "Multi Session Unit Test Suite",
15099 .setup = multi_session_testsuite_setup,
15100 .unit_test_cases = {
15101 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
15102 TEST_CASE_ST(ut_setup, ut_teardown,
15103 test_multi_session_random_usage),
15105 TEST_CASES_END() /**< NULL terminate unit test array */
15109 static struct unit_test_suite cryptodev_null_testsuite = {
15110 .suite_name = "NULL Test Suite",
15111 .setup = null_testsuite_setup,
15112 .unit_test_cases = {
15113 TEST_CASE_ST(ut_setup, ut_teardown,
15114 test_null_invalid_operation),
15115 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
15120 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
15121 .suite_name = "AES CCM Authenticated Test Suite",
15122 .setup = aes_ccm_auth_testsuite_setup,
15123 .unit_test_cases = {
15124 /** AES CCM Authenticated Encryption 128 bits key*/
15125 TEST_CASE_ST(ut_setup, ut_teardown,
15126 test_AES_CCM_authenticated_encryption_test_case_128_1),
15127 TEST_CASE_ST(ut_setup, ut_teardown,
15128 test_AES_CCM_authenticated_encryption_test_case_128_2),
15129 TEST_CASE_ST(ut_setup, ut_teardown,
15130 test_AES_CCM_authenticated_encryption_test_case_128_3),
15132 /** AES CCM Authenticated Decryption 128 bits key*/
15133 TEST_CASE_ST(ut_setup, ut_teardown,
15134 test_AES_CCM_authenticated_decryption_test_case_128_1),
15135 TEST_CASE_ST(ut_setup, ut_teardown,
15136 test_AES_CCM_authenticated_decryption_test_case_128_2),
15137 TEST_CASE_ST(ut_setup, ut_teardown,
15138 test_AES_CCM_authenticated_decryption_test_case_128_3),
15140 /** AES CCM Authenticated Encryption 192 bits key */
15141 TEST_CASE_ST(ut_setup, ut_teardown,
15142 test_AES_CCM_authenticated_encryption_test_case_192_1),
15143 TEST_CASE_ST(ut_setup, ut_teardown,
15144 test_AES_CCM_authenticated_encryption_test_case_192_2),
15145 TEST_CASE_ST(ut_setup, ut_teardown,
15146 test_AES_CCM_authenticated_encryption_test_case_192_3),
15148 /** AES CCM Authenticated Decryption 192 bits key*/
15149 TEST_CASE_ST(ut_setup, ut_teardown,
15150 test_AES_CCM_authenticated_decryption_test_case_192_1),
15151 TEST_CASE_ST(ut_setup, ut_teardown,
15152 test_AES_CCM_authenticated_decryption_test_case_192_2),
15153 TEST_CASE_ST(ut_setup, ut_teardown,
15154 test_AES_CCM_authenticated_decryption_test_case_192_3),
15156 /** AES CCM Authenticated Encryption 256 bits key */
15157 TEST_CASE_ST(ut_setup, ut_teardown,
15158 test_AES_CCM_authenticated_encryption_test_case_256_1),
15159 TEST_CASE_ST(ut_setup, ut_teardown,
15160 test_AES_CCM_authenticated_encryption_test_case_256_2),
15161 TEST_CASE_ST(ut_setup, ut_teardown,
15162 test_AES_CCM_authenticated_encryption_test_case_256_3),
15164 /** AES CCM Authenticated Decryption 256 bits key*/
15165 TEST_CASE_ST(ut_setup, ut_teardown,
15166 test_AES_CCM_authenticated_decryption_test_case_256_1),
15167 TEST_CASE_ST(ut_setup, ut_teardown,
15168 test_AES_CCM_authenticated_decryption_test_case_256_2),
15169 TEST_CASE_ST(ut_setup, ut_teardown,
15170 test_AES_CCM_authenticated_decryption_test_case_256_3),
15175 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
15176 .suite_name = "AES GCM Authenticated Test Suite",
15177 .setup = aes_gcm_auth_testsuite_setup,
15178 .unit_test_cases = {
15179 /** AES GCM Authenticated Encryption */
15180 TEST_CASE_ST(ut_setup, ut_teardown,
15181 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
15182 TEST_CASE_ST(ut_setup, ut_teardown,
15183 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
15184 TEST_CASE_ST(ut_setup, ut_teardown,
15185 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
15186 TEST_CASE_ST(ut_setup, ut_teardown,
15187 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
15188 TEST_CASE_ST(ut_setup, ut_teardown,
15189 test_AES_GCM_authenticated_encryption_test_case_1),
15190 TEST_CASE_ST(ut_setup, ut_teardown,
15191 test_AES_GCM_authenticated_encryption_test_case_2),
15192 TEST_CASE_ST(ut_setup, ut_teardown,
15193 test_AES_GCM_authenticated_encryption_test_case_3),
15194 TEST_CASE_ST(ut_setup, ut_teardown,
15195 test_AES_GCM_authenticated_encryption_test_case_4),
15196 TEST_CASE_ST(ut_setup, ut_teardown,
15197 test_AES_GCM_authenticated_encryption_test_case_5),
15198 TEST_CASE_ST(ut_setup, ut_teardown,
15199 test_AES_GCM_authenticated_encryption_test_case_6),
15200 TEST_CASE_ST(ut_setup, ut_teardown,
15201 test_AES_GCM_authenticated_encryption_test_case_7),
15202 TEST_CASE_ST(ut_setup, ut_teardown,
15203 test_AES_GCM_authenticated_encryption_test_case_8),
15204 TEST_CASE_ST(ut_setup, ut_teardown,
15205 test_AES_GCM_J0_authenticated_encryption_test_case_1),
15207 /** AES GCM Authenticated Decryption */
15208 TEST_CASE_ST(ut_setup, ut_teardown,
15209 test_AES_GCM_authenticated_decryption_test_case_1),
15210 TEST_CASE_ST(ut_setup, ut_teardown,
15211 test_AES_GCM_authenticated_decryption_test_case_2),
15212 TEST_CASE_ST(ut_setup, ut_teardown,
15213 test_AES_GCM_authenticated_decryption_test_case_3),
15214 TEST_CASE_ST(ut_setup, ut_teardown,
15215 test_AES_GCM_authenticated_decryption_test_case_4),
15216 TEST_CASE_ST(ut_setup, ut_teardown,
15217 test_AES_GCM_authenticated_decryption_test_case_5),
15218 TEST_CASE_ST(ut_setup, ut_teardown,
15219 test_AES_GCM_authenticated_decryption_test_case_6),
15220 TEST_CASE_ST(ut_setup, ut_teardown,
15221 test_AES_GCM_authenticated_decryption_test_case_7),
15222 TEST_CASE_ST(ut_setup, ut_teardown,
15223 test_AES_GCM_authenticated_decryption_test_case_8),
15224 TEST_CASE_ST(ut_setup, ut_teardown,
15225 test_AES_GCM_J0_authenticated_decryption_test_case_1),
15227 /** AES GCM Authenticated Encryption 192 bits key */
15228 TEST_CASE_ST(ut_setup, ut_teardown,
15229 test_AES_GCM_auth_encryption_test_case_192_1),
15230 TEST_CASE_ST(ut_setup, ut_teardown,
15231 test_AES_GCM_auth_encryption_test_case_192_2),
15232 TEST_CASE_ST(ut_setup, ut_teardown,
15233 test_AES_GCM_auth_encryption_test_case_192_3),
15234 TEST_CASE_ST(ut_setup, ut_teardown,
15235 test_AES_GCM_auth_encryption_test_case_192_4),
15236 TEST_CASE_ST(ut_setup, ut_teardown,
15237 test_AES_GCM_auth_encryption_test_case_192_5),
15238 TEST_CASE_ST(ut_setup, ut_teardown,
15239 test_AES_GCM_auth_encryption_test_case_192_6),
15240 TEST_CASE_ST(ut_setup, ut_teardown,
15241 test_AES_GCM_auth_encryption_test_case_192_7),
15243 /** AES GCM Authenticated Decryption 192 bits key */
15244 TEST_CASE_ST(ut_setup, ut_teardown,
15245 test_AES_GCM_auth_decryption_test_case_192_1),
15246 TEST_CASE_ST(ut_setup, ut_teardown,
15247 test_AES_GCM_auth_decryption_test_case_192_2),
15248 TEST_CASE_ST(ut_setup, ut_teardown,
15249 test_AES_GCM_auth_decryption_test_case_192_3),
15250 TEST_CASE_ST(ut_setup, ut_teardown,
15251 test_AES_GCM_auth_decryption_test_case_192_4),
15252 TEST_CASE_ST(ut_setup, ut_teardown,
15253 test_AES_GCM_auth_decryption_test_case_192_5),
15254 TEST_CASE_ST(ut_setup, ut_teardown,
15255 test_AES_GCM_auth_decryption_test_case_192_6),
15256 TEST_CASE_ST(ut_setup, ut_teardown,
15257 test_AES_GCM_auth_decryption_test_case_192_7),
15259 /** AES GCM Authenticated Encryption 256 bits key */
15260 TEST_CASE_ST(ut_setup, ut_teardown,
15261 test_AES_GCM_auth_encryption_test_case_256_1),
15262 TEST_CASE_ST(ut_setup, ut_teardown,
15263 test_AES_GCM_auth_encryption_test_case_256_2),
15264 TEST_CASE_ST(ut_setup, ut_teardown,
15265 test_AES_GCM_auth_encryption_test_case_256_3),
15266 TEST_CASE_ST(ut_setup, ut_teardown,
15267 test_AES_GCM_auth_encryption_test_case_256_4),
15268 TEST_CASE_ST(ut_setup, ut_teardown,
15269 test_AES_GCM_auth_encryption_test_case_256_5),
15270 TEST_CASE_ST(ut_setup, ut_teardown,
15271 test_AES_GCM_auth_encryption_test_case_256_6),
15272 TEST_CASE_ST(ut_setup, ut_teardown,
15273 test_AES_GCM_auth_encryption_test_case_256_7),
15275 /** AES GCM Authenticated Decryption 256 bits key */
15276 TEST_CASE_ST(ut_setup, ut_teardown,
15277 test_AES_GCM_auth_decryption_test_case_256_1),
15278 TEST_CASE_ST(ut_setup, ut_teardown,
15279 test_AES_GCM_auth_decryption_test_case_256_2),
15280 TEST_CASE_ST(ut_setup, ut_teardown,
15281 test_AES_GCM_auth_decryption_test_case_256_3),
15282 TEST_CASE_ST(ut_setup, ut_teardown,
15283 test_AES_GCM_auth_decryption_test_case_256_4),
15284 TEST_CASE_ST(ut_setup, ut_teardown,
15285 test_AES_GCM_auth_decryption_test_case_256_5),
15286 TEST_CASE_ST(ut_setup, ut_teardown,
15287 test_AES_GCM_auth_decryption_test_case_256_6),
15288 TEST_CASE_ST(ut_setup, ut_teardown,
15289 test_AES_GCM_auth_decryption_test_case_256_7),
15291 /** AES GCM Authenticated Encryption big aad size */
15292 TEST_CASE_ST(ut_setup, ut_teardown,
15293 test_AES_GCM_auth_encryption_test_case_aad_1),
15294 TEST_CASE_ST(ut_setup, ut_teardown,
15295 test_AES_GCM_auth_encryption_test_case_aad_2),
15297 /** AES GCM Authenticated Decryption big aad size */
15298 TEST_CASE_ST(ut_setup, ut_teardown,
15299 test_AES_GCM_auth_decryption_test_case_aad_1),
15300 TEST_CASE_ST(ut_setup, ut_teardown,
15301 test_AES_GCM_auth_decryption_test_case_aad_2),
15303 /** Out of place tests */
15304 TEST_CASE_ST(ut_setup, ut_teardown,
15305 test_AES_GCM_authenticated_encryption_oop_test_case_1),
15306 TEST_CASE_ST(ut_setup, ut_teardown,
15307 test_AES_GCM_authenticated_decryption_oop_test_case_1),
15309 /** Session-less tests */
15310 TEST_CASE_ST(ut_setup, ut_teardown,
15311 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
15312 TEST_CASE_ST(ut_setup, ut_teardown,
15313 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
15319 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
15320 .suite_name = "AES GMAC Authentication Test Suite",
15321 .setup = aes_gmac_auth_testsuite_setup,
15322 .unit_test_cases = {
15323 TEST_CASE_ST(ut_setup, ut_teardown,
15324 test_AES_GMAC_authentication_test_case_1),
15325 TEST_CASE_ST(ut_setup, ut_teardown,
15326 test_AES_GMAC_authentication_verify_test_case_1),
15327 TEST_CASE_ST(ut_setup, ut_teardown,
15328 test_AES_GMAC_authentication_test_case_2),
15329 TEST_CASE_ST(ut_setup, ut_teardown,
15330 test_AES_GMAC_authentication_verify_test_case_2),
15331 TEST_CASE_ST(ut_setup, ut_teardown,
15332 test_AES_GMAC_authentication_test_case_3),
15333 TEST_CASE_ST(ut_setup, ut_teardown,
15334 test_AES_GMAC_authentication_verify_test_case_3),
15335 TEST_CASE_ST(ut_setup, ut_teardown,
15336 test_AES_GMAC_authentication_test_case_4),
15337 TEST_CASE_ST(ut_setup, ut_teardown,
15338 test_AES_GMAC_authentication_verify_test_case_4),
15339 TEST_CASE_ST(ut_setup, ut_teardown,
15340 test_AES_GMAC_authentication_SGL_40B),
15341 TEST_CASE_ST(ut_setup, ut_teardown,
15342 test_AES_GMAC_authentication_SGL_80B),
15343 TEST_CASE_ST(ut_setup, ut_teardown,
15344 test_AES_GMAC_authentication_SGL_2048B),
15345 TEST_CASE_ST(ut_setup, ut_teardown,
15346 test_AES_GMAC_authentication_SGL_2047B),
15352 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
15353 .suite_name = "Chacha20-Poly1305 Test Suite",
15354 .setup = chacha20_poly1305_testsuite_setup,
15355 .unit_test_cases = {
15356 TEST_CASE_ST(ut_setup, ut_teardown,
15357 test_chacha20_poly1305_encrypt_test_case_rfc8439),
15358 TEST_CASE_ST(ut_setup, ut_teardown,
15359 test_chacha20_poly1305_decrypt_test_case_rfc8439),
15360 TEST_CASE_ST(ut_setup, ut_teardown,
15361 test_chacha20_poly1305_encrypt_SGL_out_of_place),
15366 static struct unit_test_suite cryptodev_snow3g_testsuite = {
15367 .suite_name = "SNOW 3G Test Suite",
15368 .setup = snow3g_testsuite_setup,
15369 .unit_test_cases = {
15370 /** SNOW 3G encrypt only (UEA2) */
15371 TEST_CASE_ST(ut_setup, ut_teardown,
15372 test_snow3g_encryption_test_case_1),
15373 TEST_CASE_ST(ut_setup, ut_teardown,
15374 test_snow3g_encryption_test_case_2),
15375 TEST_CASE_ST(ut_setup, ut_teardown,
15376 test_snow3g_encryption_test_case_3),
15377 TEST_CASE_ST(ut_setup, ut_teardown,
15378 test_snow3g_encryption_test_case_4),
15379 TEST_CASE_ST(ut_setup, ut_teardown,
15380 test_snow3g_encryption_test_case_5),
15382 TEST_CASE_ST(ut_setup, ut_teardown,
15383 test_snow3g_encryption_test_case_1_oop),
15384 TEST_CASE_ST(ut_setup, ut_teardown,
15385 test_snow3g_encryption_test_case_1_oop_sgl),
15386 TEST_CASE_ST(ut_setup, ut_teardown,
15387 test_snow3g_encryption_test_case_1_offset_oop),
15388 TEST_CASE_ST(ut_setup, ut_teardown,
15389 test_snow3g_decryption_test_case_1_oop),
15391 /** SNOW 3G generate auth, then encrypt (UEA2) */
15392 TEST_CASE_ST(ut_setup, ut_teardown,
15393 test_snow3g_auth_cipher_test_case_1),
15394 TEST_CASE_ST(ut_setup, ut_teardown,
15395 test_snow3g_auth_cipher_test_case_2),
15396 TEST_CASE_ST(ut_setup, ut_teardown,
15397 test_snow3g_auth_cipher_test_case_2_oop),
15398 TEST_CASE_ST(ut_setup, ut_teardown,
15399 test_snow3g_auth_cipher_part_digest_enc),
15400 TEST_CASE_ST(ut_setup, ut_teardown,
15401 test_snow3g_auth_cipher_part_digest_enc_oop),
15402 TEST_CASE_ST(ut_setup, ut_teardown,
15403 test_snow3g_auth_cipher_test_case_3_sgl),
15404 TEST_CASE_ST(ut_setup, ut_teardown,
15405 test_snow3g_auth_cipher_test_case_3_oop_sgl),
15406 TEST_CASE_ST(ut_setup, ut_teardown,
15407 test_snow3g_auth_cipher_part_digest_enc_sgl),
15408 TEST_CASE_ST(ut_setup, ut_teardown,
15409 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
15411 /** SNOW 3G decrypt (UEA2), then verify auth */
15412 TEST_CASE_ST(ut_setup, ut_teardown,
15413 test_snow3g_auth_cipher_verify_test_case_1),
15414 TEST_CASE_ST(ut_setup, ut_teardown,
15415 test_snow3g_auth_cipher_verify_test_case_2),
15416 TEST_CASE_ST(ut_setup, ut_teardown,
15417 test_snow3g_auth_cipher_verify_test_case_2_oop),
15418 TEST_CASE_ST(ut_setup, ut_teardown,
15419 test_snow3g_auth_cipher_verify_part_digest_enc),
15420 TEST_CASE_ST(ut_setup, ut_teardown,
15421 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
15422 TEST_CASE_ST(ut_setup, ut_teardown,
15423 test_snow3g_auth_cipher_verify_test_case_3_sgl),
15424 TEST_CASE_ST(ut_setup, ut_teardown,
15425 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
15426 TEST_CASE_ST(ut_setup, ut_teardown,
15427 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
15428 TEST_CASE_ST(ut_setup, ut_teardown,
15429 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
15431 /** SNOW 3G decrypt only (UEA2) */
15432 TEST_CASE_ST(ut_setup, ut_teardown,
15433 test_snow3g_decryption_test_case_1),
15434 TEST_CASE_ST(ut_setup, ut_teardown,
15435 test_snow3g_decryption_test_case_2),
15436 TEST_CASE_ST(ut_setup, ut_teardown,
15437 test_snow3g_decryption_test_case_3),
15438 TEST_CASE_ST(ut_setup, ut_teardown,
15439 test_snow3g_decryption_test_case_4),
15440 TEST_CASE_ST(ut_setup, ut_teardown,
15441 test_snow3g_decryption_test_case_5),
15442 TEST_CASE_ST(ut_setup, ut_teardown,
15443 test_snow3g_decryption_with_digest_test_case_1),
15444 TEST_CASE_ST(ut_setup, ut_teardown,
15445 test_snow3g_hash_generate_test_case_1),
15446 TEST_CASE_ST(ut_setup, ut_teardown,
15447 test_snow3g_hash_generate_test_case_2),
15448 TEST_CASE_ST(ut_setup, ut_teardown,
15449 test_snow3g_hash_generate_test_case_3),
15451 /* Tests with buffers which length is not byte-aligned */
15452 TEST_CASE_ST(ut_setup, ut_teardown,
15453 test_snow3g_hash_generate_test_case_4),
15454 TEST_CASE_ST(ut_setup, ut_teardown,
15455 test_snow3g_hash_generate_test_case_5),
15456 TEST_CASE_ST(ut_setup, ut_teardown,
15457 test_snow3g_hash_generate_test_case_6),
15458 TEST_CASE_ST(ut_setup, ut_teardown,
15459 test_snow3g_hash_verify_test_case_1),
15460 TEST_CASE_ST(ut_setup, ut_teardown,
15461 test_snow3g_hash_verify_test_case_2),
15462 TEST_CASE_ST(ut_setup, ut_teardown,
15463 test_snow3g_hash_verify_test_case_3),
15465 /* Tests with buffers which length is not byte-aligned */
15466 TEST_CASE_ST(ut_setup, ut_teardown,
15467 test_snow3g_hash_verify_test_case_4),
15468 TEST_CASE_ST(ut_setup, ut_teardown,
15469 test_snow3g_hash_verify_test_case_5),
15470 TEST_CASE_ST(ut_setup, ut_teardown,
15471 test_snow3g_hash_verify_test_case_6),
15472 TEST_CASE_ST(ut_setup, ut_teardown,
15473 test_snow3g_cipher_auth_test_case_1),
15474 TEST_CASE_ST(ut_setup, ut_teardown,
15475 test_snow3g_auth_cipher_with_digest_test_case_1),
15480 static struct unit_test_suite cryptodev_zuc_testsuite = {
15481 .suite_name = "ZUC Test Suite",
15482 .setup = zuc_testsuite_setup,
15483 .unit_test_cases = {
15484 /** ZUC encrypt only (EEA3) */
15485 TEST_CASE_ST(ut_setup, ut_teardown,
15486 test_zuc_encryption_test_case_1),
15487 TEST_CASE_ST(ut_setup, ut_teardown,
15488 test_zuc_encryption_test_case_2),
15489 TEST_CASE_ST(ut_setup, ut_teardown,
15490 test_zuc_encryption_test_case_3),
15491 TEST_CASE_ST(ut_setup, ut_teardown,
15492 test_zuc_encryption_test_case_4),
15493 TEST_CASE_ST(ut_setup, ut_teardown,
15494 test_zuc_encryption_test_case_5),
15495 TEST_CASE_ST(ut_setup, ut_teardown,
15496 test_zuc_encryption_test_case_6_sgl),
15498 /** ZUC authenticate (EIA3) */
15499 TEST_CASE_ST(ut_setup, ut_teardown,
15500 test_zuc_hash_generate_test_case_1),
15501 TEST_CASE_ST(ut_setup, ut_teardown,
15502 test_zuc_hash_generate_test_case_2),
15503 TEST_CASE_ST(ut_setup, ut_teardown,
15504 test_zuc_hash_generate_test_case_3),
15505 TEST_CASE_ST(ut_setup, ut_teardown,
15506 test_zuc_hash_generate_test_case_4),
15507 TEST_CASE_ST(ut_setup, ut_teardown,
15508 test_zuc_hash_generate_test_case_5),
15509 TEST_CASE_ST(ut_setup, ut_teardown,
15510 test_zuc_hash_generate_test_case_6),
15511 TEST_CASE_ST(ut_setup, ut_teardown,
15512 test_zuc_hash_generate_test_case_7),
15513 TEST_CASE_ST(ut_setup, ut_teardown,
15514 test_zuc_hash_generate_test_case_8),
15515 TEST_CASE_ST(ut_setup, ut_teardown,
15516 test_zuc_hash_generate_test_case_9),
15517 TEST_CASE_ST(ut_setup, ut_teardown,
15518 test_zuc_hash_generate_test_case_10),
15519 TEST_CASE_ST(ut_setup, ut_teardown,
15520 test_zuc_hash_generate_test_case_11),
15523 /** ZUC alg-chain (EEA3/EIA3) */
15524 TEST_CASE_ST(ut_setup, ut_teardown,
15525 test_zuc_cipher_auth_test_case_1),
15526 TEST_CASE_ST(ut_setup, ut_teardown,
15527 test_zuc_cipher_auth_test_case_2),
15529 /** ZUC generate auth, then encrypt (EEA3) */
15530 TEST_CASE_ST(ut_setup, ut_teardown,
15531 test_zuc_auth_cipher_test_case_1),
15532 TEST_CASE_ST(ut_setup, ut_teardown,
15533 test_zuc_auth_cipher_test_case_1_oop),
15534 TEST_CASE_ST(ut_setup, ut_teardown,
15535 test_zuc_auth_cipher_test_case_1_sgl),
15536 TEST_CASE_ST(ut_setup, ut_teardown,
15537 test_zuc_auth_cipher_test_case_1_oop_sgl),
15539 /** ZUC decrypt (EEA3), then verify auth */
15540 TEST_CASE_ST(ut_setup, ut_teardown,
15541 test_zuc_auth_cipher_verify_test_case_1),
15542 TEST_CASE_ST(ut_setup, ut_teardown,
15543 test_zuc_auth_cipher_verify_test_case_1_oop),
15544 TEST_CASE_ST(ut_setup, ut_teardown,
15545 test_zuc_auth_cipher_verify_test_case_1_sgl),
15546 TEST_CASE_ST(ut_setup, ut_teardown,
15547 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
15549 /** ZUC-256 encrypt only **/
15550 TEST_CASE_ST(ut_setup, ut_teardown,
15551 test_zuc256_encryption_test_case_1),
15552 TEST_CASE_ST(ut_setup, ut_teardown,
15553 test_zuc256_encryption_test_case_2),
15555 /** ZUC-256 authentication only **/
15556 TEST_CASE_ST(ut_setup, ut_teardown,
15557 test_zuc256_authentication_test_case_1),
15558 TEST_CASE_ST(ut_setup, ut_teardown,
15559 test_zuc256_authentication_test_case_2),
15565 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
15566 .suite_name = "HMAC_MD5 Authentication Test Suite",
15567 .setup = hmac_md5_auth_testsuite_setup,
15568 .unit_test_cases = {
15569 TEST_CASE_ST(ut_setup, ut_teardown,
15570 test_MD5_HMAC_generate_case_1),
15571 TEST_CASE_ST(ut_setup, ut_teardown,
15572 test_MD5_HMAC_verify_case_1),
15573 TEST_CASE_ST(ut_setup, ut_teardown,
15574 test_MD5_HMAC_generate_case_2),
15575 TEST_CASE_ST(ut_setup, ut_teardown,
15576 test_MD5_HMAC_verify_case_2),
15581 static struct unit_test_suite cryptodev_kasumi_testsuite = {
15582 .suite_name = "Kasumi Test Suite",
15583 .setup = kasumi_testsuite_setup,
15584 .unit_test_cases = {
15585 /** KASUMI hash only (UIA1) */
15586 TEST_CASE_ST(ut_setup, ut_teardown,
15587 test_kasumi_hash_generate_test_case_1),
15588 TEST_CASE_ST(ut_setup, ut_teardown,
15589 test_kasumi_hash_generate_test_case_2),
15590 TEST_CASE_ST(ut_setup, ut_teardown,
15591 test_kasumi_hash_generate_test_case_3),
15592 TEST_CASE_ST(ut_setup, ut_teardown,
15593 test_kasumi_hash_generate_test_case_4),
15594 TEST_CASE_ST(ut_setup, ut_teardown,
15595 test_kasumi_hash_generate_test_case_5),
15596 TEST_CASE_ST(ut_setup, ut_teardown,
15597 test_kasumi_hash_generate_test_case_6),
15599 TEST_CASE_ST(ut_setup, ut_teardown,
15600 test_kasumi_hash_verify_test_case_1),
15601 TEST_CASE_ST(ut_setup, ut_teardown,
15602 test_kasumi_hash_verify_test_case_2),
15603 TEST_CASE_ST(ut_setup, ut_teardown,
15604 test_kasumi_hash_verify_test_case_3),
15605 TEST_CASE_ST(ut_setup, ut_teardown,
15606 test_kasumi_hash_verify_test_case_4),
15607 TEST_CASE_ST(ut_setup, ut_teardown,
15608 test_kasumi_hash_verify_test_case_5),
15610 /** KASUMI encrypt only (UEA1) */
15611 TEST_CASE_ST(ut_setup, ut_teardown,
15612 test_kasumi_encryption_test_case_1),
15613 TEST_CASE_ST(ut_setup, ut_teardown,
15614 test_kasumi_encryption_test_case_1_sgl),
15615 TEST_CASE_ST(ut_setup, ut_teardown,
15616 test_kasumi_encryption_test_case_1_oop),
15617 TEST_CASE_ST(ut_setup, ut_teardown,
15618 test_kasumi_encryption_test_case_1_oop_sgl),
15619 TEST_CASE_ST(ut_setup, ut_teardown,
15620 test_kasumi_encryption_test_case_2),
15621 TEST_CASE_ST(ut_setup, ut_teardown,
15622 test_kasumi_encryption_test_case_3),
15623 TEST_CASE_ST(ut_setup, ut_teardown,
15624 test_kasumi_encryption_test_case_4),
15625 TEST_CASE_ST(ut_setup, ut_teardown,
15626 test_kasumi_encryption_test_case_5),
15628 /** KASUMI decrypt only (UEA1) */
15629 TEST_CASE_ST(ut_setup, ut_teardown,
15630 test_kasumi_decryption_test_case_1),
15631 TEST_CASE_ST(ut_setup, ut_teardown,
15632 test_kasumi_decryption_test_case_2),
15633 TEST_CASE_ST(ut_setup, ut_teardown,
15634 test_kasumi_decryption_test_case_3),
15635 TEST_CASE_ST(ut_setup, ut_teardown,
15636 test_kasumi_decryption_test_case_4),
15637 TEST_CASE_ST(ut_setup, ut_teardown,
15638 test_kasumi_decryption_test_case_5),
15639 TEST_CASE_ST(ut_setup, ut_teardown,
15640 test_kasumi_decryption_test_case_1_oop),
15641 TEST_CASE_ST(ut_setup, ut_teardown,
15642 test_kasumi_cipher_auth_test_case_1),
15644 /** KASUMI generate auth, then encrypt (F8) */
15645 TEST_CASE_ST(ut_setup, ut_teardown,
15646 test_kasumi_auth_cipher_test_case_1),
15647 TEST_CASE_ST(ut_setup, ut_teardown,
15648 test_kasumi_auth_cipher_test_case_2),
15649 TEST_CASE_ST(ut_setup, ut_teardown,
15650 test_kasumi_auth_cipher_test_case_2_oop),
15651 TEST_CASE_ST(ut_setup, ut_teardown,
15652 test_kasumi_auth_cipher_test_case_2_sgl),
15653 TEST_CASE_ST(ut_setup, ut_teardown,
15654 test_kasumi_auth_cipher_test_case_2_oop_sgl),
15656 /** KASUMI decrypt (F8), then verify auth */
15657 TEST_CASE_ST(ut_setup, ut_teardown,
15658 test_kasumi_auth_cipher_verify_test_case_1),
15659 TEST_CASE_ST(ut_setup, ut_teardown,
15660 test_kasumi_auth_cipher_verify_test_case_2),
15661 TEST_CASE_ST(ut_setup, ut_teardown,
15662 test_kasumi_auth_cipher_verify_test_case_2_oop),
15663 TEST_CASE_ST(ut_setup, ut_teardown,
15664 test_kasumi_auth_cipher_verify_test_case_2_sgl),
15665 TEST_CASE_ST(ut_setup, ut_teardown,
15666 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
15672 static struct unit_test_suite cryptodev_esn_testsuite = {
15673 .suite_name = "ESN Test Suite",
15674 .setup = esn_testsuite_setup,
15675 .unit_test_cases = {
15676 TEST_CASE_ST(ut_setup, ut_teardown,
15677 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
15678 TEST_CASE_ST(ut_setup, ut_teardown,
15679 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
15684 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
15685 .suite_name = "Negative AES GCM Test Suite",
15686 .setup = negative_aes_gcm_testsuite_setup,
15687 .unit_test_cases = {
15688 TEST_CASE_ST(ut_setup, ut_teardown,
15689 test_AES_GCM_auth_encryption_fail_iv_corrupt),
15690 TEST_CASE_ST(ut_setup, ut_teardown,
15691 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
15692 TEST_CASE_ST(ut_setup, ut_teardown,
15693 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
15694 TEST_CASE_ST(ut_setup, ut_teardown,
15695 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
15696 TEST_CASE_ST(ut_setup, ut_teardown,
15697 test_AES_GCM_auth_encryption_fail_aad_corrupt),
15698 TEST_CASE_ST(ut_setup, ut_teardown,
15699 test_AES_GCM_auth_encryption_fail_tag_corrupt),
15700 TEST_CASE_ST(ut_setup, ut_teardown,
15701 test_AES_GCM_auth_decryption_fail_iv_corrupt),
15702 TEST_CASE_ST(ut_setup, ut_teardown,
15703 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
15704 TEST_CASE_ST(ut_setup, ut_teardown,
15705 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
15706 TEST_CASE_ST(ut_setup, ut_teardown,
15707 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
15708 TEST_CASE_ST(ut_setup, ut_teardown,
15709 test_AES_GCM_auth_decryption_fail_aad_corrupt),
15710 TEST_CASE_ST(ut_setup, ut_teardown,
15711 test_AES_GCM_auth_decryption_fail_tag_corrupt),
15717 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
15718 .suite_name = "Negative AES GMAC Test Suite",
15719 .setup = negative_aes_gmac_testsuite_setup,
15720 .unit_test_cases = {
15721 TEST_CASE_ST(ut_setup, ut_teardown,
15722 authentication_verify_AES128_GMAC_fail_data_corrupt),
15723 TEST_CASE_ST(ut_setup, ut_teardown,
15724 authentication_verify_AES128_GMAC_fail_tag_corrupt),
15730 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
15731 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
15732 .setup = mixed_cipher_hash_testsuite_setup,
15733 .unit_test_cases = {
15734 /** AUTH AES CMAC + CIPHER AES CTR */
15735 TEST_CASE_ST(ut_setup, ut_teardown,
15736 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
15737 TEST_CASE_ST(ut_setup, ut_teardown,
15738 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15739 TEST_CASE_ST(ut_setup, ut_teardown,
15740 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15741 TEST_CASE_ST(ut_setup, ut_teardown,
15742 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15743 TEST_CASE_ST(ut_setup, ut_teardown,
15744 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
15745 TEST_CASE_ST(ut_setup, ut_teardown,
15746 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15747 TEST_CASE_ST(ut_setup, ut_teardown,
15748 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15749 TEST_CASE_ST(ut_setup, ut_teardown,
15750 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15752 /** AUTH ZUC + CIPHER SNOW3G */
15753 TEST_CASE_ST(ut_setup, ut_teardown,
15754 test_auth_zuc_cipher_snow_test_case_1),
15755 TEST_CASE_ST(ut_setup, ut_teardown,
15756 test_verify_auth_zuc_cipher_snow_test_case_1),
15757 /** AUTH AES CMAC + CIPHER SNOW3G */
15758 TEST_CASE_ST(ut_setup, ut_teardown,
15759 test_auth_aes_cmac_cipher_snow_test_case_1),
15760 TEST_CASE_ST(ut_setup, ut_teardown,
15761 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
15762 /** AUTH ZUC + CIPHER AES CTR */
15763 TEST_CASE_ST(ut_setup, ut_teardown,
15764 test_auth_zuc_cipher_aes_ctr_test_case_1),
15765 TEST_CASE_ST(ut_setup, ut_teardown,
15766 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
15767 /** AUTH SNOW3G + CIPHER AES CTR */
15768 TEST_CASE_ST(ut_setup, ut_teardown,
15769 test_auth_snow_cipher_aes_ctr_test_case_1),
15770 TEST_CASE_ST(ut_setup, ut_teardown,
15771 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
15772 /** AUTH SNOW3G + CIPHER ZUC */
15773 TEST_CASE_ST(ut_setup, ut_teardown,
15774 test_auth_snow_cipher_zuc_test_case_1),
15775 TEST_CASE_ST(ut_setup, ut_teardown,
15776 test_verify_auth_snow_cipher_zuc_test_case_1),
15777 /** AUTH AES CMAC + CIPHER ZUC */
15778 TEST_CASE_ST(ut_setup, ut_teardown,
15779 test_auth_aes_cmac_cipher_zuc_test_case_1),
15780 TEST_CASE_ST(ut_setup, ut_teardown,
15781 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
15783 /** AUTH NULL + CIPHER SNOW3G */
15784 TEST_CASE_ST(ut_setup, ut_teardown,
15785 test_auth_null_cipher_snow_test_case_1),
15786 TEST_CASE_ST(ut_setup, ut_teardown,
15787 test_verify_auth_null_cipher_snow_test_case_1),
15788 /** AUTH NULL + CIPHER ZUC */
15789 TEST_CASE_ST(ut_setup, ut_teardown,
15790 test_auth_null_cipher_zuc_test_case_1),
15791 TEST_CASE_ST(ut_setup, ut_teardown,
15792 test_verify_auth_null_cipher_zuc_test_case_1),
15793 /** AUTH SNOW3G + CIPHER NULL */
15794 TEST_CASE_ST(ut_setup, ut_teardown,
15795 test_auth_snow_cipher_null_test_case_1),
15796 TEST_CASE_ST(ut_setup, ut_teardown,
15797 test_verify_auth_snow_cipher_null_test_case_1),
15798 /** AUTH ZUC + CIPHER NULL */
15799 TEST_CASE_ST(ut_setup, ut_teardown,
15800 test_auth_zuc_cipher_null_test_case_1),
15801 TEST_CASE_ST(ut_setup, ut_teardown,
15802 test_verify_auth_zuc_cipher_null_test_case_1),
15803 /** AUTH NULL + CIPHER AES CTR */
15804 TEST_CASE_ST(ut_setup, ut_teardown,
15805 test_auth_null_cipher_aes_ctr_test_case_1),
15806 TEST_CASE_ST(ut_setup, ut_teardown,
15807 test_verify_auth_null_cipher_aes_ctr_test_case_1),
15808 /** AUTH AES CMAC + CIPHER NULL */
15809 TEST_CASE_ST(ut_setup, ut_teardown,
15810 test_auth_aes_cmac_cipher_null_test_case_1),
15811 TEST_CASE_ST(ut_setup, ut_teardown,
15812 test_verify_auth_aes_cmac_cipher_null_test_case_1),
15818 run_cryptodev_testsuite(const char *pmd_name)
15820 uint8_t ret, j, i = 0, blk_start_idx = 0;
15821 const enum blockcipher_test_type blk_suites[] = {
15822 BLKCIPHER_AES_CHAIN_TYPE,
15823 BLKCIPHER_AES_CIPHERONLY_TYPE,
15824 BLKCIPHER_AES_DOCSIS_TYPE,
15825 BLKCIPHER_3DES_CHAIN_TYPE,
15826 BLKCIPHER_3DES_CIPHERONLY_TYPE,
15827 BLKCIPHER_DES_CIPHERONLY_TYPE,
15828 BLKCIPHER_DES_DOCSIS_TYPE,
15829 BLKCIPHER_AUTHONLY_TYPE};
15830 struct unit_test_suite *static_suites[] = {
15831 &cryptodev_multi_session_testsuite,
15832 &cryptodev_null_testsuite,
15833 &cryptodev_aes_ccm_auth_testsuite,
15834 &cryptodev_aes_gcm_auth_testsuite,
15835 &cryptodev_aes_gmac_auth_testsuite,
15836 &cryptodev_snow3g_testsuite,
15837 &cryptodev_chacha20_poly1305_testsuite,
15838 &cryptodev_zuc_testsuite,
15839 &cryptodev_hmac_md5_auth_testsuite,
15840 &cryptodev_kasumi_testsuite,
15841 &cryptodev_esn_testsuite,
15842 &cryptodev_negative_aes_gcm_testsuite,
15843 &cryptodev_negative_aes_gmac_testsuite,
15844 &cryptodev_mixed_cipher_hash_testsuite,
15845 &cryptodev_negative_hmac_sha1_testsuite,
15846 &cryptodev_gen_testsuite,
15847 #ifdef RTE_LIB_SECURITY
15848 &ipsec_proto_testsuite,
15849 &pdcp_proto_testsuite,
15850 &docsis_proto_testsuite,
15854 static struct unit_test_suite ts = {
15855 .suite_name = "Cryptodev Unit Test Suite",
15856 .setup = testsuite_setup,
15857 .teardown = testsuite_teardown,
15858 .unit_test_cases = {TEST_CASES_END()}
15861 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
15863 if (gbl_driver_id == -1) {
15864 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
15865 return TEST_SKIPPED;
15868 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15869 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
15871 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
15872 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15873 ret = unit_test_suite_runner(&ts);
15875 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
15876 free(ts.unit_test_suites);
15881 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
15883 struct rte_cryptodev_info dev_info;
15884 uint8_t i, nb_devs;
15887 driver_id = rte_cryptodev_driver_id_get(pmd_name);
15888 if (driver_id == -1) {
15889 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
15890 return TEST_SKIPPED;
15893 nb_devs = rte_cryptodev_count();
15895 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
15896 return TEST_SKIPPED;
15899 for (i = 0; i < nb_devs; i++) {
15900 rte_cryptodev_info_get(i, &dev_info);
15901 if (dev_info.driver_id == driver_id) {
15902 if (!(dev_info.feature_flags & flag)) {
15903 RTE_LOG(INFO, USER1, "%s not supported\n",
15905 return TEST_SKIPPED;
15907 return 0; /* found */
15911 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
15912 return TEST_SKIPPED;
15916 test_cryptodev_qat(void)
15918 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
15922 test_cryptodev_virtio(void)
15924 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
15928 test_cryptodev_aesni_mb(void)
15930 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15934 test_cryptodev_cpu_aesni_mb(void)
15937 enum rte_security_session_action_type at = gbl_action_type;
15938 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15939 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15940 gbl_action_type = at;
15945 test_cryptodev_chacha_poly_mb(void)
15948 enum rte_security_session_action_type at = gbl_action_type;
15949 rc = run_cryptodev_testsuite(
15950 RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
15951 gbl_action_type = at;
15956 test_cryptodev_openssl(void)
15958 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
15962 test_cryptodev_aesni_gcm(void)
15964 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15968 test_cryptodev_cpu_aesni_gcm(void)
15971 enum rte_security_session_action_type at = gbl_action_type;
15972 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15973 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15974 gbl_action_type = at;
15979 test_cryptodev_mlx5(void)
15981 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
15985 test_cryptodev_null(void)
15987 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
15991 test_cryptodev_sw_snow3g(void)
15993 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
15997 test_cryptodev_sw_kasumi(void)
15999 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
16003 test_cryptodev_sw_zuc(void)
16005 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
16009 test_cryptodev_armv8(void)
16011 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
16015 test_cryptodev_mrvl(void)
16017 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
16020 #ifdef RTE_CRYPTO_SCHEDULER
16023 test_cryptodev_scheduler(void)
16025 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
16026 const enum blockcipher_test_type blk_suites[] = {
16027 BLKCIPHER_AES_CHAIN_TYPE,
16028 BLKCIPHER_AES_CIPHERONLY_TYPE,
16029 BLKCIPHER_AUTHONLY_TYPE
16031 static struct unit_test_suite scheduler_multicore = {
16032 .suite_name = "Scheduler Multicore Unit Test Suite",
16033 .setup = scheduler_multicore_testsuite_setup,
16034 .teardown = scheduler_mode_testsuite_teardown,
16035 .unit_test_cases = {TEST_CASES_END()}
16037 static struct unit_test_suite scheduler_round_robin = {
16038 .suite_name = "Scheduler Round Robin Unit Test Suite",
16039 .setup = scheduler_roundrobin_testsuite_setup,
16040 .teardown = scheduler_mode_testsuite_teardown,
16041 .unit_test_cases = {TEST_CASES_END()}
16043 static struct unit_test_suite scheduler_failover = {
16044 .suite_name = "Scheduler Failover Unit Test Suite",
16045 .setup = scheduler_failover_testsuite_setup,
16046 .teardown = scheduler_mode_testsuite_teardown,
16047 .unit_test_cases = {TEST_CASES_END()}
16049 static struct unit_test_suite scheduler_pkt_size_distr = {
16050 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
16051 .setup = scheduler_pkt_size_distr_testsuite_setup,
16052 .teardown = scheduler_mode_testsuite_teardown,
16053 .unit_test_cases = {TEST_CASES_END()}
16055 struct unit_test_suite *sched_mode_suites[] = {
16056 &scheduler_multicore,
16057 &scheduler_round_robin,
16058 &scheduler_failover,
16059 &scheduler_pkt_size_distr
16061 static struct unit_test_suite scheduler_config = {
16062 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
16063 .unit_test_cases = {
16064 TEST_CASE(test_scheduler_attach_worker_op),
16065 TEST_CASE(test_scheduler_mode_multicore_op),
16066 TEST_CASE(test_scheduler_mode_roundrobin_op),
16067 TEST_CASE(test_scheduler_mode_failover_op),
16068 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
16069 TEST_CASE(test_scheduler_detach_worker_op),
16071 TEST_CASES_END() /**< NULL terminate array */
16074 struct unit_test_suite *static_suites[] = {
16078 static struct unit_test_suite ts = {
16079 .suite_name = "Scheduler Unit Test Suite",
16080 .setup = scheduler_testsuite_setup,
16081 .teardown = testsuite_teardown,
16082 .unit_test_cases = {TEST_CASES_END()}
16085 gbl_driver_id = rte_cryptodev_driver_id_get(
16086 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
16088 if (gbl_driver_id == -1) {
16089 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
16090 return TEST_SKIPPED;
16093 if (rte_cryptodev_driver_id_get(
16094 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
16095 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
16096 return TEST_SKIPPED;
16099 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
16101 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
16102 (struct unit_test_suite *) *
16103 (RTE_DIM(blk_suites) + 1));
16104 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
16105 blk_suites, RTE_DIM(blk_suites));
16106 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
16109 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
16110 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
16111 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
16112 RTE_DIM(sched_mode_suites));
16113 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
16114 ret = unit_test_suite_runner(&ts);
16116 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
16117 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
16118 (*sched_mode_suites[sched_i]),
16119 RTE_DIM(blk_suites));
16120 free(sched_mode_suites[sched_i]->unit_test_suites);
16122 free(ts.unit_test_suites);
16126 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
16131 test_cryptodev_dpaa2_sec(void)
16133 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
16137 test_cryptodev_dpaa_sec(void)
16139 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
16143 test_cryptodev_ccp(void)
16145 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
16149 test_cryptodev_octeontx(void)
16151 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
16155 test_cryptodev_caam_jr(void)
16157 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
16161 test_cryptodev_nitrox(void)
16163 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
16167 test_cryptodev_bcmfs(void)
16169 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
16173 test_cryptodev_qat_raw_api(void)
16175 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
16178 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16183 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16184 ret = run_cryptodev_testsuite(pmd_name);
16185 global_api_test_type = CRYPTODEV_API_TEST;
16191 test_cryptodev_cn9k(void)
16193 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
16197 test_cryptodev_cn10k(void)
16199 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
16203 test_cryptodev_dpaa2_sec_raw_api(void)
16205 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16208 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16213 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16214 ret = run_cryptodev_testsuite(pmd_name);
16215 global_api_test_type = CRYPTODEV_API_TEST;
16221 test_cryptodev_dpaa_sec_raw_api(void)
16223 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16226 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16231 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16232 ret = run_cryptodev_testsuite(pmd_name);
16233 global_api_test_type = CRYPTODEV_API_TEST;
16238 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
16239 test_cryptodev_dpaa2_sec_raw_api);
16240 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
16241 test_cryptodev_dpaa_sec_raw_api);
16242 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
16243 test_cryptodev_qat_raw_api);
16244 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
16245 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
16246 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
16247 test_cryptodev_cpu_aesni_mb);
16248 REGISTER_TEST_COMMAND(cryptodev_chacha_poly_mb_autotest,
16249 test_cryptodev_chacha_poly_mb);
16250 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
16251 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
16252 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
16253 test_cryptodev_cpu_aesni_gcm);
16254 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
16255 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
16256 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
16257 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
16258 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
16259 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
16260 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
16261 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
16262 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
16263 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
16264 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
16265 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
16266 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
16267 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
16268 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
16269 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
16270 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
16272 #endif /* !RTE_EXEC_ENV_WINDOWS */