1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
19 #include <rte_cryptodev_pmd.h>
20 #include <rte_string_fns.h>
22 #ifdef RTE_CRYPTO_SCHEDULER
23 #include <rte_cryptodev_scheduler.h>
24 #include <rte_cryptodev_scheduler_operations.h>
27 #include <rte_lcore.h>
30 #include "test_cryptodev.h"
32 #include "test_cryptodev_blockcipher.h"
33 #include "test_cryptodev_aes_test_vectors.h"
34 #include "test_cryptodev_des_test_vectors.h"
35 #include "test_cryptodev_hash_test_vectors.h"
36 #include "test_cryptodev_kasumi_test_vectors.h"
37 #include "test_cryptodev_kasumi_hash_test_vectors.h"
38 #include "test_cryptodev_snow3g_test_vectors.h"
39 #include "test_cryptodev_snow3g_hash_test_vectors.h"
40 #include "test_cryptodev_zuc_test_vectors.h"
41 #include "test_cryptodev_aead_test_vectors.h"
42 #include "test_cryptodev_hmac_test_vectors.h"
43 #include "test_cryptodev_mixed_test_vectors.h"
44 #ifdef RTE_LIB_SECURITY
45 #include "test_cryptodev_security_pdcp_test_vectors.h"
46 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
47 #include "test_cryptodev_security_pdcp_test_func.h"
48 #include "test_cryptodev_security_docsis_test_vectors.h"
50 #define SDAP_DISABLED 0
51 #define SDAP_ENABLED 1
54 #define VDEV_ARGS_SIZE 100
55 #define MAX_NB_SESSIONS 4
57 #define MAX_DRV_SERVICE_CTX_SIZE 256
59 #define MAX_RAW_DEQUEUE_COUNT 65535
62 #define OUT_OF_PLACE 1
65 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
68 static int gbl_driver_id;
70 static enum rte_security_session_action_type gbl_action_type =
71 RTE_SECURITY_ACTION_TYPE_NONE;
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 struct crypto_unittest_params {
76 struct rte_crypto_sym_xform cipher_xform;
77 struct rte_crypto_sym_xform auth_xform;
78 struct rte_crypto_sym_xform aead_xform;
79 #ifdef RTE_LIB_SECURITY
80 struct rte_security_docsis_xform docsis_xform;
84 struct rte_cryptodev_sym_session *sess;
85 #ifdef RTE_LIB_SECURITY
86 struct rte_security_session *sec_session;
89 #ifdef RTE_LIB_SECURITY
90 enum rte_security_session_action_type type;
92 struct rte_crypto_op *op;
94 struct rte_mbuf *obuf, *ibuf;
99 #define ALIGN_POW2_ROUNDUP(num, align) \
100 (((num) + (align) - 1) & ~((align) - 1))
102 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
103 for (j = 0; j < num_child_ts; index++, j++) \
104 parent_ts.unit_test_suites[index] = child_ts[j]
106 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
107 for (j = 0; j < num_blk_types; index++, j++) \
108 parent_ts.unit_test_suites[index] = \
109 build_blockcipher_test_suite(blk_types[j])
111 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
112 for (j = index; j < index + num_blk_types; j++) \
113 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
116 * Forward declarations.
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 struct crypto_unittest_params *ut_params,
126 struct crypto_testsuite_params *ts_param,
127 const uint8_t *cipher,
128 const uint8_t *digest,
131 static struct rte_mbuf *
132 setup_test_string(struct rte_mempool *mpool,
133 const char *string, size_t len, uint8_t blocksize)
135 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
136 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
138 memset(m->buf_addr, 0, m->buf_len);
140 char *dst = rte_pktmbuf_append(m, t_len);
147 rte_memcpy(dst, string, t_len);
149 memset(dst, 0, t_len);
155 /* Get number of bytes in X bits (rounding up) */
157 ceil_byte_length(uint32_t num_bits)
160 return ((num_bits >> 3) + 1);
162 return (num_bits >> 3);
166 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
167 uint8_t is_op_success)
169 struct rte_crypto_op *op = user_data;
170 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
171 RTE_CRYPTO_OP_STATUS_ERROR;
175 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
176 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
177 uint8_t len_in_bits, uint8_t cipher_iv_len)
179 struct rte_crypto_sym_op *sop = op->sym;
180 struct rte_crypto_op *ret_op = NULL;
181 struct rte_crypto_vec data_vec[UINT8_MAX];
182 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
183 union rte_crypto_sym_ofs ofs;
184 struct rte_crypto_sym_vec vec;
185 struct rte_crypto_sgl sgl;
187 union rte_cryptodev_session_ctx sess;
189 struct rte_crypto_raw_dp_ctx *ctx;
190 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
194 int ctx_service_size;
196 int enqueue_status, dequeue_status;
198 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
199 if (ctx_service_size < 0) {
200 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
204 ctx = malloc(ctx_service_size);
206 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
210 /* Both are enums, setting crypto_sess will suit any session type */
211 sess.crypto_sess = op->sym->session;
213 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
214 op->sess_type, sess, 0) < 0) {
215 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
221 aad_auth_iv.iova = 0;
222 aad_auth_iv.va = NULL;
229 vec.digest = &digest;
230 vec.aad = &aad_auth_iv;
231 vec.status = &status;
235 if (is_cipher && is_auth) {
236 cipher_offset = sop->cipher.data.offset;
237 cipher_len = sop->cipher.data.length;
238 auth_offset = sop->auth.data.offset;
239 auth_len = sop->auth.data.length;
240 max_len = RTE_MAX(cipher_offset + cipher_len,
241 auth_offset + auth_len);
243 max_len = max_len >> 3;
244 cipher_offset = cipher_offset >> 3;
245 auth_offset = auth_offset >> 3;
246 cipher_len = cipher_len >> 3;
247 auth_len = auth_len >> 3;
249 ofs.ofs.cipher.head = cipher_offset;
250 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
251 ofs.ofs.auth.head = auth_offset;
252 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
253 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
254 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
255 aad_auth_iv.va = rte_crypto_op_ctod_offset(
256 op, void *, IV_OFFSET + cipher_iv_len);
257 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
259 digest.va = (void *)sop->auth.digest.data;
260 digest.iova = sop->auth.digest.phys_addr;
262 } else if (is_cipher) {
263 cipher_offset = sop->cipher.data.offset;
264 cipher_len = sop->cipher.data.length;
265 max_len = cipher_len + cipher_offset;
267 max_len = max_len >> 3;
268 cipher_offset = cipher_offset >> 3;
269 cipher_len = cipher_len >> 3;
271 ofs.ofs.cipher.head = cipher_offset;
272 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
273 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
274 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
276 } else if (is_auth) {
277 auth_offset = sop->auth.data.offset;
278 auth_len = sop->auth.data.length;
279 max_len = auth_len + auth_offset;
281 max_len = max_len >> 3;
282 auth_offset = auth_offset >> 3;
283 auth_len = auth_len >> 3;
285 ofs.ofs.auth.head = auth_offset;
286 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
287 aad_auth_iv.va = rte_crypto_op_ctod_offset(
288 op, void *, IV_OFFSET + cipher_iv_len);
289 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
291 digest.va = (void *)sop->auth.digest.data;
292 digest.iova = sop->auth.digest.phys_addr;
295 cipher_offset = sop->aead.data.offset;
296 cipher_len = sop->aead.data.length;
297 max_len = cipher_len + cipher_offset;
299 max_len = max_len >> 3;
300 cipher_offset = cipher_offset >> 3;
301 cipher_len = cipher_len >> 3;
303 ofs.ofs.cipher.head = cipher_offset;
304 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
305 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
306 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
307 aad_auth_iv.va = (void *)sop->aead.aad.data;
308 aad_auth_iv.iova = sop->aead.aad.phys_addr;
309 digest.va = (void *)sop->aead.digest.data;
310 digest.iova = sop->aead.digest.phys_addr;
313 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
314 data_vec, RTE_DIM(data_vec));
315 if (n < 0 || n > sop->m_src->nb_segs) {
316 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
322 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
323 &enqueue_status) < 1) {
324 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
328 if (enqueue_status == 0) {
329 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
331 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
334 } else if (enqueue_status < 0) {
335 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
340 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
341 n = rte_cryptodev_raw_dequeue_burst(ctx,
342 NULL, 1, post_process_raw_dp_op,
343 (void **)&ret_op, 0, &n_success,
345 if (dequeue_status < 0) {
346 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
353 if (n == 1 && dequeue_status == 0) {
354 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
355 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
360 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
361 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
362 RTE_CRYPTO_OP_STATUS_SUCCESS;
369 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
372 struct rte_crypto_sym_op *sop;
373 union rte_crypto_sym_ofs ofs;
374 struct rte_crypto_sgl sgl;
375 struct rte_crypto_sym_vec symvec;
376 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
377 struct rte_crypto_vec vec[UINT8_MAX];
381 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
382 sop->aead.data.length, vec, RTE_DIM(vec));
384 if (n < 0 || n != sop->m_src->nb_segs) {
385 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
393 symvec.digest = &digest_ptr;
394 symvec.aad = &aad_ptr;
398 /* for CPU crypto the IOVA address is not required */
399 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
400 digest_ptr.va = (void *)sop->aead.digest.data;
401 aad_ptr.va = (void *)sop->aead.aad.data;
405 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
409 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
411 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
415 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
418 struct rte_crypto_sym_op *sop;
419 union rte_crypto_sym_ofs ofs;
420 struct rte_crypto_sgl sgl;
421 struct rte_crypto_sym_vec symvec;
422 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
423 struct rte_crypto_vec vec[UINT8_MAX];
427 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
428 sop->auth.data.length, vec, RTE_DIM(vec));
430 if (n < 0 || n != sop->m_src->nb_segs) {
431 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
439 symvec.digest = &digest_ptr;
443 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
444 digest_ptr.va = (void *)sop->auth.digest.data;
447 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
448 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
449 (sop->cipher.data.offset + sop->cipher.data.length);
451 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
455 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
457 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
460 static struct rte_crypto_op *
461 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
464 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
466 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
467 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
473 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
476 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
477 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
484 static struct crypto_testsuite_params testsuite_params = { NULL };
485 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
486 static struct crypto_unittest_params unittest_params;
489 testsuite_setup(void)
491 struct crypto_testsuite_params *ts_params = &testsuite_params;
492 struct rte_cryptodev_info info;
493 uint32_t i = 0, nb_devs, dev_id;
496 memset(ts_params, 0, sizeof(*ts_params));
498 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
499 if (ts_params->mbuf_pool == NULL) {
500 /* Not already created so create */
501 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
503 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
505 if (ts_params->mbuf_pool == NULL) {
506 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
511 ts_params->large_mbuf_pool = rte_mempool_lookup(
512 "CRYPTO_LARGE_MBUFPOOL");
513 if (ts_params->large_mbuf_pool == NULL) {
514 /* Not already created so create */
515 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
516 "CRYPTO_LARGE_MBUFPOOL",
519 if (ts_params->large_mbuf_pool == NULL) {
521 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
526 ts_params->op_mpool = rte_crypto_op_pool_create(
527 "MBUF_CRYPTO_SYM_OP_POOL",
528 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
529 NUM_MBUFS, MBUF_CACHE_SIZE,
531 sizeof(struct rte_crypto_sym_xform) +
534 if (ts_params->op_mpool == NULL) {
535 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
539 nb_devs = rte_cryptodev_count();
541 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
545 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
546 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
547 rte_cryptodev_driver_name_get(gbl_driver_id));
551 /* Create list of valid crypto devs */
552 for (i = 0; i < nb_devs; i++) {
553 rte_cryptodev_info_get(i, &info);
554 if (info.driver_id == gbl_driver_id)
555 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
558 if (ts_params->valid_dev_count < 1)
561 /* Set up all the qps on the first of the valid devices found */
563 dev_id = ts_params->valid_devs[0];
565 rte_cryptodev_info_get(dev_id, &info);
567 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
568 ts_params->conf.socket_id = SOCKET_ID_ANY;
569 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
571 unsigned int session_size =
572 rte_cryptodev_sym_get_private_session_size(dev_id);
574 #ifdef RTE_LIB_SECURITY
575 unsigned int security_session_size = rte_security_session_get_size(
576 rte_cryptodev_get_sec_ctx(dev_id));
578 if (session_size < security_session_size)
579 session_size = security_session_size;
582 * Create mempool with maximum number of sessions.
584 if (info.sym.max_nb_sessions != 0 &&
585 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
586 RTE_LOG(ERR, USER1, "Device does not support "
587 "at least %u sessions\n",
592 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
593 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
595 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
596 "session mempool allocation failed");
598 ts_params->session_priv_mpool = rte_mempool_create(
602 0, 0, NULL, NULL, NULL,
605 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
606 "session mempool allocation failed");
610 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
612 "Failed to configure cryptodev %u with %u qps",
613 dev_id, ts_params->conf.nb_queue_pairs);
615 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
616 ts_params->qp_conf.mp_session = ts_params->session_mpool;
617 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
619 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
620 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
621 dev_id, qp_id, &ts_params->qp_conf,
622 rte_cryptodev_socket_id(dev_id)),
623 "Failed to setup queue pair %u on cryptodev %u",
631 testsuite_teardown(void)
633 struct crypto_testsuite_params *ts_params = &testsuite_params;
636 if (ts_params->mbuf_pool != NULL) {
637 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
638 rte_mempool_avail_count(ts_params->mbuf_pool));
641 if (ts_params->op_mpool != NULL) {
642 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
643 rte_mempool_avail_count(ts_params->op_mpool));
646 /* Free session mempools */
647 if (ts_params->session_priv_mpool != NULL) {
648 rte_mempool_free(ts_params->session_priv_mpool);
649 ts_params->session_priv_mpool = NULL;
652 if (ts_params->session_mpool != NULL) {
653 rte_mempool_free(ts_params->session_mpool);
654 ts_params->session_mpool = NULL;
657 res = rte_cryptodev_close(ts_params->valid_devs[0]);
659 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
663 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
664 const int *algs, uint16_t num_algs)
666 uint8_t dev_id = testsuite_params.valid_devs[0];
667 bool some_alg_supported = FALSE;
670 for (i = 0; i < num_algs && !some_alg_supported; i++) {
671 struct rte_cryptodev_sym_capability_idx alg = {
674 if (rte_cryptodev_sym_capability_get(dev_id,
676 some_alg_supported = TRUE;
678 if (!some_alg_supported)
685 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
686 uint16_t num_ciphers)
688 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
689 (const int *) ciphers, num_ciphers);
693 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
696 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
697 (const int *) auths, num_auths);
701 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
704 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
705 (const int *) aeads, num_aeads);
709 null_testsuite_setup(void)
711 struct crypto_testsuite_params *ts_params = &testsuite_params;
712 uint8_t dev_id = ts_params->valid_devs[0];
713 struct rte_cryptodev_info dev_info;
714 const enum rte_crypto_cipher_algorithm ciphers[] = {
715 RTE_CRYPTO_CIPHER_NULL
717 const enum rte_crypto_auth_algorithm auths[] = {
721 rte_cryptodev_info_get(dev_id, &dev_info);
723 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
724 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
725 "testsuite not met\n");
729 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
730 && check_auth_capabilities_supported(auths,
731 RTE_DIM(auths)) != 0) {
732 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
733 "testsuite not met\n");
741 crypto_gen_testsuite_setup(void)
743 struct crypto_testsuite_params *ts_params = &testsuite_params;
744 uint8_t dev_id = ts_params->valid_devs[0];
745 struct rte_cryptodev_info dev_info;
747 rte_cryptodev_info_get(dev_id, &dev_info);
749 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
750 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
751 "testsuite not met\n");
758 #ifdef RTE_LIB_SECURITY
760 pdcp_proto_testsuite_setup(void)
762 struct crypto_testsuite_params *ts_params = &testsuite_params;
763 uint8_t dev_id = ts_params->valid_devs[0];
764 struct rte_cryptodev_info dev_info;
765 const enum rte_crypto_cipher_algorithm ciphers[] = {
766 RTE_CRYPTO_CIPHER_NULL,
767 RTE_CRYPTO_CIPHER_AES_CTR,
768 RTE_CRYPTO_CIPHER_ZUC_EEA3,
769 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
771 const enum rte_crypto_auth_algorithm auths[] = {
772 RTE_CRYPTO_AUTH_NULL,
773 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
774 RTE_CRYPTO_AUTH_AES_CMAC,
775 RTE_CRYPTO_AUTH_ZUC_EIA3
778 rte_cryptodev_info_get(dev_id, &dev_info);
780 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
781 !(dev_info.feature_flags &
782 RTE_CRYPTODEV_FF_SECURITY)) {
783 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
784 "testsuite not met\n");
788 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
789 && check_auth_capabilities_supported(auths,
790 RTE_DIM(auths)) != 0) {
791 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
792 "testsuite not met\n");
800 docsis_proto_testsuite_setup(void)
802 struct crypto_testsuite_params *ts_params = &testsuite_params;
803 uint8_t dev_id = ts_params->valid_devs[0];
804 struct rte_cryptodev_info dev_info;
805 const enum rte_crypto_cipher_algorithm ciphers[] = {
806 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
809 rte_cryptodev_info_get(dev_id, &dev_info);
811 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
812 !(dev_info.feature_flags &
813 RTE_CRYPTODEV_FF_SECURITY)) {
814 RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
815 "Proto testsuite not met\n");
819 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
820 RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
821 "testsuite not met\n");
830 aes_ccm_auth_testsuite_setup(void)
832 struct crypto_testsuite_params *ts_params = &testsuite_params;
833 uint8_t dev_id = ts_params->valid_devs[0];
834 struct rte_cryptodev_info dev_info;
835 const enum rte_crypto_aead_algorithm aeads[] = {
836 RTE_CRYPTO_AEAD_AES_CCM
839 rte_cryptodev_info_get(dev_id, &dev_info);
841 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
842 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
843 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
844 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
845 "testsuite not met\n");
849 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
850 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
851 "testsuite not met\n");
859 aes_gcm_auth_testsuite_setup(void)
861 struct crypto_testsuite_params *ts_params = &testsuite_params;
862 uint8_t dev_id = ts_params->valid_devs[0];
863 struct rte_cryptodev_info dev_info;
864 const enum rte_crypto_aead_algorithm aeads[] = {
865 RTE_CRYPTO_AEAD_AES_GCM
868 rte_cryptodev_info_get(dev_id, &dev_info);
870 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
871 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
872 "testsuite not met\n");
876 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
877 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
878 "testsuite not met\n");
886 aes_gmac_auth_testsuite_setup(void)
888 struct crypto_testsuite_params *ts_params = &testsuite_params;
889 uint8_t dev_id = ts_params->valid_devs[0];
890 struct rte_cryptodev_info dev_info;
891 const enum rte_crypto_auth_algorithm auths[] = {
892 RTE_CRYPTO_AUTH_AES_GMAC
895 rte_cryptodev_info_get(dev_id, &dev_info);
897 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
898 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
899 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
900 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
901 "testsuite not met\n");
905 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
906 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
907 "testsuite not met\n");
915 chacha20_poly1305_testsuite_setup(void)
917 struct crypto_testsuite_params *ts_params = &testsuite_params;
918 uint8_t dev_id = ts_params->valid_devs[0];
919 struct rte_cryptodev_info dev_info;
920 const enum rte_crypto_aead_algorithm aeads[] = {
921 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
924 rte_cryptodev_info_get(dev_id, &dev_info);
926 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
927 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
928 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
929 RTE_LOG(INFO, USER1, "Feature flag requirements for "
930 "Chacha20-Poly1305 testsuite not met\n");
934 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
935 RTE_LOG(INFO, USER1, "Capability requirements for "
936 "Chacha20-Poly1305 testsuite not met\n");
944 snow3g_testsuite_setup(void)
946 struct crypto_testsuite_params *ts_params = &testsuite_params;
947 uint8_t dev_id = ts_params->valid_devs[0];
948 struct rte_cryptodev_info dev_info;
949 const enum rte_crypto_cipher_algorithm ciphers[] = {
950 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
953 const enum rte_crypto_auth_algorithm auths[] = {
954 RTE_CRYPTO_AUTH_SNOW3G_UIA2
957 rte_cryptodev_info_get(dev_id, &dev_info);
959 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
960 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
961 "testsuite not met\n");
965 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
966 && check_auth_capabilities_supported(auths,
967 RTE_DIM(auths)) != 0) {
968 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
969 "testsuite not met\n");
977 zuc_testsuite_setup(void)
979 struct crypto_testsuite_params *ts_params = &testsuite_params;
980 uint8_t dev_id = ts_params->valid_devs[0];
981 struct rte_cryptodev_info dev_info;
982 const enum rte_crypto_cipher_algorithm ciphers[] = {
983 RTE_CRYPTO_CIPHER_ZUC_EEA3
985 const enum rte_crypto_auth_algorithm auths[] = {
986 RTE_CRYPTO_AUTH_ZUC_EIA3
989 rte_cryptodev_info_get(dev_id, &dev_info);
991 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
992 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
993 "testsuite not met\n");
997 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
998 && check_auth_capabilities_supported(auths,
999 RTE_DIM(auths)) != 0) {
1000 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1001 "testsuite not met\n");
1002 return TEST_SKIPPED;
1009 hmac_md5_auth_testsuite_setup(void)
1011 struct crypto_testsuite_params *ts_params = &testsuite_params;
1012 uint8_t dev_id = ts_params->valid_devs[0];
1013 struct rte_cryptodev_info dev_info;
1014 const enum rte_crypto_auth_algorithm auths[] = {
1015 RTE_CRYPTO_AUTH_MD5_HMAC
1018 rte_cryptodev_info_get(dev_id, &dev_info);
1020 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1021 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1022 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1023 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1024 "Auth testsuite not met\n");
1025 return TEST_SKIPPED;
1028 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1029 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1030 "testsuite not met\n");
1031 return TEST_SKIPPED;
1038 kasumi_testsuite_setup(void)
1040 struct crypto_testsuite_params *ts_params = &testsuite_params;
1041 uint8_t dev_id = ts_params->valid_devs[0];
1042 struct rte_cryptodev_info dev_info;
1043 const enum rte_crypto_cipher_algorithm ciphers[] = {
1044 RTE_CRYPTO_CIPHER_KASUMI_F8
1046 const enum rte_crypto_auth_algorithm auths[] = {
1047 RTE_CRYPTO_AUTH_KASUMI_F9
1050 rte_cryptodev_info_get(dev_id, &dev_info);
1052 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1053 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1054 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1055 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1056 "testsuite not met\n");
1057 return TEST_SKIPPED;
1060 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1061 && check_auth_capabilities_supported(auths,
1062 RTE_DIM(auths)) != 0) {
1063 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1064 "testsuite not met\n");
1065 return TEST_SKIPPED;
1072 negative_aes_gcm_testsuite_setup(void)
1074 struct crypto_testsuite_params *ts_params = &testsuite_params;
1075 uint8_t dev_id = ts_params->valid_devs[0];
1076 struct rte_cryptodev_info dev_info;
1077 const enum rte_crypto_aead_algorithm aeads[] = {
1078 RTE_CRYPTO_AEAD_AES_GCM
1081 rte_cryptodev_info_get(dev_id, &dev_info);
1083 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1084 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1085 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1086 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1087 "AES GCM testsuite not met\n");
1088 return TEST_SKIPPED;
1091 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1092 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1093 "AES GCM testsuite not met\n");
1094 return TEST_SKIPPED;
1101 negative_aes_gmac_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_AES_GMAC
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 Negative "
1116 "AES GMAC 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 Negative "
1122 "AES GMAC testsuite not met\n");
1123 return TEST_SKIPPED;
1130 mixed_cipher_hash_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 uint64_t feat_flags;
1136 const enum rte_crypto_cipher_algorithm ciphers[] = {
1137 RTE_CRYPTO_CIPHER_NULL,
1138 RTE_CRYPTO_CIPHER_AES_CTR,
1139 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1140 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1142 const enum rte_crypto_auth_algorithm auths[] = {
1143 RTE_CRYPTO_AUTH_NULL,
1144 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1145 RTE_CRYPTO_AUTH_AES_CMAC,
1146 RTE_CRYPTO_AUTH_ZUC_EIA3
1149 rte_cryptodev_info_get(dev_id, &dev_info);
1150 feat_flags = dev_info.feature_flags;
1152 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1153 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1154 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1155 "Cipher Hash testsuite not met\n");
1156 return TEST_SKIPPED;
1159 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1160 && check_auth_capabilities_supported(auths,
1161 RTE_DIM(auths)) != 0) {
1162 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1163 "Cipher Hash testsuite not met\n");
1164 return TEST_SKIPPED;
1171 esn_testsuite_setup(void)
1173 struct crypto_testsuite_params *ts_params = &testsuite_params;
1174 uint8_t dev_id = ts_params->valid_devs[0];
1175 struct rte_cryptodev_info dev_info;
1176 const enum rte_crypto_cipher_algorithm ciphers[] = {
1177 RTE_CRYPTO_CIPHER_AES_CBC
1179 const enum rte_crypto_auth_algorithm auths[] = {
1180 RTE_CRYPTO_AUTH_SHA1_HMAC
1183 rte_cryptodev_info_get(dev_id, &dev_info);
1185 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1186 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1187 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1188 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1189 "testsuite not met\n");
1190 return TEST_SKIPPED;
1193 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1194 && check_auth_capabilities_supported(auths,
1195 RTE_DIM(auths)) != 0) {
1196 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1197 "testsuite not met\n");
1198 return TEST_SKIPPED;
1205 multi_session_testsuite_setup(void)
1207 struct crypto_testsuite_params *ts_params = &testsuite_params;
1208 uint8_t dev_id = ts_params->valid_devs[0];
1209 struct rte_cryptodev_info dev_info;
1210 const enum rte_crypto_cipher_algorithm ciphers[] = {
1211 RTE_CRYPTO_CIPHER_AES_CBC
1213 const enum rte_crypto_auth_algorithm auths[] = {
1214 RTE_CRYPTO_AUTH_SHA512_HMAC
1217 rte_cryptodev_info_get(dev_id, &dev_info);
1219 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1220 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1221 "Session testsuite not met\n");
1222 return TEST_SKIPPED;
1225 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1226 && check_auth_capabilities_supported(auths,
1227 RTE_DIM(auths)) != 0) {
1228 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1229 "Session testsuite not met\n");
1230 return TEST_SKIPPED;
1237 negative_hmac_sha1_testsuite_setup(void)
1239 struct crypto_testsuite_params *ts_params = &testsuite_params;
1240 uint8_t dev_id = ts_params->valid_devs[0];
1241 struct rte_cryptodev_info dev_info;
1242 const enum rte_crypto_cipher_algorithm ciphers[] = {
1243 RTE_CRYPTO_CIPHER_AES_CBC
1245 const enum rte_crypto_auth_algorithm auths[] = {
1246 RTE_CRYPTO_AUTH_SHA1_HMAC
1249 rte_cryptodev_info_get(dev_id, &dev_info);
1251 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1252 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1253 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1254 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1255 "HMAC SHA1 testsuite not met\n");
1256 return TEST_SKIPPED;
1259 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1260 && check_auth_capabilities_supported(auths,
1261 RTE_DIM(auths)) != 0) {
1262 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1263 "HMAC SHA1 testsuite not met\n");
1264 return TEST_SKIPPED;
1271 dev_configure_and_start(uint64_t ff_disable)
1273 struct crypto_testsuite_params *ts_params = &testsuite_params;
1274 struct crypto_unittest_params *ut_params = &unittest_params;
1278 /* Clear unit test parameters before running test */
1279 memset(ut_params, 0, sizeof(*ut_params));
1281 /* Reconfigure device to default parameters */
1282 ts_params->conf.socket_id = SOCKET_ID_ANY;
1283 ts_params->conf.ff_disable = ff_disable;
1284 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1285 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1286 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1288 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1290 "Failed to configure cryptodev %u",
1291 ts_params->valid_devs[0]);
1293 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1294 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1295 ts_params->valid_devs[0], qp_id,
1296 &ts_params->qp_conf,
1297 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1298 "Failed to setup queue pair %u on cryptodev %u",
1299 qp_id, ts_params->valid_devs[0]);
1303 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1305 /* Start the device */
1306 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1307 "Failed to start cryptodev %u",
1308 ts_params->valid_devs[0]);
1310 return TEST_SUCCESS;
1316 /* Configure and start the device with security feature disabled */
1317 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1321 ut_setup_security(void)
1323 /* Configure and start the device with no features disabled */
1324 return dev_configure_and_start(0);
1330 struct crypto_testsuite_params *ts_params = &testsuite_params;
1331 struct crypto_unittest_params *ut_params = &unittest_params;
1332 struct rte_cryptodev_stats stats;
1334 /* free crypto session structure */
1335 #ifdef RTE_LIB_SECURITY
1336 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1337 if (ut_params->sec_session) {
1338 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1339 (ts_params->valid_devs[0]),
1340 ut_params->sec_session);
1341 ut_params->sec_session = NULL;
1346 if (ut_params->sess) {
1347 rte_cryptodev_sym_session_clear(
1348 ts_params->valid_devs[0],
1350 rte_cryptodev_sym_session_free(ut_params->sess);
1351 ut_params->sess = NULL;
1355 /* free crypto operation structure */
1357 rte_crypto_op_free(ut_params->op);
1360 * free mbuf - both obuf and ibuf are usually the same,
1361 * so check if they point at the same address is necessary,
1362 * to avoid freeing the mbuf twice.
1364 if (ut_params->obuf) {
1365 rte_pktmbuf_free(ut_params->obuf);
1366 if (ut_params->ibuf == ut_params->obuf)
1367 ut_params->ibuf = 0;
1368 ut_params->obuf = 0;
1370 if (ut_params->ibuf) {
1371 rte_pktmbuf_free(ut_params->ibuf);
1372 ut_params->ibuf = 0;
1375 if (ts_params->mbuf_pool != NULL)
1376 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1377 rte_mempool_avail_count(ts_params->mbuf_pool));
1379 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1381 /* Stop the device */
1382 rte_cryptodev_stop(ts_params->valid_devs[0]);
1386 test_device_configure_invalid_dev_id(void)
1388 struct crypto_testsuite_params *ts_params = &testsuite_params;
1389 uint16_t dev_id, num_devs = 0;
1391 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1392 "Need at least %d devices for test", 1);
1394 /* valid dev_id values */
1395 dev_id = ts_params->valid_devs[0];
1397 /* Stop the device in case it's started so it can be configured */
1398 rte_cryptodev_stop(dev_id);
1400 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1401 "Failed test for rte_cryptodev_configure: "
1402 "invalid dev_num %u", dev_id);
1404 /* invalid dev_id values */
1407 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1408 "Failed test for rte_cryptodev_configure: "
1409 "invalid dev_num %u", dev_id);
1413 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1414 "Failed test for rte_cryptodev_configure:"
1415 "invalid dev_num %u", dev_id);
1417 return TEST_SUCCESS;
1421 test_device_configure_invalid_queue_pair_ids(void)
1423 struct crypto_testsuite_params *ts_params = &testsuite_params;
1424 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1426 /* Stop the device in case it's started so it can be configured */
1427 rte_cryptodev_stop(ts_params->valid_devs[0]);
1429 /* valid - max value queue pairs */
1430 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1432 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1434 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1435 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1437 /* valid - one queue pairs */
1438 ts_params->conf.nb_queue_pairs = 1;
1440 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1442 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1443 ts_params->valid_devs[0],
1444 ts_params->conf.nb_queue_pairs);
1447 /* invalid - zero queue pairs */
1448 ts_params->conf.nb_queue_pairs = 0;
1450 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1452 "Failed test for rte_cryptodev_configure, dev_id %u,"
1454 ts_params->valid_devs[0],
1455 ts_params->conf.nb_queue_pairs);
1458 /* invalid - max value supported by field queue pairs */
1459 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1461 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1463 "Failed test for rte_cryptodev_configure, dev_id %u,"
1465 ts_params->valid_devs[0],
1466 ts_params->conf.nb_queue_pairs);
1469 /* invalid - max value + 1 queue pairs */
1470 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1472 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1474 "Failed test for rte_cryptodev_configure, dev_id %u,"
1476 ts_params->valid_devs[0],
1477 ts_params->conf.nb_queue_pairs);
1479 /* revert to original testsuite value */
1480 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1482 return TEST_SUCCESS;
1486 test_queue_pair_descriptor_setup(void)
1488 struct crypto_testsuite_params *ts_params = &testsuite_params;
1489 struct rte_cryptodev_qp_conf qp_conf = {
1490 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1494 /* Stop the device in case it's started so it can be configured */
1495 rte_cryptodev_stop(ts_params->valid_devs[0]);
1497 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1499 "Failed to configure cryptodev %u",
1500 ts_params->valid_devs[0]);
1503 * Test various ring sizes on this device. memzones can't be
1504 * freed so are re-used if ring is released and re-created.
1506 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1507 qp_conf.mp_session = ts_params->session_mpool;
1508 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1510 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1511 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1512 ts_params->valid_devs[0], qp_id, &qp_conf,
1513 rte_cryptodev_socket_id(
1514 ts_params->valid_devs[0])),
1516 "rte_cryptodev_queue_pair_setup: num_inflights "
1517 "%u on qp %u on cryptodev %u",
1518 qp_conf.nb_descriptors, qp_id,
1519 ts_params->valid_devs[0]);
1522 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1524 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1525 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1526 ts_params->valid_devs[0], qp_id, &qp_conf,
1527 rte_cryptodev_socket_id(
1528 ts_params->valid_devs[0])),
1530 " rte_cryptodev_queue_pair_setup: num_inflights"
1531 " %u on qp %u on cryptodev %u",
1532 qp_conf.nb_descriptors, qp_id,
1533 ts_params->valid_devs[0]);
1536 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1538 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1539 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1540 ts_params->valid_devs[0], qp_id, &qp_conf,
1541 rte_cryptodev_socket_id(
1542 ts_params->valid_devs[0])),
1544 "rte_cryptodev_queue_pair_setup: num_inflights"
1545 " %u on qp %u on cryptodev %u",
1546 qp_conf.nb_descriptors, qp_id,
1547 ts_params->valid_devs[0]);
1550 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1552 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1553 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1554 ts_params->valid_devs[0], qp_id, &qp_conf,
1555 rte_cryptodev_socket_id(
1556 ts_params->valid_devs[0])),
1558 " rte_cryptodev_queue_pair_setup:"
1559 "num_inflights %u on qp %u on cryptodev %u",
1560 qp_conf.nb_descriptors, qp_id,
1561 ts_params->valid_devs[0]);
1564 /* test invalid queue pair id */
1565 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1567 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1569 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1570 ts_params->valid_devs[0],
1572 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1573 "Failed test for rte_cryptodev_queue_pair_setup:"
1574 "invalid qp %u on cryptodev %u",
1575 qp_id, ts_params->valid_devs[0]);
1577 qp_id = 0xffff; /*invalid*/
1579 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1580 ts_params->valid_devs[0],
1582 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1583 "Failed test for rte_cryptodev_queue_pair_setup:"
1584 "invalid qp %u on cryptodev %u",
1585 qp_id, ts_params->valid_devs[0]);
1587 return TEST_SUCCESS;
1590 /* ***** Plaintext data for tests ***** */
1592 const char catch_22_quote_1[] =
1593 "There was only one catch and that was Catch-22, which "
1594 "specified that a concern for one's safety in the face of "
1595 "dangers that were real and immediate was the process of a "
1596 "rational mind. Orr was crazy and could be grounded. All he "
1597 "had to do was ask; and as soon as he did, he would no longer "
1598 "be crazy and would have to fly more missions. Orr would be "
1599 "crazy to fly more missions and sane if he didn't, but if he "
1600 "was sane he had to fly them. If he flew them he was crazy "
1601 "and didn't have to; but if he didn't want to he was sane and "
1602 "had to. Yossarian was moved very deeply by the absolute "
1603 "simplicity of this clause of Catch-22 and let out a "
1604 "respectful whistle. \"That's some catch, that Catch-22\", he "
1605 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1607 const char catch_22_quote[] =
1608 "What a lousy earth! He wondered how many people were "
1609 "destitute that same night even in his own prosperous country, "
1610 "how many homes were shanties, how many husbands were drunk "
1611 "and wives socked, and how many children were bullied, abused, "
1612 "or abandoned. How many families hungered for food they could "
1613 "not afford to buy? How many hearts were broken? How many "
1614 "suicides would take place that same night, how many people "
1615 "would go insane? How many cockroaches and landlords would "
1616 "triumph? How many winners were losers, successes failures, "
1617 "and rich men poor men? How many wise guys were stupid? How "
1618 "many happy endings were unhappy endings? How many honest men "
1619 "were liars, brave men cowards, loyal men traitors, how many "
1620 "sainted men were corrupt, how many people in positions of "
1621 "trust had sold their souls to bodyguards, how many had never "
1622 "had souls? How many straight-and-narrow paths were crooked "
1623 "paths? How many best families were worst families and how "
1624 "many good people were bad people? When you added them all up "
1625 "and then subtracted, you might be left with only the children, "
1626 "and perhaps with Albert Einstein and an old violinist or "
1627 "sculptor somewhere.";
1629 #define QUOTE_480_BYTES (480)
1630 #define QUOTE_512_BYTES (512)
1631 #define QUOTE_768_BYTES (768)
1632 #define QUOTE_1024_BYTES (1024)
1636 /* ***** SHA1 Hash Tests ***** */
1638 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1640 static uint8_t hmac_sha1_key[] = {
1641 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1642 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1643 0xDE, 0xF4, 0xDE, 0xAD };
1645 /* ***** SHA224 Hash Tests ***** */
1647 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1650 /* ***** AES-CBC Cipher Tests ***** */
1652 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1653 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1655 static uint8_t aes_cbc_key[] = {
1656 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1657 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1659 static uint8_t aes_cbc_iv[] = {
1660 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1661 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1664 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1666 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1667 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1668 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1669 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1670 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1671 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1672 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1673 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1674 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1675 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1676 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1677 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1678 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1679 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1680 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1681 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1682 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1683 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1684 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1685 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1686 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1687 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1688 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1689 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1690 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1691 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1692 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1693 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1694 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1695 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1696 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1697 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1698 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1699 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1700 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1701 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1702 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1703 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1704 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1705 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1706 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1707 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1708 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1709 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1710 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1711 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1712 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1713 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1714 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1715 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1716 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1717 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1718 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1719 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1720 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1721 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1722 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1723 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1724 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1725 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1726 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1727 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1728 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1729 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1730 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1733 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1734 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1735 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1736 0x18, 0x8c, 0x1d, 0x32
1740 /* Multisession Vector context Test */
1741 /*Begin Session 0 */
1742 static uint8_t ms_aes_cbc_key0[] = {
1743 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1744 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1747 static uint8_t ms_aes_cbc_iv0[] = {
1748 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1749 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1752 static const uint8_t ms_aes_cbc_cipher0[] = {
1753 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1754 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1755 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1756 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1757 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1758 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1759 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1760 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1761 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1762 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1763 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1764 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1765 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1766 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1767 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1768 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1769 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1770 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1771 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1772 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1773 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1774 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1775 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1776 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1777 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1778 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1779 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1780 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1781 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1782 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1783 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1784 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1785 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1786 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1787 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1788 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1789 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1790 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1791 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1792 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1793 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1794 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1795 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1796 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1797 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1798 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1799 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1800 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1801 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1802 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1803 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1804 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1805 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1806 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1807 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1808 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1809 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1810 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1811 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1812 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1813 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1814 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1815 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1816 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1820 static uint8_t ms_hmac_key0[] = {
1821 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1822 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1823 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1824 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1825 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1826 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1827 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1828 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1831 static const uint8_t ms_hmac_digest0[] = {
1832 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1833 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1834 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1835 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1836 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1837 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1838 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1839 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1843 /* Begin session 1 */
1845 static uint8_t ms_aes_cbc_key1[] = {
1846 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1847 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1850 static uint8_t ms_aes_cbc_iv1[] = {
1851 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1852 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1855 static const uint8_t ms_aes_cbc_cipher1[] = {
1856 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1857 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1858 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1859 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1860 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1861 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1862 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1863 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1864 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1865 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1866 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1867 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1868 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1869 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1870 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1871 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1872 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1873 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1874 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1875 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1876 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1877 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1878 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1879 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1880 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1881 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1882 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1883 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1884 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1885 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1886 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1887 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1888 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1889 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1890 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1891 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1892 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1893 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1894 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1895 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1896 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1897 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1898 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1899 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1900 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1901 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1902 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1903 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1904 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1905 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1906 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1907 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1908 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1909 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1910 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1911 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1912 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1913 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1914 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1915 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1916 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1917 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1918 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1919 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1923 static uint8_t ms_hmac_key1[] = {
1924 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1925 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1926 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1927 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1928 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1929 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1930 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1931 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1934 static const uint8_t ms_hmac_digest1[] = {
1935 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1936 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1937 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1938 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1939 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1940 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1941 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1942 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1945 /* Begin Session 2 */
1946 static uint8_t ms_aes_cbc_key2[] = {
1947 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1948 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1951 static uint8_t ms_aes_cbc_iv2[] = {
1952 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1953 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1956 static const uint8_t ms_aes_cbc_cipher2[] = {
1957 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1958 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1959 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1960 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1961 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1962 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1963 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1964 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1965 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1966 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1967 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1968 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1969 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1970 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1971 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1972 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1973 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1974 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1975 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1976 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1977 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1978 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1979 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1980 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1981 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1982 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1983 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1984 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1985 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1986 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1987 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1988 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1989 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1990 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1991 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1992 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1993 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1994 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1995 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1996 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1997 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1998 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1999 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2000 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2001 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2002 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2003 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2004 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2005 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2006 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2007 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2008 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2009 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2010 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2011 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2012 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2013 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2014 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2015 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2016 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2017 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2018 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2019 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2020 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2023 static uint8_t ms_hmac_key2[] = {
2024 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2025 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2026 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2027 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2028 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2029 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2030 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2031 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2034 static const uint8_t ms_hmac_digest2[] = {
2035 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2036 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2037 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2038 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2039 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2040 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2041 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2042 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2049 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2051 struct crypto_testsuite_params *ts_params = &testsuite_params;
2052 struct crypto_unittest_params *ut_params = &unittest_params;
2054 /* Verify the capabilities */
2055 struct rte_cryptodev_sym_capability_idx cap_idx;
2056 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2057 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2058 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2060 return TEST_SKIPPED;
2061 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2062 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2063 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2065 return TEST_SKIPPED;
2067 /* Generate test mbuf data and space for digest */
2068 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2069 catch_22_quote, QUOTE_512_BYTES, 0);
2071 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2072 DIGEST_BYTE_LENGTH_SHA1);
2073 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2075 /* Setup Cipher Parameters */
2076 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2077 ut_params->cipher_xform.next = &ut_params->auth_xform;
2079 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2080 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2081 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2082 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2083 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2084 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2086 /* Setup HMAC Parameters */
2087 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2089 ut_params->auth_xform.next = NULL;
2091 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2092 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2093 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2094 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2095 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2097 ut_params->sess = rte_cryptodev_sym_session_create(
2098 ts_params->session_mpool);
2100 /* Create crypto session*/
2101 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2102 ut_params->sess, &ut_params->cipher_xform,
2103 ts_params->session_priv_mpool);
2104 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2106 /* Generate crypto op data structure */
2107 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2108 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2109 TEST_ASSERT_NOT_NULL(ut_params->op,
2110 "Failed to allocate symmetric crypto operation struct");
2112 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2114 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2116 /* set crypto operation source mbuf */
2117 sym_op->m_src = ut_params->ibuf;
2119 /* Set crypto operation authentication parameters */
2120 sym_op->auth.digest.data = ut_params->digest;
2121 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2122 ut_params->ibuf, QUOTE_512_BYTES);
2124 sym_op->auth.data.offset = 0;
2125 sym_op->auth.data.length = QUOTE_512_BYTES;
2127 /* Copy IV at the end of the crypto operation */
2128 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2129 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2131 /* Set crypto operation cipher parameters */
2132 sym_op->cipher.data.offset = 0;
2133 sym_op->cipher.data.length = QUOTE_512_BYTES;
2135 /* Process crypto operation */
2136 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2137 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2140 TEST_ASSERT_NOT_NULL(
2141 process_crypto_request(ts_params->valid_devs[0],
2143 "failed to process sym crypto op");
2145 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2146 "crypto op processing failed");
2149 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2152 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2153 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2155 "ciphertext data not as expected");
2157 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2159 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2160 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2161 gbl_driver_id == rte_cryptodev_driver_id_get(
2162 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2163 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2164 DIGEST_BYTE_LENGTH_SHA1,
2165 "Generated digest data not as expected");
2167 return TEST_SUCCESS;
2170 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2172 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2174 static uint8_t hmac_sha512_key[] = {
2175 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2176 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2177 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2178 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2179 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2180 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2181 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2182 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2184 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2185 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2186 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2187 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2188 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2189 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2190 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2191 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2192 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2197 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2198 struct crypto_unittest_params *ut_params,
2199 uint8_t *cipher_key,
2203 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2204 struct crypto_unittest_params *ut_params,
2205 struct crypto_testsuite_params *ts_params,
2206 const uint8_t *cipher,
2207 const uint8_t *digest,
2212 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2213 struct crypto_unittest_params *ut_params,
2214 uint8_t *cipher_key,
2218 /* Setup Cipher Parameters */
2219 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2220 ut_params->cipher_xform.next = NULL;
2222 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2223 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2224 ut_params->cipher_xform.cipher.key.data = cipher_key;
2225 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2226 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2227 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2229 /* Setup HMAC Parameters */
2230 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2231 ut_params->auth_xform.next = &ut_params->cipher_xform;
2233 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2234 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2235 ut_params->auth_xform.auth.key.data = hmac_key;
2236 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2237 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2239 return TEST_SUCCESS;
2244 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2245 struct crypto_unittest_params *ut_params,
2246 struct crypto_testsuite_params *ts_params,
2247 const uint8_t *cipher,
2248 const uint8_t *digest,
2251 /* Generate test mbuf data and digest */
2252 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2255 QUOTE_512_BYTES, 0);
2257 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2258 DIGEST_BYTE_LENGTH_SHA512);
2259 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2261 rte_memcpy(ut_params->digest,
2263 DIGEST_BYTE_LENGTH_SHA512);
2265 /* Generate Crypto op data structure */
2266 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2267 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2268 TEST_ASSERT_NOT_NULL(ut_params->op,
2269 "Failed to allocate symmetric crypto operation struct");
2271 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2273 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2275 /* set crypto operation source mbuf */
2276 sym_op->m_src = ut_params->ibuf;
2278 sym_op->auth.digest.data = ut_params->digest;
2279 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2280 ut_params->ibuf, QUOTE_512_BYTES);
2282 sym_op->auth.data.offset = 0;
2283 sym_op->auth.data.length = QUOTE_512_BYTES;
2285 /* Copy IV at the end of the crypto operation */
2286 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2287 iv, CIPHER_IV_LENGTH_AES_CBC);
2289 sym_op->cipher.data.offset = 0;
2290 sym_op->cipher.data.length = QUOTE_512_BYTES;
2292 /* Process crypto operation */
2293 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2294 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2296 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2297 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2298 ut_params->op, 1, 1, 0, 0);
2300 TEST_ASSERT_NOT_NULL(
2301 process_crypto_request(ts_params->valid_devs[0],
2303 "failed to process sym crypto op");
2305 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2306 "crypto op processing failed");
2308 ut_params->obuf = ut_params->op->sym->m_src;
2311 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2312 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2315 "Plaintext data not as expected");
2318 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2319 "Digest verification failed");
2321 return TEST_SUCCESS;
2324 /* ***** SNOW 3G Tests ***** */
2326 create_wireless_algo_hash_session(uint8_t dev_id,
2327 const uint8_t *key, const uint8_t key_len,
2328 const uint8_t iv_len, const uint8_t auth_len,
2329 enum rte_crypto_auth_operation op,
2330 enum rte_crypto_auth_algorithm algo)
2332 uint8_t hash_key[key_len];
2335 struct crypto_testsuite_params *ts_params = &testsuite_params;
2336 struct crypto_unittest_params *ut_params = &unittest_params;
2338 memcpy(hash_key, key, key_len);
2340 debug_hexdump(stdout, "key:", key, key_len);
2342 /* Setup Authentication Parameters */
2343 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2344 ut_params->auth_xform.next = NULL;
2346 ut_params->auth_xform.auth.op = op;
2347 ut_params->auth_xform.auth.algo = algo;
2348 ut_params->auth_xform.auth.key.length = key_len;
2349 ut_params->auth_xform.auth.key.data = hash_key;
2350 ut_params->auth_xform.auth.digest_length = auth_len;
2351 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2352 ut_params->auth_xform.auth.iv.length = iv_len;
2353 ut_params->sess = rte_cryptodev_sym_session_create(
2354 ts_params->session_mpool);
2356 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2357 &ut_params->auth_xform,
2358 ts_params->session_priv_mpool);
2359 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2360 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2365 create_wireless_algo_cipher_session(uint8_t dev_id,
2366 enum rte_crypto_cipher_operation op,
2367 enum rte_crypto_cipher_algorithm algo,
2368 const uint8_t *key, const uint8_t key_len,
2371 uint8_t cipher_key[key_len];
2373 struct crypto_testsuite_params *ts_params = &testsuite_params;
2374 struct crypto_unittest_params *ut_params = &unittest_params;
2376 memcpy(cipher_key, key, key_len);
2378 /* Setup Cipher Parameters */
2379 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2380 ut_params->cipher_xform.next = NULL;
2382 ut_params->cipher_xform.cipher.algo = algo;
2383 ut_params->cipher_xform.cipher.op = op;
2384 ut_params->cipher_xform.cipher.key.data = cipher_key;
2385 ut_params->cipher_xform.cipher.key.length = key_len;
2386 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2387 ut_params->cipher_xform.cipher.iv.length = iv_len;
2389 debug_hexdump(stdout, "key:", key, key_len);
2391 /* Create Crypto session */
2392 ut_params->sess = rte_cryptodev_sym_session_create(
2393 ts_params->session_mpool);
2395 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2396 &ut_params->cipher_xform,
2397 ts_params->session_priv_mpool);
2398 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2399 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2404 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2405 unsigned int cipher_len,
2406 unsigned int cipher_offset)
2408 struct crypto_testsuite_params *ts_params = &testsuite_params;
2409 struct crypto_unittest_params *ut_params = &unittest_params;
2411 /* Generate Crypto op data structure */
2412 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2413 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2414 TEST_ASSERT_NOT_NULL(ut_params->op,
2415 "Failed to allocate pktmbuf offload");
2417 /* Set crypto operation data parameters */
2418 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2420 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2422 /* set crypto operation source mbuf */
2423 sym_op->m_src = ut_params->ibuf;
2426 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2428 sym_op->cipher.data.length = cipher_len;
2429 sym_op->cipher.data.offset = cipher_offset;
2434 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2435 unsigned int cipher_len,
2436 unsigned int cipher_offset)
2438 struct crypto_testsuite_params *ts_params = &testsuite_params;
2439 struct crypto_unittest_params *ut_params = &unittest_params;
2441 /* Generate Crypto op data structure */
2442 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2443 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2444 TEST_ASSERT_NOT_NULL(ut_params->op,
2445 "Failed to allocate pktmbuf offload");
2447 /* Set crypto operation data parameters */
2448 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2450 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2452 /* set crypto operation source mbuf */
2453 sym_op->m_src = ut_params->ibuf;
2454 sym_op->m_dst = ut_params->obuf;
2457 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2459 sym_op->cipher.data.length = cipher_len;
2460 sym_op->cipher.data.offset = cipher_offset;
2465 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2466 enum rte_crypto_cipher_operation cipher_op,
2467 enum rte_crypto_auth_operation auth_op,
2468 enum rte_crypto_auth_algorithm auth_algo,
2469 enum rte_crypto_cipher_algorithm cipher_algo,
2470 const uint8_t *key, uint8_t key_len,
2471 uint8_t auth_iv_len, uint8_t auth_len,
2472 uint8_t cipher_iv_len)
2475 uint8_t cipher_auth_key[key_len];
2478 struct crypto_testsuite_params *ts_params = &testsuite_params;
2479 struct crypto_unittest_params *ut_params = &unittest_params;
2481 memcpy(cipher_auth_key, key, key_len);
2483 /* Setup Authentication Parameters */
2484 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2485 ut_params->auth_xform.next = NULL;
2487 ut_params->auth_xform.auth.op = auth_op;
2488 ut_params->auth_xform.auth.algo = auth_algo;
2489 ut_params->auth_xform.auth.key.length = key_len;
2490 /* Hash key = cipher key */
2491 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2492 ut_params->auth_xform.auth.digest_length = auth_len;
2493 /* Auth IV will be after cipher IV */
2494 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2495 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2497 /* Setup Cipher Parameters */
2498 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2499 ut_params->cipher_xform.next = &ut_params->auth_xform;
2501 ut_params->cipher_xform.cipher.algo = cipher_algo;
2502 ut_params->cipher_xform.cipher.op = cipher_op;
2503 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2504 ut_params->cipher_xform.cipher.key.length = key_len;
2505 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2506 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2508 debug_hexdump(stdout, "key:", key, key_len);
2510 /* Create Crypto session*/
2511 ut_params->sess = rte_cryptodev_sym_session_create(
2512 ts_params->session_mpool);
2513 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2515 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2516 &ut_params->cipher_xform,
2517 ts_params->session_priv_mpool);
2518 if (status == -ENOTSUP)
2519 return TEST_SKIPPED;
2521 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2526 create_wireless_cipher_auth_session(uint8_t dev_id,
2527 enum rte_crypto_cipher_operation cipher_op,
2528 enum rte_crypto_auth_operation auth_op,
2529 enum rte_crypto_auth_algorithm auth_algo,
2530 enum rte_crypto_cipher_algorithm cipher_algo,
2531 const struct wireless_test_data *tdata)
2533 const uint8_t key_len = tdata->key.len;
2534 uint8_t cipher_auth_key[key_len];
2537 struct crypto_testsuite_params *ts_params = &testsuite_params;
2538 struct crypto_unittest_params *ut_params = &unittest_params;
2539 const uint8_t *key = tdata->key.data;
2540 const uint8_t auth_len = tdata->digest.len;
2541 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2542 uint8_t auth_iv_len = tdata->auth_iv.len;
2544 memcpy(cipher_auth_key, key, key_len);
2546 /* Setup Authentication Parameters */
2547 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2548 ut_params->auth_xform.next = NULL;
2550 ut_params->auth_xform.auth.op = auth_op;
2551 ut_params->auth_xform.auth.algo = auth_algo;
2552 ut_params->auth_xform.auth.key.length = key_len;
2553 /* Hash key = cipher key */
2554 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2555 ut_params->auth_xform.auth.digest_length = auth_len;
2556 /* Auth IV will be after cipher IV */
2557 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2558 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2560 /* Setup Cipher Parameters */
2561 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2562 ut_params->cipher_xform.next = &ut_params->auth_xform;
2564 ut_params->cipher_xform.cipher.algo = cipher_algo;
2565 ut_params->cipher_xform.cipher.op = cipher_op;
2566 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2567 ut_params->cipher_xform.cipher.key.length = key_len;
2568 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2569 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2572 debug_hexdump(stdout, "key:", key, key_len);
2574 /* Create Crypto session*/
2575 ut_params->sess = rte_cryptodev_sym_session_create(
2576 ts_params->session_mpool);
2578 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2579 &ut_params->cipher_xform,
2580 ts_params->session_priv_mpool);
2581 if (status == -ENOTSUP)
2582 return TEST_SKIPPED;
2584 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2585 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2590 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2591 const struct wireless_test_data *tdata)
2593 return create_wireless_cipher_auth_session(dev_id,
2594 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2595 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2596 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2600 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2601 enum rte_crypto_cipher_operation cipher_op,
2602 enum rte_crypto_auth_operation auth_op,
2603 enum rte_crypto_auth_algorithm auth_algo,
2604 enum rte_crypto_cipher_algorithm cipher_algo,
2605 const uint8_t *key, const uint8_t key_len,
2606 uint8_t auth_iv_len, uint8_t auth_len,
2607 uint8_t cipher_iv_len)
2609 uint8_t auth_cipher_key[key_len];
2611 struct crypto_testsuite_params *ts_params = &testsuite_params;
2612 struct crypto_unittest_params *ut_params = &unittest_params;
2614 memcpy(auth_cipher_key, key, key_len);
2616 /* Setup Authentication Parameters */
2617 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2618 ut_params->auth_xform.auth.op = auth_op;
2619 ut_params->auth_xform.next = &ut_params->cipher_xform;
2620 ut_params->auth_xform.auth.algo = auth_algo;
2621 ut_params->auth_xform.auth.key.length = key_len;
2622 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2623 ut_params->auth_xform.auth.digest_length = auth_len;
2624 /* Auth IV will be after cipher IV */
2625 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2626 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2628 /* Setup Cipher Parameters */
2629 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2630 ut_params->cipher_xform.next = NULL;
2631 ut_params->cipher_xform.cipher.algo = cipher_algo;
2632 ut_params->cipher_xform.cipher.op = cipher_op;
2633 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2634 ut_params->cipher_xform.cipher.key.length = key_len;
2635 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2636 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2638 debug_hexdump(stdout, "key:", key, key_len);
2640 /* Create Crypto session*/
2641 ut_params->sess = rte_cryptodev_sym_session_create(
2642 ts_params->session_mpool);
2643 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2645 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2646 ut_params->auth_xform.next = NULL;
2647 ut_params->cipher_xform.next = &ut_params->auth_xform;
2648 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2649 &ut_params->cipher_xform,
2650 ts_params->session_priv_mpool);
2653 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2654 &ut_params->auth_xform,
2655 ts_params->session_priv_mpool);
2657 if (status == -ENOTSUP)
2658 return TEST_SKIPPED;
2660 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2666 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2667 unsigned int auth_tag_len,
2668 const uint8_t *iv, unsigned int iv_len,
2669 unsigned int data_pad_len,
2670 enum rte_crypto_auth_operation op,
2671 unsigned int auth_len, unsigned int auth_offset)
2673 struct crypto_testsuite_params *ts_params = &testsuite_params;
2675 struct crypto_unittest_params *ut_params = &unittest_params;
2677 /* Generate Crypto op data structure */
2678 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2679 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2680 TEST_ASSERT_NOT_NULL(ut_params->op,
2681 "Failed to allocate pktmbuf offload");
2683 /* Set crypto operation data parameters */
2684 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2686 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2688 /* set crypto operation source mbuf */
2689 sym_op->m_src = ut_params->ibuf;
2692 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2695 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2696 ut_params->ibuf, auth_tag_len);
2698 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2699 "no room to append auth tag");
2700 ut_params->digest = sym_op->auth.digest.data;
2701 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2702 ut_params->ibuf, data_pad_len);
2703 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2704 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2706 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2708 debug_hexdump(stdout, "digest:",
2709 sym_op->auth.digest.data,
2712 sym_op->auth.data.length = auth_len;
2713 sym_op->auth.data.offset = auth_offset;
2719 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2720 enum rte_crypto_auth_operation op)
2722 struct crypto_testsuite_params *ts_params = &testsuite_params;
2723 struct crypto_unittest_params *ut_params = &unittest_params;
2725 const uint8_t *auth_tag = tdata->digest.data;
2726 const unsigned int auth_tag_len = tdata->digest.len;
2727 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2728 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2730 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2731 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2732 const uint8_t *auth_iv = tdata->auth_iv.data;
2733 const uint8_t auth_iv_len = tdata->auth_iv.len;
2734 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2735 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2737 /* Generate Crypto op data structure */
2738 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2739 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2740 TEST_ASSERT_NOT_NULL(ut_params->op,
2741 "Failed to allocate pktmbuf offload");
2742 /* Set crypto operation data parameters */
2743 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2745 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2747 /* set crypto operation source mbuf */
2748 sym_op->m_src = ut_params->ibuf;
2751 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2752 ut_params->ibuf, auth_tag_len);
2754 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2755 "no room to append auth tag");
2756 ut_params->digest = sym_op->auth.digest.data;
2757 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2758 ut_params->ibuf, data_pad_len);
2759 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2760 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2762 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2764 debug_hexdump(stdout, "digest:",
2765 sym_op->auth.digest.data,
2768 /* Copy cipher and auth IVs at the end of the crypto operation */
2769 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2771 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2772 iv_ptr += cipher_iv_len;
2773 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2775 sym_op->cipher.data.length = cipher_len;
2776 sym_op->cipher.data.offset = 0;
2777 sym_op->auth.data.length = auth_len;
2778 sym_op->auth.data.offset = 0;
2784 create_zuc_cipher_hash_generate_operation(
2785 const struct wireless_test_data *tdata)
2787 return create_wireless_cipher_hash_operation(tdata,
2788 RTE_CRYPTO_AUTH_OP_GENERATE);
2792 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2793 const unsigned auth_tag_len,
2794 const uint8_t *auth_iv, uint8_t auth_iv_len,
2795 unsigned data_pad_len,
2796 enum rte_crypto_auth_operation op,
2797 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2798 const unsigned cipher_len, const unsigned cipher_offset,
2799 const unsigned auth_len, const unsigned auth_offset)
2801 struct crypto_testsuite_params *ts_params = &testsuite_params;
2802 struct crypto_unittest_params *ut_params = &unittest_params;
2804 enum rte_crypto_cipher_algorithm cipher_algo =
2805 ut_params->cipher_xform.cipher.algo;
2806 enum rte_crypto_auth_algorithm auth_algo =
2807 ut_params->auth_xform.auth.algo;
2809 /* Generate Crypto op data structure */
2810 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2811 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2812 TEST_ASSERT_NOT_NULL(ut_params->op,
2813 "Failed to allocate pktmbuf offload");
2814 /* Set crypto operation data parameters */
2815 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2817 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2819 /* set crypto operation source mbuf */
2820 sym_op->m_src = ut_params->ibuf;
2823 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2824 ut_params->ibuf, auth_tag_len);
2826 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2827 "no room to append auth tag");
2828 ut_params->digest = sym_op->auth.digest.data;
2830 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2831 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2832 ut_params->ibuf, data_pad_len);
2834 struct rte_mbuf *m = ut_params->ibuf;
2835 unsigned int offset = data_pad_len;
2837 while (offset > m->data_len && m->next != NULL) {
2838 offset -= m->data_len;
2841 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2845 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2846 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2848 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2850 debug_hexdump(stdout, "digest:",
2851 sym_op->auth.digest.data,
2854 /* Copy cipher and auth IVs at the end of the crypto operation */
2855 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2857 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2858 iv_ptr += cipher_iv_len;
2859 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2861 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2862 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2863 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2864 sym_op->cipher.data.length = cipher_len;
2865 sym_op->cipher.data.offset = cipher_offset;
2867 sym_op->cipher.data.length = cipher_len >> 3;
2868 sym_op->cipher.data.offset = cipher_offset >> 3;
2871 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2872 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2873 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2874 sym_op->auth.data.length = auth_len;
2875 sym_op->auth.data.offset = auth_offset;
2877 sym_op->auth.data.length = auth_len >> 3;
2878 sym_op->auth.data.offset = auth_offset >> 3;
2885 create_wireless_algo_auth_cipher_operation(
2886 const uint8_t *auth_tag, unsigned int auth_tag_len,
2887 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2888 const uint8_t *auth_iv, uint8_t auth_iv_len,
2889 unsigned int data_pad_len,
2890 unsigned int cipher_len, unsigned int cipher_offset,
2891 unsigned int auth_len, unsigned int auth_offset,
2892 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2894 struct crypto_testsuite_params *ts_params = &testsuite_params;
2895 struct crypto_unittest_params *ut_params = &unittest_params;
2897 enum rte_crypto_cipher_algorithm cipher_algo =
2898 ut_params->cipher_xform.cipher.algo;
2899 enum rte_crypto_auth_algorithm auth_algo =
2900 ut_params->auth_xform.auth.algo;
2902 /* Generate Crypto op data structure */
2903 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2904 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2905 TEST_ASSERT_NOT_NULL(ut_params->op,
2906 "Failed to allocate pktmbuf offload");
2908 /* Set crypto operation data parameters */
2909 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2911 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2913 /* set crypto operation mbufs */
2914 sym_op->m_src = ut_params->ibuf;
2915 if (op_mode == OUT_OF_PLACE)
2916 sym_op->m_dst = ut_params->obuf;
2920 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2921 (op_mode == IN_PLACE ?
2922 ut_params->ibuf : ut_params->obuf),
2923 uint8_t *, data_pad_len);
2924 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2925 (op_mode == IN_PLACE ?
2926 ut_params->ibuf : ut_params->obuf),
2928 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2930 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2931 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2932 sym_op->m_src : sym_op->m_dst);
2933 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2934 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2935 sgl_buf = sgl_buf->next;
2937 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2938 uint8_t *, remaining_off);
2939 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2941 memset(sym_op->auth.digest.data, 0, remaining_off);
2942 while (sgl_buf->next != NULL) {
2943 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2944 0, rte_pktmbuf_data_len(sgl_buf));
2945 sgl_buf = sgl_buf->next;
2949 /* Copy digest for the verification */
2951 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2953 /* Copy cipher and auth IVs at the end of the crypto operation */
2954 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2955 ut_params->op, uint8_t *, IV_OFFSET);
2957 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2958 iv_ptr += cipher_iv_len;
2959 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2961 /* Only copy over the offset data needed from src to dst in OOP,
2962 * if the auth and cipher offsets are not aligned
2964 if (op_mode == OUT_OF_PLACE) {
2965 if (cipher_offset > auth_offset)
2967 rte_pktmbuf_mtod_offset(
2969 uint8_t *, auth_offset >> 3),
2970 rte_pktmbuf_mtod_offset(
2972 uint8_t *, auth_offset >> 3),
2973 ((cipher_offset >> 3) - (auth_offset >> 3)));
2976 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2977 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2978 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2979 sym_op->cipher.data.length = cipher_len;
2980 sym_op->cipher.data.offset = cipher_offset;
2982 sym_op->cipher.data.length = cipher_len >> 3;
2983 sym_op->cipher.data.offset = cipher_offset >> 3;
2986 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2987 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2988 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2989 sym_op->auth.data.length = auth_len;
2990 sym_op->auth.data.offset = auth_offset;
2992 sym_op->auth.data.length = auth_len >> 3;
2993 sym_op->auth.data.offset = auth_offset >> 3;
3000 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3002 struct crypto_testsuite_params *ts_params = &testsuite_params;
3003 struct crypto_unittest_params *ut_params = &unittest_params;
3006 unsigned plaintext_pad_len;
3007 unsigned plaintext_len;
3009 struct rte_cryptodev_info dev_info;
3011 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3012 uint64_t feat_flags = dev_info.feature_flags;
3014 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3015 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3016 printf("Device doesn't support NON-Byte Aligned Data.\n");
3017 return TEST_SKIPPED;
3020 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3021 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3022 printf("Device doesn't support RAW data-path APIs.\n");
3023 return TEST_SKIPPED;
3026 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3027 return TEST_SKIPPED;
3029 /* Verify the capabilities */
3030 struct rte_cryptodev_sym_capability_idx cap_idx;
3031 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3032 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3033 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3035 return TEST_SKIPPED;
3037 /* Create SNOW 3G session */
3038 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3039 tdata->key.data, tdata->key.len,
3040 tdata->auth_iv.len, tdata->digest.len,
3041 RTE_CRYPTO_AUTH_OP_GENERATE,
3042 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3046 /* alloc mbuf and set payload */
3047 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3049 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3050 rte_pktmbuf_tailroom(ut_params->ibuf));
3052 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3053 /* Append data which is padded to a multiple of */
3054 /* the algorithms block size */
3055 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3056 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3058 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3060 /* Create SNOW 3G operation */
3061 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3062 tdata->auth_iv.data, tdata->auth_iv.len,
3063 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3064 tdata->validAuthLenInBits.len,
3069 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3070 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3071 ut_params->op, 0, 1, 1, 0);
3073 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3075 ut_params->obuf = ut_params->op->sym->m_src;
3076 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3077 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3078 + plaintext_pad_len;
3081 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3084 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3085 "SNOW 3G Generated auth tag not as expected");
3091 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3093 struct crypto_testsuite_params *ts_params = &testsuite_params;
3094 struct crypto_unittest_params *ut_params = &unittest_params;
3097 unsigned plaintext_pad_len;
3098 unsigned plaintext_len;
3100 struct rte_cryptodev_info dev_info;
3102 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3103 uint64_t feat_flags = dev_info.feature_flags;
3105 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3106 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3107 printf("Device doesn't support NON-Byte Aligned Data.\n");
3108 return TEST_SKIPPED;
3111 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3112 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3113 printf("Device doesn't support RAW data-path APIs.\n");
3114 return TEST_SKIPPED;
3117 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3118 return TEST_SKIPPED;
3120 /* Verify the capabilities */
3121 struct rte_cryptodev_sym_capability_idx cap_idx;
3122 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3123 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3124 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3126 return TEST_SKIPPED;
3128 /* Create SNOW 3G session */
3129 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3130 tdata->key.data, tdata->key.len,
3131 tdata->auth_iv.len, tdata->digest.len,
3132 RTE_CRYPTO_AUTH_OP_VERIFY,
3133 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3136 /* alloc mbuf and set payload */
3137 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3139 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3140 rte_pktmbuf_tailroom(ut_params->ibuf));
3142 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3143 /* Append data which is padded to a multiple of */
3144 /* the algorithms block size */
3145 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3146 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3148 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3150 /* Create SNOW 3G operation */
3151 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3153 tdata->auth_iv.data, tdata->auth_iv.len,
3155 RTE_CRYPTO_AUTH_OP_VERIFY,
3156 tdata->validAuthLenInBits.len,
3161 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3162 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3163 ut_params->op, 0, 1, 1, 0);
3165 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3167 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3168 ut_params->obuf = ut_params->op->sym->m_src;
3169 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3170 + plaintext_pad_len;
3173 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3182 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3184 struct crypto_testsuite_params *ts_params = &testsuite_params;
3185 struct crypto_unittest_params *ut_params = &unittest_params;
3188 unsigned plaintext_pad_len;
3189 unsigned plaintext_len;
3191 struct rte_cryptodev_info dev_info;
3193 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3194 uint64_t feat_flags = dev_info.feature_flags;
3196 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3197 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3198 printf("Device doesn't support RAW data-path APIs.\n");
3199 return TEST_SKIPPED;
3202 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3203 return TEST_SKIPPED;
3205 /* Verify the capabilities */
3206 struct rte_cryptodev_sym_capability_idx cap_idx;
3207 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3208 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3209 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3211 return TEST_SKIPPED;
3213 /* Create KASUMI session */
3214 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3215 tdata->key.data, tdata->key.len,
3216 0, tdata->digest.len,
3217 RTE_CRYPTO_AUTH_OP_GENERATE,
3218 RTE_CRYPTO_AUTH_KASUMI_F9);
3222 /* alloc mbuf and set payload */
3223 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3225 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3226 rte_pktmbuf_tailroom(ut_params->ibuf));
3228 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3229 /* Append data which is padded to a multiple of */
3230 /* the algorithms block size */
3231 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3232 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3234 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3236 /* Create KASUMI operation */
3237 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3239 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3240 tdata->plaintext.len,
3245 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3246 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3248 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3249 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3250 ut_params->op, 0, 1, 1, 0);
3252 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3255 ut_params->obuf = ut_params->op->sym->m_src;
3256 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3257 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3258 + plaintext_pad_len;
3261 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3264 DIGEST_BYTE_LENGTH_KASUMI_F9,
3265 "KASUMI Generated auth tag not as expected");
3271 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3273 struct crypto_testsuite_params *ts_params = &testsuite_params;
3274 struct crypto_unittest_params *ut_params = &unittest_params;
3277 unsigned plaintext_pad_len;
3278 unsigned plaintext_len;
3280 struct rte_cryptodev_info dev_info;
3282 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3283 uint64_t feat_flags = dev_info.feature_flags;
3285 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3286 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3287 printf("Device doesn't support RAW data-path APIs.\n");
3288 return TEST_SKIPPED;
3291 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3292 return TEST_SKIPPED;
3294 /* Verify the capabilities */
3295 struct rte_cryptodev_sym_capability_idx cap_idx;
3296 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3297 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3298 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3300 return TEST_SKIPPED;
3302 /* Create KASUMI session */
3303 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3304 tdata->key.data, tdata->key.len,
3305 0, tdata->digest.len,
3306 RTE_CRYPTO_AUTH_OP_VERIFY,
3307 RTE_CRYPTO_AUTH_KASUMI_F9);
3310 /* alloc mbuf and set payload */
3311 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3313 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3314 rte_pktmbuf_tailroom(ut_params->ibuf));
3316 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3317 /* Append data which is padded to a multiple */
3318 /* of the algorithms block size */
3319 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3320 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3322 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3324 /* Create KASUMI operation */
3325 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3329 RTE_CRYPTO_AUTH_OP_VERIFY,
3330 tdata->plaintext.len,
3335 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3336 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3337 ut_params->op, 0, 1, 1, 0);
3339 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3341 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3342 ut_params->obuf = ut_params->op->sym->m_src;
3343 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3344 + plaintext_pad_len;
3347 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3356 test_snow3g_hash_generate_test_case_1(void)
3358 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3362 test_snow3g_hash_generate_test_case_2(void)
3364 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3368 test_snow3g_hash_generate_test_case_3(void)
3370 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3374 test_snow3g_hash_generate_test_case_4(void)
3376 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3380 test_snow3g_hash_generate_test_case_5(void)
3382 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3386 test_snow3g_hash_generate_test_case_6(void)
3388 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3392 test_snow3g_hash_verify_test_case_1(void)
3394 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3399 test_snow3g_hash_verify_test_case_2(void)
3401 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3405 test_snow3g_hash_verify_test_case_3(void)
3407 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3411 test_snow3g_hash_verify_test_case_4(void)
3413 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3417 test_snow3g_hash_verify_test_case_5(void)
3419 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3423 test_snow3g_hash_verify_test_case_6(void)
3425 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3429 test_kasumi_hash_generate_test_case_1(void)
3431 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3435 test_kasumi_hash_generate_test_case_2(void)
3437 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3441 test_kasumi_hash_generate_test_case_3(void)
3443 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3447 test_kasumi_hash_generate_test_case_4(void)
3449 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3453 test_kasumi_hash_generate_test_case_5(void)
3455 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3459 test_kasumi_hash_generate_test_case_6(void)
3461 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3465 test_kasumi_hash_verify_test_case_1(void)
3467 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3471 test_kasumi_hash_verify_test_case_2(void)
3473 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3477 test_kasumi_hash_verify_test_case_3(void)
3479 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3483 test_kasumi_hash_verify_test_case_4(void)
3485 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3489 test_kasumi_hash_verify_test_case_5(void)
3491 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3495 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3497 struct crypto_testsuite_params *ts_params = &testsuite_params;
3498 struct crypto_unittest_params *ut_params = &unittest_params;
3501 uint8_t *plaintext, *ciphertext;
3502 unsigned plaintext_pad_len;
3503 unsigned plaintext_len;
3504 struct rte_cryptodev_info dev_info;
3506 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3507 uint64_t feat_flags = dev_info.feature_flags;
3509 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3510 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3511 printf("Device doesn't support RAW data-path APIs.\n");
3512 return TEST_SKIPPED;
3515 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3516 return TEST_SKIPPED;
3518 /* Verify the capabilities */
3519 struct rte_cryptodev_sym_capability_idx cap_idx;
3520 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3521 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3522 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3524 return TEST_SKIPPED;
3526 /* Create KASUMI session */
3527 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3528 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3529 RTE_CRYPTO_CIPHER_KASUMI_F8,
3530 tdata->key.data, tdata->key.len,
3531 tdata->cipher_iv.len);
3535 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3537 /* Clear mbuf payload */
3538 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3539 rte_pktmbuf_tailroom(ut_params->ibuf));
3541 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3542 /* Append data which is padded to a multiple */
3543 /* of the algorithms block size */
3544 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3545 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3547 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3549 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3551 /* Create KASUMI operation */
3552 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3553 tdata->cipher_iv.len,
3554 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3555 tdata->validCipherOffsetInBits.len);
3559 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3560 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3561 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3563 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3565 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3567 ut_params->obuf = ut_params->op->sym->m_dst;
3568 if (ut_params->obuf)
3569 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3571 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3573 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3575 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3576 (tdata->validCipherOffsetInBits.len >> 3);
3578 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3580 reference_ciphertext,
3581 tdata->validCipherLenInBits.len,
3582 "KASUMI Ciphertext data not as expected");
3587 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3589 struct crypto_testsuite_params *ts_params = &testsuite_params;
3590 struct crypto_unittest_params *ut_params = &unittest_params;
3594 unsigned int plaintext_pad_len;
3595 unsigned int plaintext_len;
3597 uint8_t buffer[10000];
3598 const uint8_t *ciphertext;
3600 struct rte_cryptodev_info dev_info;
3602 /* Verify the capabilities */
3603 struct rte_cryptodev_sym_capability_idx cap_idx;
3604 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3605 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3606 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3608 return TEST_SKIPPED;
3610 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3612 uint64_t feat_flags = dev_info.feature_flags;
3614 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3615 printf("Device doesn't support in-place scatter-gather. "
3617 return TEST_SKIPPED;
3620 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3621 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3622 printf("Device doesn't support RAW data-path APIs.\n");
3623 return TEST_SKIPPED;
3626 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3627 return TEST_SKIPPED;
3629 /* Create KASUMI session */
3630 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3631 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3632 RTE_CRYPTO_CIPHER_KASUMI_F8,
3633 tdata->key.data, tdata->key.len,
3634 tdata->cipher_iv.len);
3638 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3641 /* Append data which is padded to a multiple */
3642 /* of the algorithms block size */
3643 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3645 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3646 plaintext_pad_len, 10, 0);
3648 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3650 /* Create KASUMI operation */
3651 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3652 tdata->cipher_iv.len,
3653 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3654 tdata->validCipherOffsetInBits.len);
3658 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3659 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3660 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3662 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3664 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3666 ut_params->obuf = ut_params->op->sym->m_dst;
3668 if (ut_params->obuf)
3669 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3670 plaintext_len, buffer);
3672 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3673 tdata->validCipherOffsetInBits.len >> 3,
3674 plaintext_len, buffer);
3677 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3679 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3680 (tdata->validCipherOffsetInBits.len >> 3);
3682 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3684 reference_ciphertext,
3685 tdata->validCipherLenInBits.len,
3686 "KASUMI Ciphertext data not as expected");
3691 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3693 struct crypto_testsuite_params *ts_params = &testsuite_params;
3694 struct crypto_unittest_params *ut_params = &unittest_params;
3697 uint8_t *plaintext, *ciphertext;
3698 unsigned plaintext_pad_len;
3699 unsigned plaintext_len;
3701 /* Verify the capabilities */
3702 struct rte_cryptodev_sym_capability_idx cap_idx;
3703 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3704 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3705 /* Data-path service does not support OOP */
3706 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3708 return TEST_SKIPPED;
3710 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3711 return TEST_SKIPPED;
3713 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3714 return TEST_SKIPPED;
3716 /* Create KASUMI session */
3717 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3718 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3719 RTE_CRYPTO_CIPHER_KASUMI_F8,
3720 tdata->key.data, tdata->key.len,
3721 tdata->cipher_iv.len);
3725 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3726 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3728 /* Clear mbuf payload */
3729 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3730 rte_pktmbuf_tailroom(ut_params->ibuf));
3732 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3733 /* Append data which is padded to a multiple */
3734 /* of the algorithms block size */
3735 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3736 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3738 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3739 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3741 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3743 /* Create KASUMI operation */
3744 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3745 tdata->cipher_iv.len,
3746 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3747 tdata->validCipherOffsetInBits.len);
3751 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3753 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3755 ut_params->obuf = ut_params->op->sym->m_dst;
3756 if (ut_params->obuf)
3757 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3759 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3761 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3763 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3764 (tdata->validCipherOffsetInBits.len >> 3);
3766 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3768 reference_ciphertext,
3769 tdata->validCipherLenInBits.len,
3770 "KASUMI Ciphertext data not as expected");
3775 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3777 struct crypto_testsuite_params *ts_params = &testsuite_params;
3778 struct crypto_unittest_params *ut_params = &unittest_params;
3781 unsigned int plaintext_pad_len;
3782 unsigned int plaintext_len;
3784 const uint8_t *ciphertext;
3785 uint8_t buffer[2048];
3787 struct rte_cryptodev_info dev_info;
3789 /* Verify the capabilities */
3790 struct rte_cryptodev_sym_capability_idx cap_idx;
3791 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3792 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3793 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3795 return TEST_SKIPPED;
3797 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3798 return TEST_SKIPPED;
3800 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3801 return TEST_SKIPPED;
3803 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3805 uint64_t feat_flags = dev_info.feature_flags;
3806 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3807 printf("Device doesn't support out-of-place scatter-gather "
3808 "in both input and output mbufs. "
3810 return TEST_SKIPPED;
3813 /* Create KASUMI session */
3814 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3815 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3816 RTE_CRYPTO_CIPHER_KASUMI_F8,
3817 tdata->key.data, tdata->key.len,
3818 tdata->cipher_iv.len);
3822 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3823 /* Append data which is padded to a multiple */
3824 /* of the algorithms block size */
3825 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3827 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3828 plaintext_pad_len, 10, 0);
3829 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3830 plaintext_pad_len, 3, 0);
3832 /* Append data which is padded to a multiple */
3833 /* of the algorithms block size */
3834 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3836 /* Create KASUMI operation */
3837 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3838 tdata->cipher_iv.len,
3839 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3840 tdata->validCipherOffsetInBits.len);
3844 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3846 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3848 ut_params->obuf = ut_params->op->sym->m_dst;
3849 if (ut_params->obuf)
3850 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3851 plaintext_pad_len, buffer);
3853 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3854 tdata->validCipherOffsetInBits.len >> 3,
3855 plaintext_pad_len, buffer);
3857 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3858 (tdata->validCipherOffsetInBits.len >> 3);
3860 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3862 reference_ciphertext,
3863 tdata->validCipherLenInBits.len,
3864 "KASUMI Ciphertext data not as expected");
3870 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3872 struct crypto_testsuite_params *ts_params = &testsuite_params;
3873 struct crypto_unittest_params *ut_params = &unittest_params;
3876 uint8_t *ciphertext, *plaintext;
3877 unsigned ciphertext_pad_len;
3878 unsigned ciphertext_len;
3880 /* Verify the capabilities */
3881 struct rte_cryptodev_sym_capability_idx cap_idx;
3882 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3883 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3884 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3886 return TEST_SKIPPED;
3888 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3889 return TEST_SKIPPED;
3891 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3892 return TEST_SKIPPED;
3894 /* Create KASUMI session */
3895 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3896 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3897 RTE_CRYPTO_CIPHER_KASUMI_F8,
3898 tdata->key.data, tdata->key.len,
3899 tdata->cipher_iv.len);
3903 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3904 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3906 /* Clear mbuf payload */
3907 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3908 rte_pktmbuf_tailroom(ut_params->ibuf));
3910 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3911 /* Append data which is padded to a multiple */
3912 /* of the algorithms block size */
3913 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3914 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3915 ciphertext_pad_len);
3916 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3917 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3919 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3921 /* Create KASUMI operation */
3922 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3923 tdata->cipher_iv.len,
3924 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3925 tdata->validCipherOffsetInBits.len);
3929 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3931 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3933 ut_params->obuf = ut_params->op->sym->m_dst;
3934 if (ut_params->obuf)
3935 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3937 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3939 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3941 const uint8_t *reference_plaintext = tdata->plaintext.data +
3942 (tdata->validCipherOffsetInBits.len >> 3);
3944 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3946 reference_plaintext,
3947 tdata->validCipherLenInBits.len,
3948 "KASUMI Plaintext data not as expected");
3953 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3955 struct crypto_testsuite_params *ts_params = &testsuite_params;
3956 struct crypto_unittest_params *ut_params = &unittest_params;
3959 uint8_t *ciphertext, *plaintext;
3960 unsigned ciphertext_pad_len;
3961 unsigned ciphertext_len;
3962 struct rte_cryptodev_info dev_info;
3964 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3965 uint64_t feat_flags = dev_info.feature_flags;
3967 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3968 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3969 printf("Device doesn't support RAW data-path APIs.\n");
3970 return TEST_SKIPPED;
3973 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3974 return TEST_SKIPPED;
3976 /* Verify the capabilities */
3977 struct rte_cryptodev_sym_capability_idx cap_idx;
3978 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3979 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3980 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3982 return TEST_SKIPPED;
3984 /* Create KASUMI session */
3985 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3986 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3987 RTE_CRYPTO_CIPHER_KASUMI_F8,
3988 tdata->key.data, tdata->key.len,
3989 tdata->cipher_iv.len);
3993 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3995 /* Clear mbuf payload */
3996 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3997 rte_pktmbuf_tailroom(ut_params->ibuf));
3999 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4000 /* Append data which is padded to a multiple */
4001 /* of the algorithms block size */
4002 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4003 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4004 ciphertext_pad_len);
4005 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4007 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4009 /* Create KASUMI operation */
4010 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4011 tdata->cipher_iv.len,
4012 tdata->ciphertext.len,
4013 tdata->validCipherOffsetInBits.len);
4017 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4018 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4019 ut_params->op, 1, 0, 1, 0);
4021 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4023 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4025 ut_params->obuf = ut_params->op->sym->m_dst;
4026 if (ut_params->obuf)
4027 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4029 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4031 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4033 const uint8_t *reference_plaintext = tdata->plaintext.data +
4034 (tdata->validCipherOffsetInBits.len >> 3);
4036 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4038 reference_plaintext,
4039 tdata->validCipherLenInBits.len,
4040 "KASUMI Plaintext data not as expected");
4045 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4047 struct crypto_testsuite_params *ts_params = &testsuite_params;
4048 struct crypto_unittest_params *ut_params = &unittest_params;
4051 uint8_t *plaintext, *ciphertext;
4052 unsigned plaintext_pad_len;
4053 unsigned plaintext_len;
4054 struct rte_cryptodev_info dev_info;
4056 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4057 uint64_t feat_flags = dev_info.feature_flags;
4059 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4060 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4061 printf("Device doesn't support RAW data-path APIs.\n");
4062 return TEST_SKIPPED;
4065 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4066 return TEST_SKIPPED;
4068 /* Verify the capabilities */
4069 struct rte_cryptodev_sym_capability_idx cap_idx;
4070 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4071 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4072 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4074 return TEST_SKIPPED;
4076 /* Create SNOW 3G session */
4077 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4078 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4079 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4080 tdata->key.data, tdata->key.len,
4081 tdata->cipher_iv.len);
4085 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4087 /* Clear mbuf payload */
4088 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4089 rte_pktmbuf_tailroom(ut_params->ibuf));
4091 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4092 /* Append data which is padded to a multiple of */
4093 /* the algorithms block size */
4094 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4095 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4097 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4099 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4101 /* Create SNOW 3G operation */
4102 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4103 tdata->cipher_iv.len,
4104 tdata->validCipherLenInBits.len,
4109 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4110 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4111 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4113 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4115 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4117 ut_params->obuf = ut_params->op->sym->m_dst;
4118 if (ut_params->obuf)
4119 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4121 ciphertext = plaintext;
4123 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4126 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4128 tdata->ciphertext.data,
4129 tdata->validDataLenInBits.len,
4130 "SNOW 3G Ciphertext data not as expected");
4136 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4138 struct crypto_testsuite_params *ts_params = &testsuite_params;
4139 struct crypto_unittest_params *ut_params = &unittest_params;
4140 uint8_t *plaintext, *ciphertext;
4143 unsigned plaintext_pad_len;
4144 unsigned plaintext_len;
4146 /* Verify the capabilities */
4147 struct rte_cryptodev_sym_capability_idx cap_idx;
4148 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4149 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4150 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4152 return TEST_SKIPPED;
4154 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4155 return TEST_SKIPPED;
4157 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4158 return TEST_SKIPPED;
4160 /* Create SNOW 3G session */
4161 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4162 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4163 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4164 tdata->key.data, tdata->key.len,
4165 tdata->cipher_iv.len);
4169 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4170 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4172 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4173 "Failed to allocate input buffer in mempool");
4174 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4175 "Failed to allocate output buffer in mempool");
4177 /* Clear mbuf payload */
4178 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4179 rte_pktmbuf_tailroom(ut_params->ibuf));
4181 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4182 /* Append data which is padded to a multiple of */
4183 /* the algorithms block size */
4184 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4185 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4187 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4188 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4190 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4192 /* Create SNOW 3G operation */
4193 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4194 tdata->cipher_iv.len,
4195 tdata->validCipherLenInBits.len,
4200 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4202 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4204 ut_params->obuf = ut_params->op->sym->m_dst;
4205 if (ut_params->obuf)
4206 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4208 ciphertext = plaintext;
4210 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4213 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4215 tdata->ciphertext.data,
4216 tdata->validDataLenInBits.len,
4217 "SNOW 3G Ciphertext data not as expected");
4222 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4224 struct crypto_testsuite_params *ts_params = &testsuite_params;
4225 struct crypto_unittest_params *ut_params = &unittest_params;
4228 unsigned int plaintext_pad_len;
4229 unsigned int plaintext_len;
4230 uint8_t buffer[10000];
4231 const uint8_t *ciphertext;
4233 struct rte_cryptodev_info dev_info;
4235 /* Verify the capabilities */
4236 struct rte_cryptodev_sym_capability_idx cap_idx;
4237 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4238 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4239 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4241 return TEST_SKIPPED;
4243 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4244 return TEST_SKIPPED;
4246 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4247 return TEST_SKIPPED;
4249 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4251 uint64_t feat_flags = dev_info.feature_flags;
4253 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4254 printf("Device doesn't support out-of-place scatter-gather "
4255 "in both input and output mbufs. "
4257 return TEST_SKIPPED;
4260 /* Create SNOW 3G session */
4261 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4262 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4263 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4264 tdata->key.data, tdata->key.len,
4265 tdata->cipher_iv.len);
4269 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4270 /* Append data which is padded to a multiple of */
4271 /* the algorithms block size */
4272 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4274 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4275 plaintext_pad_len, 10, 0);
4276 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4277 plaintext_pad_len, 3, 0);
4279 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4280 "Failed to allocate input buffer in mempool");
4281 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4282 "Failed to allocate output buffer in mempool");
4284 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4286 /* Create SNOW 3G operation */
4287 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4288 tdata->cipher_iv.len,
4289 tdata->validCipherLenInBits.len,
4294 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4296 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4298 ut_params->obuf = ut_params->op->sym->m_dst;
4299 if (ut_params->obuf)
4300 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4301 plaintext_len, buffer);
4303 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4304 plaintext_len, buffer);
4306 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4309 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4311 tdata->ciphertext.data,
4312 tdata->validDataLenInBits.len,
4313 "SNOW 3G Ciphertext data not as expected");
4318 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4320 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4322 uint8_t curr_byte, prev_byte;
4323 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4324 uint8_t lower_byte_mask = (1 << offset) - 1;
4327 prev_byte = buffer[0];
4328 buffer[0] >>= offset;
4330 for (i = 1; i < length_in_bytes; i++) {
4331 curr_byte = buffer[i];
4332 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4333 (curr_byte >> offset);
4334 prev_byte = curr_byte;
4339 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4341 struct crypto_testsuite_params *ts_params = &testsuite_params;
4342 struct crypto_unittest_params *ut_params = &unittest_params;
4343 uint8_t *plaintext, *ciphertext;
4345 uint32_t plaintext_len;
4346 uint32_t plaintext_pad_len;
4347 uint8_t extra_offset = 4;
4348 uint8_t *expected_ciphertext_shifted;
4349 struct rte_cryptodev_info dev_info;
4351 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4352 uint64_t feat_flags = dev_info.feature_flags;
4354 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4355 ((tdata->validDataLenInBits.len % 8) != 0)) {
4356 printf("Device doesn't support NON-Byte Aligned Data.\n");
4357 return TEST_SKIPPED;
4360 /* Verify the capabilities */
4361 struct rte_cryptodev_sym_capability_idx cap_idx;
4362 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4363 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4364 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4366 return TEST_SKIPPED;
4368 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4369 return TEST_SKIPPED;
4371 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4372 return TEST_SKIPPED;
4374 /* Create SNOW 3G session */
4375 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4376 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4377 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4378 tdata->key.data, tdata->key.len,
4379 tdata->cipher_iv.len);
4383 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4384 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4386 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4387 "Failed to allocate input buffer in mempool");
4388 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4389 "Failed to allocate output buffer in mempool");
4391 /* Clear mbuf payload */
4392 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4393 rte_pktmbuf_tailroom(ut_params->ibuf));
4395 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4397 * Append data which is padded to a
4398 * multiple of the algorithms block size
4400 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4402 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4405 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4407 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4408 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4410 #ifdef RTE_APP_TEST_DEBUG
4411 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4413 /* Create SNOW 3G operation */
4414 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4415 tdata->cipher_iv.len,
4416 tdata->validCipherLenInBits.len,
4421 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4423 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4425 ut_params->obuf = ut_params->op->sym->m_dst;
4426 if (ut_params->obuf)
4427 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4429 ciphertext = plaintext;
4431 #ifdef RTE_APP_TEST_DEBUG
4432 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4435 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4437 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4438 "failed to reserve memory for ciphertext shifted\n");
4440 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4441 ceil_byte_length(tdata->ciphertext.len));
4442 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4445 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4447 expected_ciphertext_shifted,
4448 tdata->validDataLenInBits.len,
4450 "SNOW 3G Ciphertext data not as expected");
4454 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4456 struct crypto_testsuite_params *ts_params = &testsuite_params;
4457 struct crypto_unittest_params *ut_params = &unittest_params;
4461 uint8_t *plaintext, *ciphertext;
4462 unsigned ciphertext_pad_len;
4463 unsigned ciphertext_len;
4464 struct rte_cryptodev_info dev_info;
4466 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4467 uint64_t feat_flags = dev_info.feature_flags;
4469 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4470 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4471 printf("Device doesn't support RAW data-path APIs.\n");
4472 return TEST_SKIPPED;
4475 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4476 return TEST_SKIPPED;
4478 /* Verify the capabilities */
4479 struct rte_cryptodev_sym_capability_idx cap_idx;
4480 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4481 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4482 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4484 return TEST_SKIPPED;
4486 /* Create SNOW 3G session */
4487 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4488 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4489 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4490 tdata->key.data, tdata->key.len,
4491 tdata->cipher_iv.len);
4495 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4497 /* Clear mbuf payload */
4498 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4499 rte_pktmbuf_tailroom(ut_params->ibuf));
4501 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4502 /* Append data which is padded to a multiple of */
4503 /* the algorithms block size */
4504 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4505 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4506 ciphertext_pad_len);
4507 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4509 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4511 /* Create SNOW 3G operation */
4512 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4513 tdata->cipher_iv.len,
4514 tdata->validCipherLenInBits.len,
4515 tdata->cipher.offset_bits);
4519 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4520 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4521 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4523 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4525 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4526 ut_params->obuf = ut_params->op->sym->m_dst;
4527 if (ut_params->obuf)
4528 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4530 plaintext = ciphertext;
4532 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4535 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4536 tdata->plaintext.data,
4537 tdata->validDataLenInBits.len,
4538 "SNOW 3G Plaintext data not as expected");
4542 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4544 struct crypto_testsuite_params *ts_params = &testsuite_params;
4545 struct crypto_unittest_params *ut_params = &unittest_params;
4549 uint8_t *plaintext, *ciphertext;
4550 unsigned ciphertext_pad_len;
4551 unsigned ciphertext_len;
4553 /* Verify the capabilities */
4554 struct rte_cryptodev_sym_capability_idx cap_idx;
4555 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4556 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4557 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4559 return TEST_SKIPPED;
4561 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4562 return TEST_SKIPPED;
4564 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4565 return TEST_SKIPPED;
4567 /* Create SNOW 3G session */
4568 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4569 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4570 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4571 tdata->key.data, tdata->key.len,
4572 tdata->cipher_iv.len);
4576 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4577 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4579 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4580 "Failed to allocate input buffer");
4581 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4582 "Failed to allocate output buffer");
4584 /* Clear mbuf payload */
4585 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4586 rte_pktmbuf_tailroom(ut_params->ibuf));
4588 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4589 rte_pktmbuf_tailroom(ut_params->obuf));
4591 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4592 /* Append data which is padded to a multiple of */
4593 /* the algorithms block size */
4594 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4595 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4596 ciphertext_pad_len);
4597 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4598 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4600 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4602 /* Create SNOW 3G operation */
4603 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4604 tdata->cipher_iv.len,
4605 tdata->validCipherLenInBits.len,
4610 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4612 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4613 ut_params->obuf = ut_params->op->sym->m_dst;
4614 if (ut_params->obuf)
4615 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4617 plaintext = ciphertext;
4619 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4622 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4623 tdata->plaintext.data,
4624 tdata->validDataLenInBits.len,
4625 "SNOW 3G Plaintext data not as expected");
4630 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4632 struct crypto_testsuite_params *ts_params = &testsuite_params;
4633 struct crypto_unittest_params *ut_params = &unittest_params;
4637 uint8_t *plaintext, *ciphertext;
4638 unsigned int plaintext_pad_len;
4639 unsigned int plaintext_len;
4641 struct rte_cryptodev_info dev_info;
4642 struct rte_cryptodev_sym_capability_idx cap_idx;
4644 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4645 uint64_t feat_flags = dev_info.feature_flags;
4647 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4648 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4649 (tdata->validDataLenInBits.len % 8 != 0))) {
4650 printf("Device doesn't support NON-Byte Aligned Data.\n");
4651 return TEST_SKIPPED;
4654 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4655 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4656 printf("Device doesn't support RAW data-path APIs.\n");
4657 return TEST_SKIPPED;
4660 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4661 return TEST_SKIPPED;
4663 /* Check if device supports ZUC EEA3 */
4664 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4665 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4667 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4669 return TEST_SKIPPED;
4671 /* Check if device supports ZUC EIA3 */
4672 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4673 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4675 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4677 return TEST_SKIPPED;
4679 /* Create ZUC session */
4680 retval = create_zuc_cipher_auth_encrypt_generate_session(
4681 ts_params->valid_devs[0],
4685 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4687 /* clear mbuf payload */
4688 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4689 rte_pktmbuf_tailroom(ut_params->ibuf));
4691 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4692 /* Append data which is padded to a multiple of */
4693 /* the algorithms block size */
4694 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4695 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4697 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4699 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4701 /* Create ZUC operation */
4702 retval = create_zuc_cipher_hash_generate_operation(tdata);
4706 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4707 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4708 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4710 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4712 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4713 ut_params->obuf = ut_params->op->sym->m_src;
4714 if (ut_params->obuf)
4715 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4717 ciphertext = plaintext;
4719 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4721 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4723 tdata->ciphertext.data,
4724 tdata->validDataLenInBits.len,
4725 "ZUC Ciphertext data not as expected");
4727 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4728 + plaintext_pad_len;
4731 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4735 "ZUC Generated auth tag not as expected");
4740 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4742 struct crypto_testsuite_params *ts_params = &testsuite_params;
4743 struct crypto_unittest_params *ut_params = &unittest_params;
4747 uint8_t *plaintext, *ciphertext;
4748 unsigned plaintext_pad_len;
4749 unsigned plaintext_len;
4750 struct rte_cryptodev_info dev_info;
4752 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4753 uint64_t feat_flags = dev_info.feature_flags;
4755 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4756 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4757 printf("Device doesn't support RAW data-path APIs.\n");
4758 return TEST_SKIPPED;
4761 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4762 return TEST_SKIPPED;
4764 /* Verify the capabilities */
4765 struct rte_cryptodev_sym_capability_idx cap_idx;
4766 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4767 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4768 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4770 return TEST_SKIPPED;
4771 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4772 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4773 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4775 return TEST_SKIPPED;
4777 /* Create SNOW 3G session */
4778 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4779 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4780 RTE_CRYPTO_AUTH_OP_GENERATE,
4781 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4782 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4783 tdata->key.data, tdata->key.len,
4784 tdata->auth_iv.len, tdata->digest.len,
4785 tdata->cipher_iv.len);
4788 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4790 /* clear mbuf payload */
4791 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4792 rte_pktmbuf_tailroom(ut_params->ibuf));
4794 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4795 /* Append data which is padded to a multiple of */
4796 /* the algorithms block size */
4797 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4798 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4800 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4802 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4804 /* Create SNOW 3G operation */
4805 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4806 tdata->digest.len, tdata->auth_iv.data,
4808 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4809 tdata->cipher_iv.data, tdata->cipher_iv.len,
4810 tdata->validCipherLenInBits.len,
4812 tdata->validAuthLenInBits.len,
4818 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4819 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4820 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4822 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4824 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4825 ut_params->obuf = ut_params->op->sym->m_src;
4826 if (ut_params->obuf)
4827 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4829 ciphertext = plaintext;
4831 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4833 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4835 tdata->ciphertext.data,
4836 tdata->validDataLenInBits.len,
4837 "SNOW 3G Ciphertext data not as expected");
4839 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4840 + plaintext_pad_len;
4843 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4846 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4847 "SNOW 3G Generated auth tag not as expected");
4852 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4853 uint8_t op_mode, uint8_t verify)
4855 struct crypto_testsuite_params *ts_params = &testsuite_params;
4856 struct crypto_unittest_params *ut_params = &unittest_params;
4860 uint8_t *plaintext = NULL, *ciphertext = NULL;
4861 unsigned int plaintext_pad_len;
4862 unsigned int plaintext_len;
4863 unsigned int ciphertext_pad_len;
4864 unsigned int ciphertext_len;
4866 struct rte_cryptodev_info dev_info;
4868 /* Verify the capabilities */
4869 struct rte_cryptodev_sym_capability_idx cap_idx;
4870 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4871 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4872 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4874 return TEST_SKIPPED;
4875 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4876 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4877 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4879 return TEST_SKIPPED;
4881 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4882 return TEST_SKIPPED;
4884 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4886 uint64_t feat_flags = dev_info.feature_flags;
4888 if (op_mode == OUT_OF_PLACE) {
4889 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4890 printf("Device doesn't support digest encrypted.\n");
4891 return TEST_SKIPPED;
4893 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4894 return TEST_SKIPPED;
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 /* Create SNOW 3G session */
4904 retval = create_wireless_algo_auth_cipher_session(
4905 ts_params->valid_devs[0],
4906 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4907 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4908 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4909 : RTE_CRYPTO_AUTH_OP_GENERATE),
4910 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4911 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4912 tdata->key.data, tdata->key.len,
4913 tdata->auth_iv.len, tdata->digest.len,
4914 tdata->cipher_iv.len);
4918 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4919 if (op_mode == OUT_OF_PLACE)
4920 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4922 /* clear mbuf payload */
4923 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4924 rte_pktmbuf_tailroom(ut_params->ibuf));
4925 if (op_mode == OUT_OF_PLACE)
4926 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4927 rte_pktmbuf_tailroom(ut_params->obuf));
4929 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4930 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4931 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4932 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4935 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4936 ciphertext_pad_len);
4937 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4938 if (op_mode == OUT_OF_PLACE)
4939 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4940 debug_hexdump(stdout, "ciphertext:", ciphertext,
4943 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4945 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4946 if (op_mode == OUT_OF_PLACE)
4947 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4948 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4951 /* Create SNOW 3G operation */
4952 retval = create_wireless_algo_auth_cipher_operation(
4953 tdata->digest.data, tdata->digest.len,
4954 tdata->cipher_iv.data, tdata->cipher_iv.len,
4955 tdata->auth_iv.data, tdata->auth_iv.len,
4956 (tdata->digest.offset_bytes == 0 ?
4957 (verify ? ciphertext_pad_len : plaintext_pad_len)
4958 : tdata->digest.offset_bytes),
4959 tdata->validCipherLenInBits.len,
4960 tdata->cipher.offset_bits,
4961 tdata->validAuthLenInBits.len,
4962 tdata->auth.offset_bits,
4963 op_mode, 0, verify);
4968 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4969 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4970 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4972 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4975 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4977 ut_params->obuf = (op_mode == IN_PLACE ?
4978 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4981 if (ut_params->obuf)
4982 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4985 plaintext = ciphertext +
4986 (tdata->cipher.offset_bits >> 3);
4988 debug_hexdump(stdout, "plaintext:", plaintext,
4989 (tdata->plaintext.len >> 3) - tdata->digest.len);
4990 debug_hexdump(stdout, "plaintext expected:",
4991 tdata->plaintext.data,
4992 (tdata->plaintext.len >> 3) - tdata->digest.len);
4994 if (ut_params->obuf)
4995 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4998 ciphertext = plaintext;
5000 debug_hexdump(stdout, "ciphertext:", ciphertext,
5002 debug_hexdump(stdout, "ciphertext expected:",
5003 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5005 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5006 + (tdata->digest.offset_bytes == 0 ?
5007 plaintext_pad_len : tdata->digest.offset_bytes);
5009 debug_hexdump(stdout, "digest:", ut_params->digest,
5011 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5017 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5019 tdata->plaintext.data,
5020 (tdata->plaintext.len - tdata->cipher.offset_bits -
5021 (tdata->digest.len << 3)),
5022 tdata->cipher.offset_bits,
5023 "SNOW 3G Plaintext data not as expected");
5025 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5027 tdata->ciphertext.data,
5028 (tdata->validDataLenInBits.len -
5029 tdata->cipher.offset_bits),
5030 tdata->cipher.offset_bits,
5031 "SNOW 3G Ciphertext data not as expected");
5033 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5036 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5037 "SNOW 3G Generated auth tag not as expected");
5043 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5044 uint8_t op_mode, uint8_t verify)
5046 struct crypto_testsuite_params *ts_params = &testsuite_params;
5047 struct crypto_unittest_params *ut_params = &unittest_params;
5051 const uint8_t *plaintext = NULL;
5052 const uint8_t *ciphertext = NULL;
5053 const uint8_t *digest = NULL;
5054 unsigned int plaintext_pad_len;
5055 unsigned int plaintext_len;
5056 unsigned int ciphertext_pad_len;
5057 unsigned int ciphertext_len;
5058 uint8_t buffer[10000];
5059 uint8_t digest_buffer[10000];
5061 struct rte_cryptodev_info dev_info;
5063 /* Verify the capabilities */
5064 struct rte_cryptodev_sym_capability_idx cap_idx;
5065 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5066 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5067 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5069 return TEST_SKIPPED;
5070 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5071 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5072 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5074 return TEST_SKIPPED;
5076 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5077 return TEST_SKIPPED;
5079 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5081 uint64_t feat_flags = dev_info.feature_flags;
5083 if (op_mode == IN_PLACE) {
5084 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5085 printf("Device doesn't support in-place scatter-gather "
5086 "in both input and output mbufs.\n");
5087 return TEST_SKIPPED;
5089 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5090 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5091 printf("Device doesn't support RAW data-path APIs.\n");
5092 return TEST_SKIPPED;
5095 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5096 return TEST_SKIPPED;
5097 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5098 printf("Device doesn't support out-of-place scatter-gather "
5099 "in both input and output mbufs.\n");
5100 return TEST_SKIPPED;
5102 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5103 printf("Device doesn't support digest encrypted.\n");
5104 return TEST_SKIPPED;
5108 /* Create SNOW 3G session */
5109 retval = create_wireless_algo_auth_cipher_session(
5110 ts_params->valid_devs[0],
5111 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5112 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5113 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5114 : RTE_CRYPTO_AUTH_OP_GENERATE),
5115 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5116 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5117 tdata->key.data, tdata->key.len,
5118 tdata->auth_iv.len, tdata->digest.len,
5119 tdata->cipher_iv.len);
5124 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5125 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5126 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5127 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5129 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5130 plaintext_pad_len, 15, 0);
5131 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5132 "Failed to allocate input buffer in mempool");
5134 if (op_mode == OUT_OF_PLACE) {
5135 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5136 plaintext_pad_len, 15, 0);
5137 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5138 "Failed to allocate output buffer in mempool");
5142 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5143 tdata->ciphertext.data);
5144 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5145 ciphertext_len, buffer);
5146 debug_hexdump(stdout, "ciphertext:", ciphertext,
5149 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5150 tdata->plaintext.data);
5151 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5152 plaintext_len, buffer);
5153 debug_hexdump(stdout, "plaintext:", plaintext,
5156 memset(buffer, 0, sizeof(buffer));
5158 /* Create SNOW 3G operation */
5159 retval = create_wireless_algo_auth_cipher_operation(
5160 tdata->digest.data, tdata->digest.len,
5161 tdata->cipher_iv.data, tdata->cipher_iv.len,
5162 tdata->auth_iv.data, tdata->auth_iv.len,
5163 (tdata->digest.offset_bytes == 0 ?
5164 (verify ? ciphertext_pad_len : plaintext_pad_len)
5165 : tdata->digest.offset_bytes),
5166 tdata->validCipherLenInBits.len,
5167 tdata->cipher.offset_bits,
5168 tdata->validAuthLenInBits.len,
5169 tdata->auth.offset_bits,
5170 op_mode, 1, verify);
5175 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5176 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5177 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5179 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5182 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5184 ut_params->obuf = (op_mode == IN_PLACE ?
5185 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5188 if (ut_params->obuf)
5189 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5190 plaintext_len, buffer);
5192 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5193 plaintext_len, buffer);
5195 debug_hexdump(stdout, "plaintext:", plaintext,
5196 (tdata->plaintext.len >> 3) - tdata->digest.len);
5197 debug_hexdump(stdout, "plaintext expected:",
5198 tdata->plaintext.data,
5199 (tdata->plaintext.len >> 3) - tdata->digest.len);
5201 if (ut_params->obuf)
5202 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5203 ciphertext_len, buffer);
5205 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5206 ciphertext_len, buffer);
5208 debug_hexdump(stdout, "ciphertext:", ciphertext,
5210 debug_hexdump(stdout, "ciphertext expected:",
5211 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5213 if (ut_params->obuf)
5214 digest = rte_pktmbuf_read(ut_params->obuf,
5215 (tdata->digest.offset_bytes == 0 ?
5216 plaintext_pad_len : tdata->digest.offset_bytes),
5217 tdata->digest.len, digest_buffer);
5219 digest = rte_pktmbuf_read(ut_params->ibuf,
5220 (tdata->digest.offset_bytes == 0 ?
5221 plaintext_pad_len : tdata->digest.offset_bytes),
5222 tdata->digest.len, digest_buffer);
5224 debug_hexdump(stdout, "digest:", digest,
5226 debug_hexdump(stdout, "digest expected:",
5227 tdata->digest.data, tdata->digest.len);
5232 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5234 tdata->plaintext.data,
5235 (tdata->plaintext.len - tdata->cipher.offset_bits -
5236 (tdata->digest.len << 3)),
5237 tdata->cipher.offset_bits,
5238 "SNOW 3G Plaintext data not as expected");
5240 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5242 tdata->ciphertext.data,
5243 (tdata->validDataLenInBits.len -
5244 tdata->cipher.offset_bits),
5245 tdata->cipher.offset_bits,
5246 "SNOW 3G Ciphertext data not as expected");
5248 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5251 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5252 "SNOW 3G Generated auth tag not as expected");
5258 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5259 uint8_t op_mode, uint8_t verify)
5261 struct crypto_testsuite_params *ts_params = &testsuite_params;
5262 struct crypto_unittest_params *ut_params = &unittest_params;
5266 uint8_t *plaintext = NULL, *ciphertext = NULL;
5267 unsigned int plaintext_pad_len;
5268 unsigned int plaintext_len;
5269 unsigned int ciphertext_pad_len;
5270 unsigned int ciphertext_len;
5272 struct rte_cryptodev_info dev_info;
5274 /* Verify the capabilities */
5275 struct rte_cryptodev_sym_capability_idx cap_idx;
5276 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5277 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5278 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5280 return TEST_SKIPPED;
5281 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5282 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5283 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5285 return TEST_SKIPPED;
5287 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5289 uint64_t feat_flags = dev_info.feature_flags;
5291 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5292 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5293 printf("Device doesn't support RAW data-path APIs.\n");
5294 return TEST_SKIPPED;
5297 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5298 return TEST_SKIPPED;
5300 if (op_mode == OUT_OF_PLACE) {
5301 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5302 return TEST_SKIPPED;
5303 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5304 printf("Device doesn't support digest encrypted.\n");
5305 return TEST_SKIPPED;
5309 /* Create KASUMI session */
5310 retval = create_wireless_algo_auth_cipher_session(
5311 ts_params->valid_devs[0],
5312 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5313 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5314 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5315 : RTE_CRYPTO_AUTH_OP_GENERATE),
5316 RTE_CRYPTO_AUTH_KASUMI_F9,
5317 RTE_CRYPTO_CIPHER_KASUMI_F8,
5318 tdata->key.data, tdata->key.len,
5319 0, tdata->digest.len,
5320 tdata->cipher_iv.len);
5325 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5326 if (op_mode == OUT_OF_PLACE)
5327 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5329 /* clear mbuf payload */
5330 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5331 rte_pktmbuf_tailroom(ut_params->ibuf));
5332 if (op_mode == OUT_OF_PLACE)
5333 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5334 rte_pktmbuf_tailroom(ut_params->obuf));
5336 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5337 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5338 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5339 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5342 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5343 ciphertext_pad_len);
5344 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5345 if (op_mode == OUT_OF_PLACE)
5346 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5347 debug_hexdump(stdout, "ciphertext:", ciphertext,
5350 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5352 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5353 if (op_mode == OUT_OF_PLACE)
5354 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5355 debug_hexdump(stdout, "plaintext:", plaintext,
5359 /* Create KASUMI operation */
5360 retval = create_wireless_algo_auth_cipher_operation(
5361 tdata->digest.data, tdata->digest.len,
5362 tdata->cipher_iv.data, tdata->cipher_iv.len,
5364 (tdata->digest.offset_bytes == 0 ?
5365 (verify ? ciphertext_pad_len : plaintext_pad_len)
5366 : tdata->digest.offset_bytes),
5367 tdata->validCipherLenInBits.len,
5368 tdata->validCipherOffsetInBits.len,
5369 tdata->validAuthLenInBits.len,
5371 op_mode, 0, verify);
5376 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5377 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5378 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5380 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5383 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5385 ut_params->obuf = (op_mode == IN_PLACE ?
5386 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5390 if (ut_params->obuf)
5391 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5394 plaintext = ciphertext;
5396 debug_hexdump(stdout, "plaintext:", plaintext,
5397 (tdata->plaintext.len >> 3) - tdata->digest.len);
5398 debug_hexdump(stdout, "plaintext expected:",
5399 tdata->plaintext.data,
5400 (tdata->plaintext.len >> 3) - tdata->digest.len);
5402 if (ut_params->obuf)
5403 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5406 ciphertext = plaintext;
5408 debug_hexdump(stdout, "ciphertext:", ciphertext,
5410 debug_hexdump(stdout, "ciphertext expected:",
5411 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5413 ut_params->digest = rte_pktmbuf_mtod(
5414 ut_params->obuf, uint8_t *) +
5415 (tdata->digest.offset_bytes == 0 ?
5416 plaintext_pad_len : tdata->digest.offset_bytes);
5418 debug_hexdump(stdout, "digest:", ut_params->digest,
5420 debug_hexdump(stdout, "digest expected:",
5421 tdata->digest.data, tdata->digest.len);
5426 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5428 tdata->plaintext.data,
5429 tdata->plaintext.len >> 3,
5430 "KASUMI Plaintext data not as expected");
5432 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5434 tdata->ciphertext.data,
5435 tdata->ciphertext.len >> 3,
5436 "KASUMI Ciphertext data not as expected");
5438 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5441 DIGEST_BYTE_LENGTH_KASUMI_F9,
5442 "KASUMI Generated auth tag not as expected");
5448 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5449 uint8_t op_mode, uint8_t verify)
5451 struct crypto_testsuite_params *ts_params = &testsuite_params;
5452 struct crypto_unittest_params *ut_params = &unittest_params;
5456 const uint8_t *plaintext = NULL;
5457 const uint8_t *ciphertext = NULL;
5458 const uint8_t *digest = NULL;
5459 unsigned int plaintext_pad_len;
5460 unsigned int plaintext_len;
5461 unsigned int ciphertext_pad_len;
5462 unsigned int ciphertext_len;
5463 uint8_t buffer[10000];
5464 uint8_t digest_buffer[10000];
5466 struct rte_cryptodev_info dev_info;
5468 /* Verify the capabilities */
5469 struct rte_cryptodev_sym_capability_idx cap_idx;
5470 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5471 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5472 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5474 return TEST_SKIPPED;
5475 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5476 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5477 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5479 return TEST_SKIPPED;
5481 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5482 return TEST_SKIPPED;
5484 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5486 uint64_t feat_flags = dev_info.feature_flags;
5488 if (op_mode == IN_PLACE) {
5489 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5490 printf("Device doesn't support in-place scatter-gather "
5491 "in both input and output mbufs.\n");
5492 return TEST_SKIPPED;
5494 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5495 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5496 printf("Device doesn't support RAW data-path APIs.\n");
5497 return TEST_SKIPPED;
5500 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5501 return TEST_SKIPPED;
5502 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5503 printf("Device doesn't support out-of-place scatter-gather "
5504 "in both input and output mbufs.\n");
5505 return TEST_SKIPPED;
5507 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5508 printf("Device doesn't support digest encrypted.\n");
5509 return TEST_SKIPPED;
5513 /* Create KASUMI session */
5514 retval = create_wireless_algo_auth_cipher_session(
5515 ts_params->valid_devs[0],
5516 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5517 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5518 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5519 : RTE_CRYPTO_AUTH_OP_GENERATE),
5520 RTE_CRYPTO_AUTH_KASUMI_F9,
5521 RTE_CRYPTO_CIPHER_KASUMI_F8,
5522 tdata->key.data, tdata->key.len,
5523 0, tdata->digest.len,
5524 tdata->cipher_iv.len);
5529 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5530 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5531 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5532 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5534 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5535 plaintext_pad_len, 15, 0);
5536 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5537 "Failed to allocate input buffer in mempool");
5539 if (op_mode == OUT_OF_PLACE) {
5540 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5541 plaintext_pad_len, 15, 0);
5542 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5543 "Failed to allocate output buffer in mempool");
5547 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5548 tdata->ciphertext.data);
5549 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5550 ciphertext_len, buffer);
5551 debug_hexdump(stdout, "ciphertext:", ciphertext,
5554 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5555 tdata->plaintext.data);
5556 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5557 plaintext_len, buffer);
5558 debug_hexdump(stdout, "plaintext:", plaintext,
5561 memset(buffer, 0, sizeof(buffer));
5563 /* Create KASUMI operation */
5564 retval = create_wireless_algo_auth_cipher_operation(
5565 tdata->digest.data, tdata->digest.len,
5566 tdata->cipher_iv.data, tdata->cipher_iv.len,
5568 (tdata->digest.offset_bytes == 0 ?
5569 (verify ? ciphertext_pad_len : plaintext_pad_len)
5570 : tdata->digest.offset_bytes),
5571 tdata->validCipherLenInBits.len,
5572 tdata->validCipherOffsetInBits.len,
5573 tdata->validAuthLenInBits.len,
5575 op_mode, 1, verify);
5580 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5581 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5582 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5584 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5587 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5589 ut_params->obuf = (op_mode == IN_PLACE ?
5590 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5593 if (ut_params->obuf)
5594 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5595 plaintext_len, buffer);
5597 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5598 plaintext_len, buffer);
5600 debug_hexdump(stdout, "plaintext:", plaintext,
5601 (tdata->plaintext.len >> 3) - tdata->digest.len);
5602 debug_hexdump(stdout, "plaintext expected:",
5603 tdata->plaintext.data,
5604 (tdata->plaintext.len >> 3) - tdata->digest.len);
5606 if (ut_params->obuf)
5607 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5608 ciphertext_len, buffer);
5610 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5611 ciphertext_len, buffer);
5613 debug_hexdump(stdout, "ciphertext:", ciphertext,
5615 debug_hexdump(stdout, "ciphertext expected:",
5616 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5618 if (ut_params->obuf)
5619 digest = rte_pktmbuf_read(ut_params->obuf,
5620 (tdata->digest.offset_bytes == 0 ?
5621 plaintext_pad_len : tdata->digest.offset_bytes),
5622 tdata->digest.len, digest_buffer);
5624 digest = rte_pktmbuf_read(ut_params->ibuf,
5625 (tdata->digest.offset_bytes == 0 ?
5626 plaintext_pad_len : tdata->digest.offset_bytes),
5627 tdata->digest.len, digest_buffer);
5629 debug_hexdump(stdout, "digest:", digest,
5631 debug_hexdump(stdout, "digest expected:",
5632 tdata->digest.data, tdata->digest.len);
5637 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5639 tdata->plaintext.data,
5640 tdata->plaintext.len >> 3,
5641 "KASUMI Plaintext data not as expected");
5643 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5645 tdata->ciphertext.data,
5646 tdata->validDataLenInBits.len,
5647 "KASUMI Ciphertext data not as expected");
5649 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5652 DIGEST_BYTE_LENGTH_KASUMI_F9,
5653 "KASUMI Generated auth tag not as expected");
5659 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5661 struct crypto_testsuite_params *ts_params = &testsuite_params;
5662 struct crypto_unittest_params *ut_params = &unittest_params;
5666 uint8_t *plaintext, *ciphertext;
5667 unsigned plaintext_pad_len;
5668 unsigned plaintext_len;
5669 struct rte_cryptodev_info dev_info;
5671 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5672 uint64_t feat_flags = dev_info.feature_flags;
5674 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5675 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5676 printf("Device doesn't support RAW data-path APIs.\n");
5677 return TEST_SKIPPED;
5680 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5681 return TEST_SKIPPED;
5683 /* Verify the capabilities */
5684 struct rte_cryptodev_sym_capability_idx cap_idx;
5685 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5686 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5687 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5689 return TEST_SKIPPED;
5690 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5691 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5692 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5694 return TEST_SKIPPED;
5696 /* Create KASUMI session */
5697 retval = create_wireless_algo_cipher_auth_session(
5698 ts_params->valid_devs[0],
5699 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5700 RTE_CRYPTO_AUTH_OP_GENERATE,
5701 RTE_CRYPTO_AUTH_KASUMI_F9,
5702 RTE_CRYPTO_CIPHER_KASUMI_F8,
5703 tdata->key.data, tdata->key.len,
5704 0, tdata->digest.len,
5705 tdata->cipher_iv.len);
5709 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5711 /* clear mbuf payload */
5712 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5713 rte_pktmbuf_tailroom(ut_params->ibuf));
5715 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5716 /* Append data which is padded to a multiple of */
5717 /* the algorithms block size */
5718 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5719 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5721 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5723 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5725 /* Create KASUMI operation */
5726 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5727 tdata->digest.len, NULL, 0,
5728 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5729 tdata->cipher_iv.data, tdata->cipher_iv.len,
5730 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5731 tdata->validCipherOffsetInBits.len,
5732 tdata->validAuthLenInBits.len,
5738 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5739 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5740 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5742 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5744 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5746 if (ut_params->op->sym->m_dst)
5747 ut_params->obuf = ut_params->op->sym->m_dst;
5749 ut_params->obuf = ut_params->op->sym->m_src;
5751 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5752 tdata->validCipherOffsetInBits.len >> 3);
5754 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5755 + plaintext_pad_len;
5757 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5758 (tdata->validCipherOffsetInBits.len >> 3);
5760 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5762 reference_ciphertext,
5763 tdata->validCipherLenInBits.len,
5764 "KASUMI Ciphertext data not as expected");
5767 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5770 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5771 "KASUMI Generated auth tag not as expected");
5776 test_zuc_encryption(const struct wireless_test_data *tdata)
5778 struct crypto_testsuite_params *ts_params = &testsuite_params;
5779 struct crypto_unittest_params *ut_params = &unittest_params;
5782 uint8_t *plaintext, *ciphertext;
5783 unsigned plaintext_pad_len;
5784 unsigned plaintext_len;
5785 struct rte_cryptodev_info dev_info;
5787 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5788 uint64_t feat_flags = dev_info.feature_flags;
5790 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5791 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5792 printf("Device doesn't support RAW data-path APIs.\n");
5793 return TEST_SKIPPED;
5796 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5797 return TEST_SKIPPED;
5799 struct rte_cryptodev_sym_capability_idx cap_idx;
5801 /* Check if device supports ZUC EEA3 */
5802 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5803 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5805 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5807 return TEST_SKIPPED;
5809 /* Create ZUC session */
5810 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5811 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5812 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5813 tdata->key.data, tdata->key.len,
5814 tdata->cipher_iv.len);
5818 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5820 /* Clear mbuf payload */
5821 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5822 rte_pktmbuf_tailroom(ut_params->ibuf));
5824 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5825 /* Append data which is padded to a multiple */
5826 /* of the algorithms block size */
5827 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5828 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5830 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5832 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5834 /* Create ZUC operation */
5835 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5836 tdata->cipher_iv.len,
5837 tdata->plaintext.len,
5842 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5843 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5844 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5846 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5848 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5850 ut_params->obuf = ut_params->op->sym->m_dst;
5851 if (ut_params->obuf)
5852 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5854 ciphertext = plaintext;
5856 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5859 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5861 tdata->ciphertext.data,
5862 tdata->validCipherLenInBits.len,
5863 "ZUC Ciphertext data not as expected");
5868 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5870 struct crypto_testsuite_params *ts_params = &testsuite_params;
5871 struct crypto_unittest_params *ut_params = &unittest_params;
5875 unsigned int plaintext_pad_len;
5876 unsigned int plaintext_len;
5877 const uint8_t *ciphertext;
5878 uint8_t ciphertext_buffer[2048];
5879 struct rte_cryptodev_info dev_info;
5881 struct rte_cryptodev_sym_capability_idx cap_idx;
5883 /* Check if device supports ZUC EEA3 */
5884 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5885 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5887 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5889 return TEST_SKIPPED;
5891 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5892 return TEST_SKIPPED;
5894 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5896 uint64_t feat_flags = dev_info.feature_flags;
5898 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5899 printf("Device doesn't support in-place scatter-gather. "
5901 return TEST_SKIPPED;
5904 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5905 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5906 printf("Device doesn't support RAW data-path APIs.\n");
5907 return TEST_SKIPPED;
5910 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5912 /* Append data which is padded to a multiple */
5913 /* of the algorithms block size */
5914 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5916 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5917 plaintext_pad_len, 10, 0);
5919 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5920 tdata->plaintext.data);
5922 /* Create ZUC session */
5923 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5924 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5925 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5926 tdata->key.data, tdata->key.len,
5927 tdata->cipher_iv.len);
5931 /* Clear mbuf payload */
5933 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5935 /* Create ZUC operation */
5936 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5937 tdata->cipher_iv.len, tdata->plaintext.len,
5942 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5943 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5944 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5946 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5948 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5950 ut_params->obuf = ut_params->op->sym->m_dst;
5951 if (ut_params->obuf)
5952 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5953 0, plaintext_len, ciphertext_buffer);
5955 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5956 0, plaintext_len, ciphertext_buffer);
5959 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5962 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5964 tdata->ciphertext.data,
5965 tdata->validCipherLenInBits.len,
5966 "ZUC Ciphertext data not as expected");
5972 test_zuc_authentication(const struct wireless_test_data *tdata)
5974 struct crypto_testsuite_params *ts_params = &testsuite_params;
5975 struct crypto_unittest_params *ut_params = &unittest_params;
5978 unsigned plaintext_pad_len;
5979 unsigned plaintext_len;
5982 struct rte_cryptodev_sym_capability_idx cap_idx;
5983 struct rte_cryptodev_info dev_info;
5985 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5986 uint64_t feat_flags = dev_info.feature_flags;
5988 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5989 (tdata->validAuthLenInBits.len % 8 != 0)) {
5990 printf("Device doesn't support NON-Byte Aligned Data.\n");
5991 return TEST_SKIPPED;
5994 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5995 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5996 printf("Device doesn't support RAW data-path APIs.\n");
5997 return TEST_SKIPPED;
6000 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6001 return TEST_SKIPPED;
6003 /* Check if device supports ZUC EIA3 */
6004 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6005 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6007 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6009 return TEST_SKIPPED;
6011 /* Create ZUC session */
6012 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6013 tdata->key.data, tdata->key.len,
6014 tdata->auth_iv.len, tdata->digest.len,
6015 RTE_CRYPTO_AUTH_OP_GENERATE,
6016 RTE_CRYPTO_AUTH_ZUC_EIA3);
6020 /* alloc mbuf and set payload */
6021 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6023 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6024 rte_pktmbuf_tailroom(ut_params->ibuf));
6026 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6027 /* Append data which is padded to a multiple of */
6028 /* the algorithms block size */
6029 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6030 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6032 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6034 /* Create ZUC operation */
6035 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6036 tdata->auth_iv.data, tdata->auth_iv.len,
6037 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6038 tdata->validAuthLenInBits.len,
6043 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6044 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6045 ut_params->op, 0, 1, 1, 0);
6047 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6049 ut_params->obuf = ut_params->op->sym->m_src;
6050 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6051 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6052 + plaintext_pad_len;
6055 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6059 "ZUC Generated auth tag not as expected");
6065 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6066 uint8_t op_mode, uint8_t verify)
6068 struct crypto_testsuite_params *ts_params = &testsuite_params;
6069 struct crypto_unittest_params *ut_params = &unittest_params;
6073 uint8_t *plaintext = NULL, *ciphertext = NULL;
6074 unsigned int plaintext_pad_len;
6075 unsigned int plaintext_len;
6076 unsigned int ciphertext_pad_len;
6077 unsigned int ciphertext_len;
6079 struct rte_cryptodev_info dev_info;
6080 struct rte_cryptodev_sym_capability_idx cap_idx;
6082 /* Check if device supports ZUC EIA3 */
6083 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6084 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6086 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6088 return TEST_SKIPPED;
6090 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6092 uint64_t feat_flags = dev_info.feature_flags;
6094 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6095 printf("Device doesn't support digest encrypted.\n");
6096 return TEST_SKIPPED;
6098 if (op_mode == IN_PLACE) {
6099 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6100 printf("Device doesn't support in-place scatter-gather "
6101 "in both input and output mbufs.\n");
6102 return TEST_SKIPPED;
6105 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6106 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6107 printf("Device doesn't support RAW data-path APIs.\n");
6108 return TEST_SKIPPED;
6111 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6112 return TEST_SKIPPED;
6113 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6114 printf("Device doesn't support out-of-place scatter-gather "
6115 "in both input and output mbufs.\n");
6116 return TEST_SKIPPED;
6120 /* Create ZUC session */
6121 retval = create_wireless_algo_auth_cipher_session(
6122 ts_params->valid_devs[0],
6123 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6124 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6125 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6126 : RTE_CRYPTO_AUTH_OP_GENERATE),
6127 RTE_CRYPTO_AUTH_ZUC_EIA3,
6128 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6129 tdata->key.data, tdata->key.len,
6130 tdata->auth_iv.len, tdata->digest.len,
6131 tdata->cipher_iv.len);
6136 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6137 if (op_mode == OUT_OF_PLACE)
6138 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6140 /* clear mbuf payload */
6141 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6142 rte_pktmbuf_tailroom(ut_params->ibuf));
6143 if (op_mode == OUT_OF_PLACE)
6144 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6145 rte_pktmbuf_tailroom(ut_params->obuf));
6147 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6148 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6149 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6150 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6153 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6154 ciphertext_pad_len);
6155 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6156 if (op_mode == OUT_OF_PLACE)
6157 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6158 debug_hexdump(stdout, "ciphertext:", ciphertext,
6161 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6163 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6164 if (op_mode == OUT_OF_PLACE)
6165 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6166 debug_hexdump(stdout, "plaintext:", plaintext,
6170 /* Create ZUC operation */
6171 retval = create_wireless_algo_auth_cipher_operation(
6172 tdata->digest.data, tdata->digest.len,
6173 tdata->cipher_iv.data, tdata->cipher_iv.len,
6174 tdata->auth_iv.data, tdata->auth_iv.len,
6175 (tdata->digest.offset_bytes == 0 ?
6176 (verify ? ciphertext_pad_len : plaintext_pad_len)
6177 : tdata->digest.offset_bytes),
6178 tdata->validCipherLenInBits.len,
6179 tdata->validCipherOffsetInBits.len,
6180 tdata->validAuthLenInBits.len,
6182 op_mode, 0, verify);
6187 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6188 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6189 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6191 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6194 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6196 ut_params->obuf = (op_mode == IN_PLACE ?
6197 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6201 if (ut_params->obuf)
6202 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6205 plaintext = ciphertext;
6207 debug_hexdump(stdout, "plaintext:", plaintext,
6208 (tdata->plaintext.len >> 3) - tdata->digest.len);
6209 debug_hexdump(stdout, "plaintext expected:",
6210 tdata->plaintext.data,
6211 (tdata->plaintext.len >> 3) - tdata->digest.len);
6213 if (ut_params->obuf)
6214 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6217 ciphertext = plaintext;
6219 debug_hexdump(stdout, "ciphertext:", ciphertext,
6221 debug_hexdump(stdout, "ciphertext expected:",
6222 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6224 ut_params->digest = rte_pktmbuf_mtod(
6225 ut_params->obuf, uint8_t *) +
6226 (tdata->digest.offset_bytes == 0 ?
6227 plaintext_pad_len : tdata->digest.offset_bytes);
6229 debug_hexdump(stdout, "digest:", ut_params->digest,
6231 debug_hexdump(stdout, "digest expected:",
6232 tdata->digest.data, tdata->digest.len);
6237 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6239 tdata->plaintext.data,
6240 tdata->plaintext.len >> 3,
6241 "ZUC Plaintext data not as expected");
6243 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6245 tdata->ciphertext.data,
6246 tdata->ciphertext.len >> 3,
6247 "ZUC Ciphertext data not as expected");
6249 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6252 DIGEST_BYTE_LENGTH_KASUMI_F9,
6253 "ZUC Generated auth tag not as expected");
6259 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6260 uint8_t op_mode, uint8_t verify)
6262 struct crypto_testsuite_params *ts_params = &testsuite_params;
6263 struct crypto_unittest_params *ut_params = &unittest_params;
6267 const uint8_t *plaintext = NULL;
6268 const uint8_t *ciphertext = NULL;
6269 const uint8_t *digest = NULL;
6270 unsigned int plaintext_pad_len;
6271 unsigned int plaintext_len;
6272 unsigned int ciphertext_pad_len;
6273 unsigned int ciphertext_len;
6274 uint8_t buffer[10000];
6275 uint8_t digest_buffer[10000];
6277 struct rte_cryptodev_info dev_info;
6278 struct rte_cryptodev_sym_capability_idx cap_idx;
6280 /* Check if device supports ZUC EIA3 */
6281 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6282 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6284 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6286 return TEST_SKIPPED;
6288 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6290 uint64_t feat_flags = dev_info.feature_flags;
6292 if (op_mode == IN_PLACE) {
6293 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6294 printf("Device doesn't support in-place scatter-gather "
6295 "in both input and output mbufs.\n");
6296 return TEST_SKIPPED;
6299 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6300 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6301 printf("Device doesn't support RAW data-path APIs.\n");
6302 return TEST_SKIPPED;
6305 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6306 return TEST_SKIPPED;
6307 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6308 printf("Device doesn't support out-of-place scatter-gather "
6309 "in both input and output mbufs.\n");
6310 return TEST_SKIPPED;
6312 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6313 printf("Device doesn't support digest encrypted.\n");
6314 return TEST_SKIPPED;
6318 /* Create ZUC session */
6319 retval = create_wireless_algo_auth_cipher_session(
6320 ts_params->valid_devs[0],
6321 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6322 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6323 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6324 : RTE_CRYPTO_AUTH_OP_GENERATE),
6325 RTE_CRYPTO_AUTH_ZUC_EIA3,
6326 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6327 tdata->key.data, tdata->key.len,
6328 tdata->auth_iv.len, tdata->digest.len,
6329 tdata->cipher_iv.len);
6334 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6335 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6336 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6337 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6339 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6340 plaintext_pad_len, 15, 0);
6341 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6342 "Failed to allocate input buffer in mempool");
6344 if (op_mode == OUT_OF_PLACE) {
6345 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6346 plaintext_pad_len, 15, 0);
6347 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6348 "Failed to allocate output buffer in mempool");
6352 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6353 tdata->ciphertext.data);
6354 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6355 ciphertext_len, buffer);
6356 debug_hexdump(stdout, "ciphertext:", ciphertext,
6359 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6360 tdata->plaintext.data);
6361 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6362 plaintext_len, buffer);
6363 debug_hexdump(stdout, "plaintext:", plaintext,
6366 memset(buffer, 0, sizeof(buffer));
6368 /* Create ZUC operation */
6369 retval = create_wireless_algo_auth_cipher_operation(
6370 tdata->digest.data, tdata->digest.len,
6371 tdata->cipher_iv.data, tdata->cipher_iv.len,
6373 (tdata->digest.offset_bytes == 0 ?
6374 (verify ? ciphertext_pad_len : plaintext_pad_len)
6375 : tdata->digest.offset_bytes),
6376 tdata->validCipherLenInBits.len,
6377 tdata->validCipherOffsetInBits.len,
6378 tdata->validAuthLenInBits.len,
6380 op_mode, 1, verify);
6385 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6386 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6387 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6389 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6392 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6394 ut_params->obuf = (op_mode == IN_PLACE ?
6395 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6398 if (ut_params->obuf)
6399 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6400 plaintext_len, buffer);
6402 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6403 plaintext_len, buffer);
6405 debug_hexdump(stdout, "plaintext:", plaintext,
6406 (tdata->plaintext.len >> 3) - tdata->digest.len);
6407 debug_hexdump(stdout, "plaintext expected:",
6408 tdata->plaintext.data,
6409 (tdata->plaintext.len >> 3) - tdata->digest.len);
6411 if (ut_params->obuf)
6412 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6413 ciphertext_len, buffer);
6415 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6416 ciphertext_len, buffer);
6418 debug_hexdump(stdout, "ciphertext:", ciphertext,
6420 debug_hexdump(stdout, "ciphertext expected:",
6421 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6423 if (ut_params->obuf)
6424 digest = rte_pktmbuf_read(ut_params->obuf,
6425 (tdata->digest.offset_bytes == 0 ?
6426 plaintext_pad_len : tdata->digest.offset_bytes),
6427 tdata->digest.len, digest_buffer);
6429 digest = rte_pktmbuf_read(ut_params->ibuf,
6430 (tdata->digest.offset_bytes == 0 ?
6431 plaintext_pad_len : tdata->digest.offset_bytes),
6432 tdata->digest.len, digest_buffer);
6434 debug_hexdump(stdout, "digest:", digest,
6436 debug_hexdump(stdout, "digest expected:",
6437 tdata->digest.data, tdata->digest.len);
6442 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6444 tdata->plaintext.data,
6445 tdata->plaintext.len >> 3,
6446 "ZUC Plaintext data not as expected");
6448 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6450 tdata->ciphertext.data,
6451 tdata->validDataLenInBits.len,
6452 "ZUC Ciphertext data not as expected");
6454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6457 DIGEST_BYTE_LENGTH_KASUMI_F9,
6458 "ZUC Generated auth tag not as expected");
6464 test_kasumi_encryption_test_case_1(void)
6466 return test_kasumi_encryption(&kasumi_test_case_1);
6470 test_kasumi_encryption_test_case_1_sgl(void)
6472 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6476 test_kasumi_encryption_test_case_1_oop(void)
6478 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6482 test_kasumi_encryption_test_case_1_oop_sgl(void)
6484 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6488 test_kasumi_encryption_test_case_2(void)
6490 return test_kasumi_encryption(&kasumi_test_case_2);
6494 test_kasumi_encryption_test_case_3(void)
6496 return test_kasumi_encryption(&kasumi_test_case_3);
6500 test_kasumi_encryption_test_case_4(void)
6502 return test_kasumi_encryption(&kasumi_test_case_4);
6506 test_kasumi_encryption_test_case_5(void)
6508 return test_kasumi_encryption(&kasumi_test_case_5);
6512 test_kasumi_decryption_test_case_1(void)
6514 return test_kasumi_decryption(&kasumi_test_case_1);
6518 test_kasumi_decryption_test_case_1_oop(void)
6520 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6524 test_kasumi_decryption_test_case_2(void)
6526 return test_kasumi_decryption(&kasumi_test_case_2);
6530 test_kasumi_decryption_test_case_3(void)
6532 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6533 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6534 return TEST_SKIPPED;
6535 return test_kasumi_decryption(&kasumi_test_case_3);
6539 test_kasumi_decryption_test_case_4(void)
6541 return test_kasumi_decryption(&kasumi_test_case_4);
6545 test_kasumi_decryption_test_case_5(void)
6547 return test_kasumi_decryption(&kasumi_test_case_5);
6550 test_snow3g_encryption_test_case_1(void)
6552 return test_snow3g_encryption(&snow3g_test_case_1);
6556 test_snow3g_encryption_test_case_1_oop(void)
6558 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6562 test_snow3g_encryption_test_case_1_oop_sgl(void)
6564 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6569 test_snow3g_encryption_test_case_1_offset_oop(void)
6571 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6575 test_snow3g_encryption_test_case_2(void)
6577 return test_snow3g_encryption(&snow3g_test_case_2);
6581 test_snow3g_encryption_test_case_3(void)
6583 return test_snow3g_encryption(&snow3g_test_case_3);
6587 test_snow3g_encryption_test_case_4(void)
6589 return test_snow3g_encryption(&snow3g_test_case_4);
6593 test_snow3g_encryption_test_case_5(void)
6595 return test_snow3g_encryption(&snow3g_test_case_5);
6599 test_snow3g_decryption_test_case_1(void)
6601 return test_snow3g_decryption(&snow3g_test_case_1);
6605 test_snow3g_decryption_test_case_1_oop(void)
6607 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6611 test_snow3g_decryption_test_case_2(void)
6613 return test_snow3g_decryption(&snow3g_test_case_2);
6617 test_snow3g_decryption_test_case_3(void)
6619 return test_snow3g_decryption(&snow3g_test_case_3);
6623 test_snow3g_decryption_test_case_4(void)
6625 return test_snow3g_decryption(&snow3g_test_case_4);
6629 test_snow3g_decryption_test_case_5(void)
6631 return test_snow3g_decryption(&snow3g_test_case_5);
6635 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6636 * Pattern digest from snow3g_test_data must be allocated as
6637 * 4 last bytes in plaintext.
6640 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6641 struct snow3g_hash_test_data *output)
6643 if ((pattern != NULL) && (output != NULL)) {
6644 output->key.len = pattern->key.len;
6646 memcpy(output->key.data,
6647 pattern->key.data, pattern->key.len);
6649 output->auth_iv.len = pattern->auth_iv.len;
6651 memcpy(output->auth_iv.data,
6652 pattern->auth_iv.data, pattern->auth_iv.len);
6654 output->plaintext.len = pattern->plaintext.len;
6656 memcpy(output->plaintext.data,
6657 pattern->plaintext.data, pattern->plaintext.len >> 3);
6659 output->digest.len = pattern->digest.len;
6661 memcpy(output->digest.data,
6662 &pattern->plaintext.data[pattern->digest.offset_bytes],
6663 pattern->digest.len);
6665 output->validAuthLenInBits.len =
6666 pattern->validAuthLenInBits.len;
6671 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6674 test_snow3g_decryption_with_digest_test_case_1(void)
6676 struct snow3g_hash_test_data snow3g_hash_data;
6677 struct rte_cryptodev_info dev_info;
6678 struct crypto_testsuite_params *ts_params = &testsuite_params;
6680 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6681 uint64_t feat_flags = dev_info.feature_flags;
6683 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6684 printf("Device doesn't support encrypted digest operations.\n");
6685 return TEST_SKIPPED;
6689 * Function prepare data for hash veryfication test case.
6690 * Digest is allocated in 4 last bytes in plaintext, pattern.
6692 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6694 return test_snow3g_decryption(&snow3g_test_case_7) &
6695 test_snow3g_authentication_verify(&snow3g_hash_data);
6699 test_snow3g_cipher_auth_test_case_1(void)
6701 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6705 test_snow3g_auth_cipher_test_case_1(void)
6707 return test_snow3g_auth_cipher(
6708 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6712 test_snow3g_auth_cipher_test_case_2(void)
6714 return test_snow3g_auth_cipher(
6715 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6719 test_snow3g_auth_cipher_test_case_2_oop(void)
6721 return test_snow3g_auth_cipher(
6722 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6726 test_snow3g_auth_cipher_part_digest_enc(void)
6728 return test_snow3g_auth_cipher(
6729 &snow3g_auth_cipher_partial_digest_encryption,
6734 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6736 return test_snow3g_auth_cipher(
6737 &snow3g_auth_cipher_partial_digest_encryption,
6742 test_snow3g_auth_cipher_test_case_3_sgl(void)
6744 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6745 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6746 return TEST_SKIPPED;
6747 return test_snow3g_auth_cipher_sgl(
6748 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6752 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6754 return test_snow3g_auth_cipher_sgl(
6755 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6759 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6761 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6762 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6763 return TEST_SKIPPED;
6764 return test_snow3g_auth_cipher_sgl(
6765 &snow3g_auth_cipher_partial_digest_encryption,
6770 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6772 return test_snow3g_auth_cipher_sgl(
6773 &snow3g_auth_cipher_partial_digest_encryption,
6778 test_snow3g_auth_cipher_verify_test_case_1(void)
6780 return test_snow3g_auth_cipher(
6781 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6785 test_snow3g_auth_cipher_verify_test_case_2(void)
6787 return test_snow3g_auth_cipher(
6788 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6792 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6794 return test_snow3g_auth_cipher(
6795 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6799 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6801 return test_snow3g_auth_cipher(
6802 &snow3g_auth_cipher_partial_digest_encryption,
6807 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6809 return test_snow3g_auth_cipher(
6810 &snow3g_auth_cipher_partial_digest_encryption,
6815 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6817 return test_snow3g_auth_cipher_sgl(
6818 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6822 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6824 return test_snow3g_auth_cipher_sgl(
6825 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6829 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6831 return test_snow3g_auth_cipher_sgl(
6832 &snow3g_auth_cipher_partial_digest_encryption,
6837 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6839 return test_snow3g_auth_cipher_sgl(
6840 &snow3g_auth_cipher_partial_digest_encryption,
6845 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6847 return test_snow3g_auth_cipher(
6848 &snow3g_test_case_7, IN_PLACE, 0);
6852 test_kasumi_auth_cipher_test_case_1(void)
6854 return test_kasumi_auth_cipher(
6855 &kasumi_test_case_3, IN_PLACE, 0);
6859 test_kasumi_auth_cipher_test_case_2(void)
6861 return test_kasumi_auth_cipher(
6862 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6866 test_kasumi_auth_cipher_test_case_2_oop(void)
6868 return test_kasumi_auth_cipher(
6869 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6873 test_kasumi_auth_cipher_test_case_2_sgl(void)
6875 return test_kasumi_auth_cipher_sgl(
6876 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6880 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6882 return test_kasumi_auth_cipher_sgl(
6883 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6887 test_kasumi_auth_cipher_verify_test_case_1(void)
6889 return test_kasumi_auth_cipher(
6890 &kasumi_test_case_3, IN_PLACE, 1);
6894 test_kasumi_auth_cipher_verify_test_case_2(void)
6896 return test_kasumi_auth_cipher(
6897 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6901 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6903 return test_kasumi_auth_cipher(
6904 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6908 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6910 return test_kasumi_auth_cipher_sgl(
6911 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6915 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6917 return test_kasumi_auth_cipher_sgl(
6918 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6922 test_kasumi_cipher_auth_test_case_1(void)
6924 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6928 test_zuc_encryption_test_case_1(void)
6930 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6934 test_zuc_encryption_test_case_2(void)
6936 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6940 test_zuc_encryption_test_case_3(void)
6942 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6946 test_zuc_encryption_test_case_4(void)
6948 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6952 test_zuc_encryption_test_case_5(void)
6954 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6958 test_zuc_encryption_test_case_6_sgl(void)
6960 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6964 test_zuc_hash_generate_test_case_1(void)
6966 return test_zuc_authentication(&zuc_test_case_auth_1b);
6970 test_zuc_hash_generate_test_case_2(void)
6972 return test_zuc_authentication(&zuc_test_case_auth_90b);
6976 test_zuc_hash_generate_test_case_3(void)
6978 return test_zuc_authentication(&zuc_test_case_auth_577b);
6982 test_zuc_hash_generate_test_case_4(void)
6984 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6988 test_zuc_hash_generate_test_case_5(void)
6990 return test_zuc_authentication(&zuc_test_auth_5670b);
6994 test_zuc_hash_generate_test_case_6(void)
6996 return test_zuc_authentication(&zuc_test_case_auth_128b);
7000 test_zuc_hash_generate_test_case_7(void)
7002 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7006 test_zuc_hash_generate_test_case_8(void)
7008 return test_zuc_authentication(&zuc_test_case_auth_584b);
7012 test_zuc_cipher_auth_test_case_1(void)
7014 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7018 test_zuc_cipher_auth_test_case_2(void)
7020 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7024 test_zuc_auth_cipher_test_case_1(void)
7026 return test_zuc_auth_cipher(
7027 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7031 test_zuc_auth_cipher_test_case_1_oop(void)
7033 return test_zuc_auth_cipher(
7034 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7038 test_zuc_auth_cipher_test_case_1_sgl(void)
7040 return test_zuc_auth_cipher_sgl(
7041 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7045 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7047 return test_zuc_auth_cipher_sgl(
7048 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7052 test_zuc_auth_cipher_verify_test_case_1(void)
7054 return test_zuc_auth_cipher(
7055 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7059 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7061 return test_zuc_auth_cipher(
7062 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7066 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7068 return test_zuc_auth_cipher_sgl(
7069 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7073 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7075 return test_zuc_auth_cipher_sgl(
7076 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7080 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7082 uint8_t dev_id = testsuite_params.valid_devs[0];
7084 struct rte_cryptodev_sym_capability_idx cap_idx;
7086 /* Check if device supports particular cipher algorithm */
7087 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7088 cap_idx.algo.cipher = tdata->cipher_algo;
7089 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7090 return TEST_SKIPPED;
7092 /* Check if device supports particular hash algorithm */
7093 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7094 cap_idx.algo.auth = tdata->auth_algo;
7095 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7096 return TEST_SKIPPED;
7102 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7103 uint8_t op_mode, uint8_t verify)
7105 struct crypto_testsuite_params *ts_params = &testsuite_params;
7106 struct crypto_unittest_params *ut_params = &unittest_params;
7110 uint8_t *plaintext = NULL, *ciphertext = NULL;
7111 unsigned int plaintext_pad_len;
7112 unsigned int plaintext_len;
7113 unsigned int ciphertext_pad_len;
7114 unsigned int ciphertext_len;
7116 struct rte_cryptodev_info dev_info;
7117 struct rte_crypto_op *op;
7119 /* Check if device supports particular algorithms separately */
7120 if (test_mixed_check_if_unsupported(tdata))
7121 return TEST_SKIPPED;
7122 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7123 return TEST_SKIPPED;
7125 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7127 uint64_t feat_flags = dev_info.feature_flags;
7129 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7130 printf("Device doesn't support digest encrypted.\n");
7131 return TEST_SKIPPED;
7134 /* Create the session */
7136 retval = create_wireless_algo_cipher_auth_session(
7137 ts_params->valid_devs[0],
7138 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7139 RTE_CRYPTO_AUTH_OP_VERIFY,
7142 tdata->auth_key.data, tdata->auth_key.len,
7143 tdata->auth_iv.len, tdata->digest_enc.len,
7144 tdata->cipher_iv.len);
7146 retval = create_wireless_algo_auth_cipher_session(
7147 ts_params->valid_devs[0],
7148 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7149 RTE_CRYPTO_AUTH_OP_GENERATE,
7152 tdata->auth_key.data, tdata->auth_key.len,
7153 tdata->auth_iv.len, tdata->digest_enc.len,
7154 tdata->cipher_iv.len);
7158 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7159 if (op_mode == OUT_OF_PLACE)
7160 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7162 /* clear mbuf payload */
7163 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7164 rte_pktmbuf_tailroom(ut_params->ibuf));
7165 if (op_mode == OUT_OF_PLACE) {
7167 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7168 rte_pktmbuf_tailroom(ut_params->obuf));
7171 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7172 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7173 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7174 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7177 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7178 ciphertext_pad_len);
7179 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7180 if (op_mode == OUT_OF_PLACE)
7181 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7182 debug_hexdump(stdout, "ciphertext:", ciphertext,
7185 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7187 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7188 if (op_mode == OUT_OF_PLACE)
7189 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7190 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7193 /* Create the operation */
7194 retval = create_wireless_algo_auth_cipher_operation(
7195 tdata->digest_enc.data, tdata->digest_enc.len,
7196 tdata->cipher_iv.data, tdata->cipher_iv.len,
7197 tdata->auth_iv.data, tdata->auth_iv.len,
7198 (tdata->digest_enc.offset == 0 ?
7200 : tdata->digest_enc.offset),
7201 tdata->validCipherLen.len_bits,
7202 tdata->cipher.offset_bits,
7203 tdata->validAuthLen.len_bits,
7204 tdata->auth.offset_bits,
7205 op_mode, 0, verify);
7210 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7212 /* Check if the op failed because the device doesn't */
7213 /* support this particular combination of algorithms */
7214 if (op == NULL && ut_params->op->status ==
7215 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7216 printf("Device doesn't support this mixed combination. "
7218 return TEST_SKIPPED;
7222 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7224 ut_params->obuf = (op_mode == IN_PLACE ?
7225 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7228 if (ut_params->obuf)
7229 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7232 plaintext = ciphertext +
7233 (tdata->cipher.offset_bits >> 3);
7235 debug_hexdump(stdout, "plaintext:", plaintext,
7236 tdata->plaintext.len_bits >> 3);
7237 debug_hexdump(stdout, "plaintext expected:",
7238 tdata->plaintext.data,
7239 tdata->plaintext.len_bits >> 3);
7241 if (ut_params->obuf)
7242 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7245 ciphertext = plaintext;
7247 debug_hexdump(stdout, "ciphertext:", ciphertext,
7249 debug_hexdump(stdout, "ciphertext expected:",
7250 tdata->ciphertext.data,
7251 tdata->ciphertext.len_bits >> 3);
7253 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7254 + (tdata->digest_enc.offset == 0 ?
7255 plaintext_pad_len : tdata->digest_enc.offset);
7257 debug_hexdump(stdout, "digest:", ut_params->digest,
7258 tdata->digest_enc.len);
7259 debug_hexdump(stdout, "digest expected:",
7260 tdata->digest_enc.data,
7261 tdata->digest_enc.len);
7266 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7268 tdata->plaintext.data,
7269 tdata->plaintext.len_bits >> 3,
7270 "Plaintext data not as expected");
7272 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7274 tdata->ciphertext.data,
7275 tdata->validDataLen.len_bits,
7276 "Ciphertext data not as expected");
7278 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7280 tdata->digest_enc.data,
7281 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7282 "Generated auth tag not as expected");
7285 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7286 "crypto op processing failed");
7292 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7293 uint8_t op_mode, uint8_t verify)
7295 struct crypto_testsuite_params *ts_params = &testsuite_params;
7296 struct crypto_unittest_params *ut_params = &unittest_params;
7300 const uint8_t *plaintext = NULL;
7301 const uint8_t *ciphertext = NULL;
7302 const uint8_t *digest = NULL;
7303 unsigned int plaintext_pad_len;
7304 unsigned int plaintext_len;
7305 unsigned int ciphertext_pad_len;
7306 unsigned int ciphertext_len;
7307 uint8_t buffer[10000];
7308 uint8_t digest_buffer[10000];
7310 struct rte_cryptodev_info dev_info;
7311 struct rte_crypto_op *op;
7313 /* Check if device supports particular algorithms */
7314 if (test_mixed_check_if_unsupported(tdata))
7315 return TEST_SKIPPED;
7316 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7317 return TEST_SKIPPED;
7319 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7321 uint64_t feat_flags = dev_info.feature_flags;
7323 if (op_mode == IN_PLACE) {
7324 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7325 printf("Device doesn't support in-place scatter-gather "
7326 "in both input and output mbufs.\n");
7327 return TEST_SKIPPED;
7330 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7331 printf("Device doesn't support out-of-place scatter-gather "
7332 "in both input and output mbufs.\n");
7333 return TEST_SKIPPED;
7335 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7336 printf("Device doesn't support digest encrypted.\n");
7337 return TEST_SKIPPED;
7341 /* Create the session */
7343 retval = create_wireless_algo_cipher_auth_session(
7344 ts_params->valid_devs[0],
7345 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7346 RTE_CRYPTO_AUTH_OP_VERIFY,
7349 tdata->auth_key.data, tdata->auth_key.len,
7350 tdata->auth_iv.len, tdata->digest_enc.len,
7351 tdata->cipher_iv.len);
7353 retval = create_wireless_algo_auth_cipher_session(
7354 ts_params->valid_devs[0],
7355 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7356 RTE_CRYPTO_AUTH_OP_GENERATE,
7359 tdata->auth_key.data, tdata->auth_key.len,
7360 tdata->auth_iv.len, tdata->digest_enc.len,
7361 tdata->cipher_iv.len);
7365 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7366 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7367 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7368 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7370 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7371 ciphertext_pad_len, 15, 0);
7372 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7373 "Failed to allocate input buffer in mempool");
7375 if (op_mode == OUT_OF_PLACE) {
7376 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7377 plaintext_pad_len, 15, 0);
7378 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7379 "Failed to allocate output buffer in mempool");
7383 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7384 tdata->ciphertext.data);
7385 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7386 ciphertext_len, buffer);
7387 debug_hexdump(stdout, "ciphertext:", ciphertext,
7390 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7391 tdata->plaintext.data);
7392 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7393 plaintext_len, buffer);
7394 debug_hexdump(stdout, "plaintext:", plaintext,
7397 memset(buffer, 0, sizeof(buffer));
7399 /* Create the operation */
7400 retval = create_wireless_algo_auth_cipher_operation(
7401 tdata->digest_enc.data, tdata->digest_enc.len,
7402 tdata->cipher_iv.data, tdata->cipher_iv.len,
7403 tdata->auth_iv.data, tdata->auth_iv.len,
7404 (tdata->digest_enc.offset == 0 ?
7406 : tdata->digest_enc.offset),
7407 tdata->validCipherLen.len_bits,
7408 tdata->cipher.offset_bits,
7409 tdata->validAuthLen.len_bits,
7410 tdata->auth.offset_bits,
7411 op_mode, 1, verify);
7416 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7418 /* Check if the op failed because the device doesn't */
7419 /* support this particular combination of algorithms */
7420 if (op == NULL && ut_params->op->status ==
7421 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7422 printf("Device doesn't support this mixed combination. "
7424 return TEST_SKIPPED;
7428 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7430 ut_params->obuf = (op_mode == IN_PLACE ?
7431 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7434 if (ut_params->obuf)
7435 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7436 plaintext_len, buffer);
7438 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7439 plaintext_len, buffer);
7441 debug_hexdump(stdout, "plaintext:", plaintext,
7442 (tdata->plaintext.len_bits >> 3) -
7443 tdata->digest_enc.len);
7444 debug_hexdump(stdout, "plaintext expected:",
7445 tdata->plaintext.data,
7446 (tdata->plaintext.len_bits >> 3) -
7447 tdata->digest_enc.len);
7449 if (ut_params->obuf)
7450 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7451 ciphertext_len, buffer);
7453 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7454 ciphertext_len, buffer);
7456 debug_hexdump(stdout, "ciphertext:", ciphertext,
7458 debug_hexdump(stdout, "ciphertext expected:",
7459 tdata->ciphertext.data,
7460 tdata->ciphertext.len_bits >> 3);
7462 if (ut_params->obuf)
7463 digest = rte_pktmbuf_read(ut_params->obuf,
7464 (tdata->digest_enc.offset == 0 ?
7466 tdata->digest_enc.offset),
7467 tdata->digest_enc.len, digest_buffer);
7469 digest = rte_pktmbuf_read(ut_params->ibuf,
7470 (tdata->digest_enc.offset == 0 ?
7472 tdata->digest_enc.offset),
7473 tdata->digest_enc.len, digest_buffer);
7475 debug_hexdump(stdout, "digest:", digest,
7476 tdata->digest_enc.len);
7477 debug_hexdump(stdout, "digest expected:",
7478 tdata->digest_enc.data, tdata->digest_enc.len);
7483 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7485 tdata->plaintext.data,
7486 tdata->plaintext.len_bits >> 3,
7487 "Plaintext data not as expected");
7489 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7491 tdata->ciphertext.data,
7492 tdata->validDataLen.len_bits,
7493 "Ciphertext data not as expected");
7494 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7496 tdata->digest_enc.data,
7497 tdata->digest_enc.len,
7498 "Generated auth tag not as expected");
7501 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7502 "crypto op processing failed");
7507 /** AUTH AES CMAC + CIPHER AES CTR */
7510 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7512 return test_mixed_auth_cipher(
7513 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7517 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7519 return test_mixed_auth_cipher(
7520 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7524 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7526 return test_mixed_auth_cipher_sgl(
7527 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7531 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7533 return test_mixed_auth_cipher_sgl(
7534 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7538 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7540 return test_mixed_auth_cipher(
7541 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7545 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7547 return test_mixed_auth_cipher(
7548 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7552 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7554 return test_mixed_auth_cipher_sgl(
7555 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7559 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7561 return test_mixed_auth_cipher_sgl(
7562 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7565 /** MIXED AUTH + CIPHER */
7568 test_auth_zuc_cipher_snow_test_case_1(void)
7570 return test_mixed_auth_cipher(
7571 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7575 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7577 return test_mixed_auth_cipher(
7578 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7582 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7584 return test_mixed_auth_cipher(
7585 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7589 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7591 return test_mixed_auth_cipher(
7592 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7596 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7598 return test_mixed_auth_cipher(
7599 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7603 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7605 return test_mixed_auth_cipher(
7606 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7610 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7612 return test_mixed_auth_cipher(
7613 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7617 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7619 return test_mixed_auth_cipher(
7620 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7624 test_auth_snow_cipher_zuc_test_case_1(void)
7626 return test_mixed_auth_cipher(
7627 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7631 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7633 return test_mixed_auth_cipher(
7634 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7638 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7640 return test_mixed_auth_cipher(
7641 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7645 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7647 return test_mixed_auth_cipher(
7648 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7652 test_auth_null_cipher_snow_test_case_1(void)
7654 return test_mixed_auth_cipher(
7655 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7659 test_verify_auth_null_cipher_snow_test_case_1(void)
7661 return test_mixed_auth_cipher(
7662 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7666 test_auth_null_cipher_zuc_test_case_1(void)
7668 return test_mixed_auth_cipher(
7669 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7673 test_verify_auth_null_cipher_zuc_test_case_1(void)
7675 return test_mixed_auth_cipher(
7676 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7680 test_auth_snow_cipher_null_test_case_1(void)
7682 return test_mixed_auth_cipher(
7683 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7687 test_verify_auth_snow_cipher_null_test_case_1(void)
7689 return test_mixed_auth_cipher(
7690 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7694 test_auth_zuc_cipher_null_test_case_1(void)
7696 return test_mixed_auth_cipher(
7697 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7701 test_verify_auth_zuc_cipher_null_test_case_1(void)
7703 return test_mixed_auth_cipher(
7704 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7708 test_auth_null_cipher_aes_ctr_test_case_1(void)
7710 return test_mixed_auth_cipher(
7711 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7715 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7717 return test_mixed_auth_cipher(
7718 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7722 test_auth_aes_cmac_cipher_null_test_case_1(void)
7724 return test_mixed_auth_cipher(
7725 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7729 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7731 return test_mixed_auth_cipher(
7732 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7735 /* ***** AEAD algorithm Tests ***** */
7738 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7739 enum rte_crypto_aead_operation op,
7740 const uint8_t *key, const uint8_t key_len,
7741 const uint16_t aad_len, const uint8_t auth_len,
7744 uint8_t aead_key[key_len];
7746 struct crypto_testsuite_params *ts_params = &testsuite_params;
7747 struct crypto_unittest_params *ut_params = &unittest_params;
7749 memcpy(aead_key, key, key_len);
7751 /* Setup AEAD Parameters */
7752 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7753 ut_params->aead_xform.next = NULL;
7754 ut_params->aead_xform.aead.algo = algo;
7755 ut_params->aead_xform.aead.op = op;
7756 ut_params->aead_xform.aead.key.data = aead_key;
7757 ut_params->aead_xform.aead.key.length = key_len;
7758 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7759 ut_params->aead_xform.aead.iv.length = iv_len;
7760 ut_params->aead_xform.aead.digest_length = auth_len;
7761 ut_params->aead_xform.aead.aad_length = aad_len;
7763 debug_hexdump(stdout, "key:", key, key_len);
7765 /* Create Crypto session*/
7766 ut_params->sess = rte_cryptodev_sym_session_create(
7767 ts_params->session_mpool);
7769 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7770 &ut_params->aead_xform,
7771 ts_params->session_priv_mpool);
7773 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7779 create_aead_xform(struct rte_crypto_op *op,
7780 enum rte_crypto_aead_algorithm algo,
7781 enum rte_crypto_aead_operation aead_op,
7782 uint8_t *key, const uint8_t key_len,
7783 const uint8_t aad_len, const uint8_t auth_len,
7786 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7787 "failed to allocate space for crypto transform");
7789 struct rte_crypto_sym_op *sym_op = op->sym;
7791 /* Setup AEAD Parameters */
7792 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7793 sym_op->xform->next = NULL;
7794 sym_op->xform->aead.algo = algo;
7795 sym_op->xform->aead.op = aead_op;
7796 sym_op->xform->aead.key.data = key;
7797 sym_op->xform->aead.key.length = key_len;
7798 sym_op->xform->aead.iv.offset = IV_OFFSET;
7799 sym_op->xform->aead.iv.length = iv_len;
7800 sym_op->xform->aead.digest_length = auth_len;
7801 sym_op->xform->aead.aad_length = aad_len;
7803 debug_hexdump(stdout, "key:", key, key_len);
7809 create_aead_operation(enum rte_crypto_aead_operation op,
7810 const struct aead_test_data *tdata)
7812 struct crypto_testsuite_params *ts_params = &testsuite_params;
7813 struct crypto_unittest_params *ut_params = &unittest_params;
7815 uint8_t *plaintext, *ciphertext;
7816 unsigned int aad_pad_len, plaintext_pad_len;
7818 /* Generate Crypto op data structure */
7819 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7820 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7821 TEST_ASSERT_NOT_NULL(ut_params->op,
7822 "Failed to allocate symmetric crypto operation struct");
7824 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7826 /* Append aad data */
7827 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7828 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7829 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7831 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7832 "no room to append aad");
7834 sym_op->aead.aad.phys_addr =
7835 rte_pktmbuf_iova(ut_params->ibuf);
7836 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7837 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7838 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7841 /* Append IV at the end of the crypto operation*/
7842 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7843 uint8_t *, IV_OFFSET);
7845 /* Copy IV 1 byte after the IV pointer, according to the API */
7846 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7847 debug_hexdump(stdout, "iv:", iv_ptr,
7850 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7851 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7853 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7854 "no room to append aad");
7856 sym_op->aead.aad.phys_addr =
7857 rte_pktmbuf_iova(ut_params->ibuf);
7858 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7859 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7862 /* Append IV at the end of the crypto operation*/
7863 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7864 uint8_t *, IV_OFFSET);
7866 if (tdata->iv.len == 0) {
7867 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7868 debug_hexdump(stdout, "iv:", iv_ptr,
7871 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7872 debug_hexdump(stdout, "iv:", iv_ptr,
7877 /* Append plaintext/ciphertext */
7878 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7879 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7880 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7882 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7884 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7885 debug_hexdump(stdout, "plaintext:", plaintext,
7886 tdata->plaintext.len);
7888 if (ut_params->obuf) {
7889 ciphertext = (uint8_t *)rte_pktmbuf_append(
7891 plaintext_pad_len + aad_pad_len);
7892 TEST_ASSERT_NOT_NULL(ciphertext,
7893 "no room to append ciphertext");
7895 memset(ciphertext + aad_pad_len, 0,
7896 tdata->ciphertext.len);
7899 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7900 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7902 TEST_ASSERT_NOT_NULL(ciphertext,
7903 "no room to append ciphertext");
7905 memcpy(ciphertext, tdata->ciphertext.data,
7906 tdata->ciphertext.len);
7907 debug_hexdump(stdout, "ciphertext:", ciphertext,
7908 tdata->ciphertext.len);
7910 if (ut_params->obuf) {
7911 plaintext = (uint8_t *)rte_pktmbuf_append(
7913 plaintext_pad_len + aad_pad_len);
7914 TEST_ASSERT_NOT_NULL(plaintext,
7915 "no room to append plaintext");
7917 memset(plaintext + aad_pad_len, 0,
7918 tdata->plaintext.len);
7922 /* Append digest data */
7923 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7924 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7925 ut_params->obuf ? ut_params->obuf :
7927 tdata->auth_tag.len);
7928 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7929 "no room to append digest");
7930 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7931 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7932 ut_params->obuf ? ut_params->obuf :
7937 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7938 ut_params->ibuf, tdata->auth_tag.len);
7939 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7940 "no room to append digest");
7941 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7943 plaintext_pad_len + aad_pad_len);
7945 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7946 tdata->auth_tag.len);
7947 debug_hexdump(stdout, "digest:",
7948 sym_op->aead.digest.data,
7949 tdata->auth_tag.len);
7952 sym_op->aead.data.length = tdata->plaintext.len;
7953 sym_op->aead.data.offset = aad_pad_len;
7959 test_authenticated_encryption(const struct aead_test_data *tdata)
7961 struct crypto_testsuite_params *ts_params = &testsuite_params;
7962 struct crypto_unittest_params *ut_params = &unittest_params;
7965 uint8_t *ciphertext, *auth_tag;
7966 uint16_t plaintext_pad_len;
7968 struct rte_cryptodev_info dev_info;
7970 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7971 uint64_t feat_flags = dev_info.feature_flags;
7973 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7974 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7975 printf("Device doesn't support RAW data-path APIs.\n");
7976 return TEST_SKIPPED;
7979 /* Verify the capabilities */
7980 struct rte_cryptodev_sym_capability_idx cap_idx;
7981 const struct rte_cryptodev_symmetric_capability *capability;
7982 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7983 cap_idx.algo.aead = tdata->algo;
7984 capability = rte_cryptodev_sym_capability_get(
7985 ts_params->valid_devs[0], &cap_idx);
7986 if (capability == NULL)
7987 return TEST_SKIPPED;
7988 if (rte_cryptodev_sym_capability_check_aead(
7989 capability, tdata->key.len, tdata->auth_tag.len,
7990 tdata->aad.len, tdata->iv.len))
7991 return TEST_SKIPPED;
7993 /* Create AEAD session */
7994 retval = create_aead_session(ts_params->valid_devs[0],
7996 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7997 tdata->key.data, tdata->key.len,
7998 tdata->aad.len, tdata->auth_tag.len,
8003 if (tdata->aad.len > MBUF_SIZE) {
8004 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8005 /* Populate full size of add data */
8006 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8007 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8009 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8011 /* clear mbuf payload */
8012 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8013 rte_pktmbuf_tailroom(ut_params->ibuf));
8015 /* Create AEAD operation */
8016 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8020 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8022 ut_params->op->sym->m_src = ut_params->ibuf;
8024 /* Process crypto operation */
8025 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8026 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8027 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8028 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8029 ut_params->op, 0, 0, 0, 0);
8031 TEST_ASSERT_NOT_NULL(
8032 process_crypto_request(ts_params->valid_devs[0],
8033 ut_params->op), "failed to process sym crypto op");
8035 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8036 "crypto op processing failed");
8038 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8040 if (ut_params->op->sym->m_dst) {
8041 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8043 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8044 uint8_t *, plaintext_pad_len);
8046 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8048 ut_params->op->sym->cipher.data.offset);
8049 auth_tag = ciphertext + plaintext_pad_len;
8052 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8053 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8056 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8058 tdata->ciphertext.data,
8059 tdata->ciphertext.len,
8060 "Ciphertext data not as expected");
8062 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8064 tdata->auth_tag.data,
8065 tdata->auth_tag.len,
8066 "Generated auth tag not as expected");
8072 #ifdef RTE_LIB_SECURITY
8074 security_proto_supported(enum rte_security_session_action_type action,
8075 enum rte_security_session_protocol proto)
8077 struct crypto_testsuite_params *ts_params = &testsuite_params;
8079 const struct rte_security_capability *capabilities;
8080 const struct rte_security_capability *capability;
8083 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8084 rte_cryptodev_get_sec_ctx(
8085 ts_params->valid_devs[0]);
8088 capabilities = rte_security_capabilities_get(ctx);
8090 if (capabilities == NULL)
8093 while ((capability = &capabilities[i++])->action !=
8094 RTE_SECURITY_ACTION_TYPE_NONE) {
8095 if (capability->action == action &&
8096 capability->protocol == proto)
8103 /* Basic algorithm run function for async inplace mode.
8104 * Creates a session from input parameters and runs one operation
8105 * on input_vec. Checks the output of the crypto operation against
8108 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8109 enum rte_crypto_auth_operation opa,
8110 const uint8_t *input_vec, unsigned int input_vec_len,
8111 const uint8_t *output_vec,
8112 unsigned int output_vec_len,
8113 enum rte_crypto_cipher_algorithm cipher_alg,
8114 const uint8_t *cipher_key, uint32_t cipher_key_len,
8115 enum rte_crypto_auth_algorithm auth_alg,
8116 const uint8_t *auth_key, uint32_t auth_key_len,
8117 uint8_t bearer, enum rte_security_pdcp_domain domain,
8118 uint8_t packet_direction, uint8_t sn_size,
8119 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8121 struct crypto_testsuite_params *ts_params = &testsuite_params;
8122 struct crypto_unittest_params *ut_params = &unittest_params;
8124 int ret = TEST_SUCCESS;
8125 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8126 rte_cryptodev_get_sec_ctx(
8127 ts_params->valid_devs[0]);
8129 /* Verify the capabilities */
8130 struct rte_security_capability_idx sec_cap_idx;
8132 sec_cap_idx.action = ut_params->type;
8133 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8134 sec_cap_idx.pdcp.domain = domain;
8135 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8136 return TEST_SKIPPED;
8138 /* Generate test mbuf data */
8139 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8141 /* clear mbuf payload */
8142 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8143 rte_pktmbuf_tailroom(ut_params->ibuf));
8145 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8147 memcpy(plaintext, input_vec, input_vec_len);
8149 /* Out of place support */
8152 * For out-op-place we need to alloc another mbuf
8154 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8155 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8158 /* Setup Cipher Parameters */
8159 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8160 ut_params->cipher_xform.cipher.algo = cipher_alg;
8161 ut_params->cipher_xform.cipher.op = opc;
8162 ut_params->cipher_xform.cipher.key.data = cipher_key;
8163 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8164 ut_params->cipher_xform.cipher.iv.length =
8165 packet_direction ? 4 : 0;
8166 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8168 /* Setup HMAC Parameters if ICV header is required */
8169 if (auth_alg != 0) {
8170 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8171 ut_params->auth_xform.next = NULL;
8172 ut_params->auth_xform.auth.algo = auth_alg;
8173 ut_params->auth_xform.auth.op = opa;
8174 ut_params->auth_xform.auth.key.data = auth_key;
8175 ut_params->auth_xform.auth.key.length = auth_key_len;
8177 ut_params->cipher_xform.next = &ut_params->auth_xform;
8179 ut_params->cipher_xform.next = NULL;
8182 struct rte_security_session_conf sess_conf = {
8183 .action_type = ut_params->type,
8184 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8188 .pkt_dir = packet_direction,
8190 .hfn = packet_direction ? 0 : hfn,
8192 * hfn can be set as pdcp_test_hfn[i]
8193 * if hfn_ovrd is not set. Here, PDCP
8194 * packet direction is just used to
8195 * run half of the cases with session
8196 * HFN and other half with per packet
8199 .hfn_threshold = hfn_threshold,
8200 .hfn_ovrd = packet_direction ? 1 : 0,
8201 .sdap_enabled = sdap,
8203 .crypto_xform = &ut_params->cipher_xform
8206 /* Create security session */
8207 ut_params->sec_session = rte_security_session_create(ctx,
8208 &sess_conf, ts_params->session_mpool,
8209 ts_params->session_priv_mpool);
8211 if (!ut_params->sec_session) {
8212 printf("TestCase %s()-%d line %d failed %s: ",
8213 __func__, i, __LINE__, "Failed to allocate session");
8218 /* Generate crypto op data structure */
8219 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8220 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8221 if (!ut_params->op) {
8222 printf("TestCase %s()-%d line %d failed %s: ",
8223 __func__, i, __LINE__,
8224 "Failed to allocate symmetric crypto operation struct");
8229 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8230 uint32_t *, IV_OFFSET);
8231 *per_pkt_hfn = packet_direction ? hfn : 0;
8233 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8235 /* set crypto operation source mbuf */
8236 ut_params->op->sym->m_src = ut_params->ibuf;
8238 ut_params->op->sym->m_dst = ut_params->obuf;
8240 /* Process crypto operation */
8241 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8243 printf("TestCase %s()-%d line %d failed %s: ",
8244 __func__, i, __LINE__,
8245 "failed to process sym crypto op");
8250 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8251 printf("TestCase %s()-%d line %d failed %s: ",
8252 __func__, i, __LINE__, "crypto op processing failed");
8258 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8261 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8265 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8266 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8267 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8268 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8274 rte_crypto_op_free(ut_params->op);
8275 ut_params->op = NULL;
8277 if (ut_params->sec_session)
8278 rte_security_session_destroy(ctx, ut_params->sec_session);
8279 ut_params->sec_session = NULL;
8281 rte_pktmbuf_free(ut_params->ibuf);
8282 ut_params->ibuf = NULL;
8284 rte_pktmbuf_free(ut_params->obuf);
8285 ut_params->obuf = NULL;
8292 test_pdcp_proto_SGL(int i, int oop,
8293 enum rte_crypto_cipher_operation opc,
8294 enum rte_crypto_auth_operation opa,
8296 unsigned int input_vec_len,
8297 uint8_t *output_vec,
8298 unsigned int output_vec_len,
8300 uint32_t fragsz_oop)
8302 struct crypto_testsuite_params *ts_params = &testsuite_params;
8303 struct crypto_unittest_params *ut_params = &unittest_params;
8305 struct rte_mbuf *buf, *buf_oop = NULL;
8306 int ret = TEST_SUCCESS;
8310 unsigned int trn_data = 0;
8311 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8312 rte_cryptodev_get_sec_ctx(
8313 ts_params->valid_devs[0]);
8315 /* Verify the capabilities */
8316 struct rte_security_capability_idx sec_cap_idx;
8318 sec_cap_idx.action = ut_params->type;
8319 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8320 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8321 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8322 return TEST_SKIPPED;
8324 if (fragsz > input_vec_len)
8325 fragsz = input_vec_len;
8327 uint16_t plaintext_len = fragsz;
8328 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8330 if (fragsz_oop > output_vec_len)
8331 frag_size_oop = output_vec_len;
8334 if (input_vec_len % fragsz != 0) {
8335 if (input_vec_len / fragsz + 1 > 16)
8337 } else if (input_vec_len / fragsz > 16)
8340 /* Out of place support */
8343 * For out-op-place we need to alloc another mbuf
8345 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8346 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8347 buf_oop = ut_params->obuf;
8350 /* Generate test mbuf data */
8351 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8353 /* clear mbuf payload */
8354 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8355 rte_pktmbuf_tailroom(ut_params->ibuf));
8357 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8359 memcpy(plaintext, input_vec, plaintext_len);
8360 trn_data += plaintext_len;
8362 buf = ut_params->ibuf;
8365 * Loop until no more fragments
8368 while (trn_data < input_vec_len) {
8370 to_trn = (input_vec_len - trn_data < fragsz) ?
8371 (input_vec_len - trn_data) : fragsz;
8373 to_trn_tbl[ecx++] = to_trn;
8375 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8378 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8379 rte_pktmbuf_tailroom(buf));
8382 if (oop && !fragsz_oop) {
8384 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8385 buf_oop = buf_oop->next;
8386 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8387 0, rte_pktmbuf_tailroom(buf_oop));
8388 rte_pktmbuf_append(buf_oop, to_trn);
8391 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8394 memcpy(plaintext, input_vec + trn_data, to_trn);
8398 ut_params->ibuf->nb_segs = segs;
8401 if (fragsz_oop && oop) {
8405 trn_data = frag_size_oop;
8406 while (trn_data < output_vec_len) {
8409 (output_vec_len - trn_data <
8411 (output_vec_len - trn_data) :
8414 to_trn_tbl[ecx++] = to_trn;
8417 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8418 buf_oop = buf_oop->next;
8419 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8420 0, rte_pktmbuf_tailroom(buf_oop));
8421 rte_pktmbuf_append(buf_oop, to_trn);
8425 ut_params->obuf->nb_segs = segs;
8428 /* Setup Cipher Parameters */
8429 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8430 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8431 ut_params->cipher_xform.cipher.op = opc;
8432 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8433 ut_params->cipher_xform.cipher.key.length =
8434 pdcp_test_params[i].cipher_key_len;
8435 ut_params->cipher_xform.cipher.iv.length = 0;
8437 /* Setup HMAC Parameters if ICV header is required */
8438 if (pdcp_test_params[i].auth_alg != 0) {
8439 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8440 ut_params->auth_xform.next = NULL;
8441 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8442 ut_params->auth_xform.auth.op = opa;
8443 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8444 ut_params->auth_xform.auth.key.length =
8445 pdcp_test_params[i].auth_key_len;
8447 ut_params->cipher_xform.next = &ut_params->auth_xform;
8449 ut_params->cipher_xform.next = NULL;
8452 struct rte_security_session_conf sess_conf = {
8453 .action_type = ut_params->type,
8454 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8456 .bearer = pdcp_test_bearer[i],
8457 .domain = pdcp_test_params[i].domain,
8458 .pkt_dir = pdcp_test_packet_direction[i],
8459 .sn_size = pdcp_test_data_sn_size[i],
8460 .hfn = pdcp_test_hfn[i],
8461 .hfn_threshold = pdcp_test_hfn_threshold[i],
8464 .crypto_xform = &ut_params->cipher_xform
8467 /* Create security session */
8468 ut_params->sec_session = rte_security_session_create(ctx,
8469 &sess_conf, ts_params->session_mpool,
8470 ts_params->session_priv_mpool);
8472 if (!ut_params->sec_session) {
8473 printf("TestCase %s()-%d line %d failed %s: ",
8474 __func__, i, __LINE__, "Failed to allocate session");
8479 /* Generate crypto op data structure */
8480 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8481 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8482 if (!ut_params->op) {
8483 printf("TestCase %s()-%d line %d failed %s: ",
8484 __func__, i, __LINE__,
8485 "Failed to allocate symmetric crypto operation struct");
8490 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8492 /* set crypto operation source mbuf */
8493 ut_params->op->sym->m_src = ut_params->ibuf;
8495 ut_params->op->sym->m_dst = ut_params->obuf;
8497 /* Process crypto operation */
8498 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8500 printf("TestCase %s()-%d line %d failed %s: ",
8501 __func__, i, __LINE__,
8502 "failed to process sym crypto op");
8507 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8508 printf("TestCase %s()-%d line %d failed %s: ",
8509 __func__, i, __LINE__, "crypto op processing failed");
8515 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8518 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8522 fragsz = frag_size_oop;
8523 if (memcmp(ciphertext, output_vec, fragsz)) {
8524 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8525 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8526 rte_hexdump(stdout, "reference", output_vec, fragsz);
8531 buf = ut_params->op->sym->m_src->next;
8533 buf = ut_params->op->sym->m_dst->next;
8535 unsigned int off = fragsz;
8539 ciphertext = rte_pktmbuf_mtod(buf,
8541 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8542 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8543 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8544 rte_hexdump(stdout, "reference", output_vec + off,
8549 off += to_trn_tbl[ecx++];
8553 rte_crypto_op_free(ut_params->op);
8554 ut_params->op = NULL;
8556 if (ut_params->sec_session)
8557 rte_security_session_destroy(ctx, ut_params->sec_session);
8558 ut_params->sec_session = NULL;
8560 rte_pktmbuf_free(ut_params->ibuf);
8561 ut_params->ibuf = NULL;
8563 rte_pktmbuf_free(ut_params->obuf);
8564 ut_params->obuf = NULL;
8571 test_pdcp_proto_cplane_encap(int i)
8573 return test_pdcp_proto(
8574 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8575 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8576 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8577 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8578 pdcp_test_params[i].cipher_key_len,
8579 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8580 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8581 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8582 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8583 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8587 test_pdcp_proto_uplane_encap(int i)
8589 return test_pdcp_proto(
8590 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8591 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8592 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8593 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8594 pdcp_test_params[i].cipher_key_len,
8595 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8596 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8597 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8598 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8599 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8603 test_pdcp_proto_uplane_encap_with_int(int i)
8605 return test_pdcp_proto(
8606 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8607 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8608 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8609 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8610 pdcp_test_params[i].cipher_key_len,
8611 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8612 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8613 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8614 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8615 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8619 test_pdcp_proto_cplane_decap(int i)
8621 return test_pdcp_proto(
8622 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8623 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8624 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8625 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8626 pdcp_test_params[i].cipher_key_len,
8627 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8628 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8629 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8630 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8631 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8635 test_pdcp_proto_uplane_decap(int i)
8637 return test_pdcp_proto(
8638 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8639 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8640 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8641 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8642 pdcp_test_params[i].cipher_key_len,
8643 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8644 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8645 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8646 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8647 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8651 test_pdcp_proto_uplane_decap_with_int(int i)
8653 return test_pdcp_proto(
8654 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8655 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8656 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8657 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8658 pdcp_test_params[i].cipher_key_len,
8659 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8660 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8661 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8662 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8663 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8667 test_PDCP_PROTO_SGL_in_place_32B(void)
8669 /* i can be used for running any PDCP case
8670 * In this case it is uplane 12-bit AES-SNOW DL encap
8672 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8673 return test_pdcp_proto_SGL(i, IN_PLACE,
8674 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8675 RTE_CRYPTO_AUTH_OP_GENERATE,
8676 pdcp_test_data_in[i],
8677 pdcp_test_data_in_len[i],
8678 pdcp_test_data_out[i],
8679 pdcp_test_data_in_len[i]+4,
8683 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8685 /* i can be used for running any PDCP case
8686 * In this case it is uplane 18-bit NULL-NULL DL encap
8688 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8689 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8690 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8691 RTE_CRYPTO_AUTH_OP_GENERATE,
8692 pdcp_test_data_in[i],
8693 pdcp_test_data_in_len[i],
8694 pdcp_test_data_out[i],
8695 pdcp_test_data_in_len[i]+4,
8699 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8701 /* i can be used for running any PDCP case
8702 * In this case it is uplane 18-bit AES DL encap
8704 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8706 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8707 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8708 RTE_CRYPTO_AUTH_OP_GENERATE,
8709 pdcp_test_data_in[i],
8710 pdcp_test_data_in_len[i],
8711 pdcp_test_data_out[i],
8712 pdcp_test_data_in_len[i],
8716 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8718 /* i can be used for running any PDCP case
8719 * In this case it is cplane 12-bit AES-ZUC DL encap
8721 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8722 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8723 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8724 RTE_CRYPTO_AUTH_OP_GENERATE,
8725 pdcp_test_data_in[i],
8726 pdcp_test_data_in_len[i],
8727 pdcp_test_data_out[i],
8728 pdcp_test_data_in_len[i]+4,
8733 test_PDCP_SDAP_PROTO_encap_all(void)
8735 int i = 0, size = 0;
8736 int err, all_err = TEST_SUCCESS;
8737 const struct pdcp_sdap_test *cur_test;
8739 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8741 for (i = 0; i < size; i++) {
8742 cur_test = &list_pdcp_sdap_tests[i];
8743 err = test_pdcp_proto(
8744 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8745 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8746 cur_test->in_len, cur_test->data_out,
8747 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8748 cur_test->param.cipher_alg, cur_test->cipher_key,
8749 cur_test->param.cipher_key_len,
8750 cur_test->param.auth_alg,
8751 cur_test->auth_key, cur_test->param.auth_key_len,
8752 cur_test->bearer, cur_test->param.domain,
8753 cur_test->packet_direction, cur_test->sn_size,
8755 cur_test->hfn_threshold, SDAP_ENABLED);
8757 printf("\t%d) %s: Encapsulation failed\n",
8759 cur_test->param.name);
8762 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8763 cur_test->param.name);
8769 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8771 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8775 test_PDCP_SDAP_PROTO_decap_all(void)
8777 int i = 0, size = 0;
8778 int err, all_err = TEST_SUCCESS;
8779 const struct pdcp_sdap_test *cur_test;
8781 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8783 for (i = 0; i < size; i++) {
8784 cur_test = &list_pdcp_sdap_tests[i];
8785 err = test_pdcp_proto(
8786 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8787 RTE_CRYPTO_AUTH_OP_VERIFY,
8789 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8790 cur_test->data_in, cur_test->in_len,
8791 cur_test->param.cipher_alg,
8792 cur_test->cipher_key, cur_test->param.cipher_key_len,
8793 cur_test->param.auth_alg, cur_test->auth_key,
8794 cur_test->param.auth_key_len, cur_test->bearer,
8795 cur_test->param.domain, cur_test->packet_direction,
8796 cur_test->sn_size, cur_test->hfn,
8797 cur_test->hfn_threshold, SDAP_ENABLED);
8799 printf("\t%d) %s: Decapsulation failed\n",
8801 cur_test->param.name);
8804 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8805 cur_test->param.name);
8811 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8813 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8817 test_PDCP_PROTO_all(void)
8819 struct crypto_testsuite_params *ts_params = &testsuite_params;
8820 struct crypto_unittest_params *ut_params = &unittest_params;
8821 struct rte_cryptodev_info dev_info;
8824 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8825 uint64_t feat_flags = dev_info.feature_flags;
8827 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8828 return TEST_SKIPPED;
8830 /* Set action type */
8831 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8832 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8835 if (security_proto_supported(ut_params->type,
8836 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8837 return TEST_SKIPPED;
8839 status = test_PDCP_PROTO_cplane_encap_all();
8840 status += test_PDCP_PROTO_cplane_decap_all();
8841 status += test_PDCP_PROTO_uplane_encap_all();
8842 status += test_PDCP_PROTO_uplane_decap_all();
8843 status += test_PDCP_PROTO_SGL_in_place_32B();
8844 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8845 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8846 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8847 status += test_PDCP_SDAP_PROTO_encap_all();
8848 status += test_PDCP_SDAP_PROTO_decap_all();
8853 return TEST_SUCCESS;
8857 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8859 struct crypto_testsuite_params *ts_params = &testsuite_params;
8860 struct crypto_unittest_params *ut_params = &unittest_params;
8861 uint8_t *plaintext, *ciphertext;
8863 int32_t cipher_len, crc_len;
8864 uint32_t crc_data_len;
8865 int ret = TEST_SUCCESS;
8867 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8868 rte_cryptodev_get_sec_ctx(
8869 ts_params->valid_devs[0]);
8871 /* Verify the capabilities */
8872 struct rte_security_capability_idx sec_cap_idx;
8873 const struct rte_security_capability *sec_cap;
8874 const struct rte_cryptodev_capabilities *crypto_cap;
8875 const struct rte_cryptodev_symmetric_capability *sym_cap;
8878 sec_cap_idx.action = ut_params->type;
8879 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8880 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8882 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8883 if (sec_cap == NULL)
8884 return TEST_SKIPPED;
8886 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8887 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8888 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8889 crypto_cap->sym.xform_type ==
8890 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8891 crypto_cap->sym.cipher.algo ==
8892 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8893 sym_cap = &crypto_cap->sym;
8894 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8901 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8902 return TEST_SKIPPED;
8904 /* Setup source mbuf payload */
8905 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8906 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8907 rte_pktmbuf_tailroom(ut_params->ibuf));
8909 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8910 d_td->ciphertext.len);
8912 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8914 /* Setup cipher session parameters */
8915 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8916 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8917 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8918 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8919 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8920 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8921 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8922 ut_params->cipher_xform.next = NULL;
8924 /* Setup DOCSIS session parameters */
8925 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8927 struct rte_security_session_conf sess_conf = {
8928 .action_type = ut_params->type,
8929 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8930 .docsis = ut_params->docsis_xform,
8931 .crypto_xform = &ut_params->cipher_xform,
8934 /* Create security session */
8935 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8936 ts_params->session_mpool,
8937 ts_params->session_priv_mpool);
8939 if (!ut_params->sec_session) {
8940 printf("TestCase %s(%d) line %d: %s\n",
8941 __func__, i, __LINE__, "failed to allocate session");
8946 /* Generate crypto op data structure */
8947 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8948 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8949 if (!ut_params->op) {
8950 printf("TestCase %s(%d) line %d: %s\n",
8951 __func__, i, __LINE__,
8952 "failed to allocate symmetric crypto operation");
8957 /* Setup CRC operation parameters */
8958 crc_len = d_td->ciphertext.no_crc == false ?
8959 (d_td->ciphertext.len -
8960 d_td->ciphertext.crc_offset -
8961 RTE_ETHER_CRC_LEN) :
8963 crc_len = crc_len > 0 ? crc_len : 0;
8964 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8965 ut_params->op->sym->auth.data.length = crc_len;
8966 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8968 /* Setup cipher operation parameters */
8969 cipher_len = d_td->ciphertext.no_cipher == false ?
8970 (d_td->ciphertext.len -
8971 d_td->ciphertext.cipher_offset) :
8973 cipher_len = cipher_len > 0 ? cipher_len : 0;
8974 ut_params->op->sym->cipher.data.length = cipher_len;
8975 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8977 /* Setup cipher IV */
8978 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8979 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8981 /* Attach session to operation */
8982 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8984 /* Set crypto operation mbufs */
8985 ut_params->op->sym->m_src = ut_params->ibuf;
8986 ut_params->op->sym->m_dst = NULL;
8988 /* Process crypto operation */
8989 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8991 printf("TestCase %s(%d) line %d: %s\n",
8992 __func__, i, __LINE__,
8993 "failed to process security crypto op");
8998 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8999 printf("TestCase %s(%d) line %d: %s\n",
9000 __func__, i, __LINE__, "crypto op processing failed");
9005 /* Validate plaintext */
9006 plaintext = ciphertext;
9008 if (memcmp(plaintext, d_td->plaintext.data,
9009 d_td->plaintext.len - crc_data_len)) {
9010 printf("TestCase %s(%d) line %d: %s\n",
9011 __func__, i, __LINE__, "plaintext not as expected\n");
9012 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9013 d_td->plaintext.len);
9014 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9020 rte_crypto_op_free(ut_params->op);
9021 ut_params->op = NULL;
9023 if (ut_params->sec_session)
9024 rte_security_session_destroy(ctx, ut_params->sec_session);
9025 ut_params->sec_session = NULL;
9027 rte_pktmbuf_free(ut_params->ibuf);
9028 ut_params->ibuf = NULL;
9034 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9036 struct crypto_testsuite_params *ts_params = &testsuite_params;
9037 struct crypto_unittest_params *ut_params = &unittest_params;
9038 uint8_t *plaintext, *ciphertext;
9040 int32_t cipher_len, crc_len;
9041 int ret = TEST_SUCCESS;
9043 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9044 rte_cryptodev_get_sec_ctx(
9045 ts_params->valid_devs[0]);
9047 /* Verify the capabilities */
9048 struct rte_security_capability_idx sec_cap_idx;
9049 const struct rte_security_capability *sec_cap;
9050 const struct rte_cryptodev_capabilities *crypto_cap;
9051 const struct rte_cryptodev_symmetric_capability *sym_cap;
9054 sec_cap_idx.action = ut_params->type;
9055 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9056 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9058 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9059 if (sec_cap == NULL)
9060 return TEST_SKIPPED;
9062 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9063 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9064 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9065 crypto_cap->sym.xform_type ==
9066 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9067 crypto_cap->sym.cipher.algo ==
9068 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9069 sym_cap = &crypto_cap->sym;
9070 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9077 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9078 return TEST_SKIPPED;
9080 /* Setup source mbuf payload */
9081 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9082 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9083 rte_pktmbuf_tailroom(ut_params->ibuf));
9085 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9086 d_td->plaintext.len);
9088 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9090 /* Setup cipher session parameters */
9091 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9092 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9093 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9094 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9095 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9096 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9097 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9098 ut_params->cipher_xform.next = NULL;
9100 /* Setup DOCSIS session parameters */
9101 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9103 struct rte_security_session_conf sess_conf = {
9104 .action_type = ut_params->type,
9105 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9106 .docsis = ut_params->docsis_xform,
9107 .crypto_xform = &ut_params->cipher_xform,
9110 /* Create security session */
9111 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9112 ts_params->session_mpool,
9113 ts_params->session_priv_mpool);
9115 if (!ut_params->sec_session) {
9116 printf("TestCase %s(%d) line %d: %s\n",
9117 __func__, i, __LINE__, "failed to allocate session");
9122 /* Generate crypto op data structure */
9123 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9124 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9125 if (!ut_params->op) {
9126 printf("TestCase %s(%d) line %d: %s\n",
9127 __func__, i, __LINE__,
9128 "failed to allocate security crypto operation");
9133 /* Setup CRC operation parameters */
9134 crc_len = d_td->plaintext.no_crc == false ?
9135 (d_td->plaintext.len -
9136 d_td->plaintext.crc_offset -
9137 RTE_ETHER_CRC_LEN) :
9139 crc_len = crc_len > 0 ? crc_len : 0;
9140 ut_params->op->sym->auth.data.length = crc_len;
9141 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9143 /* Setup cipher operation parameters */
9144 cipher_len = d_td->plaintext.no_cipher == false ?
9145 (d_td->plaintext.len -
9146 d_td->plaintext.cipher_offset) :
9148 cipher_len = cipher_len > 0 ? cipher_len : 0;
9149 ut_params->op->sym->cipher.data.length = cipher_len;
9150 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9152 /* Setup cipher IV */
9153 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9154 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9156 /* Attach session to operation */
9157 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9159 /* Set crypto operation mbufs */
9160 ut_params->op->sym->m_src = ut_params->ibuf;
9161 ut_params->op->sym->m_dst = NULL;
9163 /* Process crypto operation */
9164 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9166 printf("TestCase %s(%d) line %d: %s\n",
9167 __func__, i, __LINE__,
9168 "failed to process security crypto op");
9173 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9174 printf("TestCase %s(%d) line %d: %s\n",
9175 __func__, i, __LINE__, "crypto op processing failed");
9180 /* Validate ciphertext */
9181 ciphertext = plaintext;
9183 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9184 printf("TestCase %s(%d) line %d: %s\n",
9185 __func__, i, __LINE__, "ciphertext not as expected\n");
9186 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9187 d_td->ciphertext.len);
9188 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9194 rte_crypto_op_free(ut_params->op);
9195 ut_params->op = NULL;
9197 if (ut_params->sec_session)
9198 rte_security_session_destroy(ctx, ut_params->sec_session);
9199 ut_params->sec_session = NULL;
9201 rte_pktmbuf_free(ut_params->ibuf);
9202 ut_params->ibuf = NULL;
9207 #define TEST_DOCSIS_COUNT(func) do { \
9209 if (ret == TEST_SUCCESS) { \
9210 printf("\t%2d)", n++); \
9211 printf("+++++ PASSED:" #func"\n"); \
9213 } else if (ret == TEST_SKIPPED) { \
9214 printf("\t%2d)", n++); \
9215 printf("~~~~~ SKIPPED:" #func"\n"); \
9218 printf("\t%2d)", n++); \
9219 printf("----- FAILED:" #func"\n"); \
9225 test_DOCSIS_PROTO_uplink_all(void)
9227 int p = 0, s = 0, f = 0, n = 0;
9229 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9230 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9231 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9232 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9233 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9234 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9235 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9236 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9237 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9238 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9239 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9240 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9241 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9242 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9243 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9244 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9245 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9246 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9247 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9248 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9249 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9250 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9251 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9252 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9253 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9254 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9257 printf("## %s: %d passed out of %d (%d skipped)\n",
9264 test_DOCSIS_PROTO_downlink_all(void)
9266 int p = 0, s = 0, f = 0, n = 0;
9268 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9269 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9270 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9271 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9272 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9273 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9274 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9275 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9276 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9277 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9278 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9279 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9280 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9281 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9282 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9283 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9284 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9285 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9286 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9287 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9288 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9289 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9290 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9291 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9292 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9293 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9296 printf("## %s: %d passed out of %d (%d skipped)\n",
9303 test_DOCSIS_PROTO_all(void)
9305 struct crypto_testsuite_params *ts_params = &testsuite_params;
9306 struct crypto_unittest_params *ut_params = &unittest_params;
9307 struct rte_cryptodev_info dev_info;
9310 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9311 uint64_t feat_flags = dev_info.feature_flags;
9313 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9314 return TEST_SKIPPED;
9316 /* Set action type */
9317 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9318 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9321 if (security_proto_supported(ut_params->type,
9322 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9323 return TEST_SKIPPED;
9325 status = test_DOCSIS_PROTO_uplink_all();
9326 status += test_DOCSIS_PROTO_downlink_all();
9331 return TEST_SUCCESS;
9336 test_AES_GCM_authenticated_encryption_test_case_1(void)
9338 return test_authenticated_encryption(&gcm_test_case_1);
9342 test_AES_GCM_authenticated_encryption_test_case_2(void)
9344 return test_authenticated_encryption(&gcm_test_case_2);
9348 test_AES_GCM_authenticated_encryption_test_case_3(void)
9350 return test_authenticated_encryption(&gcm_test_case_3);
9354 test_AES_GCM_authenticated_encryption_test_case_4(void)
9356 return test_authenticated_encryption(&gcm_test_case_4);
9360 test_AES_GCM_authenticated_encryption_test_case_5(void)
9362 return test_authenticated_encryption(&gcm_test_case_5);
9366 test_AES_GCM_authenticated_encryption_test_case_6(void)
9368 return test_authenticated_encryption(&gcm_test_case_6);
9372 test_AES_GCM_authenticated_encryption_test_case_7(void)
9374 return test_authenticated_encryption(&gcm_test_case_7);
9378 test_AES_GCM_authenticated_encryption_test_case_8(void)
9380 return test_authenticated_encryption(&gcm_test_case_8);
9384 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9386 return test_authenticated_encryption(&gcm_J0_test_case_1);
9390 test_AES_GCM_auth_encryption_test_case_192_1(void)
9392 return test_authenticated_encryption(&gcm_test_case_192_1);
9396 test_AES_GCM_auth_encryption_test_case_192_2(void)
9398 return test_authenticated_encryption(&gcm_test_case_192_2);
9402 test_AES_GCM_auth_encryption_test_case_192_3(void)
9404 return test_authenticated_encryption(&gcm_test_case_192_3);
9408 test_AES_GCM_auth_encryption_test_case_192_4(void)
9410 return test_authenticated_encryption(&gcm_test_case_192_4);
9414 test_AES_GCM_auth_encryption_test_case_192_5(void)
9416 return test_authenticated_encryption(&gcm_test_case_192_5);
9420 test_AES_GCM_auth_encryption_test_case_192_6(void)
9422 return test_authenticated_encryption(&gcm_test_case_192_6);
9426 test_AES_GCM_auth_encryption_test_case_192_7(void)
9428 return test_authenticated_encryption(&gcm_test_case_192_7);
9432 test_AES_GCM_auth_encryption_test_case_256_1(void)
9434 return test_authenticated_encryption(&gcm_test_case_256_1);
9438 test_AES_GCM_auth_encryption_test_case_256_2(void)
9440 return test_authenticated_encryption(&gcm_test_case_256_2);
9444 test_AES_GCM_auth_encryption_test_case_256_3(void)
9446 return test_authenticated_encryption(&gcm_test_case_256_3);
9450 test_AES_GCM_auth_encryption_test_case_256_4(void)
9452 return test_authenticated_encryption(&gcm_test_case_256_4);
9456 test_AES_GCM_auth_encryption_test_case_256_5(void)
9458 return test_authenticated_encryption(&gcm_test_case_256_5);
9462 test_AES_GCM_auth_encryption_test_case_256_6(void)
9464 return test_authenticated_encryption(&gcm_test_case_256_6);
9468 test_AES_GCM_auth_encryption_test_case_256_7(void)
9470 return test_authenticated_encryption(&gcm_test_case_256_7);
9474 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9476 return test_authenticated_encryption(&gcm_test_case_aad_1);
9480 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9482 return test_authenticated_encryption(&gcm_test_case_aad_2);
9486 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9488 struct aead_test_data tdata;
9491 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9492 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9493 tdata.iv.data[0] += 1;
9494 res = test_authenticated_encryption(&tdata);
9495 if (res == TEST_SKIPPED)
9497 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9498 return TEST_SUCCESS;
9502 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9504 struct aead_test_data tdata;
9507 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9508 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9509 tdata.plaintext.data[0] += 1;
9510 res = test_authenticated_encryption(&tdata);
9511 if (res == TEST_SKIPPED)
9513 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9514 return TEST_SUCCESS;
9518 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9520 struct aead_test_data tdata;
9523 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9524 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9525 tdata.ciphertext.data[0] += 1;
9526 res = test_authenticated_encryption(&tdata);
9527 if (res == TEST_SKIPPED)
9529 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9530 return TEST_SUCCESS;
9534 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9536 struct aead_test_data tdata;
9539 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9540 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9542 res = test_authenticated_encryption(&tdata);
9543 if (res == TEST_SKIPPED)
9545 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9546 return TEST_SUCCESS;
9550 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9552 struct aead_test_data tdata;
9553 uint8_t aad[gcm_test_case_7.aad.len];
9556 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9557 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9558 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9560 tdata.aad.data = aad;
9561 res = test_authenticated_encryption(&tdata);
9562 if (res == TEST_SKIPPED)
9564 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9565 return TEST_SUCCESS;
9569 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9571 struct aead_test_data tdata;
9574 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9575 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9576 tdata.auth_tag.data[0] += 1;
9577 res = test_authenticated_encryption(&tdata);
9578 if (res == TEST_SKIPPED)
9580 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9581 return TEST_SUCCESS;
9585 test_authenticated_decryption(const struct aead_test_data *tdata)
9587 struct crypto_testsuite_params *ts_params = &testsuite_params;
9588 struct crypto_unittest_params *ut_params = &unittest_params;
9593 struct rte_cryptodev_info dev_info;
9595 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9596 uint64_t feat_flags = dev_info.feature_flags;
9598 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9599 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9600 printf("Device doesn't support RAW data-path APIs.\n");
9601 return TEST_SKIPPED;
9604 /* Verify the capabilities */
9605 struct rte_cryptodev_sym_capability_idx cap_idx;
9606 const struct rte_cryptodev_symmetric_capability *capability;
9607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9608 cap_idx.algo.aead = tdata->algo;
9609 capability = rte_cryptodev_sym_capability_get(
9610 ts_params->valid_devs[0], &cap_idx);
9611 if (capability == NULL)
9612 return TEST_SKIPPED;
9613 if (rte_cryptodev_sym_capability_check_aead(
9614 capability, tdata->key.len, tdata->auth_tag.len,
9615 tdata->aad.len, tdata->iv.len))
9616 return TEST_SKIPPED;
9618 /* Create AEAD session */
9619 retval = create_aead_session(ts_params->valid_devs[0],
9621 RTE_CRYPTO_AEAD_OP_DECRYPT,
9622 tdata->key.data, tdata->key.len,
9623 tdata->aad.len, tdata->auth_tag.len,
9628 /* alloc mbuf and set payload */
9629 if (tdata->aad.len > MBUF_SIZE) {
9630 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9631 /* Populate full size of add data */
9632 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9633 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9635 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9637 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9638 rte_pktmbuf_tailroom(ut_params->ibuf));
9640 /* Create AEAD operation */
9641 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9645 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9647 ut_params->op->sym->m_src = ut_params->ibuf;
9649 /* Process crypto operation */
9650 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9651 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9652 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9653 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9654 ut_params->op, 0, 0, 0, 0);
9656 TEST_ASSERT_NOT_NULL(
9657 process_crypto_request(ts_params->valid_devs[0],
9658 ut_params->op), "failed to process sym crypto op");
9660 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9661 "crypto op processing failed");
9663 if (ut_params->op->sym->m_dst)
9664 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9667 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9669 ut_params->op->sym->cipher.data.offset);
9671 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9674 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9676 tdata->plaintext.data,
9677 tdata->plaintext.len,
9678 "Plaintext data not as expected");
9680 TEST_ASSERT_EQUAL(ut_params->op->status,
9681 RTE_CRYPTO_OP_STATUS_SUCCESS,
9682 "Authentication failed");
9688 test_AES_GCM_authenticated_decryption_test_case_1(void)
9690 return test_authenticated_decryption(&gcm_test_case_1);
9694 test_AES_GCM_authenticated_decryption_test_case_2(void)
9696 return test_authenticated_decryption(&gcm_test_case_2);
9700 test_AES_GCM_authenticated_decryption_test_case_3(void)
9702 return test_authenticated_decryption(&gcm_test_case_3);
9706 test_AES_GCM_authenticated_decryption_test_case_4(void)
9708 return test_authenticated_decryption(&gcm_test_case_4);
9712 test_AES_GCM_authenticated_decryption_test_case_5(void)
9714 return test_authenticated_decryption(&gcm_test_case_5);
9718 test_AES_GCM_authenticated_decryption_test_case_6(void)
9720 return test_authenticated_decryption(&gcm_test_case_6);
9724 test_AES_GCM_authenticated_decryption_test_case_7(void)
9726 return test_authenticated_decryption(&gcm_test_case_7);
9730 test_AES_GCM_authenticated_decryption_test_case_8(void)
9732 return test_authenticated_decryption(&gcm_test_case_8);
9736 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9738 return test_authenticated_decryption(&gcm_J0_test_case_1);
9742 test_AES_GCM_auth_decryption_test_case_192_1(void)
9744 return test_authenticated_decryption(&gcm_test_case_192_1);
9748 test_AES_GCM_auth_decryption_test_case_192_2(void)
9750 return test_authenticated_decryption(&gcm_test_case_192_2);
9754 test_AES_GCM_auth_decryption_test_case_192_3(void)
9756 return test_authenticated_decryption(&gcm_test_case_192_3);
9760 test_AES_GCM_auth_decryption_test_case_192_4(void)
9762 return test_authenticated_decryption(&gcm_test_case_192_4);
9766 test_AES_GCM_auth_decryption_test_case_192_5(void)
9768 return test_authenticated_decryption(&gcm_test_case_192_5);
9772 test_AES_GCM_auth_decryption_test_case_192_6(void)
9774 return test_authenticated_decryption(&gcm_test_case_192_6);
9778 test_AES_GCM_auth_decryption_test_case_192_7(void)
9780 return test_authenticated_decryption(&gcm_test_case_192_7);
9784 test_AES_GCM_auth_decryption_test_case_256_1(void)
9786 return test_authenticated_decryption(&gcm_test_case_256_1);
9790 test_AES_GCM_auth_decryption_test_case_256_2(void)
9792 return test_authenticated_decryption(&gcm_test_case_256_2);
9796 test_AES_GCM_auth_decryption_test_case_256_3(void)
9798 return test_authenticated_decryption(&gcm_test_case_256_3);
9802 test_AES_GCM_auth_decryption_test_case_256_4(void)
9804 return test_authenticated_decryption(&gcm_test_case_256_4);
9808 test_AES_GCM_auth_decryption_test_case_256_5(void)
9810 return test_authenticated_decryption(&gcm_test_case_256_5);
9814 test_AES_GCM_auth_decryption_test_case_256_6(void)
9816 return test_authenticated_decryption(&gcm_test_case_256_6);
9820 test_AES_GCM_auth_decryption_test_case_256_7(void)
9822 return test_authenticated_decryption(&gcm_test_case_256_7);
9826 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9828 return test_authenticated_decryption(&gcm_test_case_aad_1);
9832 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9834 return test_authenticated_decryption(&gcm_test_case_aad_2);
9838 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9840 struct aead_test_data tdata;
9843 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9844 tdata.iv.data[0] += 1;
9845 res = test_authenticated_decryption(&tdata);
9846 if (res == TEST_SKIPPED)
9848 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9849 return TEST_SUCCESS;
9853 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9855 struct aead_test_data tdata;
9858 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9859 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9860 tdata.plaintext.data[0] += 1;
9861 res = test_authenticated_decryption(&tdata);
9862 if (res == TEST_SKIPPED)
9864 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9865 return TEST_SUCCESS;
9869 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9871 struct aead_test_data tdata;
9874 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9875 tdata.ciphertext.data[0] += 1;
9876 res = test_authenticated_decryption(&tdata);
9877 if (res == TEST_SKIPPED)
9879 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9880 return TEST_SUCCESS;
9884 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9886 struct aead_test_data tdata;
9889 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9891 res = test_authenticated_decryption(&tdata);
9892 if (res == TEST_SKIPPED)
9894 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9895 return TEST_SUCCESS;
9899 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9901 struct aead_test_data tdata;
9902 uint8_t aad[gcm_test_case_7.aad.len];
9905 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9906 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9908 tdata.aad.data = aad;
9909 res = test_authenticated_decryption(&tdata);
9910 if (res == TEST_SKIPPED)
9912 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9913 return TEST_SUCCESS;
9917 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9919 struct aead_test_data tdata;
9922 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9923 tdata.auth_tag.data[0] += 1;
9924 res = test_authenticated_decryption(&tdata);
9925 if (res == TEST_SKIPPED)
9927 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9928 return TEST_SUCCESS;
9932 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9934 struct crypto_testsuite_params *ts_params = &testsuite_params;
9935 struct crypto_unittest_params *ut_params = &unittest_params;
9938 uint8_t *ciphertext, *auth_tag;
9939 uint16_t plaintext_pad_len;
9941 /* Verify the capabilities */
9942 struct rte_cryptodev_sym_capability_idx cap_idx;
9943 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9944 cap_idx.algo.aead = tdata->algo;
9945 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9947 return TEST_SKIPPED;
9949 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9950 return TEST_SKIPPED;
9952 /* not supported with CPU crypto */
9953 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9954 return TEST_SKIPPED;
9956 /* Create AEAD session */
9957 retval = create_aead_session(ts_params->valid_devs[0],
9959 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9960 tdata->key.data, tdata->key.len,
9961 tdata->aad.len, tdata->auth_tag.len,
9966 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9967 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9969 /* clear mbuf payload */
9970 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9971 rte_pktmbuf_tailroom(ut_params->ibuf));
9972 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9973 rte_pktmbuf_tailroom(ut_params->obuf));
9975 /* Create AEAD operation */
9976 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9980 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9982 ut_params->op->sym->m_src = ut_params->ibuf;
9983 ut_params->op->sym->m_dst = ut_params->obuf;
9985 /* Process crypto operation */
9986 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9987 ut_params->op), "failed to process sym crypto op");
9989 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9990 "crypto op processing failed");
9992 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9994 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9995 ut_params->op->sym->cipher.data.offset);
9996 auth_tag = ciphertext + plaintext_pad_len;
9998 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9999 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10001 /* Validate obuf */
10002 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10004 tdata->ciphertext.data,
10005 tdata->ciphertext.len,
10006 "Ciphertext data not as expected");
10008 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10010 tdata->auth_tag.data,
10011 tdata->auth_tag.len,
10012 "Generated auth tag not as expected");
10019 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10021 return test_authenticated_encryption_oop(&gcm_test_case_5);
10025 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10027 struct crypto_testsuite_params *ts_params = &testsuite_params;
10028 struct crypto_unittest_params *ut_params = &unittest_params;
10031 uint8_t *plaintext;
10033 /* Verify the capabilities */
10034 struct rte_cryptodev_sym_capability_idx cap_idx;
10035 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10036 cap_idx.algo.aead = tdata->algo;
10037 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10039 return TEST_SKIPPED;
10041 /* not supported with CPU crypto and raw data-path APIs*/
10042 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10043 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10044 return TEST_SKIPPED;
10046 /* Create AEAD session */
10047 retval = create_aead_session(ts_params->valid_devs[0],
10049 RTE_CRYPTO_AEAD_OP_DECRYPT,
10050 tdata->key.data, tdata->key.len,
10051 tdata->aad.len, tdata->auth_tag.len,
10056 /* alloc mbuf and set payload */
10057 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10058 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10060 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10061 rte_pktmbuf_tailroom(ut_params->ibuf));
10062 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10063 rte_pktmbuf_tailroom(ut_params->obuf));
10065 /* Create AEAD operation */
10066 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10070 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10072 ut_params->op->sym->m_src = ut_params->ibuf;
10073 ut_params->op->sym->m_dst = ut_params->obuf;
10075 /* Process crypto operation */
10076 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10077 ut_params->op), "failed to process sym crypto op");
10079 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10080 "crypto op processing failed");
10082 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10083 ut_params->op->sym->cipher.data.offset);
10085 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10087 /* Validate obuf */
10088 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10090 tdata->plaintext.data,
10091 tdata->plaintext.len,
10092 "Plaintext data not as expected");
10094 TEST_ASSERT_EQUAL(ut_params->op->status,
10095 RTE_CRYPTO_OP_STATUS_SUCCESS,
10096 "Authentication failed");
10101 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10103 return test_authenticated_decryption_oop(&gcm_test_case_5);
10107 test_authenticated_encryption_sessionless(
10108 const struct aead_test_data *tdata)
10110 struct crypto_testsuite_params *ts_params = &testsuite_params;
10111 struct crypto_unittest_params *ut_params = &unittest_params;
10114 uint8_t *ciphertext, *auth_tag;
10115 uint16_t plaintext_pad_len;
10116 uint8_t key[tdata->key.len + 1];
10117 struct rte_cryptodev_info dev_info;
10119 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10120 uint64_t feat_flags = dev_info.feature_flags;
10122 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10123 printf("Device doesn't support Sessionless ops.\n");
10124 return TEST_SKIPPED;
10127 /* not supported with CPU crypto */
10128 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10129 return TEST_SKIPPED;
10131 /* Verify the capabilities */
10132 struct rte_cryptodev_sym_capability_idx cap_idx;
10133 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10134 cap_idx.algo.aead = tdata->algo;
10135 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10137 return TEST_SKIPPED;
10139 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10141 /* clear mbuf payload */
10142 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10143 rte_pktmbuf_tailroom(ut_params->ibuf));
10145 /* Create AEAD operation */
10146 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10150 /* Create GCM xform */
10151 memcpy(key, tdata->key.data, tdata->key.len);
10152 retval = create_aead_xform(ut_params->op,
10154 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10155 key, tdata->key.len,
10156 tdata->aad.len, tdata->auth_tag.len,
10161 ut_params->op->sym->m_src = ut_params->ibuf;
10163 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10164 RTE_CRYPTO_OP_SESSIONLESS,
10165 "crypto op session type not sessionless");
10167 /* Process crypto operation */
10168 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10169 ut_params->op), "failed to process sym crypto op");
10171 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10173 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10174 "crypto op status not success");
10176 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10178 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10179 ut_params->op->sym->cipher.data.offset);
10180 auth_tag = ciphertext + plaintext_pad_len;
10182 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10183 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10185 /* Validate obuf */
10186 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10188 tdata->ciphertext.data,
10189 tdata->ciphertext.len,
10190 "Ciphertext data not as expected");
10192 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10194 tdata->auth_tag.data,
10195 tdata->auth_tag.len,
10196 "Generated auth tag not as expected");
10203 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10205 return test_authenticated_encryption_sessionless(
10210 test_authenticated_decryption_sessionless(
10211 const struct aead_test_data *tdata)
10213 struct crypto_testsuite_params *ts_params = &testsuite_params;
10214 struct crypto_unittest_params *ut_params = &unittest_params;
10217 uint8_t *plaintext;
10218 uint8_t key[tdata->key.len + 1];
10219 struct rte_cryptodev_info dev_info;
10221 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10222 uint64_t feat_flags = dev_info.feature_flags;
10224 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10225 printf("Device doesn't support Sessionless ops.\n");
10226 return TEST_SKIPPED;
10229 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10230 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10231 printf("Device doesn't support RAW data-path APIs.\n");
10232 return TEST_SKIPPED;
10235 /* not supported with CPU crypto */
10236 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10237 return TEST_SKIPPED;
10239 /* Verify the capabilities */
10240 struct rte_cryptodev_sym_capability_idx cap_idx;
10241 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10242 cap_idx.algo.aead = tdata->algo;
10243 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10245 return TEST_SKIPPED;
10247 /* alloc mbuf and set payload */
10248 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10250 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10251 rte_pktmbuf_tailroom(ut_params->ibuf));
10253 /* Create AEAD operation */
10254 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10258 /* Create AEAD xform */
10259 memcpy(key, tdata->key.data, tdata->key.len);
10260 retval = create_aead_xform(ut_params->op,
10262 RTE_CRYPTO_AEAD_OP_DECRYPT,
10263 key, tdata->key.len,
10264 tdata->aad.len, tdata->auth_tag.len,
10269 ut_params->op->sym->m_src = ut_params->ibuf;
10271 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10272 RTE_CRYPTO_OP_SESSIONLESS,
10273 "crypto op session type not sessionless");
10275 /* Process crypto operation */
10276 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10277 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10278 ut_params->op, 0, 0, 0, 0);
10280 TEST_ASSERT_NOT_NULL(process_crypto_request(
10281 ts_params->valid_devs[0], ut_params->op),
10282 "failed to process sym crypto op");
10284 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10286 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10287 "crypto op status not success");
10289 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10290 ut_params->op->sym->cipher.data.offset);
10292 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10294 /* Validate obuf */
10295 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10297 tdata->plaintext.data,
10298 tdata->plaintext.len,
10299 "Plaintext data not as expected");
10301 TEST_ASSERT_EQUAL(ut_params->op->status,
10302 RTE_CRYPTO_OP_STATUS_SUCCESS,
10303 "Authentication failed");
10308 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10310 return test_authenticated_decryption_sessionless(
10315 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10317 return test_authenticated_encryption(&ccm_test_case_128_1);
10321 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10323 return test_authenticated_encryption(&ccm_test_case_128_2);
10327 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10329 return test_authenticated_encryption(&ccm_test_case_128_3);
10333 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10335 return test_authenticated_decryption(&ccm_test_case_128_1);
10339 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10341 return test_authenticated_decryption(&ccm_test_case_128_2);
10345 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10347 return test_authenticated_decryption(&ccm_test_case_128_3);
10351 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10353 return test_authenticated_encryption(&ccm_test_case_192_1);
10357 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10359 return test_authenticated_encryption(&ccm_test_case_192_2);
10363 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10365 return test_authenticated_encryption(&ccm_test_case_192_3);
10369 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10371 return test_authenticated_decryption(&ccm_test_case_192_1);
10375 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10377 return test_authenticated_decryption(&ccm_test_case_192_2);
10381 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10383 return test_authenticated_decryption(&ccm_test_case_192_3);
10387 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10389 return test_authenticated_encryption(&ccm_test_case_256_1);
10393 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10395 return test_authenticated_encryption(&ccm_test_case_256_2);
10399 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10401 return test_authenticated_encryption(&ccm_test_case_256_3);
10405 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10407 return test_authenticated_decryption(&ccm_test_case_256_1);
10411 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10413 return test_authenticated_decryption(&ccm_test_case_256_2);
10417 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10419 return test_authenticated_decryption(&ccm_test_case_256_3);
10425 struct crypto_testsuite_params *ts_params = &testsuite_params;
10426 struct rte_cryptodev_stats stats;
10428 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10429 return TEST_SKIPPED;
10431 /* Verify the capabilities */
10432 struct rte_cryptodev_sym_capability_idx cap_idx;
10433 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10434 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10435 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10437 return TEST_SKIPPED;
10438 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10439 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10440 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10442 return TEST_SKIPPED;
10444 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10446 return TEST_SKIPPED;
10448 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10449 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10450 &stats) == -ENODEV),
10451 "rte_cryptodev_stats_get invalid dev failed");
10452 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10453 "rte_cryptodev_stats_get invalid Param failed");
10455 /* Test expected values */
10456 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10457 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10459 "rte_cryptodev_stats_get failed");
10460 TEST_ASSERT((stats.enqueued_count == 1),
10461 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10462 TEST_ASSERT((stats.dequeued_count == 1),
10463 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10464 TEST_ASSERT((stats.enqueue_err_count == 0),
10465 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10466 TEST_ASSERT((stats.dequeue_err_count == 0),
10467 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10469 /* invalid device but should ignore and not reset device stats*/
10470 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10471 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10473 "rte_cryptodev_stats_get failed");
10474 TEST_ASSERT((stats.enqueued_count == 1),
10475 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10477 /* check that a valid reset clears stats */
10478 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10479 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10481 "rte_cryptodev_stats_get failed");
10482 TEST_ASSERT((stats.enqueued_count == 0),
10483 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10484 TEST_ASSERT((stats.dequeued_count == 0),
10485 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10487 return TEST_SUCCESS;
10490 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10491 struct crypto_unittest_params *ut_params,
10492 enum rte_crypto_auth_operation op,
10493 const struct HMAC_MD5_vector *test_case)
10497 memcpy(key, test_case->key.data, test_case->key.len);
10499 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10500 ut_params->auth_xform.next = NULL;
10501 ut_params->auth_xform.auth.op = op;
10503 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10505 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10506 ut_params->auth_xform.auth.key.length = test_case->key.len;
10507 ut_params->auth_xform.auth.key.data = key;
10509 ut_params->sess = rte_cryptodev_sym_session_create(
10510 ts_params->session_mpool);
10512 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10513 ut_params->sess, &ut_params->auth_xform,
10514 ts_params->session_priv_mpool);
10516 if (ut_params->sess == NULL)
10517 return TEST_FAILED;
10519 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10521 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10522 rte_pktmbuf_tailroom(ut_params->ibuf));
10527 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10528 const struct HMAC_MD5_vector *test_case,
10529 uint8_t **plaintext)
10531 uint16_t plaintext_pad_len;
10533 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10535 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10538 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10539 plaintext_pad_len);
10540 memcpy(*plaintext, test_case->plaintext.data,
10541 test_case->plaintext.len);
10543 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10544 ut_params->ibuf, MD5_DIGEST_LEN);
10545 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10546 "no room to append digest");
10547 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10548 ut_params->ibuf, plaintext_pad_len);
10550 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10551 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10552 test_case->auth_tag.len);
10555 sym_op->auth.data.offset = 0;
10556 sym_op->auth.data.length = test_case->plaintext.len;
10558 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10559 ut_params->op->sym->m_src = ut_params->ibuf;
10565 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10567 uint16_t plaintext_pad_len;
10568 uint8_t *plaintext, *auth_tag;
10570 struct crypto_testsuite_params *ts_params = &testsuite_params;
10571 struct crypto_unittest_params *ut_params = &unittest_params;
10572 struct rte_cryptodev_info dev_info;
10574 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10575 uint64_t feat_flags = dev_info.feature_flags;
10577 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10578 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10579 printf("Device doesn't support RAW data-path APIs.\n");
10580 return TEST_SKIPPED;
10583 /* Verify the capabilities */
10584 struct rte_cryptodev_sym_capability_idx cap_idx;
10585 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10586 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10587 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10589 return TEST_SKIPPED;
10591 if (MD5_HMAC_create_session(ts_params, ut_params,
10592 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10593 return TEST_FAILED;
10595 /* Generate Crypto op data structure */
10596 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10597 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10598 TEST_ASSERT_NOT_NULL(ut_params->op,
10599 "Failed to allocate symmetric crypto operation struct");
10601 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10604 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10605 return TEST_FAILED;
10607 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10608 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10610 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10611 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10612 ut_params->op, 0, 1, 0, 0);
10614 TEST_ASSERT_NOT_NULL(
10615 process_crypto_request(ts_params->valid_devs[0],
10617 "failed to process sym crypto op");
10619 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10620 "crypto op processing failed");
10622 if (ut_params->op->sym->m_dst) {
10623 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10624 uint8_t *, plaintext_pad_len);
10626 auth_tag = plaintext + plaintext_pad_len;
10629 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10631 test_case->auth_tag.data,
10632 test_case->auth_tag.len,
10633 "HMAC_MD5 generated tag not as expected");
10635 return TEST_SUCCESS;
10639 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10641 uint8_t *plaintext;
10643 struct crypto_testsuite_params *ts_params = &testsuite_params;
10644 struct crypto_unittest_params *ut_params = &unittest_params;
10645 struct rte_cryptodev_info dev_info;
10647 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10648 uint64_t feat_flags = dev_info.feature_flags;
10650 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10651 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10652 printf("Device doesn't support RAW data-path APIs.\n");
10653 return TEST_SKIPPED;
10656 /* Verify the capabilities */
10657 struct rte_cryptodev_sym_capability_idx cap_idx;
10658 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10659 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10660 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10662 return TEST_SKIPPED;
10664 if (MD5_HMAC_create_session(ts_params, ut_params,
10665 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10666 return TEST_FAILED;
10669 /* Generate Crypto op data structure */
10670 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10671 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10672 TEST_ASSERT_NOT_NULL(ut_params->op,
10673 "Failed to allocate symmetric crypto operation struct");
10675 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10676 return TEST_FAILED;
10678 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10679 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10681 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10682 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10683 ut_params->op, 0, 1, 0, 0);
10685 TEST_ASSERT_NOT_NULL(
10686 process_crypto_request(ts_params->valid_devs[0],
10688 "failed to process sym crypto op");
10690 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10691 "HMAC_MD5 crypto op processing failed");
10693 return TEST_SUCCESS;
10697 test_MD5_HMAC_generate_case_1(void)
10699 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10703 test_MD5_HMAC_verify_case_1(void)
10705 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10709 test_MD5_HMAC_generate_case_2(void)
10711 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10715 test_MD5_HMAC_verify_case_2(void)
10717 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10721 test_multi_session(void)
10723 struct crypto_testsuite_params *ts_params = &testsuite_params;
10724 struct crypto_unittest_params *ut_params = &unittest_params;
10726 struct rte_cryptodev_info dev_info;
10727 struct rte_cryptodev_sym_session **sessions;
10731 /* Verify the capabilities */
10732 struct rte_cryptodev_sym_capability_idx cap_idx;
10733 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10734 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10735 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10737 return TEST_SKIPPED;
10738 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10739 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10740 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10742 return TEST_SKIPPED;
10744 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10745 aes_cbc_key, hmac_sha512_key);
10748 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10750 sessions = rte_malloc(NULL,
10751 sizeof(struct rte_cryptodev_sym_session *) *
10752 (MAX_NB_SESSIONS + 1), 0);
10754 /* Create multiple crypto sessions*/
10755 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10757 sessions[i] = rte_cryptodev_sym_session_create(
10758 ts_params->session_mpool);
10760 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10761 sessions[i], &ut_params->auth_xform,
10762 ts_params->session_priv_mpool);
10763 TEST_ASSERT_NOT_NULL(sessions[i],
10764 "Session creation failed at session number %u",
10767 /* Attempt to send a request on each session */
10768 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10772 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10773 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10775 "Failed to perform decrypt on request number %u.", i);
10776 /* free crypto operation structure */
10778 rte_crypto_op_free(ut_params->op);
10781 * free mbuf - both obuf and ibuf are usually the same,
10782 * so check if they point at the same address is necessary,
10783 * to avoid freeing the mbuf twice.
10785 if (ut_params->obuf) {
10786 rte_pktmbuf_free(ut_params->obuf);
10787 if (ut_params->ibuf == ut_params->obuf)
10788 ut_params->ibuf = 0;
10789 ut_params->obuf = 0;
10791 if (ut_params->ibuf) {
10792 rte_pktmbuf_free(ut_params->ibuf);
10793 ut_params->ibuf = 0;
10797 sessions[i] = NULL;
10798 /* Next session create should fail */
10799 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10800 sessions[i], &ut_params->auth_xform,
10801 ts_params->session_priv_mpool);
10802 TEST_ASSERT_NULL(sessions[i],
10803 "Session creation succeeded unexpectedly!");
10805 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10806 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10808 rte_cryptodev_sym_session_free(sessions[i]);
10811 rte_free(sessions);
10813 return TEST_SUCCESS;
10816 struct multi_session_params {
10817 struct crypto_unittest_params ut_params;
10818 uint8_t *cipher_key;
10820 const uint8_t *cipher;
10821 const uint8_t *digest;
10825 #define MB_SESSION_NUMBER 3
10828 test_multi_session_random_usage(void)
10830 struct crypto_testsuite_params *ts_params = &testsuite_params;
10831 struct rte_cryptodev_info dev_info;
10832 struct rte_cryptodev_sym_session **sessions;
10834 struct multi_session_params ut_paramz[] = {
10837 .cipher_key = ms_aes_cbc_key0,
10838 .hmac_key = ms_hmac_key0,
10839 .cipher = ms_aes_cbc_cipher0,
10840 .digest = ms_hmac_digest0,
10841 .iv = ms_aes_cbc_iv0
10844 .cipher_key = ms_aes_cbc_key1,
10845 .hmac_key = ms_hmac_key1,
10846 .cipher = ms_aes_cbc_cipher1,
10847 .digest = ms_hmac_digest1,
10848 .iv = ms_aes_cbc_iv1
10851 .cipher_key = ms_aes_cbc_key2,
10852 .hmac_key = ms_hmac_key2,
10853 .cipher = ms_aes_cbc_cipher2,
10854 .digest = ms_hmac_digest2,
10855 .iv = ms_aes_cbc_iv2
10860 /* Verify the capabilities */
10861 struct rte_cryptodev_sym_capability_idx cap_idx;
10862 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10863 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10864 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10866 return TEST_SKIPPED;
10867 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10868 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10869 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10871 return TEST_SKIPPED;
10873 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10875 sessions = rte_malloc(NULL,
10876 (sizeof(struct rte_cryptodev_sym_session *)
10877 * MAX_NB_SESSIONS) + 1, 0);
10879 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10880 sessions[i] = rte_cryptodev_sym_session_create(
10881 ts_params->session_mpool);
10883 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10884 sizeof(struct crypto_unittest_params));
10886 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10887 &ut_paramz[i].ut_params,
10888 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10890 /* Create multiple crypto sessions*/
10891 rte_cryptodev_sym_session_init(
10892 ts_params->valid_devs[0],
10894 &ut_paramz[i].ut_params.auth_xform,
10895 ts_params->session_priv_mpool);
10897 TEST_ASSERT_NOT_NULL(sessions[i],
10898 "Session creation failed at session number %u",
10904 for (i = 0; i < 40000; i++) {
10906 j = rand() % MB_SESSION_NUMBER;
10908 TEST_ASSERT_SUCCESS(
10909 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10911 &ut_paramz[j].ut_params,
10912 ts_params, ut_paramz[j].cipher,
10913 ut_paramz[j].digest,
10915 "Failed to perform decrypt on request number %u.", i);
10917 if (ut_paramz[j].ut_params.op)
10918 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10921 * free mbuf - both obuf and ibuf are usually the same,
10922 * so check if they point at the same address is necessary,
10923 * to avoid freeing the mbuf twice.
10925 if (ut_paramz[j].ut_params.obuf) {
10926 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10927 if (ut_paramz[j].ut_params.ibuf
10928 == ut_paramz[j].ut_params.obuf)
10929 ut_paramz[j].ut_params.ibuf = 0;
10930 ut_paramz[j].ut_params.obuf = 0;
10932 if (ut_paramz[j].ut_params.ibuf) {
10933 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10934 ut_paramz[j].ut_params.ibuf = 0;
10938 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10939 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10941 rte_cryptodev_sym_session_free(sessions[i]);
10944 rte_free(sessions);
10946 return TEST_SUCCESS;
10949 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10950 0xab, 0xab, 0xab, 0xab,
10951 0xab, 0xab, 0xab, 0xab,
10952 0xab, 0xab, 0xab, 0xab};
10955 test_null_invalid_operation(void)
10957 struct crypto_testsuite_params *ts_params = &testsuite_params;
10958 struct crypto_unittest_params *ut_params = &unittest_params;
10961 /* This test is for NULL PMD only */
10962 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10963 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10964 return TEST_SKIPPED;
10966 /* Setup Cipher Parameters */
10967 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10968 ut_params->cipher_xform.next = NULL;
10970 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10971 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10973 ut_params->sess = rte_cryptodev_sym_session_create(
10974 ts_params->session_mpool);
10976 /* Create Crypto session*/
10977 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10978 ut_params->sess, &ut_params->cipher_xform,
10979 ts_params->session_priv_mpool);
10980 TEST_ASSERT(ret < 0,
10981 "Session creation succeeded unexpectedly");
10984 /* Setup HMAC Parameters */
10985 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10986 ut_params->auth_xform.next = NULL;
10988 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10989 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10991 ut_params->sess = rte_cryptodev_sym_session_create(
10992 ts_params->session_mpool);
10994 /* Create Crypto session*/
10995 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10996 ut_params->sess, &ut_params->auth_xform,
10997 ts_params->session_priv_mpool);
10998 TEST_ASSERT(ret < 0,
10999 "Session creation succeeded unexpectedly");
11001 return TEST_SUCCESS;
11005 #define NULL_BURST_LENGTH (32)
11008 test_null_burst_operation(void)
11010 struct crypto_testsuite_params *ts_params = &testsuite_params;
11011 struct crypto_unittest_params *ut_params = &unittest_params;
11013 unsigned i, burst_len = NULL_BURST_LENGTH;
11015 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11016 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11018 /* This test is for NULL PMD only */
11019 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11020 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11021 return TEST_SKIPPED;
11023 /* Setup Cipher Parameters */
11024 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11025 ut_params->cipher_xform.next = &ut_params->auth_xform;
11027 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11028 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11030 /* Setup HMAC Parameters */
11031 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11032 ut_params->auth_xform.next = NULL;
11034 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11035 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11037 ut_params->sess = rte_cryptodev_sym_session_create(
11038 ts_params->session_mpool);
11040 /* Create Crypto session*/
11041 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11042 ut_params->sess, &ut_params->cipher_xform,
11043 ts_params->session_priv_mpool);
11044 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11046 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11047 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11048 burst_len, "failed to generate burst of crypto ops");
11050 /* Generate an operation for each mbuf in burst */
11051 for (i = 0; i < burst_len; i++) {
11052 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11054 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11056 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11060 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11062 burst[i]->sym->m_src = m;
11065 /* Process crypto operation */
11066 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11067 0, burst, burst_len),
11069 "Error enqueuing burst");
11071 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11072 0, burst_dequeued, burst_len),
11074 "Error dequeuing burst");
11077 for (i = 0; i < burst_len; i++) {
11079 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11080 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11082 "data not as expected");
11084 rte_pktmbuf_free(burst[i]->sym->m_src);
11085 rte_crypto_op_free(burst[i]);
11088 return TEST_SUCCESS;
11092 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11093 uint16_t nb_ops, void *user_param)
11095 RTE_SET_USED(dev_id);
11096 RTE_SET_USED(qp_id);
11098 RTE_SET_USED(user_param);
11100 printf("crypto enqueue callback called\n");
11105 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11106 uint16_t nb_ops, void *user_param)
11108 RTE_SET_USED(dev_id);
11109 RTE_SET_USED(qp_id);
11111 RTE_SET_USED(user_param);
11113 printf("crypto dequeue callback called\n");
11118 * Thread using enqueue/dequeue callback with RCU.
11121 test_enqdeq_callback_thread(void *arg)
11124 /* DP thread calls rte_cryptodev_enqueue_burst()/
11125 * rte_cryptodev_dequeue_burst() and invokes callback.
11127 test_null_burst_operation();
11132 test_enq_callback_setup(void)
11134 struct crypto_testsuite_params *ts_params = &testsuite_params;
11135 struct rte_cryptodev_info dev_info;
11136 struct rte_cryptodev_qp_conf qp_conf = {
11137 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11140 struct rte_cryptodev_cb *cb;
11141 uint16_t qp_id = 0;
11143 /* Stop the device in case it's started so it can be configured */
11144 rte_cryptodev_stop(ts_params->valid_devs[0]);
11146 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11148 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11150 "Failed to configure cryptodev %u",
11151 ts_params->valid_devs[0]);
11153 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11154 qp_conf.mp_session = ts_params->session_mpool;
11155 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11157 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11158 ts_params->valid_devs[0], qp_id, &qp_conf,
11159 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11161 "rte_cryptodev_queue_pair_setup: num_inflights "
11162 "%u on qp %u on cryptodev %u",
11163 qp_conf.nb_descriptors, qp_id,
11164 ts_params->valid_devs[0]);
11166 /* Test with invalid crypto device */
11167 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11168 qp_id, test_enq_callback, NULL);
11169 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11170 "cryptodev %u did not fail",
11171 qp_id, RTE_CRYPTO_MAX_DEVS);
11173 /* Test with invalid queue pair */
11174 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11175 dev_info.max_nb_queue_pairs + 1,
11176 test_enq_callback, NULL);
11177 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11178 "cryptodev %u did not fail",
11179 dev_info.max_nb_queue_pairs + 1,
11180 ts_params->valid_devs[0]);
11182 /* Test with NULL callback */
11183 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11184 qp_id, NULL, NULL);
11185 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11186 "cryptodev %u did not fail",
11187 qp_id, ts_params->valid_devs[0]);
11189 /* Test with valid configuration */
11190 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11191 qp_id, test_enq_callback, NULL);
11192 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11193 "qp %u on cryptodev %u",
11194 qp_id, ts_params->valid_devs[0]);
11196 rte_cryptodev_start(ts_params->valid_devs[0]);
11198 /* Launch a thread */
11199 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11200 rte_get_next_lcore(-1, 1, 0));
11202 /* Wait until reader exited. */
11203 rte_eal_mp_wait_lcore();
11205 /* Test with invalid crypto device */
11206 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11207 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11208 "Expected call to fail as crypto device is invalid");
11210 /* Test with invalid queue pair */
11211 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11212 ts_params->valid_devs[0],
11213 dev_info.max_nb_queue_pairs + 1, cb),
11214 "Expected call to fail as queue pair is invalid");
11216 /* Test with NULL callback */
11217 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11218 ts_params->valid_devs[0], qp_id, NULL),
11219 "Expected call to fail as callback is NULL");
11221 /* Test with valid configuration */
11222 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11223 ts_params->valid_devs[0], qp_id, cb),
11224 "Failed test to remove callback on "
11225 "qp %u on cryptodev %u",
11226 qp_id, ts_params->valid_devs[0]);
11228 return TEST_SUCCESS;
11232 test_deq_callback_setup(void)
11234 struct crypto_testsuite_params *ts_params = &testsuite_params;
11235 struct rte_cryptodev_info dev_info;
11236 struct rte_cryptodev_qp_conf qp_conf = {
11237 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11240 struct rte_cryptodev_cb *cb;
11241 uint16_t qp_id = 0;
11243 /* Stop the device in case it's started so it can be configured */
11244 rte_cryptodev_stop(ts_params->valid_devs[0]);
11246 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11248 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11250 "Failed to configure cryptodev %u",
11251 ts_params->valid_devs[0]);
11253 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11254 qp_conf.mp_session = ts_params->session_mpool;
11255 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11257 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11258 ts_params->valid_devs[0], qp_id, &qp_conf,
11259 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11261 "rte_cryptodev_queue_pair_setup: num_inflights "
11262 "%u on qp %u on cryptodev %u",
11263 qp_conf.nb_descriptors, qp_id,
11264 ts_params->valid_devs[0]);
11266 /* Test with invalid crypto device */
11267 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11268 qp_id, test_deq_callback, NULL);
11269 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11270 "cryptodev %u did not fail",
11271 qp_id, RTE_CRYPTO_MAX_DEVS);
11273 /* Test with invalid queue pair */
11274 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11275 dev_info.max_nb_queue_pairs + 1,
11276 test_deq_callback, NULL);
11277 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11278 "cryptodev %u did not fail",
11279 dev_info.max_nb_queue_pairs + 1,
11280 ts_params->valid_devs[0]);
11282 /* Test with NULL callback */
11283 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11284 qp_id, NULL, NULL);
11285 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11286 "cryptodev %u did not fail",
11287 qp_id, ts_params->valid_devs[0]);
11289 /* Test with valid configuration */
11290 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11291 qp_id, test_deq_callback, NULL);
11292 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11293 "qp %u on cryptodev %u",
11294 qp_id, ts_params->valid_devs[0]);
11296 rte_cryptodev_start(ts_params->valid_devs[0]);
11298 /* Launch a thread */
11299 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11300 rte_get_next_lcore(-1, 1, 0));
11302 /* Wait until reader exited. */
11303 rte_eal_mp_wait_lcore();
11305 /* Test with invalid crypto device */
11306 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11307 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11308 "Expected call to fail as crypto device is invalid");
11310 /* Test with invalid queue pair */
11311 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11312 ts_params->valid_devs[0],
11313 dev_info.max_nb_queue_pairs + 1, cb),
11314 "Expected call to fail as queue pair is invalid");
11316 /* Test with NULL callback */
11317 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11318 ts_params->valid_devs[0], qp_id, NULL),
11319 "Expected call to fail as callback is NULL");
11321 /* Test with valid configuration */
11322 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11323 ts_params->valid_devs[0], qp_id, cb),
11324 "Failed test to remove callback on "
11325 "qp %u on cryptodev %u",
11326 qp_id, ts_params->valid_devs[0]);
11328 return TEST_SUCCESS;
11332 generate_gmac_large_plaintext(uint8_t *data)
11336 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11337 memcpy(&data[i], &data[0], 32);
11341 create_gmac_operation(enum rte_crypto_auth_operation op,
11342 const struct gmac_test_data *tdata)
11344 struct crypto_testsuite_params *ts_params = &testsuite_params;
11345 struct crypto_unittest_params *ut_params = &unittest_params;
11346 struct rte_crypto_sym_op *sym_op;
11348 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11350 /* Generate Crypto op data structure */
11351 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11352 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11353 TEST_ASSERT_NOT_NULL(ut_params->op,
11354 "Failed to allocate symmetric crypto operation struct");
11356 sym_op = ut_params->op->sym;
11358 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11359 ut_params->ibuf, tdata->gmac_tag.len);
11360 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11361 "no room to append digest");
11363 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11364 ut_params->ibuf, plaintext_pad_len);
11366 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11367 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11368 tdata->gmac_tag.len);
11369 debug_hexdump(stdout, "digest:",
11370 sym_op->auth.digest.data,
11371 tdata->gmac_tag.len);
11374 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11375 uint8_t *, IV_OFFSET);
11377 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11379 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11381 sym_op->cipher.data.length = 0;
11382 sym_op->cipher.data.offset = 0;
11384 sym_op->auth.data.offset = 0;
11385 sym_op->auth.data.length = tdata->plaintext.len;
11391 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11392 const struct gmac_test_data *tdata,
11393 void *digest_mem, uint64_t digest_phys)
11395 struct crypto_testsuite_params *ts_params = &testsuite_params;
11396 struct crypto_unittest_params *ut_params = &unittest_params;
11397 struct rte_crypto_sym_op *sym_op;
11399 /* Generate Crypto op data structure */
11400 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11401 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11402 TEST_ASSERT_NOT_NULL(ut_params->op,
11403 "Failed to allocate symmetric crypto operation struct");
11405 sym_op = ut_params->op->sym;
11407 sym_op->auth.digest.data = digest_mem;
11408 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11409 "no room to append digest");
11411 sym_op->auth.digest.phys_addr = digest_phys;
11413 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11414 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11415 tdata->gmac_tag.len);
11416 debug_hexdump(stdout, "digest:",
11417 sym_op->auth.digest.data,
11418 tdata->gmac_tag.len);
11421 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11422 uint8_t *, IV_OFFSET);
11424 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11426 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11428 sym_op->cipher.data.length = 0;
11429 sym_op->cipher.data.offset = 0;
11431 sym_op->auth.data.offset = 0;
11432 sym_op->auth.data.length = tdata->plaintext.len;
11437 static int create_gmac_session(uint8_t dev_id,
11438 const struct gmac_test_data *tdata,
11439 enum rte_crypto_auth_operation auth_op)
11441 uint8_t auth_key[tdata->key.len];
11443 struct crypto_testsuite_params *ts_params = &testsuite_params;
11444 struct crypto_unittest_params *ut_params = &unittest_params;
11446 memcpy(auth_key, tdata->key.data, tdata->key.len);
11448 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11449 ut_params->auth_xform.next = NULL;
11451 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11452 ut_params->auth_xform.auth.op = auth_op;
11453 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11454 ut_params->auth_xform.auth.key.length = tdata->key.len;
11455 ut_params->auth_xform.auth.key.data = auth_key;
11456 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11457 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11460 ut_params->sess = rte_cryptodev_sym_session_create(
11461 ts_params->session_mpool);
11463 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11464 &ut_params->auth_xform,
11465 ts_params->session_priv_mpool);
11467 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11473 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11475 struct crypto_testsuite_params *ts_params = &testsuite_params;
11476 struct crypto_unittest_params *ut_params = &unittest_params;
11477 struct rte_cryptodev_info dev_info;
11479 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11480 uint64_t feat_flags = dev_info.feature_flags;
11482 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11483 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11484 printf("Device doesn't support RAW data-path APIs.\n");
11485 return TEST_SKIPPED;
11490 uint8_t *auth_tag, *plaintext;
11491 uint16_t plaintext_pad_len;
11493 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11494 "No GMAC length in the source data");
11496 /* Verify the capabilities */
11497 struct rte_cryptodev_sym_capability_idx cap_idx;
11498 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11499 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11500 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11502 return TEST_SKIPPED;
11504 retval = create_gmac_session(ts_params->valid_devs[0],
11505 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11510 if (tdata->plaintext.len > MBUF_SIZE)
11511 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11513 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11514 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11515 "Failed to allocate input buffer in mempool");
11517 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11518 rte_pktmbuf_tailroom(ut_params->ibuf));
11520 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11522 * Runtime generate the large plain text instead of use hard code
11523 * plain text vector. It is done to avoid create huge source file
11524 * with the test vector.
11526 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11527 generate_gmac_large_plaintext(tdata->plaintext.data);
11529 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11530 plaintext_pad_len);
11531 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11533 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11534 debug_hexdump(stdout, "plaintext:", plaintext,
11535 tdata->plaintext.len);
11537 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11543 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11545 ut_params->op->sym->m_src = ut_params->ibuf;
11547 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11548 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11550 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11551 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11552 ut_params->op, 0, 1, 0, 0);
11554 TEST_ASSERT_NOT_NULL(
11555 process_crypto_request(ts_params->valid_devs[0],
11556 ut_params->op), "failed to process sym crypto op");
11558 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11559 "crypto op processing failed");
11561 if (ut_params->op->sym->m_dst) {
11562 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11563 uint8_t *, plaintext_pad_len);
11565 auth_tag = plaintext + plaintext_pad_len;
11568 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11570 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11572 tdata->gmac_tag.data,
11573 tdata->gmac_tag.len,
11574 "GMAC Generated auth tag not as expected");
11580 test_AES_GMAC_authentication_test_case_1(void)
11582 return test_AES_GMAC_authentication(&gmac_test_case_1);
11586 test_AES_GMAC_authentication_test_case_2(void)
11588 return test_AES_GMAC_authentication(&gmac_test_case_2);
11592 test_AES_GMAC_authentication_test_case_3(void)
11594 return test_AES_GMAC_authentication(&gmac_test_case_3);
11598 test_AES_GMAC_authentication_test_case_4(void)
11600 return test_AES_GMAC_authentication(&gmac_test_case_4);
11604 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11606 struct crypto_testsuite_params *ts_params = &testsuite_params;
11607 struct crypto_unittest_params *ut_params = &unittest_params;
11609 uint32_t plaintext_pad_len;
11610 uint8_t *plaintext;
11611 struct rte_cryptodev_info dev_info;
11613 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11614 uint64_t feat_flags = dev_info.feature_flags;
11616 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11617 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11618 printf("Device doesn't support RAW data-path APIs.\n");
11619 return TEST_SKIPPED;
11622 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11623 "No GMAC length in the source data");
11625 /* Verify the capabilities */
11626 struct rte_cryptodev_sym_capability_idx cap_idx;
11627 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11628 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11629 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11631 return TEST_SKIPPED;
11633 retval = create_gmac_session(ts_params->valid_devs[0],
11634 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11639 if (tdata->plaintext.len > MBUF_SIZE)
11640 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11642 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11643 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11644 "Failed to allocate input buffer in mempool");
11646 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11647 rte_pktmbuf_tailroom(ut_params->ibuf));
11649 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11652 * Runtime generate the large plain text instead of use hard code
11653 * plain text vector. It is done to avoid create huge source file
11654 * with the test vector.
11656 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11657 generate_gmac_large_plaintext(tdata->plaintext.data);
11659 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11660 plaintext_pad_len);
11661 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11663 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11664 debug_hexdump(stdout, "plaintext:", plaintext,
11665 tdata->plaintext.len);
11667 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11673 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11675 ut_params->op->sym->m_src = ut_params->ibuf;
11677 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11678 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11680 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11681 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11682 ut_params->op, 0, 1, 0, 0);
11684 TEST_ASSERT_NOT_NULL(
11685 process_crypto_request(ts_params->valid_devs[0],
11686 ut_params->op), "failed to process sym crypto op");
11688 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11689 "crypto op processing failed");
11696 test_AES_GMAC_authentication_verify_test_case_1(void)
11698 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11702 test_AES_GMAC_authentication_verify_test_case_2(void)
11704 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11708 test_AES_GMAC_authentication_verify_test_case_3(void)
11710 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11714 test_AES_GMAC_authentication_verify_test_case_4(void)
11716 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11720 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11723 struct crypto_testsuite_params *ts_params = &testsuite_params;
11724 struct crypto_unittest_params *ut_params = &unittest_params;
11725 struct rte_cryptodev_info dev_info;
11726 uint64_t feature_flags;
11727 unsigned int trn_data = 0;
11728 void *digest_mem = NULL;
11730 unsigned int to_trn = 0;
11731 struct rte_mbuf *buf = NULL;
11732 uint8_t *auth_tag, *plaintext;
11735 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11736 "No GMAC length in the source data");
11738 /* Verify the capabilities */
11739 struct rte_cryptodev_sym_capability_idx cap_idx;
11740 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11741 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11742 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11744 return TEST_SKIPPED;
11746 /* Check for any input SGL support */
11747 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11748 feature_flags = dev_info.feature_flags;
11750 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11751 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11752 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11753 return TEST_SKIPPED;
11755 if (fragsz > tdata->plaintext.len)
11756 fragsz = tdata->plaintext.len;
11758 uint16_t plaintext_len = fragsz;
11760 retval = create_gmac_session(ts_params->valid_devs[0],
11761 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11766 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11767 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11768 "Failed to allocate input buffer in mempool");
11770 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11771 rte_pktmbuf_tailroom(ut_params->ibuf));
11773 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11775 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11777 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11779 trn_data += plaintext_len;
11781 buf = ut_params->ibuf;
11784 * Loop until no more fragments
11787 while (trn_data < tdata->plaintext.len) {
11789 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11790 (tdata->plaintext.len - trn_data) : fragsz;
11792 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11795 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11796 rte_pktmbuf_tailroom(buf));
11798 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11801 memcpy(plaintext, tdata->plaintext.data + trn_data,
11803 trn_data += to_trn;
11804 if (trn_data == tdata->plaintext.len)
11805 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11806 tdata->gmac_tag.len);
11808 ut_params->ibuf->nb_segs = segs;
11811 * Place digest at the end of the last buffer
11813 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11816 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11817 + tdata->gmac_tag.len);
11818 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11819 tdata->plaintext.len);
11822 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11823 tdata, digest_mem, digest_phys);
11828 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11830 ut_params->op->sym->m_src = ut_params->ibuf;
11832 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11833 return TEST_SKIPPED;
11835 TEST_ASSERT_NOT_NULL(
11836 process_crypto_request(ts_params->valid_devs[0],
11837 ut_params->op), "failed to process sym crypto op");
11839 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11840 "crypto op processing failed");
11842 auth_tag = digest_mem;
11843 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11844 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11846 tdata->gmac_tag.data,
11847 tdata->gmac_tag.len,
11848 "GMAC Generated auth tag not as expected");
11853 /* Segment size not multiple of block size (16B) */
11855 test_AES_GMAC_authentication_SGL_40B(void)
11857 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11861 test_AES_GMAC_authentication_SGL_80B(void)
11863 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11867 test_AES_GMAC_authentication_SGL_2048B(void)
11869 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11872 /* Segment size not multiple of block size (16B) */
11874 test_AES_GMAC_authentication_SGL_2047B(void)
11876 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11879 struct test_crypto_vector {
11880 enum rte_crypto_cipher_algorithm crypto_algo;
11881 unsigned int cipher_offset;
11882 unsigned int cipher_len;
11895 const uint8_t *data;
11900 const uint8_t *data;
11904 enum rte_crypto_auth_algorithm auth_algo;
11905 unsigned int auth_offset;
11913 const uint8_t *data;
11923 static const struct test_crypto_vector
11924 hmac_sha1_test_crypto_vector = {
11925 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11927 .data = plaintext_hash,
11932 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11933 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11934 0xDE, 0xF4, 0xDE, 0xAD
11940 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11941 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11942 0x3F, 0x91, 0x64, 0x59
11948 static const struct test_crypto_vector
11949 aes128_gmac_test_vector = {
11950 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11952 .data = plaintext_hash,
11957 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11958 0x08, 0x09, 0x0A, 0x0B
11964 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11965 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11971 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11972 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11978 static const struct test_crypto_vector
11979 aes128cbc_hmac_sha1_test_vector = {
11980 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11981 .cipher_offset = 0,
11985 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11986 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11992 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11993 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11998 .data = plaintext_hash,
12002 .data = ciphertext512_aes128cbc,
12005 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12009 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12010 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12011 0xDE, 0xF4, 0xDE, 0xAD
12017 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12018 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12019 0x18, 0x8C, 0x1D, 0x32
12025 static const struct test_crypto_vector
12026 aes128cbc_hmac_sha1_aad_test_vector = {
12027 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12028 .cipher_offset = 8,
12032 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12033 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12039 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12040 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12045 .data = plaintext_hash,
12049 .data = ciphertext512_aes128cbc_aad,
12052 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12056 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12057 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12058 0xDE, 0xF4, 0xDE, 0xAD
12064 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12065 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12066 0x62, 0x0F, 0xFB, 0x10
12073 data_corruption(uint8_t *data)
12079 tag_corruption(uint8_t *data, unsigned int tag_offset)
12081 data[tag_offset] += 1;
12085 create_auth_session(struct crypto_unittest_params *ut_params,
12087 const struct test_crypto_vector *reference,
12088 enum rte_crypto_auth_operation auth_op)
12090 struct crypto_testsuite_params *ts_params = &testsuite_params;
12091 uint8_t auth_key[reference->auth_key.len + 1];
12093 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12095 /* Setup Authentication Parameters */
12096 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12097 ut_params->auth_xform.auth.op = auth_op;
12098 ut_params->auth_xform.next = NULL;
12099 ut_params->auth_xform.auth.algo = reference->auth_algo;
12100 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12101 ut_params->auth_xform.auth.key.data = auth_key;
12102 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12104 /* Create Crypto session*/
12105 ut_params->sess = rte_cryptodev_sym_session_create(
12106 ts_params->session_mpool);
12108 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12109 &ut_params->auth_xform,
12110 ts_params->session_priv_mpool);
12112 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12118 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12120 const struct test_crypto_vector *reference,
12121 enum rte_crypto_auth_operation auth_op,
12122 enum rte_crypto_cipher_operation cipher_op)
12124 struct crypto_testsuite_params *ts_params = &testsuite_params;
12125 uint8_t cipher_key[reference->cipher_key.len + 1];
12126 uint8_t auth_key[reference->auth_key.len + 1];
12128 memcpy(cipher_key, reference->cipher_key.data,
12129 reference->cipher_key.len);
12130 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12132 /* Setup Authentication Parameters */
12133 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12134 ut_params->auth_xform.auth.op = auth_op;
12135 ut_params->auth_xform.auth.algo = reference->auth_algo;
12136 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12137 ut_params->auth_xform.auth.key.data = auth_key;
12138 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12140 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12141 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12142 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12144 ut_params->auth_xform.next = &ut_params->cipher_xform;
12146 /* Setup Cipher Parameters */
12147 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12148 ut_params->cipher_xform.next = NULL;
12149 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12150 ut_params->cipher_xform.cipher.op = cipher_op;
12151 ut_params->cipher_xform.cipher.key.data = cipher_key;
12152 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12153 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12154 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12157 /* Create Crypto session*/
12158 ut_params->sess = rte_cryptodev_sym_session_create(
12159 ts_params->session_mpool);
12161 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12162 &ut_params->auth_xform,
12163 ts_params->session_priv_mpool);
12165 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12171 create_auth_operation(struct crypto_testsuite_params *ts_params,
12172 struct crypto_unittest_params *ut_params,
12173 const struct test_crypto_vector *reference,
12174 unsigned int auth_generate)
12176 /* Generate Crypto op data structure */
12177 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12178 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12179 TEST_ASSERT_NOT_NULL(ut_params->op,
12180 "Failed to allocate pktmbuf offload");
12182 /* Set crypto operation data parameters */
12183 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12185 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12187 /* set crypto operation source mbuf */
12188 sym_op->m_src = ut_params->ibuf;
12191 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12192 ut_params->ibuf, reference->digest.len);
12194 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12195 "no room to append auth tag");
12197 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12198 ut_params->ibuf, reference->plaintext.len);
12201 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12203 memcpy(sym_op->auth.digest.data,
12204 reference->digest.data,
12205 reference->digest.len);
12207 debug_hexdump(stdout, "digest:",
12208 sym_op->auth.digest.data,
12209 reference->digest.len);
12211 sym_op->auth.data.length = reference->plaintext.len;
12212 sym_op->auth.data.offset = 0;
12218 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12219 struct crypto_unittest_params *ut_params,
12220 const struct test_crypto_vector *reference,
12221 unsigned int auth_generate)
12223 /* Generate Crypto op data structure */
12224 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12225 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12226 TEST_ASSERT_NOT_NULL(ut_params->op,
12227 "Failed to allocate pktmbuf offload");
12229 /* Set crypto operation data parameters */
12230 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12232 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12234 /* set crypto operation source mbuf */
12235 sym_op->m_src = ut_params->ibuf;
12238 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12239 ut_params->ibuf, reference->digest.len);
12241 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12242 "no room to append auth tag");
12244 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12245 ut_params->ibuf, reference->ciphertext.len);
12248 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12250 memcpy(sym_op->auth.digest.data,
12251 reference->digest.data,
12252 reference->digest.len);
12254 debug_hexdump(stdout, "digest:",
12255 sym_op->auth.digest.data,
12256 reference->digest.len);
12258 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12259 reference->iv.data, reference->iv.len);
12261 sym_op->cipher.data.length = 0;
12262 sym_op->cipher.data.offset = 0;
12264 sym_op->auth.data.length = reference->plaintext.len;
12265 sym_op->auth.data.offset = 0;
12271 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12272 struct crypto_unittest_params *ut_params,
12273 const struct test_crypto_vector *reference,
12274 unsigned int auth_generate)
12276 /* Generate Crypto op data structure */
12277 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12278 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12279 TEST_ASSERT_NOT_NULL(ut_params->op,
12280 "Failed to allocate pktmbuf offload");
12282 /* Set crypto operation data parameters */
12283 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12285 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12287 /* set crypto operation source mbuf */
12288 sym_op->m_src = ut_params->ibuf;
12291 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12292 ut_params->ibuf, reference->digest.len);
12294 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12295 "no room to append auth tag");
12297 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12298 ut_params->ibuf, reference->ciphertext.len);
12301 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12303 memcpy(sym_op->auth.digest.data,
12304 reference->digest.data,
12305 reference->digest.len);
12307 debug_hexdump(stdout, "digest:",
12308 sym_op->auth.digest.data,
12309 reference->digest.len);
12311 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12312 reference->iv.data, reference->iv.len);
12314 sym_op->cipher.data.length = reference->cipher_len;
12315 sym_op->cipher.data.offset = reference->cipher_offset;
12317 sym_op->auth.data.length = reference->plaintext.len;
12318 sym_op->auth.data.offset = reference->auth_offset;
12324 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12325 struct crypto_unittest_params *ut_params,
12326 const struct test_crypto_vector *reference)
12328 return create_auth_operation(ts_params, ut_params, reference, 0);
12332 create_auth_verify_GMAC_operation(
12333 struct crypto_testsuite_params *ts_params,
12334 struct crypto_unittest_params *ut_params,
12335 const struct test_crypto_vector *reference)
12337 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12341 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12342 struct crypto_unittest_params *ut_params,
12343 const struct test_crypto_vector *reference)
12345 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12349 test_authentication_verify_fail_when_data_corruption(
12350 struct crypto_testsuite_params *ts_params,
12351 struct crypto_unittest_params *ut_params,
12352 const struct test_crypto_vector *reference,
12353 unsigned int data_corrupted)
12357 uint8_t *plaintext;
12358 struct rte_cryptodev_info dev_info;
12360 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12361 uint64_t feat_flags = dev_info.feature_flags;
12363 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12364 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12365 printf("Device doesn't support RAW data-path APIs.\n");
12366 return TEST_SKIPPED;
12369 /* Verify the capabilities */
12370 struct rte_cryptodev_sym_capability_idx cap_idx;
12371 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12372 cap_idx.algo.auth = reference->auth_algo;
12373 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12375 return TEST_SKIPPED;
12378 /* Create session */
12379 retval = create_auth_session(ut_params,
12380 ts_params->valid_devs[0],
12382 RTE_CRYPTO_AUTH_OP_VERIFY);
12386 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12387 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12388 "Failed to allocate input buffer in mempool");
12390 /* clear mbuf payload */
12391 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12392 rte_pktmbuf_tailroom(ut_params->ibuf));
12394 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12395 reference->plaintext.len);
12396 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12397 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12399 debug_hexdump(stdout, "plaintext:", plaintext,
12400 reference->plaintext.len);
12402 /* Create operation */
12403 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12408 if (data_corrupted)
12409 data_corruption(plaintext);
12411 tag_corruption(plaintext, reference->plaintext.len);
12413 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12414 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12416 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12417 RTE_CRYPTO_OP_STATUS_SUCCESS,
12418 "authentication not failed");
12419 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12420 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12421 ut_params->op, 0, 1, 0, 0);
12423 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12425 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12432 test_authentication_verify_GMAC_fail_when_corruption(
12433 struct crypto_testsuite_params *ts_params,
12434 struct crypto_unittest_params *ut_params,
12435 const struct test_crypto_vector *reference,
12436 unsigned int data_corrupted)
12439 uint8_t *plaintext;
12440 struct rte_cryptodev_info dev_info;
12442 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12443 uint64_t feat_flags = dev_info.feature_flags;
12445 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12446 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12447 printf("Device doesn't support RAW data-path APIs.\n");
12448 return TEST_SKIPPED;
12451 /* Verify the capabilities */
12452 struct rte_cryptodev_sym_capability_idx cap_idx;
12453 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12454 cap_idx.algo.auth = reference->auth_algo;
12455 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12457 return TEST_SKIPPED;
12459 /* Create session */
12460 retval = create_auth_cipher_session(ut_params,
12461 ts_params->valid_devs[0],
12463 RTE_CRYPTO_AUTH_OP_VERIFY,
12464 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12468 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12469 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12470 "Failed to allocate input buffer in mempool");
12472 /* clear mbuf payload */
12473 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12474 rte_pktmbuf_tailroom(ut_params->ibuf));
12476 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12477 reference->plaintext.len);
12478 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12479 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12481 debug_hexdump(stdout, "plaintext:", plaintext,
12482 reference->plaintext.len);
12484 /* Create operation */
12485 retval = create_auth_verify_GMAC_operation(ts_params,
12492 if (data_corrupted)
12493 data_corruption(plaintext);
12495 tag_corruption(plaintext, reference->aad.len);
12497 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12498 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12500 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12501 RTE_CRYPTO_OP_STATUS_SUCCESS,
12502 "authentication not failed");
12503 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12504 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12505 ut_params->op, 0, 1, 0, 0);
12507 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12509 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12516 test_authenticated_decryption_fail_when_corruption(
12517 struct crypto_testsuite_params *ts_params,
12518 struct crypto_unittest_params *ut_params,
12519 const struct test_crypto_vector *reference,
12520 unsigned int data_corrupted)
12524 uint8_t *ciphertext;
12525 struct rte_cryptodev_info dev_info;
12527 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12528 uint64_t feat_flags = dev_info.feature_flags;
12530 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12531 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12532 printf("Device doesn't support RAW data-path APIs.\n");
12533 return TEST_SKIPPED;
12536 /* Verify the capabilities */
12537 struct rte_cryptodev_sym_capability_idx cap_idx;
12538 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12539 cap_idx.algo.auth = reference->auth_algo;
12540 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12542 return TEST_SKIPPED;
12543 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12544 cap_idx.algo.cipher = reference->crypto_algo;
12545 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12547 return TEST_SKIPPED;
12549 /* Create session */
12550 retval = create_auth_cipher_session(ut_params,
12551 ts_params->valid_devs[0],
12553 RTE_CRYPTO_AUTH_OP_VERIFY,
12554 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12558 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12559 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12560 "Failed to allocate input buffer in mempool");
12562 /* clear mbuf payload */
12563 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12564 rte_pktmbuf_tailroom(ut_params->ibuf));
12566 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12567 reference->ciphertext.len);
12568 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12569 memcpy(ciphertext, reference->ciphertext.data,
12570 reference->ciphertext.len);
12572 /* Create operation */
12573 retval = create_cipher_auth_verify_operation(ts_params,
12580 if (data_corrupted)
12581 data_corruption(ciphertext);
12583 tag_corruption(ciphertext, reference->ciphertext.len);
12585 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12586 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12588 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12589 RTE_CRYPTO_OP_STATUS_SUCCESS,
12590 "authentication not failed");
12591 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12592 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12593 ut_params->op, 1, 1, 0, 0);
12595 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12597 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12604 test_authenticated_encryt_with_esn(
12605 struct crypto_testsuite_params *ts_params,
12606 struct crypto_unittest_params *ut_params,
12607 const struct test_crypto_vector *reference)
12611 uint8_t *authciphertext, *plaintext, *auth_tag;
12612 uint16_t plaintext_pad_len;
12613 uint8_t cipher_key[reference->cipher_key.len + 1];
12614 uint8_t auth_key[reference->auth_key.len + 1];
12615 struct rte_cryptodev_info dev_info;
12617 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12618 uint64_t feat_flags = dev_info.feature_flags;
12620 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12621 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12622 printf("Device doesn't support RAW data-path APIs.\n");
12623 return TEST_SKIPPED;
12626 /* Verify the capabilities */
12627 struct rte_cryptodev_sym_capability_idx cap_idx;
12628 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12629 cap_idx.algo.auth = reference->auth_algo;
12630 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12632 return TEST_SKIPPED;
12633 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12634 cap_idx.algo.cipher = reference->crypto_algo;
12635 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12637 return TEST_SKIPPED;
12639 /* Create session */
12640 memcpy(cipher_key, reference->cipher_key.data,
12641 reference->cipher_key.len);
12642 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12644 /* Setup Cipher Parameters */
12645 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12646 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12647 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12648 ut_params->cipher_xform.cipher.key.data = cipher_key;
12649 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12650 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12651 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12653 ut_params->cipher_xform.next = &ut_params->auth_xform;
12655 /* Setup Authentication Parameters */
12656 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12657 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12658 ut_params->auth_xform.auth.algo = reference->auth_algo;
12659 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12660 ut_params->auth_xform.auth.key.data = auth_key;
12661 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12662 ut_params->auth_xform.next = NULL;
12664 /* Create Crypto session*/
12665 ut_params->sess = rte_cryptodev_sym_session_create(
12666 ts_params->session_mpool);
12668 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12670 &ut_params->cipher_xform,
12671 ts_params->session_priv_mpool);
12673 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12675 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12676 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12677 "Failed to allocate input buffer in mempool");
12679 /* clear mbuf payload */
12680 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12681 rte_pktmbuf_tailroom(ut_params->ibuf));
12683 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12684 reference->plaintext.len);
12685 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12686 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12688 /* Create operation */
12689 retval = create_cipher_auth_operation(ts_params,
12696 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12697 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12699 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12700 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12701 ut_params->op, 1, 1, 0, 0);
12703 ut_params->op = process_crypto_request(
12704 ts_params->valid_devs[0], ut_params->op);
12706 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12708 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12709 "crypto op processing failed");
12711 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12713 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12714 ut_params->op->sym->auth.data.offset);
12715 auth_tag = authciphertext + plaintext_pad_len;
12716 debug_hexdump(stdout, "ciphertext:", authciphertext,
12717 reference->ciphertext.len);
12718 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12720 /* Validate obuf */
12721 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12723 reference->ciphertext.data,
12724 reference->ciphertext.len,
12725 "Ciphertext data not as expected");
12727 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12729 reference->digest.data,
12730 reference->digest.len,
12731 "Generated digest not as expected");
12733 return TEST_SUCCESS;
12738 test_authenticated_decrypt_with_esn(
12739 struct crypto_testsuite_params *ts_params,
12740 struct crypto_unittest_params *ut_params,
12741 const struct test_crypto_vector *reference)
12745 uint8_t *ciphertext;
12746 uint8_t cipher_key[reference->cipher_key.len + 1];
12747 uint8_t auth_key[reference->auth_key.len + 1];
12748 struct rte_cryptodev_info dev_info;
12750 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12751 uint64_t feat_flags = dev_info.feature_flags;
12753 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12754 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12755 printf("Device doesn't support RAW data-path APIs.\n");
12756 return TEST_SKIPPED;
12759 /* Verify the capabilities */
12760 struct rte_cryptodev_sym_capability_idx cap_idx;
12761 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12762 cap_idx.algo.auth = reference->auth_algo;
12763 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12765 return TEST_SKIPPED;
12766 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12767 cap_idx.algo.cipher = reference->crypto_algo;
12768 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12770 return TEST_SKIPPED;
12772 /* Create session */
12773 memcpy(cipher_key, reference->cipher_key.data,
12774 reference->cipher_key.len);
12775 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12777 /* Setup Authentication Parameters */
12778 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12779 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12780 ut_params->auth_xform.auth.algo = reference->auth_algo;
12781 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12782 ut_params->auth_xform.auth.key.data = auth_key;
12783 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12784 ut_params->auth_xform.next = &ut_params->cipher_xform;
12786 /* Setup Cipher Parameters */
12787 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12788 ut_params->cipher_xform.next = NULL;
12789 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12790 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12791 ut_params->cipher_xform.cipher.key.data = cipher_key;
12792 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12793 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12794 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12796 /* Create Crypto session*/
12797 ut_params->sess = rte_cryptodev_sym_session_create(
12798 ts_params->session_mpool);
12800 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12802 &ut_params->auth_xform,
12803 ts_params->session_priv_mpool);
12805 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12807 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12808 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12809 "Failed to allocate input buffer in mempool");
12811 /* clear mbuf payload */
12812 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12813 rte_pktmbuf_tailroom(ut_params->ibuf));
12815 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12816 reference->ciphertext.len);
12817 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12818 memcpy(ciphertext, reference->ciphertext.data,
12819 reference->ciphertext.len);
12821 /* Create operation */
12822 retval = create_cipher_auth_verify_operation(ts_params,
12829 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12830 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12832 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12833 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12834 ut_params->op, 1, 1, 0, 0);
12836 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12839 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12840 TEST_ASSERT_EQUAL(ut_params->op->status,
12841 RTE_CRYPTO_OP_STATUS_SUCCESS,
12842 "crypto op processing passed");
12844 ut_params->obuf = ut_params->op->sym->m_src;
12845 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12851 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12852 const struct aead_test_data *tdata,
12853 void *digest_mem, uint64_t digest_phys)
12855 struct crypto_testsuite_params *ts_params = &testsuite_params;
12856 struct crypto_unittest_params *ut_params = &unittest_params;
12858 const unsigned int auth_tag_len = tdata->auth_tag.len;
12859 const unsigned int iv_len = tdata->iv.len;
12860 unsigned int aad_len = tdata->aad.len;
12861 unsigned int aad_len_pad = 0;
12863 /* Generate Crypto op data structure */
12864 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12865 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12866 TEST_ASSERT_NOT_NULL(ut_params->op,
12867 "Failed to allocate symmetric crypto operation struct");
12869 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12871 sym_op->aead.digest.data = digest_mem;
12873 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12874 "no room to append digest");
12876 sym_op->aead.digest.phys_addr = digest_phys;
12878 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12879 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12881 debug_hexdump(stdout, "digest:",
12882 sym_op->aead.digest.data,
12886 /* Append aad data */
12887 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12888 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12889 uint8_t *, IV_OFFSET);
12891 /* Copy IV 1 byte after the IV pointer, according to the API */
12892 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12894 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12896 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12897 ut_params->ibuf, aad_len);
12898 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12899 "no room to prepend aad");
12900 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12903 memset(sym_op->aead.aad.data, 0, aad_len);
12904 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12905 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12907 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12908 debug_hexdump(stdout, "aad:",
12909 sym_op->aead.aad.data, aad_len);
12911 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12912 uint8_t *, IV_OFFSET);
12914 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12916 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12918 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12919 ut_params->ibuf, aad_len_pad);
12920 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12921 "no room to prepend aad");
12922 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12925 memset(sym_op->aead.aad.data, 0, aad_len);
12926 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12928 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12929 debug_hexdump(stdout, "aad:",
12930 sym_op->aead.aad.data, aad_len);
12933 sym_op->aead.data.length = tdata->plaintext.len;
12934 sym_op->aead.data.offset = aad_len_pad;
12939 #define SGL_MAX_NO 16
12942 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12943 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12945 struct crypto_testsuite_params *ts_params = &testsuite_params;
12946 struct crypto_unittest_params *ut_params = &unittest_params;
12947 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12950 int to_trn_tbl[SGL_MAX_NO];
12952 unsigned int trn_data = 0;
12953 uint8_t *plaintext, *ciphertext, *auth_tag;
12954 struct rte_cryptodev_info dev_info;
12956 /* Verify the capabilities */
12957 struct rte_cryptodev_sym_capability_idx cap_idx;
12958 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12959 cap_idx.algo.aead = tdata->algo;
12960 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12962 return TEST_SKIPPED;
12964 /* OOP not supported with CPU crypto */
12965 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12966 return TEST_SKIPPED;
12968 /* Detailed check for the particular SGL support flag */
12969 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12971 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12972 if (sgl_in && (!(dev_info.feature_flags &
12973 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12974 return TEST_SKIPPED;
12976 uint64_t feat_flags = dev_info.feature_flags;
12978 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12979 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12980 printf("Device doesn't support RAW data-path APIs.\n");
12981 return TEST_SKIPPED;
12984 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12985 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12986 tdata->plaintext.len;
12987 /* Raw data path API does not support OOP */
12988 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12989 return TEST_SKIPPED;
12990 if (sgl_in && !sgl_out) {
12991 if (!(dev_info.feature_flags &
12992 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12993 return TEST_SKIPPED;
12994 } else if (!sgl_in && sgl_out) {
12995 if (!(dev_info.feature_flags &
12996 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12997 return TEST_SKIPPED;
12998 } else if (sgl_in && sgl_out) {
12999 if (!(dev_info.feature_flags &
13000 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13001 return TEST_SKIPPED;
13005 if (fragsz > tdata->plaintext.len)
13006 fragsz = tdata->plaintext.len;
13008 uint16_t plaintext_len = fragsz;
13009 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13011 if (fragsz_oop > tdata->plaintext.len)
13012 frag_size_oop = tdata->plaintext.len;
13015 void *digest_mem = NULL;
13017 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13019 if (tdata->plaintext.len % fragsz != 0) {
13020 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13023 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13028 * For out-op-place we need to alloc another mbuf
13031 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13032 rte_pktmbuf_append(ut_params->obuf,
13033 frag_size_oop + prepend_len);
13034 buf_oop = ut_params->obuf;
13037 /* Create AEAD session */
13038 retval = create_aead_session(ts_params->valid_devs[0],
13040 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13041 tdata->key.data, tdata->key.len,
13042 tdata->aad.len, tdata->auth_tag.len,
13047 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13049 /* clear mbuf payload */
13050 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13051 rte_pktmbuf_tailroom(ut_params->ibuf));
13053 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13056 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13058 trn_data += plaintext_len;
13060 buf = ut_params->ibuf;
13063 * Loop until no more fragments
13066 while (trn_data < tdata->plaintext.len) {
13068 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13069 (tdata->plaintext.len - trn_data) : fragsz;
13071 to_trn_tbl[ecx++] = to_trn;
13073 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13076 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13077 rte_pktmbuf_tailroom(buf));
13080 if (oop && !fragsz_oop) {
13081 buf_last_oop = buf_oop->next =
13082 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13083 buf_oop = buf_oop->next;
13084 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13085 0, rte_pktmbuf_tailroom(buf_oop));
13086 rte_pktmbuf_append(buf_oop, to_trn);
13089 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13092 memcpy(plaintext, tdata->plaintext.data + trn_data,
13094 trn_data += to_trn;
13095 if (trn_data == tdata->plaintext.len) {
13098 digest_mem = rte_pktmbuf_append(buf_oop,
13099 tdata->auth_tag.len);
13101 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13102 tdata->auth_tag.len);
13106 uint64_t digest_phys = 0;
13108 ut_params->ibuf->nb_segs = segs;
13111 if (fragsz_oop && oop) {
13115 if (frag_size_oop == tdata->plaintext.len) {
13116 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13117 tdata->auth_tag.len);
13119 digest_phys = rte_pktmbuf_iova_offset(
13121 tdata->plaintext.len + prepend_len);
13124 trn_data = frag_size_oop;
13125 while (trn_data < tdata->plaintext.len) {
13128 (tdata->plaintext.len - trn_data <
13130 (tdata->plaintext.len - trn_data) :
13133 to_trn_tbl[ecx++] = to_trn;
13135 buf_last_oop = buf_oop->next =
13136 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13137 buf_oop = buf_oop->next;
13138 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13139 0, rte_pktmbuf_tailroom(buf_oop));
13140 rte_pktmbuf_append(buf_oop, to_trn);
13142 trn_data += to_trn;
13144 if (trn_data == tdata->plaintext.len) {
13145 digest_mem = rte_pktmbuf_append(buf_oop,
13146 tdata->auth_tag.len);
13150 ut_params->obuf->nb_segs = segs;
13154 * Place digest at the end of the last buffer
13157 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13158 if (oop && buf_last_oop)
13159 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13161 if (!digest_mem && !oop) {
13162 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13163 + tdata->auth_tag.len);
13164 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13165 tdata->plaintext.len);
13168 /* Create AEAD operation */
13169 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13170 tdata, digest_mem, digest_phys);
13175 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13177 ut_params->op->sym->m_src = ut_params->ibuf;
13179 ut_params->op->sym->m_dst = ut_params->obuf;
13181 /* Process crypto operation */
13182 if (oop == IN_PLACE &&
13183 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13184 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13185 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13186 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13187 ut_params->op, 0, 0, 0, 0);
13189 TEST_ASSERT_NOT_NULL(
13190 process_crypto_request(ts_params->valid_devs[0],
13191 ut_params->op), "failed to process sym crypto op");
13193 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13194 "crypto op processing failed");
13197 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13198 uint8_t *, prepend_len);
13200 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13201 uint8_t *, prepend_len);
13205 fragsz = fragsz_oop;
13207 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13209 tdata->ciphertext.data,
13211 "Ciphertext data not as expected");
13213 buf = ut_params->op->sym->m_src->next;
13215 buf = ut_params->op->sym->m_dst->next;
13217 unsigned int off = fragsz;
13221 ciphertext = rte_pktmbuf_mtod(buf,
13224 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13226 tdata->ciphertext.data + off,
13228 "Ciphertext data not as expected");
13230 off += to_trn_tbl[ecx++];
13234 auth_tag = digest_mem;
13235 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13237 tdata->auth_tag.data,
13238 tdata->auth_tag.len,
13239 "Generated auth tag not as expected");
13245 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13247 return test_authenticated_encryption_SGL(
13248 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13252 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13254 return test_authenticated_encryption_SGL(
13255 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13259 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13261 return test_authenticated_encryption_SGL(
13262 &gcm_test_case_8, OUT_OF_PLACE, 400,
13263 gcm_test_case_8.plaintext.len);
13267 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13269 /* This test is not for OPENSSL PMD */
13270 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13271 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13272 return TEST_SKIPPED;
13274 return test_authenticated_encryption_SGL(
13275 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13279 test_authentication_verify_fail_when_data_corrupted(
13280 struct crypto_testsuite_params *ts_params,
13281 struct crypto_unittest_params *ut_params,
13282 const struct test_crypto_vector *reference)
13284 return test_authentication_verify_fail_when_data_corruption(
13285 ts_params, ut_params, reference, 1);
13289 test_authentication_verify_fail_when_tag_corrupted(
13290 struct crypto_testsuite_params *ts_params,
13291 struct crypto_unittest_params *ut_params,
13292 const struct test_crypto_vector *reference)
13294 return test_authentication_verify_fail_when_data_corruption(
13295 ts_params, ut_params, reference, 0);
13299 test_authentication_verify_GMAC_fail_when_data_corrupted(
13300 struct crypto_testsuite_params *ts_params,
13301 struct crypto_unittest_params *ut_params,
13302 const struct test_crypto_vector *reference)
13304 return test_authentication_verify_GMAC_fail_when_corruption(
13305 ts_params, ut_params, reference, 1);
13309 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13310 struct crypto_testsuite_params *ts_params,
13311 struct crypto_unittest_params *ut_params,
13312 const struct test_crypto_vector *reference)
13314 return test_authentication_verify_GMAC_fail_when_corruption(
13315 ts_params, ut_params, reference, 0);
13319 test_authenticated_decryption_fail_when_data_corrupted(
13320 struct crypto_testsuite_params *ts_params,
13321 struct crypto_unittest_params *ut_params,
13322 const struct test_crypto_vector *reference)
13324 return test_authenticated_decryption_fail_when_corruption(
13325 ts_params, ut_params, reference, 1);
13329 test_authenticated_decryption_fail_when_tag_corrupted(
13330 struct crypto_testsuite_params *ts_params,
13331 struct crypto_unittest_params *ut_params,
13332 const struct test_crypto_vector *reference)
13334 return test_authenticated_decryption_fail_when_corruption(
13335 ts_params, ut_params, reference, 0);
13339 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13341 return test_authentication_verify_fail_when_data_corrupted(
13342 &testsuite_params, &unittest_params,
13343 &hmac_sha1_test_crypto_vector);
13347 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13349 return test_authentication_verify_fail_when_tag_corrupted(
13350 &testsuite_params, &unittest_params,
13351 &hmac_sha1_test_crypto_vector);
13355 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13357 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13358 &testsuite_params, &unittest_params,
13359 &aes128_gmac_test_vector);
13363 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13365 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13366 &testsuite_params, &unittest_params,
13367 &aes128_gmac_test_vector);
13371 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13373 return test_authenticated_decryption_fail_when_data_corrupted(
13376 &aes128cbc_hmac_sha1_test_vector);
13380 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13382 return test_authenticated_decryption_fail_when_tag_corrupted(
13385 &aes128cbc_hmac_sha1_test_vector);
13389 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13391 return test_authenticated_encryt_with_esn(
13394 &aes128cbc_hmac_sha1_aad_test_vector);
13398 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13400 return test_authenticated_decrypt_with_esn(
13403 &aes128cbc_hmac_sha1_aad_test_vector);
13407 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13409 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13413 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13415 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13418 #ifdef RTE_CRYPTO_SCHEDULER
13420 /* global AESNI worker IDs for the scheduler test */
13421 uint8_t aesni_ids[2];
13424 scheduler_testsuite_setup(void)
13427 int32_t nb_devs, ret;
13428 char vdev_args[VDEV_ARGS_SIZE] = {""};
13429 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
13430 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
13431 uint16_t worker_core_count = 0;
13432 uint16_t socket_id = 0;
13434 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13435 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
13437 /* Identify the Worker Cores
13438 * Use 2 worker cores for the device args
13440 RTE_LCORE_FOREACH_WORKER(i) {
13441 if (worker_core_count > 1)
13443 snprintf(vdev_args, sizeof(vdev_args),
13444 "%s%d", temp_str, i);
13445 strcpy(temp_str, vdev_args);
13446 strlcat(temp_str, ";", sizeof(temp_str));
13447 worker_core_count++;
13448 socket_id = rte_lcore_to_socket_id(i);
13450 if (worker_core_count != 2) {
13451 RTE_LOG(ERR, USER1,
13452 "Cryptodev scheduler test require at least "
13453 "two worker cores to run. "
13454 "Please use the correct coremask.\n");
13455 return TEST_FAILED;
13457 strcpy(temp_str, vdev_args);
13458 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
13459 temp_str, socket_id);
13460 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
13461 nb_devs = rte_cryptodev_device_count_by_driver(
13462 rte_cryptodev_driver_id_get(
13463 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
13465 ret = rte_vdev_init(
13466 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
13468 TEST_ASSERT(ret == 0,
13469 "Failed to create instance %u of pmd : %s",
13470 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13473 return testsuite_setup();
13477 test_scheduler_attach_slave_op(void)
13479 struct crypto_testsuite_params *ts_params = &testsuite_params;
13480 uint8_t sched_id = ts_params->valid_devs[0];
13481 uint32_t nb_devs, i, nb_devs_attached = 0;
13483 char vdev_name[32];
13485 /* create 2 AESNI_MB if necessary */
13486 nb_devs = rte_cryptodev_device_count_by_driver(
13487 rte_cryptodev_driver_id_get(
13488 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13490 for (i = nb_devs; i < 2; i++) {
13491 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13492 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13494 ret = rte_vdev_init(vdev_name, NULL);
13496 TEST_ASSERT(ret == 0,
13497 "Failed to create instance %u of"
13499 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13503 /* attach 2 AESNI_MB cdevs */
13504 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13506 struct rte_cryptodev_info info;
13507 unsigned int session_size;
13509 rte_cryptodev_info_get(i, &info);
13510 if (info.driver_id != rte_cryptodev_driver_id_get(
13511 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13514 session_size = rte_cryptodev_sym_get_private_session_size(i);
13516 * Create the session mempool again, since now there are new devices
13517 * to use the mempool.
13519 if (ts_params->session_mpool) {
13520 rte_mempool_free(ts_params->session_mpool);
13521 ts_params->session_mpool = NULL;
13523 if (ts_params->session_priv_mpool) {
13524 rte_mempool_free(ts_params->session_priv_mpool);
13525 ts_params->session_priv_mpool = NULL;
13528 if (info.sym.max_nb_sessions != 0 &&
13529 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13530 RTE_LOG(ERR, USER1,
13531 "Device does not support "
13532 "at least %u sessions\n",
13534 return TEST_FAILED;
13537 * Create mempool with maximum number of sessions,
13538 * to include the session headers
13540 if (ts_params->session_mpool == NULL) {
13541 ts_params->session_mpool =
13542 rte_cryptodev_sym_session_pool_create(
13544 MAX_NB_SESSIONS, 0, 0, 0,
13546 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13547 "session mempool allocation failed");
13551 * Create mempool with maximum number of sessions,
13552 * to include device specific session private data
13554 if (ts_params->session_priv_mpool == NULL) {
13555 ts_params->session_priv_mpool = rte_mempool_create(
13556 "test_sess_mp_priv",
13559 0, 0, NULL, NULL, NULL,
13560 NULL, SOCKET_ID_ANY,
13563 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13564 "session mempool allocation failed");
13567 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13568 ts_params->qp_conf.mp_session_private =
13569 ts_params->session_priv_mpool;
13571 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13574 TEST_ASSERT(ret == 0,
13575 "Failed to attach device %u of pmd : %s", i,
13576 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13578 aesni_ids[nb_devs_attached] = (uint8_t)i;
13580 nb_devs_attached++;
13587 test_scheduler_detach_slave_op(void)
13589 struct crypto_testsuite_params *ts_params = &testsuite_params;
13590 uint8_t sched_id = ts_params->valid_devs[0];
13594 for (i = 0; i < 2; i++) {
13595 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13597 TEST_ASSERT(ret == 0,
13598 "Failed to detach device %u", aesni_ids[i]);
13605 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13607 struct crypto_testsuite_params *ts_params = &testsuite_params;
13608 uint8_t sched_id = ts_params->valid_devs[0];
13610 return rte_cryptodev_scheduler_mode_set(sched_id,
13615 test_scheduler_mode_roundrobin_op(void)
13617 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13618 0, "Failed to set roundrobin mode");
13624 test_scheduler_mode_multicore_op(void)
13626 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13627 0, "Failed to set multicore mode");
13633 test_scheduler_mode_failover_op(void)
13635 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13636 0, "Failed to set failover mode");
13642 test_scheduler_mode_pkt_size_distr_op(void)
13644 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13645 0, "Failed to set pktsize mode");
13651 scheduler_multicore_testsuite_setup(void)
13653 if (test_scheduler_attach_slave_op() < 0)
13654 return TEST_SKIPPED;
13655 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
13656 return TEST_SKIPPED;
13661 scheduler_roundrobin_testsuite_setup(void)
13663 if (test_scheduler_attach_slave_op() < 0)
13664 return TEST_SKIPPED;
13665 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
13666 return TEST_SKIPPED;
13671 scheduler_failover_testsuite_setup(void)
13673 if (test_scheduler_attach_slave_op() < 0)
13674 return TEST_SKIPPED;
13675 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
13676 return TEST_SKIPPED;
13681 scheduler_pkt_size_distr_testsuite_setup(void)
13683 if (test_scheduler_attach_slave_op() < 0)
13684 return TEST_SKIPPED;
13685 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
13686 return TEST_SKIPPED;
13691 scheduler_mode_testsuite_teardown(void)
13693 test_scheduler_detach_slave_op();
13696 #endif /* RTE_CRYPTO_SCHEDULER */
13698 static struct unit_test_suite end_testsuite = {
13699 .suite_name = NULL,
13702 .unit_test_suites = NULL
13705 #ifdef RTE_LIB_SECURITY
13706 static struct unit_test_suite pdcp_proto_testsuite = {
13707 .suite_name = "PDCP Proto Unit Test Suite",
13708 .setup = pdcp_proto_testsuite_setup,
13709 .unit_test_cases = {
13710 TEST_CASE_ST(ut_setup_security, ut_teardown,
13711 test_PDCP_PROTO_all),
13712 TEST_CASES_END() /**< NULL terminate unit test array */
13716 static struct unit_test_suite docsis_proto_testsuite = {
13717 .suite_name = "Docsis Proto Unit Test Suite",
13718 .setup = docsis_proto_testsuite_setup,
13719 .unit_test_cases = {
13720 TEST_CASE_ST(ut_setup_security, ut_teardown,
13721 test_DOCSIS_PROTO_all),
13722 TEST_CASES_END() /**< NULL terminate unit test array */
13727 static struct unit_test_suite cryptodev_gen_testsuite = {
13728 .suite_name = "Crypto General Unit Test Suite",
13729 .setup = crypto_gen_testsuite_setup,
13730 .unit_test_cases = {
13731 TEST_CASE_ST(ut_setup, ut_teardown,
13732 test_device_configure_invalid_dev_id),
13733 TEST_CASE_ST(ut_setup, ut_teardown,
13734 test_queue_pair_descriptor_setup),
13735 TEST_CASE_ST(ut_setup, ut_teardown,
13736 test_device_configure_invalid_queue_pair_ids),
13737 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13738 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13739 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13740 TEST_CASES_END() /**< NULL terminate unit test array */
13744 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
13745 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
13746 .setup = negative_hmac_sha1_testsuite_setup,
13747 .unit_test_cases = {
13748 /** Negative tests */
13749 TEST_CASE_ST(ut_setup, ut_teardown,
13750 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13751 TEST_CASE_ST(ut_setup, ut_teardown,
13752 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13753 TEST_CASE_ST(ut_setup, ut_teardown,
13754 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13755 TEST_CASE_ST(ut_setup, ut_teardown,
13756 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13758 TEST_CASES_END() /**< NULL terminate unit test array */
13762 static struct unit_test_suite cryptodev_multi_session_testsuite = {
13763 .suite_name = "Multi Session Unit Test Suite",
13764 .setup = multi_session_testsuite_setup,
13765 .unit_test_cases = {
13766 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13767 TEST_CASE_ST(ut_setup, ut_teardown,
13768 test_multi_session_random_usage),
13770 TEST_CASES_END() /**< NULL terminate unit test array */
13774 static struct unit_test_suite cryptodev_null_testsuite = {
13775 .suite_name = "NULL Test Suite",
13776 .setup = null_testsuite_setup,
13777 .unit_test_cases = {
13778 TEST_CASE_ST(ut_setup, ut_teardown,
13779 test_null_invalid_operation),
13780 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13785 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
13786 .suite_name = "AES CCM Authenticated Test Suite",
13787 .setup = aes_ccm_auth_testsuite_setup,
13788 .unit_test_cases = {
13789 /** AES CCM Authenticated Encryption 128 bits key*/
13790 TEST_CASE_ST(ut_setup, ut_teardown,
13791 test_AES_CCM_authenticated_encryption_test_case_128_1),
13792 TEST_CASE_ST(ut_setup, ut_teardown,
13793 test_AES_CCM_authenticated_encryption_test_case_128_2),
13794 TEST_CASE_ST(ut_setup, ut_teardown,
13795 test_AES_CCM_authenticated_encryption_test_case_128_3),
13797 /** AES CCM Authenticated Decryption 128 bits key*/
13798 TEST_CASE_ST(ut_setup, ut_teardown,
13799 test_AES_CCM_authenticated_decryption_test_case_128_1),
13800 TEST_CASE_ST(ut_setup, ut_teardown,
13801 test_AES_CCM_authenticated_decryption_test_case_128_2),
13802 TEST_CASE_ST(ut_setup, ut_teardown,
13803 test_AES_CCM_authenticated_decryption_test_case_128_3),
13805 /** AES CCM Authenticated Encryption 192 bits key */
13806 TEST_CASE_ST(ut_setup, ut_teardown,
13807 test_AES_CCM_authenticated_encryption_test_case_192_1),
13808 TEST_CASE_ST(ut_setup, ut_teardown,
13809 test_AES_CCM_authenticated_encryption_test_case_192_2),
13810 TEST_CASE_ST(ut_setup, ut_teardown,
13811 test_AES_CCM_authenticated_encryption_test_case_192_3),
13813 /** AES CCM Authenticated Decryption 192 bits key*/
13814 TEST_CASE_ST(ut_setup, ut_teardown,
13815 test_AES_CCM_authenticated_decryption_test_case_192_1),
13816 TEST_CASE_ST(ut_setup, ut_teardown,
13817 test_AES_CCM_authenticated_decryption_test_case_192_2),
13818 TEST_CASE_ST(ut_setup, ut_teardown,
13819 test_AES_CCM_authenticated_decryption_test_case_192_3),
13821 /** AES CCM Authenticated Encryption 256 bits key */
13822 TEST_CASE_ST(ut_setup, ut_teardown,
13823 test_AES_CCM_authenticated_encryption_test_case_256_1),
13824 TEST_CASE_ST(ut_setup, ut_teardown,
13825 test_AES_CCM_authenticated_encryption_test_case_256_2),
13826 TEST_CASE_ST(ut_setup, ut_teardown,
13827 test_AES_CCM_authenticated_encryption_test_case_256_3),
13829 /** AES CCM Authenticated Decryption 256 bits key*/
13830 TEST_CASE_ST(ut_setup, ut_teardown,
13831 test_AES_CCM_authenticated_decryption_test_case_256_1),
13832 TEST_CASE_ST(ut_setup, ut_teardown,
13833 test_AES_CCM_authenticated_decryption_test_case_256_2),
13834 TEST_CASE_ST(ut_setup, ut_teardown,
13835 test_AES_CCM_authenticated_decryption_test_case_256_3),
13840 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
13841 .suite_name = "AES GCM Authenticated Test Suite",
13842 .setup = aes_gcm_auth_testsuite_setup,
13843 .unit_test_cases = {
13844 /** AES GCM Authenticated Encryption */
13845 TEST_CASE_ST(ut_setup, ut_teardown,
13846 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13847 TEST_CASE_ST(ut_setup, ut_teardown,
13848 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13849 TEST_CASE_ST(ut_setup, ut_teardown,
13850 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13851 TEST_CASE_ST(ut_setup, ut_teardown,
13852 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13853 TEST_CASE_ST(ut_setup, ut_teardown,
13854 test_AES_GCM_authenticated_encryption_test_case_1),
13855 TEST_CASE_ST(ut_setup, ut_teardown,
13856 test_AES_GCM_authenticated_encryption_test_case_2),
13857 TEST_CASE_ST(ut_setup, ut_teardown,
13858 test_AES_GCM_authenticated_encryption_test_case_3),
13859 TEST_CASE_ST(ut_setup, ut_teardown,
13860 test_AES_GCM_authenticated_encryption_test_case_4),
13861 TEST_CASE_ST(ut_setup, ut_teardown,
13862 test_AES_GCM_authenticated_encryption_test_case_5),
13863 TEST_CASE_ST(ut_setup, ut_teardown,
13864 test_AES_GCM_authenticated_encryption_test_case_6),
13865 TEST_CASE_ST(ut_setup, ut_teardown,
13866 test_AES_GCM_authenticated_encryption_test_case_7),
13867 TEST_CASE_ST(ut_setup, ut_teardown,
13868 test_AES_GCM_authenticated_encryption_test_case_8),
13869 TEST_CASE_ST(ut_setup, ut_teardown,
13870 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13872 /** AES GCM Authenticated Decryption */
13873 TEST_CASE_ST(ut_setup, ut_teardown,
13874 test_AES_GCM_authenticated_decryption_test_case_1),
13875 TEST_CASE_ST(ut_setup, ut_teardown,
13876 test_AES_GCM_authenticated_decryption_test_case_2),
13877 TEST_CASE_ST(ut_setup, ut_teardown,
13878 test_AES_GCM_authenticated_decryption_test_case_3),
13879 TEST_CASE_ST(ut_setup, ut_teardown,
13880 test_AES_GCM_authenticated_decryption_test_case_4),
13881 TEST_CASE_ST(ut_setup, ut_teardown,
13882 test_AES_GCM_authenticated_decryption_test_case_5),
13883 TEST_CASE_ST(ut_setup, ut_teardown,
13884 test_AES_GCM_authenticated_decryption_test_case_6),
13885 TEST_CASE_ST(ut_setup, ut_teardown,
13886 test_AES_GCM_authenticated_decryption_test_case_7),
13887 TEST_CASE_ST(ut_setup, ut_teardown,
13888 test_AES_GCM_authenticated_decryption_test_case_8),
13889 TEST_CASE_ST(ut_setup, ut_teardown,
13890 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13892 /** AES GCM Authenticated Encryption 192 bits key */
13893 TEST_CASE_ST(ut_setup, ut_teardown,
13894 test_AES_GCM_auth_encryption_test_case_192_1),
13895 TEST_CASE_ST(ut_setup, ut_teardown,
13896 test_AES_GCM_auth_encryption_test_case_192_2),
13897 TEST_CASE_ST(ut_setup, ut_teardown,
13898 test_AES_GCM_auth_encryption_test_case_192_3),
13899 TEST_CASE_ST(ut_setup, ut_teardown,
13900 test_AES_GCM_auth_encryption_test_case_192_4),
13901 TEST_CASE_ST(ut_setup, ut_teardown,
13902 test_AES_GCM_auth_encryption_test_case_192_5),
13903 TEST_CASE_ST(ut_setup, ut_teardown,
13904 test_AES_GCM_auth_encryption_test_case_192_6),
13905 TEST_CASE_ST(ut_setup, ut_teardown,
13906 test_AES_GCM_auth_encryption_test_case_192_7),
13908 /** AES GCM Authenticated Decryption 192 bits key */
13909 TEST_CASE_ST(ut_setup, ut_teardown,
13910 test_AES_GCM_auth_decryption_test_case_192_1),
13911 TEST_CASE_ST(ut_setup, ut_teardown,
13912 test_AES_GCM_auth_decryption_test_case_192_2),
13913 TEST_CASE_ST(ut_setup, ut_teardown,
13914 test_AES_GCM_auth_decryption_test_case_192_3),
13915 TEST_CASE_ST(ut_setup, ut_teardown,
13916 test_AES_GCM_auth_decryption_test_case_192_4),
13917 TEST_CASE_ST(ut_setup, ut_teardown,
13918 test_AES_GCM_auth_decryption_test_case_192_5),
13919 TEST_CASE_ST(ut_setup, ut_teardown,
13920 test_AES_GCM_auth_decryption_test_case_192_6),
13921 TEST_CASE_ST(ut_setup, ut_teardown,
13922 test_AES_GCM_auth_decryption_test_case_192_7),
13924 /** AES GCM Authenticated Encryption 256 bits key */
13925 TEST_CASE_ST(ut_setup, ut_teardown,
13926 test_AES_GCM_auth_encryption_test_case_256_1),
13927 TEST_CASE_ST(ut_setup, ut_teardown,
13928 test_AES_GCM_auth_encryption_test_case_256_2),
13929 TEST_CASE_ST(ut_setup, ut_teardown,
13930 test_AES_GCM_auth_encryption_test_case_256_3),
13931 TEST_CASE_ST(ut_setup, ut_teardown,
13932 test_AES_GCM_auth_encryption_test_case_256_4),
13933 TEST_CASE_ST(ut_setup, ut_teardown,
13934 test_AES_GCM_auth_encryption_test_case_256_5),
13935 TEST_CASE_ST(ut_setup, ut_teardown,
13936 test_AES_GCM_auth_encryption_test_case_256_6),
13937 TEST_CASE_ST(ut_setup, ut_teardown,
13938 test_AES_GCM_auth_encryption_test_case_256_7),
13940 /** AES GCM Authenticated Decryption 256 bits key */
13941 TEST_CASE_ST(ut_setup, ut_teardown,
13942 test_AES_GCM_auth_decryption_test_case_256_1),
13943 TEST_CASE_ST(ut_setup, ut_teardown,
13944 test_AES_GCM_auth_decryption_test_case_256_2),
13945 TEST_CASE_ST(ut_setup, ut_teardown,
13946 test_AES_GCM_auth_decryption_test_case_256_3),
13947 TEST_CASE_ST(ut_setup, ut_teardown,
13948 test_AES_GCM_auth_decryption_test_case_256_4),
13949 TEST_CASE_ST(ut_setup, ut_teardown,
13950 test_AES_GCM_auth_decryption_test_case_256_5),
13951 TEST_CASE_ST(ut_setup, ut_teardown,
13952 test_AES_GCM_auth_decryption_test_case_256_6),
13953 TEST_CASE_ST(ut_setup, ut_teardown,
13954 test_AES_GCM_auth_decryption_test_case_256_7),
13956 /** AES GCM Authenticated Encryption big aad size */
13957 TEST_CASE_ST(ut_setup, ut_teardown,
13958 test_AES_GCM_auth_encryption_test_case_aad_1),
13959 TEST_CASE_ST(ut_setup, ut_teardown,
13960 test_AES_GCM_auth_encryption_test_case_aad_2),
13962 /** AES GCM Authenticated Decryption big aad size */
13963 TEST_CASE_ST(ut_setup, ut_teardown,
13964 test_AES_GCM_auth_decryption_test_case_aad_1),
13965 TEST_CASE_ST(ut_setup, ut_teardown,
13966 test_AES_GCM_auth_decryption_test_case_aad_2),
13968 /** Out of place tests */
13969 TEST_CASE_ST(ut_setup, ut_teardown,
13970 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13971 TEST_CASE_ST(ut_setup, ut_teardown,
13972 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13974 /** Session-less tests */
13975 TEST_CASE_ST(ut_setup, ut_teardown,
13976 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13977 TEST_CASE_ST(ut_setup, ut_teardown,
13978 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13984 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
13985 .suite_name = "AES GMAC Authentication Test Suite",
13986 .setup = aes_gmac_auth_testsuite_setup,
13987 .unit_test_cases = {
13988 TEST_CASE_ST(ut_setup, ut_teardown,
13989 test_AES_GMAC_authentication_test_case_1),
13990 TEST_CASE_ST(ut_setup, ut_teardown,
13991 test_AES_GMAC_authentication_verify_test_case_1),
13992 TEST_CASE_ST(ut_setup, ut_teardown,
13993 test_AES_GMAC_authentication_test_case_2),
13994 TEST_CASE_ST(ut_setup, ut_teardown,
13995 test_AES_GMAC_authentication_verify_test_case_2),
13996 TEST_CASE_ST(ut_setup, ut_teardown,
13997 test_AES_GMAC_authentication_test_case_3),
13998 TEST_CASE_ST(ut_setup, ut_teardown,
13999 test_AES_GMAC_authentication_verify_test_case_3),
14000 TEST_CASE_ST(ut_setup, ut_teardown,
14001 test_AES_GMAC_authentication_test_case_4),
14002 TEST_CASE_ST(ut_setup, ut_teardown,
14003 test_AES_GMAC_authentication_verify_test_case_4),
14004 TEST_CASE_ST(ut_setup, ut_teardown,
14005 test_AES_GMAC_authentication_SGL_40B),
14006 TEST_CASE_ST(ut_setup, ut_teardown,
14007 test_AES_GMAC_authentication_SGL_80B),
14008 TEST_CASE_ST(ut_setup, ut_teardown,
14009 test_AES_GMAC_authentication_SGL_2048B),
14010 TEST_CASE_ST(ut_setup, ut_teardown,
14011 test_AES_GMAC_authentication_SGL_2047B),
14017 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14018 .suite_name = "Chacha20-Poly1305 Test Suite",
14019 .setup = chacha20_poly1305_testsuite_setup,
14020 .unit_test_cases = {
14021 TEST_CASE_ST(ut_setup, ut_teardown,
14022 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14023 TEST_CASE_ST(ut_setup, ut_teardown,
14024 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14029 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14030 .suite_name = "SNOW 3G Test Suite",
14031 .setup = snow3g_testsuite_setup,
14032 .unit_test_cases = {
14033 /** SNOW 3G encrypt only (UEA2) */
14034 TEST_CASE_ST(ut_setup, ut_teardown,
14035 test_snow3g_encryption_test_case_1),
14036 TEST_CASE_ST(ut_setup, ut_teardown,
14037 test_snow3g_encryption_test_case_2),
14038 TEST_CASE_ST(ut_setup, ut_teardown,
14039 test_snow3g_encryption_test_case_3),
14040 TEST_CASE_ST(ut_setup, ut_teardown,
14041 test_snow3g_encryption_test_case_4),
14042 TEST_CASE_ST(ut_setup, ut_teardown,
14043 test_snow3g_encryption_test_case_5),
14045 TEST_CASE_ST(ut_setup, ut_teardown,
14046 test_snow3g_encryption_test_case_1_oop),
14047 TEST_CASE_ST(ut_setup, ut_teardown,
14048 test_snow3g_encryption_test_case_1_oop_sgl),
14049 TEST_CASE_ST(ut_setup, ut_teardown,
14050 test_snow3g_encryption_test_case_1_offset_oop),
14051 TEST_CASE_ST(ut_setup, ut_teardown,
14052 test_snow3g_decryption_test_case_1_oop),
14054 /** SNOW 3G generate auth, then encrypt (UEA2) */
14055 TEST_CASE_ST(ut_setup, ut_teardown,
14056 test_snow3g_auth_cipher_test_case_1),
14057 TEST_CASE_ST(ut_setup, ut_teardown,
14058 test_snow3g_auth_cipher_test_case_2),
14059 TEST_CASE_ST(ut_setup, ut_teardown,
14060 test_snow3g_auth_cipher_test_case_2_oop),
14061 TEST_CASE_ST(ut_setup, ut_teardown,
14062 test_snow3g_auth_cipher_part_digest_enc),
14063 TEST_CASE_ST(ut_setup, ut_teardown,
14064 test_snow3g_auth_cipher_part_digest_enc_oop),
14065 TEST_CASE_ST(ut_setup, ut_teardown,
14066 test_snow3g_auth_cipher_test_case_3_sgl),
14067 TEST_CASE_ST(ut_setup, ut_teardown,
14068 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14069 TEST_CASE_ST(ut_setup, ut_teardown,
14070 test_snow3g_auth_cipher_part_digest_enc_sgl),
14071 TEST_CASE_ST(ut_setup, ut_teardown,
14072 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14074 /** SNOW 3G decrypt (UEA2), then verify auth */
14075 TEST_CASE_ST(ut_setup, ut_teardown,
14076 test_snow3g_auth_cipher_verify_test_case_1),
14077 TEST_CASE_ST(ut_setup, ut_teardown,
14078 test_snow3g_auth_cipher_verify_test_case_2),
14079 TEST_CASE_ST(ut_setup, ut_teardown,
14080 test_snow3g_auth_cipher_verify_test_case_2_oop),
14081 TEST_CASE_ST(ut_setup, ut_teardown,
14082 test_snow3g_auth_cipher_verify_part_digest_enc),
14083 TEST_CASE_ST(ut_setup, ut_teardown,
14084 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14085 TEST_CASE_ST(ut_setup, ut_teardown,
14086 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14087 TEST_CASE_ST(ut_setup, ut_teardown,
14088 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14089 TEST_CASE_ST(ut_setup, ut_teardown,
14090 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14091 TEST_CASE_ST(ut_setup, ut_teardown,
14092 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14094 /** SNOW 3G decrypt only (UEA2) */
14095 TEST_CASE_ST(ut_setup, ut_teardown,
14096 test_snow3g_decryption_test_case_1),
14097 TEST_CASE_ST(ut_setup, ut_teardown,
14098 test_snow3g_decryption_test_case_2),
14099 TEST_CASE_ST(ut_setup, ut_teardown,
14100 test_snow3g_decryption_test_case_3),
14101 TEST_CASE_ST(ut_setup, ut_teardown,
14102 test_snow3g_decryption_test_case_4),
14103 TEST_CASE_ST(ut_setup, ut_teardown,
14104 test_snow3g_decryption_test_case_5),
14105 TEST_CASE_ST(ut_setup, ut_teardown,
14106 test_snow3g_decryption_with_digest_test_case_1),
14107 TEST_CASE_ST(ut_setup, ut_teardown,
14108 test_snow3g_hash_generate_test_case_1),
14109 TEST_CASE_ST(ut_setup, ut_teardown,
14110 test_snow3g_hash_generate_test_case_2),
14111 TEST_CASE_ST(ut_setup, ut_teardown,
14112 test_snow3g_hash_generate_test_case_3),
14114 /* Tests with buffers which length is not byte-aligned */
14115 TEST_CASE_ST(ut_setup, ut_teardown,
14116 test_snow3g_hash_generate_test_case_4),
14117 TEST_CASE_ST(ut_setup, ut_teardown,
14118 test_snow3g_hash_generate_test_case_5),
14119 TEST_CASE_ST(ut_setup, ut_teardown,
14120 test_snow3g_hash_generate_test_case_6),
14121 TEST_CASE_ST(ut_setup, ut_teardown,
14122 test_snow3g_hash_verify_test_case_1),
14123 TEST_CASE_ST(ut_setup, ut_teardown,
14124 test_snow3g_hash_verify_test_case_2),
14125 TEST_CASE_ST(ut_setup, ut_teardown,
14126 test_snow3g_hash_verify_test_case_3),
14128 /* Tests with buffers which length is not byte-aligned */
14129 TEST_CASE_ST(ut_setup, ut_teardown,
14130 test_snow3g_hash_verify_test_case_4),
14131 TEST_CASE_ST(ut_setup, ut_teardown,
14132 test_snow3g_hash_verify_test_case_5),
14133 TEST_CASE_ST(ut_setup, ut_teardown,
14134 test_snow3g_hash_verify_test_case_6),
14135 TEST_CASE_ST(ut_setup, ut_teardown,
14136 test_snow3g_cipher_auth_test_case_1),
14137 TEST_CASE_ST(ut_setup, ut_teardown,
14138 test_snow3g_auth_cipher_with_digest_test_case_1),
14143 static struct unit_test_suite cryptodev_zuc_testsuite = {
14144 .suite_name = "ZUC Test Suite",
14145 .setup = zuc_testsuite_setup,
14146 .unit_test_cases = {
14147 /** ZUC encrypt only (EEA3) */
14148 TEST_CASE_ST(ut_setup, ut_teardown,
14149 test_zuc_encryption_test_case_1),
14150 TEST_CASE_ST(ut_setup, ut_teardown,
14151 test_zuc_encryption_test_case_2),
14152 TEST_CASE_ST(ut_setup, ut_teardown,
14153 test_zuc_encryption_test_case_3),
14154 TEST_CASE_ST(ut_setup, ut_teardown,
14155 test_zuc_encryption_test_case_4),
14156 TEST_CASE_ST(ut_setup, ut_teardown,
14157 test_zuc_encryption_test_case_5),
14158 TEST_CASE_ST(ut_setup, ut_teardown,
14159 test_zuc_encryption_test_case_6_sgl),
14161 /** ZUC authenticate (EIA3) */
14162 TEST_CASE_ST(ut_setup, ut_teardown,
14163 test_zuc_hash_generate_test_case_1),
14164 TEST_CASE_ST(ut_setup, ut_teardown,
14165 test_zuc_hash_generate_test_case_2),
14166 TEST_CASE_ST(ut_setup, ut_teardown,
14167 test_zuc_hash_generate_test_case_3),
14168 TEST_CASE_ST(ut_setup, ut_teardown,
14169 test_zuc_hash_generate_test_case_4),
14170 TEST_CASE_ST(ut_setup, ut_teardown,
14171 test_zuc_hash_generate_test_case_5),
14172 TEST_CASE_ST(ut_setup, ut_teardown,
14173 test_zuc_hash_generate_test_case_6),
14174 TEST_CASE_ST(ut_setup, ut_teardown,
14175 test_zuc_hash_generate_test_case_7),
14176 TEST_CASE_ST(ut_setup, ut_teardown,
14177 test_zuc_hash_generate_test_case_8),
14179 /** ZUC alg-chain (EEA3/EIA3) */
14180 TEST_CASE_ST(ut_setup, ut_teardown,
14181 test_zuc_cipher_auth_test_case_1),
14182 TEST_CASE_ST(ut_setup, ut_teardown,
14183 test_zuc_cipher_auth_test_case_2),
14185 /** ZUC generate auth, then encrypt (EEA3) */
14186 TEST_CASE_ST(ut_setup, ut_teardown,
14187 test_zuc_auth_cipher_test_case_1),
14188 TEST_CASE_ST(ut_setup, ut_teardown,
14189 test_zuc_auth_cipher_test_case_1_oop),
14190 TEST_CASE_ST(ut_setup, ut_teardown,
14191 test_zuc_auth_cipher_test_case_1_sgl),
14192 TEST_CASE_ST(ut_setup, ut_teardown,
14193 test_zuc_auth_cipher_test_case_1_oop_sgl),
14195 /** ZUC decrypt (EEA3), then verify auth */
14196 TEST_CASE_ST(ut_setup, ut_teardown,
14197 test_zuc_auth_cipher_verify_test_case_1),
14198 TEST_CASE_ST(ut_setup, ut_teardown,
14199 test_zuc_auth_cipher_verify_test_case_1_oop),
14200 TEST_CASE_ST(ut_setup, ut_teardown,
14201 test_zuc_auth_cipher_verify_test_case_1_sgl),
14202 TEST_CASE_ST(ut_setup, ut_teardown,
14203 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14208 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14209 .suite_name = "HMAC_MD5 Authentication Test Suite",
14210 .setup = hmac_md5_auth_testsuite_setup,
14211 .unit_test_cases = {
14212 TEST_CASE_ST(ut_setup, ut_teardown,
14213 test_MD5_HMAC_generate_case_1),
14214 TEST_CASE_ST(ut_setup, ut_teardown,
14215 test_MD5_HMAC_verify_case_1),
14216 TEST_CASE_ST(ut_setup, ut_teardown,
14217 test_MD5_HMAC_generate_case_2),
14218 TEST_CASE_ST(ut_setup, ut_teardown,
14219 test_MD5_HMAC_verify_case_2),
14224 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14225 .suite_name = "Kasumi Test Suite",
14226 .setup = kasumi_testsuite_setup,
14227 .unit_test_cases = {
14228 /** KASUMI hash only (UIA1) */
14229 TEST_CASE_ST(ut_setup, ut_teardown,
14230 test_kasumi_hash_generate_test_case_1),
14231 TEST_CASE_ST(ut_setup, ut_teardown,
14232 test_kasumi_hash_generate_test_case_2),
14233 TEST_CASE_ST(ut_setup, ut_teardown,
14234 test_kasumi_hash_generate_test_case_3),
14235 TEST_CASE_ST(ut_setup, ut_teardown,
14236 test_kasumi_hash_generate_test_case_4),
14237 TEST_CASE_ST(ut_setup, ut_teardown,
14238 test_kasumi_hash_generate_test_case_5),
14239 TEST_CASE_ST(ut_setup, ut_teardown,
14240 test_kasumi_hash_generate_test_case_6),
14242 TEST_CASE_ST(ut_setup, ut_teardown,
14243 test_kasumi_hash_verify_test_case_1),
14244 TEST_CASE_ST(ut_setup, ut_teardown,
14245 test_kasumi_hash_verify_test_case_2),
14246 TEST_CASE_ST(ut_setup, ut_teardown,
14247 test_kasumi_hash_verify_test_case_3),
14248 TEST_CASE_ST(ut_setup, ut_teardown,
14249 test_kasumi_hash_verify_test_case_4),
14250 TEST_CASE_ST(ut_setup, ut_teardown,
14251 test_kasumi_hash_verify_test_case_5),
14253 /** KASUMI encrypt only (UEA1) */
14254 TEST_CASE_ST(ut_setup, ut_teardown,
14255 test_kasumi_encryption_test_case_1),
14256 TEST_CASE_ST(ut_setup, ut_teardown,
14257 test_kasumi_encryption_test_case_1_sgl),
14258 TEST_CASE_ST(ut_setup, ut_teardown,
14259 test_kasumi_encryption_test_case_1_oop),
14260 TEST_CASE_ST(ut_setup, ut_teardown,
14261 test_kasumi_encryption_test_case_1_oop_sgl),
14262 TEST_CASE_ST(ut_setup, ut_teardown,
14263 test_kasumi_encryption_test_case_2),
14264 TEST_CASE_ST(ut_setup, ut_teardown,
14265 test_kasumi_encryption_test_case_3),
14266 TEST_CASE_ST(ut_setup, ut_teardown,
14267 test_kasumi_encryption_test_case_4),
14268 TEST_CASE_ST(ut_setup, ut_teardown,
14269 test_kasumi_encryption_test_case_5),
14271 /** KASUMI decrypt only (UEA1) */
14272 TEST_CASE_ST(ut_setup, ut_teardown,
14273 test_kasumi_decryption_test_case_1),
14274 TEST_CASE_ST(ut_setup, ut_teardown,
14275 test_kasumi_decryption_test_case_2),
14276 TEST_CASE_ST(ut_setup, ut_teardown,
14277 test_kasumi_decryption_test_case_3),
14278 TEST_CASE_ST(ut_setup, ut_teardown,
14279 test_kasumi_decryption_test_case_4),
14280 TEST_CASE_ST(ut_setup, ut_teardown,
14281 test_kasumi_decryption_test_case_5),
14282 TEST_CASE_ST(ut_setup, ut_teardown,
14283 test_kasumi_decryption_test_case_1_oop),
14285 TEST_CASE_ST(ut_setup, ut_teardown,
14286 test_kasumi_cipher_auth_test_case_1),
14288 /** KASUMI generate auth, then encrypt (F8) */
14289 TEST_CASE_ST(ut_setup, ut_teardown,
14290 test_kasumi_auth_cipher_test_case_1),
14291 TEST_CASE_ST(ut_setup, ut_teardown,
14292 test_kasumi_auth_cipher_test_case_2),
14293 TEST_CASE_ST(ut_setup, ut_teardown,
14294 test_kasumi_auth_cipher_test_case_2_oop),
14295 TEST_CASE_ST(ut_setup, ut_teardown,
14296 test_kasumi_auth_cipher_test_case_2_sgl),
14297 TEST_CASE_ST(ut_setup, ut_teardown,
14298 test_kasumi_auth_cipher_test_case_2_oop_sgl),
14300 /** KASUMI decrypt (F8), then verify auth */
14301 TEST_CASE_ST(ut_setup, ut_teardown,
14302 test_kasumi_auth_cipher_verify_test_case_1),
14303 TEST_CASE_ST(ut_setup, ut_teardown,
14304 test_kasumi_auth_cipher_verify_test_case_2),
14305 TEST_CASE_ST(ut_setup, ut_teardown,
14306 test_kasumi_auth_cipher_verify_test_case_2_oop),
14307 TEST_CASE_ST(ut_setup, ut_teardown,
14308 test_kasumi_auth_cipher_verify_test_case_2_sgl),
14309 TEST_CASE_ST(ut_setup, ut_teardown,
14310 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14316 static struct unit_test_suite cryptodev_esn_testsuite = {
14317 .suite_name = "ESN Test Suite",
14318 .setup = esn_testsuite_setup,
14319 .unit_test_cases = {
14320 TEST_CASE_ST(ut_setup, ut_teardown,
14321 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14322 TEST_CASE_ST(ut_setup, ut_teardown,
14323 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14328 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
14329 .suite_name = "Negative AES GCM Test Suite",
14330 .setup = negative_aes_gcm_testsuite_setup,
14331 .unit_test_cases = {
14332 TEST_CASE_ST(ut_setup, ut_teardown,
14333 test_AES_GCM_auth_encryption_fail_iv_corrupt),
14334 TEST_CASE_ST(ut_setup, ut_teardown,
14335 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14336 TEST_CASE_ST(ut_setup, ut_teardown,
14337 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14338 TEST_CASE_ST(ut_setup, ut_teardown,
14339 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14340 TEST_CASE_ST(ut_setup, ut_teardown,
14341 test_AES_GCM_auth_encryption_fail_aad_corrupt),
14342 TEST_CASE_ST(ut_setup, ut_teardown,
14343 test_AES_GCM_auth_encryption_fail_tag_corrupt),
14344 TEST_CASE_ST(ut_setup, ut_teardown,
14345 test_AES_GCM_auth_decryption_fail_iv_corrupt),
14346 TEST_CASE_ST(ut_setup, ut_teardown,
14347 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
14348 TEST_CASE_ST(ut_setup, ut_teardown,
14349 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
14350 TEST_CASE_ST(ut_setup, ut_teardown,
14351 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
14352 TEST_CASE_ST(ut_setup, ut_teardown,
14353 test_AES_GCM_auth_decryption_fail_aad_corrupt),
14354 TEST_CASE_ST(ut_setup, ut_teardown,
14355 test_AES_GCM_auth_decryption_fail_tag_corrupt),
14361 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
14362 .suite_name = "Negative AES GMAC Test Suite",
14363 .setup = negative_aes_gmac_testsuite_setup,
14364 .unit_test_cases = {
14365 TEST_CASE_ST(ut_setup, ut_teardown,
14366 authentication_verify_AES128_GMAC_fail_data_corrupt),
14367 TEST_CASE_ST(ut_setup, ut_teardown,
14368 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14374 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
14375 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
14376 .setup = mixed_cipher_hash_testsuite_setup,
14377 .unit_test_cases = {
14378 /** AUTH AES CMAC + CIPHER AES CTR */
14379 TEST_CASE_ST(ut_setup, ut_teardown,
14380 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
14381 TEST_CASE_ST(ut_setup, ut_teardown,
14382 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14383 TEST_CASE_ST(ut_setup, ut_teardown,
14384 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14385 TEST_CASE_ST(ut_setup, ut_teardown,
14386 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14387 TEST_CASE_ST(ut_setup, ut_teardown,
14388 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
14389 TEST_CASE_ST(ut_setup, ut_teardown,
14390 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14391 TEST_CASE_ST(ut_setup, ut_teardown,
14392 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14393 TEST_CASE_ST(ut_setup, ut_teardown,
14394 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14396 /** AUTH ZUC + CIPHER SNOW3G */
14397 TEST_CASE_ST(ut_setup, ut_teardown,
14398 test_auth_zuc_cipher_snow_test_case_1),
14399 TEST_CASE_ST(ut_setup, ut_teardown,
14400 test_verify_auth_zuc_cipher_snow_test_case_1),
14401 /** AUTH AES CMAC + CIPHER SNOW3G */
14402 TEST_CASE_ST(ut_setup, ut_teardown,
14403 test_auth_aes_cmac_cipher_snow_test_case_1),
14404 TEST_CASE_ST(ut_setup, ut_teardown,
14405 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
14406 /** AUTH ZUC + CIPHER AES CTR */
14407 TEST_CASE_ST(ut_setup, ut_teardown,
14408 test_auth_zuc_cipher_aes_ctr_test_case_1),
14409 TEST_CASE_ST(ut_setup, ut_teardown,
14410 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
14411 /** AUTH SNOW3G + CIPHER AES CTR */
14412 TEST_CASE_ST(ut_setup, ut_teardown,
14413 test_auth_snow_cipher_aes_ctr_test_case_1),
14414 TEST_CASE_ST(ut_setup, ut_teardown,
14415 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
14416 /** AUTH SNOW3G + CIPHER ZUC */
14417 TEST_CASE_ST(ut_setup, ut_teardown,
14418 test_auth_snow_cipher_zuc_test_case_1),
14419 TEST_CASE_ST(ut_setup, ut_teardown,
14420 test_verify_auth_snow_cipher_zuc_test_case_1),
14421 /** AUTH AES CMAC + CIPHER ZUC */
14422 TEST_CASE_ST(ut_setup, ut_teardown,
14423 test_auth_aes_cmac_cipher_zuc_test_case_1),
14424 TEST_CASE_ST(ut_setup, ut_teardown,
14425 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
14427 /** AUTH NULL + CIPHER SNOW3G */
14428 TEST_CASE_ST(ut_setup, ut_teardown,
14429 test_auth_null_cipher_snow_test_case_1),
14430 TEST_CASE_ST(ut_setup, ut_teardown,
14431 test_verify_auth_null_cipher_snow_test_case_1),
14432 /** AUTH NULL + CIPHER ZUC */
14433 TEST_CASE_ST(ut_setup, ut_teardown,
14434 test_auth_null_cipher_zuc_test_case_1),
14435 TEST_CASE_ST(ut_setup, ut_teardown,
14436 test_verify_auth_null_cipher_zuc_test_case_1),
14437 /** AUTH SNOW3G + CIPHER NULL */
14438 TEST_CASE_ST(ut_setup, ut_teardown,
14439 test_auth_snow_cipher_null_test_case_1),
14440 TEST_CASE_ST(ut_setup, ut_teardown,
14441 test_verify_auth_snow_cipher_null_test_case_1),
14442 /** AUTH ZUC + CIPHER NULL */
14443 TEST_CASE_ST(ut_setup, ut_teardown,
14444 test_auth_zuc_cipher_null_test_case_1),
14445 TEST_CASE_ST(ut_setup, ut_teardown,
14446 test_verify_auth_zuc_cipher_null_test_case_1),
14447 /** AUTH NULL + CIPHER AES CTR */
14448 TEST_CASE_ST(ut_setup, ut_teardown,
14449 test_auth_null_cipher_aes_ctr_test_case_1),
14450 TEST_CASE_ST(ut_setup, ut_teardown,
14451 test_verify_auth_null_cipher_aes_ctr_test_case_1),
14452 /** AUTH AES CMAC + CIPHER NULL */
14453 TEST_CASE_ST(ut_setup, ut_teardown,
14454 test_auth_aes_cmac_cipher_null_test_case_1),
14455 TEST_CASE_ST(ut_setup, ut_teardown,
14456 test_verify_auth_aes_cmac_cipher_null_test_case_1),
14462 run_cryptodev_testsuite(const char *pmd_name)
14464 uint8_t ret, j, i = 0, blk_start_idx = 0;
14465 const enum blockcipher_test_type blk_suites[] = {
14466 BLKCIPHER_AES_CHAIN_TYPE,
14467 BLKCIPHER_AES_CIPHERONLY_TYPE,
14468 BLKCIPHER_AES_DOCSIS_TYPE,
14469 BLKCIPHER_3DES_CHAIN_TYPE,
14470 BLKCIPHER_3DES_CIPHERONLY_TYPE,
14471 BLKCIPHER_DES_CIPHERONLY_TYPE,
14472 BLKCIPHER_DES_DOCSIS_TYPE,
14473 BLKCIPHER_AUTHONLY_TYPE};
14474 struct unit_test_suite *static_suites[] = {
14475 &cryptodev_multi_session_testsuite,
14476 &cryptodev_null_testsuite,
14477 &cryptodev_aes_ccm_auth_testsuite,
14478 &cryptodev_aes_gcm_auth_testsuite,
14479 &cryptodev_aes_gmac_auth_testsuite,
14480 &cryptodev_snow3g_testsuite,
14481 &cryptodev_chacha20_poly1305_testsuite,
14482 &cryptodev_zuc_testsuite,
14483 &cryptodev_hmac_md5_auth_testsuite,
14484 &cryptodev_kasumi_testsuite,
14485 &cryptodev_esn_testsuite,
14486 &cryptodev_negative_aes_gcm_testsuite,
14487 &cryptodev_negative_aes_gmac_testsuite,
14488 &cryptodev_mixed_cipher_hash_testsuite,
14489 &cryptodev_negative_hmac_sha1_testsuite,
14490 &cryptodev_gen_testsuite,
14491 #ifdef RTE_LIB_SECURITY
14492 &pdcp_proto_testsuite,
14493 &docsis_proto_testsuite,
14497 static struct unit_test_suite ts = {
14498 .suite_name = "Cryptodev Unit Test Suite",
14499 .setup = testsuite_setup,
14500 .teardown = testsuite_teardown,
14501 .unit_test_cases = {TEST_CASES_END()}
14504 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
14506 if (gbl_driver_id == -1) {
14507 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
14508 return TEST_SKIPPED;
14511 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14512 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
14514 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
14515 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14516 ret = unit_test_suite_runner(&ts);
14518 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
14519 free(ts.unit_test_suites);
14524 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14526 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14530 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14532 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14536 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14538 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14542 test_cryptodev_cpu_aesni_mb(void)
14545 enum rte_security_session_action_type at = gbl_action_type;
14546 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14547 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14548 gbl_action_type = at;
14553 test_cryptodev_openssl(void)
14555 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14559 test_cryptodev_aesni_gcm(void)
14561 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14565 test_cryptodev_cpu_aesni_gcm(void)
14568 enum rte_security_session_action_type at = gbl_action_type;
14569 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14570 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14571 gbl_action_type = at;
14576 test_cryptodev_null(void)
14578 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14582 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14584 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14588 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14590 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14594 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14596 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14600 test_cryptodev_armv8(void)
14602 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14606 test_cryptodev_mrvl(void)
14608 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14611 #ifdef RTE_CRYPTO_SCHEDULER
14614 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14616 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
14617 const enum blockcipher_test_type blk_suites[] = {
14618 BLKCIPHER_AES_CHAIN_TYPE,
14619 BLKCIPHER_AES_CIPHERONLY_TYPE,
14620 BLKCIPHER_AUTHONLY_TYPE
14622 static struct unit_test_suite scheduler_multicore = {
14623 .suite_name = "Scheduler Multicore Unit Test Suite",
14624 .setup = scheduler_multicore_testsuite_setup,
14625 .teardown = scheduler_mode_testsuite_teardown,
14626 .unit_test_cases = {TEST_CASES_END()}
14628 static struct unit_test_suite scheduler_round_robin = {
14629 .suite_name = "Scheduler Round Robin Unit Test Suite",
14630 .setup = scheduler_roundrobin_testsuite_setup,
14631 .teardown = scheduler_mode_testsuite_teardown,
14632 .unit_test_cases = {TEST_CASES_END()}
14634 static struct unit_test_suite scheduler_failover = {
14635 .suite_name = "Scheduler Failover Unit Test Suite",
14636 .setup = scheduler_failover_testsuite_setup,
14637 .teardown = scheduler_mode_testsuite_teardown,
14638 .unit_test_cases = {TEST_CASES_END()}
14640 static struct unit_test_suite scheduler_pkt_size_distr = {
14641 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
14642 .setup = scheduler_pkt_size_distr_testsuite_setup,
14643 .teardown = scheduler_mode_testsuite_teardown,
14644 .unit_test_cases = {TEST_CASES_END()}
14646 struct unit_test_suite *sched_mode_suites[] = {
14647 &scheduler_multicore,
14648 &scheduler_round_robin,
14649 &scheduler_failover,
14650 &scheduler_pkt_size_distr
14652 static struct unit_test_suite scheduler_config = {
14653 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
14654 .unit_test_cases = {
14655 TEST_CASE(test_scheduler_attach_slave_op),
14656 TEST_CASE(test_scheduler_mode_multicore_op),
14657 TEST_CASE(test_scheduler_mode_roundrobin_op),
14658 TEST_CASE(test_scheduler_mode_failover_op),
14659 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
14660 TEST_CASE(test_scheduler_detach_slave_op),
14662 TEST_CASES_END() /**< NULL terminate array */
14665 struct unit_test_suite *static_suites[] = {
14669 static struct unit_test_suite ts = {
14670 .suite_name = "Scheduler Unit Test Suite",
14671 .setup = scheduler_testsuite_setup,
14672 .teardown = testsuite_teardown,
14673 .unit_test_cases = {TEST_CASES_END()}
14676 gbl_driver_id = rte_cryptodev_driver_id_get(
14677 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14679 if (gbl_driver_id == -1) {
14680 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14681 return TEST_SKIPPED;
14684 if (rte_cryptodev_driver_id_get(
14685 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14686 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14687 return TEST_SKIPPED;
14690 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
14692 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
14693 (struct unit_test_suite *) *
14694 (RTE_DIM(blk_suites) + 1));
14695 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
14696 blk_suites, RTE_DIM(blk_suites));
14697 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
14700 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14701 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
14702 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
14703 RTE_DIM(sched_mode_suites));
14704 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14705 ret = unit_test_suite_runner(&ts);
14707 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
14708 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
14709 (*sched_mode_suites[sched_i]),
14710 RTE_DIM(blk_suites));
14711 free(sched_mode_suites[sched_i]->unit_test_suites);
14713 free(ts.unit_test_suites);
14717 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14722 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14724 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14728 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14730 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14734 test_cryptodev_ccp(void)
14736 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14740 test_cryptodev_octeontx(void)
14742 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14746 test_cryptodev_octeontx2(void)
14748 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14752 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14754 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14758 test_cryptodev_nitrox(void)
14760 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14764 test_cryptodev_bcmfs(void)
14766 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14770 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14774 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14775 ret = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14776 global_api_test_type = CRYPTODEV_API_TEST;
14782 test_cryptodev_cn9k(void)
14784 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
14788 test_cryptodev_cn10k(void)
14790 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
14793 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14794 test_cryptodev_qat_raw_api);
14795 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14796 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14797 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14798 test_cryptodev_cpu_aesni_mb);
14799 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14800 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14801 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14802 test_cryptodev_cpu_aesni_gcm);
14803 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14804 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14805 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14806 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14807 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14808 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14809 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14810 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14811 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14812 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14813 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14814 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14815 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14816 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14817 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
14818 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
14819 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);