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;
215 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
216 if (ctx_service_size < 0) {
217 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
221 ctx = malloc(ctx_service_size);
223 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
227 /* Both are enums, setting crypto_sess will suit any session type */
228 sess.crypto_sess = op->sym->session;
230 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
231 op->sess_type, sess, 0) < 0) {
232 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
238 aad_auth_iv.iova = 0;
239 aad_auth_iv.va = NULL;
246 vec.digest = &digest;
247 vec.aad = &aad_auth_iv;
248 vec.status = &status;
252 if (is_cipher && is_auth) {
253 cipher_offset = sop->cipher.data.offset;
254 cipher_len = sop->cipher.data.length;
255 auth_offset = sop->auth.data.offset;
256 auth_len = sop->auth.data.length;
257 max_len = RTE_MAX(cipher_offset + cipher_len,
258 auth_offset + auth_len);
260 max_len = max_len >> 3;
261 cipher_offset = cipher_offset >> 3;
262 auth_offset = auth_offset >> 3;
263 cipher_len = cipher_len >> 3;
264 auth_len = auth_len >> 3;
266 ofs.ofs.cipher.head = cipher_offset;
267 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
268 ofs.ofs.auth.head = auth_offset;
269 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
270 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
271 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
272 aad_auth_iv.va = rte_crypto_op_ctod_offset(
273 op, void *, IV_OFFSET + cipher_iv_len);
274 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
276 digest.va = (void *)sop->auth.digest.data;
277 digest.iova = sop->auth.digest.phys_addr;
280 uint32_t remaining_off = auth_offset + auth_len;
281 struct rte_mbuf *sgl_buf = sop->m_src;
283 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
284 && sgl_buf->next != NULL) {
285 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
286 sgl_buf = sgl_buf->next;
289 auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
290 sgl_buf, remaining_off);
292 auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
293 auth_offset + auth_len;
295 /* Then check if digest-encrypted conditions are met */
296 if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
297 (digest.iova == auth_end_iova) && is_sgl)
298 max_len = RTE_MAX(max_len, auth_offset + auth_len +
299 ut_params->auth_xform.auth.digest_length);
301 } else if (is_cipher) {
302 cipher_offset = sop->cipher.data.offset;
303 cipher_len = sop->cipher.data.length;
304 max_len = cipher_len + cipher_offset;
306 max_len = max_len >> 3;
307 cipher_offset = cipher_offset >> 3;
308 cipher_len = cipher_len >> 3;
310 ofs.ofs.cipher.head = cipher_offset;
311 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
312 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
313 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
315 } else if (is_auth) {
316 auth_offset = sop->auth.data.offset;
317 auth_len = sop->auth.data.length;
318 max_len = auth_len + auth_offset;
320 max_len = max_len >> 3;
321 auth_offset = auth_offset >> 3;
322 auth_len = auth_len >> 3;
324 ofs.ofs.auth.head = auth_offset;
325 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
326 aad_auth_iv.va = rte_crypto_op_ctod_offset(
327 op, void *, IV_OFFSET + cipher_iv_len);
328 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
330 digest.va = (void *)sop->auth.digest.data;
331 digest.iova = sop->auth.digest.phys_addr;
334 cipher_offset = sop->aead.data.offset;
335 cipher_len = sop->aead.data.length;
336 max_len = cipher_len + cipher_offset;
338 max_len = max_len >> 3;
339 cipher_offset = cipher_offset >> 3;
340 cipher_len = cipher_len >> 3;
342 ofs.ofs.cipher.head = cipher_offset;
343 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
344 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
345 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
346 aad_auth_iv.va = (void *)sop->aead.aad.data;
347 aad_auth_iv.iova = sop->aead.aad.phys_addr;
348 digest.va = (void *)sop->aead.digest.data;
349 digest.iova = sop->aead.digest.phys_addr;
352 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
353 data_vec, RTE_DIM(data_vec));
354 if (n < 0 || n > sop->m_src->nb_segs) {
355 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
361 if (sop->m_dst != NULL) {
362 dest_sgl.vec = dest_data_vec;
363 vec.dest_sgl = &dest_sgl;
364 n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
365 dest_data_vec, RTE_DIM(dest_data_vec));
366 if (n < 0 || n > sop->m_dst->nb_segs) {
367 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
374 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
375 &enqueue_status) < 1) {
376 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
380 if (enqueue_status == 0) {
381 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
383 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
386 } else if (enqueue_status < 0) {
387 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
392 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
393 n = rte_cryptodev_raw_dequeue_burst(ctx,
394 NULL, 1, post_process_raw_dp_op,
395 (void **)&ret_op, 0, &n_success,
397 if (dequeue_status < 0) {
398 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
405 if (n == 1 && dequeue_status == 0) {
406 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
407 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
412 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
413 ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
414 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
415 RTE_CRYPTO_OP_STATUS_SUCCESS;
422 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
425 struct rte_crypto_sym_op *sop;
426 union rte_crypto_sym_ofs ofs;
427 struct rte_crypto_sgl sgl;
428 struct rte_crypto_sym_vec symvec;
429 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
430 struct rte_crypto_vec vec[UINT8_MAX];
434 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
435 sop->aead.data.length, vec, RTE_DIM(vec));
437 if (n < 0 || n != sop->m_src->nb_segs) {
438 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
444 symvec.src_sgl = &sgl;
446 symvec.digest = &digest_ptr;
447 symvec.aad = &aad_ptr;
451 /* for CPU crypto the IOVA address is not required */
452 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
453 digest_ptr.va = (void *)sop->aead.digest.data;
454 aad_ptr.va = (void *)sop->aead.aad.data;
458 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
462 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
464 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
468 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
471 struct rte_crypto_sym_op *sop;
472 union rte_crypto_sym_ofs ofs;
473 struct rte_crypto_sgl sgl;
474 struct rte_crypto_sym_vec symvec;
475 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
476 struct rte_crypto_vec vec[UINT8_MAX];
480 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
481 sop->auth.data.length, vec, RTE_DIM(vec));
483 if (n < 0 || n != sop->m_src->nb_segs) {
484 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
490 symvec.src_sgl = &sgl;
492 symvec.digest = &digest_ptr;
496 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
497 digest_ptr.va = (void *)sop->auth.digest.data;
500 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
501 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
502 (sop->cipher.data.offset + sop->cipher.data.length);
504 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
508 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
510 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
513 static struct rte_crypto_op *
514 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
517 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
519 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
520 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
526 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
529 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
530 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
538 testsuite_setup(void)
540 struct crypto_testsuite_params *ts_params = &testsuite_params;
541 struct rte_cryptodev_info info;
542 uint32_t i = 0, nb_devs, dev_id;
545 memset(ts_params, 0, sizeof(*ts_params));
547 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
548 if (ts_params->mbuf_pool == NULL) {
549 /* Not already created so create */
550 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
552 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
554 if (ts_params->mbuf_pool == NULL) {
555 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
560 ts_params->large_mbuf_pool = rte_mempool_lookup(
561 "CRYPTO_LARGE_MBUFPOOL");
562 if (ts_params->large_mbuf_pool == NULL) {
563 /* Not already created so create */
564 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
565 "CRYPTO_LARGE_MBUFPOOL",
568 if (ts_params->large_mbuf_pool == NULL) {
570 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
575 ts_params->op_mpool = rte_crypto_op_pool_create(
576 "MBUF_CRYPTO_SYM_OP_POOL",
577 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
578 NUM_MBUFS, MBUF_CACHE_SIZE,
580 sizeof(struct rte_crypto_sym_xform) +
583 if (ts_params->op_mpool == NULL) {
584 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
588 nb_devs = rte_cryptodev_count();
590 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
594 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
595 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
596 rte_cryptodev_driver_name_get(gbl_driver_id));
600 /* Create list of valid crypto devs */
601 for (i = 0; i < nb_devs; i++) {
602 rte_cryptodev_info_get(i, &info);
603 if (info.driver_id == gbl_driver_id)
604 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
607 if (ts_params->valid_dev_count < 1)
610 /* Set up all the qps on the first of the valid devices found */
612 dev_id = ts_params->valid_devs[0];
614 rte_cryptodev_info_get(dev_id, &info);
616 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
617 ts_params->conf.socket_id = SOCKET_ID_ANY;
618 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
620 unsigned int session_size =
621 rte_cryptodev_sym_get_private_session_size(dev_id);
623 #ifdef RTE_LIB_SECURITY
624 unsigned int security_session_size = rte_security_session_get_size(
625 rte_cryptodev_get_sec_ctx(dev_id));
627 if (session_size < security_session_size)
628 session_size = security_session_size;
631 * Create mempool with maximum number of sessions.
633 if (info.sym.max_nb_sessions != 0 &&
634 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
635 RTE_LOG(ERR, USER1, "Device does not support "
636 "at least %u sessions\n",
641 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
642 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
644 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
645 "session mempool allocation failed");
647 ts_params->session_priv_mpool = rte_mempool_create(
651 0, 0, NULL, NULL, NULL,
654 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
655 "session mempool allocation failed");
659 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
661 "Failed to configure cryptodev %u with %u qps",
662 dev_id, ts_params->conf.nb_queue_pairs);
664 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
665 ts_params->qp_conf.mp_session = ts_params->session_mpool;
666 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
668 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
669 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
670 dev_id, qp_id, &ts_params->qp_conf,
671 rte_cryptodev_socket_id(dev_id)),
672 "Failed to setup queue pair %u on cryptodev %u",
680 testsuite_teardown(void)
682 struct crypto_testsuite_params *ts_params = &testsuite_params;
685 if (ts_params->mbuf_pool != NULL) {
686 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
687 rte_mempool_avail_count(ts_params->mbuf_pool));
690 if (ts_params->op_mpool != NULL) {
691 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
692 rte_mempool_avail_count(ts_params->op_mpool));
695 /* Free session mempools */
696 if (ts_params->session_priv_mpool != NULL) {
697 rte_mempool_free(ts_params->session_priv_mpool);
698 ts_params->session_priv_mpool = NULL;
701 if (ts_params->session_mpool != NULL) {
702 rte_mempool_free(ts_params->session_mpool);
703 ts_params->session_mpool = NULL;
706 res = rte_cryptodev_close(ts_params->valid_devs[0]);
708 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
712 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
713 const int *algs, uint16_t num_algs)
715 uint8_t dev_id = testsuite_params.valid_devs[0];
716 bool some_alg_supported = FALSE;
719 for (i = 0; i < num_algs && !some_alg_supported; i++) {
720 struct rte_cryptodev_sym_capability_idx alg = {
723 if (rte_cryptodev_sym_capability_get(dev_id,
725 some_alg_supported = TRUE;
727 if (!some_alg_supported)
734 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
735 uint16_t num_ciphers)
737 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
738 (const int *) ciphers, num_ciphers);
742 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
745 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
746 (const int *) auths, num_auths);
750 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
753 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
754 (const int *) aeads, num_aeads);
758 null_testsuite_setup(void)
760 struct crypto_testsuite_params *ts_params = &testsuite_params;
761 uint8_t dev_id = ts_params->valid_devs[0];
762 struct rte_cryptodev_info dev_info;
763 const enum rte_crypto_cipher_algorithm ciphers[] = {
764 RTE_CRYPTO_CIPHER_NULL
766 const enum rte_crypto_auth_algorithm auths[] = {
770 rte_cryptodev_info_get(dev_id, &dev_info);
772 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
773 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
774 "testsuite not met\n");
778 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
779 && check_auth_capabilities_supported(auths,
780 RTE_DIM(auths)) != 0) {
781 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
782 "testsuite not met\n");
790 crypto_gen_testsuite_setup(void)
792 struct crypto_testsuite_params *ts_params = &testsuite_params;
793 uint8_t dev_id = ts_params->valid_devs[0];
794 struct rte_cryptodev_info dev_info;
796 rte_cryptodev_info_get(dev_id, &dev_info);
798 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
799 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
800 "testsuite not met\n");
807 #ifdef RTE_LIB_SECURITY
809 ipsec_proto_testsuite_setup(void)
811 struct crypto_testsuite_params *ts_params = &testsuite_params;
812 struct crypto_unittest_params *ut_params = &unittest_params;
813 struct rte_cryptodev_info dev_info;
816 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
818 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
819 RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
820 "testsuite not met\n");
824 /* Reconfigure to enable security */
825 ret = dev_configure_and_start(0);
826 if (ret != TEST_SUCCESS)
829 /* Set action type */
830 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
832 if (security_proto_supported(
833 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
834 RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
835 RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
840 test_ipsec_alg_list_populate();
843 * Stop the device. Device would be started again by individual test
844 * case setup routine.
846 rte_cryptodev_stop(ts_params->valid_devs[0]);
852 pdcp_proto_testsuite_setup(void)
854 struct crypto_testsuite_params *ts_params = &testsuite_params;
855 uint8_t dev_id = ts_params->valid_devs[0];
856 struct rte_cryptodev_info dev_info;
857 const enum rte_crypto_cipher_algorithm ciphers[] = {
858 RTE_CRYPTO_CIPHER_NULL,
859 RTE_CRYPTO_CIPHER_AES_CTR,
860 RTE_CRYPTO_CIPHER_ZUC_EEA3,
861 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
863 const enum rte_crypto_auth_algorithm auths[] = {
864 RTE_CRYPTO_AUTH_NULL,
865 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
866 RTE_CRYPTO_AUTH_AES_CMAC,
867 RTE_CRYPTO_AUTH_ZUC_EIA3
870 rte_cryptodev_info_get(dev_id, &dev_info);
872 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
873 !(dev_info.feature_flags &
874 RTE_CRYPTODEV_FF_SECURITY)) {
875 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
876 "testsuite not met\n");
880 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
881 && check_auth_capabilities_supported(auths,
882 RTE_DIM(auths)) != 0) {
883 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
884 "testsuite not met\n");
892 docsis_proto_testsuite_setup(void)
894 struct crypto_testsuite_params *ts_params = &testsuite_params;
895 uint8_t dev_id = ts_params->valid_devs[0];
896 struct rte_cryptodev_info dev_info;
897 const enum rte_crypto_cipher_algorithm ciphers[] = {
898 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
901 rte_cryptodev_info_get(dev_id, &dev_info);
903 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
904 !(dev_info.feature_flags &
905 RTE_CRYPTODEV_FF_SECURITY)) {
906 RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
907 "Proto testsuite not met\n");
911 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
912 RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
913 "testsuite not met\n");
922 aes_ccm_auth_testsuite_setup(void)
924 struct crypto_testsuite_params *ts_params = &testsuite_params;
925 uint8_t dev_id = ts_params->valid_devs[0];
926 struct rte_cryptodev_info dev_info;
927 const enum rte_crypto_aead_algorithm aeads[] = {
928 RTE_CRYPTO_AEAD_AES_CCM
931 rte_cryptodev_info_get(dev_id, &dev_info);
933 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
934 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
935 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
936 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
937 "testsuite not met\n");
941 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
942 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
943 "testsuite not met\n");
951 aes_gcm_auth_testsuite_setup(void)
953 struct crypto_testsuite_params *ts_params = &testsuite_params;
954 uint8_t dev_id = ts_params->valid_devs[0];
955 struct rte_cryptodev_info dev_info;
956 const enum rte_crypto_aead_algorithm aeads[] = {
957 RTE_CRYPTO_AEAD_AES_GCM
960 rte_cryptodev_info_get(dev_id, &dev_info);
962 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
963 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
964 "testsuite not met\n");
968 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
969 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
970 "testsuite not met\n");
978 aes_gmac_auth_testsuite_setup(void)
980 struct crypto_testsuite_params *ts_params = &testsuite_params;
981 uint8_t dev_id = ts_params->valid_devs[0];
982 struct rte_cryptodev_info dev_info;
983 const enum rte_crypto_auth_algorithm auths[] = {
984 RTE_CRYPTO_AUTH_AES_GMAC
987 rte_cryptodev_info_get(dev_id, &dev_info);
989 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
990 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
991 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
992 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
993 "testsuite not met\n");
997 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
998 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
999 "testsuite not met\n");
1000 return TEST_SKIPPED;
1007 chacha20_poly1305_testsuite_setup(void)
1009 struct crypto_testsuite_params *ts_params = &testsuite_params;
1010 uint8_t dev_id = ts_params->valid_devs[0];
1011 struct rte_cryptodev_info dev_info;
1012 const enum rte_crypto_aead_algorithm aeads[] = {
1013 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1016 rte_cryptodev_info_get(dev_id, &dev_info);
1018 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1019 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1020 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1021 RTE_LOG(INFO, USER1, "Feature flag requirements for "
1022 "Chacha20-Poly1305 testsuite not met\n");
1023 return TEST_SKIPPED;
1026 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1027 RTE_LOG(INFO, USER1, "Capability requirements for "
1028 "Chacha20-Poly1305 testsuite not met\n");
1029 return TEST_SKIPPED;
1036 snow3g_testsuite_setup(void)
1038 struct crypto_testsuite_params *ts_params = &testsuite_params;
1039 uint8_t dev_id = ts_params->valid_devs[0];
1040 struct rte_cryptodev_info dev_info;
1041 const enum rte_crypto_cipher_algorithm ciphers[] = {
1042 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1045 const enum rte_crypto_auth_algorithm auths[] = {
1046 RTE_CRYPTO_AUTH_SNOW3G_UIA2
1049 rte_cryptodev_info_get(dev_id, &dev_info);
1051 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1052 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1053 "testsuite not met\n");
1054 return TEST_SKIPPED;
1057 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1058 && check_auth_capabilities_supported(auths,
1059 RTE_DIM(auths)) != 0) {
1060 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1061 "testsuite not met\n");
1062 return TEST_SKIPPED;
1069 zuc_testsuite_setup(void)
1071 struct crypto_testsuite_params *ts_params = &testsuite_params;
1072 uint8_t dev_id = ts_params->valid_devs[0];
1073 struct rte_cryptodev_info dev_info;
1074 const enum rte_crypto_cipher_algorithm ciphers[] = {
1075 RTE_CRYPTO_CIPHER_ZUC_EEA3
1077 const enum rte_crypto_auth_algorithm auths[] = {
1078 RTE_CRYPTO_AUTH_ZUC_EIA3
1081 rte_cryptodev_info_get(dev_id, &dev_info);
1083 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1084 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1085 "testsuite not met\n");
1086 return TEST_SKIPPED;
1089 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1090 && check_auth_capabilities_supported(auths,
1091 RTE_DIM(auths)) != 0) {
1092 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1093 "testsuite not met\n");
1094 return TEST_SKIPPED;
1101 hmac_md5_auth_testsuite_setup(void)
1103 struct crypto_testsuite_params *ts_params = &testsuite_params;
1104 uint8_t dev_id = ts_params->valid_devs[0];
1105 struct rte_cryptodev_info dev_info;
1106 const enum rte_crypto_auth_algorithm auths[] = {
1107 RTE_CRYPTO_AUTH_MD5_HMAC
1110 rte_cryptodev_info_get(dev_id, &dev_info);
1112 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1113 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1114 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1115 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1116 "Auth testsuite not met\n");
1117 return TEST_SKIPPED;
1120 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1121 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1122 "testsuite not met\n");
1123 return TEST_SKIPPED;
1130 kasumi_testsuite_setup(void)
1132 struct crypto_testsuite_params *ts_params = &testsuite_params;
1133 uint8_t dev_id = ts_params->valid_devs[0];
1134 struct rte_cryptodev_info dev_info;
1135 const enum rte_crypto_cipher_algorithm ciphers[] = {
1136 RTE_CRYPTO_CIPHER_KASUMI_F8
1138 const enum rte_crypto_auth_algorithm auths[] = {
1139 RTE_CRYPTO_AUTH_KASUMI_F9
1142 rte_cryptodev_info_get(dev_id, &dev_info);
1144 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1145 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1146 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1147 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1148 "testsuite not met\n");
1149 return TEST_SKIPPED;
1152 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1153 && check_auth_capabilities_supported(auths,
1154 RTE_DIM(auths)) != 0) {
1155 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1156 "testsuite not met\n");
1157 return TEST_SKIPPED;
1164 negative_aes_gcm_testsuite_setup(void)
1166 struct crypto_testsuite_params *ts_params = &testsuite_params;
1167 uint8_t dev_id = ts_params->valid_devs[0];
1168 struct rte_cryptodev_info dev_info;
1169 const enum rte_crypto_aead_algorithm aeads[] = {
1170 RTE_CRYPTO_AEAD_AES_GCM
1173 rte_cryptodev_info_get(dev_id, &dev_info);
1175 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1176 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1177 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1178 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1179 "AES GCM testsuite not met\n");
1180 return TEST_SKIPPED;
1183 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1184 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1185 "AES GCM testsuite not met\n");
1186 return TEST_SKIPPED;
1193 negative_aes_gmac_testsuite_setup(void)
1195 struct crypto_testsuite_params *ts_params = &testsuite_params;
1196 uint8_t dev_id = ts_params->valid_devs[0];
1197 struct rte_cryptodev_info dev_info;
1198 const enum rte_crypto_auth_algorithm auths[] = {
1199 RTE_CRYPTO_AUTH_AES_GMAC
1202 rte_cryptodev_info_get(dev_id, &dev_info);
1204 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1205 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1206 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1207 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1208 "AES GMAC testsuite not met\n");
1209 return TEST_SKIPPED;
1212 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1213 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1214 "AES GMAC testsuite not met\n");
1215 return TEST_SKIPPED;
1222 mixed_cipher_hash_testsuite_setup(void)
1224 struct crypto_testsuite_params *ts_params = &testsuite_params;
1225 uint8_t dev_id = ts_params->valid_devs[0];
1226 struct rte_cryptodev_info dev_info;
1227 uint64_t feat_flags;
1228 const enum rte_crypto_cipher_algorithm ciphers[] = {
1229 RTE_CRYPTO_CIPHER_NULL,
1230 RTE_CRYPTO_CIPHER_AES_CTR,
1231 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1232 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1234 const enum rte_crypto_auth_algorithm auths[] = {
1235 RTE_CRYPTO_AUTH_NULL,
1236 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1237 RTE_CRYPTO_AUTH_AES_CMAC,
1238 RTE_CRYPTO_AUTH_ZUC_EIA3
1241 rte_cryptodev_info_get(dev_id, &dev_info);
1242 feat_flags = dev_info.feature_flags;
1244 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1245 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1246 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1247 "Cipher Hash testsuite not met\n");
1248 return TEST_SKIPPED;
1251 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1252 && check_auth_capabilities_supported(auths,
1253 RTE_DIM(auths)) != 0) {
1254 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1255 "Cipher Hash testsuite not met\n");
1256 return TEST_SKIPPED;
1263 esn_testsuite_setup(void)
1265 struct crypto_testsuite_params *ts_params = &testsuite_params;
1266 uint8_t dev_id = ts_params->valid_devs[0];
1267 struct rte_cryptodev_info dev_info;
1268 const enum rte_crypto_cipher_algorithm ciphers[] = {
1269 RTE_CRYPTO_CIPHER_AES_CBC
1271 const enum rte_crypto_auth_algorithm auths[] = {
1272 RTE_CRYPTO_AUTH_SHA1_HMAC
1275 rte_cryptodev_info_get(dev_id, &dev_info);
1277 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1278 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1279 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1280 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1281 "testsuite not met\n");
1282 return TEST_SKIPPED;
1285 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1286 && check_auth_capabilities_supported(auths,
1287 RTE_DIM(auths)) != 0) {
1288 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1289 "testsuite not met\n");
1290 return TEST_SKIPPED;
1297 multi_session_testsuite_setup(void)
1299 struct crypto_testsuite_params *ts_params = &testsuite_params;
1300 uint8_t dev_id = ts_params->valid_devs[0];
1301 struct rte_cryptodev_info dev_info;
1302 const enum rte_crypto_cipher_algorithm ciphers[] = {
1303 RTE_CRYPTO_CIPHER_AES_CBC
1305 const enum rte_crypto_auth_algorithm auths[] = {
1306 RTE_CRYPTO_AUTH_SHA512_HMAC
1309 rte_cryptodev_info_get(dev_id, &dev_info);
1311 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1312 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1313 "Session testsuite not met\n");
1314 return TEST_SKIPPED;
1317 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1318 && check_auth_capabilities_supported(auths,
1319 RTE_DIM(auths)) != 0) {
1320 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1321 "Session testsuite not met\n");
1322 return TEST_SKIPPED;
1329 negative_hmac_sha1_testsuite_setup(void)
1331 struct crypto_testsuite_params *ts_params = &testsuite_params;
1332 uint8_t dev_id = ts_params->valid_devs[0];
1333 struct rte_cryptodev_info dev_info;
1334 const enum rte_crypto_cipher_algorithm ciphers[] = {
1335 RTE_CRYPTO_CIPHER_AES_CBC
1337 const enum rte_crypto_auth_algorithm auths[] = {
1338 RTE_CRYPTO_AUTH_SHA1_HMAC
1341 rte_cryptodev_info_get(dev_id, &dev_info);
1343 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1344 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1345 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1346 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1347 "HMAC SHA1 testsuite not met\n");
1348 return TEST_SKIPPED;
1351 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1352 && check_auth_capabilities_supported(auths,
1353 RTE_DIM(auths)) != 0) {
1354 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1355 "HMAC SHA1 testsuite not met\n");
1356 return TEST_SKIPPED;
1363 dev_configure_and_start(uint64_t ff_disable)
1365 struct crypto_testsuite_params *ts_params = &testsuite_params;
1366 struct crypto_unittest_params *ut_params = &unittest_params;
1370 /* Clear unit test parameters before running test */
1371 memset(ut_params, 0, sizeof(*ut_params));
1373 /* Reconfigure device to default parameters */
1374 ts_params->conf.socket_id = SOCKET_ID_ANY;
1375 ts_params->conf.ff_disable = ff_disable;
1376 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1377 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1378 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1380 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1382 "Failed to configure cryptodev %u",
1383 ts_params->valid_devs[0]);
1385 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1386 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1387 ts_params->valid_devs[0], qp_id,
1388 &ts_params->qp_conf,
1389 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1390 "Failed to setup queue pair %u on cryptodev %u",
1391 qp_id, ts_params->valid_devs[0]);
1395 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1397 /* Start the device */
1398 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1399 "Failed to start cryptodev %u",
1400 ts_params->valid_devs[0]);
1402 return TEST_SUCCESS;
1408 /* Configure and start the device with security feature disabled */
1409 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1413 ut_setup_security(void)
1415 /* Configure and start the device with no features disabled */
1416 return dev_configure_and_start(0);
1422 struct crypto_testsuite_params *ts_params = &testsuite_params;
1423 struct crypto_unittest_params *ut_params = &unittest_params;
1425 /* free crypto session structure */
1426 #ifdef RTE_LIB_SECURITY
1427 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1428 if (ut_params->sec_session) {
1429 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1430 (ts_params->valid_devs[0]),
1431 ut_params->sec_session);
1432 ut_params->sec_session = NULL;
1437 if (ut_params->sess) {
1438 rte_cryptodev_sym_session_clear(
1439 ts_params->valid_devs[0],
1441 rte_cryptodev_sym_session_free(ut_params->sess);
1442 ut_params->sess = NULL;
1446 /* free crypto operation structure */
1448 rte_crypto_op_free(ut_params->op);
1451 * free mbuf - both obuf and ibuf are usually the same,
1452 * so check if they point at the same address is necessary,
1453 * to avoid freeing the mbuf twice.
1455 if (ut_params->obuf) {
1456 rte_pktmbuf_free(ut_params->obuf);
1457 if (ut_params->ibuf == ut_params->obuf)
1458 ut_params->ibuf = 0;
1459 ut_params->obuf = 0;
1461 if (ut_params->ibuf) {
1462 rte_pktmbuf_free(ut_params->ibuf);
1463 ut_params->ibuf = 0;
1466 if (ts_params->mbuf_pool != NULL)
1467 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1468 rte_mempool_avail_count(ts_params->mbuf_pool));
1470 /* Stop the device */
1471 rte_cryptodev_stop(ts_params->valid_devs[0]);
1475 test_device_configure_invalid_dev_id(void)
1477 struct crypto_testsuite_params *ts_params = &testsuite_params;
1478 uint16_t dev_id, num_devs = 0;
1480 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1481 "Need at least %d devices for test", 1);
1483 /* valid dev_id values */
1484 dev_id = ts_params->valid_devs[0];
1486 /* Stop the device in case it's started so it can be configured */
1487 rte_cryptodev_stop(dev_id);
1489 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1490 "Failed test for rte_cryptodev_configure: "
1491 "invalid dev_num %u", dev_id);
1493 /* invalid dev_id values */
1496 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1497 "Failed test for rte_cryptodev_configure: "
1498 "invalid dev_num %u", dev_id);
1502 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1503 "Failed test for rte_cryptodev_configure:"
1504 "invalid dev_num %u", dev_id);
1506 return TEST_SUCCESS;
1510 test_device_configure_invalid_queue_pair_ids(void)
1512 struct crypto_testsuite_params *ts_params = &testsuite_params;
1513 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1515 /* Stop the device in case it's started so it can be configured */
1516 rte_cryptodev_stop(ts_params->valid_devs[0]);
1518 /* valid - max value queue pairs */
1519 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1521 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1523 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1524 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1526 /* valid - one queue pairs */
1527 ts_params->conf.nb_queue_pairs = 1;
1529 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1531 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1532 ts_params->valid_devs[0],
1533 ts_params->conf.nb_queue_pairs);
1536 /* invalid - zero queue pairs */
1537 ts_params->conf.nb_queue_pairs = 0;
1539 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1541 "Failed test for rte_cryptodev_configure, dev_id %u,"
1543 ts_params->valid_devs[0],
1544 ts_params->conf.nb_queue_pairs);
1547 /* invalid - max value supported by field queue pairs */
1548 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1550 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1552 "Failed test for rte_cryptodev_configure, dev_id %u,"
1554 ts_params->valid_devs[0],
1555 ts_params->conf.nb_queue_pairs);
1558 /* invalid - max value + 1 queue pairs */
1559 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1561 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1563 "Failed test for rte_cryptodev_configure, dev_id %u,"
1565 ts_params->valid_devs[0],
1566 ts_params->conf.nb_queue_pairs);
1568 /* revert to original testsuite value */
1569 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1571 return TEST_SUCCESS;
1575 test_queue_pair_descriptor_setup(void)
1577 struct crypto_testsuite_params *ts_params = &testsuite_params;
1578 struct rte_cryptodev_qp_conf qp_conf = {
1579 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1583 /* Stop the device in case it's started so it can be configured */
1584 rte_cryptodev_stop(ts_params->valid_devs[0]);
1586 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1588 "Failed to configure cryptodev %u",
1589 ts_params->valid_devs[0]);
1592 * Test various ring sizes on this device. memzones can't be
1593 * freed so are re-used if ring is released and re-created.
1595 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1596 qp_conf.mp_session = ts_params->session_mpool;
1597 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1599 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1600 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1601 ts_params->valid_devs[0], qp_id, &qp_conf,
1602 rte_cryptodev_socket_id(
1603 ts_params->valid_devs[0])),
1605 "rte_cryptodev_queue_pair_setup: num_inflights "
1606 "%u on qp %u on cryptodev %u",
1607 qp_conf.nb_descriptors, qp_id,
1608 ts_params->valid_devs[0]);
1611 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1613 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1614 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1615 ts_params->valid_devs[0], qp_id, &qp_conf,
1616 rte_cryptodev_socket_id(
1617 ts_params->valid_devs[0])),
1619 " rte_cryptodev_queue_pair_setup: num_inflights"
1620 " %u on qp %u on cryptodev %u",
1621 qp_conf.nb_descriptors, qp_id,
1622 ts_params->valid_devs[0]);
1625 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1627 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1628 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1629 ts_params->valid_devs[0], qp_id, &qp_conf,
1630 rte_cryptodev_socket_id(
1631 ts_params->valid_devs[0])),
1633 "rte_cryptodev_queue_pair_setup: num_inflights"
1634 " %u on qp %u on cryptodev %u",
1635 qp_conf.nb_descriptors, qp_id,
1636 ts_params->valid_devs[0]);
1639 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1641 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1642 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1643 ts_params->valid_devs[0], qp_id, &qp_conf,
1644 rte_cryptodev_socket_id(
1645 ts_params->valid_devs[0])),
1647 " rte_cryptodev_queue_pair_setup:"
1648 "num_inflights %u on qp %u on cryptodev %u",
1649 qp_conf.nb_descriptors, qp_id,
1650 ts_params->valid_devs[0]);
1653 /* test invalid queue pair id */
1654 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1656 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1658 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1659 ts_params->valid_devs[0],
1661 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1662 "Failed test for rte_cryptodev_queue_pair_setup:"
1663 "invalid qp %u on cryptodev %u",
1664 qp_id, ts_params->valid_devs[0]);
1666 qp_id = 0xffff; /*invalid*/
1668 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1669 ts_params->valid_devs[0],
1671 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1672 "Failed test for rte_cryptodev_queue_pair_setup:"
1673 "invalid qp %u on cryptodev %u",
1674 qp_id, ts_params->valid_devs[0]);
1676 return TEST_SUCCESS;
1679 /* ***** Plaintext data for tests ***** */
1681 const char catch_22_quote_1[] =
1682 "There was only one catch and that was Catch-22, which "
1683 "specified that a concern for one's safety in the face of "
1684 "dangers that were real and immediate was the process of a "
1685 "rational mind. Orr was crazy and could be grounded. All he "
1686 "had to do was ask; and as soon as he did, he would no longer "
1687 "be crazy and would have to fly more missions. Orr would be "
1688 "crazy to fly more missions and sane if he didn't, but if he "
1689 "was sane he had to fly them. If he flew them he was crazy "
1690 "and didn't have to; but if he didn't want to he was sane and "
1691 "had to. Yossarian was moved very deeply by the absolute "
1692 "simplicity of this clause of Catch-22 and let out a "
1693 "respectful whistle. \"That's some catch, that Catch-22\", he "
1694 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1696 const char catch_22_quote[] =
1697 "What a lousy earth! He wondered how many people were "
1698 "destitute that same night even in his own prosperous country, "
1699 "how many homes were shanties, how many husbands were drunk "
1700 "and wives socked, and how many children were bullied, abused, "
1701 "or abandoned. How many families hungered for food they could "
1702 "not afford to buy? How many hearts were broken? How many "
1703 "suicides would take place that same night, how many people "
1704 "would go insane? How many cockroaches and landlords would "
1705 "triumph? How many winners were losers, successes failures, "
1706 "and rich men poor men? How many wise guys were stupid? How "
1707 "many happy endings were unhappy endings? How many honest men "
1708 "were liars, brave men cowards, loyal men traitors, how many "
1709 "sainted men were corrupt, how many people in positions of "
1710 "trust had sold their souls to bodyguards, how many had never "
1711 "had souls? How many straight-and-narrow paths were crooked "
1712 "paths? How many best families were worst families and how "
1713 "many good people were bad people? When you added them all up "
1714 "and then subtracted, you might be left with only the children, "
1715 "and perhaps with Albert Einstein and an old violinist or "
1716 "sculptor somewhere.";
1718 #define QUOTE_480_BYTES (480)
1719 #define QUOTE_512_BYTES (512)
1720 #define QUOTE_768_BYTES (768)
1721 #define QUOTE_1024_BYTES (1024)
1725 /* ***** SHA1 Hash Tests ***** */
1727 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1729 static uint8_t hmac_sha1_key[] = {
1730 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1731 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1732 0xDE, 0xF4, 0xDE, 0xAD };
1734 /* ***** SHA224 Hash Tests ***** */
1736 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1739 /* ***** AES-CBC Cipher Tests ***** */
1741 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1742 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1744 static uint8_t aes_cbc_key[] = {
1745 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1746 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1748 static uint8_t aes_cbc_iv[] = {
1749 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1750 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1753 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1755 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1756 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1757 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1758 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1759 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1760 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1761 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1762 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1763 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1764 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1765 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1766 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1767 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1768 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1769 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1770 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1771 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1772 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1773 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1774 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1775 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1776 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1777 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1778 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1779 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1780 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1781 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1782 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1783 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1784 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1785 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1786 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1787 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1788 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1789 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1790 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1791 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1792 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1793 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1794 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1795 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1796 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1797 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1798 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1799 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1800 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1801 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1802 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1803 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1804 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1805 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1806 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1807 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1808 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1809 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1810 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1811 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1812 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1813 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1814 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1815 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1816 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1817 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1818 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1819 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1822 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1823 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1824 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1825 0x18, 0x8c, 0x1d, 0x32
1829 /* Multisession Vector context Test */
1830 /*Begin Session 0 */
1831 static uint8_t ms_aes_cbc_key0[] = {
1832 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1833 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1836 static uint8_t ms_aes_cbc_iv0[] = {
1837 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1838 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1841 static const uint8_t ms_aes_cbc_cipher0[] = {
1842 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1843 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1844 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1845 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1846 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1847 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1848 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1849 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1850 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1851 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1852 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1853 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1854 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1855 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1856 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1857 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1858 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1859 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1860 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1861 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1862 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1863 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1864 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1865 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1866 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1867 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1868 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1869 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1870 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1871 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1872 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1873 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1874 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1875 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1876 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1877 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1878 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1879 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1880 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1881 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1882 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1883 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1884 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1885 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1886 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1887 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1888 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1889 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1890 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1891 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1892 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1893 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1894 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1895 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1896 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1897 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1898 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1899 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1900 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1901 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1902 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1903 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1904 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1905 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1909 static uint8_t ms_hmac_key0[] = {
1910 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1911 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1912 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1913 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1914 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1915 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1916 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1917 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1920 static const uint8_t ms_hmac_digest0[] = {
1921 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1922 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1923 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1924 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1925 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1926 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1927 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1928 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1932 /* Begin session 1 */
1934 static uint8_t ms_aes_cbc_key1[] = {
1935 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1936 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1939 static uint8_t ms_aes_cbc_iv1[] = {
1940 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1941 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1944 static const uint8_t ms_aes_cbc_cipher1[] = {
1945 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1946 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1947 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1948 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1949 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1950 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1951 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1952 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1953 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1954 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1955 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1956 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1957 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1958 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1959 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1960 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1961 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1962 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1963 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1964 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1965 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1966 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1967 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1968 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1969 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1970 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1971 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1972 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1973 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1974 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1975 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1976 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1977 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1978 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1979 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1980 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1981 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1982 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1983 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1984 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1985 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1986 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1987 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1988 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1989 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1990 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1991 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1992 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1993 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1994 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1995 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1996 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1997 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1998 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1999 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2000 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2001 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2002 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2003 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2004 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2005 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2006 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2007 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2008 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2012 static uint8_t ms_hmac_key1[] = {
2013 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2014 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2015 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2016 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2017 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2018 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2019 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2020 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2023 static const uint8_t ms_hmac_digest1[] = {
2024 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2025 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2026 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2027 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2028 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2029 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2030 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2031 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2034 /* Begin Session 2 */
2035 static uint8_t ms_aes_cbc_key2[] = {
2036 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2037 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2040 static uint8_t ms_aes_cbc_iv2[] = {
2041 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2042 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2045 static const uint8_t ms_aes_cbc_cipher2[] = {
2046 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2047 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2048 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2049 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2050 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2051 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2052 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2053 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2054 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2055 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2056 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2057 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2058 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2059 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2060 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2061 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2062 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2063 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2064 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2065 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2066 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2067 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2068 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2069 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2070 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2071 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2072 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2073 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2074 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2075 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2076 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2077 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2078 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2079 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2080 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2081 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2082 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2083 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2084 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2085 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2086 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2087 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2088 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2089 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2090 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2091 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2092 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2093 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2094 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2095 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2096 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2097 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2098 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2099 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2100 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2101 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2102 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2103 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2104 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2105 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2106 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2107 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2108 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2109 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2112 static uint8_t ms_hmac_key2[] = {
2113 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2114 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2115 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2116 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2117 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2118 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2119 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2120 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2123 static const uint8_t ms_hmac_digest2[] = {
2124 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2125 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2126 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2127 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2128 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2129 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2130 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2131 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2138 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2140 struct crypto_testsuite_params *ts_params = &testsuite_params;
2141 struct crypto_unittest_params *ut_params = &unittest_params;
2144 /* Verify the capabilities */
2145 struct rte_cryptodev_sym_capability_idx cap_idx;
2146 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2147 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2148 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2150 return TEST_SKIPPED;
2151 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2152 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2153 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2155 return TEST_SKIPPED;
2157 /* Generate test mbuf data and space for digest */
2158 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2159 catch_22_quote, QUOTE_512_BYTES, 0);
2161 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2162 DIGEST_BYTE_LENGTH_SHA1);
2163 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2165 /* Setup Cipher Parameters */
2166 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2167 ut_params->cipher_xform.next = &ut_params->auth_xform;
2169 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2170 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2171 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2172 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2173 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2174 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2176 /* Setup HMAC Parameters */
2177 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2179 ut_params->auth_xform.next = NULL;
2181 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2182 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2183 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2184 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2185 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2187 ut_params->sess = rte_cryptodev_sym_session_create(
2188 ts_params->session_mpool);
2189 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2191 /* Create crypto session*/
2192 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2193 ut_params->sess, &ut_params->cipher_xform,
2194 ts_params->session_priv_mpool);
2196 if (status == -ENOTSUP)
2197 return TEST_SKIPPED;
2199 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
2201 /* Generate crypto op data structure */
2202 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2203 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2204 TEST_ASSERT_NOT_NULL(ut_params->op,
2205 "Failed to allocate symmetric crypto operation struct");
2207 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2209 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2211 /* set crypto operation source mbuf */
2212 sym_op->m_src = ut_params->ibuf;
2214 /* Set crypto operation authentication parameters */
2215 sym_op->auth.digest.data = ut_params->digest;
2216 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2217 ut_params->ibuf, QUOTE_512_BYTES);
2219 sym_op->auth.data.offset = 0;
2220 sym_op->auth.data.length = QUOTE_512_BYTES;
2222 /* Copy IV at the end of the crypto operation */
2223 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2224 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2226 /* Set crypto operation cipher parameters */
2227 sym_op->cipher.data.offset = 0;
2228 sym_op->cipher.data.length = QUOTE_512_BYTES;
2230 /* Process crypto operation */
2231 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2232 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2235 TEST_ASSERT_NOT_NULL(
2236 process_crypto_request(ts_params->valid_devs[0],
2238 "failed to process sym crypto op");
2240 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2241 "crypto op processing failed");
2244 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2247 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2248 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2250 "ciphertext data not as expected");
2252 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2254 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2255 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2256 gbl_driver_id == rte_cryptodev_driver_id_get(
2257 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2258 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2259 DIGEST_BYTE_LENGTH_SHA1,
2260 "Generated digest data not as expected");
2262 return TEST_SUCCESS;
2265 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2267 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2269 static uint8_t hmac_sha512_key[] = {
2270 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2271 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2272 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2273 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2274 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2275 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2276 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2277 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2279 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2280 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2281 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2282 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2283 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2284 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2285 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2286 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2287 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2292 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2293 struct crypto_unittest_params *ut_params,
2294 uint8_t *cipher_key,
2298 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2299 struct crypto_unittest_params *ut_params,
2300 struct crypto_testsuite_params *ts_params,
2301 const uint8_t *cipher,
2302 const uint8_t *digest,
2307 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2308 struct crypto_unittest_params *ut_params,
2309 uint8_t *cipher_key,
2313 /* Setup Cipher Parameters */
2314 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2315 ut_params->cipher_xform.next = NULL;
2317 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2318 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2319 ut_params->cipher_xform.cipher.key.data = cipher_key;
2320 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2321 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2322 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2324 /* Setup HMAC Parameters */
2325 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2326 ut_params->auth_xform.next = &ut_params->cipher_xform;
2328 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2329 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2330 ut_params->auth_xform.auth.key.data = hmac_key;
2331 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2332 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2334 return TEST_SUCCESS;
2339 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2340 struct crypto_unittest_params *ut_params,
2341 struct crypto_testsuite_params *ts_params,
2342 const uint8_t *cipher,
2343 const uint8_t *digest,
2346 /* Generate test mbuf data and digest */
2347 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2350 QUOTE_512_BYTES, 0);
2352 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2353 DIGEST_BYTE_LENGTH_SHA512);
2354 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2356 rte_memcpy(ut_params->digest,
2358 DIGEST_BYTE_LENGTH_SHA512);
2360 /* Generate Crypto op data structure */
2361 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2362 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2363 TEST_ASSERT_NOT_NULL(ut_params->op,
2364 "Failed to allocate symmetric crypto operation struct");
2366 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2368 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2370 /* set crypto operation source mbuf */
2371 sym_op->m_src = ut_params->ibuf;
2373 sym_op->auth.digest.data = ut_params->digest;
2374 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2375 ut_params->ibuf, QUOTE_512_BYTES);
2377 sym_op->auth.data.offset = 0;
2378 sym_op->auth.data.length = QUOTE_512_BYTES;
2380 /* Copy IV at the end of the crypto operation */
2381 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2382 iv, CIPHER_IV_LENGTH_AES_CBC);
2384 sym_op->cipher.data.offset = 0;
2385 sym_op->cipher.data.length = QUOTE_512_BYTES;
2387 /* Process crypto operation */
2388 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2389 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2391 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2392 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2393 ut_params->op, 1, 1, 0, 0);
2395 TEST_ASSERT_NOT_NULL(
2396 process_crypto_request(ts_params->valid_devs[0],
2398 "failed to process sym crypto op");
2400 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2401 "crypto op processing failed");
2403 ut_params->obuf = ut_params->op->sym->m_src;
2406 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2407 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2410 "Plaintext data not as expected");
2413 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2414 "Digest verification failed");
2416 return TEST_SUCCESS;
2419 /* ***** SNOW 3G Tests ***** */
2421 create_wireless_algo_hash_session(uint8_t dev_id,
2422 const uint8_t *key, const uint8_t key_len,
2423 const uint8_t iv_len, const uint8_t auth_len,
2424 enum rte_crypto_auth_operation op,
2425 enum rte_crypto_auth_algorithm algo)
2427 uint8_t hash_key[key_len];
2430 struct crypto_testsuite_params *ts_params = &testsuite_params;
2431 struct crypto_unittest_params *ut_params = &unittest_params;
2433 memcpy(hash_key, key, key_len);
2435 debug_hexdump(stdout, "key:", key, key_len);
2437 /* Setup Authentication Parameters */
2438 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2439 ut_params->auth_xform.next = NULL;
2441 ut_params->auth_xform.auth.op = op;
2442 ut_params->auth_xform.auth.algo = algo;
2443 ut_params->auth_xform.auth.key.length = key_len;
2444 ut_params->auth_xform.auth.key.data = hash_key;
2445 ut_params->auth_xform.auth.digest_length = auth_len;
2446 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2447 ut_params->auth_xform.auth.iv.length = iv_len;
2448 ut_params->sess = rte_cryptodev_sym_session_create(
2449 ts_params->session_mpool);
2451 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2452 &ut_params->auth_xform,
2453 ts_params->session_priv_mpool);
2454 if (status == -ENOTSUP)
2455 return TEST_SKIPPED;
2457 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2458 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2463 create_wireless_algo_cipher_session(uint8_t dev_id,
2464 enum rte_crypto_cipher_operation op,
2465 enum rte_crypto_cipher_algorithm algo,
2466 const uint8_t *key, const uint8_t key_len,
2469 uint8_t cipher_key[key_len];
2471 struct crypto_testsuite_params *ts_params = &testsuite_params;
2472 struct crypto_unittest_params *ut_params = &unittest_params;
2474 memcpy(cipher_key, key, key_len);
2476 /* Setup Cipher Parameters */
2477 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2478 ut_params->cipher_xform.next = NULL;
2480 ut_params->cipher_xform.cipher.algo = algo;
2481 ut_params->cipher_xform.cipher.op = op;
2482 ut_params->cipher_xform.cipher.key.data = cipher_key;
2483 ut_params->cipher_xform.cipher.key.length = key_len;
2484 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2485 ut_params->cipher_xform.cipher.iv.length = iv_len;
2487 debug_hexdump(stdout, "key:", key, key_len);
2489 /* Create Crypto session */
2490 ut_params->sess = rte_cryptodev_sym_session_create(
2491 ts_params->session_mpool);
2493 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2494 &ut_params->cipher_xform,
2495 ts_params->session_priv_mpool);
2496 if (status == -ENOTSUP)
2497 return TEST_SKIPPED;
2499 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2500 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2505 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2506 unsigned int cipher_len,
2507 unsigned int cipher_offset)
2509 struct crypto_testsuite_params *ts_params = &testsuite_params;
2510 struct crypto_unittest_params *ut_params = &unittest_params;
2512 /* Generate Crypto op data structure */
2513 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2514 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2515 TEST_ASSERT_NOT_NULL(ut_params->op,
2516 "Failed to allocate pktmbuf offload");
2518 /* Set crypto operation data parameters */
2519 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2521 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2523 /* set crypto operation source mbuf */
2524 sym_op->m_src = ut_params->ibuf;
2527 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2529 sym_op->cipher.data.length = cipher_len;
2530 sym_op->cipher.data.offset = cipher_offset;
2535 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2536 unsigned int cipher_len,
2537 unsigned int cipher_offset)
2539 struct crypto_testsuite_params *ts_params = &testsuite_params;
2540 struct crypto_unittest_params *ut_params = &unittest_params;
2542 /* Generate Crypto op data structure */
2543 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2544 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2545 TEST_ASSERT_NOT_NULL(ut_params->op,
2546 "Failed to allocate pktmbuf offload");
2548 /* Set crypto operation data parameters */
2549 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2551 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2553 /* set crypto operation source mbuf */
2554 sym_op->m_src = ut_params->ibuf;
2555 sym_op->m_dst = ut_params->obuf;
2558 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2560 sym_op->cipher.data.length = cipher_len;
2561 sym_op->cipher.data.offset = cipher_offset;
2566 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2567 enum rte_crypto_cipher_operation cipher_op,
2568 enum rte_crypto_auth_operation auth_op,
2569 enum rte_crypto_auth_algorithm auth_algo,
2570 enum rte_crypto_cipher_algorithm cipher_algo,
2571 const uint8_t *key, uint8_t key_len,
2572 uint8_t auth_iv_len, uint8_t auth_len,
2573 uint8_t cipher_iv_len)
2576 uint8_t cipher_auth_key[key_len];
2579 struct crypto_testsuite_params *ts_params = &testsuite_params;
2580 struct crypto_unittest_params *ut_params = &unittest_params;
2582 memcpy(cipher_auth_key, key, key_len);
2584 /* Setup Authentication Parameters */
2585 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2586 ut_params->auth_xform.next = NULL;
2588 ut_params->auth_xform.auth.op = auth_op;
2589 ut_params->auth_xform.auth.algo = auth_algo;
2590 ut_params->auth_xform.auth.key.length = key_len;
2591 /* Hash key = cipher key */
2592 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2593 ut_params->auth_xform.auth.digest_length = auth_len;
2594 /* Auth IV will be after cipher IV */
2595 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2596 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2598 /* Setup Cipher Parameters */
2599 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2600 ut_params->cipher_xform.next = &ut_params->auth_xform;
2602 ut_params->cipher_xform.cipher.algo = cipher_algo;
2603 ut_params->cipher_xform.cipher.op = cipher_op;
2604 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2605 ut_params->cipher_xform.cipher.key.length = key_len;
2606 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2607 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2609 debug_hexdump(stdout, "key:", key, key_len);
2611 /* Create Crypto session*/
2612 ut_params->sess = rte_cryptodev_sym_session_create(
2613 ts_params->session_mpool);
2614 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2616 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2617 &ut_params->cipher_xform,
2618 ts_params->session_priv_mpool);
2619 if (status == -ENOTSUP)
2620 return TEST_SKIPPED;
2622 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2627 create_wireless_cipher_auth_session(uint8_t dev_id,
2628 enum rte_crypto_cipher_operation cipher_op,
2629 enum rte_crypto_auth_operation auth_op,
2630 enum rte_crypto_auth_algorithm auth_algo,
2631 enum rte_crypto_cipher_algorithm cipher_algo,
2632 const struct wireless_test_data *tdata)
2634 const uint8_t key_len = tdata->key.len;
2635 uint8_t cipher_auth_key[key_len];
2638 struct crypto_testsuite_params *ts_params = &testsuite_params;
2639 struct crypto_unittest_params *ut_params = &unittest_params;
2640 const uint8_t *key = tdata->key.data;
2641 const uint8_t auth_len = tdata->digest.len;
2642 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2643 uint8_t auth_iv_len = tdata->auth_iv.len;
2645 memcpy(cipher_auth_key, key, key_len);
2647 /* Setup Authentication Parameters */
2648 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2649 ut_params->auth_xform.next = NULL;
2651 ut_params->auth_xform.auth.op = auth_op;
2652 ut_params->auth_xform.auth.algo = auth_algo;
2653 ut_params->auth_xform.auth.key.length = key_len;
2654 /* Hash key = cipher key */
2655 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2656 ut_params->auth_xform.auth.digest_length = auth_len;
2657 /* Auth IV will be after cipher IV */
2658 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2659 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2661 /* Setup Cipher Parameters */
2662 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2663 ut_params->cipher_xform.next = &ut_params->auth_xform;
2665 ut_params->cipher_xform.cipher.algo = cipher_algo;
2666 ut_params->cipher_xform.cipher.op = cipher_op;
2667 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2668 ut_params->cipher_xform.cipher.key.length = key_len;
2669 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2670 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2673 debug_hexdump(stdout, "key:", key, key_len);
2675 /* Create Crypto session*/
2676 ut_params->sess = rte_cryptodev_sym_session_create(
2677 ts_params->session_mpool);
2679 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2680 &ut_params->cipher_xform,
2681 ts_params->session_priv_mpool);
2682 if (status == -ENOTSUP)
2683 return TEST_SKIPPED;
2685 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2686 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2691 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2692 const struct wireless_test_data *tdata)
2694 return create_wireless_cipher_auth_session(dev_id,
2695 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2696 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2697 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2701 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2702 enum rte_crypto_cipher_operation cipher_op,
2703 enum rte_crypto_auth_operation auth_op,
2704 enum rte_crypto_auth_algorithm auth_algo,
2705 enum rte_crypto_cipher_algorithm cipher_algo,
2706 const uint8_t *key, const uint8_t key_len,
2707 uint8_t auth_iv_len, uint8_t auth_len,
2708 uint8_t cipher_iv_len)
2710 uint8_t auth_cipher_key[key_len];
2712 struct crypto_testsuite_params *ts_params = &testsuite_params;
2713 struct crypto_unittest_params *ut_params = &unittest_params;
2715 memcpy(auth_cipher_key, key, key_len);
2717 /* Setup Authentication Parameters */
2718 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2719 ut_params->auth_xform.auth.op = auth_op;
2720 ut_params->auth_xform.next = &ut_params->cipher_xform;
2721 ut_params->auth_xform.auth.algo = auth_algo;
2722 ut_params->auth_xform.auth.key.length = key_len;
2723 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2724 ut_params->auth_xform.auth.digest_length = auth_len;
2725 /* Auth IV will be after cipher IV */
2726 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2727 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2729 /* Setup Cipher Parameters */
2730 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2731 ut_params->cipher_xform.next = NULL;
2732 ut_params->cipher_xform.cipher.algo = cipher_algo;
2733 ut_params->cipher_xform.cipher.op = cipher_op;
2734 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2735 ut_params->cipher_xform.cipher.key.length = key_len;
2736 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2737 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2739 debug_hexdump(stdout, "key:", key, key_len);
2741 /* Create Crypto session*/
2742 ut_params->sess = rte_cryptodev_sym_session_create(
2743 ts_params->session_mpool);
2744 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2746 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2747 ut_params->auth_xform.next = NULL;
2748 ut_params->cipher_xform.next = &ut_params->auth_xform;
2749 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2750 &ut_params->cipher_xform,
2751 ts_params->session_priv_mpool);
2754 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2755 &ut_params->auth_xform,
2756 ts_params->session_priv_mpool);
2758 if (status == -ENOTSUP)
2759 return TEST_SKIPPED;
2761 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2767 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2768 unsigned int auth_tag_len,
2769 const uint8_t *iv, unsigned int iv_len,
2770 unsigned int data_pad_len,
2771 enum rte_crypto_auth_operation op,
2772 unsigned int auth_len, unsigned int auth_offset)
2774 struct crypto_testsuite_params *ts_params = &testsuite_params;
2776 struct crypto_unittest_params *ut_params = &unittest_params;
2778 /* Generate Crypto op data structure */
2779 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2780 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2781 TEST_ASSERT_NOT_NULL(ut_params->op,
2782 "Failed to allocate pktmbuf offload");
2784 /* Set crypto operation data parameters */
2785 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2787 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2789 /* set crypto operation source mbuf */
2790 sym_op->m_src = ut_params->ibuf;
2793 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2796 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2797 ut_params->ibuf, auth_tag_len);
2799 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2800 "no room to append auth tag");
2801 ut_params->digest = sym_op->auth.digest.data;
2802 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2803 ut_params->ibuf, data_pad_len);
2804 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2805 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2807 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2809 debug_hexdump(stdout, "digest:",
2810 sym_op->auth.digest.data,
2813 sym_op->auth.data.length = auth_len;
2814 sym_op->auth.data.offset = auth_offset;
2820 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2821 enum rte_crypto_auth_operation op)
2823 struct crypto_testsuite_params *ts_params = &testsuite_params;
2824 struct crypto_unittest_params *ut_params = &unittest_params;
2826 const uint8_t *auth_tag = tdata->digest.data;
2827 const unsigned int auth_tag_len = tdata->digest.len;
2828 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2829 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2831 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2832 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2833 const uint8_t *auth_iv = tdata->auth_iv.data;
2834 const uint8_t auth_iv_len = tdata->auth_iv.len;
2835 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2836 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2838 /* Generate Crypto op data structure */
2839 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2840 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2841 TEST_ASSERT_NOT_NULL(ut_params->op,
2842 "Failed to allocate pktmbuf offload");
2843 /* Set crypto operation data parameters */
2844 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2846 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2848 /* set crypto operation source mbuf */
2849 sym_op->m_src = ut_params->ibuf;
2852 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2853 ut_params->ibuf, auth_tag_len);
2855 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2856 "no room to append auth tag");
2857 ut_params->digest = sym_op->auth.digest.data;
2858 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2859 ut_params->ibuf, data_pad_len);
2860 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2861 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2863 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2865 debug_hexdump(stdout, "digest:",
2866 sym_op->auth.digest.data,
2869 /* Copy cipher and auth IVs at the end of the crypto operation */
2870 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2872 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2873 iv_ptr += cipher_iv_len;
2874 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2876 sym_op->cipher.data.length = cipher_len;
2877 sym_op->cipher.data.offset = 0;
2878 sym_op->auth.data.length = auth_len;
2879 sym_op->auth.data.offset = 0;
2885 create_zuc_cipher_hash_generate_operation(
2886 const struct wireless_test_data *tdata)
2888 return create_wireless_cipher_hash_operation(tdata,
2889 RTE_CRYPTO_AUTH_OP_GENERATE);
2893 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2894 const unsigned auth_tag_len,
2895 const uint8_t *auth_iv, uint8_t auth_iv_len,
2896 unsigned data_pad_len,
2897 enum rte_crypto_auth_operation op,
2898 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2899 const unsigned cipher_len, const unsigned cipher_offset,
2900 const unsigned auth_len, const unsigned auth_offset)
2902 struct crypto_testsuite_params *ts_params = &testsuite_params;
2903 struct crypto_unittest_params *ut_params = &unittest_params;
2905 enum rte_crypto_cipher_algorithm cipher_algo =
2906 ut_params->cipher_xform.cipher.algo;
2907 enum rte_crypto_auth_algorithm auth_algo =
2908 ut_params->auth_xform.auth.algo;
2910 /* Generate Crypto op data structure */
2911 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2912 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2913 TEST_ASSERT_NOT_NULL(ut_params->op,
2914 "Failed to allocate pktmbuf offload");
2915 /* Set crypto operation data parameters */
2916 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2918 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2920 /* set crypto operation source mbuf */
2921 sym_op->m_src = ut_params->ibuf;
2924 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2925 ut_params->ibuf, auth_tag_len);
2927 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2928 "no room to append auth tag");
2929 ut_params->digest = sym_op->auth.digest.data;
2931 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2932 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2933 ut_params->ibuf, data_pad_len);
2935 struct rte_mbuf *m = ut_params->ibuf;
2936 unsigned int offset = data_pad_len;
2938 while (offset > m->data_len && m->next != NULL) {
2939 offset -= m->data_len;
2942 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2946 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2947 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2949 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2951 debug_hexdump(stdout, "digest:",
2952 sym_op->auth.digest.data,
2955 /* Copy cipher and auth IVs at the end of the crypto operation */
2956 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2958 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2959 iv_ptr += cipher_iv_len;
2960 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2962 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2963 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2964 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2965 sym_op->cipher.data.length = cipher_len;
2966 sym_op->cipher.data.offset = cipher_offset;
2968 sym_op->cipher.data.length = cipher_len >> 3;
2969 sym_op->cipher.data.offset = cipher_offset >> 3;
2972 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2973 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2974 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2975 sym_op->auth.data.length = auth_len;
2976 sym_op->auth.data.offset = auth_offset;
2978 sym_op->auth.data.length = auth_len >> 3;
2979 sym_op->auth.data.offset = auth_offset >> 3;
2986 create_wireless_algo_auth_cipher_operation(
2987 const uint8_t *auth_tag, unsigned int auth_tag_len,
2988 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2989 const uint8_t *auth_iv, uint8_t auth_iv_len,
2990 unsigned int data_pad_len,
2991 unsigned int cipher_len, unsigned int cipher_offset,
2992 unsigned int auth_len, unsigned int auth_offset,
2993 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2995 struct crypto_testsuite_params *ts_params = &testsuite_params;
2996 struct crypto_unittest_params *ut_params = &unittest_params;
2998 enum rte_crypto_cipher_algorithm cipher_algo =
2999 ut_params->cipher_xform.cipher.algo;
3000 enum rte_crypto_auth_algorithm auth_algo =
3001 ut_params->auth_xform.auth.algo;
3003 /* Generate Crypto op data structure */
3004 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3005 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3006 TEST_ASSERT_NOT_NULL(ut_params->op,
3007 "Failed to allocate pktmbuf offload");
3009 /* Set crypto operation data parameters */
3010 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3012 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3014 /* set crypto operation mbufs */
3015 sym_op->m_src = ut_params->ibuf;
3016 if (op_mode == OUT_OF_PLACE)
3017 sym_op->m_dst = ut_params->obuf;
3021 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3022 (op_mode == IN_PLACE ?
3023 ut_params->ibuf : ut_params->obuf),
3024 uint8_t *, data_pad_len);
3025 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3026 (op_mode == IN_PLACE ?
3027 ut_params->ibuf : ut_params->obuf),
3029 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3031 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3032 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3033 sym_op->m_src : sym_op->m_dst);
3034 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3035 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3036 sgl_buf = sgl_buf->next;
3038 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3039 uint8_t *, remaining_off);
3040 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3042 memset(sym_op->auth.digest.data, 0, remaining_off);
3043 while (sgl_buf->next != NULL) {
3044 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3045 0, rte_pktmbuf_data_len(sgl_buf));
3046 sgl_buf = sgl_buf->next;
3050 /* Copy digest for the verification */
3052 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3054 /* Copy cipher and auth IVs at the end of the crypto operation */
3055 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3056 ut_params->op, uint8_t *, IV_OFFSET);
3058 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3059 iv_ptr += cipher_iv_len;
3060 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3062 /* Only copy over the offset data needed from src to dst in OOP,
3063 * if the auth and cipher offsets are not aligned
3065 if (op_mode == OUT_OF_PLACE) {
3066 if (cipher_offset > auth_offset)
3068 rte_pktmbuf_mtod_offset(
3070 uint8_t *, auth_offset >> 3),
3071 rte_pktmbuf_mtod_offset(
3073 uint8_t *, auth_offset >> 3),
3074 ((cipher_offset >> 3) - (auth_offset >> 3)));
3077 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3078 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3079 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3080 sym_op->cipher.data.length = cipher_len;
3081 sym_op->cipher.data.offset = cipher_offset;
3083 sym_op->cipher.data.length = cipher_len >> 3;
3084 sym_op->cipher.data.offset = cipher_offset >> 3;
3087 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3088 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3089 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3090 sym_op->auth.data.length = auth_len;
3091 sym_op->auth.data.offset = auth_offset;
3093 sym_op->auth.data.length = auth_len >> 3;
3094 sym_op->auth.data.offset = auth_offset >> 3;
3101 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3103 struct crypto_testsuite_params *ts_params = &testsuite_params;
3104 struct crypto_unittest_params *ut_params = &unittest_params;
3107 unsigned plaintext_pad_len;
3108 unsigned plaintext_len;
3110 struct rte_cryptodev_info dev_info;
3112 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3113 uint64_t feat_flags = dev_info.feature_flags;
3115 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3116 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3117 printf("Device doesn't support NON-Byte Aligned Data.\n");
3118 return TEST_SKIPPED;
3121 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3122 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3123 printf("Device doesn't support RAW data-path APIs.\n");
3124 return TEST_SKIPPED;
3127 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3128 return TEST_SKIPPED;
3130 /* Verify the capabilities */
3131 struct rte_cryptodev_sym_capability_idx cap_idx;
3132 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3133 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3134 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3136 return TEST_SKIPPED;
3138 /* Create SNOW 3G session */
3139 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3140 tdata->key.data, tdata->key.len,
3141 tdata->auth_iv.len, tdata->digest.len,
3142 RTE_CRYPTO_AUTH_OP_GENERATE,
3143 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3147 /* alloc mbuf and set payload */
3148 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3150 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3151 rte_pktmbuf_tailroom(ut_params->ibuf));
3153 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3154 /* Append data which is padded to a multiple of */
3155 /* the algorithms block size */
3156 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3157 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3159 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3161 /* Create SNOW 3G operation */
3162 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3163 tdata->auth_iv.data, tdata->auth_iv.len,
3164 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3165 tdata->validAuthLenInBits.len,
3170 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3171 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3172 ut_params->op, 0, 1, 1, 0);
3174 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3176 ut_params->obuf = ut_params->op->sym->m_src;
3177 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3178 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3179 + plaintext_pad_len;
3182 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3185 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3186 "SNOW 3G Generated auth tag not as expected");
3192 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3194 struct crypto_testsuite_params *ts_params = &testsuite_params;
3195 struct crypto_unittest_params *ut_params = &unittest_params;
3198 unsigned plaintext_pad_len;
3199 unsigned plaintext_len;
3201 struct rte_cryptodev_info dev_info;
3203 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3204 uint64_t feat_flags = dev_info.feature_flags;
3206 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3207 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3208 printf("Device doesn't support NON-Byte Aligned Data.\n");
3209 return TEST_SKIPPED;
3212 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3213 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3214 printf("Device doesn't support RAW data-path APIs.\n");
3215 return TEST_SKIPPED;
3218 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3219 return TEST_SKIPPED;
3221 /* Verify the capabilities */
3222 struct rte_cryptodev_sym_capability_idx cap_idx;
3223 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3224 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3225 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3227 return TEST_SKIPPED;
3229 /* Create SNOW 3G session */
3230 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3231 tdata->key.data, tdata->key.len,
3232 tdata->auth_iv.len, tdata->digest.len,
3233 RTE_CRYPTO_AUTH_OP_VERIFY,
3234 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3237 /* alloc mbuf and set payload */
3238 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3240 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3241 rte_pktmbuf_tailroom(ut_params->ibuf));
3243 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3244 /* Append data which is padded to a multiple of */
3245 /* the algorithms block size */
3246 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3247 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3249 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3251 /* Create SNOW 3G operation */
3252 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3254 tdata->auth_iv.data, tdata->auth_iv.len,
3256 RTE_CRYPTO_AUTH_OP_VERIFY,
3257 tdata->validAuthLenInBits.len,
3262 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3263 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3264 ut_params->op, 0, 1, 1, 0);
3266 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3268 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3269 ut_params->obuf = ut_params->op->sym->m_src;
3270 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3271 + plaintext_pad_len;
3274 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3283 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3285 struct crypto_testsuite_params *ts_params = &testsuite_params;
3286 struct crypto_unittest_params *ut_params = &unittest_params;
3289 unsigned plaintext_pad_len;
3290 unsigned plaintext_len;
3292 struct rte_cryptodev_info dev_info;
3294 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3295 uint64_t feat_flags = dev_info.feature_flags;
3297 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3298 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3299 printf("Device doesn't support RAW data-path APIs.\n");
3300 return TEST_SKIPPED;
3303 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3304 return TEST_SKIPPED;
3306 /* Verify the capabilities */
3307 struct rte_cryptodev_sym_capability_idx cap_idx;
3308 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3309 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3310 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3312 return TEST_SKIPPED;
3314 /* Create KASUMI session */
3315 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3316 tdata->key.data, tdata->key.len,
3317 0, tdata->digest.len,
3318 RTE_CRYPTO_AUTH_OP_GENERATE,
3319 RTE_CRYPTO_AUTH_KASUMI_F9);
3323 /* alloc mbuf and set payload */
3324 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3326 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3327 rte_pktmbuf_tailroom(ut_params->ibuf));
3329 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3330 /* Append data which is padded to a multiple of */
3331 /* the algorithms block size */
3332 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3333 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3335 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3337 /* Create KASUMI operation */
3338 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3340 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3341 tdata->plaintext.len,
3346 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3347 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3349 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3350 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3351 ut_params->op, 0, 1, 1, 0);
3353 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3356 ut_params->obuf = ut_params->op->sym->m_src;
3357 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3358 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3359 + plaintext_pad_len;
3362 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3365 DIGEST_BYTE_LENGTH_KASUMI_F9,
3366 "KASUMI Generated auth tag not as expected");
3372 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3374 struct crypto_testsuite_params *ts_params = &testsuite_params;
3375 struct crypto_unittest_params *ut_params = &unittest_params;
3378 unsigned plaintext_pad_len;
3379 unsigned plaintext_len;
3381 struct rte_cryptodev_info dev_info;
3383 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3384 uint64_t feat_flags = dev_info.feature_flags;
3386 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3387 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3388 printf("Device doesn't support RAW data-path APIs.\n");
3389 return TEST_SKIPPED;
3392 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3393 return TEST_SKIPPED;
3395 /* Verify the capabilities */
3396 struct rte_cryptodev_sym_capability_idx cap_idx;
3397 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3398 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3399 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3401 return TEST_SKIPPED;
3403 /* Create KASUMI session */
3404 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3405 tdata->key.data, tdata->key.len,
3406 0, tdata->digest.len,
3407 RTE_CRYPTO_AUTH_OP_VERIFY,
3408 RTE_CRYPTO_AUTH_KASUMI_F9);
3411 /* alloc mbuf and set payload */
3412 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3414 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3415 rte_pktmbuf_tailroom(ut_params->ibuf));
3417 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3418 /* Append data which is padded to a multiple */
3419 /* of the algorithms block size */
3420 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3421 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3423 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3425 /* Create KASUMI operation */
3426 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3430 RTE_CRYPTO_AUTH_OP_VERIFY,
3431 tdata->plaintext.len,
3436 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3437 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3438 ut_params->op, 0, 1, 1, 0);
3440 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3442 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3443 ut_params->obuf = ut_params->op->sym->m_src;
3444 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3445 + plaintext_pad_len;
3448 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3457 test_snow3g_hash_generate_test_case_1(void)
3459 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3463 test_snow3g_hash_generate_test_case_2(void)
3465 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3469 test_snow3g_hash_generate_test_case_3(void)
3471 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3475 test_snow3g_hash_generate_test_case_4(void)
3477 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3481 test_snow3g_hash_generate_test_case_5(void)
3483 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3487 test_snow3g_hash_generate_test_case_6(void)
3489 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3493 test_snow3g_hash_verify_test_case_1(void)
3495 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3500 test_snow3g_hash_verify_test_case_2(void)
3502 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3506 test_snow3g_hash_verify_test_case_3(void)
3508 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3512 test_snow3g_hash_verify_test_case_4(void)
3514 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3518 test_snow3g_hash_verify_test_case_5(void)
3520 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3524 test_snow3g_hash_verify_test_case_6(void)
3526 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3530 test_kasumi_hash_generate_test_case_1(void)
3532 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3536 test_kasumi_hash_generate_test_case_2(void)
3538 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3542 test_kasumi_hash_generate_test_case_3(void)
3544 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3548 test_kasumi_hash_generate_test_case_4(void)
3550 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3554 test_kasumi_hash_generate_test_case_5(void)
3556 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3560 test_kasumi_hash_generate_test_case_6(void)
3562 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3566 test_kasumi_hash_verify_test_case_1(void)
3568 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3572 test_kasumi_hash_verify_test_case_2(void)
3574 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3578 test_kasumi_hash_verify_test_case_3(void)
3580 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3584 test_kasumi_hash_verify_test_case_4(void)
3586 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3590 test_kasumi_hash_verify_test_case_5(void)
3592 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3596 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3598 struct crypto_testsuite_params *ts_params = &testsuite_params;
3599 struct crypto_unittest_params *ut_params = &unittest_params;
3602 uint8_t *plaintext, *ciphertext;
3603 unsigned plaintext_pad_len;
3604 unsigned plaintext_len;
3605 struct rte_cryptodev_info dev_info;
3607 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3608 uint64_t feat_flags = dev_info.feature_flags;
3610 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3611 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3612 printf("Device doesn't support RAW data-path APIs.\n");
3613 return TEST_SKIPPED;
3616 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3617 return TEST_SKIPPED;
3619 /* Verify the capabilities */
3620 struct rte_cryptodev_sym_capability_idx cap_idx;
3621 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3622 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3623 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3625 return TEST_SKIPPED;
3627 /* Create KASUMI session */
3628 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3629 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3630 RTE_CRYPTO_CIPHER_KASUMI_F8,
3631 tdata->key.data, tdata->key.len,
3632 tdata->cipher_iv.len);
3636 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3638 /* Clear mbuf payload */
3639 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3640 rte_pktmbuf_tailroom(ut_params->ibuf));
3642 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3643 /* Append data which is padded to a multiple */
3644 /* of the algorithms block size */
3645 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3646 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3648 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3650 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3652 /* Create KASUMI operation */
3653 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3654 tdata->cipher_iv.len,
3655 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3656 tdata->validCipherOffsetInBits.len);
3660 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3661 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3662 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3664 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3666 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3668 ut_params->obuf = ut_params->op->sym->m_dst;
3669 if (ut_params->obuf)
3670 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3672 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3674 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3676 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3677 (tdata->validCipherOffsetInBits.len >> 3);
3679 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3681 reference_ciphertext,
3682 tdata->validCipherLenInBits.len,
3683 "KASUMI Ciphertext data not as expected");
3688 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3690 struct crypto_testsuite_params *ts_params = &testsuite_params;
3691 struct crypto_unittest_params *ut_params = &unittest_params;
3695 unsigned int plaintext_pad_len;
3696 unsigned int plaintext_len;
3698 uint8_t buffer[10000];
3699 const uint8_t *ciphertext;
3701 struct rte_cryptodev_info dev_info;
3703 /* Verify the capabilities */
3704 struct rte_cryptodev_sym_capability_idx cap_idx;
3705 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3706 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3707 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3709 return TEST_SKIPPED;
3711 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3713 uint64_t feat_flags = dev_info.feature_flags;
3715 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3716 printf("Device doesn't support in-place scatter-gather. "
3718 return TEST_SKIPPED;
3721 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3722 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3723 printf("Device doesn't support RAW data-path APIs.\n");
3724 return TEST_SKIPPED;
3727 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3728 return TEST_SKIPPED;
3730 /* Create KASUMI session */
3731 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3732 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3733 RTE_CRYPTO_CIPHER_KASUMI_F8,
3734 tdata->key.data, tdata->key.len,
3735 tdata->cipher_iv.len);
3739 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3742 /* Append data which is padded to a multiple */
3743 /* of the algorithms block size */
3744 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3746 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3747 plaintext_pad_len, 10, 0);
3749 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3751 /* Create KASUMI operation */
3752 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3753 tdata->cipher_iv.len,
3754 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3755 tdata->validCipherOffsetInBits.len);
3759 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3760 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3761 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3763 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3765 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3767 ut_params->obuf = ut_params->op->sym->m_dst;
3769 if (ut_params->obuf)
3770 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3771 plaintext_len, buffer);
3773 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3774 tdata->validCipherOffsetInBits.len >> 3,
3775 plaintext_len, buffer);
3778 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3780 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3781 (tdata->validCipherOffsetInBits.len >> 3);
3783 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3785 reference_ciphertext,
3786 tdata->validCipherLenInBits.len,
3787 "KASUMI Ciphertext data not as expected");
3792 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3794 struct crypto_testsuite_params *ts_params = &testsuite_params;
3795 struct crypto_unittest_params *ut_params = &unittest_params;
3798 uint8_t *plaintext, *ciphertext;
3799 unsigned plaintext_pad_len;
3800 unsigned plaintext_len;
3802 /* Verify the capabilities */
3803 struct rte_cryptodev_sym_capability_idx cap_idx;
3804 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3805 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3806 /* Data-path service does not support OOP */
3807 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3809 return TEST_SKIPPED;
3811 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3812 return TEST_SKIPPED;
3814 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3815 return TEST_SKIPPED;
3817 /* Create KASUMI session */
3818 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3819 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3820 RTE_CRYPTO_CIPHER_KASUMI_F8,
3821 tdata->key.data, tdata->key.len,
3822 tdata->cipher_iv.len);
3826 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3827 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3829 /* Clear mbuf payload */
3830 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3831 rte_pktmbuf_tailroom(ut_params->ibuf));
3833 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3834 /* Append data which is padded to a multiple */
3835 /* of the algorithms block size */
3836 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3837 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3839 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3840 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3842 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3844 /* Create KASUMI operation */
3845 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3846 tdata->cipher_iv.len,
3847 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3848 tdata->validCipherOffsetInBits.len);
3852 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3854 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3856 ut_params->obuf = ut_params->op->sym->m_dst;
3857 if (ut_params->obuf)
3858 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3860 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3862 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3864 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3865 (tdata->validCipherOffsetInBits.len >> 3);
3867 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3869 reference_ciphertext,
3870 tdata->validCipherLenInBits.len,
3871 "KASUMI Ciphertext data not as expected");
3876 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3878 struct crypto_testsuite_params *ts_params = &testsuite_params;
3879 struct crypto_unittest_params *ut_params = &unittest_params;
3882 unsigned int plaintext_pad_len;
3883 unsigned int plaintext_len;
3885 const uint8_t *ciphertext;
3886 uint8_t buffer[2048];
3888 struct rte_cryptodev_info dev_info;
3890 /* Verify the capabilities */
3891 struct rte_cryptodev_sym_capability_idx cap_idx;
3892 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3893 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3894 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3896 return TEST_SKIPPED;
3898 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3899 return TEST_SKIPPED;
3901 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3902 return TEST_SKIPPED;
3904 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3906 uint64_t feat_flags = dev_info.feature_flags;
3907 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3908 printf("Device doesn't support out-of-place scatter-gather "
3909 "in both input and output mbufs. "
3911 return TEST_SKIPPED;
3914 /* Create KASUMI session */
3915 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3916 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3917 RTE_CRYPTO_CIPHER_KASUMI_F8,
3918 tdata->key.data, tdata->key.len,
3919 tdata->cipher_iv.len);
3923 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3924 /* Append data which is padded to a multiple */
3925 /* of the algorithms block size */
3926 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3928 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3929 plaintext_pad_len, 10, 0);
3930 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3931 plaintext_pad_len, 3, 0);
3933 /* Append data which is padded to a multiple */
3934 /* of the algorithms block size */
3935 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3937 /* Create KASUMI operation */
3938 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3939 tdata->cipher_iv.len,
3940 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3941 tdata->validCipherOffsetInBits.len);
3945 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3947 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3949 ut_params->obuf = ut_params->op->sym->m_dst;
3950 if (ut_params->obuf)
3951 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3952 plaintext_pad_len, buffer);
3954 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3955 tdata->validCipherOffsetInBits.len >> 3,
3956 plaintext_pad_len, buffer);
3958 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3959 (tdata->validCipherOffsetInBits.len >> 3);
3961 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3963 reference_ciphertext,
3964 tdata->validCipherLenInBits.len,
3965 "KASUMI Ciphertext data not as expected");
3971 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3973 struct crypto_testsuite_params *ts_params = &testsuite_params;
3974 struct crypto_unittest_params *ut_params = &unittest_params;
3977 uint8_t *ciphertext, *plaintext;
3978 unsigned ciphertext_pad_len;
3979 unsigned ciphertext_len;
3981 /* Verify the capabilities */
3982 struct rte_cryptodev_sym_capability_idx cap_idx;
3983 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3984 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3985 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3987 return TEST_SKIPPED;
3989 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3990 return TEST_SKIPPED;
3992 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3993 return TEST_SKIPPED;
3995 /* Create KASUMI session */
3996 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3997 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3998 RTE_CRYPTO_CIPHER_KASUMI_F8,
3999 tdata->key.data, tdata->key.len,
4000 tdata->cipher_iv.len);
4004 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4005 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4007 /* Clear mbuf payload */
4008 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4009 rte_pktmbuf_tailroom(ut_params->ibuf));
4011 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4012 /* Append data which is padded to a multiple */
4013 /* of the algorithms block size */
4014 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4015 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4016 ciphertext_pad_len);
4017 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4018 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4020 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4022 /* Create KASUMI operation */
4023 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4024 tdata->cipher_iv.len,
4025 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4026 tdata->validCipherOffsetInBits.len);
4030 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4032 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4034 ut_params->obuf = ut_params->op->sym->m_dst;
4035 if (ut_params->obuf)
4036 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4038 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4040 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4042 const uint8_t *reference_plaintext = tdata->plaintext.data +
4043 (tdata->validCipherOffsetInBits.len >> 3);
4045 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4047 reference_plaintext,
4048 tdata->validCipherLenInBits.len,
4049 "KASUMI Plaintext data not as expected");
4054 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4056 struct crypto_testsuite_params *ts_params = &testsuite_params;
4057 struct crypto_unittest_params *ut_params = &unittest_params;
4060 uint8_t *ciphertext, *plaintext;
4061 unsigned ciphertext_pad_len;
4062 unsigned ciphertext_len;
4063 struct rte_cryptodev_info dev_info;
4065 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4066 uint64_t feat_flags = dev_info.feature_flags;
4068 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4069 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4070 printf("Device doesn't support RAW data-path APIs.\n");
4071 return TEST_SKIPPED;
4074 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4075 return TEST_SKIPPED;
4077 /* Verify the capabilities */
4078 struct rte_cryptodev_sym_capability_idx cap_idx;
4079 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4080 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4081 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4083 return TEST_SKIPPED;
4085 /* Create KASUMI session */
4086 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4087 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4088 RTE_CRYPTO_CIPHER_KASUMI_F8,
4089 tdata->key.data, tdata->key.len,
4090 tdata->cipher_iv.len);
4094 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4096 /* Clear mbuf payload */
4097 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4098 rte_pktmbuf_tailroom(ut_params->ibuf));
4100 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4101 /* Append data which is padded to a multiple */
4102 /* of the algorithms block size */
4103 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4104 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4105 ciphertext_pad_len);
4106 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4108 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4110 /* Create KASUMI operation */
4111 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4112 tdata->cipher_iv.len,
4113 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4114 tdata->validCipherOffsetInBits.len);
4118 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4119 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4120 ut_params->op, 1, 0, 1, 0);
4122 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4124 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4126 ut_params->obuf = ut_params->op->sym->m_dst;
4127 if (ut_params->obuf)
4128 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4130 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4132 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4134 const uint8_t *reference_plaintext = tdata->plaintext.data +
4135 (tdata->validCipherOffsetInBits.len >> 3);
4137 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4139 reference_plaintext,
4140 tdata->validCipherLenInBits.len,
4141 "KASUMI Plaintext data not as expected");
4146 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4148 struct crypto_testsuite_params *ts_params = &testsuite_params;
4149 struct crypto_unittest_params *ut_params = &unittest_params;
4152 uint8_t *plaintext, *ciphertext;
4153 unsigned plaintext_pad_len;
4154 unsigned plaintext_len;
4155 struct rte_cryptodev_info dev_info;
4157 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4158 uint64_t feat_flags = dev_info.feature_flags;
4160 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4161 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4162 printf("Device doesn't support RAW data-path APIs.\n");
4163 return TEST_SKIPPED;
4166 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4167 return TEST_SKIPPED;
4169 /* Verify the capabilities */
4170 struct rte_cryptodev_sym_capability_idx cap_idx;
4171 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4172 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4173 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4175 return TEST_SKIPPED;
4177 /* Create SNOW 3G session */
4178 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4179 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4180 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4181 tdata->key.data, tdata->key.len,
4182 tdata->cipher_iv.len);
4186 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4188 /* Clear mbuf payload */
4189 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4190 rte_pktmbuf_tailroom(ut_params->ibuf));
4192 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4193 /* Append data which is padded to a multiple of */
4194 /* the algorithms block size */
4195 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4196 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4198 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4200 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4202 /* Create SNOW 3G operation */
4203 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4204 tdata->cipher_iv.len,
4205 tdata->validCipherLenInBits.len,
4210 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4211 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4212 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4214 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4216 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4218 ut_params->obuf = ut_params->op->sym->m_dst;
4219 if (ut_params->obuf)
4220 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4222 ciphertext = plaintext;
4224 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4227 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4229 tdata->ciphertext.data,
4230 tdata->validDataLenInBits.len,
4231 "SNOW 3G Ciphertext data not as expected");
4237 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4239 struct crypto_testsuite_params *ts_params = &testsuite_params;
4240 struct crypto_unittest_params *ut_params = &unittest_params;
4241 uint8_t *plaintext, *ciphertext;
4244 unsigned plaintext_pad_len;
4245 unsigned plaintext_len;
4246 struct rte_cryptodev_info dev_info;
4248 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4249 uint64_t feat_flags = dev_info.feature_flags;
4251 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4252 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4253 printf("Device does not support RAW data-path APIs.\n");
4257 /* Verify the capabilities */
4258 struct rte_cryptodev_sym_capability_idx cap_idx;
4259 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4260 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4261 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4263 return TEST_SKIPPED;
4265 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4266 return TEST_SKIPPED;
4268 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4269 return TEST_SKIPPED;
4271 /* Create SNOW 3G session */
4272 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4273 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4274 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4275 tdata->key.data, tdata->key.len,
4276 tdata->cipher_iv.len);
4280 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4281 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4283 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4284 "Failed to allocate input buffer in mempool");
4285 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4286 "Failed to allocate output buffer in mempool");
4288 /* Clear mbuf payload */
4289 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4290 rte_pktmbuf_tailroom(ut_params->ibuf));
4292 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4293 /* Append data which is padded to a multiple of */
4294 /* the algorithms block size */
4295 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4296 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4298 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4299 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4301 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4303 /* Create SNOW 3G operation */
4304 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4305 tdata->cipher_iv.len,
4306 tdata->validCipherLenInBits.len,
4311 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4312 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4313 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4315 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4317 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4319 ut_params->obuf = ut_params->op->sym->m_dst;
4320 if (ut_params->obuf)
4321 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4323 ciphertext = plaintext;
4325 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4328 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4330 tdata->ciphertext.data,
4331 tdata->validDataLenInBits.len,
4332 "SNOW 3G Ciphertext data not as expected");
4337 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4339 struct crypto_testsuite_params *ts_params = &testsuite_params;
4340 struct crypto_unittest_params *ut_params = &unittest_params;
4343 unsigned int plaintext_pad_len;
4344 unsigned int plaintext_len;
4345 uint8_t buffer[10000];
4346 const uint8_t *ciphertext;
4348 struct rte_cryptodev_info dev_info;
4350 /* Verify the capabilities */
4351 struct rte_cryptodev_sym_capability_idx cap_idx;
4352 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4353 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4354 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4356 return TEST_SKIPPED;
4358 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4359 return TEST_SKIPPED;
4361 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4362 return TEST_SKIPPED;
4364 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4366 uint64_t feat_flags = dev_info.feature_flags;
4368 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4369 printf("Device doesn't support out-of-place scatter-gather "
4370 "in both input and output mbufs. "
4372 return TEST_SKIPPED;
4375 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4376 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4377 printf("Device does not support RAW data-path APIs.\n");
4381 /* Create SNOW 3G session */
4382 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4383 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4384 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4385 tdata->key.data, tdata->key.len,
4386 tdata->cipher_iv.len);
4390 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4391 /* Append data which is padded to a multiple of */
4392 /* the algorithms block size */
4393 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4395 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4396 plaintext_pad_len, 10, 0);
4397 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4398 plaintext_pad_len, 3, 0);
4400 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4401 "Failed to allocate input buffer in mempool");
4402 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4403 "Failed to allocate output buffer in mempool");
4405 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4407 /* Create SNOW 3G operation */
4408 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4409 tdata->cipher_iv.len,
4410 tdata->validCipherLenInBits.len,
4415 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4416 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4417 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4419 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4421 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4423 ut_params->obuf = ut_params->op->sym->m_dst;
4424 if (ut_params->obuf)
4425 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4426 plaintext_len, buffer);
4428 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4429 plaintext_len, buffer);
4431 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4434 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4436 tdata->ciphertext.data,
4437 tdata->validDataLenInBits.len,
4438 "SNOW 3G Ciphertext data not as expected");
4443 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4445 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4447 uint8_t curr_byte, prev_byte;
4448 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4449 uint8_t lower_byte_mask = (1 << offset) - 1;
4452 prev_byte = buffer[0];
4453 buffer[0] >>= offset;
4455 for (i = 1; i < length_in_bytes; i++) {
4456 curr_byte = buffer[i];
4457 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4458 (curr_byte >> offset);
4459 prev_byte = curr_byte;
4464 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4466 struct crypto_testsuite_params *ts_params = &testsuite_params;
4467 struct crypto_unittest_params *ut_params = &unittest_params;
4468 uint8_t *plaintext, *ciphertext;
4470 uint32_t plaintext_len;
4471 uint32_t plaintext_pad_len;
4472 uint8_t extra_offset = 4;
4473 uint8_t *expected_ciphertext_shifted;
4474 struct rte_cryptodev_info dev_info;
4476 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4477 uint64_t feat_flags = dev_info.feature_flags;
4479 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4480 ((tdata->validDataLenInBits.len % 8) != 0)) {
4481 printf("Device doesn't support NON-Byte Aligned Data.\n");
4482 return TEST_SKIPPED;
4485 /* Verify the capabilities */
4486 struct rte_cryptodev_sym_capability_idx cap_idx;
4487 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4488 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4489 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4491 return TEST_SKIPPED;
4493 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4494 return TEST_SKIPPED;
4496 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4497 return TEST_SKIPPED;
4499 /* Create SNOW 3G session */
4500 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4501 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4502 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4503 tdata->key.data, tdata->key.len,
4504 tdata->cipher_iv.len);
4508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4509 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4511 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4512 "Failed to allocate input buffer in mempool");
4513 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4514 "Failed to allocate output buffer in mempool");
4516 /* Clear mbuf payload */
4517 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4518 rte_pktmbuf_tailroom(ut_params->ibuf));
4520 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4522 * Append data which is padded to a
4523 * multiple of the algorithms block size
4525 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4527 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4530 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4532 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4533 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4535 #ifdef RTE_APP_TEST_DEBUG
4536 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4538 /* Create SNOW 3G operation */
4539 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4540 tdata->cipher_iv.len,
4541 tdata->validCipherLenInBits.len,
4546 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4547 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4548 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4550 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4552 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4554 ut_params->obuf = ut_params->op->sym->m_dst;
4555 if (ut_params->obuf)
4556 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4558 ciphertext = plaintext;
4560 #ifdef RTE_APP_TEST_DEBUG
4561 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4564 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4566 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4567 "failed to reserve memory for ciphertext shifted\n");
4569 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4570 ceil_byte_length(tdata->ciphertext.len));
4571 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4574 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4576 expected_ciphertext_shifted,
4577 tdata->validDataLenInBits.len,
4579 "SNOW 3G Ciphertext data not as expected");
4583 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4585 struct crypto_testsuite_params *ts_params = &testsuite_params;
4586 struct crypto_unittest_params *ut_params = &unittest_params;
4590 uint8_t *plaintext, *ciphertext;
4591 unsigned ciphertext_pad_len;
4592 unsigned ciphertext_len;
4593 struct rte_cryptodev_info dev_info;
4595 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4596 uint64_t feat_flags = dev_info.feature_flags;
4598 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4599 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4600 printf("Device doesn't support RAW data-path APIs.\n");
4601 return TEST_SKIPPED;
4604 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4605 return TEST_SKIPPED;
4607 /* Verify the capabilities */
4608 struct rte_cryptodev_sym_capability_idx cap_idx;
4609 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4610 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4611 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4613 return TEST_SKIPPED;
4615 /* Create SNOW 3G session */
4616 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4617 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4618 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4619 tdata->key.data, tdata->key.len,
4620 tdata->cipher_iv.len);
4624 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4626 /* Clear mbuf payload */
4627 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4628 rte_pktmbuf_tailroom(ut_params->ibuf));
4630 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4631 /* Append data which is padded to a multiple of */
4632 /* the algorithms block size */
4633 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4634 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4635 ciphertext_pad_len);
4636 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4638 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4640 /* Create SNOW 3G operation */
4641 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4642 tdata->cipher_iv.len,
4643 tdata->validCipherLenInBits.len,
4644 tdata->cipher.offset_bits);
4648 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4649 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4650 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4652 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4654 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4655 ut_params->obuf = ut_params->op->sym->m_dst;
4656 if (ut_params->obuf)
4657 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4659 plaintext = ciphertext;
4661 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4664 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4665 tdata->plaintext.data,
4666 tdata->validDataLenInBits.len,
4667 "SNOW 3G Plaintext data not as expected");
4671 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4673 struct crypto_testsuite_params *ts_params = &testsuite_params;
4674 struct crypto_unittest_params *ut_params = &unittest_params;
4678 uint8_t *plaintext, *ciphertext;
4679 unsigned ciphertext_pad_len;
4680 unsigned ciphertext_len;
4681 struct rte_cryptodev_info dev_info;
4683 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4684 uint64_t feat_flags = dev_info.feature_flags;
4686 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4687 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4688 printf("Device does not support RAW data-path APIs.\n");
4691 /* Verify the capabilities */
4692 struct rte_cryptodev_sym_capability_idx cap_idx;
4693 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4694 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4695 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4697 return TEST_SKIPPED;
4699 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4700 return TEST_SKIPPED;
4702 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4703 return TEST_SKIPPED;
4705 /* Create SNOW 3G session */
4706 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4707 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4708 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4709 tdata->key.data, tdata->key.len,
4710 tdata->cipher_iv.len);
4714 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4715 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4717 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4718 "Failed to allocate input buffer");
4719 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4720 "Failed to allocate output buffer");
4722 /* Clear mbuf payload */
4723 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4724 rte_pktmbuf_tailroom(ut_params->ibuf));
4726 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4727 rte_pktmbuf_tailroom(ut_params->obuf));
4729 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4730 /* Append data which is padded to a multiple of */
4731 /* the algorithms block size */
4732 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4733 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4734 ciphertext_pad_len);
4735 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4736 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4738 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4740 /* Create SNOW 3G operation */
4741 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4742 tdata->cipher_iv.len,
4743 tdata->validCipherLenInBits.len,
4748 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4749 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4750 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4752 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4754 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4755 ut_params->obuf = ut_params->op->sym->m_dst;
4756 if (ut_params->obuf)
4757 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4759 plaintext = ciphertext;
4761 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4764 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4765 tdata->plaintext.data,
4766 tdata->validDataLenInBits.len,
4767 "SNOW 3G Plaintext data not as expected");
4772 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4774 struct crypto_testsuite_params *ts_params = &testsuite_params;
4775 struct crypto_unittest_params *ut_params = &unittest_params;
4779 uint8_t *plaintext, *ciphertext;
4780 unsigned int plaintext_pad_len;
4781 unsigned int plaintext_len;
4783 struct rte_cryptodev_info dev_info;
4784 struct rte_cryptodev_sym_capability_idx cap_idx;
4786 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4787 uint64_t feat_flags = dev_info.feature_flags;
4789 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4790 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4791 (tdata->validDataLenInBits.len % 8 != 0))) {
4792 printf("Device doesn't support NON-Byte Aligned Data.\n");
4793 return TEST_SKIPPED;
4796 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4797 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4798 printf("Device doesn't support RAW data-path APIs.\n");
4799 return TEST_SKIPPED;
4802 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4803 return TEST_SKIPPED;
4805 /* Check if device supports ZUC EEA3 */
4806 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4807 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4809 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4811 return TEST_SKIPPED;
4813 /* Check if device supports ZUC EIA3 */
4814 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4815 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4817 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4819 return TEST_SKIPPED;
4821 /* Create ZUC session */
4822 retval = create_zuc_cipher_auth_encrypt_generate_session(
4823 ts_params->valid_devs[0],
4827 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4829 /* clear mbuf payload */
4830 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4831 rte_pktmbuf_tailroom(ut_params->ibuf));
4833 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4834 /* Append data which is padded to a multiple of */
4835 /* the algorithms block size */
4836 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4837 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4839 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4841 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4843 /* Create ZUC operation */
4844 retval = create_zuc_cipher_hash_generate_operation(tdata);
4848 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4849 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4850 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4852 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4854 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4855 ut_params->obuf = ut_params->op->sym->m_src;
4856 if (ut_params->obuf)
4857 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4859 ciphertext = plaintext;
4861 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4863 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4865 tdata->ciphertext.data,
4866 tdata->validDataLenInBits.len,
4867 "ZUC Ciphertext data not as expected");
4869 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4870 + plaintext_pad_len;
4873 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4877 "ZUC Generated auth tag not as expected");
4882 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4884 struct crypto_testsuite_params *ts_params = &testsuite_params;
4885 struct crypto_unittest_params *ut_params = &unittest_params;
4889 uint8_t *plaintext, *ciphertext;
4890 unsigned plaintext_pad_len;
4891 unsigned plaintext_len;
4892 struct rte_cryptodev_info dev_info;
4894 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4895 uint64_t feat_flags = dev_info.feature_flags;
4897 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4898 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4899 printf("Device doesn't support RAW data-path APIs.\n");
4900 return TEST_SKIPPED;
4903 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4904 return TEST_SKIPPED;
4906 /* Verify the capabilities */
4907 struct rte_cryptodev_sym_capability_idx cap_idx;
4908 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4909 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4910 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4912 return TEST_SKIPPED;
4913 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4914 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4915 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4917 return TEST_SKIPPED;
4919 /* Create SNOW 3G session */
4920 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4921 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4922 RTE_CRYPTO_AUTH_OP_GENERATE,
4923 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4924 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4925 tdata->key.data, tdata->key.len,
4926 tdata->auth_iv.len, tdata->digest.len,
4927 tdata->cipher_iv.len);
4930 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4932 /* clear mbuf payload */
4933 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4934 rte_pktmbuf_tailroom(ut_params->ibuf));
4936 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4937 /* Append data which is padded to a multiple of */
4938 /* the algorithms block size */
4939 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4940 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4942 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4944 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4946 /* Create SNOW 3G operation */
4947 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4948 tdata->digest.len, tdata->auth_iv.data,
4950 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4951 tdata->cipher_iv.data, tdata->cipher_iv.len,
4952 tdata->validCipherLenInBits.len,
4954 tdata->validAuthLenInBits.len,
4960 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4961 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4962 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4964 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4966 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4967 ut_params->obuf = ut_params->op->sym->m_src;
4968 if (ut_params->obuf)
4969 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4971 ciphertext = plaintext;
4973 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4975 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4977 tdata->ciphertext.data,
4978 tdata->validDataLenInBits.len,
4979 "SNOW 3G Ciphertext data not as expected");
4981 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4982 + plaintext_pad_len;
4985 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4988 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4989 "SNOW 3G Generated auth tag not as expected");
4994 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4995 uint8_t op_mode, uint8_t verify)
4997 struct crypto_testsuite_params *ts_params = &testsuite_params;
4998 struct crypto_unittest_params *ut_params = &unittest_params;
5002 uint8_t *plaintext = NULL, *ciphertext = NULL;
5003 unsigned int plaintext_pad_len;
5004 unsigned int plaintext_len;
5005 unsigned int ciphertext_pad_len;
5006 unsigned int ciphertext_len;
5008 struct rte_cryptodev_info dev_info;
5010 /* Verify the capabilities */
5011 struct rte_cryptodev_sym_capability_idx cap_idx;
5012 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5013 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5014 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5016 return TEST_SKIPPED;
5017 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5018 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5019 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5021 return TEST_SKIPPED;
5023 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5024 return TEST_SKIPPED;
5026 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5028 uint64_t feat_flags = dev_info.feature_flags;
5030 if (op_mode == OUT_OF_PLACE) {
5031 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5032 printf("Device doesn't support digest encrypted.\n");
5033 return TEST_SKIPPED;
5035 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5036 return TEST_SKIPPED;
5039 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5040 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5041 printf("Device doesn't support RAW data-path APIs.\n");
5042 return TEST_SKIPPED;
5045 /* Create SNOW 3G session */
5046 retval = create_wireless_algo_auth_cipher_session(
5047 ts_params->valid_devs[0],
5048 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5049 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5050 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5051 : RTE_CRYPTO_AUTH_OP_GENERATE),
5052 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5053 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5054 tdata->key.data, tdata->key.len,
5055 tdata->auth_iv.len, tdata->digest.len,
5056 tdata->cipher_iv.len);
5060 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5061 if (op_mode == OUT_OF_PLACE)
5062 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5064 /* clear mbuf payload */
5065 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5066 rte_pktmbuf_tailroom(ut_params->ibuf));
5067 if (op_mode == OUT_OF_PLACE)
5068 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5069 rte_pktmbuf_tailroom(ut_params->obuf));
5071 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5072 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5073 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5074 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5077 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5078 ciphertext_pad_len);
5079 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5080 if (op_mode == OUT_OF_PLACE)
5081 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5082 debug_hexdump(stdout, "ciphertext:", ciphertext,
5085 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5087 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5088 if (op_mode == OUT_OF_PLACE)
5089 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5090 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5093 /* Create SNOW 3G operation */
5094 retval = create_wireless_algo_auth_cipher_operation(
5095 tdata->digest.data, tdata->digest.len,
5096 tdata->cipher_iv.data, tdata->cipher_iv.len,
5097 tdata->auth_iv.data, tdata->auth_iv.len,
5098 (tdata->digest.offset_bytes == 0 ?
5099 (verify ? ciphertext_pad_len : plaintext_pad_len)
5100 : tdata->digest.offset_bytes),
5101 tdata->validCipherLenInBits.len,
5102 tdata->cipher.offset_bits,
5103 tdata->validAuthLenInBits.len,
5104 tdata->auth.offset_bits,
5105 op_mode, 0, verify);
5110 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5111 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5112 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5114 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5117 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5119 ut_params->obuf = (op_mode == IN_PLACE ?
5120 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5123 if (ut_params->obuf)
5124 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5127 plaintext = ciphertext +
5128 (tdata->cipher.offset_bits >> 3);
5130 debug_hexdump(stdout, "plaintext:", plaintext,
5131 (tdata->plaintext.len >> 3) - tdata->digest.len);
5132 debug_hexdump(stdout, "plaintext expected:",
5133 tdata->plaintext.data,
5134 (tdata->plaintext.len >> 3) - tdata->digest.len);
5136 if (ut_params->obuf)
5137 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5140 ciphertext = plaintext;
5142 debug_hexdump(stdout, "ciphertext:", ciphertext,
5144 debug_hexdump(stdout, "ciphertext expected:",
5145 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5147 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5148 + (tdata->digest.offset_bytes == 0 ?
5149 plaintext_pad_len : tdata->digest.offset_bytes);
5151 debug_hexdump(stdout, "digest:", ut_params->digest,
5153 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5159 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5161 tdata->plaintext.data,
5162 (tdata->plaintext.len - tdata->cipher.offset_bits -
5163 (tdata->digest.len << 3)),
5164 tdata->cipher.offset_bits,
5165 "SNOW 3G Plaintext data not as expected");
5167 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5169 tdata->ciphertext.data,
5170 (tdata->validDataLenInBits.len -
5171 tdata->cipher.offset_bits),
5172 tdata->cipher.offset_bits,
5173 "SNOW 3G Ciphertext data not as expected");
5175 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5178 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5179 "SNOW 3G Generated auth tag not as expected");
5185 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5186 uint8_t op_mode, uint8_t verify)
5188 struct crypto_testsuite_params *ts_params = &testsuite_params;
5189 struct crypto_unittest_params *ut_params = &unittest_params;
5193 const uint8_t *plaintext = NULL;
5194 const uint8_t *ciphertext = NULL;
5195 const uint8_t *digest = NULL;
5196 unsigned int plaintext_pad_len;
5197 unsigned int plaintext_len;
5198 unsigned int ciphertext_pad_len;
5199 unsigned int ciphertext_len;
5200 uint8_t buffer[10000];
5201 uint8_t digest_buffer[10000];
5203 struct rte_cryptodev_info dev_info;
5205 /* Verify the capabilities */
5206 struct rte_cryptodev_sym_capability_idx cap_idx;
5207 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5208 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5209 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5211 return TEST_SKIPPED;
5212 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5213 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5214 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5216 return TEST_SKIPPED;
5218 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5219 return TEST_SKIPPED;
5221 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5223 uint64_t feat_flags = dev_info.feature_flags;
5225 if (op_mode == IN_PLACE) {
5226 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5227 printf("Device doesn't support in-place scatter-gather "
5228 "in both input and output mbufs.\n");
5229 return TEST_SKIPPED;
5231 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5232 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5233 printf("Device doesn't support RAW data-path APIs.\n");
5234 return TEST_SKIPPED;
5237 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5238 return TEST_SKIPPED;
5239 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5240 printf("Device doesn't support out-of-place scatter-gather "
5241 "in both input and output mbufs.\n");
5242 return TEST_SKIPPED;
5244 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5245 printf("Device doesn't support digest encrypted.\n");
5246 return TEST_SKIPPED;
5250 /* Create SNOW 3G session */
5251 retval = create_wireless_algo_auth_cipher_session(
5252 ts_params->valid_devs[0],
5253 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5254 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5255 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5256 : RTE_CRYPTO_AUTH_OP_GENERATE),
5257 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5258 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5259 tdata->key.data, tdata->key.len,
5260 tdata->auth_iv.len, tdata->digest.len,
5261 tdata->cipher_iv.len);
5266 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5267 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5268 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5269 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5271 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5272 plaintext_pad_len, 15, 0);
5273 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5274 "Failed to allocate input buffer in mempool");
5276 if (op_mode == OUT_OF_PLACE) {
5277 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5278 plaintext_pad_len, 15, 0);
5279 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5280 "Failed to allocate output buffer in mempool");
5284 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5285 tdata->ciphertext.data);
5286 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5287 ciphertext_len, buffer);
5288 debug_hexdump(stdout, "ciphertext:", ciphertext,
5291 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5292 tdata->plaintext.data);
5293 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5294 plaintext_len, buffer);
5295 debug_hexdump(stdout, "plaintext:", plaintext,
5298 memset(buffer, 0, sizeof(buffer));
5300 /* Create SNOW 3G operation */
5301 retval = create_wireless_algo_auth_cipher_operation(
5302 tdata->digest.data, tdata->digest.len,
5303 tdata->cipher_iv.data, tdata->cipher_iv.len,
5304 tdata->auth_iv.data, tdata->auth_iv.len,
5305 (tdata->digest.offset_bytes == 0 ?
5306 (verify ? ciphertext_pad_len : plaintext_pad_len)
5307 : tdata->digest.offset_bytes),
5308 tdata->validCipherLenInBits.len,
5309 tdata->cipher.offset_bits,
5310 tdata->validAuthLenInBits.len,
5311 tdata->auth.offset_bits,
5312 op_mode, 1, verify);
5317 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5318 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5319 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5321 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5324 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5326 ut_params->obuf = (op_mode == IN_PLACE ?
5327 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5330 if (ut_params->obuf)
5331 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5332 plaintext_len, buffer);
5334 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5335 plaintext_len, buffer);
5337 debug_hexdump(stdout, "plaintext:", plaintext,
5338 (tdata->plaintext.len >> 3) - tdata->digest.len);
5339 debug_hexdump(stdout, "plaintext expected:",
5340 tdata->plaintext.data,
5341 (tdata->plaintext.len >> 3) - tdata->digest.len);
5343 if (ut_params->obuf)
5344 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5345 ciphertext_len, buffer);
5347 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5348 ciphertext_len, buffer);
5350 debug_hexdump(stdout, "ciphertext:", ciphertext,
5352 debug_hexdump(stdout, "ciphertext expected:",
5353 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5355 if (ut_params->obuf)
5356 digest = rte_pktmbuf_read(ut_params->obuf,
5357 (tdata->digest.offset_bytes == 0 ?
5358 plaintext_pad_len : tdata->digest.offset_bytes),
5359 tdata->digest.len, digest_buffer);
5361 digest = rte_pktmbuf_read(ut_params->ibuf,
5362 (tdata->digest.offset_bytes == 0 ?
5363 plaintext_pad_len : tdata->digest.offset_bytes),
5364 tdata->digest.len, digest_buffer);
5366 debug_hexdump(stdout, "digest:", digest,
5368 debug_hexdump(stdout, "digest expected:",
5369 tdata->digest.data, tdata->digest.len);
5374 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5376 tdata->plaintext.data,
5377 (tdata->plaintext.len - tdata->cipher.offset_bits -
5378 (tdata->digest.len << 3)),
5379 tdata->cipher.offset_bits,
5380 "SNOW 3G Plaintext data not as expected");
5382 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5384 tdata->ciphertext.data,
5385 (tdata->validDataLenInBits.len -
5386 tdata->cipher.offset_bits),
5387 tdata->cipher.offset_bits,
5388 "SNOW 3G Ciphertext data not as expected");
5390 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5393 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5394 "SNOW 3G Generated auth tag not as expected");
5400 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5401 uint8_t op_mode, uint8_t verify)
5403 struct crypto_testsuite_params *ts_params = &testsuite_params;
5404 struct crypto_unittest_params *ut_params = &unittest_params;
5408 uint8_t *plaintext = NULL, *ciphertext = NULL;
5409 unsigned int plaintext_pad_len;
5410 unsigned int plaintext_len;
5411 unsigned int ciphertext_pad_len;
5412 unsigned int ciphertext_len;
5414 struct rte_cryptodev_info dev_info;
5416 /* Verify the capabilities */
5417 struct rte_cryptodev_sym_capability_idx cap_idx;
5418 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5419 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5420 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5422 return TEST_SKIPPED;
5423 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5424 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5425 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5427 return TEST_SKIPPED;
5429 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5431 uint64_t feat_flags = dev_info.feature_flags;
5433 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5434 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5435 printf("Device doesn't support RAW data-path APIs.\n");
5436 return TEST_SKIPPED;
5439 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5440 return TEST_SKIPPED;
5442 if (op_mode == OUT_OF_PLACE) {
5443 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5444 return TEST_SKIPPED;
5445 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5446 printf("Device doesn't support digest encrypted.\n");
5447 return TEST_SKIPPED;
5451 /* Create KASUMI session */
5452 retval = create_wireless_algo_auth_cipher_session(
5453 ts_params->valid_devs[0],
5454 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5455 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5456 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5457 : RTE_CRYPTO_AUTH_OP_GENERATE),
5458 RTE_CRYPTO_AUTH_KASUMI_F9,
5459 RTE_CRYPTO_CIPHER_KASUMI_F8,
5460 tdata->key.data, tdata->key.len,
5461 0, tdata->digest.len,
5462 tdata->cipher_iv.len);
5467 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5468 if (op_mode == OUT_OF_PLACE)
5469 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5471 /* clear mbuf payload */
5472 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5473 rte_pktmbuf_tailroom(ut_params->ibuf));
5474 if (op_mode == OUT_OF_PLACE)
5475 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5476 rte_pktmbuf_tailroom(ut_params->obuf));
5478 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5479 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5480 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5481 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5484 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5485 ciphertext_pad_len);
5486 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5487 if (op_mode == OUT_OF_PLACE)
5488 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5489 debug_hexdump(stdout, "ciphertext:", ciphertext,
5492 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5494 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5495 if (op_mode == OUT_OF_PLACE)
5496 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5497 debug_hexdump(stdout, "plaintext:", plaintext,
5501 /* Create KASUMI operation */
5502 retval = create_wireless_algo_auth_cipher_operation(
5503 tdata->digest.data, tdata->digest.len,
5504 tdata->cipher_iv.data, tdata->cipher_iv.len,
5506 (tdata->digest.offset_bytes == 0 ?
5507 (verify ? ciphertext_pad_len : plaintext_pad_len)
5508 : tdata->digest.offset_bytes),
5509 tdata->validCipherLenInBits.len,
5510 tdata->validCipherOffsetInBits.len,
5511 tdata->validAuthLenInBits.len,
5513 op_mode, 0, verify);
5518 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5519 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5520 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5522 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5525 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5527 ut_params->obuf = (op_mode == IN_PLACE ?
5528 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5532 if (ut_params->obuf)
5533 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5536 plaintext = ciphertext;
5538 debug_hexdump(stdout, "plaintext:", plaintext,
5539 (tdata->plaintext.len >> 3) - tdata->digest.len);
5540 debug_hexdump(stdout, "plaintext expected:",
5541 tdata->plaintext.data,
5542 (tdata->plaintext.len >> 3) - tdata->digest.len);
5544 if (ut_params->obuf)
5545 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5548 ciphertext = plaintext;
5550 debug_hexdump(stdout, "ciphertext:", ciphertext,
5552 debug_hexdump(stdout, "ciphertext expected:",
5553 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5555 ut_params->digest = rte_pktmbuf_mtod(
5556 ut_params->obuf, uint8_t *) +
5557 (tdata->digest.offset_bytes == 0 ?
5558 plaintext_pad_len : tdata->digest.offset_bytes);
5560 debug_hexdump(stdout, "digest:", ut_params->digest,
5562 debug_hexdump(stdout, "digest expected:",
5563 tdata->digest.data, tdata->digest.len);
5568 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5570 tdata->plaintext.data,
5571 tdata->plaintext.len >> 3,
5572 "KASUMI Plaintext data not as expected");
5574 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5576 tdata->ciphertext.data,
5577 tdata->ciphertext.len >> 3,
5578 "KASUMI Ciphertext data not as expected");
5580 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5583 DIGEST_BYTE_LENGTH_KASUMI_F9,
5584 "KASUMI Generated auth tag not as expected");
5590 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5591 uint8_t op_mode, uint8_t verify)
5593 struct crypto_testsuite_params *ts_params = &testsuite_params;
5594 struct crypto_unittest_params *ut_params = &unittest_params;
5598 const uint8_t *plaintext = NULL;
5599 const uint8_t *ciphertext = NULL;
5600 const uint8_t *digest = NULL;
5601 unsigned int plaintext_pad_len;
5602 unsigned int plaintext_len;
5603 unsigned int ciphertext_pad_len;
5604 unsigned int ciphertext_len;
5605 uint8_t buffer[10000];
5606 uint8_t digest_buffer[10000];
5608 struct rte_cryptodev_info dev_info;
5610 /* Verify the capabilities */
5611 struct rte_cryptodev_sym_capability_idx cap_idx;
5612 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5613 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5614 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5616 return TEST_SKIPPED;
5617 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5618 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5619 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5621 return TEST_SKIPPED;
5623 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5624 return TEST_SKIPPED;
5626 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5628 uint64_t feat_flags = dev_info.feature_flags;
5630 if (op_mode == IN_PLACE) {
5631 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5632 printf("Device doesn't support in-place scatter-gather "
5633 "in both input and output mbufs.\n");
5634 return TEST_SKIPPED;
5636 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5637 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5638 printf("Device doesn't support RAW data-path APIs.\n");
5639 return TEST_SKIPPED;
5642 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5643 return TEST_SKIPPED;
5644 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5645 printf("Device doesn't support out-of-place scatter-gather "
5646 "in both input and output mbufs.\n");
5647 return TEST_SKIPPED;
5649 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5650 printf("Device doesn't support digest encrypted.\n");
5651 return TEST_SKIPPED;
5655 /* Create KASUMI session */
5656 retval = create_wireless_algo_auth_cipher_session(
5657 ts_params->valid_devs[0],
5658 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5659 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5660 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5661 : RTE_CRYPTO_AUTH_OP_GENERATE),
5662 RTE_CRYPTO_AUTH_KASUMI_F9,
5663 RTE_CRYPTO_CIPHER_KASUMI_F8,
5664 tdata->key.data, tdata->key.len,
5665 0, tdata->digest.len,
5666 tdata->cipher_iv.len);
5671 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5672 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5673 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5674 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5676 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5677 plaintext_pad_len, 15, 0);
5678 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5679 "Failed to allocate input buffer in mempool");
5681 if (op_mode == OUT_OF_PLACE) {
5682 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5683 plaintext_pad_len, 15, 0);
5684 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5685 "Failed to allocate output buffer in mempool");
5689 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5690 tdata->ciphertext.data);
5691 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5692 ciphertext_len, buffer);
5693 debug_hexdump(stdout, "ciphertext:", ciphertext,
5696 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5697 tdata->plaintext.data);
5698 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5699 plaintext_len, buffer);
5700 debug_hexdump(stdout, "plaintext:", plaintext,
5703 memset(buffer, 0, sizeof(buffer));
5705 /* Create KASUMI operation */
5706 retval = create_wireless_algo_auth_cipher_operation(
5707 tdata->digest.data, tdata->digest.len,
5708 tdata->cipher_iv.data, tdata->cipher_iv.len,
5710 (tdata->digest.offset_bytes == 0 ?
5711 (verify ? ciphertext_pad_len : plaintext_pad_len)
5712 : tdata->digest.offset_bytes),
5713 tdata->validCipherLenInBits.len,
5714 tdata->validCipherOffsetInBits.len,
5715 tdata->validAuthLenInBits.len,
5717 op_mode, 1, verify);
5722 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5723 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5724 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5726 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5729 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5731 ut_params->obuf = (op_mode == IN_PLACE ?
5732 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5735 if (ut_params->obuf)
5736 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5737 plaintext_len, buffer);
5739 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5740 plaintext_len, buffer);
5742 debug_hexdump(stdout, "plaintext:", plaintext,
5743 (tdata->plaintext.len >> 3) - tdata->digest.len);
5744 debug_hexdump(stdout, "plaintext expected:",
5745 tdata->plaintext.data,
5746 (tdata->plaintext.len >> 3) - tdata->digest.len);
5748 if (ut_params->obuf)
5749 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5750 ciphertext_len, buffer);
5752 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5753 ciphertext_len, buffer);
5755 debug_hexdump(stdout, "ciphertext:", ciphertext,
5757 debug_hexdump(stdout, "ciphertext expected:",
5758 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5760 if (ut_params->obuf)
5761 digest = rte_pktmbuf_read(ut_params->obuf,
5762 (tdata->digest.offset_bytes == 0 ?
5763 plaintext_pad_len : tdata->digest.offset_bytes),
5764 tdata->digest.len, digest_buffer);
5766 digest = rte_pktmbuf_read(ut_params->ibuf,
5767 (tdata->digest.offset_bytes == 0 ?
5768 plaintext_pad_len : tdata->digest.offset_bytes),
5769 tdata->digest.len, digest_buffer);
5771 debug_hexdump(stdout, "digest:", digest,
5773 debug_hexdump(stdout, "digest expected:",
5774 tdata->digest.data, tdata->digest.len);
5779 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5781 tdata->plaintext.data,
5782 tdata->plaintext.len >> 3,
5783 "KASUMI Plaintext data not as expected");
5785 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5787 tdata->ciphertext.data,
5788 tdata->validDataLenInBits.len,
5789 "KASUMI Ciphertext data not as expected");
5791 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5794 DIGEST_BYTE_LENGTH_KASUMI_F9,
5795 "KASUMI Generated auth tag not as expected");
5801 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5803 struct crypto_testsuite_params *ts_params = &testsuite_params;
5804 struct crypto_unittest_params *ut_params = &unittest_params;
5808 uint8_t *plaintext, *ciphertext;
5809 unsigned plaintext_pad_len;
5810 unsigned plaintext_len;
5811 struct rte_cryptodev_info dev_info;
5813 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5814 uint64_t feat_flags = dev_info.feature_flags;
5816 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5817 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5818 printf("Device doesn't support RAW data-path APIs.\n");
5819 return TEST_SKIPPED;
5822 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5823 return TEST_SKIPPED;
5825 /* Verify the capabilities */
5826 struct rte_cryptodev_sym_capability_idx cap_idx;
5827 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5828 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5829 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5831 return TEST_SKIPPED;
5832 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5833 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5834 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5836 return TEST_SKIPPED;
5838 /* Create KASUMI session */
5839 retval = create_wireless_algo_cipher_auth_session(
5840 ts_params->valid_devs[0],
5841 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5842 RTE_CRYPTO_AUTH_OP_GENERATE,
5843 RTE_CRYPTO_AUTH_KASUMI_F9,
5844 RTE_CRYPTO_CIPHER_KASUMI_F8,
5845 tdata->key.data, tdata->key.len,
5846 0, tdata->digest.len,
5847 tdata->cipher_iv.len);
5851 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5853 /* clear mbuf payload */
5854 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5855 rte_pktmbuf_tailroom(ut_params->ibuf));
5857 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5858 /* Append data which is padded to a multiple of */
5859 /* the algorithms block size */
5860 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5861 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5863 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5865 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5867 /* Create KASUMI operation */
5868 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5869 tdata->digest.len, NULL, 0,
5870 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5871 tdata->cipher_iv.data, tdata->cipher_iv.len,
5872 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5873 tdata->validCipherOffsetInBits.len,
5874 tdata->validAuthLenInBits.len,
5880 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5881 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5882 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5884 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5886 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5888 if (ut_params->op->sym->m_dst)
5889 ut_params->obuf = ut_params->op->sym->m_dst;
5891 ut_params->obuf = ut_params->op->sym->m_src;
5893 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5894 tdata->validCipherOffsetInBits.len >> 3);
5896 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5897 + plaintext_pad_len;
5899 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5900 (tdata->validCipherOffsetInBits.len >> 3);
5902 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5904 reference_ciphertext,
5905 tdata->validCipherLenInBits.len,
5906 "KASUMI Ciphertext data not as expected");
5909 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5912 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5913 "KASUMI Generated auth tag not as expected");
5918 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
5919 const enum rte_crypto_cipher_algorithm cipher_algo,
5920 const uint16_t key_size, const uint16_t iv_size)
5922 struct rte_cryptodev_sym_capability_idx cap_idx;
5923 const struct rte_cryptodev_symmetric_capability *cap;
5925 /* Check if device supports the algorithm */
5926 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5927 cap_idx.algo.cipher = cipher_algo;
5929 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5935 /* Check if device supports key size and IV size */
5936 if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
5945 check_auth_capability(const struct crypto_testsuite_params *ts_params,
5946 const enum rte_crypto_auth_algorithm auth_algo,
5947 const uint16_t key_size, const uint16_t iv_size,
5948 const uint16_t tag_size)
5950 struct rte_cryptodev_sym_capability_idx cap_idx;
5951 const struct rte_cryptodev_symmetric_capability *cap;
5953 /* Check if device supports the algorithm */
5954 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5955 cap_idx.algo.auth = auth_algo;
5957 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5963 /* Check if device supports key size and IV size */
5964 if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
5965 tag_size, iv_size) < 0) {
5973 test_zuc_encryption(const struct wireless_test_data *tdata)
5975 struct crypto_testsuite_params *ts_params = &testsuite_params;
5976 struct crypto_unittest_params *ut_params = &unittest_params;
5979 uint8_t *plaintext, *ciphertext;
5980 unsigned plaintext_pad_len;
5981 unsigned plaintext_len;
5982 struct rte_cryptodev_info dev_info;
5984 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5985 uint64_t feat_flags = dev_info.feature_flags;
5987 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5988 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5989 printf("Device doesn't support RAW data-path APIs.\n");
5990 return TEST_SKIPPED;
5993 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5994 return TEST_SKIPPED;
5996 /* Check if device supports ZUC EEA3 */
5997 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5998 tdata->key.len, tdata->cipher_iv.len) < 0)
5999 return TEST_SKIPPED;
6001 /* Create ZUC session */
6002 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6003 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6004 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6005 tdata->key.data, tdata->key.len,
6006 tdata->cipher_iv.len);
6010 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6012 /* Clear mbuf payload */
6013 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6014 rte_pktmbuf_tailroom(ut_params->ibuf));
6016 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6017 /* Append data which is padded to a multiple */
6018 /* of the algorithms block size */
6019 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6020 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6022 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6024 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6026 /* Create ZUC operation */
6027 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6028 tdata->cipher_iv.len,
6029 tdata->plaintext.len,
6034 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6035 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6036 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6038 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6040 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6042 ut_params->obuf = ut_params->op->sym->m_dst;
6043 if (ut_params->obuf)
6044 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6046 ciphertext = plaintext;
6048 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6051 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6053 tdata->ciphertext.data,
6054 tdata->validCipherLenInBits.len,
6055 "ZUC Ciphertext data not as expected");
6060 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
6062 struct crypto_testsuite_params *ts_params = &testsuite_params;
6063 struct crypto_unittest_params *ut_params = &unittest_params;
6067 unsigned int plaintext_pad_len;
6068 unsigned int plaintext_len;
6069 const uint8_t *ciphertext;
6070 uint8_t ciphertext_buffer[2048];
6071 struct rte_cryptodev_info dev_info;
6073 /* Check if device supports ZUC EEA3 */
6074 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6075 tdata->key.len, tdata->cipher_iv.len) < 0)
6076 return TEST_SKIPPED;
6078 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6079 return TEST_SKIPPED;
6081 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6083 uint64_t feat_flags = dev_info.feature_flags;
6085 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6086 printf("Device doesn't support in-place scatter-gather. "
6088 return TEST_SKIPPED;
6091 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6092 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6093 printf("Device doesn't support RAW data-path APIs.\n");
6094 return TEST_SKIPPED;
6097 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6099 /* Append data which is padded to a multiple */
6100 /* of the algorithms block size */
6101 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6103 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6104 plaintext_pad_len, 10, 0);
6106 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6107 tdata->plaintext.data);
6109 /* Create ZUC session */
6110 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6111 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6112 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6113 tdata->key.data, tdata->key.len,
6114 tdata->cipher_iv.len);
6118 /* Clear mbuf payload */
6120 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6122 /* Create ZUC operation */
6123 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6124 tdata->cipher_iv.len, tdata->plaintext.len,
6129 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6130 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6131 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6133 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6135 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6137 ut_params->obuf = ut_params->op->sym->m_dst;
6138 if (ut_params->obuf)
6139 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6140 0, plaintext_len, ciphertext_buffer);
6142 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6143 0, plaintext_len, ciphertext_buffer);
6146 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6149 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6151 tdata->ciphertext.data,
6152 tdata->validCipherLenInBits.len,
6153 "ZUC Ciphertext data not as expected");
6159 test_zuc_authentication(const struct wireless_test_data *tdata)
6161 struct crypto_testsuite_params *ts_params = &testsuite_params;
6162 struct crypto_unittest_params *ut_params = &unittest_params;
6165 unsigned plaintext_pad_len;
6166 unsigned plaintext_len;
6169 struct rte_cryptodev_info dev_info;
6171 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6172 uint64_t feat_flags = dev_info.feature_flags;
6174 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6175 (tdata->validAuthLenInBits.len % 8 != 0)) {
6176 printf("Device doesn't support NON-Byte Aligned Data.\n");
6177 return TEST_SKIPPED;
6180 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6181 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6182 printf("Device doesn't support RAW data-path APIs.\n");
6183 return TEST_SKIPPED;
6186 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6187 return TEST_SKIPPED;
6189 /* Check if device supports ZUC EIA3 */
6190 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6191 tdata->key.len, tdata->auth_iv.len,
6192 tdata->digest.len) < 0)
6193 return TEST_SKIPPED;
6195 /* Create ZUC session */
6196 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6197 tdata->key.data, tdata->key.len,
6198 tdata->auth_iv.len, tdata->digest.len,
6199 RTE_CRYPTO_AUTH_OP_GENERATE,
6200 RTE_CRYPTO_AUTH_ZUC_EIA3);
6204 /* alloc mbuf and set payload */
6205 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6207 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6208 rte_pktmbuf_tailroom(ut_params->ibuf));
6210 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6211 /* Append data which is padded to a multiple of */
6212 /* the algorithms block size */
6213 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6214 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6216 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6218 /* Create ZUC operation */
6219 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6220 tdata->auth_iv.data, tdata->auth_iv.len,
6221 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6222 tdata->validAuthLenInBits.len,
6227 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6228 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6229 ut_params->op, 0, 1, 1, 0);
6231 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6233 ut_params->obuf = ut_params->op->sym->m_src;
6234 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6235 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6236 + plaintext_pad_len;
6239 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6243 "ZUC Generated auth tag not as expected");
6249 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6250 uint8_t op_mode, uint8_t verify)
6252 struct crypto_testsuite_params *ts_params = &testsuite_params;
6253 struct crypto_unittest_params *ut_params = &unittest_params;
6257 uint8_t *plaintext = NULL, *ciphertext = NULL;
6258 unsigned int plaintext_pad_len;
6259 unsigned int plaintext_len;
6260 unsigned int ciphertext_pad_len;
6261 unsigned int ciphertext_len;
6263 struct rte_cryptodev_info dev_info;
6265 /* Check if device supports ZUC EEA3 */
6266 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6267 tdata->key.len, tdata->cipher_iv.len) < 0)
6268 return TEST_SKIPPED;
6270 /* Check if device supports ZUC EIA3 */
6271 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6272 tdata->key.len, tdata->auth_iv.len,
6273 tdata->digest.len) < 0)
6274 return TEST_SKIPPED;
6276 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6278 uint64_t feat_flags = dev_info.feature_flags;
6280 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6281 printf("Device doesn't support digest encrypted.\n");
6282 return TEST_SKIPPED;
6284 if (op_mode == IN_PLACE) {
6285 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6286 printf("Device doesn't support in-place scatter-gather "
6287 "in both input and output mbufs.\n");
6288 return TEST_SKIPPED;
6291 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6292 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6293 printf("Device doesn't support RAW data-path APIs.\n");
6294 return TEST_SKIPPED;
6297 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6298 return TEST_SKIPPED;
6299 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6300 printf("Device doesn't support out-of-place scatter-gather "
6301 "in both input and output mbufs.\n");
6302 return TEST_SKIPPED;
6306 /* Create ZUC session */
6307 retval = create_wireless_algo_auth_cipher_session(
6308 ts_params->valid_devs[0],
6309 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6310 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6311 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6312 : RTE_CRYPTO_AUTH_OP_GENERATE),
6313 RTE_CRYPTO_AUTH_ZUC_EIA3,
6314 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6315 tdata->key.data, tdata->key.len,
6316 tdata->auth_iv.len, tdata->digest.len,
6317 tdata->cipher_iv.len);
6322 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6323 if (op_mode == OUT_OF_PLACE)
6324 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6326 /* clear mbuf payload */
6327 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6328 rte_pktmbuf_tailroom(ut_params->ibuf));
6329 if (op_mode == OUT_OF_PLACE)
6330 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6331 rte_pktmbuf_tailroom(ut_params->obuf));
6333 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6334 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6335 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6336 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6339 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6340 ciphertext_pad_len);
6341 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6342 debug_hexdump(stdout, "ciphertext:", ciphertext,
6345 /* make sure enough space to cover partial digest verify case */
6346 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6347 ciphertext_pad_len);
6348 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6349 debug_hexdump(stdout, "plaintext:", plaintext,
6353 if (op_mode == OUT_OF_PLACE)
6354 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6356 /* Create ZUC operation */
6357 retval = create_wireless_algo_auth_cipher_operation(
6358 tdata->digest.data, tdata->digest.len,
6359 tdata->cipher_iv.data, tdata->cipher_iv.len,
6360 tdata->auth_iv.data, tdata->auth_iv.len,
6361 (tdata->digest.offset_bytes == 0 ?
6362 (verify ? ciphertext_pad_len : plaintext_pad_len)
6363 : tdata->digest.offset_bytes),
6364 tdata->validCipherLenInBits.len,
6365 tdata->validCipherOffsetInBits.len,
6366 tdata->validAuthLenInBits.len,
6368 op_mode, 0, verify);
6373 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6374 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6375 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6377 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6380 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6382 ut_params->obuf = (op_mode == IN_PLACE ?
6383 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6387 if (ut_params->obuf)
6388 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6391 plaintext = ciphertext;
6393 debug_hexdump(stdout, "plaintext:", plaintext,
6394 (tdata->plaintext.len >> 3) - tdata->digest.len);
6395 debug_hexdump(stdout, "plaintext expected:",
6396 tdata->plaintext.data,
6397 (tdata->plaintext.len >> 3) - tdata->digest.len);
6399 if (ut_params->obuf)
6400 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6403 ciphertext = plaintext;
6405 debug_hexdump(stdout, "ciphertext:", ciphertext,
6407 debug_hexdump(stdout, "ciphertext expected:",
6408 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6410 ut_params->digest = rte_pktmbuf_mtod(
6411 ut_params->obuf, uint8_t *) +
6412 (tdata->digest.offset_bytes == 0 ?
6413 plaintext_pad_len : tdata->digest.offset_bytes);
6415 debug_hexdump(stdout, "digest:", ut_params->digest,
6417 debug_hexdump(stdout, "digest expected:",
6418 tdata->digest.data, tdata->digest.len);
6423 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6425 tdata->plaintext.data,
6426 tdata->plaintext.len >> 3,
6427 "ZUC Plaintext data not as expected");
6429 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6431 tdata->ciphertext.data,
6432 tdata->ciphertext.len >> 3,
6433 "ZUC Ciphertext data not as expected");
6435 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6438 DIGEST_BYTE_LENGTH_KASUMI_F9,
6439 "ZUC Generated auth tag not as expected");
6445 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6446 uint8_t op_mode, uint8_t verify)
6448 struct crypto_testsuite_params *ts_params = &testsuite_params;
6449 struct crypto_unittest_params *ut_params = &unittest_params;
6453 const uint8_t *plaintext = NULL;
6454 const uint8_t *ciphertext = NULL;
6455 const uint8_t *digest = NULL;
6456 unsigned int plaintext_pad_len;
6457 unsigned int plaintext_len;
6458 unsigned int ciphertext_pad_len;
6459 unsigned int ciphertext_len;
6460 uint8_t buffer[10000];
6461 uint8_t digest_buffer[10000];
6463 struct rte_cryptodev_info dev_info;
6465 /* Check if device supports ZUC EEA3 */
6466 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6467 tdata->key.len, tdata->cipher_iv.len) < 0)
6468 return TEST_SKIPPED;
6470 /* Check if device supports ZUC EIA3 */
6471 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6472 tdata->key.len, tdata->auth_iv.len,
6473 tdata->digest.len) < 0)
6474 return TEST_SKIPPED;
6476 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6478 uint64_t feat_flags = dev_info.feature_flags;
6480 if (op_mode == IN_PLACE) {
6481 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6482 printf("Device doesn't support in-place scatter-gather "
6483 "in both input and output mbufs.\n");
6484 return TEST_SKIPPED;
6487 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6488 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6489 printf("Device doesn't support RAW data-path APIs.\n");
6490 return TEST_SKIPPED;
6493 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6494 return TEST_SKIPPED;
6495 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6496 printf("Device doesn't support out-of-place scatter-gather "
6497 "in both input and output mbufs.\n");
6498 return TEST_SKIPPED;
6500 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6501 printf("Device doesn't support digest encrypted.\n");
6502 return TEST_SKIPPED;
6506 /* Create ZUC session */
6507 retval = create_wireless_algo_auth_cipher_session(
6508 ts_params->valid_devs[0],
6509 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6510 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6511 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6512 : RTE_CRYPTO_AUTH_OP_GENERATE),
6513 RTE_CRYPTO_AUTH_ZUC_EIA3,
6514 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6515 tdata->key.data, tdata->key.len,
6516 tdata->auth_iv.len, tdata->digest.len,
6517 tdata->cipher_iv.len);
6522 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6523 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6524 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6525 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6527 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6528 plaintext_pad_len, 15, 0);
6529 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6530 "Failed to allocate input buffer in mempool");
6532 if (op_mode == OUT_OF_PLACE) {
6533 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6534 plaintext_pad_len, 15, 0);
6535 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6536 "Failed to allocate output buffer in mempool");
6540 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6541 tdata->ciphertext.data);
6542 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6543 ciphertext_len, buffer);
6544 debug_hexdump(stdout, "ciphertext:", ciphertext,
6547 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6548 tdata->plaintext.data);
6549 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6550 plaintext_len, buffer);
6551 debug_hexdump(stdout, "plaintext:", plaintext,
6554 memset(buffer, 0, sizeof(buffer));
6556 /* Create ZUC operation */
6557 retval = create_wireless_algo_auth_cipher_operation(
6558 tdata->digest.data, tdata->digest.len,
6559 tdata->cipher_iv.data, tdata->cipher_iv.len,
6561 (tdata->digest.offset_bytes == 0 ?
6562 (verify ? ciphertext_pad_len : plaintext_pad_len)
6563 : tdata->digest.offset_bytes),
6564 tdata->validCipherLenInBits.len,
6565 tdata->validCipherOffsetInBits.len,
6566 tdata->validAuthLenInBits.len,
6568 op_mode, 1, verify);
6573 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6574 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6575 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6577 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6580 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6582 ut_params->obuf = (op_mode == IN_PLACE ?
6583 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6586 if (ut_params->obuf)
6587 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6588 plaintext_len, buffer);
6590 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6591 plaintext_len, buffer);
6593 debug_hexdump(stdout, "plaintext:", plaintext,
6594 (tdata->plaintext.len >> 3) - tdata->digest.len);
6595 debug_hexdump(stdout, "plaintext expected:",
6596 tdata->plaintext.data,
6597 (tdata->plaintext.len >> 3) - tdata->digest.len);
6599 if (ut_params->obuf)
6600 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6601 ciphertext_len, buffer);
6603 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6604 ciphertext_len, buffer);
6606 debug_hexdump(stdout, "ciphertext:", ciphertext,
6608 debug_hexdump(stdout, "ciphertext expected:",
6609 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6611 if (ut_params->obuf)
6612 digest = rte_pktmbuf_read(ut_params->obuf,
6613 (tdata->digest.offset_bytes == 0 ?
6614 plaintext_pad_len : tdata->digest.offset_bytes),
6615 tdata->digest.len, digest_buffer);
6617 digest = rte_pktmbuf_read(ut_params->ibuf,
6618 (tdata->digest.offset_bytes == 0 ?
6619 plaintext_pad_len : tdata->digest.offset_bytes),
6620 tdata->digest.len, digest_buffer);
6622 debug_hexdump(stdout, "digest:", digest,
6624 debug_hexdump(stdout, "digest expected:",
6625 tdata->digest.data, tdata->digest.len);
6630 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6632 tdata->plaintext.data,
6633 tdata->plaintext.len >> 3,
6634 "ZUC Plaintext data not as expected");
6636 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6638 tdata->ciphertext.data,
6639 tdata->validDataLenInBits.len,
6640 "ZUC Ciphertext data not as expected");
6642 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6645 DIGEST_BYTE_LENGTH_KASUMI_F9,
6646 "ZUC Generated auth tag not as expected");
6652 test_kasumi_encryption_test_case_1(void)
6654 return test_kasumi_encryption(&kasumi_test_case_1);
6658 test_kasumi_encryption_test_case_1_sgl(void)
6660 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6664 test_kasumi_encryption_test_case_1_oop(void)
6666 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6670 test_kasumi_encryption_test_case_1_oop_sgl(void)
6672 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6676 test_kasumi_encryption_test_case_2(void)
6678 return test_kasumi_encryption(&kasumi_test_case_2);
6682 test_kasumi_encryption_test_case_3(void)
6684 return test_kasumi_encryption(&kasumi_test_case_3);
6688 test_kasumi_encryption_test_case_4(void)
6690 return test_kasumi_encryption(&kasumi_test_case_4);
6694 test_kasumi_encryption_test_case_5(void)
6696 return test_kasumi_encryption(&kasumi_test_case_5);
6700 test_kasumi_decryption_test_case_1(void)
6702 return test_kasumi_decryption(&kasumi_test_case_1);
6706 test_kasumi_decryption_test_case_1_oop(void)
6708 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6712 test_kasumi_decryption_test_case_2(void)
6714 return test_kasumi_decryption(&kasumi_test_case_2);
6718 test_kasumi_decryption_test_case_3(void)
6720 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6721 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6722 return TEST_SKIPPED;
6723 return test_kasumi_decryption(&kasumi_test_case_3);
6727 test_kasumi_decryption_test_case_4(void)
6729 return test_kasumi_decryption(&kasumi_test_case_4);
6733 test_kasumi_decryption_test_case_5(void)
6735 return test_kasumi_decryption(&kasumi_test_case_5);
6738 test_snow3g_encryption_test_case_1(void)
6740 return test_snow3g_encryption(&snow3g_test_case_1);
6744 test_snow3g_encryption_test_case_1_oop(void)
6746 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6750 test_snow3g_encryption_test_case_1_oop_sgl(void)
6752 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6757 test_snow3g_encryption_test_case_1_offset_oop(void)
6759 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6763 test_snow3g_encryption_test_case_2(void)
6765 return test_snow3g_encryption(&snow3g_test_case_2);
6769 test_snow3g_encryption_test_case_3(void)
6771 return test_snow3g_encryption(&snow3g_test_case_3);
6775 test_snow3g_encryption_test_case_4(void)
6777 return test_snow3g_encryption(&snow3g_test_case_4);
6781 test_snow3g_encryption_test_case_5(void)
6783 return test_snow3g_encryption(&snow3g_test_case_5);
6787 test_snow3g_decryption_test_case_1(void)
6789 return test_snow3g_decryption(&snow3g_test_case_1);
6793 test_snow3g_decryption_test_case_1_oop(void)
6795 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6799 test_snow3g_decryption_test_case_2(void)
6801 return test_snow3g_decryption(&snow3g_test_case_2);
6805 test_snow3g_decryption_test_case_3(void)
6807 return test_snow3g_decryption(&snow3g_test_case_3);
6811 test_snow3g_decryption_test_case_4(void)
6813 return test_snow3g_decryption(&snow3g_test_case_4);
6817 test_snow3g_decryption_test_case_5(void)
6819 return test_snow3g_decryption(&snow3g_test_case_5);
6823 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6824 * Pattern digest from snow3g_test_data must be allocated as
6825 * 4 last bytes in plaintext.
6828 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6829 struct snow3g_hash_test_data *output)
6831 if ((pattern != NULL) && (output != NULL)) {
6832 output->key.len = pattern->key.len;
6834 memcpy(output->key.data,
6835 pattern->key.data, pattern->key.len);
6837 output->auth_iv.len = pattern->auth_iv.len;
6839 memcpy(output->auth_iv.data,
6840 pattern->auth_iv.data, pattern->auth_iv.len);
6842 output->plaintext.len = pattern->plaintext.len;
6844 memcpy(output->plaintext.data,
6845 pattern->plaintext.data, pattern->plaintext.len >> 3);
6847 output->digest.len = pattern->digest.len;
6849 memcpy(output->digest.data,
6850 &pattern->plaintext.data[pattern->digest.offset_bytes],
6851 pattern->digest.len);
6853 output->validAuthLenInBits.len =
6854 pattern->validAuthLenInBits.len;
6859 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6862 test_snow3g_decryption_with_digest_test_case_1(void)
6864 struct snow3g_hash_test_data snow3g_hash_data;
6865 struct rte_cryptodev_info dev_info;
6866 struct crypto_testsuite_params *ts_params = &testsuite_params;
6868 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6869 uint64_t feat_flags = dev_info.feature_flags;
6871 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6872 printf("Device doesn't support encrypted digest operations.\n");
6873 return TEST_SKIPPED;
6877 * Function prepare data for hash verification test case.
6878 * Digest is allocated in 4 last bytes in plaintext, pattern.
6880 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6882 return test_snow3g_decryption(&snow3g_test_case_7) &
6883 test_snow3g_authentication_verify(&snow3g_hash_data);
6887 test_snow3g_cipher_auth_test_case_1(void)
6889 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6893 test_snow3g_auth_cipher_test_case_1(void)
6895 return test_snow3g_auth_cipher(
6896 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6900 test_snow3g_auth_cipher_test_case_2(void)
6902 return test_snow3g_auth_cipher(
6903 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6907 test_snow3g_auth_cipher_test_case_2_oop(void)
6909 return test_snow3g_auth_cipher(
6910 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6914 test_snow3g_auth_cipher_part_digest_enc(void)
6916 return test_snow3g_auth_cipher(
6917 &snow3g_auth_cipher_partial_digest_encryption,
6922 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6924 return test_snow3g_auth_cipher(
6925 &snow3g_auth_cipher_partial_digest_encryption,
6930 test_snow3g_auth_cipher_test_case_3_sgl(void)
6932 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6933 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6934 return TEST_SKIPPED;
6935 return test_snow3g_auth_cipher_sgl(
6936 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6940 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6942 return test_snow3g_auth_cipher_sgl(
6943 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6947 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6949 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6950 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6951 return TEST_SKIPPED;
6952 return test_snow3g_auth_cipher_sgl(
6953 &snow3g_auth_cipher_partial_digest_encryption,
6958 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6960 return test_snow3g_auth_cipher_sgl(
6961 &snow3g_auth_cipher_partial_digest_encryption,
6966 test_snow3g_auth_cipher_verify_test_case_1(void)
6968 return test_snow3g_auth_cipher(
6969 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6973 test_snow3g_auth_cipher_verify_test_case_2(void)
6975 return test_snow3g_auth_cipher(
6976 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6980 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6982 return test_snow3g_auth_cipher(
6983 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6987 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6989 return test_snow3g_auth_cipher(
6990 &snow3g_auth_cipher_partial_digest_encryption,
6995 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6997 return test_snow3g_auth_cipher(
6998 &snow3g_auth_cipher_partial_digest_encryption,
7003 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7005 return test_snow3g_auth_cipher_sgl(
7006 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7010 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7012 return test_snow3g_auth_cipher_sgl(
7013 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7017 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7019 return test_snow3g_auth_cipher_sgl(
7020 &snow3g_auth_cipher_partial_digest_encryption,
7025 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7027 return test_snow3g_auth_cipher_sgl(
7028 &snow3g_auth_cipher_partial_digest_encryption,
7033 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7035 return test_snow3g_auth_cipher(
7036 &snow3g_test_case_7, IN_PLACE, 0);
7040 test_kasumi_auth_cipher_test_case_1(void)
7042 return test_kasumi_auth_cipher(
7043 &kasumi_test_case_3, IN_PLACE, 0);
7047 test_kasumi_auth_cipher_test_case_2(void)
7049 return test_kasumi_auth_cipher(
7050 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7054 test_kasumi_auth_cipher_test_case_2_oop(void)
7056 return test_kasumi_auth_cipher(
7057 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7061 test_kasumi_auth_cipher_test_case_2_sgl(void)
7063 return test_kasumi_auth_cipher_sgl(
7064 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7068 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7070 return test_kasumi_auth_cipher_sgl(
7071 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7075 test_kasumi_auth_cipher_verify_test_case_1(void)
7077 return test_kasumi_auth_cipher(
7078 &kasumi_test_case_3, IN_PLACE, 1);
7082 test_kasumi_auth_cipher_verify_test_case_2(void)
7084 return test_kasumi_auth_cipher(
7085 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7089 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7091 return test_kasumi_auth_cipher(
7092 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7096 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7098 return test_kasumi_auth_cipher_sgl(
7099 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7103 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7105 return test_kasumi_auth_cipher_sgl(
7106 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7110 test_kasumi_cipher_auth_test_case_1(void)
7112 return test_kasumi_cipher_auth(&kasumi_test_case_6);
7116 test_zuc_encryption_test_case_1(void)
7118 return test_zuc_encryption(&zuc_test_case_cipher_193b);
7122 test_zuc_encryption_test_case_2(void)
7124 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7128 test_zuc_encryption_test_case_3(void)
7130 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7134 test_zuc_encryption_test_case_4(void)
7136 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7140 test_zuc_encryption_test_case_5(void)
7142 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7146 test_zuc_encryption_test_case_6_sgl(void)
7148 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7152 test_zuc_hash_generate_test_case_1(void)
7154 return test_zuc_authentication(&zuc_test_case_auth_1b);
7158 test_zuc_hash_generate_test_case_2(void)
7160 return test_zuc_authentication(&zuc_test_case_auth_90b);
7164 test_zuc_hash_generate_test_case_3(void)
7166 return test_zuc_authentication(&zuc_test_case_auth_577b);
7170 test_zuc_hash_generate_test_case_4(void)
7172 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7176 test_zuc_hash_generate_test_case_5(void)
7178 return test_zuc_authentication(&zuc_test_auth_5670b);
7182 test_zuc_hash_generate_test_case_6(void)
7184 return test_zuc_authentication(&zuc_test_case_auth_128b);
7188 test_zuc_hash_generate_test_case_7(void)
7190 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7194 test_zuc_hash_generate_test_case_8(void)
7196 return test_zuc_authentication(&zuc_test_case_auth_584b);
7200 test_zuc_hash_generate_test_case_9(void)
7202 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b);
7206 test_zuc_hash_generate_test_case_10(void)
7208 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b);
7212 test_zuc_hash_generate_test_case_11(void)
7214 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b);
7218 test_zuc_cipher_auth_test_case_1(void)
7220 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7224 test_zuc_cipher_auth_test_case_2(void)
7226 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7230 test_zuc_auth_cipher_test_case_1(void)
7232 return test_zuc_auth_cipher(
7233 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7237 test_zuc_auth_cipher_test_case_1_oop(void)
7239 return test_zuc_auth_cipher(
7240 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7244 test_zuc_auth_cipher_test_case_1_sgl(void)
7246 return test_zuc_auth_cipher_sgl(
7247 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7251 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7253 return test_zuc_auth_cipher_sgl(
7254 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7258 test_zuc_auth_cipher_verify_test_case_1(void)
7260 return test_zuc_auth_cipher(
7261 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7265 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7267 return test_zuc_auth_cipher(
7268 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7272 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7274 return test_zuc_auth_cipher_sgl(
7275 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7279 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7281 return test_zuc_auth_cipher_sgl(
7282 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7286 test_zuc256_encryption_test_case_1(void)
7288 return test_zuc_encryption(&zuc256_test_case_cipher_1);
7292 test_zuc256_encryption_test_case_2(void)
7294 return test_zuc_encryption(&zuc256_test_case_cipher_2);
7298 test_zuc256_authentication_test_case_1(void)
7300 return test_zuc_authentication(&zuc256_test_case_auth_1);
7304 test_zuc256_authentication_test_case_2(void)
7306 return test_zuc_authentication(&zuc256_test_case_auth_2);
7310 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7312 uint8_t dev_id = testsuite_params.valid_devs[0];
7314 struct rte_cryptodev_sym_capability_idx cap_idx;
7316 /* Check if device supports particular cipher algorithm */
7317 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7318 cap_idx.algo.cipher = tdata->cipher_algo;
7319 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7320 return TEST_SKIPPED;
7322 /* Check if device supports particular hash algorithm */
7323 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7324 cap_idx.algo.auth = tdata->auth_algo;
7325 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7326 return TEST_SKIPPED;
7332 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7333 uint8_t op_mode, uint8_t verify)
7335 struct crypto_testsuite_params *ts_params = &testsuite_params;
7336 struct crypto_unittest_params *ut_params = &unittest_params;
7340 uint8_t *plaintext = NULL, *ciphertext = NULL;
7341 unsigned int plaintext_pad_len;
7342 unsigned int plaintext_len;
7343 unsigned int ciphertext_pad_len;
7344 unsigned int ciphertext_len;
7346 struct rte_cryptodev_info dev_info;
7347 struct rte_crypto_op *op;
7349 /* Check if device supports particular algorithms separately */
7350 if (test_mixed_check_if_unsupported(tdata))
7351 return TEST_SKIPPED;
7352 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7353 return TEST_SKIPPED;
7355 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7357 uint64_t feat_flags = dev_info.feature_flags;
7359 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7360 printf("Device doesn't support digest encrypted.\n");
7361 return TEST_SKIPPED;
7364 /* Create the session */
7366 retval = create_wireless_algo_cipher_auth_session(
7367 ts_params->valid_devs[0],
7368 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7369 RTE_CRYPTO_AUTH_OP_VERIFY,
7372 tdata->auth_key.data, tdata->auth_key.len,
7373 tdata->auth_iv.len, tdata->digest_enc.len,
7374 tdata->cipher_iv.len);
7376 retval = create_wireless_algo_auth_cipher_session(
7377 ts_params->valid_devs[0],
7378 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7379 RTE_CRYPTO_AUTH_OP_GENERATE,
7382 tdata->auth_key.data, tdata->auth_key.len,
7383 tdata->auth_iv.len, tdata->digest_enc.len,
7384 tdata->cipher_iv.len);
7388 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7389 if (op_mode == OUT_OF_PLACE)
7390 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7392 /* clear mbuf payload */
7393 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7394 rte_pktmbuf_tailroom(ut_params->ibuf));
7395 if (op_mode == OUT_OF_PLACE) {
7397 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7398 rte_pktmbuf_tailroom(ut_params->obuf));
7401 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7402 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7403 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7404 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7407 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7408 ciphertext_pad_len);
7409 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7410 debug_hexdump(stdout, "ciphertext:", ciphertext,
7413 /* make sure enough space to cover partial digest verify case */
7414 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7415 ciphertext_pad_len);
7416 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7417 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7420 if (op_mode == OUT_OF_PLACE)
7421 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7423 /* Create the operation */
7424 retval = create_wireless_algo_auth_cipher_operation(
7425 tdata->digest_enc.data, tdata->digest_enc.len,
7426 tdata->cipher_iv.data, tdata->cipher_iv.len,
7427 tdata->auth_iv.data, tdata->auth_iv.len,
7428 (tdata->digest_enc.offset == 0 ?
7430 : tdata->digest_enc.offset),
7431 tdata->validCipherLen.len_bits,
7432 tdata->cipher.offset_bits,
7433 tdata->validAuthLen.len_bits,
7434 tdata->auth.offset_bits,
7435 op_mode, 0, verify);
7440 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7442 /* Check if the op failed because the device doesn't */
7443 /* support this particular combination of algorithms */
7444 if (op == NULL && ut_params->op->status ==
7445 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7446 printf("Device doesn't support this mixed combination. "
7448 return TEST_SKIPPED;
7452 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7454 ut_params->obuf = (op_mode == IN_PLACE ?
7455 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7458 if (ut_params->obuf)
7459 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7462 plaintext = ciphertext +
7463 (tdata->cipher.offset_bits >> 3);
7465 debug_hexdump(stdout, "plaintext:", plaintext,
7466 tdata->plaintext.len_bits >> 3);
7467 debug_hexdump(stdout, "plaintext expected:",
7468 tdata->plaintext.data,
7469 tdata->plaintext.len_bits >> 3);
7471 if (ut_params->obuf)
7472 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7475 ciphertext = plaintext;
7477 debug_hexdump(stdout, "ciphertext:", ciphertext,
7479 debug_hexdump(stdout, "ciphertext expected:",
7480 tdata->ciphertext.data,
7481 tdata->ciphertext.len_bits >> 3);
7483 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7484 + (tdata->digest_enc.offset == 0 ?
7485 plaintext_pad_len : tdata->digest_enc.offset);
7487 debug_hexdump(stdout, "digest:", ut_params->digest,
7488 tdata->digest_enc.len);
7489 debug_hexdump(stdout, "digest expected:",
7490 tdata->digest_enc.data,
7491 tdata->digest_enc.len);
7495 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7497 tdata->digest_enc.data,
7498 tdata->digest_enc.len,
7499 "Generated auth tag not as expected");
7502 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7504 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7506 tdata->plaintext.data,
7507 tdata->plaintext.len_bits >> 3,
7508 "Plaintext data not as expected");
7510 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7512 tdata->ciphertext.data,
7513 tdata->validDataLen.len_bits,
7514 "Ciphertext data not as expected");
7518 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7519 "crypto op processing failed");
7525 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7526 uint8_t op_mode, uint8_t verify)
7528 struct crypto_testsuite_params *ts_params = &testsuite_params;
7529 struct crypto_unittest_params *ut_params = &unittest_params;
7533 const uint8_t *plaintext = NULL;
7534 const uint8_t *ciphertext = NULL;
7535 const uint8_t *digest = NULL;
7536 unsigned int plaintext_pad_len;
7537 unsigned int plaintext_len;
7538 unsigned int ciphertext_pad_len;
7539 unsigned int ciphertext_len;
7540 uint8_t buffer[10000];
7541 uint8_t digest_buffer[10000];
7543 struct rte_cryptodev_info dev_info;
7544 struct rte_crypto_op *op;
7546 /* Check if device supports particular algorithms */
7547 if (test_mixed_check_if_unsupported(tdata))
7548 return TEST_SKIPPED;
7549 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7550 return TEST_SKIPPED;
7552 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7554 uint64_t feat_flags = dev_info.feature_flags;
7556 if (op_mode == IN_PLACE) {
7557 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7558 printf("Device doesn't support in-place scatter-gather "
7559 "in both input and output mbufs.\n");
7560 return TEST_SKIPPED;
7563 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7564 printf("Device doesn't support out-of-place scatter-gather "
7565 "in both input and output mbufs.\n");
7566 return TEST_SKIPPED;
7568 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7569 printf("Device doesn't support digest encrypted.\n");
7570 return TEST_SKIPPED;
7574 /* Create the session */
7576 retval = create_wireless_algo_cipher_auth_session(
7577 ts_params->valid_devs[0],
7578 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7579 RTE_CRYPTO_AUTH_OP_VERIFY,
7582 tdata->auth_key.data, tdata->auth_key.len,
7583 tdata->auth_iv.len, tdata->digest_enc.len,
7584 tdata->cipher_iv.len);
7586 retval = create_wireless_algo_auth_cipher_session(
7587 ts_params->valid_devs[0],
7588 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7589 RTE_CRYPTO_AUTH_OP_GENERATE,
7592 tdata->auth_key.data, tdata->auth_key.len,
7593 tdata->auth_iv.len, tdata->digest_enc.len,
7594 tdata->cipher_iv.len);
7598 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7599 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7600 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7601 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7603 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7604 ciphertext_pad_len, 15, 0);
7605 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7606 "Failed to allocate input buffer in mempool");
7608 if (op_mode == OUT_OF_PLACE) {
7609 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7610 plaintext_pad_len, 15, 0);
7611 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7612 "Failed to allocate output buffer in mempool");
7616 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7617 tdata->ciphertext.data);
7618 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7619 ciphertext_len, buffer);
7620 debug_hexdump(stdout, "ciphertext:", ciphertext,
7623 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7624 tdata->plaintext.data);
7625 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7626 plaintext_len, buffer);
7627 debug_hexdump(stdout, "plaintext:", plaintext,
7630 memset(buffer, 0, sizeof(buffer));
7632 /* Create the operation */
7633 retval = create_wireless_algo_auth_cipher_operation(
7634 tdata->digest_enc.data, tdata->digest_enc.len,
7635 tdata->cipher_iv.data, tdata->cipher_iv.len,
7636 tdata->auth_iv.data, tdata->auth_iv.len,
7637 (tdata->digest_enc.offset == 0 ?
7639 : tdata->digest_enc.offset),
7640 tdata->validCipherLen.len_bits,
7641 tdata->cipher.offset_bits,
7642 tdata->validAuthLen.len_bits,
7643 tdata->auth.offset_bits,
7644 op_mode, 1, verify);
7649 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7651 /* Check if the op failed because the device doesn't */
7652 /* support this particular combination of algorithms */
7653 if (op == NULL && ut_params->op->status ==
7654 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7655 printf("Device doesn't support this mixed combination. "
7657 return TEST_SKIPPED;
7661 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7663 ut_params->obuf = (op_mode == IN_PLACE ?
7664 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7667 if (ut_params->obuf)
7668 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7669 plaintext_len, buffer);
7671 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7672 plaintext_len, buffer);
7674 debug_hexdump(stdout, "plaintext:", plaintext,
7675 (tdata->plaintext.len_bits >> 3) -
7676 tdata->digest_enc.len);
7677 debug_hexdump(stdout, "plaintext expected:",
7678 tdata->plaintext.data,
7679 (tdata->plaintext.len_bits >> 3) -
7680 tdata->digest_enc.len);
7682 if (ut_params->obuf)
7683 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7684 ciphertext_len, buffer);
7686 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7687 ciphertext_len, buffer);
7689 debug_hexdump(stdout, "ciphertext:", ciphertext,
7691 debug_hexdump(stdout, "ciphertext expected:",
7692 tdata->ciphertext.data,
7693 tdata->ciphertext.len_bits >> 3);
7695 if (ut_params->obuf)
7696 digest = rte_pktmbuf_read(ut_params->obuf,
7697 (tdata->digest_enc.offset == 0 ?
7699 tdata->digest_enc.offset),
7700 tdata->digest_enc.len, digest_buffer);
7702 digest = rte_pktmbuf_read(ut_params->ibuf,
7703 (tdata->digest_enc.offset == 0 ?
7705 tdata->digest_enc.offset),
7706 tdata->digest_enc.len, digest_buffer);
7708 debug_hexdump(stdout, "digest:", digest,
7709 tdata->digest_enc.len);
7710 debug_hexdump(stdout, "digest expected:",
7711 tdata->digest_enc.data, tdata->digest_enc.len);
7715 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7717 tdata->digest_enc.data,
7718 tdata->digest_enc.len,
7719 "Generated auth tag not as expected");
7722 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7724 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7726 tdata->plaintext.data,
7727 tdata->plaintext.len_bits >> 3,
7728 "Plaintext data not as expected");
7730 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7732 tdata->ciphertext.data,
7733 tdata->validDataLen.len_bits,
7734 "Ciphertext data not as expected");
7738 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7739 "crypto op processing failed");
7744 /** AUTH AES CMAC + CIPHER AES CTR */
7747 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7749 return test_mixed_auth_cipher(
7750 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7754 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7756 return test_mixed_auth_cipher(
7757 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7761 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7763 return test_mixed_auth_cipher_sgl(
7764 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7768 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7770 return test_mixed_auth_cipher_sgl(
7771 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7775 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7777 return test_mixed_auth_cipher(
7778 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7782 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7784 return test_mixed_auth_cipher(
7785 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7789 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7791 return test_mixed_auth_cipher_sgl(
7792 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7796 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7798 return test_mixed_auth_cipher_sgl(
7799 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7802 /** MIXED AUTH + CIPHER */
7805 test_auth_zuc_cipher_snow_test_case_1(void)
7807 return test_mixed_auth_cipher(
7808 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7812 test_verify_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, 1);
7819 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7821 return test_mixed_auth_cipher(
7822 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7826 test_verify_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, 1);
7833 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7835 return test_mixed_auth_cipher(
7836 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7840 test_verify_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, 1);
7847 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7849 return test_mixed_auth_cipher(
7850 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7854 test_verify_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, 1);
7861 test_auth_snow_cipher_zuc_test_case_1(void)
7863 return test_mixed_auth_cipher(
7864 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7868 test_verify_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, 1);
7875 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7877 return test_mixed_auth_cipher(
7878 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7882 test_verify_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, 1);
7889 test_auth_null_cipher_snow_test_case_1(void)
7891 return test_mixed_auth_cipher(
7892 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7896 test_verify_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, 1);
7903 test_auth_null_cipher_zuc_test_case_1(void)
7905 return test_mixed_auth_cipher(
7906 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7910 test_verify_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, 1);
7917 test_auth_snow_cipher_null_test_case_1(void)
7919 return test_mixed_auth_cipher(
7920 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7924 test_verify_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, 1);
7931 test_auth_zuc_cipher_null_test_case_1(void)
7933 return test_mixed_auth_cipher(
7934 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7938 test_verify_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, 1);
7945 test_auth_null_cipher_aes_ctr_test_case_1(void)
7947 return test_mixed_auth_cipher(
7948 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7952 test_verify_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, 1);
7959 test_auth_aes_cmac_cipher_null_test_case_1(void)
7961 return test_mixed_auth_cipher(
7962 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7966 test_verify_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, 1);
7972 /* ***** AEAD algorithm Tests ***** */
7975 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7976 enum rte_crypto_aead_operation op,
7977 const uint8_t *key, const uint8_t key_len,
7978 const uint16_t aad_len, const uint8_t auth_len,
7981 uint8_t aead_key[key_len];
7984 struct crypto_testsuite_params *ts_params = &testsuite_params;
7985 struct crypto_unittest_params *ut_params = &unittest_params;
7987 memcpy(aead_key, key, key_len);
7989 /* Setup AEAD Parameters */
7990 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7991 ut_params->aead_xform.next = NULL;
7992 ut_params->aead_xform.aead.algo = algo;
7993 ut_params->aead_xform.aead.op = op;
7994 ut_params->aead_xform.aead.key.data = aead_key;
7995 ut_params->aead_xform.aead.key.length = key_len;
7996 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7997 ut_params->aead_xform.aead.iv.length = iv_len;
7998 ut_params->aead_xform.aead.digest_length = auth_len;
7999 ut_params->aead_xform.aead.aad_length = aad_len;
8001 debug_hexdump(stdout, "key:", key, key_len);
8003 /* Create Crypto session*/
8004 ut_params->sess = rte_cryptodev_sym_session_create(
8005 ts_params->session_mpool);
8006 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8008 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8009 &ut_params->aead_xform,
8010 ts_params->session_priv_mpool);
8016 create_aead_xform(struct rte_crypto_op *op,
8017 enum rte_crypto_aead_algorithm algo,
8018 enum rte_crypto_aead_operation aead_op,
8019 uint8_t *key, const uint8_t key_len,
8020 const uint8_t aad_len, const uint8_t auth_len,
8023 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8024 "failed to allocate space for crypto transform");
8026 struct rte_crypto_sym_op *sym_op = op->sym;
8028 /* Setup AEAD Parameters */
8029 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8030 sym_op->xform->next = NULL;
8031 sym_op->xform->aead.algo = algo;
8032 sym_op->xform->aead.op = aead_op;
8033 sym_op->xform->aead.key.data = key;
8034 sym_op->xform->aead.key.length = key_len;
8035 sym_op->xform->aead.iv.offset = IV_OFFSET;
8036 sym_op->xform->aead.iv.length = iv_len;
8037 sym_op->xform->aead.digest_length = auth_len;
8038 sym_op->xform->aead.aad_length = aad_len;
8040 debug_hexdump(stdout, "key:", key, key_len);
8046 create_aead_operation(enum rte_crypto_aead_operation op,
8047 const struct aead_test_data *tdata)
8049 struct crypto_testsuite_params *ts_params = &testsuite_params;
8050 struct crypto_unittest_params *ut_params = &unittest_params;
8052 uint8_t *plaintext, *ciphertext;
8053 unsigned int aad_pad_len, plaintext_pad_len;
8055 /* Generate Crypto op data structure */
8056 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8057 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8058 TEST_ASSERT_NOT_NULL(ut_params->op,
8059 "Failed to allocate symmetric crypto operation struct");
8061 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8063 /* Append aad data */
8064 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8065 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8066 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8068 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8069 "no room to append aad");
8071 sym_op->aead.aad.phys_addr =
8072 rte_pktmbuf_iova(ut_params->ibuf);
8073 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8074 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8075 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8078 /* Append IV at the end of the crypto operation*/
8079 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8080 uint8_t *, IV_OFFSET);
8082 /* Copy IV 1 byte after the IV pointer, according to the API */
8083 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8084 debug_hexdump(stdout, "iv:", iv_ptr,
8087 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8088 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8090 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8091 "no room to append aad");
8093 sym_op->aead.aad.phys_addr =
8094 rte_pktmbuf_iova(ut_params->ibuf);
8095 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8096 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8099 /* Append IV at the end of the crypto operation*/
8100 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8101 uint8_t *, IV_OFFSET);
8103 if (tdata->iv.len == 0) {
8104 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8105 debug_hexdump(stdout, "iv:", iv_ptr,
8108 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8109 debug_hexdump(stdout, "iv:", iv_ptr,
8114 /* Append plaintext/ciphertext */
8115 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8116 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8117 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8119 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8121 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8122 debug_hexdump(stdout, "plaintext:", plaintext,
8123 tdata->plaintext.len);
8125 if (ut_params->obuf) {
8126 ciphertext = (uint8_t *)rte_pktmbuf_append(
8128 plaintext_pad_len + aad_pad_len);
8129 TEST_ASSERT_NOT_NULL(ciphertext,
8130 "no room to append ciphertext");
8132 memset(ciphertext + aad_pad_len, 0,
8133 tdata->ciphertext.len);
8136 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8137 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8139 TEST_ASSERT_NOT_NULL(ciphertext,
8140 "no room to append ciphertext");
8142 memcpy(ciphertext, tdata->ciphertext.data,
8143 tdata->ciphertext.len);
8144 debug_hexdump(stdout, "ciphertext:", ciphertext,
8145 tdata->ciphertext.len);
8147 if (ut_params->obuf) {
8148 plaintext = (uint8_t *)rte_pktmbuf_append(
8150 plaintext_pad_len + aad_pad_len);
8151 TEST_ASSERT_NOT_NULL(plaintext,
8152 "no room to append plaintext");
8154 memset(plaintext + aad_pad_len, 0,
8155 tdata->plaintext.len);
8159 /* Append digest data */
8160 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8161 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8162 ut_params->obuf ? ut_params->obuf :
8164 tdata->auth_tag.len);
8165 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8166 "no room to append digest");
8167 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8168 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8169 ut_params->obuf ? ut_params->obuf :
8174 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8175 ut_params->ibuf, tdata->auth_tag.len);
8176 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8177 "no room to append digest");
8178 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8180 plaintext_pad_len + aad_pad_len);
8182 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8183 tdata->auth_tag.len);
8184 debug_hexdump(stdout, "digest:",
8185 sym_op->aead.digest.data,
8186 tdata->auth_tag.len);
8189 sym_op->aead.data.length = tdata->plaintext.len;
8190 sym_op->aead.data.offset = aad_pad_len;
8196 test_authenticated_encryption(const struct aead_test_data *tdata)
8198 struct crypto_testsuite_params *ts_params = &testsuite_params;
8199 struct crypto_unittest_params *ut_params = &unittest_params;
8202 uint8_t *ciphertext, *auth_tag;
8203 uint16_t plaintext_pad_len;
8205 struct rte_cryptodev_info dev_info;
8207 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8208 uint64_t feat_flags = dev_info.feature_flags;
8210 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8211 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8212 printf("Device doesn't support RAW data-path APIs.\n");
8213 return TEST_SKIPPED;
8216 /* Verify the capabilities */
8217 struct rte_cryptodev_sym_capability_idx cap_idx;
8218 const struct rte_cryptodev_symmetric_capability *capability;
8219 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8220 cap_idx.algo.aead = tdata->algo;
8221 capability = rte_cryptodev_sym_capability_get(
8222 ts_params->valid_devs[0], &cap_idx);
8223 if (capability == NULL)
8224 return TEST_SKIPPED;
8225 if (rte_cryptodev_sym_capability_check_aead(
8226 capability, tdata->key.len, tdata->auth_tag.len,
8227 tdata->aad.len, tdata->iv.len))
8228 return TEST_SKIPPED;
8230 /* Create AEAD session */
8231 retval = create_aead_session(ts_params->valid_devs[0],
8233 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8234 tdata->key.data, tdata->key.len,
8235 tdata->aad.len, tdata->auth_tag.len,
8240 if (tdata->aad.len > MBUF_SIZE) {
8241 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8242 /* Populate full size of add data */
8243 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8244 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8246 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8248 /* clear mbuf payload */
8249 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8250 rte_pktmbuf_tailroom(ut_params->ibuf));
8252 /* Create AEAD operation */
8253 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8257 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8259 ut_params->op->sym->m_src = ut_params->ibuf;
8261 /* Process crypto operation */
8262 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8263 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8264 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8265 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8266 ut_params->op, 0, 0, 0, 0);
8268 TEST_ASSERT_NOT_NULL(
8269 process_crypto_request(ts_params->valid_devs[0],
8270 ut_params->op), "failed to process sym crypto op");
8272 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8273 "crypto op processing failed");
8275 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8277 if (ut_params->op->sym->m_dst) {
8278 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8280 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8281 uint8_t *, plaintext_pad_len);
8283 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8285 ut_params->op->sym->cipher.data.offset);
8286 auth_tag = ciphertext + plaintext_pad_len;
8289 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8290 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8293 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8295 tdata->ciphertext.data,
8296 tdata->ciphertext.len,
8297 "Ciphertext data not as expected");
8299 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8301 tdata->auth_tag.data,
8302 tdata->auth_tag.len,
8303 "Generated auth tag not as expected");
8309 #ifdef RTE_LIB_SECURITY
8311 security_proto_supported(enum rte_security_session_action_type action,
8312 enum rte_security_session_protocol proto)
8314 struct crypto_testsuite_params *ts_params = &testsuite_params;
8316 const struct rte_security_capability *capabilities;
8317 const struct rte_security_capability *capability;
8320 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8321 rte_cryptodev_get_sec_ctx(
8322 ts_params->valid_devs[0]);
8325 capabilities = rte_security_capabilities_get(ctx);
8327 if (capabilities == NULL)
8330 while ((capability = &capabilities[i++])->action !=
8331 RTE_SECURITY_ACTION_TYPE_NONE) {
8332 if (capability->action == action &&
8333 capability->protocol == proto)
8340 /* Basic algorithm run function for async inplace mode.
8341 * Creates a session from input parameters and runs one operation
8342 * on input_vec. Checks the output of the crypto operation against
8345 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8346 enum rte_crypto_auth_operation opa,
8347 const uint8_t *input_vec, unsigned int input_vec_len,
8348 const uint8_t *output_vec,
8349 unsigned int output_vec_len,
8350 enum rte_crypto_cipher_algorithm cipher_alg,
8351 const uint8_t *cipher_key, uint32_t cipher_key_len,
8352 enum rte_crypto_auth_algorithm auth_alg,
8353 const uint8_t *auth_key, uint32_t auth_key_len,
8354 uint8_t bearer, enum rte_security_pdcp_domain domain,
8355 uint8_t packet_direction, uint8_t sn_size,
8356 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8358 struct crypto_testsuite_params *ts_params = &testsuite_params;
8359 struct crypto_unittest_params *ut_params = &unittest_params;
8361 int ret = TEST_SUCCESS;
8362 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8363 rte_cryptodev_get_sec_ctx(
8364 ts_params->valid_devs[0]);
8366 /* Verify the capabilities */
8367 struct rte_security_capability_idx sec_cap_idx;
8369 sec_cap_idx.action = ut_params->type;
8370 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8371 sec_cap_idx.pdcp.domain = domain;
8372 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8373 return TEST_SKIPPED;
8375 /* Generate test mbuf data */
8376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8378 /* clear mbuf payload */
8379 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8380 rte_pktmbuf_tailroom(ut_params->ibuf));
8382 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8384 memcpy(plaintext, input_vec, input_vec_len);
8386 /* Out of place support */
8389 * For out-op-place we need to alloc another mbuf
8391 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8392 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8395 /* Setup Cipher Parameters */
8396 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8397 ut_params->cipher_xform.cipher.algo = cipher_alg;
8398 ut_params->cipher_xform.cipher.op = opc;
8399 ut_params->cipher_xform.cipher.key.data = cipher_key;
8400 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8401 ut_params->cipher_xform.cipher.iv.length =
8402 packet_direction ? 4 : 0;
8403 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8405 /* Setup HMAC Parameters if ICV header is required */
8406 if (auth_alg != 0) {
8407 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8408 ut_params->auth_xform.next = NULL;
8409 ut_params->auth_xform.auth.algo = auth_alg;
8410 ut_params->auth_xform.auth.op = opa;
8411 ut_params->auth_xform.auth.key.data = auth_key;
8412 ut_params->auth_xform.auth.key.length = auth_key_len;
8414 ut_params->cipher_xform.next = &ut_params->auth_xform;
8416 ut_params->cipher_xform.next = NULL;
8419 struct rte_security_session_conf sess_conf = {
8420 .action_type = ut_params->type,
8421 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8425 .pkt_dir = packet_direction,
8427 .hfn = packet_direction ? 0 : hfn,
8429 * hfn can be set as pdcp_test_hfn[i]
8430 * if hfn_ovrd is not set. Here, PDCP
8431 * packet direction is just used to
8432 * run half of the cases with session
8433 * HFN and other half with per packet
8436 .hfn_threshold = hfn_threshold,
8437 .hfn_ovrd = packet_direction ? 1 : 0,
8438 .sdap_enabled = sdap,
8440 .crypto_xform = &ut_params->cipher_xform
8443 /* Create security session */
8444 ut_params->sec_session = rte_security_session_create(ctx,
8445 &sess_conf, ts_params->session_mpool,
8446 ts_params->session_priv_mpool);
8448 if (!ut_params->sec_session) {
8449 printf("TestCase %s()-%d line %d failed %s: ",
8450 __func__, i, __LINE__, "Failed to allocate session");
8455 /* Generate crypto op data structure */
8456 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8457 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8458 if (!ut_params->op) {
8459 printf("TestCase %s()-%d line %d failed %s: ",
8460 __func__, i, __LINE__,
8461 "Failed to allocate symmetric crypto operation struct");
8466 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8467 uint32_t *, IV_OFFSET);
8468 *per_pkt_hfn = packet_direction ? hfn : 0;
8470 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8472 /* set crypto operation source mbuf */
8473 ut_params->op->sym->m_src = ut_params->ibuf;
8475 ut_params->op->sym->m_dst = ut_params->obuf;
8477 /* Process crypto operation */
8478 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8480 printf("TestCase %s()-%d line %d failed %s: ",
8481 __func__, i, __LINE__,
8482 "failed to process sym crypto op");
8487 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8488 printf("TestCase %s()-%d line %d failed %s: ",
8489 __func__, i, __LINE__, "crypto op processing failed");
8495 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8498 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8502 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8503 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8504 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8505 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8511 rte_crypto_op_free(ut_params->op);
8512 ut_params->op = NULL;
8514 if (ut_params->sec_session)
8515 rte_security_session_destroy(ctx, ut_params->sec_session);
8516 ut_params->sec_session = NULL;
8518 rte_pktmbuf_free(ut_params->ibuf);
8519 ut_params->ibuf = NULL;
8521 rte_pktmbuf_free(ut_params->obuf);
8522 ut_params->obuf = NULL;
8529 test_pdcp_proto_SGL(int i, int oop,
8530 enum rte_crypto_cipher_operation opc,
8531 enum rte_crypto_auth_operation opa,
8533 unsigned int input_vec_len,
8534 uint8_t *output_vec,
8535 unsigned int output_vec_len,
8537 uint32_t fragsz_oop)
8539 struct crypto_testsuite_params *ts_params = &testsuite_params;
8540 struct crypto_unittest_params *ut_params = &unittest_params;
8542 struct rte_mbuf *buf, *buf_oop = NULL;
8543 int ret = TEST_SUCCESS;
8547 unsigned int trn_data = 0;
8548 struct rte_cryptodev_info dev_info;
8549 uint64_t feat_flags;
8550 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8551 rte_cryptodev_get_sec_ctx(
8552 ts_params->valid_devs[0]);
8553 struct rte_mbuf *temp_mbuf;
8555 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8556 feat_flags = dev_info.feature_flags;
8558 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8559 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8560 printf("Device does not support RAW data-path APIs.\n");
8563 /* Verify the capabilities */
8564 struct rte_security_capability_idx sec_cap_idx;
8566 sec_cap_idx.action = ut_params->type;
8567 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8568 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8569 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8570 return TEST_SKIPPED;
8572 if (fragsz > input_vec_len)
8573 fragsz = input_vec_len;
8575 uint16_t plaintext_len = fragsz;
8576 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8578 if (fragsz_oop > output_vec_len)
8579 frag_size_oop = output_vec_len;
8582 if (input_vec_len % fragsz != 0) {
8583 if (input_vec_len / fragsz + 1 > 16)
8585 } else if (input_vec_len / fragsz > 16)
8588 /* Out of place support */
8591 * For out-op-place we need to alloc another mbuf
8593 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8594 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8595 buf_oop = ut_params->obuf;
8598 /* Generate test mbuf data */
8599 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8601 /* clear mbuf payload */
8602 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8603 rte_pktmbuf_tailroom(ut_params->ibuf));
8605 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8607 memcpy(plaintext, input_vec, plaintext_len);
8608 trn_data += plaintext_len;
8610 buf = ut_params->ibuf;
8613 * Loop until no more fragments
8616 while (trn_data < input_vec_len) {
8618 to_trn = (input_vec_len - trn_data < fragsz) ?
8619 (input_vec_len - trn_data) : fragsz;
8621 to_trn_tbl[ecx++] = to_trn;
8623 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8626 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8627 rte_pktmbuf_tailroom(buf));
8630 if (oop && !fragsz_oop) {
8632 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8633 buf_oop = buf_oop->next;
8634 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8635 0, rte_pktmbuf_tailroom(buf_oop));
8636 rte_pktmbuf_append(buf_oop, to_trn);
8639 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8642 memcpy(plaintext, input_vec + trn_data, to_trn);
8646 ut_params->ibuf->nb_segs = segs;
8649 if (fragsz_oop && oop) {
8653 trn_data = frag_size_oop;
8654 while (trn_data < output_vec_len) {
8657 (output_vec_len - trn_data <
8659 (output_vec_len - trn_data) :
8662 to_trn_tbl[ecx++] = to_trn;
8665 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8666 buf_oop = buf_oop->next;
8667 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8668 0, rte_pktmbuf_tailroom(buf_oop));
8669 rte_pktmbuf_append(buf_oop, to_trn);
8673 ut_params->obuf->nb_segs = segs;
8676 /* Setup Cipher Parameters */
8677 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8678 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8679 ut_params->cipher_xform.cipher.op = opc;
8680 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8681 ut_params->cipher_xform.cipher.key.length =
8682 pdcp_test_params[i].cipher_key_len;
8683 ut_params->cipher_xform.cipher.iv.length = 0;
8685 /* Setup HMAC Parameters if ICV header is required */
8686 if (pdcp_test_params[i].auth_alg != 0) {
8687 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8688 ut_params->auth_xform.next = NULL;
8689 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8690 ut_params->auth_xform.auth.op = opa;
8691 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8692 ut_params->auth_xform.auth.key.length =
8693 pdcp_test_params[i].auth_key_len;
8695 ut_params->cipher_xform.next = &ut_params->auth_xform;
8697 ut_params->cipher_xform.next = NULL;
8700 struct rte_security_session_conf sess_conf = {
8701 .action_type = ut_params->type,
8702 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8704 .bearer = pdcp_test_bearer[i],
8705 .domain = pdcp_test_params[i].domain,
8706 .pkt_dir = pdcp_test_packet_direction[i],
8707 .sn_size = pdcp_test_data_sn_size[i],
8708 .hfn = pdcp_test_hfn[i],
8709 .hfn_threshold = pdcp_test_hfn_threshold[i],
8712 .crypto_xform = &ut_params->cipher_xform
8715 /* Create security session */
8716 ut_params->sec_session = rte_security_session_create(ctx,
8717 &sess_conf, ts_params->session_mpool,
8718 ts_params->session_priv_mpool);
8720 if (!ut_params->sec_session) {
8721 printf("TestCase %s()-%d line %d failed %s: ",
8722 __func__, i, __LINE__, "Failed to allocate session");
8727 /* Generate crypto op data structure */
8728 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8729 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8730 if (!ut_params->op) {
8731 printf("TestCase %s()-%d line %d failed %s: ",
8732 __func__, i, __LINE__,
8733 "Failed to allocate symmetric crypto operation struct");
8738 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8740 /* set crypto operation source mbuf */
8741 ut_params->op->sym->m_src = ut_params->ibuf;
8743 ut_params->op->sym->m_dst = ut_params->obuf;
8745 /* Process crypto operation */
8746 temp_mbuf = ut_params->op->sym->m_src;
8747 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8748 /* filling lengths */
8750 ut_params->op->sym->cipher.data.length
8751 += temp_mbuf->pkt_len;
8752 ut_params->op->sym->auth.data.length
8753 += temp_mbuf->pkt_len;
8754 temp_mbuf = temp_mbuf->next;
8756 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8757 ut_params->op, 1, 1, 0, 0);
8759 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8762 if (ut_params->op == NULL) {
8763 printf("TestCase %s()-%d line %d failed %s: ",
8764 __func__, i, __LINE__,
8765 "failed to process sym crypto op");
8770 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8771 printf("TestCase %s()-%d line %d failed %s: ",
8772 __func__, i, __LINE__, "crypto op processing failed");
8778 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8781 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8785 fragsz = frag_size_oop;
8786 if (memcmp(ciphertext, output_vec, fragsz)) {
8787 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8788 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8789 rte_hexdump(stdout, "reference", output_vec, fragsz);
8794 buf = ut_params->op->sym->m_src->next;
8796 buf = ut_params->op->sym->m_dst->next;
8798 unsigned int off = fragsz;
8802 ciphertext = rte_pktmbuf_mtod(buf,
8804 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8805 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8806 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8807 rte_hexdump(stdout, "reference", output_vec + off,
8812 off += to_trn_tbl[ecx++];
8816 rte_crypto_op_free(ut_params->op);
8817 ut_params->op = NULL;
8819 if (ut_params->sec_session)
8820 rte_security_session_destroy(ctx, ut_params->sec_session);
8821 ut_params->sec_session = NULL;
8823 rte_pktmbuf_free(ut_params->ibuf);
8824 ut_params->ibuf = NULL;
8826 rte_pktmbuf_free(ut_params->obuf);
8827 ut_params->obuf = NULL;
8834 test_pdcp_proto_cplane_encap(int i)
8836 return test_pdcp_proto(
8837 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8838 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8839 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8840 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8841 pdcp_test_params[i].cipher_key_len,
8842 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8843 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8844 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8845 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8846 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8850 test_pdcp_proto_uplane_encap(int i)
8852 return test_pdcp_proto(
8853 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8854 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8855 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8856 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8857 pdcp_test_params[i].cipher_key_len,
8858 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8859 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8860 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8861 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8862 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8866 test_pdcp_proto_uplane_encap_with_int(int i)
8868 return test_pdcp_proto(
8869 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8870 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8871 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8872 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8873 pdcp_test_params[i].cipher_key_len,
8874 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8875 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8876 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8877 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8878 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8882 test_pdcp_proto_cplane_decap(int i)
8884 return test_pdcp_proto(
8885 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8886 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8887 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8888 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8889 pdcp_test_params[i].cipher_key_len,
8890 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8891 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8892 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8893 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8894 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8898 test_pdcp_proto_uplane_decap(int i)
8900 return test_pdcp_proto(
8901 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8902 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8903 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8904 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8905 pdcp_test_params[i].cipher_key_len,
8906 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8907 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8908 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8909 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8910 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8914 test_pdcp_proto_uplane_decap_with_int(int i)
8916 return test_pdcp_proto(
8917 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8918 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8919 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8920 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8921 pdcp_test_params[i].cipher_key_len,
8922 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8923 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8924 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8925 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8926 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8930 test_PDCP_PROTO_SGL_in_place_32B(void)
8932 /* i can be used for running any PDCP case
8933 * In this case it is uplane 12-bit AES-SNOW DL encap
8935 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8936 return test_pdcp_proto_SGL(i, IN_PLACE,
8937 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8938 RTE_CRYPTO_AUTH_OP_GENERATE,
8939 pdcp_test_data_in[i],
8940 pdcp_test_data_in_len[i],
8941 pdcp_test_data_out[i],
8942 pdcp_test_data_in_len[i]+4,
8946 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8948 /* i can be used for running any PDCP case
8949 * In this case it is uplane 18-bit NULL-NULL DL encap
8951 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8952 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8953 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8954 RTE_CRYPTO_AUTH_OP_GENERATE,
8955 pdcp_test_data_in[i],
8956 pdcp_test_data_in_len[i],
8957 pdcp_test_data_out[i],
8958 pdcp_test_data_in_len[i]+4,
8962 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8964 /* i can be used for running any PDCP case
8965 * In this case it is uplane 18-bit AES DL encap
8967 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8969 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8970 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8971 RTE_CRYPTO_AUTH_OP_GENERATE,
8972 pdcp_test_data_in[i],
8973 pdcp_test_data_in_len[i],
8974 pdcp_test_data_out[i],
8975 pdcp_test_data_in_len[i],
8979 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8981 /* i can be used for running any PDCP case
8982 * In this case it is cplane 12-bit AES-ZUC DL encap
8984 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8985 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8986 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8987 RTE_CRYPTO_AUTH_OP_GENERATE,
8988 pdcp_test_data_in[i],
8989 pdcp_test_data_in_len[i],
8990 pdcp_test_data_out[i],
8991 pdcp_test_data_in_len[i]+4,
8996 test_PDCP_SDAP_PROTO_encap_all(void)
8998 int i = 0, size = 0;
8999 int err, all_err = TEST_SUCCESS;
9000 const struct pdcp_sdap_test *cur_test;
9002 size = RTE_DIM(list_pdcp_sdap_tests);
9004 for (i = 0; i < size; i++) {
9005 cur_test = &list_pdcp_sdap_tests[i];
9006 err = test_pdcp_proto(
9007 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9008 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9009 cur_test->in_len, cur_test->data_out,
9010 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9011 cur_test->param.cipher_alg, cur_test->cipher_key,
9012 cur_test->param.cipher_key_len,
9013 cur_test->param.auth_alg,
9014 cur_test->auth_key, cur_test->param.auth_key_len,
9015 cur_test->bearer, cur_test->param.domain,
9016 cur_test->packet_direction, cur_test->sn_size,
9018 cur_test->hfn_threshold, SDAP_ENABLED);
9020 printf("\t%d) %s: Encapsulation failed\n",
9022 cur_test->param.name);
9025 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9026 cur_test->param.name);
9032 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9034 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9038 test_PDCP_PROTO_short_mac(void)
9040 int i = 0, size = 0;
9041 int err, all_err = TEST_SUCCESS;
9042 const struct pdcp_short_mac_test *cur_test;
9044 size = RTE_DIM(list_pdcp_smac_tests);
9046 for (i = 0; i < size; i++) {
9047 cur_test = &list_pdcp_smac_tests[i];
9048 err = test_pdcp_proto(
9049 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9050 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9051 cur_test->in_len, cur_test->data_out,
9052 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9053 RTE_CRYPTO_CIPHER_NULL, NULL,
9054 0, cur_test->param.auth_alg,
9055 cur_test->auth_key, cur_test->param.auth_key_len,
9056 0, cur_test->param.domain, 0, 0,
9059 printf("\t%d) %s: Short MAC test failed\n",
9061 cur_test->param.name);
9064 printf("\t%d) %s: Short MAC test PASS\n",
9066 cur_test->param.name);
9067 rte_hexdump(stdout, "MAC I",
9068 cur_test->data_out + cur_test->in_len + 2,
9075 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9077 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9082 test_PDCP_SDAP_PROTO_decap_all(void)
9084 int i = 0, size = 0;
9085 int err, all_err = TEST_SUCCESS;
9086 const struct pdcp_sdap_test *cur_test;
9088 size = RTE_DIM(list_pdcp_sdap_tests);
9090 for (i = 0; i < size; i++) {
9091 cur_test = &list_pdcp_sdap_tests[i];
9092 err = test_pdcp_proto(
9093 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9094 RTE_CRYPTO_AUTH_OP_VERIFY,
9096 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9097 cur_test->data_in, cur_test->in_len,
9098 cur_test->param.cipher_alg,
9099 cur_test->cipher_key, cur_test->param.cipher_key_len,
9100 cur_test->param.auth_alg, cur_test->auth_key,
9101 cur_test->param.auth_key_len, cur_test->bearer,
9102 cur_test->param.domain, cur_test->packet_direction,
9103 cur_test->sn_size, cur_test->hfn,
9104 cur_test->hfn_threshold, SDAP_ENABLED);
9106 printf("\t%d) %s: Decapsulation failed\n",
9108 cur_test->param.name);
9111 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9112 cur_test->param.name);
9118 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9120 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9124 test_ipsec_proto_process(const struct ipsec_test_data td[],
9125 struct ipsec_test_data res_d[],
9128 const struct ipsec_test_flags *flags)
9130 uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
9132 uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
9134 struct crypto_testsuite_params *ts_params = &testsuite_params;
9135 struct crypto_unittest_params *ut_params = &unittest_params;
9136 struct rte_security_capability_idx sec_cap_idx;
9137 const struct rte_security_capability *sec_cap;
9138 struct rte_security_ipsec_xform ipsec_xform;
9139 uint8_t dev_id = ts_params->valid_devs[0];
9140 enum rte_security_ipsec_sa_direction dir;
9141 struct ipsec_test_data *res_d_tmp = NULL;
9142 uint32_t src = RTE_IPV4(192, 168, 1, 0);
9143 uint32_t dst = RTE_IPV4(192, 168, 1, 1);
9144 int salt_len, i, ret = TEST_SUCCESS;
9145 struct rte_security_ctx *ctx;
9146 uint8_t *input_text;
9149 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9150 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9152 /* Use first test data to create session */
9154 /* Copy IPsec xform */
9155 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9157 dir = ipsec_xform.direction;
9158 verify = flags->tunnel_hdr_verify;
9160 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9161 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9163 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9167 if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
9168 if (td->ipsec_xform.tunnel.type ==
9169 RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
9170 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
9172 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
9175 if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
9176 ipsec_xform.tunnel.ipv4.df = 0;
9178 if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
9179 ipsec_xform.tunnel.ipv4.df = 1;
9182 memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
9184 memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
9189 ctx = rte_cryptodev_get_sec_ctx(dev_id);
9191 sec_cap_idx.action = ut_params->type;
9192 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9193 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9194 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9195 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9197 if (flags->udp_encap)
9198 ipsec_xform.options.udp_encap = 1;
9200 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9201 if (sec_cap == NULL)
9202 return TEST_SKIPPED;
9204 /* Copy cipher session parameters */
9206 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9207 sizeof(ut_params->aead_xform));
9208 ut_params->aead_xform.aead.key.data = td[0].key.data;
9209 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9211 /* Verify crypto capabilities */
9212 if (test_ipsec_crypto_caps_aead_verify(
9214 &ut_params->aead_xform) != 0) {
9216 RTE_LOG(INFO, USER1,
9217 "Crypto capabilities not supported\n");
9218 return TEST_SKIPPED;
9221 memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
9222 sizeof(ut_params->cipher_xform));
9223 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
9224 sizeof(ut_params->auth_xform));
9225 ut_params->cipher_xform.cipher.key.data = td[0].key.data;
9226 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9227 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
9229 /* Verify crypto capabilities */
9231 if (test_ipsec_crypto_caps_cipher_verify(
9233 &ut_params->cipher_xform) != 0) {
9235 RTE_LOG(INFO, USER1,
9236 "Cipher crypto capabilities not supported\n");
9237 return TEST_SKIPPED;
9240 if (test_ipsec_crypto_caps_auth_verify(
9242 &ut_params->auth_xform) != 0) {
9244 RTE_LOG(INFO, USER1,
9245 "Auth crypto capabilities not supported\n");
9246 return TEST_SKIPPED;
9250 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9251 return TEST_SKIPPED;
9253 struct rte_security_session_conf sess_conf = {
9254 .action_type = ut_params->type,
9255 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9259 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9260 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9261 sess_conf.ipsec = ipsec_xform;
9262 sess_conf.crypto_xform = &ut_params->aead_xform;
9264 sess_conf.ipsec = ipsec_xform;
9265 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
9266 sess_conf.crypto_xform = &ut_params->cipher_xform;
9267 ut_params->cipher_xform.next = &ut_params->auth_xform;
9269 sess_conf.crypto_xform = &ut_params->auth_xform;
9270 ut_params->auth_xform.next = &ut_params->cipher_xform;
9274 /* Create security session */
9275 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9276 ts_params->session_mpool,
9277 ts_params->session_priv_mpool);
9279 if (ut_params->sec_session == NULL)
9280 return TEST_SKIPPED;
9282 for (i = 0; i < nb_td; i++) {
9283 /* Setup source mbuf payload */
9284 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9285 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9286 rte_pktmbuf_tailroom(ut_params->ibuf));
9288 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9289 td[i].input_text.len);
9291 memcpy(input_text, td[i].input_text.data,
9292 td[i].input_text.len);
9294 if (test_ipsec_pkt_update(input_text, flags))
9297 /* Generate crypto op data structure */
9298 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9299 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9300 if (!ut_params->op) {
9301 printf("TestCase %s line %d: %s\n",
9303 "failed to allocate crypto op");
9305 goto crypto_op_free;
9308 /* Attach session to operation */
9309 rte_security_attach_session(ut_params->op,
9310 ut_params->sec_session);
9312 /* Set crypto operation mbufs */
9313 ut_params->op->sym->m_src = ut_params->ibuf;
9314 ut_params->op->sym->m_dst = NULL;
9316 /* Copy IV in crypto operation when IV generation is disabled */
9317 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9318 ipsec_xform.options.iv_gen_disable == 1) {
9319 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9325 len = td[i].xform.aead.aead.iv.length;
9327 len = td[i].xform.chain.cipher.cipher.iv.length;
9329 memcpy(iv, td[i].iv.data, len);
9332 /* Process crypto operation */
9333 process_crypto_request(dev_id, ut_params->op);
9335 ret = test_ipsec_status_check(ut_params->op, flags, dir, i + 1);
9336 if (ret != TEST_SUCCESS)
9337 goto crypto_op_free;
9340 res_d_tmp = &res_d[i];
9342 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9343 res_d_tmp, silent, flags);
9344 if (ret != TEST_SUCCESS)
9345 goto crypto_op_free;
9347 ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
9349 if (ret != TEST_SUCCESS)
9350 goto crypto_op_free;
9352 rte_crypto_op_free(ut_params->op);
9353 ut_params->op = NULL;
9355 rte_pktmbuf_free(ut_params->ibuf);
9356 ut_params->ibuf = NULL;
9360 rte_crypto_op_free(ut_params->op);
9361 ut_params->op = NULL;
9363 rte_pktmbuf_free(ut_params->ibuf);
9364 ut_params->ibuf = NULL;
9366 if (ut_params->sec_session)
9367 rte_security_session_destroy(ctx, ut_params->sec_session);
9368 ut_params->sec_session = NULL;
9374 test_ipsec_proto_known_vec(const void *test_data)
9376 struct ipsec_test_data td_outb;
9377 struct ipsec_test_flags flags;
9379 memset(&flags, 0, sizeof(flags));
9381 memcpy(&td_outb, test_data, sizeof(td_outb));
9384 td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL) {
9385 /* Disable IV gen to be able to test with known vectors */
9386 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9389 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9393 test_ipsec_proto_known_vec_inb(const void *test_data)
9395 const struct ipsec_test_data *td = test_data;
9396 struct ipsec_test_flags flags;
9397 struct ipsec_test_data td_inb;
9399 memset(&flags, 0, sizeof(flags));
9401 if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
9402 test_ipsec_td_in_from_out(td, &td_inb);
9404 memcpy(&td_inb, td, sizeof(td_inb));
9406 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9410 test_ipsec_proto_known_vec_fragmented(const void *test_data)
9412 struct ipsec_test_data td_outb;
9413 struct ipsec_test_flags flags;
9415 memset(&flags, 0, sizeof(flags));
9416 flags.fragment = true;
9418 memcpy(&td_outb, test_data, sizeof(td_outb));
9420 /* Disable IV gen to be able to test with known vectors */
9421 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9423 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9427 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9429 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9430 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9431 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9434 if (flags->iv_gen ||
9435 flags->sa_expiry_pkts_soft ||
9436 flags->sa_expiry_pkts_hard)
9437 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9439 for (i = 0; i < RTE_DIM(alg_list); i++) {
9440 test_ipsec_td_prepare(alg_list[i].param1,
9446 if (!td_outb->aead) {
9447 enum rte_crypto_cipher_algorithm cipher_alg;
9448 enum rte_crypto_auth_algorithm auth_alg;
9450 cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
9451 auth_alg = td_outb->xform.chain.auth.auth.algo;
9453 /* ICV is not applicable for NULL auth */
9454 if (flags->icv_corrupt &&
9455 auth_alg == RTE_CRYPTO_AUTH_NULL)
9458 /* IV is not applicable for NULL cipher */
9459 if (flags->iv_gen &&
9460 cipher_alg == RTE_CRYPTO_CIPHER_NULL)
9464 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9466 if (ret == TEST_SKIPPED)
9469 if (ret == TEST_FAILED)
9472 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9474 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9476 if (ret == TEST_SKIPPED)
9479 if (ret == TEST_FAILED)
9482 if (flags->display_alg)
9483 test_ipsec_display_alg(alg_list[i].param1,
9484 alg_list[i].param2);
9490 return TEST_SUCCESS;
9492 return TEST_SKIPPED;
9496 test_ipsec_proto_display_list(const void *data __rte_unused)
9498 struct ipsec_test_flags flags;
9500 memset(&flags, 0, sizeof(flags));
9502 flags.display_alg = true;
9504 return test_ipsec_proto_all(&flags);
9508 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9510 struct ipsec_test_flags flags;
9512 memset(&flags, 0, sizeof(flags));
9514 flags.iv_gen = true;
9516 return test_ipsec_proto_all(&flags);
9520 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9522 struct ipsec_test_flags flags;
9524 memset(&flags, 0, sizeof(flags));
9526 flags.sa_expiry_pkts_soft = true;
9528 return test_ipsec_proto_all(&flags);
9532 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9534 struct ipsec_test_flags flags;
9536 memset(&flags, 0, sizeof(flags));
9538 flags.sa_expiry_pkts_hard = true;
9540 return test_ipsec_proto_all(&flags);
9544 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9546 struct ipsec_test_flags flags;
9548 memset(&flags, 0, sizeof(flags));
9550 flags.icv_corrupt = true;
9552 return test_ipsec_proto_all(&flags);
9556 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9558 struct ipsec_test_flags flags;
9560 memset(&flags, 0, sizeof(flags));
9562 flags.udp_encap = true;
9564 return test_ipsec_proto_all(&flags);
9568 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9570 struct ipsec_test_flags flags;
9572 memset(&flags, 0, sizeof(flags));
9574 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9576 return test_ipsec_proto_all(&flags);
9580 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9582 struct ipsec_test_flags flags;
9584 memset(&flags, 0, sizeof(flags));
9586 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9588 return test_ipsec_proto_all(&flags);
9592 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9594 struct ipsec_test_flags flags;
9596 memset(&flags, 0, sizeof(flags));
9598 flags.udp_encap = true;
9599 flags.udp_ports_verify = true;
9601 return test_ipsec_proto_all(&flags);
9605 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9607 struct ipsec_test_flags flags;
9609 memset(&flags, 0, sizeof(flags));
9611 flags.ip_csum = true;
9613 return test_ipsec_proto_all(&flags);
9617 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9619 struct ipsec_test_flags flags;
9621 memset(&flags, 0, sizeof(flags));
9623 flags.l4_csum = true;
9625 return test_ipsec_proto_all(&flags);
9629 test_ipsec_proto_tunnel_v4_in_v4(const void *data __rte_unused)
9631 struct ipsec_test_flags flags;
9633 memset(&flags, 0, sizeof(flags));
9636 flags.tunnel_ipv6 = false;
9638 return test_ipsec_proto_all(&flags);
9642 test_ipsec_proto_tunnel_v6_in_v6(const void *data __rte_unused)
9644 struct ipsec_test_flags flags;
9646 memset(&flags, 0, sizeof(flags));
9649 flags.tunnel_ipv6 = true;
9651 return test_ipsec_proto_all(&flags);
9655 test_ipsec_proto_tunnel_v4_in_v6(const void *data __rte_unused)
9657 struct ipsec_test_flags flags;
9659 memset(&flags, 0, sizeof(flags));
9662 flags.tunnel_ipv6 = true;
9664 return test_ipsec_proto_all(&flags);
9668 test_ipsec_proto_tunnel_v6_in_v4(const void *data __rte_unused)
9670 struct ipsec_test_flags flags;
9672 memset(&flags, 0, sizeof(flags));
9675 flags.tunnel_ipv6 = false;
9677 return test_ipsec_proto_all(&flags);
9681 test_ipsec_proto_transport_v4(const void *data __rte_unused)
9683 struct ipsec_test_flags flags;
9685 memset(&flags, 0, sizeof(flags));
9688 flags.transport = true;
9690 return test_ipsec_proto_all(&flags);
9694 test_ipsec_proto_stats(const void *data __rte_unused)
9696 struct ipsec_test_flags flags;
9698 memset(&flags, 0, sizeof(flags));
9700 flags.stats_success = true;
9702 return test_ipsec_proto_all(&flags);
9706 test_ipsec_proto_pkt_fragment(const void *data __rte_unused)
9708 struct ipsec_test_flags flags;
9710 memset(&flags, 0, sizeof(flags));
9712 flags.fragment = true;
9714 return test_ipsec_proto_all(&flags);
9719 test_ipsec_proto_copy_df_inner_0(const void *data __rte_unused)
9721 struct ipsec_test_flags flags;
9723 memset(&flags, 0, sizeof(flags));
9725 flags.df = TEST_IPSEC_COPY_DF_INNER_0;
9727 return test_ipsec_proto_all(&flags);
9731 test_ipsec_proto_copy_df_inner_1(const void *data __rte_unused)
9733 struct ipsec_test_flags flags;
9735 memset(&flags, 0, sizeof(flags));
9737 flags.df = TEST_IPSEC_COPY_DF_INNER_1;
9739 return test_ipsec_proto_all(&flags);
9743 test_ipsec_proto_set_df_0_inner_1(const void *data __rte_unused)
9745 struct ipsec_test_flags flags;
9747 memset(&flags, 0, sizeof(flags));
9749 flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
9751 return test_ipsec_proto_all(&flags);
9755 test_ipsec_proto_set_df_1_inner_0(const void *data __rte_unused)
9757 struct ipsec_test_flags flags;
9759 memset(&flags, 0, sizeof(flags));
9761 flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
9763 return test_ipsec_proto_all(&flags);
9767 test_PDCP_PROTO_all(void)
9769 struct crypto_testsuite_params *ts_params = &testsuite_params;
9770 struct crypto_unittest_params *ut_params = &unittest_params;
9771 struct rte_cryptodev_info dev_info;
9774 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9775 uint64_t feat_flags = dev_info.feature_flags;
9777 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9778 return TEST_SKIPPED;
9780 /* Set action type */
9781 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9782 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9785 if (security_proto_supported(ut_params->type,
9786 RTE_SECURITY_PROTOCOL_PDCP) < 0)
9787 return TEST_SKIPPED;
9789 status = test_PDCP_PROTO_cplane_encap_all();
9790 status += test_PDCP_PROTO_cplane_decap_all();
9791 status += test_PDCP_PROTO_uplane_encap_all();
9792 status += test_PDCP_PROTO_uplane_decap_all();
9793 status += test_PDCP_PROTO_SGL_in_place_32B();
9794 status += test_PDCP_PROTO_SGL_oop_32B_128B();
9795 status += test_PDCP_PROTO_SGL_oop_32B_40B();
9796 status += test_PDCP_PROTO_SGL_oop_128B_32B();
9797 status += test_PDCP_SDAP_PROTO_encap_all();
9798 status += test_PDCP_SDAP_PROTO_decap_all();
9799 status += test_PDCP_PROTO_short_mac();
9804 return TEST_SUCCESS;
9808 test_docsis_proto_uplink(const void *data)
9810 const struct docsis_test_data *d_td = data;
9811 struct crypto_testsuite_params *ts_params = &testsuite_params;
9812 struct crypto_unittest_params *ut_params = &unittest_params;
9813 uint8_t *plaintext = NULL;
9814 uint8_t *ciphertext = NULL;
9816 int32_t cipher_len, crc_len;
9817 uint32_t crc_data_len;
9818 int ret = TEST_SUCCESS;
9820 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9821 rte_cryptodev_get_sec_ctx(
9822 ts_params->valid_devs[0]);
9824 /* Verify the capabilities */
9825 struct rte_security_capability_idx sec_cap_idx;
9826 const struct rte_security_capability *sec_cap;
9827 const struct rte_cryptodev_capabilities *crypto_cap;
9828 const struct rte_cryptodev_symmetric_capability *sym_cap;
9831 /* Set action type */
9832 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9833 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9836 if (security_proto_supported(ut_params->type,
9837 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9838 return TEST_SKIPPED;
9840 sec_cap_idx.action = ut_params->type;
9841 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9842 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9844 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9845 if (sec_cap == NULL)
9846 return TEST_SKIPPED;
9848 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9849 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9850 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9851 crypto_cap->sym.xform_type ==
9852 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9853 crypto_cap->sym.cipher.algo ==
9854 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9855 sym_cap = &crypto_cap->sym;
9856 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9863 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9864 return TEST_SKIPPED;
9866 /* Setup source mbuf payload */
9867 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9868 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9869 rte_pktmbuf_tailroom(ut_params->ibuf));
9871 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9872 d_td->ciphertext.len);
9874 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
9876 /* Setup cipher session parameters */
9877 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9878 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9879 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
9880 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9881 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9882 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9883 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9884 ut_params->cipher_xform.next = NULL;
9886 /* Setup DOCSIS session parameters */
9887 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9889 struct rte_security_session_conf sess_conf = {
9890 .action_type = ut_params->type,
9891 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9892 .docsis = ut_params->docsis_xform,
9893 .crypto_xform = &ut_params->cipher_xform,
9896 /* Create security session */
9897 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9898 ts_params->session_mpool,
9899 ts_params->session_priv_mpool);
9901 if (!ut_params->sec_session) {
9902 printf("Test function %s line %u: failed to allocate session\n",
9903 __func__, __LINE__);
9908 /* Generate crypto op data structure */
9909 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9910 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9911 if (!ut_params->op) {
9912 printf("Test function %s line %u: failed to allocate symmetric "
9913 "crypto operation\n", __func__, __LINE__);
9918 /* Setup CRC operation parameters */
9919 crc_len = d_td->ciphertext.no_crc == false ?
9920 (d_td->ciphertext.len -
9921 d_td->ciphertext.crc_offset -
9922 RTE_ETHER_CRC_LEN) :
9924 crc_len = crc_len > 0 ? crc_len : 0;
9925 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9926 ut_params->op->sym->auth.data.length = crc_len;
9927 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9929 /* Setup cipher operation parameters */
9930 cipher_len = d_td->ciphertext.no_cipher == false ?
9931 (d_td->ciphertext.len -
9932 d_td->ciphertext.cipher_offset) :
9934 cipher_len = cipher_len > 0 ? cipher_len : 0;
9935 ut_params->op->sym->cipher.data.length = cipher_len;
9936 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9938 /* Setup cipher IV */
9939 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9940 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9942 /* Attach session to operation */
9943 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9945 /* Set crypto operation mbufs */
9946 ut_params->op->sym->m_src = ut_params->ibuf;
9947 ut_params->op->sym->m_dst = NULL;
9949 /* Process crypto operation */
9950 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9952 printf("Test function %s line %u: failed to process security "
9953 "crypto op\n", __func__, __LINE__);
9958 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9959 printf("Test function %s line %u: failed to process crypto op\n",
9960 __func__, __LINE__);
9965 /* Validate plaintext */
9966 plaintext = ciphertext;
9968 if (memcmp(plaintext, d_td->plaintext.data,
9969 d_td->plaintext.len - crc_data_len)) {
9970 printf("Test function %s line %u: plaintext not as expected\n",
9971 __func__, __LINE__);
9972 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9973 d_td->plaintext.len);
9974 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9980 rte_crypto_op_free(ut_params->op);
9981 ut_params->op = NULL;
9983 if (ut_params->sec_session)
9984 rte_security_session_destroy(ctx, ut_params->sec_session);
9985 ut_params->sec_session = NULL;
9987 rte_pktmbuf_free(ut_params->ibuf);
9988 ut_params->ibuf = NULL;
9994 test_docsis_proto_downlink(const void *data)
9996 const struct docsis_test_data *d_td = data;
9997 struct crypto_testsuite_params *ts_params = &testsuite_params;
9998 struct crypto_unittest_params *ut_params = &unittest_params;
9999 uint8_t *plaintext = NULL;
10000 uint8_t *ciphertext = NULL;
10002 int32_t cipher_len, crc_len;
10003 int ret = TEST_SUCCESS;
10005 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
10006 rte_cryptodev_get_sec_ctx(
10007 ts_params->valid_devs[0]);
10009 /* Verify the capabilities */
10010 struct rte_security_capability_idx sec_cap_idx;
10011 const struct rte_security_capability *sec_cap;
10012 const struct rte_cryptodev_capabilities *crypto_cap;
10013 const struct rte_cryptodev_symmetric_capability *sym_cap;
10016 /* Set action type */
10017 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10018 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10021 if (security_proto_supported(ut_params->type,
10022 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
10023 return TEST_SKIPPED;
10025 sec_cap_idx.action = ut_params->type;
10026 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
10027 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10029 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10030 if (sec_cap == NULL)
10031 return TEST_SKIPPED;
10033 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
10034 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
10035 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
10036 crypto_cap->sym.xform_type ==
10037 RTE_CRYPTO_SYM_XFORM_CIPHER &&
10038 crypto_cap->sym.cipher.algo ==
10039 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
10040 sym_cap = &crypto_cap->sym;
10041 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10043 d_td->iv.len) == 0)
10048 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10049 return TEST_SKIPPED;
10051 /* Setup source mbuf payload */
10052 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10053 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10054 rte_pktmbuf_tailroom(ut_params->ibuf));
10056 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10057 d_td->plaintext.len);
10059 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
10061 /* Setup cipher session parameters */
10062 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10063 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10064 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10065 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10066 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10067 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10068 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10069 ut_params->cipher_xform.next = NULL;
10071 /* Setup DOCSIS session parameters */
10072 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10074 struct rte_security_session_conf sess_conf = {
10075 .action_type = ut_params->type,
10076 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10077 .docsis = ut_params->docsis_xform,
10078 .crypto_xform = &ut_params->cipher_xform,
10081 /* Create security session */
10082 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10083 ts_params->session_mpool,
10084 ts_params->session_priv_mpool);
10086 if (!ut_params->sec_session) {
10087 printf("Test function %s line %u: failed to allocate session\n",
10088 __func__, __LINE__);
10093 /* Generate crypto op data structure */
10094 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10095 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10096 if (!ut_params->op) {
10097 printf("Test function %s line %u: failed to allocate symmetric "
10098 "crypto operation\n", __func__, __LINE__);
10103 /* Setup CRC operation parameters */
10104 crc_len = d_td->plaintext.no_crc == false ?
10105 (d_td->plaintext.len -
10106 d_td->plaintext.crc_offset -
10107 RTE_ETHER_CRC_LEN) :
10109 crc_len = crc_len > 0 ? crc_len : 0;
10110 ut_params->op->sym->auth.data.length = crc_len;
10111 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
10113 /* Setup cipher operation parameters */
10114 cipher_len = d_td->plaintext.no_cipher == false ?
10115 (d_td->plaintext.len -
10116 d_td->plaintext.cipher_offset) :
10118 cipher_len = cipher_len > 0 ? cipher_len : 0;
10119 ut_params->op->sym->cipher.data.length = cipher_len;
10120 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
10122 /* Setup cipher IV */
10123 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10124 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10126 /* Attach session to operation */
10127 rte_security_attach_session(ut_params->op, ut_params->sec_session);
10129 /* Set crypto operation mbufs */
10130 ut_params->op->sym->m_src = ut_params->ibuf;
10131 ut_params->op->sym->m_dst = NULL;
10133 /* Process crypto operation */
10134 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10136 printf("Test function %s line %u: failed to process crypto op\n",
10137 __func__, __LINE__);
10142 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10143 printf("Test function %s line %u: crypto op processing failed\n",
10144 __func__, __LINE__);
10149 /* Validate ciphertext */
10150 ciphertext = plaintext;
10152 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
10153 printf("Test function %s line %u: plaintext not as expected\n",
10154 __func__, __LINE__);
10155 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
10156 d_td->ciphertext.len);
10157 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
10163 rte_crypto_op_free(ut_params->op);
10164 ut_params->op = NULL;
10166 if (ut_params->sec_session)
10167 rte_security_session_destroy(ctx, ut_params->sec_session);
10168 ut_params->sec_session = NULL;
10170 rte_pktmbuf_free(ut_params->ibuf);
10171 ut_params->ibuf = NULL;
10178 test_AES_GCM_authenticated_encryption_test_case_1(void)
10180 return test_authenticated_encryption(&gcm_test_case_1);
10184 test_AES_GCM_authenticated_encryption_test_case_2(void)
10186 return test_authenticated_encryption(&gcm_test_case_2);
10190 test_AES_GCM_authenticated_encryption_test_case_3(void)
10192 return test_authenticated_encryption(&gcm_test_case_3);
10196 test_AES_GCM_authenticated_encryption_test_case_4(void)
10198 return test_authenticated_encryption(&gcm_test_case_4);
10202 test_AES_GCM_authenticated_encryption_test_case_5(void)
10204 return test_authenticated_encryption(&gcm_test_case_5);
10208 test_AES_GCM_authenticated_encryption_test_case_6(void)
10210 return test_authenticated_encryption(&gcm_test_case_6);
10214 test_AES_GCM_authenticated_encryption_test_case_7(void)
10216 return test_authenticated_encryption(&gcm_test_case_7);
10220 test_AES_GCM_authenticated_encryption_test_case_8(void)
10222 return test_authenticated_encryption(&gcm_test_case_8);
10226 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
10228 return test_authenticated_encryption(&gcm_J0_test_case_1);
10232 test_AES_GCM_auth_encryption_test_case_192_1(void)
10234 return test_authenticated_encryption(&gcm_test_case_192_1);
10238 test_AES_GCM_auth_encryption_test_case_192_2(void)
10240 return test_authenticated_encryption(&gcm_test_case_192_2);
10244 test_AES_GCM_auth_encryption_test_case_192_3(void)
10246 return test_authenticated_encryption(&gcm_test_case_192_3);
10250 test_AES_GCM_auth_encryption_test_case_192_4(void)
10252 return test_authenticated_encryption(&gcm_test_case_192_4);
10256 test_AES_GCM_auth_encryption_test_case_192_5(void)
10258 return test_authenticated_encryption(&gcm_test_case_192_5);
10262 test_AES_GCM_auth_encryption_test_case_192_6(void)
10264 return test_authenticated_encryption(&gcm_test_case_192_6);
10268 test_AES_GCM_auth_encryption_test_case_192_7(void)
10270 return test_authenticated_encryption(&gcm_test_case_192_7);
10274 test_AES_GCM_auth_encryption_test_case_256_1(void)
10276 return test_authenticated_encryption(&gcm_test_case_256_1);
10280 test_AES_GCM_auth_encryption_test_case_256_2(void)
10282 return test_authenticated_encryption(&gcm_test_case_256_2);
10286 test_AES_GCM_auth_encryption_test_case_256_3(void)
10288 return test_authenticated_encryption(&gcm_test_case_256_3);
10292 test_AES_GCM_auth_encryption_test_case_256_4(void)
10294 return test_authenticated_encryption(&gcm_test_case_256_4);
10298 test_AES_GCM_auth_encryption_test_case_256_5(void)
10300 return test_authenticated_encryption(&gcm_test_case_256_5);
10304 test_AES_GCM_auth_encryption_test_case_256_6(void)
10306 return test_authenticated_encryption(&gcm_test_case_256_6);
10310 test_AES_GCM_auth_encryption_test_case_256_7(void)
10312 return test_authenticated_encryption(&gcm_test_case_256_7);
10316 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10318 return test_authenticated_encryption(&gcm_test_case_aad_1);
10322 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10324 return test_authenticated_encryption(&gcm_test_case_aad_2);
10328 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10330 struct aead_test_data tdata;
10333 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10334 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10335 tdata.iv.data[0] += 1;
10336 res = test_authenticated_encryption(&tdata);
10337 if (res == TEST_SKIPPED)
10339 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10340 return TEST_SUCCESS;
10344 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10346 struct aead_test_data tdata;
10349 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10350 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10351 tdata.plaintext.data[0] += 1;
10352 res = test_authenticated_encryption(&tdata);
10353 if (res == TEST_SKIPPED)
10355 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10356 return TEST_SUCCESS;
10360 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10362 struct aead_test_data tdata;
10365 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10366 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10367 tdata.ciphertext.data[0] += 1;
10368 res = test_authenticated_encryption(&tdata);
10369 if (res == TEST_SKIPPED)
10371 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10372 return TEST_SUCCESS;
10376 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10378 struct aead_test_data tdata;
10381 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10382 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10383 tdata.aad.len += 1;
10384 res = test_authenticated_encryption(&tdata);
10385 if (res == TEST_SKIPPED)
10387 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10388 return TEST_SUCCESS;
10392 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10394 struct aead_test_data tdata;
10395 uint8_t aad[gcm_test_case_7.aad.len];
10398 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10399 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10400 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10402 tdata.aad.data = aad;
10403 res = test_authenticated_encryption(&tdata);
10404 if (res == TEST_SKIPPED)
10406 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10407 return TEST_SUCCESS;
10411 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10413 struct aead_test_data tdata;
10416 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10417 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10418 tdata.auth_tag.data[0] += 1;
10419 res = test_authenticated_encryption(&tdata);
10420 if (res == TEST_SKIPPED)
10422 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10423 return TEST_SUCCESS;
10427 test_authenticated_decryption(const struct aead_test_data *tdata)
10429 struct crypto_testsuite_params *ts_params = &testsuite_params;
10430 struct crypto_unittest_params *ut_params = &unittest_params;
10433 uint8_t *plaintext;
10435 struct rte_cryptodev_info dev_info;
10437 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10438 uint64_t feat_flags = dev_info.feature_flags;
10440 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10441 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10442 printf("Device doesn't support RAW data-path APIs.\n");
10443 return TEST_SKIPPED;
10446 /* Verify the capabilities */
10447 struct rte_cryptodev_sym_capability_idx cap_idx;
10448 const struct rte_cryptodev_symmetric_capability *capability;
10449 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10450 cap_idx.algo.aead = tdata->algo;
10451 capability = rte_cryptodev_sym_capability_get(
10452 ts_params->valid_devs[0], &cap_idx);
10453 if (capability == NULL)
10454 return TEST_SKIPPED;
10455 if (rte_cryptodev_sym_capability_check_aead(
10456 capability, tdata->key.len, tdata->auth_tag.len,
10457 tdata->aad.len, tdata->iv.len))
10458 return TEST_SKIPPED;
10460 /* Create AEAD session */
10461 retval = create_aead_session(ts_params->valid_devs[0],
10463 RTE_CRYPTO_AEAD_OP_DECRYPT,
10464 tdata->key.data, tdata->key.len,
10465 tdata->aad.len, tdata->auth_tag.len,
10470 /* alloc mbuf and set payload */
10471 if (tdata->aad.len > MBUF_SIZE) {
10472 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10473 /* Populate full size of add data */
10474 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10475 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10477 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10479 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10480 rte_pktmbuf_tailroom(ut_params->ibuf));
10482 /* Create AEAD operation */
10483 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10487 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10489 ut_params->op->sym->m_src = ut_params->ibuf;
10491 /* Process crypto operation */
10492 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10493 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10494 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10495 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10496 ut_params->op, 0, 0, 0, 0);
10498 TEST_ASSERT_NOT_NULL(
10499 process_crypto_request(ts_params->valid_devs[0],
10500 ut_params->op), "failed to process sym crypto op");
10502 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10503 "crypto op processing failed");
10505 if (ut_params->op->sym->m_dst)
10506 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10509 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10511 ut_params->op->sym->cipher.data.offset);
10513 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10515 /* Validate obuf */
10516 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10518 tdata->plaintext.data,
10519 tdata->plaintext.len,
10520 "Plaintext data not as expected");
10522 TEST_ASSERT_EQUAL(ut_params->op->status,
10523 RTE_CRYPTO_OP_STATUS_SUCCESS,
10524 "Authentication failed");
10530 test_AES_GCM_authenticated_decryption_test_case_1(void)
10532 return test_authenticated_decryption(&gcm_test_case_1);
10536 test_AES_GCM_authenticated_decryption_test_case_2(void)
10538 return test_authenticated_decryption(&gcm_test_case_2);
10542 test_AES_GCM_authenticated_decryption_test_case_3(void)
10544 return test_authenticated_decryption(&gcm_test_case_3);
10548 test_AES_GCM_authenticated_decryption_test_case_4(void)
10550 return test_authenticated_decryption(&gcm_test_case_4);
10554 test_AES_GCM_authenticated_decryption_test_case_5(void)
10556 return test_authenticated_decryption(&gcm_test_case_5);
10560 test_AES_GCM_authenticated_decryption_test_case_6(void)
10562 return test_authenticated_decryption(&gcm_test_case_6);
10566 test_AES_GCM_authenticated_decryption_test_case_7(void)
10568 return test_authenticated_decryption(&gcm_test_case_7);
10572 test_AES_GCM_authenticated_decryption_test_case_8(void)
10574 return test_authenticated_decryption(&gcm_test_case_8);
10578 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10580 return test_authenticated_decryption(&gcm_J0_test_case_1);
10584 test_AES_GCM_auth_decryption_test_case_192_1(void)
10586 return test_authenticated_decryption(&gcm_test_case_192_1);
10590 test_AES_GCM_auth_decryption_test_case_192_2(void)
10592 return test_authenticated_decryption(&gcm_test_case_192_2);
10596 test_AES_GCM_auth_decryption_test_case_192_3(void)
10598 return test_authenticated_decryption(&gcm_test_case_192_3);
10602 test_AES_GCM_auth_decryption_test_case_192_4(void)
10604 return test_authenticated_decryption(&gcm_test_case_192_4);
10608 test_AES_GCM_auth_decryption_test_case_192_5(void)
10610 return test_authenticated_decryption(&gcm_test_case_192_5);
10614 test_AES_GCM_auth_decryption_test_case_192_6(void)
10616 return test_authenticated_decryption(&gcm_test_case_192_6);
10620 test_AES_GCM_auth_decryption_test_case_192_7(void)
10622 return test_authenticated_decryption(&gcm_test_case_192_7);
10626 test_AES_GCM_auth_decryption_test_case_256_1(void)
10628 return test_authenticated_decryption(&gcm_test_case_256_1);
10632 test_AES_GCM_auth_decryption_test_case_256_2(void)
10634 return test_authenticated_decryption(&gcm_test_case_256_2);
10638 test_AES_GCM_auth_decryption_test_case_256_3(void)
10640 return test_authenticated_decryption(&gcm_test_case_256_3);
10644 test_AES_GCM_auth_decryption_test_case_256_4(void)
10646 return test_authenticated_decryption(&gcm_test_case_256_4);
10650 test_AES_GCM_auth_decryption_test_case_256_5(void)
10652 return test_authenticated_decryption(&gcm_test_case_256_5);
10656 test_AES_GCM_auth_decryption_test_case_256_6(void)
10658 return test_authenticated_decryption(&gcm_test_case_256_6);
10662 test_AES_GCM_auth_decryption_test_case_256_7(void)
10664 return test_authenticated_decryption(&gcm_test_case_256_7);
10668 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10670 return test_authenticated_decryption(&gcm_test_case_aad_1);
10674 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10676 return test_authenticated_decryption(&gcm_test_case_aad_2);
10680 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10682 struct aead_test_data tdata;
10685 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10686 tdata.iv.data[0] += 1;
10687 res = test_authenticated_decryption(&tdata);
10688 if (res == TEST_SKIPPED)
10690 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10691 return TEST_SUCCESS;
10695 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10697 struct aead_test_data tdata;
10700 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10701 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10702 tdata.plaintext.data[0] += 1;
10703 res = test_authenticated_decryption(&tdata);
10704 if (res == TEST_SKIPPED)
10706 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10707 return TEST_SUCCESS;
10711 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10713 struct aead_test_data tdata;
10716 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10717 tdata.ciphertext.data[0] += 1;
10718 res = test_authenticated_decryption(&tdata);
10719 if (res == TEST_SKIPPED)
10721 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10722 return TEST_SUCCESS;
10726 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10728 struct aead_test_data tdata;
10731 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10732 tdata.aad.len += 1;
10733 res = test_authenticated_decryption(&tdata);
10734 if (res == TEST_SKIPPED)
10736 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10737 return TEST_SUCCESS;
10741 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10743 struct aead_test_data tdata;
10744 uint8_t aad[gcm_test_case_7.aad.len];
10747 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10748 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10750 tdata.aad.data = aad;
10751 res = test_authenticated_decryption(&tdata);
10752 if (res == TEST_SKIPPED)
10754 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10755 return TEST_SUCCESS;
10759 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10761 struct aead_test_data tdata;
10764 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10765 tdata.auth_tag.data[0] += 1;
10766 res = test_authenticated_decryption(&tdata);
10767 if (res == TEST_SKIPPED)
10769 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10770 return TEST_SUCCESS;
10774 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10776 struct crypto_testsuite_params *ts_params = &testsuite_params;
10777 struct crypto_unittest_params *ut_params = &unittest_params;
10780 uint8_t *ciphertext, *auth_tag;
10781 uint16_t plaintext_pad_len;
10782 struct rte_cryptodev_info dev_info;
10784 /* Verify the capabilities */
10785 struct rte_cryptodev_sym_capability_idx cap_idx;
10786 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10787 cap_idx.algo.aead = tdata->algo;
10788 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10790 return TEST_SKIPPED;
10792 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10793 uint64_t feat_flags = dev_info.feature_flags;
10795 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10796 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
10797 return TEST_SKIPPED;
10799 /* not supported with CPU crypto */
10800 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10801 return TEST_SKIPPED;
10803 /* Create AEAD session */
10804 retval = create_aead_session(ts_params->valid_devs[0],
10806 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10807 tdata->key.data, tdata->key.len,
10808 tdata->aad.len, tdata->auth_tag.len,
10813 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10814 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10816 /* clear mbuf payload */
10817 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10818 rte_pktmbuf_tailroom(ut_params->ibuf));
10819 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10820 rte_pktmbuf_tailroom(ut_params->obuf));
10822 /* Create AEAD operation */
10823 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10827 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10829 ut_params->op->sym->m_src = ut_params->ibuf;
10830 ut_params->op->sym->m_dst = ut_params->obuf;
10832 /* Process crypto operation */
10833 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10834 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10835 ut_params->op, 0, 0, 0, 0);
10837 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10838 ut_params->op), "failed to process sym crypto op");
10840 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10841 "crypto op processing failed");
10843 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10845 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10846 ut_params->op->sym->cipher.data.offset);
10847 auth_tag = ciphertext + plaintext_pad_len;
10849 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10850 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10852 /* Validate obuf */
10853 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10855 tdata->ciphertext.data,
10856 tdata->ciphertext.len,
10857 "Ciphertext data not as expected");
10859 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10861 tdata->auth_tag.data,
10862 tdata->auth_tag.len,
10863 "Generated auth tag not as expected");
10870 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10872 return test_authenticated_encryption_oop(&gcm_test_case_5);
10876 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10878 struct crypto_testsuite_params *ts_params = &testsuite_params;
10879 struct crypto_unittest_params *ut_params = &unittest_params;
10882 uint8_t *plaintext;
10883 struct rte_cryptodev_info dev_info;
10885 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10886 uint64_t feat_flags = dev_info.feature_flags;
10888 /* Verify the capabilities */
10889 struct rte_cryptodev_sym_capability_idx cap_idx;
10890 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10891 cap_idx.algo.aead = tdata->algo;
10892 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10894 return TEST_SKIPPED;
10896 /* not supported with CPU crypto and raw data-path APIs*/
10897 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10898 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10899 return TEST_SKIPPED;
10901 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10902 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10903 printf("Device does not support RAW data-path APIs.\n");
10904 return TEST_SKIPPED;
10907 /* Create AEAD session */
10908 retval = create_aead_session(ts_params->valid_devs[0],
10910 RTE_CRYPTO_AEAD_OP_DECRYPT,
10911 tdata->key.data, tdata->key.len,
10912 tdata->aad.len, tdata->auth_tag.len,
10917 /* alloc mbuf and set payload */
10918 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10919 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10921 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10922 rte_pktmbuf_tailroom(ut_params->ibuf));
10923 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10924 rte_pktmbuf_tailroom(ut_params->obuf));
10926 /* Create AEAD operation */
10927 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10931 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10933 ut_params->op->sym->m_src = ut_params->ibuf;
10934 ut_params->op->sym->m_dst = ut_params->obuf;
10936 /* Process crypto operation */
10937 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10938 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10939 ut_params->op, 0, 0, 0, 0);
10941 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10942 ut_params->op), "failed to process sym crypto op");
10944 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10945 "crypto op processing failed");
10947 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10948 ut_params->op->sym->cipher.data.offset);
10950 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10952 /* Validate obuf */
10953 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10955 tdata->plaintext.data,
10956 tdata->plaintext.len,
10957 "Plaintext data not as expected");
10959 TEST_ASSERT_EQUAL(ut_params->op->status,
10960 RTE_CRYPTO_OP_STATUS_SUCCESS,
10961 "Authentication failed");
10966 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10968 return test_authenticated_decryption_oop(&gcm_test_case_5);
10972 test_authenticated_encryption_sessionless(
10973 const struct aead_test_data *tdata)
10975 struct crypto_testsuite_params *ts_params = &testsuite_params;
10976 struct crypto_unittest_params *ut_params = &unittest_params;
10979 uint8_t *ciphertext, *auth_tag;
10980 uint16_t plaintext_pad_len;
10981 uint8_t key[tdata->key.len + 1];
10982 struct rte_cryptodev_info dev_info;
10984 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10985 uint64_t feat_flags = dev_info.feature_flags;
10987 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10988 printf("Device doesn't support Sessionless ops.\n");
10989 return TEST_SKIPPED;
10992 /* not supported with CPU crypto */
10993 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10994 return TEST_SKIPPED;
10996 /* Verify the capabilities */
10997 struct rte_cryptodev_sym_capability_idx cap_idx;
10998 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10999 cap_idx.algo.aead = tdata->algo;
11000 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11002 return TEST_SKIPPED;
11004 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11006 /* clear mbuf payload */
11007 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11008 rte_pktmbuf_tailroom(ut_params->ibuf));
11010 /* Create AEAD operation */
11011 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
11015 /* Create GCM xform */
11016 memcpy(key, tdata->key.data, tdata->key.len);
11017 retval = create_aead_xform(ut_params->op,
11019 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11020 key, tdata->key.len,
11021 tdata->aad.len, tdata->auth_tag.len,
11026 ut_params->op->sym->m_src = ut_params->ibuf;
11028 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11029 RTE_CRYPTO_OP_SESSIONLESS,
11030 "crypto op session type not sessionless");
11032 /* Process crypto operation */
11033 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11034 ut_params->op), "failed to process sym crypto op");
11036 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11038 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11039 "crypto op status not success");
11041 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11043 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11044 ut_params->op->sym->cipher.data.offset);
11045 auth_tag = ciphertext + plaintext_pad_len;
11047 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
11048 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
11050 /* Validate obuf */
11051 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11053 tdata->ciphertext.data,
11054 tdata->ciphertext.len,
11055 "Ciphertext data not as expected");
11057 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11059 tdata->auth_tag.data,
11060 tdata->auth_tag.len,
11061 "Generated auth tag not as expected");
11068 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
11070 return test_authenticated_encryption_sessionless(
11075 test_authenticated_decryption_sessionless(
11076 const struct aead_test_data *tdata)
11078 struct crypto_testsuite_params *ts_params = &testsuite_params;
11079 struct crypto_unittest_params *ut_params = &unittest_params;
11082 uint8_t *plaintext;
11083 uint8_t key[tdata->key.len + 1];
11084 struct rte_cryptodev_info dev_info;
11086 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11087 uint64_t feat_flags = dev_info.feature_flags;
11089 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11090 printf("Device doesn't support Sessionless ops.\n");
11091 return TEST_SKIPPED;
11094 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11095 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11096 printf("Device doesn't support RAW data-path APIs.\n");
11097 return TEST_SKIPPED;
11100 /* not supported with CPU crypto */
11101 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11102 return TEST_SKIPPED;
11104 /* Verify the capabilities */
11105 struct rte_cryptodev_sym_capability_idx cap_idx;
11106 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11107 cap_idx.algo.aead = tdata->algo;
11108 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11110 return TEST_SKIPPED;
11112 /* alloc mbuf and set payload */
11113 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11115 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11116 rte_pktmbuf_tailroom(ut_params->ibuf));
11118 /* Create AEAD operation */
11119 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11123 /* Create AEAD xform */
11124 memcpy(key, tdata->key.data, tdata->key.len);
11125 retval = create_aead_xform(ut_params->op,
11127 RTE_CRYPTO_AEAD_OP_DECRYPT,
11128 key, tdata->key.len,
11129 tdata->aad.len, tdata->auth_tag.len,
11134 ut_params->op->sym->m_src = ut_params->ibuf;
11136 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11137 RTE_CRYPTO_OP_SESSIONLESS,
11138 "crypto op session type not sessionless");
11140 /* Process crypto operation */
11141 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11142 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11143 ut_params->op, 0, 0, 0, 0);
11145 TEST_ASSERT_NOT_NULL(process_crypto_request(
11146 ts_params->valid_devs[0], ut_params->op),
11147 "failed to process sym crypto op");
11149 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11151 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11152 "crypto op status not success");
11154 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11155 ut_params->op->sym->cipher.data.offset);
11157 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11159 /* Validate obuf */
11160 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11162 tdata->plaintext.data,
11163 tdata->plaintext.len,
11164 "Plaintext data not as expected");
11166 TEST_ASSERT_EQUAL(ut_params->op->status,
11167 RTE_CRYPTO_OP_STATUS_SUCCESS,
11168 "Authentication failed");
11173 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
11175 return test_authenticated_decryption_sessionless(
11180 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
11182 return test_authenticated_encryption(&ccm_test_case_128_1);
11186 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
11188 return test_authenticated_encryption(&ccm_test_case_128_2);
11192 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
11194 return test_authenticated_encryption(&ccm_test_case_128_3);
11198 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
11200 return test_authenticated_decryption(&ccm_test_case_128_1);
11204 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
11206 return test_authenticated_decryption(&ccm_test_case_128_2);
11210 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
11212 return test_authenticated_decryption(&ccm_test_case_128_3);
11216 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
11218 return test_authenticated_encryption(&ccm_test_case_192_1);
11222 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
11224 return test_authenticated_encryption(&ccm_test_case_192_2);
11228 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
11230 return test_authenticated_encryption(&ccm_test_case_192_3);
11234 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
11236 return test_authenticated_decryption(&ccm_test_case_192_1);
11240 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
11242 return test_authenticated_decryption(&ccm_test_case_192_2);
11246 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
11248 return test_authenticated_decryption(&ccm_test_case_192_3);
11252 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
11254 return test_authenticated_encryption(&ccm_test_case_256_1);
11258 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
11260 return test_authenticated_encryption(&ccm_test_case_256_2);
11264 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
11266 return test_authenticated_encryption(&ccm_test_case_256_3);
11270 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
11272 return test_authenticated_decryption(&ccm_test_case_256_1);
11276 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
11278 return test_authenticated_decryption(&ccm_test_case_256_2);
11282 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
11284 return test_authenticated_decryption(&ccm_test_case_256_3);
11290 struct crypto_testsuite_params *ts_params = &testsuite_params;
11291 struct rte_cryptodev_stats stats;
11293 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11294 return TEST_SKIPPED;
11296 /* Verify the capabilities */
11297 struct rte_cryptodev_sym_capability_idx cap_idx;
11298 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11299 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11300 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11302 return TEST_SKIPPED;
11303 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11304 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11305 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11307 return TEST_SKIPPED;
11309 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11311 return TEST_SKIPPED;
11313 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11314 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11315 &stats) == -ENODEV),
11316 "rte_cryptodev_stats_get invalid dev failed");
11317 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11318 "rte_cryptodev_stats_get invalid Param failed");
11320 /* Test expected values */
11321 test_AES_CBC_HMAC_SHA1_encrypt_digest();
11322 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11324 "rte_cryptodev_stats_get failed");
11325 TEST_ASSERT((stats.enqueued_count == 1),
11326 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11327 TEST_ASSERT((stats.dequeued_count == 1),
11328 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11329 TEST_ASSERT((stats.enqueue_err_count == 0),
11330 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11331 TEST_ASSERT((stats.dequeue_err_count == 0),
11332 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11334 /* invalid device but should ignore and not reset device stats*/
11335 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11336 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11338 "rte_cryptodev_stats_get failed");
11339 TEST_ASSERT((stats.enqueued_count == 1),
11340 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11342 /* check that a valid reset clears stats */
11343 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11344 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11346 "rte_cryptodev_stats_get failed");
11347 TEST_ASSERT((stats.enqueued_count == 0),
11348 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11349 TEST_ASSERT((stats.dequeued_count == 0),
11350 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11352 return TEST_SUCCESS;
11355 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11356 struct crypto_unittest_params *ut_params,
11357 enum rte_crypto_auth_operation op,
11358 const struct HMAC_MD5_vector *test_case)
11363 memcpy(key, test_case->key.data, test_case->key.len);
11365 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11366 ut_params->auth_xform.next = NULL;
11367 ut_params->auth_xform.auth.op = op;
11369 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11371 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11372 ut_params->auth_xform.auth.key.length = test_case->key.len;
11373 ut_params->auth_xform.auth.key.data = key;
11375 ut_params->sess = rte_cryptodev_sym_session_create(
11376 ts_params->session_mpool);
11377 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11378 if (ut_params->sess == NULL)
11379 return TEST_FAILED;
11381 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11382 ut_params->sess, &ut_params->auth_xform,
11383 ts_params->session_priv_mpool);
11384 if (status == -ENOTSUP)
11385 return TEST_SKIPPED;
11387 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11389 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11390 rte_pktmbuf_tailroom(ut_params->ibuf));
11395 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11396 const struct HMAC_MD5_vector *test_case,
11397 uint8_t **plaintext)
11399 uint16_t plaintext_pad_len;
11401 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11403 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11406 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11407 plaintext_pad_len);
11408 memcpy(*plaintext, test_case->plaintext.data,
11409 test_case->plaintext.len);
11411 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11412 ut_params->ibuf, MD5_DIGEST_LEN);
11413 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11414 "no room to append digest");
11415 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11416 ut_params->ibuf, plaintext_pad_len);
11418 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11419 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11420 test_case->auth_tag.len);
11423 sym_op->auth.data.offset = 0;
11424 sym_op->auth.data.length = test_case->plaintext.len;
11426 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11427 ut_params->op->sym->m_src = ut_params->ibuf;
11433 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11435 uint16_t plaintext_pad_len;
11436 uint8_t *plaintext, *auth_tag;
11438 struct crypto_testsuite_params *ts_params = &testsuite_params;
11439 struct crypto_unittest_params *ut_params = &unittest_params;
11440 struct rte_cryptodev_info dev_info;
11442 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11443 uint64_t feat_flags = dev_info.feature_flags;
11445 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11446 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11447 printf("Device doesn't support RAW data-path APIs.\n");
11448 return TEST_SKIPPED;
11451 /* Verify the capabilities */
11452 struct rte_cryptodev_sym_capability_idx cap_idx;
11453 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11454 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11455 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11457 return TEST_SKIPPED;
11459 if (MD5_HMAC_create_session(ts_params, ut_params,
11460 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11461 return TEST_FAILED;
11463 /* Generate Crypto op data structure */
11464 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11465 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11466 TEST_ASSERT_NOT_NULL(ut_params->op,
11467 "Failed to allocate symmetric crypto operation struct");
11469 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11472 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11473 return TEST_FAILED;
11475 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11476 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11478 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11479 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11480 ut_params->op, 0, 1, 0, 0);
11482 TEST_ASSERT_NOT_NULL(
11483 process_crypto_request(ts_params->valid_devs[0],
11485 "failed to process sym crypto op");
11487 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11488 "crypto op processing failed");
11490 if (ut_params->op->sym->m_dst) {
11491 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11492 uint8_t *, plaintext_pad_len);
11494 auth_tag = plaintext + plaintext_pad_len;
11497 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11499 test_case->auth_tag.data,
11500 test_case->auth_tag.len,
11501 "HMAC_MD5 generated tag not as expected");
11503 return TEST_SUCCESS;
11507 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11509 uint8_t *plaintext;
11511 struct crypto_testsuite_params *ts_params = &testsuite_params;
11512 struct crypto_unittest_params *ut_params = &unittest_params;
11513 struct rte_cryptodev_info dev_info;
11515 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11516 uint64_t feat_flags = dev_info.feature_flags;
11518 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11519 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11520 printf("Device doesn't support RAW data-path APIs.\n");
11521 return TEST_SKIPPED;
11524 /* Verify the capabilities */
11525 struct rte_cryptodev_sym_capability_idx cap_idx;
11526 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11527 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11528 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11530 return TEST_SKIPPED;
11532 if (MD5_HMAC_create_session(ts_params, ut_params,
11533 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11534 return TEST_FAILED;
11537 /* Generate Crypto op data structure */
11538 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11539 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11540 TEST_ASSERT_NOT_NULL(ut_params->op,
11541 "Failed to allocate symmetric crypto operation struct");
11543 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11544 return TEST_FAILED;
11546 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11547 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11549 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11550 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11551 ut_params->op, 0, 1, 0, 0);
11553 TEST_ASSERT_NOT_NULL(
11554 process_crypto_request(ts_params->valid_devs[0],
11556 "failed to process sym crypto op");
11558 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11559 "HMAC_MD5 crypto op processing failed");
11561 return TEST_SUCCESS;
11565 test_MD5_HMAC_generate_case_1(void)
11567 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11571 test_MD5_HMAC_verify_case_1(void)
11573 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11577 test_MD5_HMAC_generate_case_2(void)
11579 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11583 test_MD5_HMAC_verify_case_2(void)
11585 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11589 test_multi_session(void)
11591 struct crypto_testsuite_params *ts_params = &testsuite_params;
11592 struct crypto_unittest_params *ut_params = &unittest_params;
11594 struct rte_cryptodev_info dev_info;
11595 struct rte_cryptodev_sym_session **sessions;
11600 /* Verify the capabilities */
11601 struct rte_cryptodev_sym_capability_idx cap_idx;
11602 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11603 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11604 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11606 return TEST_SKIPPED;
11607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11608 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11609 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11611 return TEST_SKIPPED;
11613 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11614 aes_cbc_key, hmac_sha512_key);
11617 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11619 sessions = rte_malloc(NULL,
11620 sizeof(struct rte_cryptodev_sym_session *) *
11621 (MAX_NB_SESSIONS + 1), 0);
11623 /* Create multiple crypto sessions*/
11624 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11626 sessions[i] = rte_cryptodev_sym_session_create(
11627 ts_params->session_mpool);
11628 TEST_ASSERT_NOT_NULL(sessions[i],
11629 "Session creation failed at session number %u",
11632 status = rte_cryptodev_sym_session_init(
11633 ts_params->valid_devs[0],
11634 sessions[i], &ut_params->auth_xform,
11635 ts_params->session_priv_mpool);
11636 if (status == -ENOTSUP)
11637 return TEST_SKIPPED;
11639 /* Attempt to send a request on each session */
11640 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11644 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11645 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11647 "Failed to perform decrypt on request number %u.", i);
11648 /* free crypto operation structure */
11650 rte_crypto_op_free(ut_params->op);
11653 * free mbuf - both obuf and ibuf are usually the same,
11654 * so check if they point at the same address is necessary,
11655 * to avoid freeing the mbuf twice.
11657 if (ut_params->obuf) {
11658 rte_pktmbuf_free(ut_params->obuf);
11659 if (ut_params->ibuf == ut_params->obuf)
11660 ut_params->ibuf = 0;
11661 ut_params->obuf = 0;
11663 if (ut_params->ibuf) {
11664 rte_pktmbuf_free(ut_params->ibuf);
11665 ut_params->ibuf = 0;
11669 sessions[i] = NULL;
11670 /* Next session create should fail */
11671 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11672 sessions[i], &ut_params->auth_xform,
11673 ts_params->session_priv_mpool);
11674 TEST_ASSERT_NULL(sessions[i],
11675 "Session creation succeeded unexpectedly!");
11677 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11678 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11680 rte_cryptodev_sym_session_free(sessions[i]);
11683 rte_free(sessions);
11685 return TEST_SUCCESS;
11688 struct multi_session_params {
11689 struct crypto_unittest_params ut_params;
11690 uint8_t *cipher_key;
11692 const uint8_t *cipher;
11693 const uint8_t *digest;
11697 #define MB_SESSION_NUMBER 3
11700 test_multi_session_random_usage(void)
11702 struct crypto_testsuite_params *ts_params = &testsuite_params;
11703 struct rte_cryptodev_info dev_info;
11704 struct rte_cryptodev_sym_session **sessions;
11706 struct multi_session_params ut_paramz[] = {
11709 .cipher_key = ms_aes_cbc_key0,
11710 .hmac_key = ms_hmac_key0,
11711 .cipher = ms_aes_cbc_cipher0,
11712 .digest = ms_hmac_digest0,
11713 .iv = ms_aes_cbc_iv0
11716 .cipher_key = ms_aes_cbc_key1,
11717 .hmac_key = ms_hmac_key1,
11718 .cipher = ms_aes_cbc_cipher1,
11719 .digest = ms_hmac_digest1,
11720 .iv = ms_aes_cbc_iv1
11723 .cipher_key = ms_aes_cbc_key2,
11724 .hmac_key = ms_hmac_key2,
11725 .cipher = ms_aes_cbc_cipher2,
11726 .digest = ms_hmac_digest2,
11727 .iv = ms_aes_cbc_iv2
11733 /* Verify the capabilities */
11734 struct rte_cryptodev_sym_capability_idx cap_idx;
11735 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11736 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11737 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11739 return TEST_SKIPPED;
11740 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11741 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11742 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11744 return TEST_SKIPPED;
11746 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11748 sessions = rte_malloc(NULL,
11749 (sizeof(struct rte_cryptodev_sym_session *)
11750 * MAX_NB_SESSIONS) + 1, 0);
11752 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11753 sessions[i] = rte_cryptodev_sym_session_create(
11754 ts_params->session_mpool);
11755 TEST_ASSERT_NOT_NULL(sessions[i],
11756 "Session creation failed at session number %u",
11759 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11760 sizeof(struct crypto_unittest_params));
11762 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11763 &ut_paramz[i].ut_params,
11764 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11766 /* Create multiple crypto sessions*/
11767 status = rte_cryptodev_sym_session_init(
11768 ts_params->valid_devs[0],
11770 &ut_paramz[i].ut_params.auth_xform,
11771 ts_params->session_priv_mpool);
11773 if (status == -ENOTSUP)
11774 return TEST_SKIPPED;
11776 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
11780 for (i = 0; i < 40000; i++) {
11782 j = rand() % MB_SESSION_NUMBER;
11784 TEST_ASSERT_SUCCESS(
11785 test_AES_CBC_HMAC_SHA512_decrypt_perform(
11787 &ut_paramz[j].ut_params,
11788 ts_params, ut_paramz[j].cipher,
11789 ut_paramz[j].digest,
11791 "Failed to perform decrypt on request number %u.", i);
11793 if (ut_paramz[j].ut_params.op)
11794 rte_crypto_op_free(ut_paramz[j].ut_params.op);
11797 * free mbuf - both obuf and ibuf are usually the same,
11798 * so check if they point at the same address is necessary,
11799 * to avoid freeing the mbuf twice.
11801 if (ut_paramz[j].ut_params.obuf) {
11802 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11803 if (ut_paramz[j].ut_params.ibuf
11804 == ut_paramz[j].ut_params.obuf)
11805 ut_paramz[j].ut_params.ibuf = 0;
11806 ut_paramz[j].ut_params.obuf = 0;
11808 if (ut_paramz[j].ut_params.ibuf) {
11809 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11810 ut_paramz[j].ut_params.ibuf = 0;
11814 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11815 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11817 rte_cryptodev_sym_session_free(sessions[i]);
11820 rte_free(sessions);
11822 return TEST_SUCCESS;
11825 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11826 0xab, 0xab, 0xab, 0xab,
11827 0xab, 0xab, 0xab, 0xab,
11828 0xab, 0xab, 0xab, 0xab};
11831 test_null_invalid_operation(void)
11833 struct crypto_testsuite_params *ts_params = &testsuite_params;
11834 struct crypto_unittest_params *ut_params = &unittest_params;
11837 /* This test is for NULL PMD only */
11838 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11839 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11840 return TEST_SKIPPED;
11842 /* Setup Cipher Parameters */
11843 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11844 ut_params->cipher_xform.next = NULL;
11846 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11847 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11849 ut_params->sess = rte_cryptodev_sym_session_create(
11850 ts_params->session_mpool);
11852 /* Create Crypto session*/
11853 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11854 ut_params->sess, &ut_params->cipher_xform,
11855 ts_params->session_priv_mpool);
11856 TEST_ASSERT(ret < 0,
11857 "Session creation succeeded unexpectedly");
11860 /* Setup HMAC Parameters */
11861 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11862 ut_params->auth_xform.next = NULL;
11864 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11865 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11867 ut_params->sess = rte_cryptodev_sym_session_create(
11868 ts_params->session_mpool);
11870 /* Create Crypto session*/
11871 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11872 ut_params->sess, &ut_params->auth_xform,
11873 ts_params->session_priv_mpool);
11874 TEST_ASSERT(ret < 0,
11875 "Session creation succeeded unexpectedly");
11877 return TEST_SUCCESS;
11881 #define NULL_BURST_LENGTH (32)
11884 test_null_burst_operation(void)
11886 struct crypto_testsuite_params *ts_params = &testsuite_params;
11887 struct crypto_unittest_params *ut_params = &unittest_params;
11890 unsigned i, burst_len = NULL_BURST_LENGTH;
11892 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11893 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11895 /* This test is for NULL PMD only */
11896 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11897 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11898 return TEST_SKIPPED;
11900 /* Setup Cipher Parameters */
11901 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11902 ut_params->cipher_xform.next = &ut_params->auth_xform;
11904 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11905 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11907 /* Setup HMAC Parameters */
11908 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11909 ut_params->auth_xform.next = NULL;
11911 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11912 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11914 ut_params->sess = rte_cryptodev_sym_session_create(
11915 ts_params->session_mpool);
11916 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11918 /* Create Crypto session*/
11919 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11920 ut_params->sess, &ut_params->cipher_xform,
11921 ts_params->session_priv_mpool);
11923 if (status == -ENOTSUP)
11924 return TEST_SKIPPED;
11926 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
11928 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11929 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11930 burst_len, "failed to generate burst of crypto ops");
11932 /* Generate an operation for each mbuf in burst */
11933 for (i = 0; i < burst_len; i++) {
11934 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11936 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11938 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11942 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11944 burst[i]->sym->m_src = m;
11947 /* Process crypto operation */
11948 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11949 0, burst, burst_len),
11951 "Error enqueuing burst");
11953 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11954 0, burst_dequeued, burst_len),
11956 "Error dequeuing burst");
11959 for (i = 0; i < burst_len; i++) {
11961 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11962 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11964 "data not as expected");
11966 rte_pktmbuf_free(burst[i]->sym->m_src);
11967 rte_crypto_op_free(burst[i]);
11970 return TEST_SUCCESS;
11974 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11975 uint16_t nb_ops, void *user_param)
11977 RTE_SET_USED(dev_id);
11978 RTE_SET_USED(qp_id);
11980 RTE_SET_USED(user_param);
11982 printf("crypto enqueue callback called\n");
11987 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11988 uint16_t nb_ops, void *user_param)
11990 RTE_SET_USED(dev_id);
11991 RTE_SET_USED(qp_id);
11993 RTE_SET_USED(user_param);
11995 printf("crypto dequeue callback called\n");
12000 * Thread using enqueue/dequeue callback with RCU.
12003 test_enqdeq_callback_thread(void *arg)
12006 /* DP thread calls rte_cryptodev_enqueue_burst()/
12007 * rte_cryptodev_dequeue_burst() and invokes callback.
12009 test_null_burst_operation();
12014 test_enq_callback_setup(void)
12016 struct crypto_testsuite_params *ts_params = &testsuite_params;
12017 struct rte_cryptodev_info dev_info;
12018 struct rte_cryptodev_qp_conf qp_conf = {
12019 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
12022 struct rte_cryptodev_cb *cb;
12023 uint16_t qp_id = 0;
12025 /* Stop the device in case it's started so it can be configured */
12026 rte_cryptodev_stop(ts_params->valid_devs[0]);
12028 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12030 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12032 "Failed to configure cryptodev %u",
12033 ts_params->valid_devs[0]);
12035 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12036 qp_conf.mp_session = ts_params->session_mpool;
12037 qp_conf.mp_session_private = ts_params->session_priv_mpool;
12039 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12040 ts_params->valid_devs[0], qp_id, &qp_conf,
12041 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12043 "rte_cryptodev_queue_pair_setup: num_inflights "
12044 "%u on qp %u on cryptodev %u",
12045 qp_conf.nb_descriptors, qp_id,
12046 ts_params->valid_devs[0]);
12048 /* Test with invalid crypto device */
12049 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
12050 qp_id, test_enq_callback, NULL);
12051 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12052 "cryptodev %u did not fail",
12053 qp_id, RTE_CRYPTO_MAX_DEVS);
12055 /* Test with invalid queue pair */
12056 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12057 dev_info.max_nb_queue_pairs + 1,
12058 test_enq_callback, NULL);
12059 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12060 "cryptodev %u did not fail",
12061 dev_info.max_nb_queue_pairs + 1,
12062 ts_params->valid_devs[0]);
12064 /* Test with NULL callback */
12065 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12066 qp_id, NULL, NULL);
12067 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12068 "cryptodev %u did not fail",
12069 qp_id, ts_params->valid_devs[0]);
12071 /* Test with valid configuration */
12072 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12073 qp_id, test_enq_callback, NULL);
12074 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12075 "qp %u on cryptodev %u",
12076 qp_id, ts_params->valid_devs[0]);
12078 rte_cryptodev_start(ts_params->valid_devs[0]);
12080 /* Launch a thread */
12081 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12082 rte_get_next_lcore(-1, 1, 0));
12084 /* Wait until reader exited. */
12085 rte_eal_mp_wait_lcore();
12087 /* Test with invalid crypto device */
12088 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12089 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12090 "Expected call to fail as crypto device is invalid");
12092 /* Test with invalid queue pair */
12093 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12094 ts_params->valid_devs[0],
12095 dev_info.max_nb_queue_pairs + 1, cb),
12096 "Expected call to fail as queue pair is invalid");
12098 /* Test with NULL callback */
12099 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12100 ts_params->valid_devs[0], qp_id, NULL),
12101 "Expected call to fail as callback is NULL");
12103 /* Test with valid configuration */
12104 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
12105 ts_params->valid_devs[0], qp_id, cb),
12106 "Failed test to remove callback on "
12107 "qp %u on cryptodev %u",
12108 qp_id, ts_params->valid_devs[0]);
12110 return TEST_SUCCESS;
12114 test_deq_callback_setup(void)
12116 struct crypto_testsuite_params *ts_params = &testsuite_params;
12117 struct rte_cryptodev_info dev_info;
12118 struct rte_cryptodev_qp_conf qp_conf = {
12119 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
12122 struct rte_cryptodev_cb *cb;
12123 uint16_t qp_id = 0;
12125 /* Stop the device in case it's started so it can be configured */
12126 rte_cryptodev_stop(ts_params->valid_devs[0]);
12128 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12130 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12132 "Failed to configure cryptodev %u",
12133 ts_params->valid_devs[0]);
12135 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12136 qp_conf.mp_session = ts_params->session_mpool;
12137 qp_conf.mp_session_private = ts_params->session_priv_mpool;
12139 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12140 ts_params->valid_devs[0], qp_id, &qp_conf,
12141 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12143 "rte_cryptodev_queue_pair_setup: num_inflights "
12144 "%u on qp %u on cryptodev %u",
12145 qp_conf.nb_descriptors, qp_id,
12146 ts_params->valid_devs[0]);
12148 /* Test with invalid crypto device */
12149 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
12150 qp_id, test_deq_callback, NULL);
12151 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12152 "cryptodev %u did not fail",
12153 qp_id, RTE_CRYPTO_MAX_DEVS);
12155 /* Test with invalid queue pair */
12156 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12157 dev_info.max_nb_queue_pairs + 1,
12158 test_deq_callback, NULL);
12159 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12160 "cryptodev %u did not fail",
12161 dev_info.max_nb_queue_pairs + 1,
12162 ts_params->valid_devs[0]);
12164 /* Test with NULL callback */
12165 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12166 qp_id, NULL, NULL);
12167 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12168 "cryptodev %u did not fail",
12169 qp_id, ts_params->valid_devs[0]);
12171 /* Test with valid configuration */
12172 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12173 qp_id, test_deq_callback, NULL);
12174 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12175 "qp %u on cryptodev %u",
12176 qp_id, ts_params->valid_devs[0]);
12178 rte_cryptodev_start(ts_params->valid_devs[0]);
12180 /* Launch a thread */
12181 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12182 rte_get_next_lcore(-1, 1, 0));
12184 /* Wait until reader exited. */
12185 rte_eal_mp_wait_lcore();
12187 /* Test with invalid crypto device */
12188 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12189 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12190 "Expected call to fail as crypto device is invalid");
12192 /* Test with invalid queue pair */
12193 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12194 ts_params->valid_devs[0],
12195 dev_info.max_nb_queue_pairs + 1, cb),
12196 "Expected call to fail as queue pair is invalid");
12198 /* Test with NULL callback */
12199 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12200 ts_params->valid_devs[0], qp_id, NULL),
12201 "Expected call to fail as callback is NULL");
12203 /* Test with valid configuration */
12204 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
12205 ts_params->valid_devs[0], qp_id, cb),
12206 "Failed test to remove callback on "
12207 "qp %u on cryptodev %u",
12208 qp_id, ts_params->valid_devs[0]);
12210 return TEST_SUCCESS;
12214 generate_gmac_large_plaintext(uint8_t *data)
12218 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
12219 memcpy(&data[i], &data[0], 32);
12223 create_gmac_operation(enum rte_crypto_auth_operation op,
12224 const struct gmac_test_data *tdata)
12226 struct crypto_testsuite_params *ts_params = &testsuite_params;
12227 struct crypto_unittest_params *ut_params = &unittest_params;
12228 struct rte_crypto_sym_op *sym_op;
12230 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12232 /* Generate Crypto op data structure */
12233 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12234 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12235 TEST_ASSERT_NOT_NULL(ut_params->op,
12236 "Failed to allocate symmetric crypto operation struct");
12238 sym_op = ut_params->op->sym;
12240 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12241 ut_params->ibuf, tdata->gmac_tag.len);
12242 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12243 "no room to append digest");
12245 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12246 ut_params->ibuf, plaintext_pad_len);
12248 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12249 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12250 tdata->gmac_tag.len);
12251 debug_hexdump(stdout, "digest:",
12252 sym_op->auth.digest.data,
12253 tdata->gmac_tag.len);
12256 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12257 uint8_t *, IV_OFFSET);
12259 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12261 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12263 sym_op->cipher.data.length = 0;
12264 sym_op->cipher.data.offset = 0;
12266 sym_op->auth.data.offset = 0;
12267 sym_op->auth.data.length = tdata->plaintext.len;
12273 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
12274 const struct gmac_test_data *tdata,
12275 void *digest_mem, uint64_t digest_phys)
12277 struct crypto_testsuite_params *ts_params = &testsuite_params;
12278 struct crypto_unittest_params *ut_params = &unittest_params;
12279 struct rte_crypto_sym_op *sym_op;
12281 /* Generate Crypto op data structure */
12282 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12283 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12284 TEST_ASSERT_NOT_NULL(ut_params->op,
12285 "Failed to allocate symmetric crypto operation struct");
12287 sym_op = ut_params->op->sym;
12289 sym_op->auth.digest.data = digest_mem;
12290 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12291 "no room to append digest");
12293 sym_op->auth.digest.phys_addr = digest_phys;
12295 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12296 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12297 tdata->gmac_tag.len);
12298 debug_hexdump(stdout, "digest:",
12299 sym_op->auth.digest.data,
12300 tdata->gmac_tag.len);
12303 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12304 uint8_t *, IV_OFFSET);
12306 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12308 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12310 sym_op->cipher.data.length = 0;
12311 sym_op->cipher.data.offset = 0;
12313 sym_op->auth.data.offset = 0;
12314 sym_op->auth.data.length = tdata->plaintext.len;
12319 static int create_gmac_session(uint8_t dev_id,
12320 const struct gmac_test_data *tdata,
12321 enum rte_crypto_auth_operation auth_op)
12323 uint8_t auth_key[tdata->key.len];
12326 struct crypto_testsuite_params *ts_params = &testsuite_params;
12327 struct crypto_unittest_params *ut_params = &unittest_params;
12329 memcpy(auth_key, tdata->key.data, tdata->key.len);
12331 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12332 ut_params->auth_xform.next = NULL;
12334 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12335 ut_params->auth_xform.auth.op = auth_op;
12336 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12337 ut_params->auth_xform.auth.key.length = tdata->key.len;
12338 ut_params->auth_xform.auth.key.data = auth_key;
12339 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12340 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12343 ut_params->sess = rte_cryptodev_sym_session_create(
12344 ts_params->session_mpool);
12345 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12347 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12348 &ut_params->auth_xform,
12349 ts_params->session_priv_mpool);
12355 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12357 struct crypto_testsuite_params *ts_params = &testsuite_params;
12358 struct crypto_unittest_params *ut_params = &unittest_params;
12359 struct rte_cryptodev_info dev_info;
12361 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12362 uint64_t feat_flags = dev_info.feature_flags;
12364 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12365 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12366 printf("Device doesn't support RAW data-path APIs.\n");
12367 return TEST_SKIPPED;
12372 uint8_t *auth_tag, *plaintext;
12373 uint16_t plaintext_pad_len;
12375 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12376 "No GMAC length in the source data");
12378 /* Verify the capabilities */
12379 struct rte_cryptodev_sym_capability_idx cap_idx;
12380 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12381 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12382 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12384 return TEST_SKIPPED;
12386 retval = create_gmac_session(ts_params->valid_devs[0],
12387 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12389 if (retval == -ENOTSUP)
12390 return TEST_SKIPPED;
12394 if (tdata->plaintext.len > MBUF_SIZE)
12395 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12397 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12398 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12399 "Failed to allocate input buffer in mempool");
12401 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12402 rte_pktmbuf_tailroom(ut_params->ibuf));
12404 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12406 * Runtime generate the large plain text instead of use hard code
12407 * plain text vector. It is done to avoid create huge source file
12408 * with the test vector.
12410 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12411 generate_gmac_large_plaintext(tdata->plaintext.data);
12413 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12414 plaintext_pad_len);
12415 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12417 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12418 debug_hexdump(stdout, "plaintext:", plaintext,
12419 tdata->plaintext.len);
12421 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12427 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12429 ut_params->op->sym->m_src = ut_params->ibuf;
12431 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12432 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12434 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12435 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12436 ut_params->op, 0, 1, 0, 0);
12438 TEST_ASSERT_NOT_NULL(
12439 process_crypto_request(ts_params->valid_devs[0],
12440 ut_params->op), "failed to process sym crypto op");
12442 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12443 "crypto op processing failed");
12445 if (ut_params->op->sym->m_dst) {
12446 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12447 uint8_t *, plaintext_pad_len);
12449 auth_tag = plaintext + plaintext_pad_len;
12452 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12456 tdata->gmac_tag.data,
12457 tdata->gmac_tag.len,
12458 "GMAC Generated auth tag not as expected");
12464 test_AES_GMAC_authentication_test_case_1(void)
12466 return test_AES_GMAC_authentication(&gmac_test_case_1);
12470 test_AES_GMAC_authentication_test_case_2(void)
12472 return test_AES_GMAC_authentication(&gmac_test_case_2);
12476 test_AES_GMAC_authentication_test_case_3(void)
12478 return test_AES_GMAC_authentication(&gmac_test_case_3);
12482 test_AES_GMAC_authentication_test_case_4(void)
12484 return test_AES_GMAC_authentication(&gmac_test_case_4);
12488 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12490 struct crypto_testsuite_params *ts_params = &testsuite_params;
12491 struct crypto_unittest_params *ut_params = &unittest_params;
12493 uint32_t plaintext_pad_len;
12494 uint8_t *plaintext;
12495 struct rte_cryptodev_info dev_info;
12497 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12498 uint64_t feat_flags = dev_info.feature_flags;
12500 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12501 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12502 printf("Device doesn't support RAW data-path APIs.\n");
12503 return TEST_SKIPPED;
12506 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12507 "No GMAC length in the source data");
12509 /* Verify the capabilities */
12510 struct rte_cryptodev_sym_capability_idx cap_idx;
12511 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12512 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12513 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12515 return TEST_SKIPPED;
12517 retval = create_gmac_session(ts_params->valid_devs[0],
12518 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12520 if (retval == -ENOTSUP)
12521 return TEST_SKIPPED;
12525 if (tdata->plaintext.len > MBUF_SIZE)
12526 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12528 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12529 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12530 "Failed to allocate input buffer in mempool");
12532 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12533 rte_pktmbuf_tailroom(ut_params->ibuf));
12535 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12538 * Runtime generate the large plain text instead of use hard code
12539 * plain text vector. It is done to avoid create huge source file
12540 * with the test vector.
12542 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12543 generate_gmac_large_plaintext(tdata->plaintext.data);
12545 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12546 plaintext_pad_len);
12547 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12549 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12550 debug_hexdump(stdout, "plaintext:", plaintext,
12551 tdata->plaintext.len);
12553 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
12559 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12561 ut_params->op->sym->m_src = ut_params->ibuf;
12563 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12564 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12566 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12567 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12568 ut_params->op, 0, 1, 0, 0);
12570 TEST_ASSERT_NOT_NULL(
12571 process_crypto_request(ts_params->valid_devs[0],
12572 ut_params->op), "failed to process sym crypto op");
12574 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12575 "crypto op processing failed");
12582 test_AES_GMAC_authentication_verify_test_case_1(void)
12584 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12588 test_AES_GMAC_authentication_verify_test_case_2(void)
12590 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12594 test_AES_GMAC_authentication_verify_test_case_3(void)
12596 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12600 test_AES_GMAC_authentication_verify_test_case_4(void)
12602 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12606 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12609 struct crypto_testsuite_params *ts_params = &testsuite_params;
12610 struct crypto_unittest_params *ut_params = &unittest_params;
12611 struct rte_cryptodev_info dev_info;
12612 uint64_t feature_flags;
12613 unsigned int trn_data = 0;
12614 void *digest_mem = NULL;
12616 unsigned int to_trn = 0;
12617 struct rte_mbuf *buf = NULL;
12618 uint8_t *auth_tag, *plaintext;
12621 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12622 "No GMAC length in the source data");
12624 /* Verify the capabilities */
12625 struct rte_cryptodev_sym_capability_idx cap_idx;
12626 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12627 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12628 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12630 return TEST_SKIPPED;
12632 /* Check for any input SGL support */
12633 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12634 feature_flags = dev_info.feature_flags;
12636 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12637 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12638 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12639 return TEST_SKIPPED;
12641 if (fragsz > tdata->plaintext.len)
12642 fragsz = tdata->plaintext.len;
12644 uint16_t plaintext_len = fragsz;
12646 retval = create_gmac_session(ts_params->valid_devs[0],
12647 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12649 if (retval == -ENOTSUP)
12650 return TEST_SKIPPED;
12654 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12655 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12656 "Failed to allocate input buffer in mempool");
12658 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12659 rte_pktmbuf_tailroom(ut_params->ibuf));
12661 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12663 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12665 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12667 trn_data += plaintext_len;
12669 buf = ut_params->ibuf;
12672 * Loop until no more fragments
12675 while (trn_data < tdata->plaintext.len) {
12677 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12678 (tdata->plaintext.len - trn_data) : fragsz;
12680 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12683 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12684 rte_pktmbuf_tailroom(buf));
12686 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12689 memcpy(plaintext, tdata->plaintext.data + trn_data,
12691 trn_data += to_trn;
12692 if (trn_data == tdata->plaintext.len)
12693 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12694 tdata->gmac_tag.len);
12696 ut_params->ibuf->nb_segs = segs;
12699 * Place digest at the end of the last buffer
12701 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12704 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12705 + tdata->gmac_tag.len);
12706 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12707 tdata->plaintext.len);
12710 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12711 tdata, digest_mem, digest_phys);
12716 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12718 ut_params->op->sym->m_src = ut_params->ibuf;
12720 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12721 return TEST_SKIPPED;
12723 TEST_ASSERT_NOT_NULL(
12724 process_crypto_request(ts_params->valid_devs[0],
12725 ut_params->op), "failed to process sym crypto op");
12727 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12728 "crypto op processing failed");
12730 auth_tag = digest_mem;
12731 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12732 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12734 tdata->gmac_tag.data,
12735 tdata->gmac_tag.len,
12736 "GMAC Generated auth tag not as expected");
12741 /* Segment size not multiple of block size (16B) */
12743 test_AES_GMAC_authentication_SGL_40B(void)
12745 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12749 test_AES_GMAC_authentication_SGL_80B(void)
12751 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12755 test_AES_GMAC_authentication_SGL_2048B(void)
12757 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12760 /* Segment size not multiple of block size (16B) */
12762 test_AES_GMAC_authentication_SGL_2047B(void)
12764 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12767 struct test_crypto_vector {
12768 enum rte_crypto_cipher_algorithm crypto_algo;
12769 unsigned int cipher_offset;
12770 unsigned int cipher_len;
12783 const uint8_t *data;
12788 const uint8_t *data;
12792 enum rte_crypto_auth_algorithm auth_algo;
12793 unsigned int auth_offset;
12801 const uint8_t *data;
12811 static const struct test_crypto_vector
12812 hmac_sha1_test_crypto_vector = {
12813 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12815 .data = plaintext_hash,
12820 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12821 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12822 0xDE, 0xF4, 0xDE, 0xAD
12828 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12829 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12830 0x3F, 0x91, 0x64, 0x59
12836 static const struct test_crypto_vector
12837 aes128_gmac_test_vector = {
12838 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12840 .data = plaintext_hash,
12845 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12846 0x08, 0x09, 0x0A, 0x0B
12852 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12853 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12859 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12860 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12866 static const struct test_crypto_vector
12867 aes128cbc_hmac_sha1_test_vector = {
12868 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12869 .cipher_offset = 0,
12873 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12874 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12880 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12881 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12886 .data = plaintext_hash,
12890 .data = ciphertext512_aes128cbc,
12893 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12897 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12898 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12899 0xDE, 0xF4, 0xDE, 0xAD
12905 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12906 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12907 0x18, 0x8C, 0x1D, 0x32
12913 static const struct test_crypto_vector
12914 aes128cbc_hmac_sha1_aad_test_vector = {
12915 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12916 .cipher_offset = 8,
12920 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12921 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12927 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12928 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12933 .data = plaintext_hash,
12937 .data = ciphertext512_aes128cbc_aad,
12940 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12944 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12945 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12946 0xDE, 0xF4, 0xDE, 0xAD
12952 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12953 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12954 0x62, 0x0F, 0xFB, 0x10
12961 data_corruption(uint8_t *data)
12967 tag_corruption(uint8_t *data, unsigned int tag_offset)
12969 data[tag_offset] += 1;
12973 create_auth_session(struct crypto_unittest_params *ut_params,
12975 const struct test_crypto_vector *reference,
12976 enum rte_crypto_auth_operation auth_op)
12978 struct crypto_testsuite_params *ts_params = &testsuite_params;
12979 uint8_t auth_key[reference->auth_key.len + 1];
12982 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12984 /* Setup Authentication Parameters */
12985 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12986 ut_params->auth_xform.auth.op = auth_op;
12987 ut_params->auth_xform.next = NULL;
12988 ut_params->auth_xform.auth.algo = reference->auth_algo;
12989 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12990 ut_params->auth_xform.auth.key.data = auth_key;
12991 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12993 /* Create Crypto session*/
12994 ut_params->sess = rte_cryptodev_sym_session_create(
12995 ts_params->session_mpool);
12996 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12998 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12999 &ut_params->auth_xform,
13000 ts_params->session_priv_mpool);
13006 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
13008 const struct test_crypto_vector *reference,
13009 enum rte_crypto_auth_operation auth_op,
13010 enum rte_crypto_cipher_operation cipher_op)
13012 struct crypto_testsuite_params *ts_params = &testsuite_params;
13013 uint8_t cipher_key[reference->cipher_key.len + 1];
13014 uint8_t auth_key[reference->auth_key.len + 1];
13017 memcpy(cipher_key, reference->cipher_key.data,
13018 reference->cipher_key.len);
13019 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13021 /* Setup Authentication Parameters */
13022 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13023 ut_params->auth_xform.auth.op = auth_op;
13024 ut_params->auth_xform.auth.algo = reference->auth_algo;
13025 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13026 ut_params->auth_xform.auth.key.data = auth_key;
13027 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13029 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
13030 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
13031 ut_params->auth_xform.auth.iv.length = reference->iv.len;
13033 ut_params->auth_xform.next = &ut_params->cipher_xform;
13035 /* Setup Cipher Parameters */
13036 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13037 ut_params->cipher_xform.next = NULL;
13038 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13039 ut_params->cipher_xform.cipher.op = cipher_op;
13040 ut_params->cipher_xform.cipher.key.data = cipher_key;
13041 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13042 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13043 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13046 /* Create Crypto session*/
13047 ut_params->sess = rte_cryptodev_sym_session_create(
13048 ts_params->session_mpool);
13049 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13051 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
13052 &ut_params->auth_xform,
13053 ts_params->session_priv_mpool);
13059 create_auth_operation(struct crypto_testsuite_params *ts_params,
13060 struct crypto_unittest_params *ut_params,
13061 const struct test_crypto_vector *reference,
13062 unsigned int auth_generate)
13064 /* Generate Crypto op data structure */
13065 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13066 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13067 TEST_ASSERT_NOT_NULL(ut_params->op,
13068 "Failed to allocate pktmbuf offload");
13070 /* Set crypto operation data parameters */
13071 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13073 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13075 /* set crypto operation source mbuf */
13076 sym_op->m_src = ut_params->ibuf;
13079 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13080 ut_params->ibuf, reference->digest.len);
13082 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13083 "no room to append auth tag");
13085 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13086 ut_params->ibuf, reference->plaintext.len);
13089 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13091 memcpy(sym_op->auth.digest.data,
13092 reference->digest.data,
13093 reference->digest.len);
13095 debug_hexdump(stdout, "digest:",
13096 sym_op->auth.digest.data,
13097 reference->digest.len);
13099 sym_op->auth.data.length = reference->plaintext.len;
13100 sym_op->auth.data.offset = 0;
13106 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
13107 struct crypto_unittest_params *ut_params,
13108 const struct test_crypto_vector *reference,
13109 unsigned int auth_generate)
13111 /* Generate Crypto op data structure */
13112 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13113 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13114 TEST_ASSERT_NOT_NULL(ut_params->op,
13115 "Failed to allocate pktmbuf offload");
13117 /* Set crypto operation data parameters */
13118 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13120 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13122 /* set crypto operation source mbuf */
13123 sym_op->m_src = ut_params->ibuf;
13126 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13127 ut_params->ibuf, reference->digest.len);
13129 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13130 "no room to append auth tag");
13132 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13133 ut_params->ibuf, reference->ciphertext.len);
13136 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13138 memcpy(sym_op->auth.digest.data,
13139 reference->digest.data,
13140 reference->digest.len);
13142 debug_hexdump(stdout, "digest:",
13143 sym_op->auth.digest.data,
13144 reference->digest.len);
13146 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13147 reference->iv.data, reference->iv.len);
13149 sym_op->cipher.data.length = 0;
13150 sym_op->cipher.data.offset = 0;
13152 sym_op->auth.data.length = reference->plaintext.len;
13153 sym_op->auth.data.offset = 0;
13159 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
13160 struct crypto_unittest_params *ut_params,
13161 const struct test_crypto_vector *reference,
13162 unsigned int auth_generate)
13164 /* Generate Crypto op data structure */
13165 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13166 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13167 TEST_ASSERT_NOT_NULL(ut_params->op,
13168 "Failed to allocate pktmbuf offload");
13170 /* Set crypto operation data parameters */
13171 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13173 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13175 /* set crypto operation source mbuf */
13176 sym_op->m_src = ut_params->ibuf;
13179 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13180 ut_params->ibuf, reference->digest.len);
13182 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13183 "no room to append auth tag");
13185 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13186 ut_params->ibuf, reference->ciphertext.len);
13189 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13191 memcpy(sym_op->auth.digest.data,
13192 reference->digest.data,
13193 reference->digest.len);
13195 debug_hexdump(stdout, "digest:",
13196 sym_op->auth.digest.data,
13197 reference->digest.len);
13199 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13200 reference->iv.data, reference->iv.len);
13202 sym_op->cipher.data.length = reference->cipher_len;
13203 sym_op->cipher.data.offset = reference->cipher_offset;
13205 sym_op->auth.data.length = reference->plaintext.len;
13206 sym_op->auth.data.offset = reference->auth_offset;
13212 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13213 struct crypto_unittest_params *ut_params,
13214 const struct test_crypto_vector *reference)
13216 return create_auth_operation(ts_params, ut_params, reference, 0);
13220 create_auth_verify_GMAC_operation(
13221 struct crypto_testsuite_params *ts_params,
13222 struct crypto_unittest_params *ut_params,
13223 const struct test_crypto_vector *reference)
13225 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
13229 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13230 struct crypto_unittest_params *ut_params,
13231 const struct test_crypto_vector *reference)
13233 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
13237 test_authentication_verify_fail_when_data_corruption(
13238 struct crypto_testsuite_params *ts_params,
13239 struct crypto_unittest_params *ut_params,
13240 const struct test_crypto_vector *reference,
13241 unsigned int data_corrupted)
13245 uint8_t *plaintext;
13246 struct rte_cryptodev_info dev_info;
13248 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13249 uint64_t feat_flags = dev_info.feature_flags;
13251 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13252 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13253 printf("Device doesn't support RAW data-path APIs.\n");
13254 return TEST_SKIPPED;
13257 /* Verify the capabilities */
13258 struct rte_cryptodev_sym_capability_idx cap_idx;
13259 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13260 cap_idx.algo.auth = reference->auth_algo;
13261 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13263 return TEST_SKIPPED;
13266 /* Create session */
13267 retval = create_auth_session(ut_params,
13268 ts_params->valid_devs[0],
13270 RTE_CRYPTO_AUTH_OP_VERIFY);
13272 if (retval == -ENOTSUP)
13273 return TEST_SKIPPED;
13277 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13278 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13279 "Failed to allocate input buffer in mempool");
13281 /* clear mbuf payload */
13282 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13283 rte_pktmbuf_tailroom(ut_params->ibuf));
13285 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13286 reference->plaintext.len);
13287 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13288 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13290 debug_hexdump(stdout, "plaintext:", plaintext,
13291 reference->plaintext.len);
13293 /* Create operation */
13294 retval = create_auth_verify_operation(ts_params, ut_params, reference);
13299 if (data_corrupted)
13300 data_corruption(plaintext);
13302 tag_corruption(plaintext, reference->plaintext.len);
13304 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13305 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13307 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13308 RTE_CRYPTO_OP_STATUS_SUCCESS,
13309 "authentication not failed");
13310 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13311 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13312 ut_params->op, 0, 1, 0, 0);
13314 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13317 if (ut_params->op == NULL)
13319 else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
13326 test_authentication_verify_GMAC_fail_when_corruption(
13327 struct crypto_testsuite_params *ts_params,
13328 struct crypto_unittest_params *ut_params,
13329 const struct test_crypto_vector *reference,
13330 unsigned int data_corrupted)
13333 uint8_t *plaintext;
13334 struct rte_cryptodev_info dev_info;
13336 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13337 uint64_t feat_flags = dev_info.feature_flags;
13339 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13340 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13341 printf("Device doesn't support RAW data-path APIs.\n");
13342 return TEST_SKIPPED;
13345 /* Verify the capabilities */
13346 struct rte_cryptodev_sym_capability_idx cap_idx;
13347 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13348 cap_idx.algo.auth = reference->auth_algo;
13349 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13351 return TEST_SKIPPED;
13353 /* Create session */
13354 retval = create_auth_cipher_session(ut_params,
13355 ts_params->valid_devs[0],
13357 RTE_CRYPTO_AUTH_OP_VERIFY,
13358 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13362 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13363 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13364 "Failed to allocate input buffer in mempool");
13366 /* clear mbuf payload */
13367 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13368 rte_pktmbuf_tailroom(ut_params->ibuf));
13370 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13371 reference->plaintext.len);
13372 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13373 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13375 debug_hexdump(stdout, "plaintext:", plaintext,
13376 reference->plaintext.len);
13378 /* Create operation */
13379 retval = create_auth_verify_GMAC_operation(ts_params,
13386 if (data_corrupted)
13387 data_corruption(plaintext);
13389 tag_corruption(plaintext, reference->aad.len);
13391 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13392 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13394 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13395 RTE_CRYPTO_OP_STATUS_SUCCESS,
13396 "authentication not failed");
13397 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13398 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13399 ut_params->op, 0, 1, 0, 0);
13401 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13403 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13410 test_authenticated_decryption_fail_when_corruption(
13411 struct crypto_testsuite_params *ts_params,
13412 struct crypto_unittest_params *ut_params,
13413 const struct test_crypto_vector *reference,
13414 unsigned int data_corrupted)
13418 uint8_t *ciphertext;
13419 struct rte_cryptodev_info dev_info;
13421 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13422 uint64_t feat_flags = dev_info.feature_flags;
13424 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13425 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13426 printf("Device doesn't support RAW data-path APIs.\n");
13427 return TEST_SKIPPED;
13430 /* Verify the capabilities */
13431 struct rte_cryptodev_sym_capability_idx cap_idx;
13432 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13433 cap_idx.algo.auth = reference->auth_algo;
13434 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13436 return TEST_SKIPPED;
13437 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13438 cap_idx.algo.cipher = reference->crypto_algo;
13439 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13441 return TEST_SKIPPED;
13443 /* Create session */
13444 retval = create_auth_cipher_session(ut_params,
13445 ts_params->valid_devs[0],
13447 RTE_CRYPTO_AUTH_OP_VERIFY,
13448 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13450 if (retval == -ENOTSUP)
13451 return TEST_SKIPPED;
13455 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13456 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13457 "Failed to allocate input buffer in mempool");
13459 /* clear mbuf payload */
13460 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13461 rte_pktmbuf_tailroom(ut_params->ibuf));
13463 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13464 reference->ciphertext.len);
13465 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13466 memcpy(ciphertext, reference->ciphertext.data,
13467 reference->ciphertext.len);
13469 /* Create operation */
13470 retval = create_cipher_auth_verify_operation(ts_params,
13477 if (data_corrupted)
13478 data_corruption(ciphertext);
13480 tag_corruption(ciphertext, reference->ciphertext.len);
13482 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13483 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13485 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13486 RTE_CRYPTO_OP_STATUS_SUCCESS,
13487 "authentication not failed");
13488 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13489 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13490 ut_params->op, 1, 1, 0, 0);
13492 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13494 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13501 test_authenticated_encrypt_with_esn(
13502 struct crypto_testsuite_params *ts_params,
13503 struct crypto_unittest_params *ut_params,
13504 const struct test_crypto_vector *reference)
13508 uint8_t *authciphertext, *plaintext, *auth_tag;
13509 uint16_t plaintext_pad_len;
13510 uint8_t cipher_key[reference->cipher_key.len + 1];
13511 uint8_t auth_key[reference->auth_key.len + 1];
13512 struct rte_cryptodev_info dev_info;
13515 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13516 uint64_t feat_flags = dev_info.feature_flags;
13518 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13519 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13520 printf("Device doesn't support RAW data-path APIs.\n");
13521 return TEST_SKIPPED;
13524 /* Verify the capabilities */
13525 struct rte_cryptodev_sym_capability_idx cap_idx;
13526 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13527 cap_idx.algo.auth = reference->auth_algo;
13528 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13530 return TEST_SKIPPED;
13531 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13532 cap_idx.algo.cipher = reference->crypto_algo;
13533 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13535 return TEST_SKIPPED;
13537 /* Create session */
13538 memcpy(cipher_key, reference->cipher_key.data,
13539 reference->cipher_key.len);
13540 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13542 /* Setup Cipher Parameters */
13543 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13544 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13545 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13546 ut_params->cipher_xform.cipher.key.data = cipher_key;
13547 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13548 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13549 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13551 ut_params->cipher_xform.next = &ut_params->auth_xform;
13553 /* Setup Authentication Parameters */
13554 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13555 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13556 ut_params->auth_xform.auth.algo = reference->auth_algo;
13557 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13558 ut_params->auth_xform.auth.key.data = auth_key;
13559 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13560 ut_params->auth_xform.next = NULL;
13562 /* Create Crypto session*/
13563 ut_params->sess = rte_cryptodev_sym_session_create(
13564 ts_params->session_mpool);
13565 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13567 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13569 &ut_params->cipher_xform,
13570 ts_params->session_priv_mpool);
13572 if (status == -ENOTSUP)
13573 return TEST_SKIPPED;
13575 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
13577 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13578 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13579 "Failed to allocate input buffer in mempool");
13581 /* clear mbuf payload */
13582 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13583 rte_pktmbuf_tailroom(ut_params->ibuf));
13585 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13586 reference->plaintext.len);
13587 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13588 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13590 /* Create operation */
13591 retval = create_cipher_auth_operation(ts_params,
13598 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13599 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13601 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13602 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13603 ut_params->op, 1, 1, 0, 0);
13605 ut_params->op = process_crypto_request(
13606 ts_params->valid_devs[0], ut_params->op);
13608 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13610 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13611 "crypto op processing failed");
13613 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13615 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13616 ut_params->op->sym->auth.data.offset);
13617 auth_tag = authciphertext + plaintext_pad_len;
13618 debug_hexdump(stdout, "ciphertext:", authciphertext,
13619 reference->ciphertext.len);
13620 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13622 /* Validate obuf */
13623 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13625 reference->ciphertext.data,
13626 reference->ciphertext.len,
13627 "Ciphertext data not as expected");
13629 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13631 reference->digest.data,
13632 reference->digest.len,
13633 "Generated digest not as expected");
13635 return TEST_SUCCESS;
13640 test_authenticated_decrypt_with_esn(
13641 struct crypto_testsuite_params *ts_params,
13642 struct crypto_unittest_params *ut_params,
13643 const struct test_crypto_vector *reference)
13647 uint8_t *ciphertext;
13648 uint8_t cipher_key[reference->cipher_key.len + 1];
13649 uint8_t auth_key[reference->auth_key.len + 1];
13650 struct rte_cryptodev_info dev_info;
13652 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13653 uint64_t feat_flags = dev_info.feature_flags;
13655 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13656 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13657 printf("Device doesn't support RAW data-path APIs.\n");
13658 return TEST_SKIPPED;
13661 /* Verify the capabilities */
13662 struct rte_cryptodev_sym_capability_idx cap_idx;
13663 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13664 cap_idx.algo.auth = reference->auth_algo;
13665 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13667 return TEST_SKIPPED;
13668 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13669 cap_idx.algo.cipher = reference->crypto_algo;
13670 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13672 return TEST_SKIPPED;
13674 /* Create session */
13675 memcpy(cipher_key, reference->cipher_key.data,
13676 reference->cipher_key.len);
13677 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13679 /* Setup Authentication Parameters */
13680 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13681 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13682 ut_params->auth_xform.auth.algo = reference->auth_algo;
13683 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13684 ut_params->auth_xform.auth.key.data = auth_key;
13685 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13686 ut_params->auth_xform.next = &ut_params->cipher_xform;
13688 /* Setup Cipher Parameters */
13689 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13690 ut_params->cipher_xform.next = NULL;
13691 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13692 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13693 ut_params->cipher_xform.cipher.key.data = cipher_key;
13694 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13695 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13696 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13698 /* Create Crypto session*/
13699 ut_params->sess = rte_cryptodev_sym_session_create(
13700 ts_params->session_mpool);
13701 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13703 retval = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13705 &ut_params->auth_xform,
13706 ts_params->session_priv_mpool);
13708 if (retval == -ENOTSUP)
13709 return TEST_SKIPPED;
13711 TEST_ASSERT_EQUAL(retval, 0, "Session init failed");
13713 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13714 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13715 "Failed to allocate input buffer in mempool");
13717 /* clear mbuf payload */
13718 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13719 rte_pktmbuf_tailroom(ut_params->ibuf));
13721 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13722 reference->ciphertext.len);
13723 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13724 memcpy(ciphertext, reference->ciphertext.data,
13725 reference->ciphertext.len);
13727 /* Create operation */
13728 retval = create_cipher_auth_verify_operation(ts_params,
13735 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13736 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13738 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13739 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13740 ut_params->op, 1, 1, 0, 0);
13742 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13745 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13746 TEST_ASSERT_EQUAL(ut_params->op->status,
13747 RTE_CRYPTO_OP_STATUS_SUCCESS,
13748 "crypto op processing passed");
13750 ut_params->obuf = ut_params->op->sym->m_src;
13751 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13757 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13758 const struct aead_test_data *tdata,
13759 void *digest_mem, uint64_t digest_phys)
13761 struct crypto_testsuite_params *ts_params = &testsuite_params;
13762 struct crypto_unittest_params *ut_params = &unittest_params;
13764 const unsigned int auth_tag_len = tdata->auth_tag.len;
13765 const unsigned int iv_len = tdata->iv.len;
13766 unsigned int aad_len = tdata->aad.len;
13767 unsigned int aad_len_pad = 0;
13769 /* Generate Crypto op data structure */
13770 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13771 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13772 TEST_ASSERT_NOT_NULL(ut_params->op,
13773 "Failed to allocate symmetric crypto operation struct");
13775 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13777 sym_op->aead.digest.data = digest_mem;
13779 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13780 "no room to append digest");
13782 sym_op->aead.digest.phys_addr = digest_phys;
13784 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13785 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13787 debug_hexdump(stdout, "digest:",
13788 sym_op->aead.digest.data,
13792 /* Append aad data */
13793 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13794 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13795 uint8_t *, IV_OFFSET);
13797 /* Copy IV 1 byte after the IV pointer, according to the API */
13798 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13800 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13802 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13803 ut_params->ibuf, aad_len);
13804 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13805 "no room to prepend aad");
13806 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13809 memset(sym_op->aead.aad.data, 0, aad_len);
13810 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
13811 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13813 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13814 debug_hexdump(stdout, "aad:",
13815 sym_op->aead.aad.data, aad_len);
13817 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13818 uint8_t *, IV_OFFSET);
13820 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13822 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13824 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13825 ut_params->ibuf, aad_len_pad);
13826 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13827 "no room to prepend aad");
13828 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13831 memset(sym_op->aead.aad.data, 0, aad_len);
13832 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13834 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13835 debug_hexdump(stdout, "aad:",
13836 sym_op->aead.aad.data, aad_len);
13839 sym_op->aead.data.length = tdata->plaintext.len;
13840 sym_op->aead.data.offset = aad_len_pad;
13845 #define SGL_MAX_NO 16
13848 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13849 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13851 struct crypto_testsuite_params *ts_params = &testsuite_params;
13852 struct crypto_unittest_params *ut_params = &unittest_params;
13853 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13856 int to_trn_tbl[SGL_MAX_NO];
13858 unsigned int trn_data = 0;
13859 uint8_t *plaintext, *ciphertext, *auth_tag;
13860 struct rte_cryptodev_info dev_info;
13862 /* Verify the capabilities */
13863 struct rte_cryptodev_sym_capability_idx cap_idx;
13864 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13865 cap_idx.algo.aead = tdata->algo;
13866 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13868 return TEST_SKIPPED;
13870 /* OOP not supported with CPU crypto */
13871 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13872 return TEST_SKIPPED;
13874 /* Detailed check for the particular SGL support flag */
13875 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13877 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13878 if (sgl_in && (!(dev_info.feature_flags &
13879 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13880 return TEST_SKIPPED;
13882 uint64_t feat_flags = dev_info.feature_flags;
13884 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13885 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13886 printf("Device doesn't support RAW data-path APIs.\n");
13887 return TEST_SKIPPED;
13890 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13891 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13892 tdata->plaintext.len;
13893 /* Raw data path API does not support OOP */
13894 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13895 return TEST_SKIPPED;
13896 if (sgl_in && !sgl_out) {
13897 if (!(dev_info.feature_flags &
13898 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13899 return TEST_SKIPPED;
13900 } else if (!sgl_in && sgl_out) {
13901 if (!(dev_info.feature_flags &
13902 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13903 return TEST_SKIPPED;
13904 } else if (sgl_in && sgl_out) {
13905 if (!(dev_info.feature_flags &
13906 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13907 return TEST_SKIPPED;
13911 if (fragsz > tdata->plaintext.len)
13912 fragsz = tdata->plaintext.len;
13914 uint16_t plaintext_len = fragsz;
13915 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13917 if (fragsz_oop > tdata->plaintext.len)
13918 frag_size_oop = tdata->plaintext.len;
13921 void *digest_mem = NULL;
13923 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13925 if (tdata->plaintext.len % fragsz != 0) {
13926 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13929 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13934 * For out-op-place we need to alloc another mbuf
13937 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13938 rte_pktmbuf_append(ut_params->obuf,
13939 frag_size_oop + prepend_len);
13940 buf_oop = ut_params->obuf;
13943 /* Create AEAD session */
13944 retval = create_aead_session(ts_params->valid_devs[0],
13946 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13947 tdata->key.data, tdata->key.len,
13948 tdata->aad.len, tdata->auth_tag.len,
13953 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13955 /* clear mbuf payload */
13956 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13957 rte_pktmbuf_tailroom(ut_params->ibuf));
13959 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13962 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13964 trn_data += plaintext_len;
13966 buf = ut_params->ibuf;
13969 * Loop until no more fragments
13972 while (trn_data < tdata->plaintext.len) {
13974 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13975 (tdata->plaintext.len - trn_data) : fragsz;
13977 to_trn_tbl[ecx++] = to_trn;
13979 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13982 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13983 rte_pktmbuf_tailroom(buf));
13986 if (oop && !fragsz_oop) {
13987 buf_last_oop = buf_oop->next =
13988 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13989 buf_oop = buf_oop->next;
13990 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13991 0, rte_pktmbuf_tailroom(buf_oop));
13992 rte_pktmbuf_append(buf_oop, to_trn);
13995 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13998 memcpy(plaintext, tdata->plaintext.data + trn_data,
14000 trn_data += to_trn;
14001 if (trn_data == tdata->plaintext.len) {
14004 digest_mem = rte_pktmbuf_append(buf_oop,
14005 tdata->auth_tag.len);
14007 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14008 tdata->auth_tag.len);
14012 uint64_t digest_phys = 0;
14014 ut_params->ibuf->nb_segs = segs;
14017 if (fragsz_oop && oop) {
14021 if (frag_size_oop == tdata->plaintext.len) {
14022 digest_mem = rte_pktmbuf_append(ut_params->obuf,
14023 tdata->auth_tag.len);
14025 digest_phys = rte_pktmbuf_iova_offset(
14027 tdata->plaintext.len + prepend_len);
14030 trn_data = frag_size_oop;
14031 while (trn_data < tdata->plaintext.len) {
14034 (tdata->plaintext.len - trn_data <
14036 (tdata->plaintext.len - trn_data) :
14039 to_trn_tbl[ecx++] = to_trn;
14041 buf_last_oop = buf_oop->next =
14042 rte_pktmbuf_alloc(ts_params->mbuf_pool);
14043 buf_oop = buf_oop->next;
14044 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14045 0, rte_pktmbuf_tailroom(buf_oop));
14046 rte_pktmbuf_append(buf_oop, to_trn);
14048 trn_data += to_trn;
14050 if (trn_data == tdata->plaintext.len) {
14051 digest_mem = rte_pktmbuf_append(buf_oop,
14052 tdata->auth_tag.len);
14056 ut_params->obuf->nb_segs = segs;
14060 * Place digest at the end of the last buffer
14063 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14064 if (oop && buf_last_oop)
14065 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
14067 if (!digest_mem && !oop) {
14068 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14069 + tdata->auth_tag.len);
14070 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14071 tdata->plaintext.len);
14074 /* Create AEAD operation */
14075 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
14076 tdata, digest_mem, digest_phys);
14081 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14083 ut_params->op->sym->m_src = ut_params->ibuf;
14085 ut_params->op->sym->m_dst = ut_params->obuf;
14087 /* Process crypto operation */
14088 if (oop == IN_PLACE &&
14089 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14090 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
14091 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14092 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14093 ut_params->op, 0, 0, 0, 0);
14095 TEST_ASSERT_NOT_NULL(
14096 process_crypto_request(ts_params->valid_devs[0],
14097 ut_params->op), "failed to process sym crypto op");
14099 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14100 "crypto op processing failed");
14103 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
14104 uint8_t *, prepend_len);
14106 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14107 uint8_t *, prepend_len);
14111 fragsz = fragsz_oop;
14113 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14115 tdata->ciphertext.data,
14117 "Ciphertext data not as expected");
14119 buf = ut_params->op->sym->m_src->next;
14121 buf = ut_params->op->sym->m_dst->next;
14123 unsigned int off = fragsz;
14127 ciphertext = rte_pktmbuf_mtod(buf,
14130 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14132 tdata->ciphertext.data + off,
14134 "Ciphertext data not as expected");
14136 off += to_trn_tbl[ecx++];
14140 auth_tag = digest_mem;
14141 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14143 tdata->auth_tag.data,
14144 tdata->auth_tag.len,
14145 "Generated auth tag not as expected");
14151 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
14153 return test_authenticated_encryption_SGL(
14154 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
14158 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
14160 return test_authenticated_encryption_SGL(
14161 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
14165 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
14167 return test_authenticated_encryption_SGL(
14168 &gcm_test_case_8, OUT_OF_PLACE, 400,
14169 gcm_test_case_8.plaintext.len);
14173 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
14175 /* This test is not for OPENSSL PMD */
14176 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14177 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
14178 return TEST_SKIPPED;
14180 return test_authenticated_encryption_SGL(
14181 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
14185 test_authentication_verify_fail_when_data_corrupted(
14186 struct crypto_testsuite_params *ts_params,
14187 struct crypto_unittest_params *ut_params,
14188 const struct test_crypto_vector *reference)
14190 return test_authentication_verify_fail_when_data_corruption(
14191 ts_params, ut_params, reference, 1);
14195 test_authentication_verify_fail_when_tag_corrupted(
14196 struct crypto_testsuite_params *ts_params,
14197 struct crypto_unittest_params *ut_params,
14198 const struct test_crypto_vector *reference)
14200 return test_authentication_verify_fail_when_data_corruption(
14201 ts_params, ut_params, reference, 0);
14205 test_authentication_verify_GMAC_fail_when_data_corrupted(
14206 struct crypto_testsuite_params *ts_params,
14207 struct crypto_unittest_params *ut_params,
14208 const struct test_crypto_vector *reference)
14210 return test_authentication_verify_GMAC_fail_when_corruption(
14211 ts_params, ut_params, reference, 1);
14215 test_authentication_verify_GMAC_fail_when_tag_corrupted(
14216 struct crypto_testsuite_params *ts_params,
14217 struct crypto_unittest_params *ut_params,
14218 const struct test_crypto_vector *reference)
14220 return test_authentication_verify_GMAC_fail_when_corruption(
14221 ts_params, ut_params, reference, 0);
14225 test_authenticated_decryption_fail_when_data_corrupted(
14226 struct crypto_testsuite_params *ts_params,
14227 struct crypto_unittest_params *ut_params,
14228 const struct test_crypto_vector *reference)
14230 return test_authenticated_decryption_fail_when_corruption(
14231 ts_params, ut_params, reference, 1);
14235 test_authenticated_decryption_fail_when_tag_corrupted(
14236 struct crypto_testsuite_params *ts_params,
14237 struct crypto_unittest_params *ut_params,
14238 const struct test_crypto_vector *reference)
14240 return test_authenticated_decryption_fail_when_corruption(
14241 ts_params, ut_params, reference, 0);
14245 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
14247 return test_authentication_verify_fail_when_data_corrupted(
14248 &testsuite_params, &unittest_params,
14249 &hmac_sha1_test_crypto_vector);
14253 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
14255 return test_authentication_verify_fail_when_tag_corrupted(
14256 &testsuite_params, &unittest_params,
14257 &hmac_sha1_test_crypto_vector);
14261 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
14263 return test_authentication_verify_GMAC_fail_when_data_corrupted(
14264 &testsuite_params, &unittest_params,
14265 &aes128_gmac_test_vector);
14269 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
14271 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
14272 &testsuite_params, &unittest_params,
14273 &aes128_gmac_test_vector);
14277 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
14279 return test_authenticated_decryption_fail_when_data_corrupted(
14282 &aes128cbc_hmac_sha1_test_vector);
14286 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
14288 return test_authenticated_decryption_fail_when_tag_corrupted(
14291 &aes128cbc_hmac_sha1_test_vector);
14295 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14297 return test_authenticated_encrypt_with_esn(
14300 &aes128cbc_hmac_sha1_aad_test_vector);
14304 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14306 return test_authenticated_decrypt_with_esn(
14309 &aes128cbc_hmac_sha1_aad_test_vector);
14313 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
14315 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
14319 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
14321 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
14325 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
14327 return test_authenticated_encryption_SGL(
14328 &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
14329 chacha20_poly1305_case_2.plaintext.len);
14332 #ifdef RTE_CRYPTO_SCHEDULER
14334 /* global AESNI worker IDs for the scheduler test */
14335 uint8_t aesni_ids[2];
14338 scheduler_testsuite_setup(void)
14341 int32_t nb_devs, ret;
14342 char vdev_args[VDEV_ARGS_SIZE] = {""};
14343 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14344 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
14345 uint16_t worker_core_count = 0;
14346 uint16_t socket_id = 0;
14348 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14349 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14351 /* Identify the Worker Cores
14352 * Use 2 worker cores for the device args
14354 RTE_LCORE_FOREACH_WORKER(i) {
14355 if (worker_core_count > 1)
14357 snprintf(vdev_args, sizeof(vdev_args),
14358 "%s%d", temp_str, i);
14359 strcpy(temp_str, vdev_args);
14360 strlcat(temp_str, ";", sizeof(temp_str));
14361 worker_core_count++;
14362 socket_id = rte_lcore_to_socket_id(i);
14364 if (worker_core_count != 2) {
14365 RTE_LOG(ERR, USER1,
14366 "Cryptodev scheduler test require at least "
14367 "two worker cores to run. "
14368 "Please use the correct coremask.\n");
14369 return TEST_FAILED;
14371 strcpy(temp_str, vdev_args);
14372 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14373 temp_str, socket_id);
14374 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14375 nb_devs = rte_cryptodev_device_count_by_driver(
14376 rte_cryptodev_driver_id_get(
14377 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14379 ret = rte_vdev_init(
14380 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14382 TEST_ASSERT(ret == 0,
14383 "Failed to create instance %u of pmd : %s",
14384 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14387 return testsuite_setup();
14391 test_scheduler_attach_worker_op(void)
14393 struct crypto_testsuite_params *ts_params = &testsuite_params;
14394 uint8_t sched_id = ts_params->valid_devs[0];
14395 uint32_t i, nb_devs_attached = 0;
14397 char vdev_name[32];
14398 unsigned int count = rte_cryptodev_count();
14400 /* create 2 AESNI_MB vdevs on top of existing devices */
14401 for (i = count; i < count + 2; i++) {
14402 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14403 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14405 ret = rte_vdev_init(vdev_name, NULL);
14407 TEST_ASSERT(ret == 0,
14408 "Failed to create instance %u of"
14410 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14413 RTE_LOG(ERR, USER1,
14414 "Failed to create 2 AESNI MB PMDs.\n");
14415 return TEST_SKIPPED;
14419 /* attach 2 AESNI_MB cdevs */
14420 for (i = count; i < count + 2; i++) {
14421 struct rte_cryptodev_info info;
14422 unsigned int session_size;
14424 rte_cryptodev_info_get(i, &info);
14425 if (info.driver_id != rte_cryptodev_driver_id_get(
14426 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14429 session_size = rte_cryptodev_sym_get_private_session_size(i);
14431 * Create the session mempool again, since now there are new devices
14432 * to use the mempool.
14434 if (ts_params->session_mpool) {
14435 rte_mempool_free(ts_params->session_mpool);
14436 ts_params->session_mpool = NULL;
14438 if (ts_params->session_priv_mpool) {
14439 rte_mempool_free(ts_params->session_priv_mpool);
14440 ts_params->session_priv_mpool = NULL;
14443 if (info.sym.max_nb_sessions != 0 &&
14444 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14445 RTE_LOG(ERR, USER1,
14446 "Device does not support "
14447 "at least %u sessions\n",
14449 return TEST_FAILED;
14452 * Create mempool with maximum number of sessions,
14453 * to include the session headers
14455 if (ts_params->session_mpool == NULL) {
14456 ts_params->session_mpool =
14457 rte_cryptodev_sym_session_pool_create(
14459 MAX_NB_SESSIONS, 0, 0, 0,
14461 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14462 "session mempool allocation failed");
14466 * Create mempool with maximum number of sessions,
14467 * to include device specific session private data
14469 if (ts_params->session_priv_mpool == NULL) {
14470 ts_params->session_priv_mpool = rte_mempool_create(
14471 "test_sess_mp_priv",
14474 0, 0, NULL, NULL, NULL,
14475 NULL, SOCKET_ID_ANY,
14478 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14479 "session mempool allocation failed");
14482 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14483 ts_params->qp_conf.mp_session_private =
14484 ts_params->session_priv_mpool;
14486 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14489 TEST_ASSERT(ret == 0,
14490 "Failed to attach device %u of pmd : %s", i,
14491 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14493 aesni_ids[nb_devs_attached] = (uint8_t)i;
14495 nb_devs_attached++;
14502 test_scheduler_detach_worker_op(void)
14504 struct crypto_testsuite_params *ts_params = &testsuite_params;
14505 uint8_t sched_id = ts_params->valid_devs[0];
14509 for (i = 0; i < 2; i++) {
14510 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14512 TEST_ASSERT(ret == 0,
14513 "Failed to detach device %u", aesni_ids[i]);
14520 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14522 struct crypto_testsuite_params *ts_params = &testsuite_params;
14523 uint8_t sched_id = ts_params->valid_devs[0];
14525 return rte_cryptodev_scheduler_mode_set(sched_id,
14530 test_scheduler_mode_roundrobin_op(void)
14532 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14533 0, "Failed to set roundrobin mode");
14539 test_scheduler_mode_multicore_op(void)
14541 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14542 0, "Failed to set multicore mode");
14548 test_scheduler_mode_failover_op(void)
14550 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
14551 0, "Failed to set failover mode");
14557 test_scheduler_mode_pkt_size_distr_op(void)
14559 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
14560 0, "Failed to set pktsize mode");
14566 scheduler_multicore_testsuite_setup(void)
14568 if (test_scheduler_attach_worker_op() < 0)
14569 return TEST_SKIPPED;
14570 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
14571 return TEST_SKIPPED;
14576 scheduler_roundrobin_testsuite_setup(void)
14578 if (test_scheduler_attach_worker_op() < 0)
14579 return TEST_SKIPPED;
14580 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
14581 return TEST_SKIPPED;
14586 scheduler_failover_testsuite_setup(void)
14588 if (test_scheduler_attach_worker_op() < 0)
14589 return TEST_SKIPPED;
14590 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
14591 return TEST_SKIPPED;
14596 scheduler_pkt_size_distr_testsuite_setup(void)
14598 if (test_scheduler_attach_worker_op() < 0)
14599 return TEST_SKIPPED;
14600 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14601 return TEST_SKIPPED;
14606 scheduler_mode_testsuite_teardown(void)
14608 test_scheduler_detach_worker_op();
14611 #endif /* RTE_CRYPTO_SCHEDULER */
14613 static struct unit_test_suite end_testsuite = {
14614 .suite_name = NULL,
14617 .unit_test_suites = NULL
14620 #ifdef RTE_LIB_SECURITY
14621 static struct unit_test_suite ipsec_proto_testsuite = {
14622 .suite_name = "IPsec Proto Unit Test Suite",
14623 .setup = ipsec_proto_testsuite_setup,
14624 .unit_test_cases = {
14625 TEST_CASE_NAMED_WITH_DATA(
14626 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14627 ut_setup_security, ut_teardown,
14628 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
14629 TEST_CASE_NAMED_WITH_DATA(
14630 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14631 ut_setup_security, ut_teardown,
14632 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
14633 TEST_CASE_NAMED_WITH_DATA(
14634 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14635 ut_setup_security, ut_teardown,
14636 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
14637 TEST_CASE_NAMED_WITH_DATA(
14638 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14639 ut_setup_security, ut_teardown,
14640 test_ipsec_proto_known_vec,
14641 &pkt_aes_128_cbc_hmac_sha256),
14642 TEST_CASE_NAMED_WITH_DATA(
14643 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
14644 ut_setup_security, ut_teardown,
14645 test_ipsec_proto_known_vec,
14646 &pkt_aes_128_cbc_hmac_sha384),
14647 TEST_CASE_NAMED_WITH_DATA(
14648 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
14649 ut_setup_security, ut_teardown,
14650 test_ipsec_proto_known_vec,
14651 &pkt_aes_128_cbc_hmac_sha512),
14652 TEST_CASE_NAMED_WITH_DATA(
14653 "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
14654 ut_setup_security, ut_teardown,
14655 test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
14656 TEST_CASE_NAMED_WITH_DATA(
14657 "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14658 ut_setup_security, ut_teardown,
14659 test_ipsec_proto_known_vec,
14660 &pkt_aes_128_cbc_hmac_sha256_v6),
14661 TEST_CASE_NAMED_WITH_DATA(
14662 "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
14663 ut_setup_security, ut_teardown,
14664 test_ipsec_proto_known_vec,
14665 &pkt_null_aes_xcbc),
14666 TEST_CASE_NAMED_WITH_DATA(
14667 "Outbound fragmented packet",
14668 ut_setup_security, ut_teardown,
14669 test_ipsec_proto_known_vec_fragmented,
14670 &pkt_aes_128_gcm_frag),
14671 TEST_CASE_NAMED_WITH_DATA(
14672 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14673 ut_setup_security, ut_teardown,
14674 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14675 TEST_CASE_NAMED_WITH_DATA(
14676 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14677 ut_setup_security, ut_teardown,
14678 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14679 TEST_CASE_NAMED_WITH_DATA(
14680 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14681 ut_setup_security, ut_teardown,
14682 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14683 TEST_CASE_NAMED_WITH_DATA(
14684 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
14685 ut_setup_security, ut_teardown,
14686 test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
14687 TEST_CASE_NAMED_WITH_DATA(
14688 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14689 ut_setup_security, ut_teardown,
14690 test_ipsec_proto_known_vec_inb,
14691 &pkt_aes_128_cbc_hmac_sha256),
14692 TEST_CASE_NAMED_WITH_DATA(
14693 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
14694 ut_setup_security, ut_teardown,
14695 test_ipsec_proto_known_vec_inb,
14696 &pkt_aes_128_cbc_hmac_sha384),
14697 TEST_CASE_NAMED_WITH_DATA(
14698 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
14699 ut_setup_security, ut_teardown,
14700 test_ipsec_proto_known_vec_inb,
14701 &pkt_aes_128_cbc_hmac_sha512),
14702 TEST_CASE_NAMED_WITH_DATA(
14703 "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
14704 ut_setup_security, ut_teardown,
14705 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
14706 TEST_CASE_NAMED_WITH_DATA(
14707 "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14708 ut_setup_security, ut_teardown,
14709 test_ipsec_proto_known_vec_inb,
14710 &pkt_aes_128_cbc_hmac_sha256_v6),
14711 TEST_CASE_NAMED_WITH_DATA(
14712 "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
14713 ut_setup_security, ut_teardown,
14714 test_ipsec_proto_known_vec_inb,
14715 &pkt_null_aes_xcbc),
14716 TEST_CASE_NAMED_ST(
14717 "Combined test alg list",
14718 ut_setup_security, ut_teardown,
14719 test_ipsec_proto_display_list),
14720 TEST_CASE_NAMED_ST(
14722 ut_setup_security, ut_teardown,
14723 test_ipsec_proto_iv_gen),
14724 TEST_CASE_NAMED_ST(
14725 "UDP encapsulation",
14726 ut_setup_security, ut_teardown,
14727 test_ipsec_proto_udp_encap),
14728 TEST_CASE_NAMED_ST(
14729 "UDP encapsulation ports verification test",
14730 ut_setup_security, ut_teardown,
14731 test_ipsec_proto_udp_ports_verify),
14732 TEST_CASE_NAMED_ST(
14733 "SA expiry packets soft",
14734 ut_setup_security, ut_teardown,
14735 test_ipsec_proto_sa_exp_pkts_soft),
14736 TEST_CASE_NAMED_ST(
14737 "SA expiry packets hard",
14738 ut_setup_security, ut_teardown,
14739 test_ipsec_proto_sa_exp_pkts_hard),
14740 TEST_CASE_NAMED_ST(
14741 "Negative test: ICV corruption",
14742 ut_setup_security, ut_teardown,
14743 test_ipsec_proto_err_icv_corrupt),
14744 TEST_CASE_NAMED_ST(
14745 "Tunnel dst addr verification",
14746 ut_setup_security, ut_teardown,
14747 test_ipsec_proto_tunnel_dst_addr_verify),
14748 TEST_CASE_NAMED_ST(
14749 "Tunnel src and dst addr verification",
14750 ut_setup_security, ut_teardown,
14751 test_ipsec_proto_tunnel_src_dst_addr_verify),
14752 TEST_CASE_NAMED_ST(
14753 "Inner IP checksum",
14754 ut_setup_security, ut_teardown,
14755 test_ipsec_proto_inner_ip_csum),
14756 TEST_CASE_NAMED_ST(
14757 "Inner L4 checksum",
14758 ut_setup_security, ut_teardown,
14759 test_ipsec_proto_inner_l4_csum),
14760 TEST_CASE_NAMED_ST(
14761 "Tunnel IPv4 in IPv4",
14762 ut_setup_security, ut_teardown,
14763 test_ipsec_proto_tunnel_v4_in_v4),
14764 TEST_CASE_NAMED_ST(
14765 "Tunnel IPv6 in IPv6",
14766 ut_setup_security, ut_teardown,
14767 test_ipsec_proto_tunnel_v6_in_v6),
14768 TEST_CASE_NAMED_ST(
14769 "Tunnel IPv4 in IPv6",
14770 ut_setup_security, ut_teardown,
14771 test_ipsec_proto_tunnel_v4_in_v6),
14772 TEST_CASE_NAMED_ST(
14773 "Tunnel IPv6 in IPv4",
14774 ut_setup_security, ut_teardown,
14775 test_ipsec_proto_tunnel_v6_in_v4),
14776 TEST_CASE_NAMED_ST(
14778 ut_setup_security, ut_teardown,
14779 test_ipsec_proto_transport_v4),
14780 TEST_CASE_NAMED_ST(
14781 "Statistics: success",
14782 ut_setup_security, ut_teardown,
14783 test_ipsec_proto_stats),
14784 TEST_CASE_NAMED_ST(
14785 "Fragmented packet",
14786 ut_setup_security, ut_teardown,
14787 test_ipsec_proto_pkt_fragment),
14788 TEST_CASE_NAMED_ST(
14789 "Tunnel header copy DF (inner 0)",
14790 ut_setup_security, ut_teardown,
14791 test_ipsec_proto_copy_df_inner_0),
14792 TEST_CASE_NAMED_ST(
14793 "Tunnel header copy DF (inner 1)",
14794 ut_setup_security, ut_teardown,
14795 test_ipsec_proto_copy_df_inner_1),
14796 TEST_CASE_NAMED_ST(
14797 "Tunnel header set DF 0 (inner 1)",
14798 ut_setup_security, ut_teardown,
14799 test_ipsec_proto_set_df_0_inner_1),
14800 TEST_CASE_NAMED_ST(
14801 "Tunnel header set DF 1 (inner 0)",
14802 ut_setup_security, ut_teardown,
14803 test_ipsec_proto_set_df_1_inner_0),
14804 TEST_CASES_END() /**< NULL terminate unit test array */
14808 static struct unit_test_suite pdcp_proto_testsuite = {
14809 .suite_name = "PDCP Proto Unit Test Suite",
14810 .setup = pdcp_proto_testsuite_setup,
14811 .unit_test_cases = {
14812 TEST_CASE_ST(ut_setup_security, ut_teardown,
14813 test_PDCP_PROTO_all),
14814 TEST_CASES_END() /**< NULL terminate unit test array */
14818 #define ADD_UPLINK_TESTCASE(data) \
14819 TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
14820 ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
14822 #define ADD_DOWNLINK_TESTCASE(data) \
14823 TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
14824 ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
14826 static struct unit_test_suite docsis_proto_testsuite = {
14827 .suite_name = "DOCSIS Proto Unit Test Suite",
14828 .setup = docsis_proto_testsuite_setup,
14829 .unit_test_cases = {
14831 ADD_UPLINK_TESTCASE(docsis_test_case_1)
14832 ADD_UPLINK_TESTCASE(docsis_test_case_2)
14833 ADD_UPLINK_TESTCASE(docsis_test_case_3)
14834 ADD_UPLINK_TESTCASE(docsis_test_case_4)
14835 ADD_UPLINK_TESTCASE(docsis_test_case_5)
14836 ADD_UPLINK_TESTCASE(docsis_test_case_6)
14837 ADD_UPLINK_TESTCASE(docsis_test_case_7)
14838 ADD_UPLINK_TESTCASE(docsis_test_case_8)
14839 ADD_UPLINK_TESTCASE(docsis_test_case_9)
14840 ADD_UPLINK_TESTCASE(docsis_test_case_10)
14841 ADD_UPLINK_TESTCASE(docsis_test_case_11)
14842 ADD_UPLINK_TESTCASE(docsis_test_case_12)
14843 ADD_UPLINK_TESTCASE(docsis_test_case_13)
14844 ADD_UPLINK_TESTCASE(docsis_test_case_14)
14845 ADD_UPLINK_TESTCASE(docsis_test_case_15)
14846 ADD_UPLINK_TESTCASE(docsis_test_case_16)
14847 ADD_UPLINK_TESTCASE(docsis_test_case_17)
14848 ADD_UPLINK_TESTCASE(docsis_test_case_18)
14849 ADD_UPLINK_TESTCASE(docsis_test_case_19)
14850 ADD_UPLINK_TESTCASE(docsis_test_case_20)
14851 ADD_UPLINK_TESTCASE(docsis_test_case_21)
14852 ADD_UPLINK_TESTCASE(docsis_test_case_22)
14853 ADD_UPLINK_TESTCASE(docsis_test_case_23)
14854 ADD_UPLINK_TESTCASE(docsis_test_case_24)
14855 ADD_UPLINK_TESTCASE(docsis_test_case_25)
14856 ADD_UPLINK_TESTCASE(docsis_test_case_26)
14858 ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
14859 ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
14860 ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
14861 ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
14862 ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
14863 ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
14864 ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
14865 ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
14866 ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
14867 ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
14868 ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
14869 ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
14870 ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
14871 ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
14872 ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
14873 ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
14874 ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
14875 ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
14876 ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
14877 ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
14878 ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
14879 ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
14880 ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
14881 ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
14882 ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
14883 ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
14884 TEST_CASES_END() /**< NULL terminate unit test array */
14889 static struct unit_test_suite cryptodev_gen_testsuite = {
14890 .suite_name = "Crypto General Unit Test Suite",
14891 .setup = crypto_gen_testsuite_setup,
14892 .unit_test_cases = {
14893 TEST_CASE_ST(ut_setup, ut_teardown,
14894 test_device_configure_invalid_dev_id),
14895 TEST_CASE_ST(ut_setup, ut_teardown,
14896 test_queue_pair_descriptor_setup),
14897 TEST_CASE_ST(ut_setup, ut_teardown,
14898 test_device_configure_invalid_queue_pair_ids),
14899 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
14900 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
14901 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
14902 TEST_CASES_END() /**< NULL terminate unit test array */
14906 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
14907 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
14908 .setup = negative_hmac_sha1_testsuite_setup,
14909 .unit_test_cases = {
14910 /** Negative tests */
14911 TEST_CASE_ST(ut_setup, ut_teardown,
14912 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14913 TEST_CASE_ST(ut_setup, ut_teardown,
14914 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14915 TEST_CASE_ST(ut_setup, ut_teardown,
14916 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14917 TEST_CASE_ST(ut_setup, ut_teardown,
14918 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14920 TEST_CASES_END() /**< NULL terminate unit test array */
14924 static struct unit_test_suite cryptodev_multi_session_testsuite = {
14925 .suite_name = "Multi Session Unit Test Suite",
14926 .setup = multi_session_testsuite_setup,
14927 .unit_test_cases = {
14928 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14929 TEST_CASE_ST(ut_setup, ut_teardown,
14930 test_multi_session_random_usage),
14932 TEST_CASES_END() /**< NULL terminate unit test array */
14936 static struct unit_test_suite cryptodev_null_testsuite = {
14937 .suite_name = "NULL Test Suite",
14938 .setup = null_testsuite_setup,
14939 .unit_test_cases = {
14940 TEST_CASE_ST(ut_setup, ut_teardown,
14941 test_null_invalid_operation),
14942 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
14947 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
14948 .suite_name = "AES CCM Authenticated Test Suite",
14949 .setup = aes_ccm_auth_testsuite_setup,
14950 .unit_test_cases = {
14951 /** AES CCM Authenticated Encryption 128 bits key*/
14952 TEST_CASE_ST(ut_setup, ut_teardown,
14953 test_AES_CCM_authenticated_encryption_test_case_128_1),
14954 TEST_CASE_ST(ut_setup, ut_teardown,
14955 test_AES_CCM_authenticated_encryption_test_case_128_2),
14956 TEST_CASE_ST(ut_setup, ut_teardown,
14957 test_AES_CCM_authenticated_encryption_test_case_128_3),
14959 /** AES CCM Authenticated Decryption 128 bits key*/
14960 TEST_CASE_ST(ut_setup, ut_teardown,
14961 test_AES_CCM_authenticated_decryption_test_case_128_1),
14962 TEST_CASE_ST(ut_setup, ut_teardown,
14963 test_AES_CCM_authenticated_decryption_test_case_128_2),
14964 TEST_CASE_ST(ut_setup, ut_teardown,
14965 test_AES_CCM_authenticated_decryption_test_case_128_3),
14967 /** AES CCM Authenticated Encryption 192 bits key */
14968 TEST_CASE_ST(ut_setup, ut_teardown,
14969 test_AES_CCM_authenticated_encryption_test_case_192_1),
14970 TEST_CASE_ST(ut_setup, ut_teardown,
14971 test_AES_CCM_authenticated_encryption_test_case_192_2),
14972 TEST_CASE_ST(ut_setup, ut_teardown,
14973 test_AES_CCM_authenticated_encryption_test_case_192_3),
14975 /** AES CCM Authenticated Decryption 192 bits key*/
14976 TEST_CASE_ST(ut_setup, ut_teardown,
14977 test_AES_CCM_authenticated_decryption_test_case_192_1),
14978 TEST_CASE_ST(ut_setup, ut_teardown,
14979 test_AES_CCM_authenticated_decryption_test_case_192_2),
14980 TEST_CASE_ST(ut_setup, ut_teardown,
14981 test_AES_CCM_authenticated_decryption_test_case_192_3),
14983 /** AES CCM Authenticated Encryption 256 bits key */
14984 TEST_CASE_ST(ut_setup, ut_teardown,
14985 test_AES_CCM_authenticated_encryption_test_case_256_1),
14986 TEST_CASE_ST(ut_setup, ut_teardown,
14987 test_AES_CCM_authenticated_encryption_test_case_256_2),
14988 TEST_CASE_ST(ut_setup, ut_teardown,
14989 test_AES_CCM_authenticated_encryption_test_case_256_3),
14991 /** AES CCM Authenticated Decryption 256 bits key*/
14992 TEST_CASE_ST(ut_setup, ut_teardown,
14993 test_AES_CCM_authenticated_decryption_test_case_256_1),
14994 TEST_CASE_ST(ut_setup, ut_teardown,
14995 test_AES_CCM_authenticated_decryption_test_case_256_2),
14996 TEST_CASE_ST(ut_setup, ut_teardown,
14997 test_AES_CCM_authenticated_decryption_test_case_256_3),
15002 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
15003 .suite_name = "AES GCM Authenticated Test Suite",
15004 .setup = aes_gcm_auth_testsuite_setup,
15005 .unit_test_cases = {
15006 /** AES GCM Authenticated Encryption */
15007 TEST_CASE_ST(ut_setup, ut_teardown,
15008 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
15009 TEST_CASE_ST(ut_setup, ut_teardown,
15010 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
15011 TEST_CASE_ST(ut_setup, ut_teardown,
15012 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
15013 TEST_CASE_ST(ut_setup, ut_teardown,
15014 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
15015 TEST_CASE_ST(ut_setup, ut_teardown,
15016 test_AES_GCM_authenticated_encryption_test_case_1),
15017 TEST_CASE_ST(ut_setup, ut_teardown,
15018 test_AES_GCM_authenticated_encryption_test_case_2),
15019 TEST_CASE_ST(ut_setup, ut_teardown,
15020 test_AES_GCM_authenticated_encryption_test_case_3),
15021 TEST_CASE_ST(ut_setup, ut_teardown,
15022 test_AES_GCM_authenticated_encryption_test_case_4),
15023 TEST_CASE_ST(ut_setup, ut_teardown,
15024 test_AES_GCM_authenticated_encryption_test_case_5),
15025 TEST_CASE_ST(ut_setup, ut_teardown,
15026 test_AES_GCM_authenticated_encryption_test_case_6),
15027 TEST_CASE_ST(ut_setup, ut_teardown,
15028 test_AES_GCM_authenticated_encryption_test_case_7),
15029 TEST_CASE_ST(ut_setup, ut_teardown,
15030 test_AES_GCM_authenticated_encryption_test_case_8),
15031 TEST_CASE_ST(ut_setup, ut_teardown,
15032 test_AES_GCM_J0_authenticated_encryption_test_case_1),
15034 /** AES GCM Authenticated Decryption */
15035 TEST_CASE_ST(ut_setup, ut_teardown,
15036 test_AES_GCM_authenticated_decryption_test_case_1),
15037 TEST_CASE_ST(ut_setup, ut_teardown,
15038 test_AES_GCM_authenticated_decryption_test_case_2),
15039 TEST_CASE_ST(ut_setup, ut_teardown,
15040 test_AES_GCM_authenticated_decryption_test_case_3),
15041 TEST_CASE_ST(ut_setup, ut_teardown,
15042 test_AES_GCM_authenticated_decryption_test_case_4),
15043 TEST_CASE_ST(ut_setup, ut_teardown,
15044 test_AES_GCM_authenticated_decryption_test_case_5),
15045 TEST_CASE_ST(ut_setup, ut_teardown,
15046 test_AES_GCM_authenticated_decryption_test_case_6),
15047 TEST_CASE_ST(ut_setup, ut_teardown,
15048 test_AES_GCM_authenticated_decryption_test_case_7),
15049 TEST_CASE_ST(ut_setup, ut_teardown,
15050 test_AES_GCM_authenticated_decryption_test_case_8),
15051 TEST_CASE_ST(ut_setup, ut_teardown,
15052 test_AES_GCM_J0_authenticated_decryption_test_case_1),
15054 /** AES GCM Authenticated Encryption 192 bits key */
15055 TEST_CASE_ST(ut_setup, ut_teardown,
15056 test_AES_GCM_auth_encryption_test_case_192_1),
15057 TEST_CASE_ST(ut_setup, ut_teardown,
15058 test_AES_GCM_auth_encryption_test_case_192_2),
15059 TEST_CASE_ST(ut_setup, ut_teardown,
15060 test_AES_GCM_auth_encryption_test_case_192_3),
15061 TEST_CASE_ST(ut_setup, ut_teardown,
15062 test_AES_GCM_auth_encryption_test_case_192_4),
15063 TEST_CASE_ST(ut_setup, ut_teardown,
15064 test_AES_GCM_auth_encryption_test_case_192_5),
15065 TEST_CASE_ST(ut_setup, ut_teardown,
15066 test_AES_GCM_auth_encryption_test_case_192_6),
15067 TEST_CASE_ST(ut_setup, ut_teardown,
15068 test_AES_GCM_auth_encryption_test_case_192_7),
15070 /** AES GCM Authenticated Decryption 192 bits key */
15071 TEST_CASE_ST(ut_setup, ut_teardown,
15072 test_AES_GCM_auth_decryption_test_case_192_1),
15073 TEST_CASE_ST(ut_setup, ut_teardown,
15074 test_AES_GCM_auth_decryption_test_case_192_2),
15075 TEST_CASE_ST(ut_setup, ut_teardown,
15076 test_AES_GCM_auth_decryption_test_case_192_3),
15077 TEST_CASE_ST(ut_setup, ut_teardown,
15078 test_AES_GCM_auth_decryption_test_case_192_4),
15079 TEST_CASE_ST(ut_setup, ut_teardown,
15080 test_AES_GCM_auth_decryption_test_case_192_5),
15081 TEST_CASE_ST(ut_setup, ut_teardown,
15082 test_AES_GCM_auth_decryption_test_case_192_6),
15083 TEST_CASE_ST(ut_setup, ut_teardown,
15084 test_AES_GCM_auth_decryption_test_case_192_7),
15086 /** AES GCM Authenticated Encryption 256 bits key */
15087 TEST_CASE_ST(ut_setup, ut_teardown,
15088 test_AES_GCM_auth_encryption_test_case_256_1),
15089 TEST_CASE_ST(ut_setup, ut_teardown,
15090 test_AES_GCM_auth_encryption_test_case_256_2),
15091 TEST_CASE_ST(ut_setup, ut_teardown,
15092 test_AES_GCM_auth_encryption_test_case_256_3),
15093 TEST_CASE_ST(ut_setup, ut_teardown,
15094 test_AES_GCM_auth_encryption_test_case_256_4),
15095 TEST_CASE_ST(ut_setup, ut_teardown,
15096 test_AES_GCM_auth_encryption_test_case_256_5),
15097 TEST_CASE_ST(ut_setup, ut_teardown,
15098 test_AES_GCM_auth_encryption_test_case_256_6),
15099 TEST_CASE_ST(ut_setup, ut_teardown,
15100 test_AES_GCM_auth_encryption_test_case_256_7),
15102 /** AES GCM Authenticated Decryption 256 bits key */
15103 TEST_CASE_ST(ut_setup, ut_teardown,
15104 test_AES_GCM_auth_decryption_test_case_256_1),
15105 TEST_CASE_ST(ut_setup, ut_teardown,
15106 test_AES_GCM_auth_decryption_test_case_256_2),
15107 TEST_CASE_ST(ut_setup, ut_teardown,
15108 test_AES_GCM_auth_decryption_test_case_256_3),
15109 TEST_CASE_ST(ut_setup, ut_teardown,
15110 test_AES_GCM_auth_decryption_test_case_256_4),
15111 TEST_CASE_ST(ut_setup, ut_teardown,
15112 test_AES_GCM_auth_decryption_test_case_256_5),
15113 TEST_CASE_ST(ut_setup, ut_teardown,
15114 test_AES_GCM_auth_decryption_test_case_256_6),
15115 TEST_CASE_ST(ut_setup, ut_teardown,
15116 test_AES_GCM_auth_decryption_test_case_256_7),
15118 /** AES GCM Authenticated Encryption big aad size */
15119 TEST_CASE_ST(ut_setup, ut_teardown,
15120 test_AES_GCM_auth_encryption_test_case_aad_1),
15121 TEST_CASE_ST(ut_setup, ut_teardown,
15122 test_AES_GCM_auth_encryption_test_case_aad_2),
15124 /** AES GCM Authenticated Decryption big aad size */
15125 TEST_CASE_ST(ut_setup, ut_teardown,
15126 test_AES_GCM_auth_decryption_test_case_aad_1),
15127 TEST_CASE_ST(ut_setup, ut_teardown,
15128 test_AES_GCM_auth_decryption_test_case_aad_2),
15130 /** Out of place tests */
15131 TEST_CASE_ST(ut_setup, ut_teardown,
15132 test_AES_GCM_authenticated_encryption_oop_test_case_1),
15133 TEST_CASE_ST(ut_setup, ut_teardown,
15134 test_AES_GCM_authenticated_decryption_oop_test_case_1),
15136 /** Session-less tests */
15137 TEST_CASE_ST(ut_setup, ut_teardown,
15138 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
15139 TEST_CASE_ST(ut_setup, ut_teardown,
15140 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
15146 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
15147 .suite_name = "AES GMAC Authentication Test Suite",
15148 .setup = aes_gmac_auth_testsuite_setup,
15149 .unit_test_cases = {
15150 TEST_CASE_ST(ut_setup, ut_teardown,
15151 test_AES_GMAC_authentication_test_case_1),
15152 TEST_CASE_ST(ut_setup, ut_teardown,
15153 test_AES_GMAC_authentication_verify_test_case_1),
15154 TEST_CASE_ST(ut_setup, ut_teardown,
15155 test_AES_GMAC_authentication_test_case_2),
15156 TEST_CASE_ST(ut_setup, ut_teardown,
15157 test_AES_GMAC_authentication_verify_test_case_2),
15158 TEST_CASE_ST(ut_setup, ut_teardown,
15159 test_AES_GMAC_authentication_test_case_3),
15160 TEST_CASE_ST(ut_setup, ut_teardown,
15161 test_AES_GMAC_authentication_verify_test_case_3),
15162 TEST_CASE_ST(ut_setup, ut_teardown,
15163 test_AES_GMAC_authentication_test_case_4),
15164 TEST_CASE_ST(ut_setup, ut_teardown,
15165 test_AES_GMAC_authentication_verify_test_case_4),
15166 TEST_CASE_ST(ut_setup, ut_teardown,
15167 test_AES_GMAC_authentication_SGL_40B),
15168 TEST_CASE_ST(ut_setup, ut_teardown,
15169 test_AES_GMAC_authentication_SGL_80B),
15170 TEST_CASE_ST(ut_setup, ut_teardown,
15171 test_AES_GMAC_authentication_SGL_2048B),
15172 TEST_CASE_ST(ut_setup, ut_teardown,
15173 test_AES_GMAC_authentication_SGL_2047B),
15179 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
15180 .suite_name = "Chacha20-Poly1305 Test Suite",
15181 .setup = chacha20_poly1305_testsuite_setup,
15182 .unit_test_cases = {
15183 TEST_CASE_ST(ut_setup, ut_teardown,
15184 test_chacha20_poly1305_encrypt_test_case_rfc8439),
15185 TEST_CASE_ST(ut_setup, ut_teardown,
15186 test_chacha20_poly1305_decrypt_test_case_rfc8439),
15187 TEST_CASE_ST(ut_setup, ut_teardown,
15188 test_chacha20_poly1305_encrypt_SGL_out_of_place),
15193 static struct unit_test_suite cryptodev_snow3g_testsuite = {
15194 .suite_name = "SNOW 3G Test Suite",
15195 .setup = snow3g_testsuite_setup,
15196 .unit_test_cases = {
15197 /** SNOW 3G encrypt only (UEA2) */
15198 TEST_CASE_ST(ut_setup, ut_teardown,
15199 test_snow3g_encryption_test_case_1),
15200 TEST_CASE_ST(ut_setup, ut_teardown,
15201 test_snow3g_encryption_test_case_2),
15202 TEST_CASE_ST(ut_setup, ut_teardown,
15203 test_snow3g_encryption_test_case_3),
15204 TEST_CASE_ST(ut_setup, ut_teardown,
15205 test_snow3g_encryption_test_case_4),
15206 TEST_CASE_ST(ut_setup, ut_teardown,
15207 test_snow3g_encryption_test_case_5),
15209 TEST_CASE_ST(ut_setup, ut_teardown,
15210 test_snow3g_encryption_test_case_1_oop),
15211 TEST_CASE_ST(ut_setup, ut_teardown,
15212 test_snow3g_encryption_test_case_1_oop_sgl),
15213 TEST_CASE_ST(ut_setup, ut_teardown,
15214 test_snow3g_encryption_test_case_1_offset_oop),
15215 TEST_CASE_ST(ut_setup, ut_teardown,
15216 test_snow3g_decryption_test_case_1_oop),
15218 /** SNOW 3G generate auth, then encrypt (UEA2) */
15219 TEST_CASE_ST(ut_setup, ut_teardown,
15220 test_snow3g_auth_cipher_test_case_1),
15221 TEST_CASE_ST(ut_setup, ut_teardown,
15222 test_snow3g_auth_cipher_test_case_2),
15223 TEST_CASE_ST(ut_setup, ut_teardown,
15224 test_snow3g_auth_cipher_test_case_2_oop),
15225 TEST_CASE_ST(ut_setup, ut_teardown,
15226 test_snow3g_auth_cipher_part_digest_enc),
15227 TEST_CASE_ST(ut_setup, ut_teardown,
15228 test_snow3g_auth_cipher_part_digest_enc_oop),
15229 TEST_CASE_ST(ut_setup, ut_teardown,
15230 test_snow3g_auth_cipher_test_case_3_sgl),
15231 TEST_CASE_ST(ut_setup, ut_teardown,
15232 test_snow3g_auth_cipher_test_case_3_oop_sgl),
15233 TEST_CASE_ST(ut_setup, ut_teardown,
15234 test_snow3g_auth_cipher_part_digest_enc_sgl),
15235 TEST_CASE_ST(ut_setup, ut_teardown,
15236 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
15238 /** SNOW 3G decrypt (UEA2), then verify auth */
15239 TEST_CASE_ST(ut_setup, ut_teardown,
15240 test_snow3g_auth_cipher_verify_test_case_1),
15241 TEST_CASE_ST(ut_setup, ut_teardown,
15242 test_snow3g_auth_cipher_verify_test_case_2),
15243 TEST_CASE_ST(ut_setup, ut_teardown,
15244 test_snow3g_auth_cipher_verify_test_case_2_oop),
15245 TEST_CASE_ST(ut_setup, ut_teardown,
15246 test_snow3g_auth_cipher_verify_part_digest_enc),
15247 TEST_CASE_ST(ut_setup, ut_teardown,
15248 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
15249 TEST_CASE_ST(ut_setup, ut_teardown,
15250 test_snow3g_auth_cipher_verify_test_case_3_sgl),
15251 TEST_CASE_ST(ut_setup, ut_teardown,
15252 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
15253 TEST_CASE_ST(ut_setup, ut_teardown,
15254 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
15255 TEST_CASE_ST(ut_setup, ut_teardown,
15256 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
15258 /** SNOW 3G decrypt only (UEA2) */
15259 TEST_CASE_ST(ut_setup, ut_teardown,
15260 test_snow3g_decryption_test_case_1),
15261 TEST_CASE_ST(ut_setup, ut_teardown,
15262 test_snow3g_decryption_test_case_2),
15263 TEST_CASE_ST(ut_setup, ut_teardown,
15264 test_snow3g_decryption_test_case_3),
15265 TEST_CASE_ST(ut_setup, ut_teardown,
15266 test_snow3g_decryption_test_case_4),
15267 TEST_CASE_ST(ut_setup, ut_teardown,
15268 test_snow3g_decryption_test_case_5),
15269 TEST_CASE_ST(ut_setup, ut_teardown,
15270 test_snow3g_decryption_with_digest_test_case_1),
15271 TEST_CASE_ST(ut_setup, ut_teardown,
15272 test_snow3g_hash_generate_test_case_1),
15273 TEST_CASE_ST(ut_setup, ut_teardown,
15274 test_snow3g_hash_generate_test_case_2),
15275 TEST_CASE_ST(ut_setup, ut_teardown,
15276 test_snow3g_hash_generate_test_case_3),
15278 /* Tests with buffers which length is not byte-aligned */
15279 TEST_CASE_ST(ut_setup, ut_teardown,
15280 test_snow3g_hash_generate_test_case_4),
15281 TEST_CASE_ST(ut_setup, ut_teardown,
15282 test_snow3g_hash_generate_test_case_5),
15283 TEST_CASE_ST(ut_setup, ut_teardown,
15284 test_snow3g_hash_generate_test_case_6),
15285 TEST_CASE_ST(ut_setup, ut_teardown,
15286 test_snow3g_hash_verify_test_case_1),
15287 TEST_CASE_ST(ut_setup, ut_teardown,
15288 test_snow3g_hash_verify_test_case_2),
15289 TEST_CASE_ST(ut_setup, ut_teardown,
15290 test_snow3g_hash_verify_test_case_3),
15292 /* Tests with buffers which length is not byte-aligned */
15293 TEST_CASE_ST(ut_setup, ut_teardown,
15294 test_snow3g_hash_verify_test_case_4),
15295 TEST_CASE_ST(ut_setup, ut_teardown,
15296 test_snow3g_hash_verify_test_case_5),
15297 TEST_CASE_ST(ut_setup, ut_teardown,
15298 test_snow3g_hash_verify_test_case_6),
15299 TEST_CASE_ST(ut_setup, ut_teardown,
15300 test_snow3g_cipher_auth_test_case_1),
15301 TEST_CASE_ST(ut_setup, ut_teardown,
15302 test_snow3g_auth_cipher_with_digest_test_case_1),
15307 static struct unit_test_suite cryptodev_zuc_testsuite = {
15308 .suite_name = "ZUC Test Suite",
15309 .setup = zuc_testsuite_setup,
15310 .unit_test_cases = {
15311 /** ZUC encrypt only (EEA3) */
15312 TEST_CASE_ST(ut_setup, ut_teardown,
15313 test_zuc_encryption_test_case_1),
15314 TEST_CASE_ST(ut_setup, ut_teardown,
15315 test_zuc_encryption_test_case_2),
15316 TEST_CASE_ST(ut_setup, ut_teardown,
15317 test_zuc_encryption_test_case_3),
15318 TEST_CASE_ST(ut_setup, ut_teardown,
15319 test_zuc_encryption_test_case_4),
15320 TEST_CASE_ST(ut_setup, ut_teardown,
15321 test_zuc_encryption_test_case_5),
15322 TEST_CASE_ST(ut_setup, ut_teardown,
15323 test_zuc_encryption_test_case_6_sgl),
15325 /** ZUC authenticate (EIA3) */
15326 TEST_CASE_ST(ut_setup, ut_teardown,
15327 test_zuc_hash_generate_test_case_1),
15328 TEST_CASE_ST(ut_setup, ut_teardown,
15329 test_zuc_hash_generate_test_case_2),
15330 TEST_CASE_ST(ut_setup, ut_teardown,
15331 test_zuc_hash_generate_test_case_3),
15332 TEST_CASE_ST(ut_setup, ut_teardown,
15333 test_zuc_hash_generate_test_case_4),
15334 TEST_CASE_ST(ut_setup, ut_teardown,
15335 test_zuc_hash_generate_test_case_5),
15336 TEST_CASE_ST(ut_setup, ut_teardown,
15337 test_zuc_hash_generate_test_case_6),
15338 TEST_CASE_ST(ut_setup, ut_teardown,
15339 test_zuc_hash_generate_test_case_7),
15340 TEST_CASE_ST(ut_setup, ut_teardown,
15341 test_zuc_hash_generate_test_case_8),
15342 TEST_CASE_ST(ut_setup, ut_teardown,
15343 test_zuc_hash_generate_test_case_9),
15344 TEST_CASE_ST(ut_setup, ut_teardown,
15345 test_zuc_hash_generate_test_case_10),
15346 TEST_CASE_ST(ut_setup, ut_teardown,
15347 test_zuc_hash_generate_test_case_11),
15350 /** ZUC alg-chain (EEA3/EIA3) */
15351 TEST_CASE_ST(ut_setup, ut_teardown,
15352 test_zuc_cipher_auth_test_case_1),
15353 TEST_CASE_ST(ut_setup, ut_teardown,
15354 test_zuc_cipher_auth_test_case_2),
15356 /** ZUC generate auth, then encrypt (EEA3) */
15357 TEST_CASE_ST(ut_setup, ut_teardown,
15358 test_zuc_auth_cipher_test_case_1),
15359 TEST_CASE_ST(ut_setup, ut_teardown,
15360 test_zuc_auth_cipher_test_case_1_oop),
15361 TEST_CASE_ST(ut_setup, ut_teardown,
15362 test_zuc_auth_cipher_test_case_1_sgl),
15363 TEST_CASE_ST(ut_setup, ut_teardown,
15364 test_zuc_auth_cipher_test_case_1_oop_sgl),
15366 /** ZUC decrypt (EEA3), then verify auth */
15367 TEST_CASE_ST(ut_setup, ut_teardown,
15368 test_zuc_auth_cipher_verify_test_case_1),
15369 TEST_CASE_ST(ut_setup, ut_teardown,
15370 test_zuc_auth_cipher_verify_test_case_1_oop),
15371 TEST_CASE_ST(ut_setup, ut_teardown,
15372 test_zuc_auth_cipher_verify_test_case_1_sgl),
15373 TEST_CASE_ST(ut_setup, ut_teardown,
15374 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
15376 /** ZUC-256 encrypt only **/
15377 TEST_CASE_ST(ut_setup, ut_teardown,
15378 test_zuc256_encryption_test_case_1),
15379 TEST_CASE_ST(ut_setup, ut_teardown,
15380 test_zuc256_encryption_test_case_2),
15382 /** ZUC-256 authentication only **/
15383 TEST_CASE_ST(ut_setup, ut_teardown,
15384 test_zuc256_authentication_test_case_1),
15385 TEST_CASE_ST(ut_setup, ut_teardown,
15386 test_zuc256_authentication_test_case_2),
15392 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
15393 .suite_name = "HMAC_MD5 Authentication Test Suite",
15394 .setup = hmac_md5_auth_testsuite_setup,
15395 .unit_test_cases = {
15396 TEST_CASE_ST(ut_setup, ut_teardown,
15397 test_MD5_HMAC_generate_case_1),
15398 TEST_CASE_ST(ut_setup, ut_teardown,
15399 test_MD5_HMAC_verify_case_1),
15400 TEST_CASE_ST(ut_setup, ut_teardown,
15401 test_MD5_HMAC_generate_case_2),
15402 TEST_CASE_ST(ut_setup, ut_teardown,
15403 test_MD5_HMAC_verify_case_2),
15408 static struct unit_test_suite cryptodev_kasumi_testsuite = {
15409 .suite_name = "Kasumi Test Suite",
15410 .setup = kasumi_testsuite_setup,
15411 .unit_test_cases = {
15412 /** KASUMI hash only (UIA1) */
15413 TEST_CASE_ST(ut_setup, ut_teardown,
15414 test_kasumi_hash_generate_test_case_1),
15415 TEST_CASE_ST(ut_setup, ut_teardown,
15416 test_kasumi_hash_generate_test_case_2),
15417 TEST_CASE_ST(ut_setup, ut_teardown,
15418 test_kasumi_hash_generate_test_case_3),
15419 TEST_CASE_ST(ut_setup, ut_teardown,
15420 test_kasumi_hash_generate_test_case_4),
15421 TEST_CASE_ST(ut_setup, ut_teardown,
15422 test_kasumi_hash_generate_test_case_5),
15423 TEST_CASE_ST(ut_setup, ut_teardown,
15424 test_kasumi_hash_generate_test_case_6),
15426 TEST_CASE_ST(ut_setup, ut_teardown,
15427 test_kasumi_hash_verify_test_case_1),
15428 TEST_CASE_ST(ut_setup, ut_teardown,
15429 test_kasumi_hash_verify_test_case_2),
15430 TEST_CASE_ST(ut_setup, ut_teardown,
15431 test_kasumi_hash_verify_test_case_3),
15432 TEST_CASE_ST(ut_setup, ut_teardown,
15433 test_kasumi_hash_verify_test_case_4),
15434 TEST_CASE_ST(ut_setup, ut_teardown,
15435 test_kasumi_hash_verify_test_case_5),
15437 /** KASUMI encrypt only (UEA1) */
15438 TEST_CASE_ST(ut_setup, ut_teardown,
15439 test_kasumi_encryption_test_case_1),
15440 TEST_CASE_ST(ut_setup, ut_teardown,
15441 test_kasumi_encryption_test_case_1_sgl),
15442 TEST_CASE_ST(ut_setup, ut_teardown,
15443 test_kasumi_encryption_test_case_1_oop),
15444 TEST_CASE_ST(ut_setup, ut_teardown,
15445 test_kasumi_encryption_test_case_1_oop_sgl),
15446 TEST_CASE_ST(ut_setup, ut_teardown,
15447 test_kasumi_encryption_test_case_2),
15448 TEST_CASE_ST(ut_setup, ut_teardown,
15449 test_kasumi_encryption_test_case_3),
15450 TEST_CASE_ST(ut_setup, ut_teardown,
15451 test_kasumi_encryption_test_case_4),
15452 TEST_CASE_ST(ut_setup, ut_teardown,
15453 test_kasumi_encryption_test_case_5),
15455 /** KASUMI decrypt only (UEA1) */
15456 TEST_CASE_ST(ut_setup, ut_teardown,
15457 test_kasumi_decryption_test_case_1),
15458 TEST_CASE_ST(ut_setup, ut_teardown,
15459 test_kasumi_decryption_test_case_2),
15460 TEST_CASE_ST(ut_setup, ut_teardown,
15461 test_kasumi_decryption_test_case_3),
15462 TEST_CASE_ST(ut_setup, ut_teardown,
15463 test_kasumi_decryption_test_case_4),
15464 TEST_CASE_ST(ut_setup, ut_teardown,
15465 test_kasumi_decryption_test_case_5),
15466 TEST_CASE_ST(ut_setup, ut_teardown,
15467 test_kasumi_decryption_test_case_1_oop),
15468 TEST_CASE_ST(ut_setup, ut_teardown,
15469 test_kasumi_cipher_auth_test_case_1),
15471 /** KASUMI generate auth, then encrypt (F8) */
15472 TEST_CASE_ST(ut_setup, ut_teardown,
15473 test_kasumi_auth_cipher_test_case_1),
15474 TEST_CASE_ST(ut_setup, ut_teardown,
15475 test_kasumi_auth_cipher_test_case_2),
15476 TEST_CASE_ST(ut_setup, ut_teardown,
15477 test_kasumi_auth_cipher_test_case_2_oop),
15478 TEST_CASE_ST(ut_setup, ut_teardown,
15479 test_kasumi_auth_cipher_test_case_2_sgl),
15480 TEST_CASE_ST(ut_setup, ut_teardown,
15481 test_kasumi_auth_cipher_test_case_2_oop_sgl),
15483 /** KASUMI decrypt (F8), then verify auth */
15484 TEST_CASE_ST(ut_setup, ut_teardown,
15485 test_kasumi_auth_cipher_verify_test_case_1),
15486 TEST_CASE_ST(ut_setup, ut_teardown,
15487 test_kasumi_auth_cipher_verify_test_case_2),
15488 TEST_CASE_ST(ut_setup, ut_teardown,
15489 test_kasumi_auth_cipher_verify_test_case_2_oop),
15490 TEST_CASE_ST(ut_setup, ut_teardown,
15491 test_kasumi_auth_cipher_verify_test_case_2_sgl),
15492 TEST_CASE_ST(ut_setup, ut_teardown,
15493 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
15499 static struct unit_test_suite cryptodev_esn_testsuite = {
15500 .suite_name = "ESN Test Suite",
15501 .setup = esn_testsuite_setup,
15502 .unit_test_cases = {
15503 TEST_CASE_ST(ut_setup, ut_teardown,
15504 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
15505 TEST_CASE_ST(ut_setup, ut_teardown,
15506 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
15511 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
15512 .suite_name = "Negative AES GCM Test Suite",
15513 .setup = negative_aes_gcm_testsuite_setup,
15514 .unit_test_cases = {
15515 TEST_CASE_ST(ut_setup, ut_teardown,
15516 test_AES_GCM_auth_encryption_fail_iv_corrupt),
15517 TEST_CASE_ST(ut_setup, ut_teardown,
15518 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
15519 TEST_CASE_ST(ut_setup, ut_teardown,
15520 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
15521 TEST_CASE_ST(ut_setup, ut_teardown,
15522 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
15523 TEST_CASE_ST(ut_setup, ut_teardown,
15524 test_AES_GCM_auth_encryption_fail_aad_corrupt),
15525 TEST_CASE_ST(ut_setup, ut_teardown,
15526 test_AES_GCM_auth_encryption_fail_tag_corrupt),
15527 TEST_CASE_ST(ut_setup, ut_teardown,
15528 test_AES_GCM_auth_decryption_fail_iv_corrupt),
15529 TEST_CASE_ST(ut_setup, ut_teardown,
15530 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
15531 TEST_CASE_ST(ut_setup, ut_teardown,
15532 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
15533 TEST_CASE_ST(ut_setup, ut_teardown,
15534 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
15535 TEST_CASE_ST(ut_setup, ut_teardown,
15536 test_AES_GCM_auth_decryption_fail_aad_corrupt),
15537 TEST_CASE_ST(ut_setup, ut_teardown,
15538 test_AES_GCM_auth_decryption_fail_tag_corrupt),
15544 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
15545 .suite_name = "Negative AES GMAC Test Suite",
15546 .setup = negative_aes_gmac_testsuite_setup,
15547 .unit_test_cases = {
15548 TEST_CASE_ST(ut_setup, ut_teardown,
15549 authentication_verify_AES128_GMAC_fail_data_corrupt),
15550 TEST_CASE_ST(ut_setup, ut_teardown,
15551 authentication_verify_AES128_GMAC_fail_tag_corrupt),
15557 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
15558 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
15559 .setup = mixed_cipher_hash_testsuite_setup,
15560 .unit_test_cases = {
15561 /** AUTH AES CMAC + CIPHER AES CTR */
15562 TEST_CASE_ST(ut_setup, ut_teardown,
15563 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
15564 TEST_CASE_ST(ut_setup, ut_teardown,
15565 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15566 TEST_CASE_ST(ut_setup, ut_teardown,
15567 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15568 TEST_CASE_ST(ut_setup, ut_teardown,
15569 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15570 TEST_CASE_ST(ut_setup, ut_teardown,
15571 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
15572 TEST_CASE_ST(ut_setup, ut_teardown,
15573 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15574 TEST_CASE_ST(ut_setup, ut_teardown,
15575 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15576 TEST_CASE_ST(ut_setup, ut_teardown,
15577 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15579 /** AUTH ZUC + CIPHER SNOW3G */
15580 TEST_CASE_ST(ut_setup, ut_teardown,
15581 test_auth_zuc_cipher_snow_test_case_1),
15582 TEST_CASE_ST(ut_setup, ut_teardown,
15583 test_verify_auth_zuc_cipher_snow_test_case_1),
15584 /** AUTH AES CMAC + CIPHER SNOW3G */
15585 TEST_CASE_ST(ut_setup, ut_teardown,
15586 test_auth_aes_cmac_cipher_snow_test_case_1),
15587 TEST_CASE_ST(ut_setup, ut_teardown,
15588 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
15589 /** AUTH ZUC + CIPHER AES CTR */
15590 TEST_CASE_ST(ut_setup, ut_teardown,
15591 test_auth_zuc_cipher_aes_ctr_test_case_1),
15592 TEST_CASE_ST(ut_setup, ut_teardown,
15593 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
15594 /** AUTH SNOW3G + CIPHER AES CTR */
15595 TEST_CASE_ST(ut_setup, ut_teardown,
15596 test_auth_snow_cipher_aes_ctr_test_case_1),
15597 TEST_CASE_ST(ut_setup, ut_teardown,
15598 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
15599 /** AUTH SNOW3G + CIPHER ZUC */
15600 TEST_CASE_ST(ut_setup, ut_teardown,
15601 test_auth_snow_cipher_zuc_test_case_1),
15602 TEST_CASE_ST(ut_setup, ut_teardown,
15603 test_verify_auth_snow_cipher_zuc_test_case_1),
15604 /** AUTH AES CMAC + CIPHER ZUC */
15605 TEST_CASE_ST(ut_setup, ut_teardown,
15606 test_auth_aes_cmac_cipher_zuc_test_case_1),
15607 TEST_CASE_ST(ut_setup, ut_teardown,
15608 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
15610 /** AUTH NULL + CIPHER SNOW3G */
15611 TEST_CASE_ST(ut_setup, ut_teardown,
15612 test_auth_null_cipher_snow_test_case_1),
15613 TEST_CASE_ST(ut_setup, ut_teardown,
15614 test_verify_auth_null_cipher_snow_test_case_1),
15615 /** AUTH NULL + CIPHER ZUC */
15616 TEST_CASE_ST(ut_setup, ut_teardown,
15617 test_auth_null_cipher_zuc_test_case_1),
15618 TEST_CASE_ST(ut_setup, ut_teardown,
15619 test_verify_auth_null_cipher_zuc_test_case_1),
15620 /** AUTH SNOW3G + CIPHER NULL */
15621 TEST_CASE_ST(ut_setup, ut_teardown,
15622 test_auth_snow_cipher_null_test_case_1),
15623 TEST_CASE_ST(ut_setup, ut_teardown,
15624 test_verify_auth_snow_cipher_null_test_case_1),
15625 /** AUTH ZUC + CIPHER NULL */
15626 TEST_CASE_ST(ut_setup, ut_teardown,
15627 test_auth_zuc_cipher_null_test_case_1),
15628 TEST_CASE_ST(ut_setup, ut_teardown,
15629 test_verify_auth_zuc_cipher_null_test_case_1),
15630 /** AUTH NULL + CIPHER AES CTR */
15631 TEST_CASE_ST(ut_setup, ut_teardown,
15632 test_auth_null_cipher_aes_ctr_test_case_1),
15633 TEST_CASE_ST(ut_setup, ut_teardown,
15634 test_verify_auth_null_cipher_aes_ctr_test_case_1),
15635 /** AUTH AES CMAC + CIPHER NULL */
15636 TEST_CASE_ST(ut_setup, ut_teardown,
15637 test_auth_aes_cmac_cipher_null_test_case_1),
15638 TEST_CASE_ST(ut_setup, ut_teardown,
15639 test_verify_auth_aes_cmac_cipher_null_test_case_1),
15645 run_cryptodev_testsuite(const char *pmd_name)
15647 uint8_t ret, j, i = 0, blk_start_idx = 0;
15648 const enum blockcipher_test_type blk_suites[] = {
15649 BLKCIPHER_AES_CHAIN_TYPE,
15650 BLKCIPHER_AES_CIPHERONLY_TYPE,
15651 BLKCIPHER_AES_DOCSIS_TYPE,
15652 BLKCIPHER_3DES_CHAIN_TYPE,
15653 BLKCIPHER_3DES_CIPHERONLY_TYPE,
15654 BLKCIPHER_DES_CIPHERONLY_TYPE,
15655 BLKCIPHER_DES_DOCSIS_TYPE,
15656 BLKCIPHER_AUTHONLY_TYPE};
15657 struct unit_test_suite *static_suites[] = {
15658 &cryptodev_multi_session_testsuite,
15659 &cryptodev_null_testsuite,
15660 &cryptodev_aes_ccm_auth_testsuite,
15661 &cryptodev_aes_gcm_auth_testsuite,
15662 &cryptodev_aes_gmac_auth_testsuite,
15663 &cryptodev_snow3g_testsuite,
15664 &cryptodev_chacha20_poly1305_testsuite,
15665 &cryptodev_zuc_testsuite,
15666 &cryptodev_hmac_md5_auth_testsuite,
15667 &cryptodev_kasumi_testsuite,
15668 &cryptodev_esn_testsuite,
15669 &cryptodev_negative_aes_gcm_testsuite,
15670 &cryptodev_negative_aes_gmac_testsuite,
15671 &cryptodev_mixed_cipher_hash_testsuite,
15672 &cryptodev_negative_hmac_sha1_testsuite,
15673 &cryptodev_gen_testsuite,
15674 #ifdef RTE_LIB_SECURITY
15675 &ipsec_proto_testsuite,
15676 &pdcp_proto_testsuite,
15677 &docsis_proto_testsuite,
15681 static struct unit_test_suite ts = {
15682 .suite_name = "Cryptodev Unit Test Suite",
15683 .setup = testsuite_setup,
15684 .teardown = testsuite_teardown,
15685 .unit_test_cases = {TEST_CASES_END()}
15688 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
15690 if (gbl_driver_id == -1) {
15691 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
15692 return TEST_SKIPPED;
15695 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15696 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
15698 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
15699 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15700 ret = unit_test_suite_runner(&ts);
15702 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
15703 free(ts.unit_test_suites);
15708 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
15710 struct rte_cryptodev_info dev_info;
15711 uint8_t i, nb_devs;
15714 driver_id = rte_cryptodev_driver_id_get(pmd_name);
15715 if (driver_id == -1) {
15716 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
15717 return TEST_SKIPPED;
15720 nb_devs = rte_cryptodev_count();
15722 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
15723 return TEST_SKIPPED;
15726 for (i = 0; i < nb_devs; i++) {
15727 rte_cryptodev_info_get(i, &dev_info);
15728 if (dev_info.driver_id == driver_id) {
15729 if (!(dev_info.feature_flags & flag)) {
15730 RTE_LOG(INFO, USER1, "%s not supported\n",
15732 return TEST_SKIPPED;
15734 return 0; /* found */
15738 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
15739 return TEST_SKIPPED;
15743 test_cryptodev_qat(void)
15745 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
15749 test_cryptodev_virtio(void)
15751 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
15755 test_cryptodev_aesni_mb(void)
15757 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15761 test_cryptodev_cpu_aesni_mb(void)
15764 enum rte_security_session_action_type at = gbl_action_type;
15765 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15766 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15767 gbl_action_type = at;
15772 test_cryptodev_chacha_poly_mb(void)
15775 enum rte_security_session_action_type at = gbl_action_type;
15776 rc = run_cryptodev_testsuite(
15777 RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
15778 gbl_action_type = at;
15783 test_cryptodev_openssl(void)
15785 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
15789 test_cryptodev_aesni_gcm(void)
15791 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15795 test_cryptodev_cpu_aesni_gcm(void)
15798 enum rte_security_session_action_type at = gbl_action_type;
15799 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15800 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15801 gbl_action_type = at;
15806 test_cryptodev_mlx5(void)
15808 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
15812 test_cryptodev_null(void)
15814 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
15818 test_cryptodev_sw_snow3g(void)
15820 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
15824 test_cryptodev_sw_kasumi(void)
15826 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
15830 test_cryptodev_sw_zuc(void)
15832 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
15836 test_cryptodev_armv8(void)
15838 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
15842 test_cryptodev_mrvl(void)
15844 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
15847 #ifdef RTE_CRYPTO_SCHEDULER
15850 test_cryptodev_scheduler(void)
15852 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
15853 const enum blockcipher_test_type blk_suites[] = {
15854 BLKCIPHER_AES_CHAIN_TYPE,
15855 BLKCIPHER_AES_CIPHERONLY_TYPE,
15856 BLKCIPHER_AUTHONLY_TYPE
15858 static struct unit_test_suite scheduler_multicore = {
15859 .suite_name = "Scheduler Multicore Unit Test Suite",
15860 .setup = scheduler_multicore_testsuite_setup,
15861 .teardown = scheduler_mode_testsuite_teardown,
15862 .unit_test_cases = {TEST_CASES_END()}
15864 static struct unit_test_suite scheduler_round_robin = {
15865 .suite_name = "Scheduler Round Robin Unit Test Suite",
15866 .setup = scheduler_roundrobin_testsuite_setup,
15867 .teardown = scheduler_mode_testsuite_teardown,
15868 .unit_test_cases = {TEST_CASES_END()}
15870 static struct unit_test_suite scheduler_failover = {
15871 .suite_name = "Scheduler Failover Unit Test Suite",
15872 .setup = scheduler_failover_testsuite_setup,
15873 .teardown = scheduler_mode_testsuite_teardown,
15874 .unit_test_cases = {TEST_CASES_END()}
15876 static struct unit_test_suite scheduler_pkt_size_distr = {
15877 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
15878 .setup = scheduler_pkt_size_distr_testsuite_setup,
15879 .teardown = scheduler_mode_testsuite_teardown,
15880 .unit_test_cases = {TEST_CASES_END()}
15882 struct unit_test_suite *sched_mode_suites[] = {
15883 &scheduler_multicore,
15884 &scheduler_round_robin,
15885 &scheduler_failover,
15886 &scheduler_pkt_size_distr
15888 static struct unit_test_suite scheduler_config = {
15889 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
15890 .unit_test_cases = {
15891 TEST_CASE(test_scheduler_attach_worker_op),
15892 TEST_CASE(test_scheduler_mode_multicore_op),
15893 TEST_CASE(test_scheduler_mode_roundrobin_op),
15894 TEST_CASE(test_scheduler_mode_failover_op),
15895 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
15896 TEST_CASE(test_scheduler_detach_worker_op),
15898 TEST_CASES_END() /**< NULL terminate array */
15901 struct unit_test_suite *static_suites[] = {
15905 static struct unit_test_suite ts = {
15906 .suite_name = "Scheduler Unit Test Suite",
15907 .setup = scheduler_testsuite_setup,
15908 .teardown = testsuite_teardown,
15909 .unit_test_cases = {TEST_CASES_END()}
15912 gbl_driver_id = rte_cryptodev_driver_id_get(
15913 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15915 if (gbl_driver_id == -1) {
15916 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
15917 return TEST_SKIPPED;
15920 if (rte_cryptodev_driver_id_get(
15921 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
15922 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
15923 return TEST_SKIPPED;
15926 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15928 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
15929 (struct unit_test_suite *) *
15930 (RTE_DIM(blk_suites) + 1));
15931 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
15932 blk_suites, RTE_DIM(blk_suites));
15933 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
15936 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15937 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
15938 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
15939 RTE_DIM(sched_mode_suites));
15940 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15941 ret = unit_test_suite_runner(&ts);
15943 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15944 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
15945 (*sched_mode_suites[sched_i]),
15946 RTE_DIM(blk_suites));
15947 free(sched_mode_suites[sched_i]->unit_test_suites);
15949 free(ts.unit_test_suites);
15953 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
15958 test_cryptodev_dpaa2_sec(void)
15960 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
15964 test_cryptodev_dpaa_sec(void)
15966 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
15970 test_cryptodev_ccp(void)
15972 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
15976 test_cryptodev_octeontx(void)
15978 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
15982 test_cryptodev_caam_jr(void)
15984 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
15988 test_cryptodev_nitrox(void)
15990 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
15994 test_cryptodev_bcmfs(void)
15996 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
16000 test_cryptodev_qat_raw_api(void)
16002 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
16005 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16010 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16011 ret = run_cryptodev_testsuite(pmd_name);
16012 global_api_test_type = CRYPTODEV_API_TEST;
16018 test_cryptodev_cn9k(void)
16020 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
16024 test_cryptodev_cn10k(void)
16026 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
16030 test_cryptodev_dpaa2_sec_raw_api(void)
16032 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16035 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16040 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16041 ret = run_cryptodev_testsuite(pmd_name);
16042 global_api_test_type = CRYPTODEV_API_TEST;
16048 test_cryptodev_dpaa_sec_raw_api(void)
16050 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16053 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16058 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16059 ret = run_cryptodev_testsuite(pmd_name);
16060 global_api_test_type = CRYPTODEV_API_TEST;
16065 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
16066 test_cryptodev_dpaa2_sec_raw_api);
16067 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
16068 test_cryptodev_dpaa_sec_raw_api);
16069 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
16070 test_cryptodev_qat_raw_api);
16071 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
16072 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
16073 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
16074 test_cryptodev_cpu_aesni_mb);
16075 REGISTER_TEST_COMMAND(cryptodev_chacha_poly_mb_autotest,
16076 test_cryptodev_chacha_poly_mb);
16077 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
16078 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
16079 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
16080 test_cryptodev_cpu_aesni_gcm);
16081 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
16082 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
16083 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
16084 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
16085 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
16086 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
16087 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
16088 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
16089 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
16090 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
16091 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
16092 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
16093 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
16094 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
16095 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
16096 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
16097 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
16099 #endif /* !RTE_EXEC_ENV_WINDOWS */