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]
107 * Forward declarations.
110 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
111 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
115 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
116 struct crypto_unittest_params *ut_params,
117 struct crypto_testsuite_params *ts_param,
118 const uint8_t *cipher,
119 const uint8_t *digest,
122 static struct rte_mbuf *
123 setup_test_string(struct rte_mempool *mpool,
124 const char *string, size_t len, uint8_t blocksize)
126 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
127 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
129 memset(m->buf_addr, 0, m->buf_len);
131 char *dst = rte_pktmbuf_append(m, t_len);
138 rte_memcpy(dst, string, t_len);
140 memset(dst, 0, t_len);
146 /* Get number of bytes in X bits (rounding up) */
148 ceil_byte_length(uint32_t num_bits)
151 return ((num_bits >> 3) + 1);
153 return (num_bits >> 3);
157 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
158 uint8_t is_op_success)
160 struct rte_crypto_op *op = user_data;
161 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
162 RTE_CRYPTO_OP_STATUS_ERROR;
166 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
167 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
168 uint8_t len_in_bits, uint8_t cipher_iv_len)
170 struct rte_crypto_sym_op *sop = op->sym;
171 struct rte_crypto_op *ret_op = NULL;
172 struct rte_crypto_vec data_vec[UINT8_MAX];
173 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
174 union rte_crypto_sym_ofs ofs;
175 struct rte_crypto_sym_vec vec;
176 struct rte_crypto_sgl sgl;
178 union rte_cryptodev_session_ctx sess;
180 struct rte_crypto_raw_dp_ctx *ctx;
181 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
185 int ctx_service_size;
187 int enqueue_status, dequeue_status;
189 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
190 if (ctx_service_size < 0) {
191 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
195 ctx = malloc(ctx_service_size);
197 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
201 /* Both are enums, setting crypto_sess will suit any session type */
202 sess.crypto_sess = op->sym->session;
204 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
205 op->sess_type, sess, 0) < 0) {
206 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
212 aad_auth_iv.iova = 0;
213 aad_auth_iv.va = NULL;
220 vec.digest = &digest;
221 vec.aad = &aad_auth_iv;
222 vec.status = &status;
226 if (is_cipher && is_auth) {
227 cipher_offset = sop->cipher.data.offset;
228 cipher_len = sop->cipher.data.length;
229 auth_offset = sop->auth.data.offset;
230 auth_len = sop->auth.data.length;
231 max_len = RTE_MAX(cipher_offset + cipher_len,
232 auth_offset + auth_len);
234 max_len = max_len >> 3;
235 cipher_offset = cipher_offset >> 3;
236 auth_offset = auth_offset >> 3;
237 cipher_len = cipher_len >> 3;
238 auth_len = auth_len >> 3;
240 ofs.ofs.cipher.head = cipher_offset;
241 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
242 ofs.ofs.auth.head = auth_offset;
243 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
244 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
245 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
246 aad_auth_iv.va = rte_crypto_op_ctod_offset(
247 op, void *, IV_OFFSET + cipher_iv_len);
248 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
250 digest.va = (void *)sop->auth.digest.data;
251 digest.iova = sop->auth.digest.phys_addr;
253 } else if (is_cipher) {
254 cipher_offset = sop->cipher.data.offset;
255 cipher_len = sop->cipher.data.length;
256 max_len = cipher_len + cipher_offset;
258 max_len = max_len >> 3;
259 cipher_offset = cipher_offset >> 3;
260 cipher_len = cipher_len >> 3;
262 ofs.ofs.cipher.head = cipher_offset;
263 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
264 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
265 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
267 } else if (is_auth) {
268 auth_offset = sop->auth.data.offset;
269 auth_len = sop->auth.data.length;
270 max_len = auth_len + auth_offset;
272 max_len = max_len >> 3;
273 auth_offset = auth_offset >> 3;
274 auth_len = auth_len >> 3;
276 ofs.ofs.auth.head = auth_offset;
277 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
278 aad_auth_iv.va = rte_crypto_op_ctod_offset(
279 op, void *, IV_OFFSET + cipher_iv_len);
280 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
282 digest.va = (void *)sop->auth.digest.data;
283 digest.iova = sop->auth.digest.phys_addr;
286 cipher_offset = sop->aead.data.offset;
287 cipher_len = sop->aead.data.length;
288 max_len = cipher_len + cipher_offset;
290 max_len = max_len >> 3;
291 cipher_offset = cipher_offset >> 3;
292 cipher_len = cipher_len >> 3;
294 ofs.ofs.cipher.head = cipher_offset;
295 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
296 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
297 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
298 aad_auth_iv.va = (void *)sop->aead.aad.data;
299 aad_auth_iv.iova = sop->aead.aad.phys_addr;
300 digest.va = (void *)sop->aead.digest.data;
301 digest.iova = sop->aead.digest.phys_addr;
304 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
305 data_vec, RTE_DIM(data_vec));
306 if (n < 0 || n > sop->m_src->nb_segs) {
307 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
313 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
314 &enqueue_status) < 1) {
315 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
319 if (enqueue_status == 0) {
320 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
322 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
325 } else if (enqueue_status < 0) {
326 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
331 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
332 n = rte_cryptodev_raw_dequeue_burst(ctx,
333 NULL, 1, post_process_raw_dp_op,
334 (void **)&ret_op, 0, &n_success,
336 if (dequeue_status < 0) {
337 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
344 if (n == 1 && dequeue_status == 0) {
345 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
346 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
351 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
352 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
353 RTE_CRYPTO_OP_STATUS_SUCCESS;
360 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
363 struct rte_crypto_sym_op *sop;
364 union rte_crypto_sym_ofs ofs;
365 struct rte_crypto_sgl sgl;
366 struct rte_crypto_sym_vec symvec;
367 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
368 struct rte_crypto_vec vec[UINT8_MAX];
372 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
373 sop->aead.data.length, vec, RTE_DIM(vec));
375 if (n < 0 || n != sop->m_src->nb_segs) {
376 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
384 symvec.digest = &digest_ptr;
385 symvec.aad = &aad_ptr;
389 /* for CPU crypto the IOVA address is not required */
390 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
391 digest_ptr.va = (void *)sop->aead.digest.data;
392 aad_ptr.va = (void *)sop->aead.aad.data;
396 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
400 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
402 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
406 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
409 struct rte_crypto_sym_op *sop;
410 union rte_crypto_sym_ofs ofs;
411 struct rte_crypto_sgl sgl;
412 struct rte_crypto_sym_vec symvec;
413 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
414 struct rte_crypto_vec vec[UINT8_MAX];
418 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
419 sop->auth.data.length, vec, RTE_DIM(vec));
421 if (n < 0 || n != sop->m_src->nb_segs) {
422 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
430 symvec.digest = &digest_ptr;
434 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
435 digest_ptr.va = (void *)sop->auth.digest.data;
438 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
439 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
440 (sop->cipher.data.offset + sop->cipher.data.length);
442 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
446 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
448 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
451 static struct rte_crypto_op *
452 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
455 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
457 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
458 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
464 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
467 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
468 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
475 static struct crypto_testsuite_params testsuite_params = { NULL };
476 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
477 static struct crypto_unittest_params unittest_params;
480 testsuite_setup(void)
482 struct crypto_testsuite_params *ts_params = &testsuite_params;
483 struct rte_cryptodev_info info;
484 uint32_t i = 0, nb_devs, dev_id;
487 memset(ts_params, 0, sizeof(*ts_params));
489 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
490 if (ts_params->mbuf_pool == NULL) {
491 /* Not already created so create */
492 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
494 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
496 if (ts_params->mbuf_pool == NULL) {
497 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
502 ts_params->large_mbuf_pool = rte_mempool_lookup(
503 "CRYPTO_LARGE_MBUFPOOL");
504 if (ts_params->large_mbuf_pool == NULL) {
505 /* Not already created so create */
506 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
507 "CRYPTO_LARGE_MBUFPOOL",
510 if (ts_params->large_mbuf_pool == NULL) {
512 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
517 ts_params->op_mpool = rte_crypto_op_pool_create(
518 "MBUF_CRYPTO_SYM_OP_POOL",
519 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
520 NUM_MBUFS, MBUF_CACHE_SIZE,
522 sizeof(struct rte_crypto_sym_xform) +
525 if (ts_params->op_mpool == NULL) {
526 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
530 nb_devs = rte_cryptodev_count();
532 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
536 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
537 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
538 rte_cryptodev_driver_name_get(gbl_driver_id));
542 /* Create list of valid crypto devs */
543 for (i = 0; i < nb_devs; i++) {
544 rte_cryptodev_info_get(i, &info);
545 if (info.driver_id == gbl_driver_id)
546 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
549 if (ts_params->valid_dev_count < 1)
552 /* Set up all the qps on the first of the valid devices found */
554 dev_id = ts_params->valid_devs[0];
556 rte_cryptodev_info_get(dev_id, &info);
558 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
559 ts_params->conf.socket_id = SOCKET_ID_ANY;
560 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
562 unsigned int session_size =
563 rte_cryptodev_sym_get_private_session_size(dev_id);
565 #ifdef RTE_LIB_SECURITY
566 unsigned int security_session_size = rte_security_session_get_size(
567 rte_cryptodev_get_sec_ctx(dev_id));
569 if (session_size < security_session_size)
570 session_size = security_session_size;
573 * Create mempool with maximum number of sessions.
575 if (info.sym.max_nb_sessions != 0 &&
576 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
577 RTE_LOG(ERR, USER1, "Device does not support "
578 "at least %u sessions\n",
583 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
584 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
586 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
587 "session mempool allocation failed");
589 ts_params->session_priv_mpool = rte_mempool_create(
593 0, 0, NULL, NULL, NULL,
596 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
597 "session mempool allocation failed");
601 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
603 "Failed to configure cryptodev %u with %u qps",
604 dev_id, ts_params->conf.nb_queue_pairs);
606 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
607 ts_params->qp_conf.mp_session = ts_params->session_mpool;
608 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
610 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
611 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
612 dev_id, qp_id, &ts_params->qp_conf,
613 rte_cryptodev_socket_id(dev_id)),
614 "Failed to setup queue pair %u on cryptodev %u",
622 testsuite_teardown(void)
624 struct crypto_testsuite_params *ts_params = &testsuite_params;
627 if (ts_params->mbuf_pool != NULL) {
628 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
629 rte_mempool_avail_count(ts_params->mbuf_pool));
632 if (ts_params->op_mpool != NULL) {
633 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
634 rte_mempool_avail_count(ts_params->op_mpool));
637 /* Free session mempools */
638 if (ts_params->session_priv_mpool != NULL) {
639 rte_mempool_free(ts_params->session_priv_mpool);
640 ts_params->session_priv_mpool = NULL;
643 if (ts_params->session_mpool != NULL) {
644 rte_mempool_free(ts_params->session_mpool);
645 ts_params->session_mpool = NULL;
648 res = rte_cryptodev_close(ts_params->valid_devs[0]);
650 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
654 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
655 const int *algs, uint16_t num_algs)
657 uint8_t dev_id = testsuite_params.valid_devs[0];
658 bool some_alg_supported = FALSE;
661 for (i = 0; i < num_algs && !some_alg_supported; i++) {
662 struct rte_cryptodev_sym_capability_idx alg = {
665 if (rte_cryptodev_sym_capability_get(dev_id,
667 some_alg_supported = TRUE;
669 if (!some_alg_supported)
676 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
677 uint16_t num_ciphers)
679 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
680 (const int *) ciphers, num_ciphers);
684 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
687 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
688 (const int *) auths, num_auths);
692 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
695 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
696 (const int *) aeads, num_aeads);
700 null_testsuite_setup(void)
702 struct crypto_testsuite_params *ts_params = &testsuite_params;
703 uint8_t dev_id = ts_params->valid_devs[0];
704 struct rte_cryptodev_info dev_info;
705 const enum rte_crypto_cipher_algorithm ciphers[] = {
706 RTE_CRYPTO_CIPHER_NULL
708 const enum rte_crypto_auth_algorithm auths[] = {
712 rte_cryptodev_info_get(dev_id, &dev_info);
714 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
715 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
716 "testsuite not met\n");
720 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
721 && check_auth_capabilities_supported(auths,
722 RTE_DIM(auths)) != 0) {
723 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
724 "testsuite not met\n");
732 crypto_gen_testsuite_setup(void)
734 struct crypto_testsuite_params *ts_params = &testsuite_params;
735 uint8_t dev_id = ts_params->valid_devs[0];
736 struct rte_cryptodev_info dev_info;
738 rte_cryptodev_info_get(dev_id, &dev_info);
740 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
741 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
742 "testsuite not met\n");
749 #ifdef RTE_LIB_SECURITY
751 pdcp_proto_testsuite_setup(void)
753 struct crypto_testsuite_params *ts_params = &testsuite_params;
754 uint8_t dev_id = ts_params->valid_devs[0];
755 struct rte_cryptodev_info dev_info;
756 const enum rte_crypto_cipher_algorithm ciphers[] = {
757 RTE_CRYPTO_CIPHER_NULL,
758 RTE_CRYPTO_CIPHER_AES_CTR,
759 RTE_CRYPTO_CIPHER_ZUC_EEA3,
760 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
762 const enum rte_crypto_auth_algorithm auths[] = {
763 RTE_CRYPTO_AUTH_NULL,
764 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
765 RTE_CRYPTO_AUTH_AES_CMAC,
766 RTE_CRYPTO_AUTH_ZUC_EIA3
769 rte_cryptodev_info_get(dev_id, &dev_info);
771 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
772 !(dev_info.feature_flags &
773 RTE_CRYPTODEV_FF_SECURITY)) {
774 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
775 "testsuite not met\n");
779 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
780 && check_auth_capabilities_supported(auths,
781 RTE_DIM(auths)) != 0) {
782 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
783 "testsuite not met\n");
791 docsis_proto_testsuite_setup(void)
793 struct crypto_testsuite_params *ts_params = &testsuite_params;
794 uint8_t dev_id = ts_params->valid_devs[0];
795 struct rte_cryptodev_info dev_info;
796 const enum rte_crypto_cipher_algorithm ciphers[] = {
797 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
800 rte_cryptodev_info_get(dev_id, &dev_info);
802 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
803 !(dev_info.feature_flags &
804 RTE_CRYPTODEV_FF_SECURITY)) {
805 RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
806 "Proto testsuite not met\n");
810 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
811 RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
812 "testsuite not met\n");
821 aes_ccm_auth_testsuite_setup(void)
823 struct crypto_testsuite_params *ts_params = &testsuite_params;
824 uint8_t dev_id = ts_params->valid_devs[0];
825 struct rte_cryptodev_info dev_info;
826 const enum rte_crypto_aead_algorithm aeads[] = {
827 RTE_CRYPTO_AEAD_AES_CCM
830 rte_cryptodev_info_get(dev_id, &dev_info);
832 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
833 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
834 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
835 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
836 "testsuite not met\n");
840 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
841 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
842 "testsuite not met\n");
850 aes_gcm_auth_testsuite_setup(void)
852 struct crypto_testsuite_params *ts_params = &testsuite_params;
853 uint8_t dev_id = ts_params->valid_devs[0];
854 struct rte_cryptodev_info dev_info;
855 const enum rte_crypto_aead_algorithm aeads[] = {
856 RTE_CRYPTO_AEAD_AES_GCM
859 rte_cryptodev_info_get(dev_id, &dev_info);
861 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
862 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
863 "testsuite not met\n");
867 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
868 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
869 "testsuite not met\n");
877 aes_gmac_auth_testsuite_setup(void)
879 struct crypto_testsuite_params *ts_params = &testsuite_params;
880 uint8_t dev_id = ts_params->valid_devs[0];
881 struct rte_cryptodev_info dev_info;
882 const enum rte_crypto_auth_algorithm auths[] = {
883 RTE_CRYPTO_AUTH_AES_GMAC
886 rte_cryptodev_info_get(dev_id, &dev_info);
888 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
889 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
890 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
891 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
892 "testsuite not met\n");
896 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
897 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
898 "testsuite not met\n");
906 chacha20_poly1305_testsuite_setup(void)
908 struct crypto_testsuite_params *ts_params = &testsuite_params;
909 uint8_t dev_id = ts_params->valid_devs[0];
910 struct rte_cryptodev_info dev_info;
911 const enum rte_crypto_aead_algorithm aeads[] = {
912 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
915 rte_cryptodev_info_get(dev_id, &dev_info);
917 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
918 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
919 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
920 RTE_LOG(INFO, USER1, "Feature flag requirements for "
921 "Chacha20-Poly1305 testsuite not met\n");
925 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
926 RTE_LOG(INFO, USER1, "Capability requirements for "
927 "Chacha20-Poly1305 testsuite not met\n");
935 snow3g_testsuite_setup(void)
937 struct crypto_testsuite_params *ts_params = &testsuite_params;
938 uint8_t dev_id = ts_params->valid_devs[0];
939 struct rte_cryptodev_info dev_info;
940 const enum rte_crypto_cipher_algorithm ciphers[] = {
941 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
944 const enum rte_crypto_auth_algorithm auths[] = {
945 RTE_CRYPTO_AUTH_SNOW3G_UIA2
948 rte_cryptodev_info_get(dev_id, &dev_info);
950 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
951 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
952 "testsuite not met\n");
956 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
957 && check_auth_capabilities_supported(auths,
958 RTE_DIM(auths)) != 0) {
959 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
960 "testsuite not met\n");
968 zuc_testsuite_setup(void)
970 struct crypto_testsuite_params *ts_params = &testsuite_params;
971 uint8_t dev_id = ts_params->valid_devs[0];
972 struct rte_cryptodev_info dev_info;
973 const enum rte_crypto_cipher_algorithm ciphers[] = {
974 RTE_CRYPTO_CIPHER_ZUC_EEA3
976 const enum rte_crypto_auth_algorithm auths[] = {
977 RTE_CRYPTO_AUTH_ZUC_EIA3
980 rte_cryptodev_info_get(dev_id, &dev_info);
982 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
983 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
984 "testsuite not met\n");
988 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
989 && check_auth_capabilities_supported(auths,
990 RTE_DIM(auths)) != 0) {
991 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
992 "testsuite not met\n");
1000 hmac_md5_auth_testsuite_setup(void)
1002 struct crypto_testsuite_params *ts_params = &testsuite_params;
1003 uint8_t dev_id = ts_params->valid_devs[0];
1004 struct rte_cryptodev_info dev_info;
1005 const enum rte_crypto_auth_algorithm auths[] = {
1006 RTE_CRYPTO_AUTH_MD5_HMAC
1009 rte_cryptodev_info_get(dev_id, &dev_info);
1011 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1012 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1013 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1014 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1015 "Auth testsuite not met\n");
1016 return TEST_SKIPPED;
1019 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1020 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1021 "testsuite not met\n");
1022 return TEST_SKIPPED;
1029 kasumi_testsuite_setup(void)
1031 struct crypto_testsuite_params *ts_params = &testsuite_params;
1032 uint8_t dev_id = ts_params->valid_devs[0];
1033 struct rte_cryptodev_info dev_info;
1034 const enum rte_crypto_cipher_algorithm ciphers[] = {
1035 RTE_CRYPTO_CIPHER_KASUMI_F8
1037 const enum rte_crypto_auth_algorithm auths[] = {
1038 RTE_CRYPTO_AUTH_KASUMI_F9
1041 rte_cryptodev_info_get(dev_id, &dev_info);
1043 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1044 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1045 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1046 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1047 "testsuite not met\n");
1048 return TEST_SKIPPED;
1051 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1052 && check_auth_capabilities_supported(auths,
1053 RTE_DIM(auths)) != 0) {
1054 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1055 "testsuite not met\n");
1056 return TEST_SKIPPED;
1063 negative_aes_gcm_testsuite_setup(void)
1065 struct crypto_testsuite_params *ts_params = &testsuite_params;
1066 uint8_t dev_id = ts_params->valid_devs[0];
1067 struct rte_cryptodev_info dev_info;
1068 const enum rte_crypto_aead_algorithm aeads[] = {
1069 RTE_CRYPTO_AEAD_AES_GCM
1072 rte_cryptodev_info_get(dev_id, &dev_info);
1074 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1075 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1076 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1077 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1078 "AES GCM testsuite not met\n");
1079 return TEST_SKIPPED;
1082 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1083 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1084 "AES GCM testsuite not met\n");
1085 return TEST_SKIPPED;
1092 negative_aes_gmac_testsuite_setup(void)
1094 struct crypto_testsuite_params *ts_params = &testsuite_params;
1095 uint8_t dev_id = ts_params->valid_devs[0];
1096 struct rte_cryptodev_info dev_info;
1097 const enum rte_crypto_auth_algorithm auths[] = {
1098 RTE_CRYPTO_AUTH_AES_GMAC
1101 rte_cryptodev_info_get(dev_id, &dev_info);
1103 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1104 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1105 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1106 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1107 "AES GMAC testsuite not met\n");
1108 return TEST_SKIPPED;
1111 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1112 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1113 "AES GMAC testsuite not met\n");
1114 return TEST_SKIPPED;
1121 mixed_cipher_hash_testsuite_setup(void)
1123 struct crypto_testsuite_params *ts_params = &testsuite_params;
1124 uint8_t dev_id = ts_params->valid_devs[0];
1125 struct rte_cryptodev_info dev_info;
1126 uint64_t feat_flags;
1127 const enum rte_crypto_cipher_algorithm ciphers[] = {
1128 RTE_CRYPTO_CIPHER_NULL,
1129 RTE_CRYPTO_CIPHER_AES_CTR,
1130 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1131 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1133 const enum rte_crypto_auth_algorithm auths[] = {
1134 RTE_CRYPTO_AUTH_NULL,
1135 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1136 RTE_CRYPTO_AUTH_AES_CMAC,
1137 RTE_CRYPTO_AUTH_ZUC_EIA3
1140 rte_cryptodev_info_get(dev_id, &dev_info);
1141 feat_flags = dev_info.feature_flags;
1143 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1144 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1145 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1146 "Cipher Hash testsuite not met\n");
1147 return TEST_SKIPPED;
1150 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1151 && check_auth_capabilities_supported(auths,
1152 RTE_DIM(auths)) != 0) {
1153 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1154 "Cipher Hash testsuite not met\n");
1155 return TEST_SKIPPED;
1162 esn_testsuite_setup(void)
1164 struct crypto_testsuite_params *ts_params = &testsuite_params;
1165 uint8_t dev_id = ts_params->valid_devs[0];
1166 struct rte_cryptodev_info dev_info;
1167 const enum rte_crypto_cipher_algorithm ciphers[] = {
1168 RTE_CRYPTO_CIPHER_AES_CBC
1170 const enum rte_crypto_auth_algorithm auths[] = {
1171 RTE_CRYPTO_AUTH_SHA1_HMAC
1174 rte_cryptodev_info_get(dev_id, &dev_info);
1176 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1177 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1178 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1179 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1180 "testsuite not met\n");
1181 return TEST_SKIPPED;
1184 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1185 && check_auth_capabilities_supported(auths,
1186 RTE_DIM(auths)) != 0) {
1187 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1188 "testsuite not met\n");
1189 return TEST_SKIPPED;
1196 multi_session_testsuite_setup(void)
1198 struct crypto_testsuite_params *ts_params = &testsuite_params;
1199 uint8_t dev_id = ts_params->valid_devs[0];
1200 struct rte_cryptodev_info dev_info;
1201 const enum rte_crypto_cipher_algorithm ciphers[] = {
1202 RTE_CRYPTO_CIPHER_AES_CBC
1204 const enum rte_crypto_auth_algorithm auths[] = {
1205 RTE_CRYPTO_AUTH_SHA512_HMAC
1208 rte_cryptodev_info_get(dev_id, &dev_info);
1210 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1211 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1212 "Session testsuite not met\n");
1213 return TEST_SKIPPED;
1216 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1217 && check_auth_capabilities_supported(auths,
1218 RTE_DIM(auths)) != 0) {
1219 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1220 "Session testsuite not met\n");
1221 return TEST_SKIPPED;
1228 negative_hmac_sha1_testsuite_setup(void)
1230 struct crypto_testsuite_params *ts_params = &testsuite_params;
1231 uint8_t dev_id = ts_params->valid_devs[0];
1232 struct rte_cryptodev_info dev_info;
1233 const enum rte_crypto_cipher_algorithm ciphers[] = {
1234 RTE_CRYPTO_CIPHER_AES_CBC
1236 const enum rte_crypto_auth_algorithm auths[] = {
1237 RTE_CRYPTO_AUTH_SHA1_HMAC
1240 rte_cryptodev_info_get(dev_id, &dev_info);
1242 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1243 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1244 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1245 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1246 "HMAC SHA1 testsuite not met\n");
1247 return TEST_SKIPPED;
1250 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1251 && check_auth_capabilities_supported(auths,
1252 RTE_DIM(auths)) != 0) {
1253 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1254 "HMAC SHA1 testsuite not met\n");
1255 return TEST_SKIPPED;
1262 dev_configure_and_start(uint64_t ff_disable)
1264 struct crypto_testsuite_params *ts_params = &testsuite_params;
1265 struct crypto_unittest_params *ut_params = &unittest_params;
1269 /* Clear unit test parameters before running test */
1270 memset(ut_params, 0, sizeof(*ut_params));
1272 /* Reconfigure device to default parameters */
1273 ts_params->conf.socket_id = SOCKET_ID_ANY;
1274 ts_params->conf.ff_disable = ff_disable;
1275 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1276 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1277 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1279 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1281 "Failed to configure cryptodev %u",
1282 ts_params->valid_devs[0]);
1284 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1285 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1286 ts_params->valid_devs[0], qp_id,
1287 &ts_params->qp_conf,
1288 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1289 "Failed to setup queue pair %u on cryptodev %u",
1290 qp_id, ts_params->valid_devs[0]);
1294 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1296 /* Start the device */
1297 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1298 "Failed to start cryptodev %u",
1299 ts_params->valid_devs[0]);
1301 return TEST_SUCCESS;
1307 /* Configure and start the device with security feature disabled */
1308 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1312 ut_setup_security(void)
1314 /* Configure and start the device with no features disabled */
1315 return dev_configure_and_start(0);
1321 struct crypto_testsuite_params *ts_params = &testsuite_params;
1322 struct crypto_unittest_params *ut_params = &unittest_params;
1323 struct rte_cryptodev_stats stats;
1325 /* free crypto session structure */
1326 #ifdef RTE_LIB_SECURITY
1327 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1328 if (ut_params->sec_session) {
1329 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1330 (ts_params->valid_devs[0]),
1331 ut_params->sec_session);
1332 ut_params->sec_session = NULL;
1337 if (ut_params->sess) {
1338 rte_cryptodev_sym_session_clear(
1339 ts_params->valid_devs[0],
1341 rte_cryptodev_sym_session_free(ut_params->sess);
1342 ut_params->sess = NULL;
1346 /* free crypto operation structure */
1348 rte_crypto_op_free(ut_params->op);
1351 * free mbuf - both obuf and ibuf are usually the same,
1352 * so check if they point at the same address is necessary,
1353 * to avoid freeing the mbuf twice.
1355 if (ut_params->obuf) {
1356 rte_pktmbuf_free(ut_params->obuf);
1357 if (ut_params->ibuf == ut_params->obuf)
1358 ut_params->ibuf = 0;
1359 ut_params->obuf = 0;
1361 if (ut_params->ibuf) {
1362 rte_pktmbuf_free(ut_params->ibuf);
1363 ut_params->ibuf = 0;
1366 if (ts_params->mbuf_pool != NULL)
1367 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1368 rte_mempool_avail_count(ts_params->mbuf_pool));
1370 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1372 /* Stop the device */
1373 rte_cryptodev_stop(ts_params->valid_devs[0]);
1377 test_device_configure_invalid_dev_id(void)
1379 struct crypto_testsuite_params *ts_params = &testsuite_params;
1380 uint16_t dev_id, num_devs = 0;
1382 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1383 "Need at least %d devices for test", 1);
1385 /* valid dev_id values */
1386 dev_id = ts_params->valid_devs[0];
1388 /* Stop the device in case it's started so it can be configured */
1389 rte_cryptodev_stop(dev_id);
1391 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1392 "Failed test for rte_cryptodev_configure: "
1393 "invalid dev_num %u", dev_id);
1395 /* invalid dev_id values */
1398 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1399 "Failed test for rte_cryptodev_configure: "
1400 "invalid dev_num %u", dev_id);
1404 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1405 "Failed test for rte_cryptodev_configure:"
1406 "invalid dev_num %u", dev_id);
1408 return TEST_SUCCESS;
1412 test_device_configure_invalid_queue_pair_ids(void)
1414 struct crypto_testsuite_params *ts_params = &testsuite_params;
1415 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1417 /* Stop the device in case it's started so it can be configured */
1418 rte_cryptodev_stop(ts_params->valid_devs[0]);
1420 /* valid - max value queue pairs */
1421 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1423 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1425 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1426 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1428 /* valid - one queue pairs */
1429 ts_params->conf.nb_queue_pairs = 1;
1431 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1433 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1434 ts_params->valid_devs[0],
1435 ts_params->conf.nb_queue_pairs);
1438 /* invalid - zero queue pairs */
1439 ts_params->conf.nb_queue_pairs = 0;
1441 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1443 "Failed test for rte_cryptodev_configure, dev_id %u,"
1445 ts_params->valid_devs[0],
1446 ts_params->conf.nb_queue_pairs);
1449 /* invalid - max value supported by field queue pairs */
1450 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1452 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1454 "Failed test for rte_cryptodev_configure, dev_id %u,"
1456 ts_params->valid_devs[0],
1457 ts_params->conf.nb_queue_pairs);
1460 /* invalid - max value + 1 queue pairs */
1461 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1463 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1465 "Failed test for rte_cryptodev_configure, dev_id %u,"
1467 ts_params->valid_devs[0],
1468 ts_params->conf.nb_queue_pairs);
1470 /* revert to original testsuite value */
1471 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1473 return TEST_SUCCESS;
1477 test_queue_pair_descriptor_setup(void)
1479 struct crypto_testsuite_params *ts_params = &testsuite_params;
1480 struct rte_cryptodev_qp_conf qp_conf = {
1481 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1485 /* Stop the device in case it's started so it can be configured */
1486 rte_cryptodev_stop(ts_params->valid_devs[0]);
1488 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1490 "Failed to configure cryptodev %u",
1491 ts_params->valid_devs[0]);
1494 * Test various ring sizes on this device. memzones can't be
1495 * freed so are re-used if ring is released and re-created.
1497 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1498 qp_conf.mp_session = ts_params->session_mpool;
1499 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1501 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1502 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1503 ts_params->valid_devs[0], qp_id, &qp_conf,
1504 rte_cryptodev_socket_id(
1505 ts_params->valid_devs[0])),
1507 "rte_cryptodev_queue_pair_setup: num_inflights "
1508 "%u on qp %u on cryptodev %u",
1509 qp_conf.nb_descriptors, qp_id,
1510 ts_params->valid_devs[0]);
1513 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1515 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1516 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1517 ts_params->valid_devs[0], qp_id, &qp_conf,
1518 rte_cryptodev_socket_id(
1519 ts_params->valid_devs[0])),
1521 " rte_cryptodev_queue_pair_setup: num_inflights"
1522 " %u on qp %u on cryptodev %u",
1523 qp_conf.nb_descriptors, qp_id,
1524 ts_params->valid_devs[0]);
1527 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1529 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1530 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1531 ts_params->valid_devs[0], qp_id, &qp_conf,
1532 rte_cryptodev_socket_id(
1533 ts_params->valid_devs[0])),
1535 "rte_cryptodev_queue_pair_setup: num_inflights"
1536 " %u on qp %u on cryptodev %u",
1537 qp_conf.nb_descriptors, qp_id,
1538 ts_params->valid_devs[0]);
1541 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1543 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1544 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1545 ts_params->valid_devs[0], qp_id, &qp_conf,
1546 rte_cryptodev_socket_id(
1547 ts_params->valid_devs[0])),
1549 " rte_cryptodev_queue_pair_setup:"
1550 "num_inflights %u on qp %u on cryptodev %u",
1551 qp_conf.nb_descriptors, qp_id,
1552 ts_params->valid_devs[0]);
1555 /* test invalid queue pair id */
1556 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1558 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1560 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1561 ts_params->valid_devs[0],
1563 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1564 "Failed test for rte_cryptodev_queue_pair_setup:"
1565 "invalid qp %u on cryptodev %u",
1566 qp_id, ts_params->valid_devs[0]);
1568 qp_id = 0xffff; /*invalid*/
1570 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1571 ts_params->valid_devs[0],
1573 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1574 "Failed test for rte_cryptodev_queue_pair_setup:"
1575 "invalid qp %u on cryptodev %u",
1576 qp_id, ts_params->valid_devs[0]);
1578 return TEST_SUCCESS;
1581 /* ***** Plaintext data for tests ***** */
1583 const char catch_22_quote_1[] =
1584 "There was only one catch and that was Catch-22, which "
1585 "specified that a concern for one's safety in the face of "
1586 "dangers that were real and immediate was the process of a "
1587 "rational mind. Orr was crazy and could be grounded. All he "
1588 "had to do was ask; and as soon as he did, he would no longer "
1589 "be crazy and would have to fly more missions. Orr would be "
1590 "crazy to fly more missions and sane if he didn't, but if he "
1591 "was sane he had to fly them. If he flew them he was crazy "
1592 "and didn't have to; but if he didn't want to he was sane and "
1593 "had to. Yossarian was moved very deeply by the absolute "
1594 "simplicity of this clause of Catch-22 and let out a "
1595 "respectful whistle. \"That's some catch, that Catch-22\", he "
1596 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1598 const char catch_22_quote[] =
1599 "What a lousy earth! He wondered how many people were "
1600 "destitute that same night even in his own prosperous country, "
1601 "how many homes were shanties, how many husbands were drunk "
1602 "and wives socked, and how many children were bullied, abused, "
1603 "or abandoned. How many families hungered for food they could "
1604 "not afford to buy? How many hearts were broken? How many "
1605 "suicides would take place that same night, how many people "
1606 "would go insane? How many cockroaches and landlords would "
1607 "triumph? How many winners were losers, successes failures, "
1608 "and rich men poor men? How many wise guys were stupid? How "
1609 "many happy endings were unhappy endings? How many honest men "
1610 "were liars, brave men cowards, loyal men traitors, how many "
1611 "sainted men were corrupt, how many people in positions of "
1612 "trust had sold their souls to bodyguards, how many had never "
1613 "had souls? How many straight-and-narrow paths were crooked "
1614 "paths? How many best families were worst families and how "
1615 "many good people were bad people? When you added them all up "
1616 "and then subtracted, you might be left with only the children, "
1617 "and perhaps with Albert Einstein and an old violinist or "
1618 "sculptor somewhere.";
1620 #define QUOTE_480_BYTES (480)
1621 #define QUOTE_512_BYTES (512)
1622 #define QUOTE_768_BYTES (768)
1623 #define QUOTE_1024_BYTES (1024)
1627 /* ***** SHA1 Hash Tests ***** */
1629 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1631 static uint8_t hmac_sha1_key[] = {
1632 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1633 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1634 0xDE, 0xF4, 0xDE, 0xAD };
1636 /* ***** SHA224 Hash Tests ***** */
1638 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1641 /* ***** AES-CBC Cipher Tests ***** */
1643 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1644 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1646 static uint8_t aes_cbc_key[] = {
1647 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1648 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1650 static uint8_t aes_cbc_iv[] = {
1651 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1652 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1655 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1657 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1658 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1659 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1660 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1661 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1662 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1663 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1664 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1665 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1666 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1667 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1668 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1669 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1670 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1671 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1672 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1673 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1674 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1675 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1676 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1677 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1678 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1679 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1680 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1681 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1682 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1683 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1684 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1685 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1686 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1687 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1688 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1689 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1690 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1691 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1692 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1693 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1694 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1695 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1696 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1697 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1698 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1699 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1700 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1701 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1702 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1703 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1704 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1705 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1706 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1707 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1708 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1709 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1710 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1711 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1712 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1713 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1714 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1715 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1716 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1717 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1718 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1719 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1720 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1721 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1724 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1725 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1726 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1727 0x18, 0x8c, 0x1d, 0x32
1731 /* Multisession Vector context Test */
1732 /*Begin Session 0 */
1733 static uint8_t ms_aes_cbc_key0[] = {
1734 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1735 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1738 static uint8_t ms_aes_cbc_iv0[] = {
1739 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1740 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1743 static const uint8_t ms_aes_cbc_cipher0[] = {
1744 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1745 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1746 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1747 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1748 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1749 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1750 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1751 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1752 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1753 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1754 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1755 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1756 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1757 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1758 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1759 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1760 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1761 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1762 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1763 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1764 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1765 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1766 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1767 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1768 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1769 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1770 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1771 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1772 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1773 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1774 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1775 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1776 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1777 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1778 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1779 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1780 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1781 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1782 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1783 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1784 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1785 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1786 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1787 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1788 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1789 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1790 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1791 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1792 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1793 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1794 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1795 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1796 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1797 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1798 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1799 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1800 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1801 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1802 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1803 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1804 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1805 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1806 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1807 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1811 static uint8_t ms_hmac_key0[] = {
1812 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1813 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1814 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1815 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1816 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1817 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1818 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1819 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1822 static const uint8_t ms_hmac_digest0[] = {
1823 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1824 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1825 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1826 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1827 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1828 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1829 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1830 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1834 /* Begin session 1 */
1836 static uint8_t ms_aes_cbc_key1[] = {
1837 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1838 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1841 static uint8_t ms_aes_cbc_iv1[] = {
1842 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1843 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1846 static const uint8_t ms_aes_cbc_cipher1[] = {
1847 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1848 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1849 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1850 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1851 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1852 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1853 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1854 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1855 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1856 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1857 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1858 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1859 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1860 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1861 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1862 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1863 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1864 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1865 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1866 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1867 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1868 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1869 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1870 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1871 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1872 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1873 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1874 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1875 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1876 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1877 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1878 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1879 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1880 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1881 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1882 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1883 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1884 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1885 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1886 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1887 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1888 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1889 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1890 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1891 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1892 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1893 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1894 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1895 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1896 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1897 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1898 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1899 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1900 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1901 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1902 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1903 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1904 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1905 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1906 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1907 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1908 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1909 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1910 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1914 static uint8_t ms_hmac_key1[] = {
1915 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1916 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1917 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1918 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1919 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1920 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1921 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1922 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1925 static const uint8_t ms_hmac_digest1[] = {
1926 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1927 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1928 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1929 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1930 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1931 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1932 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1933 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1936 /* Begin Session 2 */
1937 static uint8_t ms_aes_cbc_key2[] = {
1938 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1939 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1942 static uint8_t ms_aes_cbc_iv2[] = {
1943 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1944 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1947 static const uint8_t ms_aes_cbc_cipher2[] = {
1948 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1949 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1950 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1951 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1952 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1953 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1954 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1955 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1956 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1957 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1958 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1959 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1960 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1961 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1962 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1963 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1964 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1965 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1966 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1967 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1968 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1969 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1970 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1971 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1972 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1973 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1974 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1975 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1976 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1977 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1978 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1979 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1980 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1981 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1982 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1983 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1984 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1985 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1986 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1987 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1988 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1989 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1990 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1991 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1992 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1993 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1994 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1995 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1996 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1997 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1998 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1999 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2000 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2001 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2002 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2003 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2004 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2005 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2006 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2007 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2008 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2009 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2010 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2011 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2014 static uint8_t ms_hmac_key2[] = {
2015 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2016 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2017 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2018 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2019 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2020 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2021 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2022 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2025 static const uint8_t ms_hmac_digest2[] = {
2026 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2027 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2028 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2029 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2030 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2031 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2032 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2033 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2040 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2042 struct crypto_testsuite_params *ts_params = &testsuite_params;
2043 struct crypto_unittest_params *ut_params = &unittest_params;
2045 /* Verify the capabilities */
2046 struct rte_cryptodev_sym_capability_idx cap_idx;
2047 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2048 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2049 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2051 return TEST_SKIPPED;
2052 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2053 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2054 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2056 return TEST_SKIPPED;
2058 /* Generate test mbuf data and space for digest */
2059 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2060 catch_22_quote, QUOTE_512_BYTES, 0);
2062 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2063 DIGEST_BYTE_LENGTH_SHA1);
2064 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2066 /* Setup Cipher Parameters */
2067 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2068 ut_params->cipher_xform.next = &ut_params->auth_xform;
2070 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2071 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2072 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2073 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2074 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2075 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2077 /* Setup HMAC Parameters */
2078 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2080 ut_params->auth_xform.next = NULL;
2082 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2083 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2084 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2085 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2086 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2088 ut_params->sess = rte_cryptodev_sym_session_create(
2089 ts_params->session_mpool);
2091 /* Create crypto session*/
2092 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2093 ut_params->sess, &ut_params->cipher_xform,
2094 ts_params->session_priv_mpool);
2095 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2097 /* Generate crypto op data structure */
2098 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2099 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2100 TEST_ASSERT_NOT_NULL(ut_params->op,
2101 "Failed to allocate symmetric crypto operation struct");
2103 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2105 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2107 /* set crypto operation source mbuf */
2108 sym_op->m_src = ut_params->ibuf;
2110 /* Set crypto operation authentication parameters */
2111 sym_op->auth.digest.data = ut_params->digest;
2112 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2113 ut_params->ibuf, QUOTE_512_BYTES);
2115 sym_op->auth.data.offset = 0;
2116 sym_op->auth.data.length = QUOTE_512_BYTES;
2118 /* Copy IV at the end of the crypto operation */
2119 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2120 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2122 /* Set crypto operation cipher parameters */
2123 sym_op->cipher.data.offset = 0;
2124 sym_op->cipher.data.length = QUOTE_512_BYTES;
2126 /* Process crypto operation */
2127 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2128 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2131 TEST_ASSERT_NOT_NULL(
2132 process_crypto_request(ts_params->valid_devs[0],
2134 "failed to process sym crypto op");
2136 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2137 "crypto op processing failed");
2140 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2143 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2144 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2146 "ciphertext data not as expected");
2148 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2150 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2151 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2152 gbl_driver_id == rte_cryptodev_driver_id_get(
2153 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2154 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2155 DIGEST_BYTE_LENGTH_SHA1,
2156 "Generated digest data not as expected");
2158 return TEST_SUCCESS;
2161 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2163 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2165 static uint8_t hmac_sha512_key[] = {
2166 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2167 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2168 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2169 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2170 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2171 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2172 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2173 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2175 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2176 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2177 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2178 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2179 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2180 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2181 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2182 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2183 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2188 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2189 struct crypto_unittest_params *ut_params,
2190 uint8_t *cipher_key,
2194 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2195 struct crypto_unittest_params *ut_params,
2196 struct crypto_testsuite_params *ts_params,
2197 const uint8_t *cipher,
2198 const uint8_t *digest,
2203 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2204 struct crypto_unittest_params *ut_params,
2205 uint8_t *cipher_key,
2209 /* Setup Cipher Parameters */
2210 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2211 ut_params->cipher_xform.next = NULL;
2213 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2214 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2215 ut_params->cipher_xform.cipher.key.data = cipher_key;
2216 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2217 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2218 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2220 /* Setup HMAC Parameters */
2221 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2222 ut_params->auth_xform.next = &ut_params->cipher_xform;
2224 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2225 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2226 ut_params->auth_xform.auth.key.data = hmac_key;
2227 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2228 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2230 return TEST_SUCCESS;
2235 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2236 struct crypto_unittest_params *ut_params,
2237 struct crypto_testsuite_params *ts_params,
2238 const uint8_t *cipher,
2239 const uint8_t *digest,
2242 /* Generate test mbuf data and digest */
2243 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2246 QUOTE_512_BYTES, 0);
2248 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2249 DIGEST_BYTE_LENGTH_SHA512);
2250 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2252 rte_memcpy(ut_params->digest,
2254 DIGEST_BYTE_LENGTH_SHA512);
2256 /* Generate Crypto op data structure */
2257 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2258 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2259 TEST_ASSERT_NOT_NULL(ut_params->op,
2260 "Failed to allocate symmetric crypto operation struct");
2262 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2264 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2266 /* set crypto operation source mbuf */
2267 sym_op->m_src = ut_params->ibuf;
2269 sym_op->auth.digest.data = ut_params->digest;
2270 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2271 ut_params->ibuf, QUOTE_512_BYTES);
2273 sym_op->auth.data.offset = 0;
2274 sym_op->auth.data.length = QUOTE_512_BYTES;
2276 /* Copy IV at the end of the crypto operation */
2277 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2278 iv, CIPHER_IV_LENGTH_AES_CBC);
2280 sym_op->cipher.data.offset = 0;
2281 sym_op->cipher.data.length = QUOTE_512_BYTES;
2283 /* Process crypto operation */
2284 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2285 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2287 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2288 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2289 ut_params->op, 1, 1, 0, 0);
2291 TEST_ASSERT_NOT_NULL(
2292 process_crypto_request(ts_params->valid_devs[0],
2294 "failed to process sym crypto op");
2296 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2297 "crypto op processing failed");
2299 ut_params->obuf = ut_params->op->sym->m_src;
2302 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2303 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2306 "Plaintext data not as expected");
2309 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2310 "Digest verification failed");
2312 return TEST_SUCCESS;
2316 test_blockcipher(enum blockcipher_test_type test_type)
2318 struct crypto_testsuite_params *ts_params = &testsuite_params;
2321 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2322 ts_params->op_mpool,
2323 ts_params->session_mpool, ts_params->session_priv_mpool,
2324 ts_params->valid_devs[0],
2327 if (status == -ENOTSUP)
2330 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2332 return TEST_SUCCESS;
2336 test_AES_cipheronly_all(void)
2338 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
2342 test_AES_docsis_all(void)
2344 /* Data-path service does not support DOCSIS yet */
2345 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2346 return TEST_SKIPPED;
2347 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
2351 test_DES_docsis_all(void)
2353 /* Data-path service does not support DOCSIS yet */
2354 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2355 return TEST_SKIPPED;
2356 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
2360 test_DES_cipheronly_all(void)
2362 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
2366 test_authonly_all(void)
2368 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
2372 test_AES_chain_all(void)
2374 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
2378 test_3DES_chain_all(void)
2380 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
2384 test_3DES_cipheronly_all(void)
2386 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
2389 /* ***** SNOW 3G Tests ***** */
2391 create_wireless_algo_hash_session(uint8_t dev_id,
2392 const uint8_t *key, const uint8_t key_len,
2393 const uint8_t iv_len, const uint8_t auth_len,
2394 enum rte_crypto_auth_operation op,
2395 enum rte_crypto_auth_algorithm algo)
2397 uint8_t hash_key[key_len];
2400 struct crypto_testsuite_params *ts_params = &testsuite_params;
2401 struct crypto_unittest_params *ut_params = &unittest_params;
2403 memcpy(hash_key, key, key_len);
2405 debug_hexdump(stdout, "key:", key, key_len);
2407 /* Setup Authentication Parameters */
2408 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2409 ut_params->auth_xform.next = NULL;
2411 ut_params->auth_xform.auth.op = op;
2412 ut_params->auth_xform.auth.algo = algo;
2413 ut_params->auth_xform.auth.key.length = key_len;
2414 ut_params->auth_xform.auth.key.data = hash_key;
2415 ut_params->auth_xform.auth.digest_length = auth_len;
2416 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2417 ut_params->auth_xform.auth.iv.length = iv_len;
2418 ut_params->sess = rte_cryptodev_sym_session_create(
2419 ts_params->session_mpool);
2421 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2422 &ut_params->auth_xform,
2423 ts_params->session_priv_mpool);
2424 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2425 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2430 create_wireless_algo_cipher_session(uint8_t dev_id,
2431 enum rte_crypto_cipher_operation op,
2432 enum rte_crypto_cipher_algorithm algo,
2433 const uint8_t *key, const uint8_t key_len,
2436 uint8_t cipher_key[key_len];
2438 struct crypto_testsuite_params *ts_params = &testsuite_params;
2439 struct crypto_unittest_params *ut_params = &unittest_params;
2441 memcpy(cipher_key, key, key_len);
2443 /* Setup Cipher Parameters */
2444 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2445 ut_params->cipher_xform.next = NULL;
2447 ut_params->cipher_xform.cipher.algo = algo;
2448 ut_params->cipher_xform.cipher.op = op;
2449 ut_params->cipher_xform.cipher.key.data = cipher_key;
2450 ut_params->cipher_xform.cipher.key.length = key_len;
2451 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2452 ut_params->cipher_xform.cipher.iv.length = iv_len;
2454 debug_hexdump(stdout, "key:", key, key_len);
2456 /* Create Crypto session */
2457 ut_params->sess = rte_cryptodev_sym_session_create(
2458 ts_params->session_mpool);
2460 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2461 &ut_params->cipher_xform,
2462 ts_params->session_priv_mpool);
2463 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2464 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2469 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2470 unsigned int cipher_len,
2471 unsigned int cipher_offset)
2473 struct crypto_testsuite_params *ts_params = &testsuite_params;
2474 struct crypto_unittest_params *ut_params = &unittest_params;
2476 /* Generate Crypto op data structure */
2477 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2478 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2479 TEST_ASSERT_NOT_NULL(ut_params->op,
2480 "Failed to allocate pktmbuf offload");
2482 /* Set crypto operation data parameters */
2483 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2485 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2487 /* set crypto operation source mbuf */
2488 sym_op->m_src = ut_params->ibuf;
2491 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2493 sym_op->cipher.data.length = cipher_len;
2494 sym_op->cipher.data.offset = cipher_offset;
2499 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2500 unsigned int cipher_len,
2501 unsigned int cipher_offset)
2503 struct crypto_testsuite_params *ts_params = &testsuite_params;
2504 struct crypto_unittest_params *ut_params = &unittest_params;
2506 /* Generate Crypto op data structure */
2507 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2508 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2509 TEST_ASSERT_NOT_NULL(ut_params->op,
2510 "Failed to allocate pktmbuf offload");
2512 /* Set crypto operation data parameters */
2513 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2515 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2517 /* set crypto operation source mbuf */
2518 sym_op->m_src = ut_params->ibuf;
2519 sym_op->m_dst = ut_params->obuf;
2522 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2524 sym_op->cipher.data.length = cipher_len;
2525 sym_op->cipher.data.offset = cipher_offset;
2530 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2531 enum rte_crypto_cipher_operation cipher_op,
2532 enum rte_crypto_auth_operation auth_op,
2533 enum rte_crypto_auth_algorithm auth_algo,
2534 enum rte_crypto_cipher_algorithm cipher_algo,
2535 const uint8_t *key, uint8_t key_len,
2536 uint8_t auth_iv_len, uint8_t auth_len,
2537 uint8_t cipher_iv_len)
2540 uint8_t cipher_auth_key[key_len];
2543 struct crypto_testsuite_params *ts_params = &testsuite_params;
2544 struct crypto_unittest_params *ut_params = &unittest_params;
2546 memcpy(cipher_auth_key, key, key_len);
2548 /* Setup Authentication Parameters */
2549 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2550 ut_params->auth_xform.next = NULL;
2552 ut_params->auth_xform.auth.op = auth_op;
2553 ut_params->auth_xform.auth.algo = auth_algo;
2554 ut_params->auth_xform.auth.key.length = key_len;
2555 /* Hash key = cipher key */
2556 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2557 ut_params->auth_xform.auth.digest_length = auth_len;
2558 /* Auth IV will be after cipher IV */
2559 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2560 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2562 /* Setup Cipher Parameters */
2563 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2564 ut_params->cipher_xform.next = &ut_params->auth_xform;
2566 ut_params->cipher_xform.cipher.algo = cipher_algo;
2567 ut_params->cipher_xform.cipher.op = cipher_op;
2568 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2569 ut_params->cipher_xform.cipher.key.length = key_len;
2570 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2571 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2573 debug_hexdump(stdout, "key:", key, key_len);
2575 /* Create Crypto session*/
2576 ut_params->sess = rte_cryptodev_sym_session_create(
2577 ts_params->session_mpool);
2578 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2580 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2581 &ut_params->cipher_xform,
2582 ts_params->session_priv_mpool);
2583 if (status == -ENOTSUP)
2584 return TEST_SKIPPED;
2586 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2591 create_wireless_cipher_auth_session(uint8_t dev_id,
2592 enum rte_crypto_cipher_operation cipher_op,
2593 enum rte_crypto_auth_operation auth_op,
2594 enum rte_crypto_auth_algorithm auth_algo,
2595 enum rte_crypto_cipher_algorithm cipher_algo,
2596 const struct wireless_test_data *tdata)
2598 const uint8_t key_len = tdata->key.len;
2599 uint8_t cipher_auth_key[key_len];
2602 struct crypto_testsuite_params *ts_params = &testsuite_params;
2603 struct crypto_unittest_params *ut_params = &unittest_params;
2604 const uint8_t *key = tdata->key.data;
2605 const uint8_t auth_len = tdata->digest.len;
2606 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2607 uint8_t auth_iv_len = tdata->auth_iv.len;
2609 memcpy(cipher_auth_key, key, key_len);
2611 /* Setup Authentication Parameters */
2612 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2613 ut_params->auth_xform.next = NULL;
2615 ut_params->auth_xform.auth.op = auth_op;
2616 ut_params->auth_xform.auth.algo = auth_algo;
2617 ut_params->auth_xform.auth.key.length = key_len;
2618 /* Hash key = cipher key */
2619 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2620 ut_params->auth_xform.auth.digest_length = auth_len;
2621 /* Auth IV will be after cipher IV */
2622 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2623 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2625 /* Setup Cipher Parameters */
2626 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2627 ut_params->cipher_xform.next = &ut_params->auth_xform;
2629 ut_params->cipher_xform.cipher.algo = cipher_algo;
2630 ut_params->cipher_xform.cipher.op = cipher_op;
2631 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2632 ut_params->cipher_xform.cipher.key.length = key_len;
2633 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2634 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2637 debug_hexdump(stdout, "key:", key, key_len);
2639 /* Create Crypto session*/
2640 ut_params->sess = rte_cryptodev_sym_session_create(
2641 ts_params->session_mpool);
2643 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2644 &ut_params->cipher_xform,
2645 ts_params->session_priv_mpool);
2646 if (status == -ENOTSUP)
2647 return TEST_SKIPPED;
2649 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2650 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2655 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2656 const struct wireless_test_data *tdata)
2658 return create_wireless_cipher_auth_session(dev_id,
2659 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2660 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2661 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2665 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2666 enum rte_crypto_cipher_operation cipher_op,
2667 enum rte_crypto_auth_operation auth_op,
2668 enum rte_crypto_auth_algorithm auth_algo,
2669 enum rte_crypto_cipher_algorithm cipher_algo,
2670 const uint8_t *key, const uint8_t key_len,
2671 uint8_t auth_iv_len, uint8_t auth_len,
2672 uint8_t cipher_iv_len)
2674 uint8_t auth_cipher_key[key_len];
2676 struct crypto_testsuite_params *ts_params = &testsuite_params;
2677 struct crypto_unittest_params *ut_params = &unittest_params;
2679 memcpy(auth_cipher_key, key, key_len);
2681 /* Setup Authentication Parameters */
2682 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2683 ut_params->auth_xform.auth.op = auth_op;
2684 ut_params->auth_xform.next = &ut_params->cipher_xform;
2685 ut_params->auth_xform.auth.algo = auth_algo;
2686 ut_params->auth_xform.auth.key.length = key_len;
2687 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2688 ut_params->auth_xform.auth.digest_length = auth_len;
2689 /* Auth IV will be after cipher IV */
2690 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2691 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2693 /* Setup Cipher Parameters */
2694 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2695 ut_params->cipher_xform.next = NULL;
2696 ut_params->cipher_xform.cipher.algo = cipher_algo;
2697 ut_params->cipher_xform.cipher.op = cipher_op;
2698 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2699 ut_params->cipher_xform.cipher.key.length = key_len;
2700 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2701 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2703 debug_hexdump(stdout, "key:", key, key_len);
2705 /* Create Crypto session*/
2706 ut_params->sess = rte_cryptodev_sym_session_create(
2707 ts_params->session_mpool);
2708 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2710 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2711 ut_params->auth_xform.next = NULL;
2712 ut_params->cipher_xform.next = &ut_params->auth_xform;
2713 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2714 &ut_params->cipher_xform,
2715 ts_params->session_priv_mpool);
2718 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2719 &ut_params->auth_xform,
2720 ts_params->session_priv_mpool);
2722 if (status == -ENOTSUP)
2723 return TEST_SKIPPED;
2725 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2731 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2732 unsigned int auth_tag_len,
2733 const uint8_t *iv, unsigned int iv_len,
2734 unsigned int data_pad_len,
2735 enum rte_crypto_auth_operation op,
2736 unsigned int auth_len, unsigned int auth_offset)
2738 struct crypto_testsuite_params *ts_params = &testsuite_params;
2740 struct crypto_unittest_params *ut_params = &unittest_params;
2742 /* Generate Crypto op data structure */
2743 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2744 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2745 TEST_ASSERT_NOT_NULL(ut_params->op,
2746 "Failed to allocate pktmbuf offload");
2748 /* Set crypto operation data parameters */
2749 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2751 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2753 /* set crypto operation source mbuf */
2754 sym_op->m_src = ut_params->ibuf;
2757 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2760 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2761 ut_params->ibuf, auth_tag_len);
2763 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2764 "no room to append auth tag");
2765 ut_params->digest = sym_op->auth.digest.data;
2766 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2767 ut_params->ibuf, data_pad_len);
2768 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2769 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2771 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2773 debug_hexdump(stdout, "digest:",
2774 sym_op->auth.digest.data,
2777 sym_op->auth.data.length = auth_len;
2778 sym_op->auth.data.offset = auth_offset;
2784 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2785 enum rte_crypto_auth_operation op)
2787 struct crypto_testsuite_params *ts_params = &testsuite_params;
2788 struct crypto_unittest_params *ut_params = &unittest_params;
2790 const uint8_t *auth_tag = tdata->digest.data;
2791 const unsigned int auth_tag_len = tdata->digest.len;
2792 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2793 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2795 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2796 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2797 const uint8_t *auth_iv = tdata->auth_iv.data;
2798 const uint8_t auth_iv_len = tdata->auth_iv.len;
2799 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2800 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2802 /* Generate Crypto op data structure */
2803 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2804 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2805 TEST_ASSERT_NOT_NULL(ut_params->op,
2806 "Failed to allocate pktmbuf offload");
2807 /* Set crypto operation data parameters */
2808 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2810 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2812 /* set crypto operation source mbuf */
2813 sym_op->m_src = ut_params->ibuf;
2816 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2817 ut_params->ibuf, auth_tag_len);
2819 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2820 "no room to append auth tag");
2821 ut_params->digest = sym_op->auth.digest.data;
2822 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2823 ut_params->ibuf, data_pad_len);
2824 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2825 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2827 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2829 debug_hexdump(stdout, "digest:",
2830 sym_op->auth.digest.data,
2833 /* Copy cipher and auth IVs at the end of the crypto operation */
2834 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2836 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2837 iv_ptr += cipher_iv_len;
2838 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2840 sym_op->cipher.data.length = cipher_len;
2841 sym_op->cipher.data.offset = 0;
2842 sym_op->auth.data.length = auth_len;
2843 sym_op->auth.data.offset = 0;
2849 create_zuc_cipher_hash_generate_operation(
2850 const struct wireless_test_data *tdata)
2852 return create_wireless_cipher_hash_operation(tdata,
2853 RTE_CRYPTO_AUTH_OP_GENERATE);
2857 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2858 const unsigned auth_tag_len,
2859 const uint8_t *auth_iv, uint8_t auth_iv_len,
2860 unsigned data_pad_len,
2861 enum rte_crypto_auth_operation op,
2862 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2863 const unsigned cipher_len, const unsigned cipher_offset,
2864 const unsigned auth_len, const unsigned auth_offset)
2866 struct crypto_testsuite_params *ts_params = &testsuite_params;
2867 struct crypto_unittest_params *ut_params = &unittest_params;
2869 enum rte_crypto_cipher_algorithm cipher_algo =
2870 ut_params->cipher_xform.cipher.algo;
2871 enum rte_crypto_auth_algorithm auth_algo =
2872 ut_params->auth_xform.auth.algo;
2874 /* Generate Crypto op data structure */
2875 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2876 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2877 TEST_ASSERT_NOT_NULL(ut_params->op,
2878 "Failed to allocate pktmbuf offload");
2879 /* Set crypto operation data parameters */
2880 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2882 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2884 /* set crypto operation source mbuf */
2885 sym_op->m_src = ut_params->ibuf;
2888 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2889 ut_params->ibuf, auth_tag_len);
2891 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2892 "no room to append auth tag");
2893 ut_params->digest = sym_op->auth.digest.data;
2895 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2896 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2897 ut_params->ibuf, data_pad_len);
2899 struct rte_mbuf *m = ut_params->ibuf;
2900 unsigned int offset = data_pad_len;
2902 while (offset > m->data_len && m->next != NULL) {
2903 offset -= m->data_len;
2906 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2910 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2911 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2913 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2915 debug_hexdump(stdout, "digest:",
2916 sym_op->auth.digest.data,
2919 /* Copy cipher and auth IVs at the end of the crypto operation */
2920 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2922 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2923 iv_ptr += cipher_iv_len;
2924 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2926 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2927 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2928 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2929 sym_op->cipher.data.length = cipher_len;
2930 sym_op->cipher.data.offset = cipher_offset;
2932 sym_op->cipher.data.length = cipher_len >> 3;
2933 sym_op->cipher.data.offset = cipher_offset >> 3;
2936 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2937 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2938 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2939 sym_op->auth.data.length = auth_len;
2940 sym_op->auth.data.offset = auth_offset;
2942 sym_op->auth.data.length = auth_len >> 3;
2943 sym_op->auth.data.offset = auth_offset >> 3;
2950 create_wireless_algo_auth_cipher_operation(
2951 const uint8_t *auth_tag, unsigned int auth_tag_len,
2952 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2953 const uint8_t *auth_iv, uint8_t auth_iv_len,
2954 unsigned int data_pad_len,
2955 unsigned int cipher_len, unsigned int cipher_offset,
2956 unsigned int auth_len, unsigned int auth_offset,
2957 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2959 struct crypto_testsuite_params *ts_params = &testsuite_params;
2960 struct crypto_unittest_params *ut_params = &unittest_params;
2962 enum rte_crypto_cipher_algorithm cipher_algo =
2963 ut_params->cipher_xform.cipher.algo;
2964 enum rte_crypto_auth_algorithm auth_algo =
2965 ut_params->auth_xform.auth.algo;
2967 /* Generate Crypto op data structure */
2968 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2969 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2970 TEST_ASSERT_NOT_NULL(ut_params->op,
2971 "Failed to allocate pktmbuf offload");
2973 /* Set crypto operation data parameters */
2974 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2976 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2978 /* set crypto operation mbufs */
2979 sym_op->m_src = ut_params->ibuf;
2980 if (op_mode == OUT_OF_PLACE)
2981 sym_op->m_dst = ut_params->obuf;
2985 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2986 (op_mode == IN_PLACE ?
2987 ut_params->ibuf : ut_params->obuf),
2988 uint8_t *, data_pad_len);
2989 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2990 (op_mode == IN_PLACE ?
2991 ut_params->ibuf : ut_params->obuf),
2993 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2995 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2996 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2997 sym_op->m_src : sym_op->m_dst);
2998 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2999 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3000 sgl_buf = sgl_buf->next;
3002 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3003 uint8_t *, remaining_off);
3004 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3006 memset(sym_op->auth.digest.data, 0, remaining_off);
3007 while (sgl_buf->next != NULL) {
3008 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3009 0, rte_pktmbuf_data_len(sgl_buf));
3010 sgl_buf = sgl_buf->next;
3014 /* Copy digest for the verification */
3016 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3018 /* Copy cipher and auth IVs at the end of the crypto operation */
3019 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3020 ut_params->op, uint8_t *, IV_OFFSET);
3022 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3023 iv_ptr += cipher_iv_len;
3024 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3026 /* Only copy over the offset data needed from src to dst in OOP,
3027 * if the auth and cipher offsets are not aligned
3029 if (op_mode == OUT_OF_PLACE) {
3030 if (cipher_offset > auth_offset)
3032 rte_pktmbuf_mtod_offset(
3034 uint8_t *, auth_offset >> 3),
3035 rte_pktmbuf_mtod_offset(
3037 uint8_t *, auth_offset >> 3),
3038 ((cipher_offset >> 3) - (auth_offset >> 3)));
3041 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3042 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3043 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3044 sym_op->cipher.data.length = cipher_len;
3045 sym_op->cipher.data.offset = cipher_offset;
3047 sym_op->cipher.data.length = cipher_len >> 3;
3048 sym_op->cipher.data.offset = cipher_offset >> 3;
3051 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3052 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3053 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3054 sym_op->auth.data.length = auth_len;
3055 sym_op->auth.data.offset = auth_offset;
3057 sym_op->auth.data.length = auth_len >> 3;
3058 sym_op->auth.data.offset = auth_offset >> 3;
3065 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3067 struct crypto_testsuite_params *ts_params = &testsuite_params;
3068 struct crypto_unittest_params *ut_params = &unittest_params;
3071 unsigned plaintext_pad_len;
3072 unsigned plaintext_len;
3074 struct rte_cryptodev_info dev_info;
3076 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3077 uint64_t feat_flags = dev_info.feature_flags;
3079 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3080 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3081 printf("Device doesn't support NON-Byte Aligned Data.\n");
3082 return TEST_SKIPPED;
3085 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3086 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3087 printf("Device doesn't support RAW data-path APIs.\n");
3088 return TEST_SKIPPED;
3091 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3092 return TEST_SKIPPED;
3094 /* Verify the capabilities */
3095 struct rte_cryptodev_sym_capability_idx cap_idx;
3096 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3097 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3098 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3100 return TEST_SKIPPED;
3102 /* Create SNOW 3G session */
3103 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3104 tdata->key.data, tdata->key.len,
3105 tdata->auth_iv.len, tdata->digest.len,
3106 RTE_CRYPTO_AUTH_OP_GENERATE,
3107 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3111 /* alloc mbuf and set payload */
3112 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3114 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3115 rte_pktmbuf_tailroom(ut_params->ibuf));
3117 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3118 /* Append data which is padded to a multiple of */
3119 /* the algorithms block size */
3120 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3121 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3123 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3125 /* Create SNOW 3G operation */
3126 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3127 tdata->auth_iv.data, tdata->auth_iv.len,
3128 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3129 tdata->validAuthLenInBits.len,
3134 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3135 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3136 ut_params->op, 0, 1, 1, 0);
3138 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3140 ut_params->obuf = ut_params->op->sym->m_src;
3141 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3142 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3143 + plaintext_pad_len;
3146 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3149 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3150 "SNOW 3G Generated auth tag not as expected");
3156 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3158 struct crypto_testsuite_params *ts_params = &testsuite_params;
3159 struct crypto_unittest_params *ut_params = &unittest_params;
3162 unsigned plaintext_pad_len;
3163 unsigned plaintext_len;
3165 struct rte_cryptodev_info dev_info;
3167 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3168 uint64_t feat_flags = dev_info.feature_flags;
3170 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3171 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3172 printf("Device doesn't support NON-Byte Aligned Data.\n");
3173 return TEST_SKIPPED;
3176 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3177 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3178 printf("Device doesn't support RAW data-path APIs.\n");
3179 return TEST_SKIPPED;
3182 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3183 return TEST_SKIPPED;
3185 /* Verify the capabilities */
3186 struct rte_cryptodev_sym_capability_idx cap_idx;
3187 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3188 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3189 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3191 return TEST_SKIPPED;
3193 /* Create SNOW 3G session */
3194 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3195 tdata->key.data, tdata->key.len,
3196 tdata->auth_iv.len, tdata->digest.len,
3197 RTE_CRYPTO_AUTH_OP_VERIFY,
3198 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3201 /* alloc mbuf and set payload */
3202 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3204 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3205 rte_pktmbuf_tailroom(ut_params->ibuf));
3207 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3208 /* Append data which is padded to a multiple of */
3209 /* the algorithms block size */
3210 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3211 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3213 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3215 /* Create SNOW 3G operation */
3216 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3218 tdata->auth_iv.data, tdata->auth_iv.len,
3220 RTE_CRYPTO_AUTH_OP_VERIFY,
3221 tdata->validAuthLenInBits.len,
3226 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3227 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3228 ut_params->op, 0, 1, 1, 0);
3230 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3232 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3233 ut_params->obuf = ut_params->op->sym->m_src;
3234 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3235 + plaintext_pad_len;
3238 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3247 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3249 struct crypto_testsuite_params *ts_params = &testsuite_params;
3250 struct crypto_unittest_params *ut_params = &unittest_params;
3253 unsigned plaintext_pad_len;
3254 unsigned plaintext_len;
3256 struct rte_cryptodev_info dev_info;
3258 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3259 uint64_t feat_flags = dev_info.feature_flags;
3261 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3262 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3263 printf("Device doesn't support RAW data-path APIs.\n");
3264 return TEST_SKIPPED;
3267 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3268 return TEST_SKIPPED;
3270 /* Verify the capabilities */
3271 struct rte_cryptodev_sym_capability_idx cap_idx;
3272 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3273 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3274 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3276 return TEST_SKIPPED;
3278 /* Create KASUMI session */
3279 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3280 tdata->key.data, tdata->key.len,
3281 0, tdata->digest.len,
3282 RTE_CRYPTO_AUTH_OP_GENERATE,
3283 RTE_CRYPTO_AUTH_KASUMI_F9);
3287 /* alloc mbuf and set payload */
3288 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3290 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3291 rte_pktmbuf_tailroom(ut_params->ibuf));
3293 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3294 /* Append data which is padded to a multiple of */
3295 /* the algorithms block size */
3296 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3297 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3299 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3301 /* Create KASUMI operation */
3302 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3304 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3305 tdata->plaintext.len,
3310 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3311 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3313 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3314 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3315 ut_params->op, 0, 1, 1, 0);
3317 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3320 ut_params->obuf = ut_params->op->sym->m_src;
3321 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3322 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3323 + plaintext_pad_len;
3326 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3329 DIGEST_BYTE_LENGTH_KASUMI_F9,
3330 "KASUMI Generated auth tag not as expected");
3336 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3338 struct crypto_testsuite_params *ts_params = &testsuite_params;
3339 struct crypto_unittest_params *ut_params = &unittest_params;
3342 unsigned plaintext_pad_len;
3343 unsigned plaintext_len;
3345 struct rte_cryptodev_info dev_info;
3347 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3348 uint64_t feat_flags = dev_info.feature_flags;
3350 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3351 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3352 printf("Device doesn't support RAW data-path APIs.\n");
3353 return TEST_SKIPPED;
3356 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3357 return TEST_SKIPPED;
3359 /* Verify the capabilities */
3360 struct rte_cryptodev_sym_capability_idx cap_idx;
3361 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3362 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3363 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3365 return TEST_SKIPPED;
3367 /* Create KASUMI session */
3368 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3369 tdata->key.data, tdata->key.len,
3370 0, tdata->digest.len,
3371 RTE_CRYPTO_AUTH_OP_VERIFY,
3372 RTE_CRYPTO_AUTH_KASUMI_F9);
3375 /* alloc mbuf and set payload */
3376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3378 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3379 rte_pktmbuf_tailroom(ut_params->ibuf));
3381 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3382 /* Append data which is padded to a multiple */
3383 /* of the algorithms block size */
3384 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3385 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3387 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3389 /* Create KASUMI operation */
3390 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3394 RTE_CRYPTO_AUTH_OP_VERIFY,
3395 tdata->plaintext.len,
3400 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3401 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3402 ut_params->op, 0, 1, 1, 0);
3404 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3406 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3407 ut_params->obuf = ut_params->op->sym->m_src;
3408 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3409 + plaintext_pad_len;
3412 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3421 test_snow3g_hash_generate_test_case_1(void)
3423 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3427 test_snow3g_hash_generate_test_case_2(void)
3429 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3433 test_snow3g_hash_generate_test_case_3(void)
3435 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3439 test_snow3g_hash_generate_test_case_4(void)
3441 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3445 test_snow3g_hash_generate_test_case_5(void)
3447 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3451 test_snow3g_hash_generate_test_case_6(void)
3453 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3457 test_snow3g_hash_verify_test_case_1(void)
3459 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3464 test_snow3g_hash_verify_test_case_2(void)
3466 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3470 test_snow3g_hash_verify_test_case_3(void)
3472 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3476 test_snow3g_hash_verify_test_case_4(void)
3478 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3482 test_snow3g_hash_verify_test_case_5(void)
3484 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3488 test_snow3g_hash_verify_test_case_6(void)
3490 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3494 test_kasumi_hash_generate_test_case_1(void)
3496 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3500 test_kasumi_hash_generate_test_case_2(void)
3502 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3506 test_kasumi_hash_generate_test_case_3(void)
3508 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3512 test_kasumi_hash_generate_test_case_4(void)
3514 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3518 test_kasumi_hash_generate_test_case_5(void)
3520 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3524 test_kasumi_hash_generate_test_case_6(void)
3526 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3530 test_kasumi_hash_verify_test_case_1(void)
3532 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3536 test_kasumi_hash_verify_test_case_2(void)
3538 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3542 test_kasumi_hash_verify_test_case_3(void)
3544 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3548 test_kasumi_hash_verify_test_case_4(void)
3550 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3554 test_kasumi_hash_verify_test_case_5(void)
3556 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3560 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3562 struct crypto_testsuite_params *ts_params = &testsuite_params;
3563 struct crypto_unittest_params *ut_params = &unittest_params;
3566 uint8_t *plaintext, *ciphertext;
3567 unsigned plaintext_pad_len;
3568 unsigned plaintext_len;
3569 struct rte_cryptodev_info dev_info;
3571 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3572 uint64_t feat_flags = dev_info.feature_flags;
3574 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3575 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3576 printf("Device doesn't support RAW data-path APIs.\n");
3577 return TEST_SKIPPED;
3580 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3581 return TEST_SKIPPED;
3583 /* Verify the capabilities */
3584 struct rte_cryptodev_sym_capability_idx cap_idx;
3585 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3586 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3587 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3589 return TEST_SKIPPED;
3591 /* Create KASUMI session */
3592 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3593 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3594 RTE_CRYPTO_CIPHER_KASUMI_F8,
3595 tdata->key.data, tdata->key.len,
3596 tdata->cipher_iv.len);
3600 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3602 /* Clear mbuf payload */
3603 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3604 rte_pktmbuf_tailroom(ut_params->ibuf));
3606 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3607 /* Append data which is padded to a multiple */
3608 /* of the algorithms block size */
3609 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3610 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3612 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3614 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3616 /* Create KASUMI operation */
3617 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3618 tdata->cipher_iv.len,
3619 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3620 tdata->validCipherOffsetInBits.len);
3624 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3625 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3626 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3628 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3630 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3632 ut_params->obuf = ut_params->op->sym->m_dst;
3633 if (ut_params->obuf)
3634 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3636 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3638 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3640 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3641 (tdata->validCipherOffsetInBits.len >> 3);
3643 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3645 reference_ciphertext,
3646 tdata->validCipherLenInBits.len,
3647 "KASUMI Ciphertext data not as expected");
3652 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3654 struct crypto_testsuite_params *ts_params = &testsuite_params;
3655 struct crypto_unittest_params *ut_params = &unittest_params;
3659 unsigned int plaintext_pad_len;
3660 unsigned int plaintext_len;
3662 uint8_t buffer[10000];
3663 const uint8_t *ciphertext;
3665 struct rte_cryptodev_info dev_info;
3667 /* Verify the capabilities */
3668 struct rte_cryptodev_sym_capability_idx cap_idx;
3669 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3670 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3671 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3673 return TEST_SKIPPED;
3675 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3677 uint64_t feat_flags = dev_info.feature_flags;
3679 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3680 printf("Device doesn't support in-place scatter-gather. "
3682 return TEST_SKIPPED;
3685 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3686 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3687 printf("Device doesn't support RAW data-path APIs.\n");
3688 return TEST_SKIPPED;
3691 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3692 return TEST_SKIPPED;
3694 /* Create KASUMI session */
3695 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3696 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3697 RTE_CRYPTO_CIPHER_KASUMI_F8,
3698 tdata->key.data, tdata->key.len,
3699 tdata->cipher_iv.len);
3703 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3706 /* Append data which is padded to a multiple */
3707 /* of the algorithms block size */
3708 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3710 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3711 plaintext_pad_len, 10, 0);
3713 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3715 /* Create KASUMI operation */
3716 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3717 tdata->cipher_iv.len,
3718 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3719 tdata->validCipherOffsetInBits.len);
3723 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3724 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3725 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3727 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3729 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3731 ut_params->obuf = ut_params->op->sym->m_dst;
3733 if (ut_params->obuf)
3734 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3735 plaintext_len, buffer);
3737 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3738 tdata->validCipherOffsetInBits.len >> 3,
3739 plaintext_len, buffer);
3742 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3744 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3745 (tdata->validCipherOffsetInBits.len >> 3);
3747 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3749 reference_ciphertext,
3750 tdata->validCipherLenInBits.len,
3751 "KASUMI Ciphertext data not as expected");
3756 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3758 struct crypto_testsuite_params *ts_params = &testsuite_params;
3759 struct crypto_unittest_params *ut_params = &unittest_params;
3762 uint8_t *plaintext, *ciphertext;
3763 unsigned plaintext_pad_len;
3764 unsigned plaintext_len;
3766 /* Verify the capabilities */
3767 struct rte_cryptodev_sym_capability_idx cap_idx;
3768 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3769 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3770 /* Data-path service does not support OOP */
3771 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3773 return TEST_SKIPPED;
3775 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3776 return TEST_SKIPPED;
3778 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3779 return TEST_SKIPPED;
3781 /* Create KASUMI session */
3782 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3783 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3784 RTE_CRYPTO_CIPHER_KASUMI_F8,
3785 tdata->key.data, tdata->key.len,
3786 tdata->cipher_iv.len);
3790 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3791 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3793 /* Clear mbuf payload */
3794 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3795 rte_pktmbuf_tailroom(ut_params->ibuf));
3797 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3798 /* Append data which is padded to a multiple */
3799 /* of the algorithms block size */
3800 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3801 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3803 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3804 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3806 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3808 /* Create KASUMI operation */
3809 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3810 tdata->cipher_iv.len,
3811 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3812 tdata->validCipherOffsetInBits.len);
3816 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3818 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3820 ut_params->obuf = ut_params->op->sym->m_dst;
3821 if (ut_params->obuf)
3822 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3824 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3826 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3828 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3829 (tdata->validCipherOffsetInBits.len >> 3);
3831 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3833 reference_ciphertext,
3834 tdata->validCipherLenInBits.len,
3835 "KASUMI Ciphertext data not as expected");
3840 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3842 struct crypto_testsuite_params *ts_params = &testsuite_params;
3843 struct crypto_unittest_params *ut_params = &unittest_params;
3846 unsigned int plaintext_pad_len;
3847 unsigned int plaintext_len;
3849 const uint8_t *ciphertext;
3850 uint8_t buffer[2048];
3852 struct rte_cryptodev_info dev_info;
3854 /* Verify the capabilities */
3855 struct rte_cryptodev_sym_capability_idx cap_idx;
3856 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3857 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3858 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3860 return TEST_SKIPPED;
3862 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3863 return TEST_SKIPPED;
3865 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3866 return TEST_SKIPPED;
3868 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3870 uint64_t feat_flags = dev_info.feature_flags;
3871 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3872 printf("Device doesn't support out-of-place scatter-gather "
3873 "in both input and output mbufs. "
3875 return TEST_SKIPPED;
3878 /* Create KASUMI session */
3879 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3880 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3881 RTE_CRYPTO_CIPHER_KASUMI_F8,
3882 tdata->key.data, tdata->key.len,
3883 tdata->cipher_iv.len);
3887 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3888 /* Append data which is padded to a multiple */
3889 /* of the algorithms block size */
3890 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3892 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3893 plaintext_pad_len, 10, 0);
3894 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3895 plaintext_pad_len, 3, 0);
3897 /* Append data which is padded to a multiple */
3898 /* of the algorithms block size */
3899 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3901 /* Create KASUMI operation */
3902 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3903 tdata->cipher_iv.len,
3904 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3905 tdata->validCipherOffsetInBits.len);
3909 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3911 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3913 ut_params->obuf = ut_params->op->sym->m_dst;
3914 if (ut_params->obuf)
3915 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3916 plaintext_pad_len, buffer);
3918 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3919 tdata->validCipherOffsetInBits.len >> 3,
3920 plaintext_pad_len, buffer);
3922 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3923 (tdata->validCipherOffsetInBits.len >> 3);
3925 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3927 reference_ciphertext,
3928 tdata->validCipherLenInBits.len,
3929 "KASUMI Ciphertext data not as expected");
3935 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3937 struct crypto_testsuite_params *ts_params = &testsuite_params;
3938 struct crypto_unittest_params *ut_params = &unittest_params;
3941 uint8_t *ciphertext, *plaintext;
3942 unsigned ciphertext_pad_len;
3943 unsigned ciphertext_len;
3945 /* Verify the capabilities */
3946 struct rte_cryptodev_sym_capability_idx cap_idx;
3947 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3948 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3949 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3951 return TEST_SKIPPED;
3953 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3954 return TEST_SKIPPED;
3956 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3957 return TEST_SKIPPED;
3959 /* Create KASUMI session */
3960 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3961 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3962 RTE_CRYPTO_CIPHER_KASUMI_F8,
3963 tdata->key.data, tdata->key.len,
3964 tdata->cipher_iv.len);
3968 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3969 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3971 /* Clear mbuf payload */
3972 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3973 rte_pktmbuf_tailroom(ut_params->ibuf));
3975 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3976 /* Append data which is padded to a multiple */
3977 /* of the algorithms block size */
3978 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3979 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3980 ciphertext_pad_len);
3981 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3982 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3984 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3986 /* Create KASUMI operation */
3987 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3988 tdata->cipher_iv.len,
3989 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3990 tdata->validCipherOffsetInBits.len);
3994 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3996 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3998 ut_params->obuf = ut_params->op->sym->m_dst;
3999 if (ut_params->obuf)
4000 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4002 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4004 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4006 const uint8_t *reference_plaintext = tdata->plaintext.data +
4007 (tdata->validCipherOffsetInBits.len >> 3);
4009 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4011 reference_plaintext,
4012 tdata->validCipherLenInBits.len,
4013 "KASUMI Plaintext data not as expected");
4018 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4020 struct crypto_testsuite_params *ts_params = &testsuite_params;
4021 struct crypto_unittest_params *ut_params = &unittest_params;
4024 uint8_t *ciphertext, *plaintext;
4025 unsigned ciphertext_pad_len;
4026 unsigned ciphertext_len;
4027 struct rte_cryptodev_info dev_info;
4029 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4030 uint64_t feat_flags = dev_info.feature_flags;
4032 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4033 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4034 printf("Device doesn't support RAW data-path APIs.\n");
4035 return TEST_SKIPPED;
4038 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4039 return TEST_SKIPPED;
4041 /* Verify the capabilities */
4042 struct rte_cryptodev_sym_capability_idx cap_idx;
4043 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4044 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4045 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4047 return TEST_SKIPPED;
4049 /* Create KASUMI session */
4050 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4051 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4052 RTE_CRYPTO_CIPHER_KASUMI_F8,
4053 tdata->key.data, tdata->key.len,
4054 tdata->cipher_iv.len);
4058 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4060 /* Clear mbuf payload */
4061 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4062 rte_pktmbuf_tailroom(ut_params->ibuf));
4064 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4065 /* Append data which is padded to a multiple */
4066 /* of the algorithms block size */
4067 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4068 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4069 ciphertext_pad_len);
4070 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4072 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4074 /* Create KASUMI operation */
4075 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4076 tdata->cipher_iv.len,
4077 tdata->ciphertext.len,
4078 tdata->validCipherOffsetInBits.len);
4082 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4083 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4084 ut_params->op, 1, 0, 1, 0);
4086 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4088 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4090 ut_params->obuf = ut_params->op->sym->m_dst;
4091 if (ut_params->obuf)
4092 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4094 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4096 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4098 const uint8_t *reference_plaintext = tdata->plaintext.data +
4099 (tdata->validCipherOffsetInBits.len >> 3);
4101 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4103 reference_plaintext,
4104 tdata->validCipherLenInBits.len,
4105 "KASUMI Plaintext data not as expected");
4110 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4112 struct crypto_testsuite_params *ts_params = &testsuite_params;
4113 struct crypto_unittest_params *ut_params = &unittest_params;
4116 uint8_t *plaintext, *ciphertext;
4117 unsigned plaintext_pad_len;
4118 unsigned plaintext_len;
4119 struct rte_cryptodev_info dev_info;
4121 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4122 uint64_t feat_flags = dev_info.feature_flags;
4124 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4125 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4126 printf("Device doesn't support RAW data-path APIs.\n");
4127 return TEST_SKIPPED;
4130 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4131 return TEST_SKIPPED;
4133 /* Verify the capabilities */
4134 struct rte_cryptodev_sym_capability_idx cap_idx;
4135 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4136 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4137 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4139 return TEST_SKIPPED;
4141 /* Create SNOW 3G session */
4142 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4143 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4144 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4145 tdata->key.data, tdata->key.len,
4146 tdata->cipher_iv.len);
4150 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4152 /* Clear mbuf payload */
4153 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4154 rte_pktmbuf_tailroom(ut_params->ibuf));
4156 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4157 /* Append data which is padded to a multiple of */
4158 /* the algorithms block size */
4159 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4160 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4162 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4164 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4166 /* Create SNOW 3G operation */
4167 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4168 tdata->cipher_iv.len,
4169 tdata->validCipherLenInBits.len,
4174 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4175 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4176 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4178 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4180 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4182 ut_params->obuf = ut_params->op->sym->m_dst;
4183 if (ut_params->obuf)
4184 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4186 ciphertext = plaintext;
4188 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4191 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4193 tdata->ciphertext.data,
4194 tdata->validDataLenInBits.len,
4195 "SNOW 3G Ciphertext data not as expected");
4201 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4203 struct crypto_testsuite_params *ts_params = &testsuite_params;
4204 struct crypto_unittest_params *ut_params = &unittest_params;
4205 uint8_t *plaintext, *ciphertext;
4208 unsigned plaintext_pad_len;
4209 unsigned plaintext_len;
4211 /* Verify the capabilities */
4212 struct rte_cryptodev_sym_capability_idx cap_idx;
4213 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4214 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4215 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4217 return TEST_SKIPPED;
4219 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4220 return TEST_SKIPPED;
4222 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4223 return TEST_SKIPPED;
4225 /* Create SNOW 3G session */
4226 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4227 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4228 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4229 tdata->key.data, tdata->key.len,
4230 tdata->cipher_iv.len);
4234 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4235 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4237 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4238 "Failed to allocate input buffer in mempool");
4239 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4240 "Failed to allocate output buffer in mempool");
4242 /* Clear mbuf payload */
4243 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4244 rte_pktmbuf_tailroom(ut_params->ibuf));
4246 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4247 /* Append data which is padded to a multiple of */
4248 /* the algorithms block size */
4249 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4250 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4252 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4253 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4255 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4257 /* Create SNOW 3G operation */
4258 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4259 tdata->cipher_iv.len,
4260 tdata->validCipherLenInBits.len,
4265 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4267 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4269 ut_params->obuf = ut_params->op->sym->m_dst;
4270 if (ut_params->obuf)
4271 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4273 ciphertext = plaintext;
4275 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4278 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4280 tdata->ciphertext.data,
4281 tdata->validDataLenInBits.len,
4282 "SNOW 3G Ciphertext data not as expected");
4287 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4289 struct crypto_testsuite_params *ts_params = &testsuite_params;
4290 struct crypto_unittest_params *ut_params = &unittest_params;
4293 unsigned int plaintext_pad_len;
4294 unsigned int plaintext_len;
4295 uint8_t buffer[10000];
4296 const uint8_t *ciphertext;
4298 struct rte_cryptodev_info dev_info;
4300 /* Verify the capabilities */
4301 struct rte_cryptodev_sym_capability_idx cap_idx;
4302 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4303 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4304 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4306 return TEST_SKIPPED;
4308 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4309 return TEST_SKIPPED;
4311 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4312 return TEST_SKIPPED;
4314 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4316 uint64_t feat_flags = dev_info.feature_flags;
4318 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4319 printf("Device doesn't support out-of-place scatter-gather "
4320 "in both input and output mbufs. "
4322 return TEST_SKIPPED;
4325 /* Create SNOW 3G session */
4326 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4327 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4328 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4329 tdata->key.data, tdata->key.len,
4330 tdata->cipher_iv.len);
4334 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4335 /* Append data which is padded to a multiple of */
4336 /* the algorithms block size */
4337 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4339 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4340 plaintext_pad_len, 10, 0);
4341 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4342 plaintext_pad_len, 3, 0);
4344 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4345 "Failed to allocate input buffer in mempool");
4346 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4347 "Failed to allocate output buffer in mempool");
4349 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4351 /* Create SNOW 3G operation */
4352 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4353 tdata->cipher_iv.len,
4354 tdata->validCipherLenInBits.len,
4359 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4361 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4363 ut_params->obuf = ut_params->op->sym->m_dst;
4364 if (ut_params->obuf)
4365 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4366 plaintext_len, buffer);
4368 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4369 plaintext_len, buffer);
4371 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4374 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4376 tdata->ciphertext.data,
4377 tdata->validDataLenInBits.len,
4378 "SNOW 3G Ciphertext data not as expected");
4383 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4385 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4387 uint8_t curr_byte, prev_byte;
4388 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4389 uint8_t lower_byte_mask = (1 << offset) - 1;
4392 prev_byte = buffer[0];
4393 buffer[0] >>= offset;
4395 for (i = 1; i < length_in_bytes; i++) {
4396 curr_byte = buffer[i];
4397 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4398 (curr_byte >> offset);
4399 prev_byte = curr_byte;
4404 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4406 struct crypto_testsuite_params *ts_params = &testsuite_params;
4407 struct crypto_unittest_params *ut_params = &unittest_params;
4408 uint8_t *plaintext, *ciphertext;
4410 uint32_t plaintext_len;
4411 uint32_t plaintext_pad_len;
4412 uint8_t extra_offset = 4;
4413 uint8_t *expected_ciphertext_shifted;
4414 struct rte_cryptodev_info dev_info;
4416 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4417 uint64_t feat_flags = dev_info.feature_flags;
4419 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4420 ((tdata->validDataLenInBits.len % 8) != 0)) {
4421 printf("Device doesn't support NON-Byte Aligned Data.\n");
4422 return TEST_SKIPPED;
4425 /* Verify the capabilities */
4426 struct rte_cryptodev_sym_capability_idx cap_idx;
4427 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4428 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4429 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4431 return TEST_SKIPPED;
4433 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4434 return TEST_SKIPPED;
4436 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4437 return TEST_SKIPPED;
4439 /* Create SNOW 3G session */
4440 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4441 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4442 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4443 tdata->key.data, tdata->key.len,
4444 tdata->cipher_iv.len);
4448 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4449 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4451 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4452 "Failed to allocate input buffer in mempool");
4453 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4454 "Failed to allocate output buffer in mempool");
4456 /* Clear mbuf payload */
4457 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4458 rte_pktmbuf_tailroom(ut_params->ibuf));
4460 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4462 * Append data which is padded to a
4463 * multiple of the algorithms block size
4465 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4467 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4470 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4472 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4473 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4475 #ifdef RTE_APP_TEST_DEBUG
4476 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4478 /* Create SNOW 3G operation */
4479 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4480 tdata->cipher_iv.len,
4481 tdata->validCipherLenInBits.len,
4486 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4488 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4490 ut_params->obuf = ut_params->op->sym->m_dst;
4491 if (ut_params->obuf)
4492 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4494 ciphertext = plaintext;
4496 #ifdef RTE_APP_TEST_DEBUG
4497 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4500 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4502 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4503 "failed to reserve memory for ciphertext shifted\n");
4505 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4506 ceil_byte_length(tdata->ciphertext.len));
4507 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4510 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4512 expected_ciphertext_shifted,
4513 tdata->validDataLenInBits.len,
4515 "SNOW 3G Ciphertext data not as expected");
4519 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4521 struct crypto_testsuite_params *ts_params = &testsuite_params;
4522 struct crypto_unittest_params *ut_params = &unittest_params;
4526 uint8_t *plaintext, *ciphertext;
4527 unsigned ciphertext_pad_len;
4528 unsigned ciphertext_len;
4529 struct rte_cryptodev_info dev_info;
4531 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4532 uint64_t feat_flags = dev_info.feature_flags;
4534 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4535 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4536 printf("Device doesn't support RAW data-path APIs.\n");
4537 return TEST_SKIPPED;
4540 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4541 return TEST_SKIPPED;
4543 /* Verify the capabilities */
4544 struct rte_cryptodev_sym_capability_idx cap_idx;
4545 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4546 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4547 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4549 return TEST_SKIPPED;
4551 /* Create SNOW 3G session */
4552 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4553 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4554 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4555 tdata->key.data, tdata->key.len,
4556 tdata->cipher_iv.len);
4560 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4562 /* Clear mbuf payload */
4563 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4564 rte_pktmbuf_tailroom(ut_params->ibuf));
4566 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4567 /* Append data which is padded to a multiple of */
4568 /* the algorithms block size */
4569 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4570 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4571 ciphertext_pad_len);
4572 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4574 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4576 /* Create SNOW 3G operation */
4577 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4578 tdata->cipher_iv.len,
4579 tdata->validCipherLenInBits.len,
4580 tdata->cipher.offset_bits);
4584 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4585 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4586 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4588 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4590 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4591 ut_params->obuf = ut_params->op->sym->m_dst;
4592 if (ut_params->obuf)
4593 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4595 plaintext = ciphertext;
4597 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4600 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4601 tdata->plaintext.data,
4602 tdata->validDataLenInBits.len,
4603 "SNOW 3G Plaintext data not as expected");
4607 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4609 struct crypto_testsuite_params *ts_params = &testsuite_params;
4610 struct crypto_unittest_params *ut_params = &unittest_params;
4614 uint8_t *plaintext, *ciphertext;
4615 unsigned ciphertext_pad_len;
4616 unsigned ciphertext_len;
4618 /* Verify the capabilities */
4619 struct rte_cryptodev_sym_capability_idx cap_idx;
4620 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4621 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4622 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4624 return TEST_SKIPPED;
4626 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4627 return TEST_SKIPPED;
4629 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4630 return TEST_SKIPPED;
4632 /* Create SNOW 3G session */
4633 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4634 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4635 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4636 tdata->key.data, tdata->key.len,
4637 tdata->cipher_iv.len);
4641 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4642 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4644 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4645 "Failed to allocate input buffer");
4646 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4647 "Failed to allocate output buffer");
4649 /* Clear mbuf payload */
4650 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4651 rte_pktmbuf_tailroom(ut_params->ibuf));
4653 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4654 rte_pktmbuf_tailroom(ut_params->obuf));
4656 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4657 /* Append data which is padded to a multiple of */
4658 /* the algorithms block size */
4659 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4660 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4661 ciphertext_pad_len);
4662 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4663 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4665 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4667 /* Create SNOW 3G operation */
4668 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4669 tdata->cipher_iv.len,
4670 tdata->validCipherLenInBits.len,
4675 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4677 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4678 ut_params->obuf = ut_params->op->sym->m_dst;
4679 if (ut_params->obuf)
4680 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4682 plaintext = ciphertext;
4684 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4687 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4688 tdata->plaintext.data,
4689 tdata->validDataLenInBits.len,
4690 "SNOW 3G Plaintext data not as expected");
4695 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4697 struct crypto_testsuite_params *ts_params = &testsuite_params;
4698 struct crypto_unittest_params *ut_params = &unittest_params;
4702 uint8_t *plaintext, *ciphertext;
4703 unsigned int plaintext_pad_len;
4704 unsigned int plaintext_len;
4706 struct rte_cryptodev_info dev_info;
4707 struct rte_cryptodev_sym_capability_idx cap_idx;
4709 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4710 uint64_t feat_flags = dev_info.feature_flags;
4712 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4713 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4714 (tdata->validDataLenInBits.len % 8 != 0))) {
4715 printf("Device doesn't support NON-Byte Aligned Data.\n");
4716 return TEST_SKIPPED;
4719 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4720 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4721 printf("Device doesn't support RAW data-path APIs.\n");
4722 return TEST_SKIPPED;
4725 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4726 return TEST_SKIPPED;
4728 /* Check if device supports ZUC EEA3 */
4729 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4730 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4732 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4734 return TEST_SKIPPED;
4736 /* Check if device supports ZUC EIA3 */
4737 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4738 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4740 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4742 return TEST_SKIPPED;
4744 /* Create ZUC session */
4745 retval = create_zuc_cipher_auth_encrypt_generate_session(
4746 ts_params->valid_devs[0],
4750 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4752 /* clear mbuf payload */
4753 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4754 rte_pktmbuf_tailroom(ut_params->ibuf));
4756 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4757 /* Append data which is padded to a multiple of */
4758 /* the algorithms block size */
4759 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4760 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4762 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4764 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4766 /* Create ZUC operation */
4767 retval = create_zuc_cipher_hash_generate_operation(tdata);
4771 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4772 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4773 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4775 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4777 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4778 ut_params->obuf = ut_params->op->sym->m_src;
4779 if (ut_params->obuf)
4780 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4782 ciphertext = plaintext;
4784 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4786 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4788 tdata->ciphertext.data,
4789 tdata->validDataLenInBits.len,
4790 "ZUC Ciphertext data not as expected");
4792 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4793 + plaintext_pad_len;
4796 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4800 "ZUC Generated auth tag not as expected");
4805 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4807 struct crypto_testsuite_params *ts_params = &testsuite_params;
4808 struct crypto_unittest_params *ut_params = &unittest_params;
4812 uint8_t *plaintext, *ciphertext;
4813 unsigned plaintext_pad_len;
4814 unsigned plaintext_len;
4815 struct rte_cryptodev_info dev_info;
4817 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4818 uint64_t feat_flags = dev_info.feature_flags;
4820 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4821 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4822 printf("Device doesn't support RAW data-path APIs.\n");
4823 return TEST_SKIPPED;
4826 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4827 return TEST_SKIPPED;
4829 /* Verify the capabilities */
4830 struct rte_cryptodev_sym_capability_idx cap_idx;
4831 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4832 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4833 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4835 return TEST_SKIPPED;
4836 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4837 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4838 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4840 return TEST_SKIPPED;
4842 /* Create SNOW 3G session */
4843 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4844 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4845 RTE_CRYPTO_AUTH_OP_GENERATE,
4846 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4847 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4848 tdata->key.data, tdata->key.len,
4849 tdata->auth_iv.len, tdata->digest.len,
4850 tdata->cipher_iv.len);
4853 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4855 /* clear mbuf payload */
4856 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4857 rte_pktmbuf_tailroom(ut_params->ibuf));
4859 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4860 /* Append data which is padded to a multiple of */
4861 /* the algorithms block size */
4862 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4863 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4865 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4867 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4869 /* Create SNOW 3G operation */
4870 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4871 tdata->digest.len, tdata->auth_iv.data,
4873 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4874 tdata->cipher_iv.data, tdata->cipher_iv.len,
4875 tdata->validCipherLenInBits.len,
4877 tdata->validAuthLenInBits.len,
4883 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4884 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4885 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4887 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4889 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4890 ut_params->obuf = ut_params->op->sym->m_src;
4891 if (ut_params->obuf)
4892 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4894 ciphertext = plaintext;
4896 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4898 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4900 tdata->ciphertext.data,
4901 tdata->validDataLenInBits.len,
4902 "SNOW 3G Ciphertext data not as expected");
4904 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4905 + plaintext_pad_len;
4908 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4911 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4912 "SNOW 3G Generated auth tag not as expected");
4917 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4918 uint8_t op_mode, uint8_t verify)
4920 struct crypto_testsuite_params *ts_params = &testsuite_params;
4921 struct crypto_unittest_params *ut_params = &unittest_params;
4925 uint8_t *plaintext = NULL, *ciphertext = NULL;
4926 unsigned int plaintext_pad_len;
4927 unsigned int plaintext_len;
4928 unsigned int ciphertext_pad_len;
4929 unsigned int ciphertext_len;
4931 struct rte_cryptodev_info dev_info;
4933 /* Verify the capabilities */
4934 struct rte_cryptodev_sym_capability_idx cap_idx;
4935 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4936 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4937 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4939 return TEST_SKIPPED;
4940 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4941 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4942 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4944 return TEST_SKIPPED;
4946 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4947 return TEST_SKIPPED;
4949 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4951 uint64_t feat_flags = dev_info.feature_flags;
4953 if (op_mode == OUT_OF_PLACE) {
4954 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4955 printf("Device doesn't support digest encrypted.\n");
4956 return TEST_SKIPPED;
4958 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4959 return TEST_SKIPPED;
4962 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4963 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4964 printf("Device doesn't support RAW data-path APIs.\n");
4965 return TEST_SKIPPED;
4968 /* Create SNOW 3G session */
4969 retval = create_wireless_algo_auth_cipher_session(
4970 ts_params->valid_devs[0],
4971 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4972 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4973 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4974 : RTE_CRYPTO_AUTH_OP_GENERATE),
4975 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4976 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4977 tdata->key.data, tdata->key.len,
4978 tdata->auth_iv.len, tdata->digest.len,
4979 tdata->cipher_iv.len);
4983 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4984 if (op_mode == OUT_OF_PLACE)
4985 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4987 /* clear mbuf payload */
4988 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4989 rte_pktmbuf_tailroom(ut_params->ibuf));
4990 if (op_mode == OUT_OF_PLACE)
4991 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4992 rte_pktmbuf_tailroom(ut_params->obuf));
4994 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4995 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4996 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4997 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5000 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5001 ciphertext_pad_len);
5002 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5003 if (op_mode == OUT_OF_PLACE)
5004 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5005 debug_hexdump(stdout, "ciphertext:", ciphertext,
5008 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5010 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5011 if (op_mode == OUT_OF_PLACE)
5012 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5013 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5016 /* Create SNOW 3G operation */
5017 retval = create_wireless_algo_auth_cipher_operation(
5018 tdata->digest.data, tdata->digest.len,
5019 tdata->cipher_iv.data, tdata->cipher_iv.len,
5020 tdata->auth_iv.data, tdata->auth_iv.len,
5021 (tdata->digest.offset_bytes == 0 ?
5022 (verify ? ciphertext_pad_len : plaintext_pad_len)
5023 : tdata->digest.offset_bytes),
5024 tdata->validCipherLenInBits.len,
5025 tdata->cipher.offset_bits,
5026 tdata->validAuthLenInBits.len,
5027 tdata->auth.offset_bits,
5028 op_mode, 0, verify);
5033 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5034 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5035 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5037 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5040 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5042 ut_params->obuf = (op_mode == IN_PLACE ?
5043 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5046 if (ut_params->obuf)
5047 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5050 plaintext = ciphertext +
5051 (tdata->cipher.offset_bits >> 3);
5053 debug_hexdump(stdout, "plaintext:", plaintext,
5054 (tdata->plaintext.len >> 3) - tdata->digest.len);
5055 debug_hexdump(stdout, "plaintext expected:",
5056 tdata->plaintext.data,
5057 (tdata->plaintext.len >> 3) - tdata->digest.len);
5059 if (ut_params->obuf)
5060 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5063 ciphertext = plaintext;
5065 debug_hexdump(stdout, "ciphertext:", ciphertext,
5067 debug_hexdump(stdout, "ciphertext expected:",
5068 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5070 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5071 + (tdata->digest.offset_bytes == 0 ?
5072 plaintext_pad_len : tdata->digest.offset_bytes);
5074 debug_hexdump(stdout, "digest:", ut_params->digest,
5076 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5082 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5084 tdata->plaintext.data,
5085 (tdata->plaintext.len - tdata->cipher.offset_bits -
5086 (tdata->digest.len << 3)),
5087 tdata->cipher.offset_bits,
5088 "SNOW 3G Plaintext data not as expected");
5090 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5092 tdata->ciphertext.data,
5093 (tdata->validDataLenInBits.len -
5094 tdata->cipher.offset_bits),
5095 tdata->cipher.offset_bits,
5096 "SNOW 3G Ciphertext data not as expected");
5098 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5101 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5102 "SNOW 3G Generated auth tag not as expected");
5108 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5109 uint8_t op_mode, uint8_t verify)
5111 struct crypto_testsuite_params *ts_params = &testsuite_params;
5112 struct crypto_unittest_params *ut_params = &unittest_params;
5116 const uint8_t *plaintext = NULL;
5117 const uint8_t *ciphertext = NULL;
5118 const uint8_t *digest = NULL;
5119 unsigned int plaintext_pad_len;
5120 unsigned int plaintext_len;
5121 unsigned int ciphertext_pad_len;
5122 unsigned int ciphertext_len;
5123 uint8_t buffer[10000];
5124 uint8_t digest_buffer[10000];
5126 struct rte_cryptodev_info dev_info;
5128 /* Verify the capabilities */
5129 struct rte_cryptodev_sym_capability_idx cap_idx;
5130 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5131 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5132 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5134 return TEST_SKIPPED;
5135 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5136 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5137 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5139 return TEST_SKIPPED;
5141 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5142 return TEST_SKIPPED;
5144 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5146 uint64_t feat_flags = dev_info.feature_flags;
5148 if (op_mode == IN_PLACE) {
5149 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5150 printf("Device doesn't support in-place scatter-gather "
5151 "in both input and output mbufs.\n");
5152 return TEST_SKIPPED;
5154 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5155 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5156 printf("Device doesn't support RAW data-path APIs.\n");
5157 return TEST_SKIPPED;
5160 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5161 return TEST_SKIPPED;
5162 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5163 printf("Device doesn't support out-of-place scatter-gather "
5164 "in both input and output mbufs.\n");
5165 return TEST_SKIPPED;
5167 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5168 printf("Device doesn't support digest encrypted.\n");
5169 return TEST_SKIPPED;
5173 /* Create SNOW 3G session */
5174 retval = create_wireless_algo_auth_cipher_session(
5175 ts_params->valid_devs[0],
5176 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5177 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5178 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5179 : RTE_CRYPTO_AUTH_OP_GENERATE),
5180 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5181 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5182 tdata->key.data, tdata->key.len,
5183 tdata->auth_iv.len, tdata->digest.len,
5184 tdata->cipher_iv.len);
5189 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5190 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5191 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5192 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5194 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5195 plaintext_pad_len, 15, 0);
5196 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5197 "Failed to allocate input buffer in mempool");
5199 if (op_mode == OUT_OF_PLACE) {
5200 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5201 plaintext_pad_len, 15, 0);
5202 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5203 "Failed to allocate output buffer in mempool");
5207 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5208 tdata->ciphertext.data);
5209 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5210 ciphertext_len, buffer);
5211 debug_hexdump(stdout, "ciphertext:", ciphertext,
5214 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5215 tdata->plaintext.data);
5216 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5217 plaintext_len, buffer);
5218 debug_hexdump(stdout, "plaintext:", plaintext,
5221 memset(buffer, 0, sizeof(buffer));
5223 /* Create SNOW 3G operation */
5224 retval = create_wireless_algo_auth_cipher_operation(
5225 tdata->digest.data, tdata->digest.len,
5226 tdata->cipher_iv.data, tdata->cipher_iv.len,
5227 tdata->auth_iv.data, tdata->auth_iv.len,
5228 (tdata->digest.offset_bytes == 0 ?
5229 (verify ? ciphertext_pad_len : plaintext_pad_len)
5230 : tdata->digest.offset_bytes),
5231 tdata->validCipherLenInBits.len,
5232 tdata->cipher.offset_bits,
5233 tdata->validAuthLenInBits.len,
5234 tdata->auth.offset_bits,
5235 op_mode, 1, verify);
5240 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5241 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5242 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5244 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5247 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5249 ut_params->obuf = (op_mode == IN_PLACE ?
5250 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5253 if (ut_params->obuf)
5254 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5255 plaintext_len, buffer);
5257 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5258 plaintext_len, buffer);
5260 debug_hexdump(stdout, "plaintext:", plaintext,
5261 (tdata->plaintext.len >> 3) - tdata->digest.len);
5262 debug_hexdump(stdout, "plaintext expected:",
5263 tdata->plaintext.data,
5264 (tdata->plaintext.len >> 3) - tdata->digest.len);
5266 if (ut_params->obuf)
5267 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5268 ciphertext_len, buffer);
5270 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5271 ciphertext_len, buffer);
5273 debug_hexdump(stdout, "ciphertext:", ciphertext,
5275 debug_hexdump(stdout, "ciphertext expected:",
5276 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5278 if (ut_params->obuf)
5279 digest = rte_pktmbuf_read(ut_params->obuf,
5280 (tdata->digest.offset_bytes == 0 ?
5281 plaintext_pad_len : tdata->digest.offset_bytes),
5282 tdata->digest.len, digest_buffer);
5284 digest = rte_pktmbuf_read(ut_params->ibuf,
5285 (tdata->digest.offset_bytes == 0 ?
5286 plaintext_pad_len : tdata->digest.offset_bytes),
5287 tdata->digest.len, digest_buffer);
5289 debug_hexdump(stdout, "digest:", digest,
5291 debug_hexdump(stdout, "digest expected:",
5292 tdata->digest.data, tdata->digest.len);
5297 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5299 tdata->plaintext.data,
5300 (tdata->plaintext.len - tdata->cipher.offset_bits -
5301 (tdata->digest.len << 3)),
5302 tdata->cipher.offset_bits,
5303 "SNOW 3G Plaintext data not as expected");
5305 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5307 tdata->ciphertext.data,
5308 (tdata->validDataLenInBits.len -
5309 tdata->cipher.offset_bits),
5310 tdata->cipher.offset_bits,
5311 "SNOW 3G Ciphertext data not as expected");
5313 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5316 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5317 "SNOW 3G Generated auth tag not as expected");
5323 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5324 uint8_t op_mode, uint8_t verify)
5326 struct crypto_testsuite_params *ts_params = &testsuite_params;
5327 struct crypto_unittest_params *ut_params = &unittest_params;
5331 uint8_t *plaintext = NULL, *ciphertext = NULL;
5332 unsigned int plaintext_pad_len;
5333 unsigned int plaintext_len;
5334 unsigned int ciphertext_pad_len;
5335 unsigned int ciphertext_len;
5337 struct rte_cryptodev_info dev_info;
5339 /* Verify the capabilities */
5340 struct rte_cryptodev_sym_capability_idx cap_idx;
5341 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5342 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5343 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5345 return TEST_SKIPPED;
5346 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5347 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5348 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5350 return TEST_SKIPPED;
5352 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5354 uint64_t feat_flags = dev_info.feature_flags;
5356 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5357 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5358 printf("Device doesn't support RAW data-path APIs.\n");
5359 return TEST_SKIPPED;
5362 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5363 return TEST_SKIPPED;
5365 if (op_mode == OUT_OF_PLACE) {
5366 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5367 return TEST_SKIPPED;
5368 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5369 printf("Device doesn't support digest encrypted.\n");
5370 return TEST_SKIPPED;
5374 /* Create KASUMI session */
5375 retval = create_wireless_algo_auth_cipher_session(
5376 ts_params->valid_devs[0],
5377 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5378 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5379 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5380 : RTE_CRYPTO_AUTH_OP_GENERATE),
5381 RTE_CRYPTO_AUTH_KASUMI_F9,
5382 RTE_CRYPTO_CIPHER_KASUMI_F8,
5383 tdata->key.data, tdata->key.len,
5384 0, tdata->digest.len,
5385 tdata->cipher_iv.len);
5390 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5391 if (op_mode == OUT_OF_PLACE)
5392 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5394 /* clear mbuf payload */
5395 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5396 rte_pktmbuf_tailroom(ut_params->ibuf));
5397 if (op_mode == OUT_OF_PLACE)
5398 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5399 rte_pktmbuf_tailroom(ut_params->obuf));
5401 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5402 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5403 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5404 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5407 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5408 ciphertext_pad_len);
5409 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5410 if (op_mode == OUT_OF_PLACE)
5411 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5412 debug_hexdump(stdout, "ciphertext:", ciphertext,
5415 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5417 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5418 if (op_mode == OUT_OF_PLACE)
5419 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5420 debug_hexdump(stdout, "plaintext:", plaintext,
5424 /* Create KASUMI operation */
5425 retval = create_wireless_algo_auth_cipher_operation(
5426 tdata->digest.data, tdata->digest.len,
5427 tdata->cipher_iv.data, tdata->cipher_iv.len,
5429 (tdata->digest.offset_bytes == 0 ?
5430 (verify ? ciphertext_pad_len : plaintext_pad_len)
5431 : tdata->digest.offset_bytes),
5432 tdata->validCipherLenInBits.len,
5433 tdata->validCipherOffsetInBits.len,
5434 tdata->validAuthLenInBits.len,
5436 op_mode, 0, verify);
5441 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5442 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5443 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5445 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5448 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5450 ut_params->obuf = (op_mode == IN_PLACE ?
5451 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5455 if (ut_params->obuf)
5456 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5459 plaintext = ciphertext;
5461 debug_hexdump(stdout, "plaintext:", plaintext,
5462 (tdata->plaintext.len >> 3) - tdata->digest.len);
5463 debug_hexdump(stdout, "plaintext expected:",
5464 tdata->plaintext.data,
5465 (tdata->plaintext.len >> 3) - tdata->digest.len);
5467 if (ut_params->obuf)
5468 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5471 ciphertext = plaintext;
5473 debug_hexdump(stdout, "ciphertext:", ciphertext,
5475 debug_hexdump(stdout, "ciphertext expected:",
5476 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5478 ut_params->digest = rte_pktmbuf_mtod(
5479 ut_params->obuf, uint8_t *) +
5480 (tdata->digest.offset_bytes == 0 ?
5481 plaintext_pad_len : tdata->digest.offset_bytes);
5483 debug_hexdump(stdout, "digest:", ut_params->digest,
5485 debug_hexdump(stdout, "digest expected:",
5486 tdata->digest.data, tdata->digest.len);
5491 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5493 tdata->plaintext.data,
5494 tdata->plaintext.len >> 3,
5495 "KASUMI Plaintext data not as expected");
5497 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5499 tdata->ciphertext.data,
5500 tdata->ciphertext.len >> 3,
5501 "KASUMI Ciphertext data not as expected");
5503 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5506 DIGEST_BYTE_LENGTH_KASUMI_F9,
5507 "KASUMI Generated auth tag not as expected");
5513 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5514 uint8_t op_mode, uint8_t verify)
5516 struct crypto_testsuite_params *ts_params = &testsuite_params;
5517 struct crypto_unittest_params *ut_params = &unittest_params;
5521 const uint8_t *plaintext = NULL;
5522 const uint8_t *ciphertext = NULL;
5523 const uint8_t *digest = NULL;
5524 unsigned int plaintext_pad_len;
5525 unsigned int plaintext_len;
5526 unsigned int ciphertext_pad_len;
5527 unsigned int ciphertext_len;
5528 uint8_t buffer[10000];
5529 uint8_t digest_buffer[10000];
5531 struct rte_cryptodev_info dev_info;
5533 /* Verify the capabilities */
5534 struct rte_cryptodev_sym_capability_idx cap_idx;
5535 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5536 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5537 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5539 return TEST_SKIPPED;
5540 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5541 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5542 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5544 return TEST_SKIPPED;
5546 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5547 return TEST_SKIPPED;
5549 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5551 uint64_t feat_flags = dev_info.feature_flags;
5553 if (op_mode == IN_PLACE) {
5554 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5555 printf("Device doesn't support in-place scatter-gather "
5556 "in both input and output mbufs.\n");
5557 return TEST_SKIPPED;
5559 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5560 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5561 printf("Device doesn't support RAW data-path APIs.\n");
5562 return TEST_SKIPPED;
5565 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5566 return TEST_SKIPPED;
5567 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5568 printf("Device doesn't support out-of-place scatter-gather "
5569 "in both input and output mbufs.\n");
5570 return TEST_SKIPPED;
5572 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5573 printf("Device doesn't support digest encrypted.\n");
5574 return TEST_SKIPPED;
5578 /* Create KASUMI session */
5579 retval = create_wireless_algo_auth_cipher_session(
5580 ts_params->valid_devs[0],
5581 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5582 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5583 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5584 : RTE_CRYPTO_AUTH_OP_GENERATE),
5585 RTE_CRYPTO_AUTH_KASUMI_F9,
5586 RTE_CRYPTO_CIPHER_KASUMI_F8,
5587 tdata->key.data, tdata->key.len,
5588 0, tdata->digest.len,
5589 tdata->cipher_iv.len);
5594 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5595 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5596 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5597 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5599 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5600 plaintext_pad_len, 15, 0);
5601 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5602 "Failed to allocate input buffer in mempool");
5604 if (op_mode == OUT_OF_PLACE) {
5605 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5606 plaintext_pad_len, 15, 0);
5607 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5608 "Failed to allocate output buffer in mempool");
5612 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5613 tdata->ciphertext.data);
5614 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5615 ciphertext_len, buffer);
5616 debug_hexdump(stdout, "ciphertext:", ciphertext,
5619 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5620 tdata->plaintext.data);
5621 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5622 plaintext_len, buffer);
5623 debug_hexdump(stdout, "plaintext:", plaintext,
5626 memset(buffer, 0, sizeof(buffer));
5628 /* Create KASUMI operation */
5629 retval = create_wireless_algo_auth_cipher_operation(
5630 tdata->digest.data, tdata->digest.len,
5631 tdata->cipher_iv.data, tdata->cipher_iv.len,
5633 (tdata->digest.offset_bytes == 0 ?
5634 (verify ? ciphertext_pad_len : plaintext_pad_len)
5635 : tdata->digest.offset_bytes),
5636 tdata->validCipherLenInBits.len,
5637 tdata->validCipherOffsetInBits.len,
5638 tdata->validAuthLenInBits.len,
5640 op_mode, 1, verify);
5645 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5646 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5647 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5649 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5652 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5654 ut_params->obuf = (op_mode == IN_PLACE ?
5655 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5658 if (ut_params->obuf)
5659 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5660 plaintext_len, buffer);
5662 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5663 plaintext_len, buffer);
5665 debug_hexdump(stdout, "plaintext:", plaintext,
5666 (tdata->plaintext.len >> 3) - tdata->digest.len);
5667 debug_hexdump(stdout, "plaintext expected:",
5668 tdata->plaintext.data,
5669 (tdata->plaintext.len >> 3) - tdata->digest.len);
5671 if (ut_params->obuf)
5672 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5673 ciphertext_len, buffer);
5675 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5676 ciphertext_len, buffer);
5678 debug_hexdump(stdout, "ciphertext:", ciphertext,
5680 debug_hexdump(stdout, "ciphertext expected:",
5681 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5683 if (ut_params->obuf)
5684 digest = rte_pktmbuf_read(ut_params->obuf,
5685 (tdata->digest.offset_bytes == 0 ?
5686 plaintext_pad_len : tdata->digest.offset_bytes),
5687 tdata->digest.len, digest_buffer);
5689 digest = rte_pktmbuf_read(ut_params->ibuf,
5690 (tdata->digest.offset_bytes == 0 ?
5691 plaintext_pad_len : tdata->digest.offset_bytes),
5692 tdata->digest.len, digest_buffer);
5694 debug_hexdump(stdout, "digest:", digest,
5696 debug_hexdump(stdout, "digest expected:",
5697 tdata->digest.data, tdata->digest.len);
5702 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5704 tdata->plaintext.data,
5705 tdata->plaintext.len >> 3,
5706 "KASUMI Plaintext data not as expected");
5708 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5710 tdata->ciphertext.data,
5711 tdata->validDataLenInBits.len,
5712 "KASUMI Ciphertext data not as expected");
5714 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5717 DIGEST_BYTE_LENGTH_KASUMI_F9,
5718 "KASUMI Generated auth tag not as expected");
5724 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5726 struct crypto_testsuite_params *ts_params = &testsuite_params;
5727 struct crypto_unittest_params *ut_params = &unittest_params;
5731 uint8_t *plaintext, *ciphertext;
5732 unsigned plaintext_pad_len;
5733 unsigned plaintext_len;
5734 struct rte_cryptodev_info dev_info;
5736 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5737 uint64_t feat_flags = dev_info.feature_flags;
5739 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5740 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5741 printf("Device doesn't support RAW data-path APIs.\n");
5742 return TEST_SKIPPED;
5745 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5746 return TEST_SKIPPED;
5748 /* Verify the capabilities */
5749 struct rte_cryptodev_sym_capability_idx cap_idx;
5750 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5751 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5752 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5754 return TEST_SKIPPED;
5755 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5756 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5757 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5759 return TEST_SKIPPED;
5761 /* Create KASUMI session */
5762 retval = create_wireless_algo_cipher_auth_session(
5763 ts_params->valid_devs[0],
5764 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5765 RTE_CRYPTO_AUTH_OP_GENERATE,
5766 RTE_CRYPTO_AUTH_KASUMI_F9,
5767 RTE_CRYPTO_CIPHER_KASUMI_F8,
5768 tdata->key.data, tdata->key.len,
5769 0, tdata->digest.len,
5770 tdata->cipher_iv.len);
5774 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5776 /* clear mbuf payload */
5777 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5778 rte_pktmbuf_tailroom(ut_params->ibuf));
5780 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5781 /* Append data which is padded to a multiple of */
5782 /* the algorithms block size */
5783 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5784 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5786 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5788 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5790 /* Create KASUMI operation */
5791 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5792 tdata->digest.len, NULL, 0,
5793 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5794 tdata->cipher_iv.data, tdata->cipher_iv.len,
5795 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5796 tdata->validCipherOffsetInBits.len,
5797 tdata->validAuthLenInBits.len,
5803 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5804 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5805 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5807 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5809 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5811 if (ut_params->op->sym->m_dst)
5812 ut_params->obuf = ut_params->op->sym->m_dst;
5814 ut_params->obuf = ut_params->op->sym->m_src;
5816 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5817 tdata->validCipherOffsetInBits.len >> 3);
5819 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5820 + plaintext_pad_len;
5822 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5823 (tdata->validCipherOffsetInBits.len >> 3);
5825 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5827 reference_ciphertext,
5828 tdata->validCipherLenInBits.len,
5829 "KASUMI Ciphertext data not as expected");
5832 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5835 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5836 "KASUMI Generated auth tag not as expected");
5841 test_zuc_encryption(const struct wireless_test_data *tdata)
5843 struct crypto_testsuite_params *ts_params = &testsuite_params;
5844 struct crypto_unittest_params *ut_params = &unittest_params;
5847 uint8_t *plaintext, *ciphertext;
5848 unsigned plaintext_pad_len;
5849 unsigned plaintext_len;
5850 struct rte_cryptodev_info dev_info;
5852 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5853 uint64_t feat_flags = dev_info.feature_flags;
5855 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5856 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5857 printf("Device doesn't support RAW data-path APIs.\n");
5858 return TEST_SKIPPED;
5861 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5862 return TEST_SKIPPED;
5864 struct rte_cryptodev_sym_capability_idx cap_idx;
5866 /* Check if device supports ZUC EEA3 */
5867 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5868 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5870 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5872 return TEST_SKIPPED;
5874 /* Create ZUC session */
5875 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5876 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5877 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5878 tdata->key.data, tdata->key.len,
5879 tdata->cipher_iv.len);
5883 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5885 /* Clear mbuf payload */
5886 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5887 rte_pktmbuf_tailroom(ut_params->ibuf));
5889 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5890 /* Append data which is padded to a multiple */
5891 /* of the algorithms block size */
5892 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5893 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5895 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5897 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5899 /* Create ZUC operation */
5900 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5901 tdata->cipher_iv.len,
5902 tdata->plaintext.len,
5907 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5908 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5909 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5911 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5913 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5915 ut_params->obuf = ut_params->op->sym->m_dst;
5916 if (ut_params->obuf)
5917 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5919 ciphertext = plaintext;
5921 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5924 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5926 tdata->ciphertext.data,
5927 tdata->validCipherLenInBits.len,
5928 "ZUC Ciphertext data not as expected");
5933 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5935 struct crypto_testsuite_params *ts_params = &testsuite_params;
5936 struct crypto_unittest_params *ut_params = &unittest_params;
5940 unsigned int plaintext_pad_len;
5941 unsigned int plaintext_len;
5942 const uint8_t *ciphertext;
5943 uint8_t ciphertext_buffer[2048];
5944 struct rte_cryptodev_info dev_info;
5946 struct rte_cryptodev_sym_capability_idx cap_idx;
5948 /* Check if device supports ZUC EEA3 */
5949 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5950 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5952 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5954 return TEST_SKIPPED;
5956 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5957 return TEST_SKIPPED;
5959 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5961 uint64_t feat_flags = dev_info.feature_flags;
5963 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5964 printf("Device doesn't support in-place scatter-gather. "
5966 return TEST_SKIPPED;
5969 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5970 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5971 printf("Device doesn't support RAW data-path APIs.\n");
5972 return TEST_SKIPPED;
5975 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5977 /* Append data which is padded to a multiple */
5978 /* of the algorithms block size */
5979 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5981 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5982 plaintext_pad_len, 10, 0);
5984 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5985 tdata->plaintext.data);
5987 /* Create ZUC session */
5988 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5989 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5990 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5991 tdata->key.data, tdata->key.len,
5992 tdata->cipher_iv.len);
5996 /* Clear mbuf payload */
5998 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6000 /* Create ZUC operation */
6001 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6002 tdata->cipher_iv.len, tdata->plaintext.len,
6007 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6008 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6009 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6011 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6013 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6015 ut_params->obuf = ut_params->op->sym->m_dst;
6016 if (ut_params->obuf)
6017 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6018 0, plaintext_len, ciphertext_buffer);
6020 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6021 0, plaintext_len, ciphertext_buffer);
6024 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6027 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6029 tdata->ciphertext.data,
6030 tdata->validCipherLenInBits.len,
6031 "ZUC Ciphertext data not as expected");
6037 test_zuc_authentication(const struct wireless_test_data *tdata)
6039 struct crypto_testsuite_params *ts_params = &testsuite_params;
6040 struct crypto_unittest_params *ut_params = &unittest_params;
6043 unsigned plaintext_pad_len;
6044 unsigned plaintext_len;
6047 struct rte_cryptodev_sym_capability_idx cap_idx;
6048 struct rte_cryptodev_info dev_info;
6050 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6051 uint64_t feat_flags = dev_info.feature_flags;
6053 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6054 (tdata->validAuthLenInBits.len % 8 != 0)) {
6055 printf("Device doesn't support NON-Byte Aligned Data.\n");
6056 return TEST_SKIPPED;
6059 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6060 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6061 printf("Device doesn't support RAW data-path APIs.\n");
6062 return TEST_SKIPPED;
6065 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6066 return TEST_SKIPPED;
6068 /* Check if device supports ZUC EIA3 */
6069 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6070 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6072 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6074 return TEST_SKIPPED;
6076 /* Create ZUC session */
6077 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6078 tdata->key.data, tdata->key.len,
6079 tdata->auth_iv.len, tdata->digest.len,
6080 RTE_CRYPTO_AUTH_OP_GENERATE,
6081 RTE_CRYPTO_AUTH_ZUC_EIA3);
6085 /* alloc mbuf and set payload */
6086 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6088 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6089 rte_pktmbuf_tailroom(ut_params->ibuf));
6091 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6092 /* Append data which is padded to a multiple of */
6093 /* the algorithms block size */
6094 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6095 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6097 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6099 /* Create ZUC operation */
6100 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6101 tdata->auth_iv.data, tdata->auth_iv.len,
6102 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6103 tdata->validAuthLenInBits.len,
6108 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6109 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6110 ut_params->op, 0, 1, 1, 0);
6112 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6114 ut_params->obuf = ut_params->op->sym->m_src;
6115 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6116 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6117 + plaintext_pad_len;
6120 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6124 "ZUC Generated auth tag not as expected");
6130 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6131 uint8_t op_mode, uint8_t verify)
6133 struct crypto_testsuite_params *ts_params = &testsuite_params;
6134 struct crypto_unittest_params *ut_params = &unittest_params;
6138 uint8_t *plaintext = NULL, *ciphertext = NULL;
6139 unsigned int plaintext_pad_len;
6140 unsigned int plaintext_len;
6141 unsigned int ciphertext_pad_len;
6142 unsigned int ciphertext_len;
6144 struct rte_cryptodev_info dev_info;
6145 struct rte_cryptodev_sym_capability_idx cap_idx;
6147 /* Check if device supports ZUC EIA3 */
6148 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6149 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6151 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6153 return TEST_SKIPPED;
6155 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6157 uint64_t feat_flags = dev_info.feature_flags;
6159 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6160 printf("Device doesn't support digest encrypted.\n");
6161 return TEST_SKIPPED;
6163 if (op_mode == IN_PLACE) {
6164 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6165 printf("Device doesn't support in-place scatter-gather "
6166 "in both input and output mbufs.\n");
6167 return TEST_SKIPPED;
6170 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6171 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6172 printf("Device doesn't support RAW data-path APIs.\n");
6173 return TEST_SKIPPED;
6176 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6177 return TEST_SKIPPED;
6178 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6179 printf("Device doesn't support out-of-place scatter-gather "
6180 "in both input and output mbufs.\n");
6181 return TEST_SKIPPED;
6185 /* Create ZUC session */
6186 retval = create_wireless_algo_auth_cipher_session(
6187 ts_params->valid_devs[0],
6188 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6189 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6190 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6191 : RTE_CRYPTO_AUTH_OP_GENERATE),
6192 RTE_CRYPTO_AUTH_ZUC_EIA3,
6193 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6194 tdata->key.data, tdata->key.len,
6195 tdata->auth_iv.len, tdata->digest.len,
6196 tdata->cipher_iv.len);
6201 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6202 if (op_mode == OUT_OF_PLACE)
6203 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6205 /* clear mbuf payload */
6206 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6207 rte_pktmbuf_tailroom(ut_params->ibuf));
6208 if (op_mode == OUT_OF_PLACE)
6209 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6210 rte_pktmbuf_tailroom(ut_params->obuf));
6212 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6213 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6214 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6215 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6218 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6219 ciphertext_pad_len);
6220 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6221 if (op_mode == OUT_OF_PLACE)
6222 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6223 debug_hexdump(stdout, "ciphertext:", ciphertext,
6226 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6228 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6229 if (op_mode == OUT_OF_PLACE)
6230 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6231 debug_hexdump(stdout, "plaintext:", plaintext,
6235 /* Create ZUC operation */
6236 retval = create_wireless_algo_auth_cipher_operation(
6237 tdata->digest.data, tdata->digest.len,
6238 tdata->cipher_iv.data, tdata->cipher_iv.len,
6239 tdata->auth_iv.data, tdata->auth_iv.len,
6240 (tdata->digest.offset_bytes == 0 ?
6241 (verify ? ciphertext_pad_len : plaintext_pad_len)
6242 : tdata->digest.offset_bytes),
6243 tdata->validCipherLenInBits.len,
6244 tdata->validCipherOffsetInBits.len,
6245 tdata->validAuthLenInBits.len,
6247 op_mode, 0, verify);
6252 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6253 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6254 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6256 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6259 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6261 ut_params->obuf = (op_mode == IN_PLACE ?
6262 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6266 if (ut_params->obuf)
6267 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6270 plaintext = ciphertext;
6272 debug_hexdump(stdout, "plaintext:", plaintext,
6273 (tdata->plaintext.len >> 3) - tdata->digest.len);
6274 debug_hexdump(stdout, "plaintext expected:",
6275 tdata->plaintext.data,
6276 (tdata->plaintext.len >> 3) - tdata->digest.len);
6278 if (ut_params->obuf)
6279 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6282 ciphertext = plaintext;
6284 debug_hexdump(stdout, "ciphertext:", ciphertext,
6286 debug_hexdump(stdout, "ciphertext expected:",
6287 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6289 ut_params->digest = rte_pktmbuf_mtod(
6290 ut_params->obuf, uint8_t *) +
6291 (tdata->digest.offset_bytes == 0 ?
6292 plaintext_pad_len : tdata->digest.offset_bytes);
6294 debug_hexdump(stdout, "digest:", ut_params->digest,
6296 debug_hexdump(stdout, "digest expected:",
6297 tdata->digest.data, tdata->digest.len);
6302 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6304 tdata->plaintext.data,
6305 tdata->plaintext.len >> 3,
6306 "ZUC Plaintext data not as expected");
6308 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6310 tdata->ciphertext.data,
6311 tdata->ciphertext.len >> 3,
6312 "ZUC Ciphertext data not as expected");
6314 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6317 DIGEST_BYTE_LENGTH_KASUMI_F9,
6318 "ZUC Generated auth tag not as expected");
6324 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6325 uint8_t op_mode, uint8_t verify)
6327 struct crypto_testsuite_params *ts_params = &testsuite_params;
6328 struct crypto_unittest_params *ut_params = &unittest_params;
6332 const uint8_t *plaintext = NULL;
6333 const uint8_t *ciphertext = NULL;
6334 const uint8_t *digest = NULL;
6335 unsigned int plaintext_pad_len;
6336 unsigned int plaintext_len;
6337 unsigned int ciphertext_pad_len;
6338 unsigned int ciphertext_len;
6339 uint8_t buffer[10000];
6340 uint8_t digest_buffer[10000];
6342 struct rte_cryptodev_info dev_info;
6343 struct rte_cryptodev_sym_capability_idx cap_idx;
6345 /* Check if device supports ZUC EIA3 */
6346 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6347 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6349 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6351 return TEST_SKIPPED;
6353 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6355 uint64_t feat_flags = dev_info.feature_flags;
6357 if (op_mode == IN_PLACE) {
6358 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6359 printf("Device doesn't support in-place scatter-gather "
6360 "in both input and output mbufs.\n");
6361 return TEST_SKIPPED;
6364 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6365 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6366 printf("Device doesn't support RAW data-path APIs.\n");
6367 return TEST_SKIPPED;
6370 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6371 return TEST_SKIPPED;
6372 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6373 printf("Device doesn't support out-of-place scatter-gather "
6374 "in both input and output mbufs.\n");
6375 return TEST_SKIPPED;
6377 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6378 printf("Device doesn't support digest encrypted.\n");
6379 return TEST_SKIPPED;
6383 /* Create ZUC session */
6384 retval = create_wireless_algo_auth_cipher_session(
6385 ts_params->valid_devs[0],
6386 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6387 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6388 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6389 : RTE_CRYPTO_AUTH_OP_GENERATE),
6390 RTE_CRYPTO_AUTH_ZUC_EIA3,
6391 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6392 tdata->key.data, tdata->key.len,
6393 tdata->auth_iv.len, tdata->digest.len,
6394 tdata->cipher_iv.len);
6399 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6400 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6401 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6402 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6404 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6405 plaintext_pad_len, 15, 0);
6406 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6407 "Failed to allocate input buffer in mempool");
6409 if (op_mode == OUT_OF_PLACE) {
6410 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6411 plaintext_pad_len, 15, 0);
6412 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6413 "Failed to allocate output buffer in mempool");
6417 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6418 tdata->ciphertext.data);
6419 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6420 ciphertext_len, buffer);
6421 debug_hexdump(stdout, "ciphertext:", ciphertext,
6424 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6425 tdata->plaintext.data);
6426 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6427 plaintext_len, buffer);
6428 debug_hexdump(stdout, "plaintext:", plaintext,
6431 memset(buffer, 0, sizeof(buffer));
6433 /* Create ZUC operation */
6434 retval = create_wireless_algo_auth_cipher_operation(
6435 tdata->digest.data, tdata->digest.len,
6436 tdata->cipher_iv.data, tdata->cipher_iv.len,
6438 (tdata->digest.offset_bytes == 0 ?
6439 (verify ? ciphertext_pad_len : plaintext_pad_len)
6440 : tdata->digest.offset_bytes),
6441 tdata->validCipherLenInBits.len,
6442 tdata->validCipherOffsetInBits.len,
6443 tdata->validAuthLenInBits.len,
6445 op_mode, 1, verify);
6450 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6451 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6452 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6454 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6457 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6459 ut_params->obuf = (op_mode == IN_PLACE ?
6460 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6463 if (ut_params->obuf)
6464 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6465 plaintext_len, buffer);
6467 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6468 plaintext_len, buffer);
6470 debug_hexdump(stdout, "plaintext:", plaintext,
6471 (tdata->plaintext.len >> 3) - tdata->digest.len);
6472 debug_hexdump(stdout, "plaintext expected:",
6473 tdata->plaintext.data,
6474 (tdata->plaintext.len >> 3) - tdata->digest.len);
6476 if (ut_params->obuf)
6477 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6478 ciphertext_len, buffer);
6480 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6481 ciphertext_len, buffer);
6483 debug_hexdump(stdout, "ciphertext:", ciphertext,
6485 debug_hexdump(stdout, "ciphertext expected:",
6486 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6488 if (ut_params->obuf)
6489 digest = rte_pktmbuf_read(ut_params->obuf,
6490 (tdata->digest.offset_bytes == 0 ?
6491 plaintext_pad_len : tdata->digest.offset_bytes),
6492 tdata->digest.len, digest_buffer);
6494 digest = rte_pktmbuf_read(ut_params->ibuf,
6495 (tdata->digest.offset_bytes == 0 ?
6496 plaintext_pad_len : tdata->digest.offset_bytes),
6497 tdata->digest.len, digest_buffer);
6499 debug_hexdump(stdout, "digest:", digest,
6501 debug_hexdump(stdout, "digest expected:",
6502 tdata->digest.data, tdata->digest.len);
6507 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6509 tdata->plaintext.data,
6510 tdata->plaintext.len >> 3,
6511 "ZUC Plaintext data not as expected");
6513 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6515 tdata->ciphertext.data,
6516 tdata->validDataLenInBits.len,
6517 "ZUC Ciphertext data not as expected");
6519 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6522 DIGEST_BYTE_LENGTH_KASUMI_F9,
6523 "ZUC Generated auth tag not as expected");
6529 test_kasumi_encryption_test_case_1(void)
6531 return test_kasumi_encryption(&kasumi_test_case_1);
6535 test_kasumi_encryption_test_case_1_sgl(void)
6537 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6541 test_kasumi_encryption_test_case_1_oop(void)
6543 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6547 test_kasumi_encryption_test_case_1_oop_sgl(void)
6549 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6553 test_kasumi_encryption_test_case_2(void)
6555 return test_kasumi_encryption(&kasumi_test_case_2);
6559 test_kasumi_encryption_test_case_3(void)
6561 return test_kasumi_encryption(&kasumi_test_case_3);
6565 test_kasumi_encryption_test_case_4(void)
6567 return test_kasumi_encryption(&kasumi_test_case_4);
6571 test_kasumi_encryption_test_case_5(void)
6573 return test_kasumi_encryption(&kasumi_test_case_5);
6577 test_kasumi_decryption_test_case_1(void)
6579 return test_kasumi_decryption(&kasumi_test_case_1);
6583 test_kasumi_decryption_test_case_1_oop(void)
6585 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6589 test_kasumi_decryption_test_case_2(void)
6591 return test_kasumi_decryption(&kasumi_test_case_2);
6595 test_kasumi_decryption_test_case_3(void)
6597 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6598 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6599 return TEST_SKIPPED;
6600 return test_kasumi_decryption(&kasumi_test_case_3);
6604 test_kasumi_decryption_test_case_4(void)
6606 return test_kasumi_decryption(&kasumi_test_case_4);
6610 test_kasumi_decryption_test_case_5(void)
6612 return test_kasumi_decryption(&kasumi_test_case_5);
6615 test_snow3g_encryption_test_case_1(void)
6617 return test_snow3g_encryption(&snow3g_test_case_1);
6621 test_snow3g_encryption_test_case_1_oop(void)
6623 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6627 test_snow3g_encryption_test_case_1_oop_sgl(void)
6629 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6634 test_snow3g_encryption_test_case_1_offset_oop(void)
6636 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6640 test_snow3g_encryption_test_case_2(void)
6642 return test_snow3g_encryption(&snow3g_test_case_2);
6646 test_snow3g_encryption_test_case_3(void)
6648 return test_snow3g_encryption(&snow3g_test_case_3);
6652 test_snow3g_encryption_test_case_4(void)
6654 return test_snow3g_encryption(&snow3g_test_case_4);
6658 test_snow3g_encryption_test_case_5(void)
6660 return test_snow3g_encryption(&snow3g_test_case_5);
6664 test_snow3g_decryption_test_case_1(void)
6666 return test_snow3g_decryption(&snow3g_test_case_1);
6670 test_snow3g_decryption_test_case_1_oop(void)
6672 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6676 test_snow3g_decryption_test_case_2(void)
6678 return test_snow3g_decryption(&snow3g_test_case_2);
6682 test_snow3g_decryption_test_case_3(void)
6684 return test_snow3g_decryption(&snow3g_test_case_3);
6688 test_snow3g_decryption_test_case_4(void)
6690 return test_snow3g_decryption(&snow3g_test_case_4);
6694 test_snow3g_decryption_test_case_5(void)
6696 return test_snow3g_decryption(&snow3g_test_case_5);
6700 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6701 * Pattern digest from snow3g_test_data must be allocated as
6702 * 4 last bytes in plaintext.
6705 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6706 struct snow3g_hash_test_data *output)
6708 if ((pattern != NULL) && (output != NULL)) {
6709 output->key.len = pattern->key.len;
6711 memcpy(output->key.data,
6712 pattern->key.data, pattern->key.len);
6714 output->auth_iv.len = pattern->auth_iv.len;
6716 memcpy(output->auth_iv.data,
6717 pattern->auth_iv.data, pattern->auth_iv.len);
6719 output->plaintext.len = pattern->plaintext.len;
6721 memcpy(output->plaintext.data,
6722 pattern->plaintext.data, pattern->plaintext.len >> 3);
6724 output->digest.len = pattern->digest.len;
6726 memcpy(output->digest.data,
6727 &pattern->plaintext.data[pattern->digest.offset_bytes],
6728 pattern->digest.len);
6730 output->validAuthLenInBits.len =
6731 pattern->validAuthLenInBits.len;
6736 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6739 test_snow3g_decryption_with_digest_test_case_1(void)
6741 struct snow3g_hash_test_data snow3g_hash_data;
6742 struct rte_cryptodev_info dev_info;
6743 struct crypto_testsuite_params *ts_params = &testsuite_params;
6745 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6746 uint64_t feat_flags = dev_info.feature_flags;
6748 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6749 printf("Device doesn't support encrypted digest operations.\n");
6750 return TEST_SKIPPED;
6754 * Function prepare data for hash veryfication test case.
6755 * Digest is allocated in 4 last bytes in plaintext, pattern.
6757 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6759 return test_snow3g_decryption(&snow3g_test_case_7) &
6760 test_snow3g_authentication_verify(&snow3g_hash_data);
6764 test_snow3g_cipher_auth_test_case_1(void)
6766 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6770 test_snow3g_auth_cipher_test_case_1(void)
6772 return test_snow3g_auth_cipher(
6773 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6777 test_snow3g_auth_cipher_test_case_2(void)
6779 return test_snow3g_auth_cipher(
6780 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6784 test_snow3g_auth_cipher_test_case_2_oop(void)
6786 return test_snow3g_auth_cipher(
6787 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6791 test_snow3g_auth_cipher_part_digest_enc(void)
6793 return test_snow3g_auth_cipher(
6794 &snow3g_auth_cipher_partial_digest_encryption,
6799 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6801 return test_snow3g_auth_cipher(
6802 &snow3g_auth_cipher_partial_digest_encryption,
6807 test_snow3g_auth_cipher_test_case_3_sgl(void)
6809 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6810 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6811 return TEST_SKIPPED;
6812 return test_snow3g_auth_cipher_sgl(
6813 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6817 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6819 return test_snow3g_auth_cipher_sgl(
6820 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6824 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6826 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6827 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6828 return TEST_SKIPPED;
6829 return test_snow3g_auth_cipher_sgl(
6830 &snow3g_auth_cipher_partial_digest_encryption,
6835 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6837 return test_snow3g_auth_cipher_sgl(
6838 &snow3g_auth_cipher_partial_digest_encryption,
6843 test_snow3g_auth_cipher_verify_test_case_1(void)
6845 return test_snow3g_auth_cipher(
6846 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6850 test_snow3g_auth_cipher_verify_test_case_2(void)
6852 return test_snow3g_auth_cipher(
6853 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6857 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6859 return test_snow3g_auth_cipher(
6860 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6864 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6866 return test_snow3g_auth_cipher(
6867 &snow3g_auth_cipher_partial_digest_encryption,
6872 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6874 return test_snow3g_auth_cipher(
6875 &snow3g_auth_cipher_partial_digest_encryption,
6880 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6882 return test_snow3g_auth_cipher_sgl(
6883 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6887 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6889 return test_snow3g_auth_cipher_sgl(
6890 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6894 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6896 return test_snow3g_auth_cipher_sgl(
6897 &snow3g_auth_cipher_partial_digest_encryption,
6902 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6904 return test_snow3g_auth_cipher_sgl(
6905 &snow3g_auth_cipher_partial_digest_encryption,
6910 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6912 return test_snow3g_auth_cipher(
6913 &snow3g_test_case_7, IN_PLACE, 0);
6917 test_kasumi_auth_cipher_test_case_1(void)
6919 return test_kasumi_auth_cipher(
6920 &kasumi_test_case_3, IN_PLACE, 0);
6924 test_kasumi_auth_cipher_test_case_2(void)
6926 return test_kasumi_auth_cipher(
6927 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6931 test_kasumi_auth_cipher_test_case_2_oop(void)
6933 return test_kasumi_auth_cipher(
6934 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6938 test_kasumi_auth_cipher_test_case_2_sgl(void)
6940 return test_kasumi_auth_cipher_sgl(
6941 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6945 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6947 return test_kasumi_auth_cipher_sgl(
6948 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6952 test_kasumi_auth_cipher_verify_test_case_1(void)
6954 return test_kasumi_auth_cipher(
6955 &kasumi_test_case_3, IN_PLACE, 1);
6959 test_kasumi_auth_cipher_verify_test_case_2(void)
6961 return test_kasumi_auth_cipher(
6962 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6966 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6968 return test_kasumi_auth_cipher(
6969 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6973 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6975 return test_kasumi_auth_cipher_sgl(
6976 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6980 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6982 return test_kasumi_auth_cipher_sgl(
6983 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6987 test_kasumi_cipher_auth_test_case_1(void)
6989 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6993 test_zuc_encryption_test_case_1(void)
6995 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6999 test_zuc_encryption_test_case_2(void)
7001 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7005 test_zuc_encryption_test_case_3(void)
7007 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7011 test_zuc_encryption_test_case_4(void)
7013 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7017 test_zuc_encryption_test_case_5(void)
7019 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7023 test_zuc_encryption_test_case_6_sgl(void)
7025 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7029 test_zuc_hash_generate_test_case_1(void)
7031 return test_zuc_authentication(&zuc_test_case_auth_1b);
7035 test_zuc_hash_generate_test_case_2(void)
7037 return test_zuc_authentication(&zuc_test_case_auth_90b);
7041 test_zuc_hash_generate_test_case_3(void)
7043 return test_zuc_authentication(&zuc_test_case_auth_577b);
7047 test_zuc_hash_generate_test_case_4(void)
7049 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7053 test_zuc_hash_generate_test_case_5(void)
7055 return test_zuc_authentication(&zuc_test_auth_5670b);
7059 test_zuc_hash_generate_test_case_6(void)
7061 return test_zuc_authentication(&zuc_test_case_auth_128b);
7065 test_zuc_hash_generate_test_case_7(void)
7067 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7071 test_zuc_hash_generate_test_case_8(void)
7073 return test_zuc_authentication(&zuc_test_case_auth_584b);
7077 test_zuc_cipher_auth_test_case_1(void)
7079 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7083 test_zuc_cipher_auth_test_case_2(void)
7085 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7089 test_zuc_auth_cipher_test_case_1(void)
7091 return test_zuc_auth_cipher(
7092 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7096 test_zuc_auth_cipher_test_case_1_oop(void)
7098 return test_zuc_auth_cipher(
7099 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7103 test_zuc_auth_cipher_test_case_1_sgl(void)
7105 return test_zuc_auth_cipher_sgl(
7106 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7110 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7112 return test_zuc_auth_cipher_sgl(
7113 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7117 test_zuc_auth_cipher_verify_test_case_1(void)
7119 return test_zuc_auth_cipher(
7120 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7124 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7126 return test_zuc_auth_cipher(
7127 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7131 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7133 return test_zuc_auth_cipher_sgl(
7134 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7138 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7140 return test_zuc_auth_cipher_sgl(
7141 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7145 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7147 uint8_t dev_id = testsuite_params.valid_devs[0];
7149 struct rte_cryptodev_sym_capability_idx cap_idx;
7151 /* Check if device supports particular cipher algorithm */
7152 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7153 cap_idx.algo.cipher = tdata->cipher_algo;
7154 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7155 return TEST_SKIPPED;
7157 /* Check if device supports particular hash algorithm */
7158 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7159 cap_idx.algo.auth = tdata->auth_algo;
7160 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7161 return TEST_SKIPPED;
7167 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7168 uint8_t op_mode, uint8_t verify)
7170 struct crypto_testsuite_params *ts_params = &testsuite_params;
7171 struct crypto_unittest_params *ut_params = &unittest_params;
7175 uint8_t *plaintext = NULL, *ciphertext = NULL;
7176 unsigned int plaintext_pad_len;
7177 unsigned int plaintext_len;
7178 unsigned int ciphertext_pad_len;
7179 unsigned int ciphertext_len;
7181 struct rte_cryptodev_info dev_info;
7182 struct rte_crypto_op *op;
7184 /* Check if device supports particular algorithms separately */
7185 if (test_mixed_check_if_unsupported(tdata))
7186 return TEST_SKIPPED;
7187 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7188 return TEST_SKIPPED;
7190 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7192 uint64_t feat_flags = dev_info.feature_flags;
7194 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7195 printf("Device doesn't support digest encrypted.\n");
7196 return TEST_SKIPPED;
7199 /* Create the session */
7201 retval = create_wireless_algo_cipher_auth_session(
7202 ts_params->valid_devs[0],
7203 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7204 RTE_CRYPTO_AUTH_OP_VERIFY,
7207 tdata->auth_key.data, tdata->auth_key.len,
7208 tdata->auth_iv.len, tdata->digest_enc.len,
7209 tdata->cipher_iv.len);
7211 retval = create_wireless_algo_auth_cipher_session(
7212 ts_params->valid_devs[0],
7213 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7214 RTE_CRYPTO_AUTH_OP_GENERATE,
7217 tdata->auth_key.data, tdata->auth_key.len,
7218 tdata->auth_iv.len, tdata->digest_enc.len,
7219 tdata->cipher_iv.len);
7223 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7224 if (op_mode == OUT_OF_PLACE)
7225 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7227 /* clear mbuf payload */
7228 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7229 rte_pktmbuf_tailroom(ut_params->ibuf));
7230 if (op_mode == OUT_OF_PLACE) {
7232 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7233 rte_pktmbuf_tailroom(ut_params->obuf));
7236 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7237 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7238 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7239 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7242 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7243 ciphertext_pad_len);
7244 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7245 if (op_mode == OUT_OF_PLACE)
7246 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7247 debug_hexdump(stdout, "ciphertext:", ciphertext,
7250 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7252 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7253 if (op_mode == OUT_OF_PLACE)
7254 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7255 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7258 /* Create the operation */
7259 retval = create_wireless_algo_auth_cipher_operation(
7260 tdata->digest_enc.data, tdata->digest_enc.len,
7261 tdata->cipher_iv.data, tdata->cipher_iv.len,
7262 tdata->auth_iv.data, tdata->auth_iv.len,
7263 (tdata->digest_enc.offset == 0 ?
7265 : tdata->digest_enc.offset),
7266 tdata->validCipherLen.len_bits,
7267 tdata->cipher.offset_bits,
7268 tdata->validAuthLen.len_bits,
7269 tdata->auth.offset_bits,
7270 op_mode, 0, verify);
7275 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7277 /* Check if the op failed because the device doesn't */
7278 /* support this particular combination of algorithms */
7279 if (op == NULL && ut_params->op->status ==
7280 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7281 printf("Device doesn't support this mixed combination. "
7283 return TEST_SKIPPED;
7287 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7289 ut_params->obuf = (op_mode == IN_PLACE ?
7290 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7293 if (ut_params->obuf)
7294 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7297 plaintext = ciphertext +
7298 (tdata->cipher.offset_bits >> 3);
7300 debug_hexdump(stdout, "plaintext:", plaintext,
7301 tdata->plaintext.len_bits >> 3);
7302 debug_hexdump(stdout, "plaintext expected:",
7303 tdata->plaintext.data,
7304 tdata->plaintext.len_bits >> 3);
7306 if (ut_params->obuf)
7307 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7310 ciphertext = plaintext;
7312 debug_hexdump(stdout, "ciphertext:", ciphertext,
7314 debug_hexdump(stdout, "ciphertext expected:",
7315 tdata->ciphertext.data,
7316 tdata->ciphertext.len_bits >> 3);
7318 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7319 + (tdata->digest_enc.offset == 0 ?
7320 plaintext_pad_len : tdata->digest_enc.offset);
7322 debug_hexdump(stdout, "digest:", ut_params->digest,
7323 tdata->digest_enc.len);
7324 debug_hexdump(stdout, "digest expected:",
7325 tdata->digest_enc.data,
7326 tdata->digest_enc.len);
7331 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7333 tdata->plaintext.data,
7334 tdata->plaintext.len_bits >> 3,
7335 "Plaintext data not as expected");
7337 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7339 tdata->ciphertext.data,
7340 tdata->validDataLen.len_bits,
7341 "Ciphertext data not as expected");
7343 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7345 tdata->digest_enc.data,
7346 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7347 "Generated auth tag not as expected");
7350 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7351 "crypto op processing failed");
7357 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7358 uint8_t op_mode, uint8_t verify)
7360 struct crypto_testsuite_params *ts_params = &testsuite_params;
7361 struct crypto_unittest_params *ut_params = &unittest_params;
7365 const uint8_t *plaintext = NULL;
7366 const uint8_t *ciphertext = NULL;
7367 const uint8_t *digest = NULL;
7368 unsigned int plaintext_pad_len;
7369 unsigned int plaintext_len;
7370 unsigned int ciphertext_pad_len;
7371 unsigned int ciphertext_len;
7372 uint8_t buffer[10000];
7373 uint8_t digest_buffer[10000];
7375 struct rte_cryptodev_info dev_info;
7376 struct rte_crypto_op *op;
7378 /* Check if device supports particular algorithms */
7379 if (test_mixed_check_if_unsupported(tdata))
7380 return TEST_SKIPPED;
7381 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7382 return TEST_SKIPPED;
7384 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7386 uint64_t feat_flags = dev_info.feature_flags;
7388 if (op_mode == IN_PLACE) {
7389 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7390 printf("Device doesn't support in-place scatter-gather "
7391 "in both input and output mbufs.\n");
7392 return TEST_SKIPPED;
7395 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7396 printf("Device doesn't support out-of-place scatter-gather "
7397 "in both input and output mbufs.\n");
7398 return TEST_SKIPPED;
7400 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7401 printf("Device doesn't support digest encrypted.\n");
7402 return TEST_SKIPPED;
7406 /* Create the session */
7408 retval = create_wireless_algo_cipher_auth_session(
7409 ts_params->valid_devs[0],
7410 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7411 RTE_CRYPTO_AUTH_OP_VERIFY,
7414 tdata->auth_key.data, tdata->auth_key.len,
7415 tdata->auth_iv.len, tdata->digest_enc.len,
7416 tdata->cipher_iv.len);
7418 retval = create_wireless_algo_auth_cipher_session(
7419 ts_params->valid_devs[0],
7420 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7421 RTE_CRYPTO_AUTH_OP_GENERATE,
7424 tdata->auth_key.data, tdata->auth_key.len,
7425 tdata->auth_iv.len, tdata->digest_enc.len,
7426 tdata->cipher_iv.len);
7430 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7431 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7432 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7433 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7435 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7436 ciphertext_pad_len, 15, 0);
7437 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7438 "Failed to allocate input buffer in mempool");
7440 if (op_mode == OUT_OF_PLACE) {
7441 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7442 plaintext_pad_len, 15, 0);
7443 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7444 "Failed to allocate output buffer in mempool");
7448 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7449 tdata->ciphertext.data);
7450 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7451 ciphertext_len, buffer);
7452 debug_hexdump(stdout, "ciphertext:", ciphertext,
7455 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7456 tdata->plaintext.data);
7457 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7458 plaintext_len, buffer);
7459 debug_hexdump(stdout, "plaintext:", plaintext,
7462 memset(buffer, 0, sizeof(buffer));
7464 /* Create the operation */
7465 retval = create_wireless_algo_auth_cipher_operation(
7466 tdata->digest_enc.data, tdata->digest_enc.len,
7467 tdata->cipher_iv.data, tdata->cipher_iv.len,
7468 tdata->auth_iv.data, tdata->auth_iv.len,
7469 (tdata->digest_enc.offset == 0 ?
7471 : tdata->digest_enc.offset),
7472 tdata->validCipherLen.len_bits,
7473 tdata->cipher.offset_bits,
7474 tdata->validAuthLen.len_bits,
7475 tdata->auth.offset_bits,
7476 op_mode, 1, verify);
7481 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7483 /* Check if the op failed because the device doesn't */
7484 /* support this particular combination of algorithms */
7485 if (op == NULL && ut_params->op->status ==
7486 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7487 printf("Device doesn't support this mixed combination. "
7489 return TEST_SKIPPED;
7493 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7495 ut_params->obuf = (op_mode == IN_PLACE ?
7496 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7499 if (ut_params->obuf)
7500 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7501 plaintext_len, buffer);
7503 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7504 plaintext_len, buffer);
7506 debug_hexdump(stdout, "plaintext:", plaintext,
7507 (tdata->plaintext.len_bits >> 3) -
7508 tdata->digest_enc.len);
7509 debug_hexdump(stdout, "plaintext expected:",
7510 tdata->plaintext.data,
7511 (tdata->plaintext.len_bits >> 3) -
7512 tdata->digest_enc.len);
7514 if (ut_params->obuf)
7515 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7516 ciphertext_len, buffer);
7518 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7519 ciphertext_len, buffer);
7521 debug_hexdump(stdout, "ciphertext:", ciphertext,
7523 debug_hexdump(stdout, "ciphertext expected:",
7524 tdata->ciphertext.data,
7525 tdata->ciphertext.len_bits >> 3);
7527 if (ut_params->obuf)
7528 digest = rte_pktmbuf_read(ut_params->obuf,
7529 (tdata->digest_enc.offset == 0 ?
7531 tdata->digest_enc.offset),
7532 tdata->digest_enc.len, digest_buffer);
7534 digest = rte_pktmbuf_read(ut_params->ibuf,
7535 (tdata->digest_enc.offset == 0 ?
7537 tdata->digest_enc.offset),
7538 tdata->digest_enc.len, digest_buffer);
7540 debug_hexdump(stdout, "digest:", digest,
7541 tdata->digest_enc.len);
7542 debug_hexdump(stdout, "digest expected:",
7543 tdata->digest_enc.data, tdata->digest_enc.len);
7548 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7550 tdata->plaintext.data,
7551 tdata->plaintext.len_bits >> 3,
7552 "Plaintext data not as expected");
7554 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7556 tdata->ciphertext.data,
7557 tdata->validDataLen.len_bits,
7558 "Ciphertext data not as expected");
7559 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7561 tdata->digest_enc.data,
7562 tdata->digest_enc.len,
7563 "Generated auth tag not as expected");
7566 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7567 "crypto op processing failed");
7572 /** AUTH AES CMAC + CIPHER AES CTR */
7575 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7577 return test_mixed_auth_cipher(
7578 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7582 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7584 return test_mixed_auth_cipher(
7585 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7589 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7591 return test_mixed_auth_cipher_sgl(
7592 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7596 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7598 return test_mixed_auth_cipher_sgl(
7599 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7603 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7605 return test_mixed_auth_cipher(
7606 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7610 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7612 return test_mixed_auth_cipher(
7613 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7617 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7619 return test_mixed_auth_cipher_sgl(
7620 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7624 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7626 return test_mixed_auth_cipher_sgl(
7627 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7630 /** MIXED AUTH + CIPHER */
7633 test_auth_zuc_cipher_snow_test_case_1(void)
7635 return test_mixed_auth_cipher(
7636 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7640 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7642 return test_mixed_auth_cipher(
7643 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7647 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7649 return test_mixed_auth_cipher(
7650 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7654 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7656 return test_mixed_auth_cipher(
7657 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7661 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7663 return test_mixed_auth_cipher(
7664 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7668 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7670 return test_mixed_auth_cipher(
7671 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7675 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7677 return test_mixed_auth_cipher(
7678 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7682 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7684 return test_mixed_auth_cipher(
7685 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7689 test_auth_snow_cipher_zuc_test_case_1(void)
7691 return test_mixed_auth_cipher(
7692 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7696 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7698 return test_mixed_auth_cipher(
7699 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7703 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7705 return test_mixed_auth_cipher(
7706 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7710 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7712 return test_mixed_auth_cipher(
7713 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7717 test_auth_null_cipher_snow_test_case_1(void)
7719 return test_mixed_auth_cipher(
7720 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7724 test_verify_auth_null_cipher_snow_test_case_1(void)
7726 return test_mixed_auth_cipher(
7727 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7731 test_auth_null_cipher_zuc_test_case_1(void)
7733 return test_mixed_auth_cipher(
7734 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7738 test_verify_auth_null_cipher_zuc_test_case_1(void)
7740 return test_mixed_auth_cipher(
7741 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7745 test_auth_snow_cipher_null_test_case_1(void)
7747 return test_mixed_auth_cipher(
7748 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7752 test_verify_auth_snow_cipher_null_test_case_1(void)
7754 return test_mixed_auth_cipher(
7755 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7759 test_auth_zuc_cipher_null_test_case_1(void)
7761 return test_mixed_auth_cipher(
7762 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7766 test_verify_auth_zuc_cipher_null_test_case_1(void)
7768 return test_mixed_auth_cipher(
7769 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7773 test_auth_null_cipher_aes_ctr_test_case_1(void)
7775 return test_mixed_auth_cipher(
7776 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7780 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7782 return test_mixed_auth_cipher(
7783 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7787 test_auth_aes_cmac_cipher_null_test_case_1(void)
7789 return test_mixed_auth_cipher(
7790 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7794 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7796 return test_mixed_auth_cipher(
7797 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7800 /* ***** AEAD algorithm Tests ***** */
7803 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7804 enum rte_crypto_aead_operation op,
7805 const uint8_t *key, const uint8_t key_len,
7806 const uint16_t aad_len, const uint8_t auth_len,
7809 uint8_t aead_key[key_len];
7811 struct crypto_testsuite_params *ts_params = &testsuite_params;
7812 struct crypto_unittest_params *ut_params = &unittest_params;
7814 memcpy(aead_key, key, key_len);
7816 /* Setup AEAD Parameters */
7817 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7818 ut_params->aead_xform.next = NULL;
7819 ut_params->aead_xform.aead.algo = algo;
7820 ut_params->aead_xform.aead.op = op;
7821 ut_params->aead_xform.aead.key.data = aead_key;
7822 ut_params->aead_xform.aead.key.length = key_len;
7823 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7824 ut_params->aead_xform.aead.iv.length = iv_len;
7825 ut_params->aead_xform.aead.digest_length = auth_len;
7826 ut_params->aead_xform.aead.aad_length = aad_len;
7828 debug_hexdump(stdout, "key:", key, key_len);
7830 /* Create Crypto session*/
7831 ut_params->sess = rte_cryptodev_sym_session_create(
7832 ts_params->session_mpool);
7834 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7835 &ut_params->aead_xform,
7836 ts_params->session_priv_mpool);
7838 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7844 create_aead_xform(struct rte_crypto_op *op,
7845 enum rte_crypto_aead_algorithm algo,
7846 enum rte_crypto_aead_operation aead_op,
7847 uint8_t *key, const uint8_t key_len,
7848 const uint8_t aad_len, const uint8_t auth_len,
7851 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7852 "failed to allocate space for crypto transform");
7854 struct rte_crypto_sym_op *sym_op = op->sym;
7856 /* Setup AEAD Parameters */
7857 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7858 sym_op->xform->next = NULL;
7859 sym_op->xform->aead.algo = algo;
7860 sym_op->xform->aead.op = aead_op;
7861 sym_op->xform->aead.key.data = key;
7862 sym_op->xform->aead.key.length = key_len;
7863 sym_op->xform->aead.iv.offset = IV_OFFSET;
7864 sym_op->xform->aead.iv.length = iv_len;
7865 sym_op->xform->aead.digest_length = auth_len;
7866 sym_op->xform->aead.aad_length = aad_len;
7868 debug_hexdump(stdout, "key:", key, key_len);
7874 create_aead_operation(enum rte_crypto_aead_operation op,
7875 const struct aead_test_data *tdata)
7877 struct crypto_testsuite_params *ts_params = &testsuite_params;
7878 struct crypto_unittest_params *ut_params = &unittest_params;
7880 uint8_t *plaintext, *ciphertext;
7881 unsigned int aad_pad_len, plaintext_pad_len;
7883 /* Generate Crypto op data structure */
7884 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7885 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7886 TEST_ASSERT_NOT_NULL(ut_params->op,
7887 "Failed to allocate symmetric crypto operation struct");
7889 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7891 /* Append aad data */
7892 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7893 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7894 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7896 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7897 "no room to append aad");
7899 sym_op->aead.aad.phys_addr =
7900 rte_pktmbuf_iova(ut_params->ibuf);
7901 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7902 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7903 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7906 /* Append IV at the end of the crypto operation*/
7907 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7908 uint8_t *, IV_OFFSET);
7910 /* Copy IV 1 byte after the IV pointer, according to the API */
7911 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7912 debug_hexdump(stdout, "iv:", iv_ptr,
7915 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7916 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7918 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7919 "no room to append aad");
7921 sym_op->aead.aad.phys_addr =
7922 rte_pktmbuf_iova(ut_params->ibuf);
7923 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7924 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7927 /* Append IV at the end of the crypto operation*/
7928 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7929 uint8_t *, IV_OFFSET);
7931 if (tdata->iv.len == 0) {
7932 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7933 debug_hexdump(stdout, "iv:", iv_ptr,
7936 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7937 debug_hexdump(stdout, "iv:", iv_ptr,
7942 /* Append plaintext/ciphertext */
7943 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7944 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7945 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7947 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7949 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7950 debug_hexdump(stdout, "plaintext:", plaintext,
7951 tdata->plaintext.len);
7953 if (ut_params->obuf) {
7954 ciphertext = (uint8_t *)rte_pktmbuf_append(
7956 plaintext_pad_len + aad_pad_len);
7957 TEST_ASSERT_NOT_NULL(ciphertext,
7958 "no room to append ciphertext");
7960 memset(ciphertext + aad_pad_len, 0,
7961 tdata->ciphertext.len);
7964 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7965 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7967 TEST_ASSERT_NOT_NULL(ciphertext,
7968 "no room to append ciphertext");
7970 memcpy(ciphertext, tdata->ciphertext.data,
7971 tdata->ciphertext.len);
7972 debug_hexdump(stdout, "ciphertext:", ciphertext,
7973 tdata->ciphertext.len);
7975 if (ut_params->obuf) {
7976 plaintext = (uint8_t *)rte_pktmbuf_append(
7978 plaintext_pad_len + aad_pad_len);
7979 TEST_ASSERT_NOT_NULL(plaintext,
7980 "no room to append plaintext");
7982 memset(plaintext + aad_pad_len, 0,
7983 tdata->plaintext.len);
7987 /* Append digest data */
7988 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7989 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7990 ut_params->obuf ? ut_params->obuf :
7992 tdata->auth_tag.len);
7993 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7994 "no room to append digest");
7995 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7996 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7997 ut_params->obuf ? ut_params->obuf :
8002 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8003 ut_params->ibuf, tdata->auth_tag.len);
8004 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8005 "no room to append digest");
8006 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8008 plaintext_pad_len + aad_pad_len);
8010 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8011 tdata->auth_tag.len);
8012 debug_hexdump(stdout, "digest:",
8013 sym_op->aead.digest.data,
8014 tdata->auth_tag.len);
8017 sym_op->aead.data.length = tdata->plaintext.len;
8018 sym_op->aead.data.offset = aad_pad_len;
8024 test_authenticated_encryption(const struct aead_test_data *tdata)
8026 struct crypto_testsuite_params *ts_params = &testsuite_params;
8027 struct crypto_unittest_params *ut_params = &unittest_params;
8030 uint8_t *ciphertext, *auth_tag;
8031 uint16_t plaintext_pad_len;
8033 struct rte_cryptodev_info dev_info;
8035 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8036 uint64_t feat_flags = dev_info.feature_flags;
8038 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8039 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8040 printf("Device doesn't support RAW data-path APIs.\n");
8041 return TEST_SKIPPED;
8044 /* Verify the capabilities */
8045 struct rte_cryptodev_sym_capability_idx cap_idx;
8046 const struct rte_cryptodev_symmetric_capability *capability;
8047 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8048 cap_idx.algo.aead = tdata->algo;
8049 capability = rte_cryptodev_sym_capability_get(
8050 ts_params->valid_devs[0], &cap_idx);
8051 if (capability == NULL)
8052 return TEST_SKIPPED;
8053 if (rte_cryptodev_sym_capability_check_aead(
8054 capability, tdata->key.len, tdata->auth_tag.len,
8055 tdata->aad.len, tdata->iv.len))
8056 return TEST_SKIPPED;
8058 /* Create AEAD session */
8059 retval = create_aead_session(ts_params->valid_devs[0],
8061 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8062 tdata->key.data, tdata->key.len,
8063 tdata->aad.len, tdata->auth_tag.len,
8068 if (tdata->aad.len > MBUF_SIZE) {
8069 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8070 /* Populate full size of add data */
8071 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8072 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8074 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8076 /* clear mbuf payload */
8077 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8078 rte_pktmbuf_tailroom(ut_params->ibuf));
8080 /* Create AEAD operation */
8081 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8085 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8087 ut_params->op->sym->m_src = ut_params->ibuf;
8089 /* Process crypto operation */
8090 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8091 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8092 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8093 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8094 ut_params->op, 0, 0, 0, 0);
8096 TEST_ASSERT_NOT_NULL(
8097 process_crypto_request(ts_params->valid_devs[0],
8098 ut_params->op), "failed to process sym crypto op");
8100 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8101 "crypto op processing failed");
8103 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8105 if (ut_params->op->sym->m_dst) {
8106 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8108 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8109 uint8_t *, plaintext_pad_len);
8111 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8113 ut_params->op->sym->cipher.data.offset);
8114 auth_tag = ciphertext + plaintext_pad_len;
8117 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8118 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8121 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8123 tdata->ciphertext.data,
8124 tdata->ciphertext.len,
8125 "Ciphertext data not as expected");
8127 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8129 tdata->auth_tag.data,
8130 tdata->auth_tag.len,
8131 "Generated auth tag not as expected");
8137 #ifdef RTE_LIB_SECURITY
8139 security_proto_supported(enum rte_security_session_action_type action,
8140 enum rte_security_session_protocol proto)
8142 struct crypto_testsuite_params *ts_params = &testsuite_params;
8144 const struct rte_security_capability *capabilities;
8145 const struct rte_security_capability *capability;
8148 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8149 rte_cryptodev_get_sec_ctx(
8150 ts_params->valid_devs[0]);
8153 capabilities = rte_security_capabilities_get(ctx);
8155 if (capabilities == NULL)
8158 while ((capability = &capabilities[i++])->action !=
8159 RTE_SECURITY_ACTION_TYPE_NONE) {
8160 if (capability->action == action &&
8161 capability->protocol == proto)
8168 /* Basic algorithm run function for async inplace mode.
8169 * Creates a session from input parameters and runs one operation
8170 * on input_vec. Checks the output of the crypto operation against
8173 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8174 enum rte_crypto_auth_operation opa,
8175 const uint8_t *input_vec, unsigned int input_vec_len,
8176 const uint8_t *output_vec,
8177 unsigned int output_vec_len,
8178 enum rte_crypto_cipher_algorithm cipher_alg,
8179 const uint8_t *cipher_key, uint32_t cipher_key_len,
8180 enum rte_crypto_auth_algorithm auth_alg,
8181 const uint8_t *auth_key, uint32_t auth_key_len,
8182 uint8_t bearer, enum rte_security_pdcp_domain domain,
8183 uint8_t packet_direction, uint8_t sn_size,
8184 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8186 struct crypto_testsuite_params *ts_params = &testsuite_params;
8187 struct crypto_unittest_params *ut_params = &unittest_params;
8189 int ret = TEST_SUCCESS;
8190 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8191 rte_cryptodev_get_sec_ctx(
8192 ts_params->valid_devs[0]);
8194 /* Verify the capabilities */
8195 struct rte_security_capability_idx sec_cap_idx;
8197 sec_cap_idx.action = ut_params->type;
8198 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8199 sec_cap_idx.pdcp.domain = domain;
8200 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8201 return TEST_SKIPPED;
8203 /* Generate test mbuf data */
8204 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8206 /* clear mbuf payload */
8207 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8208 rte_pktmbuf_tailroom(ut_params->ibuf));
8210 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8212 memcpy(plaintext, input_vec, input_vec_len);
8214 /* Out of place support */
8217 * For out-op-place we need to alloc another mbuf
8219 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8220 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8223 /* Setup Cipher Parameters */
8224 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8225 ut_params->cipher_xform.cipher.algo = cipher_alg;
8226 ut_params->cipher_xform.cipher.op = opc;
8227 ut_params->cipher_xform.cipher.key.data = cipher_key;
8228 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8229 ut_params->cipher_xform.cipher.iv.length =
8230 packet_direction ? 4 : 0;
8231 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8233 /* Setup HMAC Parameters if ICV header is required */
8234 if (auth_alg != 0) {
8235 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8236 ut_params->auth_xform.next = NULL;
8237 ut_params->auth_xform.auth.algo = auth_alg;
8238 ut_params->auth_xform.auth.op = opa;
8239 ut_params->auth_xform.auth.key.data = auth_key;
8240 ut_params->auth_xform.auth.key.length = auth_key_len;
8242 ut_params->cipher_xform.next = &ut_params->auth_xform;
8244 ut_params->cipher_xform.next = NULL;
8247 struct rte_security_session_conf sess_conf = {
8248 .action_type = ut_params->type,
8249 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8253 .pkt_dir = packet_direction,
8255 .hfn = packet_direction ? 0 : hfn,
8257 * hfn can be set as pdcp_test_hfn[i]
8258 * if hfn_ovrd is not set. Here, PDCP
8259 * packet direction is just used to
8260 * run half of the cases with session
8261 * HFN and other half with per packet
8264 .hfn_threshold = hfn_threshold,
8265 .hfn_ovrd = packet_direction ? 1 : 0,
8266 .sdap_enabled = sdap,
8268 .crypto_xform = &ut_params->cipher_xform
8271 /* Create security session */
8272 ut_params->sec_session = rte_security_session_create(ctx,
8273 &sess_conf, ts_params->session_mpool,
8274 ts_params->session_priv_mpool);
8276 if (!ut_params->sec_session) {
8277 printf("TestCase %s()-%d line %d failed %s: ",
8278 __func__, i, __LINE__, "Failed to allocate session");
8283 /* Generate crypto op data structure */
8284 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8285 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8286 if (!ut_params->op) {
8287 printf("TestCase %s()-%d line %d failed %s: ",
8288 __func__, i, __LINE__,
8289 "Failed to allocate symmetric crypto operation struct");
8294 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8295 uint32_t *, IV_OFFSET);
8296 *per_pkt_hfn = packet_direction ? hfn : 0;
8298 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8300 /* set crypto operation source mbuf */
8301 ut_params->op->sym->m_src = ut_params->ibuf;
8303 ut_params->op->sym->m_dst = ut_params->obuf;
8305 /* Process crypto operation */
8306 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8308 printf("TestCase %s()-%d line %d failed %s: ",
8309 __func__, i, __LINE__,
8310 "failed to process sym crypto op");
8315 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8316 printf("TestCase %s()-%d line %d failed %s: ",
8317 __func__, i, __LINE__, "crypto op processing failed");
8323 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8326 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8330 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8331 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8332 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8333 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8339 rte_crypto_op_free(ut_params->op);
8340 ut_params->op = NULL;
8342 if (ut_params->sec_session)
8343 rte_security_session_destroy(ctx, ut_params->sec_session);
8344 ut_params->sec_session = NULL;
8346 rte_pktmbuf_free(ut_params->ibuf);
8347 ut_params->ibuf = NULL;
8349 rte_pktmbuf_free(ut_params->obuf);
8350 ut_params->obuf = NULL;
8357 test_pdcp_proto_SGL(int i, int oop,
8358 enum rte_crypto_cipher_operation opc,
8359 enum rte_crypto_auth_operation opa,
8361 unsigned int input_vec_len,
8362 uint8_t *output_vec,
8363 unsigned int output_vec_len,
8365 uint32_t fragsz_oop)
8367 struct crypto_testsuite_params *ts_params = &testsuite_params;
8368 struct crypto_unittest_params *ut_params = &unittest_params;
8370 struct rte_mbuf *buf, *buf_oop = NULL;
8371 int ret = TEST_SUCCESS;
8375 unsigned int trn_data = 0;
8376 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8377 rte_cryptodev_get_sec_ctx(
8378 ts_params->valid_devs[0]);
8380 /* Verify the capabilities */
8381 struct rte_security_capability_idx sec_cap_idx;
8383 sec_cap_idx.action = ut_params->type;
8384 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8385 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8386 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8387 return TEST_SKIPPED;
8389 if (fragsz > input_vec_len)
8390 fragsz = input_vec_len;
8392 uint16_t plaintext_len = fragsz;
8393 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8395 if (fragsz_oop > output_vec_len)
8396 frag_size_oop = output_vec_len;
8399 if (input_vec_len % fragsz != 0) {
8400 if (input_vec_len / fragsz + 1 > 16)
8402 } else if (input_vec_len / fragsz > 16)
8405 /* Out of place support */
8408 * For out-op-place we need to alloc another mbuf
8410 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8411 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8412 buf_oop = ut_params->obuf;
8415 /* Generate test mbuf data */
8416 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8418 /* clear mbuf payload */
8419 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8420 rte_pktmbuf_tailroom(ut_params->ibuf));
8422 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8424 memcpy(plaintext, input_vec, plaintext_len);
8425 trn_data += plaintext_len;
8427 buf = ut_params->ibuf;
8430 * Loop until no more fragments
8433 while (trn_data < input_vec_len) {
8435 to_trn = (input_vec_len - trn_data < fragsz) ?
8436 (input_vec_len - trn_data) : fragsz;
8438 to_trn_tbl[ecx++] = to_trn;
8440 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8443 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8444 rte_pktmbuf_tailroom(buf));
8447 if (oop && !fragsz_oop) {
8449 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8450 buf_oop = buf_oop->next;
8451 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8452 0, rte_pktmbuf_tailroom(buf_oop));
8453 rte_pktmbuf_append(buf_oop, to_trn);
8456 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8459 memcpy(plaintext, input_vec + trn_data, to_trn);
8463 ut_params->ibuf->nb_segs = segs;
8466 if (fragsz_oop && oop) {
8470 trn_data = frag_size_oop;
8471 while (trn_data < output_vec_len) {
8474 (output_vec_len - trn_data <
8476 (output_vec_len - trn_data) :
8479 to_trn_tbl[ecx++] = to_trn;
8482 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8483 buf_oop = buf_oop->next;
8484 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8485 0, rte_pktmbuf_tailroom(buf_oop));
8486 rte_pktmbuf_append(buf_oop, to_trn);
8490 ut_params->obuf->nb_segs = segs;
8493 /* Setup Cipher Parameters */
8494 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8495 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8496 ut_params->cipher_xform.cipher.op = opc;
8497 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8498 ut_params->cipher_xform.cipher.key.length =
8499 pdcp_test_params[i].cipher_key_len;
8500 ut_params->cipher_xform.cipher.iv.length = 0;
8502 /* Setup HMAC Parameters if ICV header is required */
8503 if (pdcp_test_params[i].auth_alg != 0) {
8504 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8505 ut_params->auth_xform.next = NULL;
8506 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8507 ut_params->auth_xform.auth.op = opa;
8508 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8509 ut_params->auth_xform.auth.key.length =
8510 pdcp_test_params[i].auth_key_len;
8512 ut_params->cipher_xform.next = &ut_params->auth_xform;
8514 ut_params->cipher_xform.next = NULL;
8517 struct rte_security_session_conf sess_conf = {
8518 .action_type = ut_params->type,
8519 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8521 .bearer = pdcp_test_bearer[i],
8522 .domain = pdcp_test_params[i].domain,
8523 .pkt_dir = pdcp_test_packet_direction[i],
8524 .sn_size = pdcp_test_data_sn_size[i],
8525 .hfn = pdcp_test_hfn[i],
8526 .hfn_threshold = pdcp_test_hfn_threshold[i],
8529 .crypto_xform = &ut_params->cipher_xform
8532 /* Create security session */
8533 ut_params->sec_session = rte_security_session_create(ctx,
8534 &sess_conf, ts_params->session_mpool,
8535 ts_params->session_priv_mpool);
8537 if (!ut_params->sec_session) {
8538 printf("TestCase %s()-%d line %d failed %s: ",
8539 __func__, i, __LINE__, "Failed to allocate session");
8544 /* Generate crypto op data structure */
8545 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8546 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8547 if (!ut_params->op) {
8548 printf("TestCase %s()-%d line %d failed %s: ",
8549 __func__, i, __LINE__,
8550 "Failed to allocate symmetric crypto operation struct");
8555 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8557 /* set crypto operation source mbuf */
8558 ut_params->op->sym->m_src = ut_params->ibuf;
8560 ut_params->op->sym->m_dst = ut_params->obuf;
8562 /* Process crypto operation */
8563 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8565 printf("TestCase %s()-%d line %d failed %s: ",
8566 __func__, i, __LINE__,
8567 "failed to process sym crypto op");
8572 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8573 printf("TestCase %s()-%d line %d failed %s: ",
8574 __func__, i, __LINE__, "crypto op processing failed");
8580 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8583 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8587 fragsz = frag_size_oop;
8588 if (memcmp(ciphertext, output_vec, fragsz)) {
8589 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8590 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8591 rte_hexdump(stdout, "reference", output_vec, fragsz);
8596 buf = ut_params->op->sym->m_src->next;
8598 buf = ut_params->op->sym->m_dst->next;
8600 unsigned int off = fragsz;
8604 ciphertext = rte_pktmbuf_mtod(buf,
8606 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8607 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8608 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8609 rte_hexdump(stdout, "reference", output_vec + off,
8614 off += to_trn_tbl[ecx++];
8618 rte_crypto_op_free(ut_params->op);
8619 ut_params->op = NULL;
8621 if (ut_params->sec_session)
8622 rte_security_session_destroy(ctx, ut_params->sec_session);
8623 ut_params->sec_session = NULL;
8625 rte_pktmbuf_free(ut_params->ibuf);
8626 ut_params->ibuf = NULL;
8628 rte_pktmbuf_free(ut_params->obuf);
8629 ut_params->obuf = NULL;
8636 test_pdcp_proto_cplane_encap(int i)
8638 return test_pdcp_proto(
8639 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8640 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8641 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8642 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8643 pdcp_test_params[i].cipher_key_len,
8644 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8645 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8646 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8647 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8648 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8652 test_pdcp_proto_uplane_encap(int i)
8654 return test_pdcp_proto(
8655 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8656 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8657 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8658 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8659 pdcp_test_params[i].cipher_key_len,
8660 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8661 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8662 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8663 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8664 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8668 test_pdcp_proto_uplane_encap_with_int(int i)
8670 return test_pdcp_proto(
8671 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8672 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8673 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8674 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8675 pdcp_test_params[i].cipher_key_len,
8676 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8677 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8678 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8679 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8680 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8684 test_pdcp_proto_cplane_decap(int i)
8686 return test_pdcp_proto(
8687 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8688 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8689 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8690 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8691 pdcp_test_params[i].cipher_key_len,
8692 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8693 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8694 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8695 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8696 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8700 test_pdcp_proto_uplane_decap(int i)
8702 return test_pdcp_proto(
8703 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8704 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8705 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8706 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8707 pdcp_test_params[i].cipher_key_len,
8708 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8709 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8710 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8711 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8712 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8716 test_pdcp_proto_uplane_decap_with_int(int i)
8718 return test_pdcp_proto(
8719 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8720 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8721 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8722 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8723 pdcp_test_params[i].cipher_key_len,
8724 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8725 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8726 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8727 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8728 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8732 test_PDCP_PROTO_SGL_in_place_32B(void)
8734 /* i can be used for running any PDCP case
8735 * In this case it is uplane 12-bit AES-SNOW DL encap
8737 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8738 return test_pdcp_proto_SGL(i, IN_PLACE,
8739 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8740 RTE_CRYPTO_AUTH_OP_GENERATE,
8741 pdcp_test_data_in[i],
8742 pdcp_test_data_in_len[i],
8743 pdcp_test_data_out[i],
8744 pdcp_test_data_in_len[i]+4,
8748 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8750 /* i can be used for running any PDCP case
8751 * In this case it is uplane 18-bit NULL-NULL DL encap
8753 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8754 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8755 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8756 RTE_CRYPTO_AUTH_OP_GENERATE,
8757 pdcp_test_data_in[i],
8758 pdcp_test_data_in_len[i],
8759 pdcp_test_data_out[i],
8760 pdcp_test_data_in_len[i]+4,
8764 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8766 /* i can be used for running any PDCP case
8767 * In this case it is uplane 18-bit AES DL encap
8769 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8771 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8772 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8773 RTE_CRYPTO_AUTH_OP_GENERATE,
8774 pdcp_test_data_in[i],
8775 pdcp_test_data_in_len[i],
8776 pdcp_test_data_out[i],
8777 pdcp_test_data_in_len[i],
8781 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8783 /* i can be used for running any PDCP case
8784 * In this case it is cplane 12-bit AES-ZUC DL encap
8786 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8787 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8788 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8789 RTE_CRYPTO_AUTH_OP_GENERATE,
8790 pdcp_test_data_in[i],
8791 pdcp_test_data_in_len[i],
8792 pdcp_test_data_out[i],
8793 pdcp_test_data_in_len[i]+4,
8798 test_PDCP_SDAP_PROTO_encap_all(void)
8800 int i = 0, size = 0;
8801 int err, all_err = TEST_SUCCESS;
8802 const struct pdcp_sdap_test *cur_test;
8804 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8806 for (i = 0; i < size; i++) {
8807 cur_test = &list_pdcp_sdap_tests[i];
8808 err = test_pdcp_proto(
8809 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8810 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8811 cur_test->in_len, cur_test->data_out,
8812 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8813 cur_test->param.cipher_alg, cur_test->cipher_key,
8814 cur_test->param.cipher_key_len,
8815 cur_test->param.auth_alg,
8816 cur_test->auth_key, cur_test->param.auth_key_len,
8817 cur_test->bearer, cur_test->param.domain,
8818 cur_test->packet_direction, cur_test->sn_size,
8820 cur_test->hfn_threshold, SDAP_ENABLED);
8822 printf("\t%d) %s: Encapsulation failed\n",
8824 cur_test->param.name);
8827 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8828 cur_test->param.name);
8834 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8836 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8840 test_PDCP_SDAP_PROTO_decap_all(void)
8842 int i = 0, size = 0;
8843 int err, all_err = TEST_SUCCESS;
8844 const struct pdcp_sdap_test *cur_test;
8846 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8848 for (i = 0; i < size; i++) {
8849 cur_test = &list_pdcp_sdap_tests[i];
8850 err = test_pdcp_proto(
8851 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8852 RTE_CRYPTO_AUTH_OP_VERIFY,
8854 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8855 cur_test->data_in, cur_test->in_len,
8856 cur_test->param.cipher_alg,
8857 cur_test->cipher_key, cur_test->param.cipher_key_len,
8858 cur_test->param.auth_alg, cur_test->auth_key,
8859 cur_test->param.auth_key_len, cur_test->bearer,
8860 cur_test->param.domain, cur_test->packet_direction,
8861 cur_test->sn_size, cur_test->hfn,
8862 cur_test->hfn_threshold, SDAP_ENABLED);
8864 printf("\t%d) %s: Decapsulation failed\n",
8866 cur_test->param.name);
8869 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8870 cur_test->param.name);
8876 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8878 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8882 test_PDCP_PROTO_all(void)
8884 struct crypto_testsuite_params *ts_params = &testsuite_params;
8885 struct crypto_unittest_params *ut_params = &unittest_params;
8886 struct rte_cryptodev_info dev_info;
8889 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8890 uint64_t feat_flags = dev_info.feature_flags;
8892 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8893 return TEST_SKIPPED;
8895 /* Set action type */
8896 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8897 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8900 if (security_proto_supported(ut_params->type,
8901 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8902 return TEST_SKIPPED;
8904 status = test_PDCP_PROTO_cplane_encap_all();
8905 status += test_PDCP_PROTO_cplane_decap_all();
8906 status += test_PDCP_PROTO_uplane_encap_all();
8907 status += test_PDCP_PROTO_uplane_decap_all();
8908 status += test_PDCP_PROTO_SGL_in_place_32B();
8909 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8910 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8911 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8912 status += test_PDCP_SDAP_PROTO_encap_all();
8913 status += test_PDCP_SDAP_PROTO_decap_all();
8918 return TEST_SUCCESS;
8922 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8924 struct crypto_testsuite_params *ts_params = &testsuite_params;
8925 struct crypto_unittest_params *ut_params = &unittest_params;
8926 uint8_t *plaintext, *ciphertext;
8928 int32_t cipher_len, crc_len;
8929 uint32_t crc_data_len;
8930 int ret = TEST_SUCCESS;
8932 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8933 rte_cryptodev_get_sec_ctx(
8934 ts_params->valid_devs[0]);
8936 /* Verify the capabilities */
8937 struct rte_security_capability_idx sec_cap_idx;
8938 const struct rte_security_capability *sec_cap;
8939 const struct rte_cryptodev_capabilities *crypto_cap;
8940 const struct rte_cryptodev_symmetric_capability *sym_cap;
8943 sec_cap_idx.action = ut_params->type;
8944 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8945 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8947 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8948 if (sec_cap == NULL)
8949 return TEST_SKIPPED;
8951 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8952 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8953 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8954 crypto_cap->sym.xform_type ==
8955 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8956 crypto_cap->sym.cipher.algo ==
8957 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8958 sym_cap = &crypto_cap->sym;
8959 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8966 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8967 return TEST_SKIPPED;
8969 /* Setup source mbuf payload */
8970 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8971 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8972 rte_pktmbuf_tailroom(ut_params->ibuf));
8974 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8975 d_td->ciphertext.len);
8977 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8979 /* Setup cipher session parameters */
8980 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8981 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8982 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8983 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8984 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8985 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8986 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8987 ut_params->cipher_xform.next = NULL;
8989 /* Setup DOCSIS session parameters */
8990 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8992 struct rte_security_session_conf sess_conf = {
8993 .action_type = ut_params->type,
8994 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8995 .docsis = ut_params->docsis_xform,
8996 .crypto_xform = &ut_params->cipher_xform,
8999 /* Create security session */
9000 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9001 ts_params->session_mpool,
9002 ts_params->session_priv_mpool);
9004 if (!ut_params->sec_session) {
9005 printf("TestCase %s(%d) line %d: %s\n",
9006 __func__, i, __LINE__, "failed to allocate session");
9011 /* Generate crypto op data structure */
9012 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9013 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9014 if (!ut_params->op) {
9015 printf("TestCase %s(%d) line %d: %s\n",
9016 __func__, i, __LINE__,
9017 "failed to allocate symmetric crypto operation");
9022 /* Setup CRC operation parameters */
9023 crc_len = d_td->ciphertext.no_crc == false ?
9024 (d_td->ciphertext.len -
9025 d_td->ciphertext.crc_offset -
9026 RTE_ETHER_CRC_LEN) :
9028 crc_len = crc_len > 0 ? crc_len : 0;
9029 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9030 ut_params->op->sym->auth.data.length = crc_len;
9031 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9033 /* Setup cipher operation parameters */
9034 cipher_len = d_td->ciphertext.no_cipher == false ?
9035 (d_td->ciphertext.len -
9036 d_td->ciphertext.cipher_offset) :
9038 cipher_len = cipher_len > 0 ? cipher_len : 0;
9039 ut_params->op->sym->cipher.data.length = cipher_len;
9040 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9042 /* Setup cipher IV */
9043 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9044 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9046 /* Attach session to operation */
9047 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9049 /* Set crypto operation mbufs */
9050 ut_params->op->sym->m_src = ut_params->ibuf;
9051 ut_params->op->sym->m_dst = NULL;
9053 /* Process crypto operation */
9054 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9056 printf("TestCase %s(%d) line %d: %s\n",
9057 __func__, i, __LINE__,
9058 "failed to process security crypto op");
9063 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9064 printf("TestCase %s(%d) line %d: %s\n",
9065 __func__, i, __LINE__, "crypto op processing failed");
9070 /* Validate plaintext */
9071 plaintext = ciphertext;
9073 if (memcmp(plaintext, d_td->plaintext.data,
9074 d_td->plaintext.len - crc_data_len)) {
9075 printf("TestCase %s(%d) line %d: %s\n",
9076 __func__, i, __LINE__, "plaintext not as expected\n");
9077 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9078 d_td->plaintext.len);
9079 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9085 rte_crypto_op_free(ut_params->op);
9086 ut_params->op = NULL;
9088 if (ut_params->sec_session)
9089 rte_security_session_destroy(ctx, ut_params->sec_session);
9090 ut_params->sec_session = NULL;
9092 rte_pktmbuf_free(ut_params->ibuf);
9093 ut_params->ibuf = NULL;
9099 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9101 struct crypto_testsuite_params *ts_params = &testsuite_params;
9102 struct crypto_unittest_params *ut_params = &unittest_params;
9103 uint8_t *plaintext, *ciphertext;
9105 int32_t cipher_len, crc_len;
9106 int ret = TEST_SUCCESS;
9108 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9109 rte_cryptodev_get_sec_ctx(
9110 ts_params->valid_devs[0]);
9112 /* Verify the capabilities */
9113 struct rte_security_capability_idx sec_cap_idx;
9114 const struct rte_security_capability *sec_cap;
9115 const struct rte_cryptodev_capabilities *crypto_cap;
9116 const struct rte_cryptodev_symmetric_capability *sym_cap;
9119 sec_cap_idx.action = ut_params->type;
9120 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9121 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9123 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9124 if (sec_cap == NULL)
9125 return TEST_SKIPPED;
9127 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9128 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9129 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9130 crypto_cap->sym.xform_type ==
9131 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9132 crypto_cap->sym.cipher.algo ==
9133 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9134 sym_cap = &crypto_cap->sym;
9135 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9142 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9143 return TEST_SKIPPED;
9145 /* Setup source mbuf payload */
9146 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9147 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9148 rte_pktmbuf_tailroom(ut_params->ibuf));
9150 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9151 d_td->plaintext.len);
9153 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9155 /* Setup cipher session parameters */
9156 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9157 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9158 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9159 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9160 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9161 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9162 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9163 ut_params->cipher_xform.next = NULL;
9165 /* Setup DOCSIS session parameters */
9166 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9168 struct rte_security_session_conf sess_conf = {
9169 .action_type = ut_params->type,
9170 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9171 .docsis = ut_params->docsis_xform,
9172 .crypto_xform = &ut_params->cipher_xform,
9175 /* Create security session */
9176 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9177 ts_params->session_mpool,
9178 ts_params->session_priv_mpool);
9180 if (!ut_params->sec_session) {
9181 printf("TestCase %s(%d) line %d: %s\n",
9182 __func__, i, __LINE__, "failed to allocate session");
9187 /* Generate crypto op data structure */
9188 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9189 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9190 if (!ut_params->op) {
9191 printf("TestCase %s(%d) line %d: %s\n",
9192 __func__, i, __LINE__,
9193 "failed to allocate security crypto operation");
9198 /* Setup CRC operation parameters */
9199 crc_len = d_td->plaintext.no_crc == false ?
9200 (d_td->plaintext.len -
9201 d_td->plaintext.crc_offset -
9202 RTE_ETHER_CRC_LEN) :
9204 crc_len = crc_len > 0 ? crc_len : 0;
9205 ut_params->op->sym->auth.data.length = crc_len;
9206 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9208 /* Setup cipher operation parameters */
9209 cipher_len = d_td->plaintext.no_cipher == false ?
9210 (d_td->plaintext.len -
9211 d_td->plaintext.cipher_offset) :
9213 cipher_len = cipher_len > 0 ? cipher_len : 0;
9214 ut_params->op->sym->cipher.data.length = cipher_len;
9215 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9217 /* Setup cipher IV */
9218 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9219 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9221 /* Attach session to operation */
9222 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9224 /* Set crypto operation mbufs */
9225 ut_params->op->sym->m_src = ut_params->ibuf;
9226 ut_params->op->sym->m_dst = NULL;
9228 /* Process crypto operation */
9229 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9231 printf("TestCase %s(%d) line %d: %s\n",
9232 __func__, i, __LINE__,
9233 "failed to process security crypto op");
9238 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9239 printf("TestCase %s(%d) line %d: %s\n",
9240 __func__, i, __LINE__, "crypto op processing failed");
9245 /* Validate ciphertext */
9246 ciphertext = plaintext;
9248 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9249 printf("TestCase %s(%d) line %d: %s\n",
9250 __func__, i, __LINE__, "ciphertext not as expected\n");
9251 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9252 d_td->ciphertext.len);
9253 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9259 rte_crypto_op_free(ut_params->op);
9260 ut_params->op = NULL;
9262 if (ut_params->sec_session)
9263 rte_security_session_destroy(ctx, ut_params->sec_session);
9264 ut_params->sec_session = NULL;
9266 rte_pktmbuf_free(ut_params->ibuf);
9267 ut_params->ibuf = NULL;
9272 #define TEST_DOCSIS_COUNT(func) do { \
9274 if (ret == TEST_SUCCESS) { \
9275 printf("\t%2d)", n++); \
9276 printf("+++++ PASSED:" #func"\n"); \
9278 } else if (ret == TEST_SKIPPED) { \
9279 printf("\t%2d)", n++); \
9280 printf("~~~~~ SKIPPED:" #func"\n"); \
9283 printf("\t%2d)", n++); \
9284 printf("----- FAILED:" #func"\n"); \
9290 test_DOCSIS_PROTO_uplink_all(void)
9292 int p = 0, s = 0, f = 0, n = 0;
9294 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9295 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9296 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9297 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9298 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9299 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9300 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9301 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9302 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9303 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9304 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9305 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9306 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9307 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9308 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9309 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9310 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9311 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9312 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9313 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9314 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9315 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9316 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9317 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9318 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9319 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9322 printf("## %s: %d passed out of %d (%d skipped)\n",
9329 test_DOCSIS_PROTO_downlink_all(void)
9331 int p = 0, s = 0, f = 0, n = 0;
9333 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9334 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9335 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9336 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9337 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9338 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9339 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9340 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9341 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9342 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9343 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9344 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9345 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9346 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9347 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9348 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9349 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9350 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9351 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9352 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9353 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9354 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9355 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9356 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9357 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9358 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9361 printf("## %s: %d passed out of %d (%d skipped)\n",
9368 test_DOCSIS_PROTO_all(void)
9370 struct crypto_testsuite_params *ts_params = &testsuite_params;
9371 struct crypto_unittest_params *ut_params = &unittest_params;
9372 struct rte_cryptodev_info dev_info;
9375 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9376 uint64_t feat_flags = dev_info.feature_flags;
9378 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9379 return TEST_SKIPPED;
9381 /* Set action type */
9382 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9383 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9386 if (security_proto_supported(ut_params->type,
9387 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9388 return TEST_SKIPPED;
9390 status = test_DOCSIS_PROTO_uplink_all();
9391 status += test_DOCSIS_PROTO_downlink_all();
9396 return TEST_SUCCESS;
9401 test_AES_GCM_authenticated_encryption_test_case_1(void)
9403 return test_authenticated_encryption(&gcm_test_case_1);
9407 test_AES_GCM_authenticated_encryption_test_case_2(void)
9409 return test_authenticated_encryption(&gcm_test_case_2);
9413 test_AES_GCM_authenticated_encryption_test_case_3(void)
9415 return test_authenticated_encryption(&gcm_test_case_3);
9419 test_AES_GCM_authenticated_encryption_test_case_4(void)
9421 return test_authenticated_encryption(&gcm_test_case_4);
9425 test_AES_GCM_authenticated_encryption_test_case_5(void)
9427 return test_authenticated_encryption(&gcm_test_case_5);
9431 test_AES_GCM_authenticated_encryption_test_case_6(void)
9433 return test_authenticated_encryption(&gcm_test_case_6);
9437 test_AES_GCM_authenticated_encryption_test_case_7(void)
9439 return test_authenticated_encryption(&gcm_test_case_7);
9443 test_AES_GCM_authenticated_encryption_test_case_8(void)
9445 return test_authenticated_encryption(&gcm_test_case_8);
9449 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9451 return test_authenticated_encryption(&gcm_J0_test_case_1);
9455 test_AES_GCM_auth_encryption_test_case_192_1(void)
9457 return test_authenticated_encryption(&gcm_test_case_192_1);
9461 test_AES_GCM_auth_encryption_test_case_192_2(void)
9463 return test_authenticated_encryption(&gcm_test_case_192_2);
9467 test_AES_GCM_auth_encryption_test_case_192_3(void)
9469 return test_authenticated_encryption(&gcm_test_case_192_3);
9473 test_AES_GCM_auth_encryption_test_case_192_4(void)
9475 return test_authenticated_encryption(&gcm_test_case_192_4);
9479 test_AES_GCM_auth_encryption_test_case_192_5(void)
9481 return test_authenticated_encryption(&gcm_test_case_192_5);
9485 test_AES_GCM_auth_encryption_test_case_192_6(void)
9487 return test_authenticated_encryption(&gcm_test_case_192_6);
9491 test_AES_GCM_auth_encryption_test_case_192_7(void)
9493 return test_authenticated_encryption(&gcm_test_case_192_7);
9497 test_AES_GCM_auth_encryption_test_case_256_1(void)
9499 return test_authenticated_encryption(&gcm_test_case_256_1);
9503 test_AES_GCM_auth_encryption_test_case_256_2(void)
9505 return test_authenticated_encryption(&gcm_test_case_256_2);
9509 test_AES_GCM_auth_encryption_test_case_256_3(void)
9511 return test_authenticated_encryption(&gcm_test_case_256_3);
9515 test_AES_GCM_auth_encryption_test_case_256_4(void)
9517 return test_authenticated_encryption(&gcm_test_case_256_4);
9521 test_AES_GCM_auth_encryption_test_case_256_5(void)
9523 return test_authenticated_encryption(&gcm_test_case_256_5);
9527 test_AES_GCM_auth_encryption_test_case_256_6(void)
9529 return test_authenticated_encryption(&gcm_test_case_256_6);
9533 test_AES_GCM_auth_encryption_test_case_256_7(void)
9535 return test_authenticated_encryption(&gcm_test_case_256_7);
9539 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9541 return test_authenticated_encryption(&gcm_test_case_aad_1);
9545 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9547 return test_authenticated_encryption(&gcm_test_case_aad_2);
9551 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9553 struct aead_test_data tdata;
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 tdata.iv.data[0] += 1;
9559 res = test_authenticated_encryption(&tdata);
9560 if (res == TEST_SKIPPED)
9562 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9563 return TEST_SUCCESS;
9567 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9569 struct aead_test_data tdata;
9572 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9573 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9574 tdata.plaintext.data[0] += 1;
9575 res = test_authenticated_encryption(&tdata);
9576 if (res == TEST_SKIPPED)
9578 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9579 return TEST_SUCCESS;
9583 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9585 struct aead_test_data tdata;
9588 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9589 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9590 tdata.ciphertext.data[0] += 1;
9591 res = test_authenticated_encryption(&tdata);
9592 if (res == TEST_SKIPPED)
9594 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9595 return TEST_SUCCESS;
9599 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9601 struct aead_test_data tdata;
9604 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9605 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9607 res = test_authenticated_encryption(&tdata);
9608 if (res == TEST_SKIPPED)
9610 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9611 return TEST_SUCCESS;
9615 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9617 struct aead_test_data tdata;
9618 uint8_t aad[gcm_test_case_7.aad.len];
9621 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9622 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9623 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9625 tdata.aad.data = aad;
9626 res = test_authenticated_encryption(&tdata);
9627 if (res == TEST_SKIPPED)
9629 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9630 return TEST_SUCCESS;
9634 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9636 struct aead_test_data tdata;
9639 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9640 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9641 tdata.auth_tag.data[0] += 1;
9642 res = test_authenticated_encryption(&tdata);
9643 if (res == TEST_SKIPPED)
9645 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9646 return TEST_SUCCESS;
9650 test_authenticated_decryption(const struct aead_test_data *tdata)
9652 struct crypto_testsuite_params *ts_params = &testsuite_params;
9653 struct crypto_unittest_params *ut_params = &unittest_params;
9658 struct rte_cryptodev_info dev_info;
9660 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9661 uint64_t feat_flags = dev_info.feature_flags;
9663 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9664 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9665 printf("Device doesn't support RAW data-path APIs.\n");
9666 return TEST_SKIPPED;
9669 /* Verify the capabilities */
9670 struct rte_cryptodev_sym_capability_idx cap_idx;
9671 const struct rte_cryptodev_symmetric_capability *capability;
9672 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9673 cap_idx.algo.aead = tdata->algo;
9674 capability = rte_cryptodev_sym_capability_get(
9675 ts_params->valid_devs[0], &cap_idx);
9676 if (capability == NULL)
9677 return TEST_SKIPPED;
9678 if (rte_cryptodev_sym_capability_check_aead(
9679 capability, tdata->key.len, tdata->auth_tag.len,
9680 tdata->aad.len, tdata->iv.len))
9681 return TEST_SKIPPED;
9683 /* Create AEAD session */
9684 retval = create_aead_session(ts_params->valid_devs[0],
9686 RTE_CRYPTO_AEAD_OP_DECRYPT,
9687 tdata->key.data, tdata->key.len,
9688 tdata->aad.len, tdata->auth_tag.len,
9693 /* alloc mbuf and set payload */
9694 if (tdata->aad.len > MBUF_SIZE) {
9695 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9696 /* Populate full size of add data */
9697 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9698 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9700 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9702 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9703 rte_pktmbuf_tailroom(ut_params->ibuf));
9705 /* Create AEAD operation */
9706 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9710 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9712 ut_params->op->sym->m_src = ut_params->ibuf;
9714 /* Process crypto operation */
9715 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9716 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9717 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9718 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9719 ut_params->op, 0, 0, 0, 0);
9721 TEST_ASSERT_NOT_NULL(
9722 process_crypto_request(ts_params->valid_devs[0],
9723 ut_params->op), "failed to process sym crypto op");
9725 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9726 "crypto op processing failed");
9728 if (ut_params->op->sym->m_dst)
9729 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9732 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9734 ut_params->op->sym->cipher.data.offset);
9736 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9739 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9741 tdata->plaintext.data,
9742 tdata->plaintext.len,
9743 "Plaintext data not as expected");
9745 TEST_ASSERT_EQUAL(ut_params->op->status,
9746 RTE_CRYPTO_OP_STATUS_SUCCESS,
9747 "Authentication failed");
9753 test_AES_GCM_authenticated_decryption_test_case_1(void)
9755 return test_authenticated_decryption(&gcm_test_case_1);
9759 test_AES_GCM_authenticated_decryption_test_case_2(void)
9761 return test_authenticated_decryption(&gcm_test_case_2);
9765 test_AES_GCM_authenticated_decryption_test_case_3(void)
9767 return test_authenticated_decryption(&gcm_test_case_3);
9771 test_AES_GCM_authenticated_decryption_test_case_4(void)
9773 return test_authenticated_decryption(&gcm_test_case_4);
9777 test_AES_GCM_authenticated_decryption_test_case_5(void)
9779 return test_authenticated_decryption(&gcm_test_case_5);
9783 test_AES_GCM_authenticated_decryption_test_case_6(void)
9785 return test_authenticated_decryption(&gcm_test_case_6);
9789 test_AES_GCM_authenticated_decryption_test_case_7(void)
9791 return test_authenticated_decryption(&gcm_test_case_7);
9795 test_AES_GCM_authenticated_decryption_test_case_8(void)
9797 return test_authenticated_decryption(&gcm_test_case_8);
9801 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9803 return test_authenticated_decryption(&gcm_J0_test_case_1);
9807 test_AES_GCM_auth_decryption_test_case_192_1(void)
9809 return test_authenticated_decryption(&gcm_test_case_192_1);
9813 test_AES_GCM_auth_decryption_test_case_192_2(void)
9815 return test_authenticated_decryption(&gcm_test_case_192_2);
9819 test_AES_GCM_auth_decryption_test_case_192_3(void)
9821 return test_authenticated_decryption(&gcm_test_case_192_3);
9825 test_AES_GCM_auth_decryption_test_case_192_4(void)
9827 return test_authenticated_decryption(&gcm_test_case_192_4);
9831 test_AES_GCM_auth_decryption_test_case_192_5(void)
9833 return test_authenticated_decryption(&gcm_test_case_192_5);
9837 test_AES_GCM_auth_decryption_test_case_192_6(void)
9839 return test_authenticated_decryption(&gcm_test_case_192_6);
9843 test_AES_GCM_auth_decryption_test_case_192_7(void)
9845 return test_authenticated_decryption(&gcm_test_case_192_7);
9849 test_AES_GCM_auth_decryption_test_case_256_1(void)
9851 return test_authenticated_decryption(&gcm_test_case_256_1);
9855 test_AES_GCM_auth_decryption_test_case_256_2(void)
9857 return test_authenticated_decryption(&gcm_test_case_256_2);
9861 test_AES_GCM_auth_decryption_test_case_256_3(void)
9863 return test_authenticated_decryption(&gcm_test_case_256_3);
9867 test_AES_GCM_auth_decryption_test_case_256_4(void)
9869 return test_authenticated_decryption(&gcm_test_case_256_4);
9873 test_AES_GCM_auth_decryption_test_case_256_5(void)
9875 return test_authenticated_decryption(&gcm_test_case_256_5);
9879 test_AES_GCM_auth_decryption_test_case_256_6(void)
9881 return test_authenticated_decryption(&gcm_test_case_256_6);
9885 test_AES_GCM_auth_decryption_test_case_256_7(void)
9887 return test_authenticated_decryption(&gcm_test_case_256_7);
9891 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9893 return test_authenticated_decryption(&gcm_test_case_aad_1);
9897 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9899 return test_authenticated_decryption(&gcm_test_case_aad_2);
9903 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9905 struct aead_test_data tdata;
9908 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9909 tdata.iv.data[0] += 1;
9910 res = test_authenticated_decryption(&tdata);
9911 if (res == TEST_SKIPPED)
9913 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9914 return TEST_SUCCESS;
9918 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9920 struct aead_test_data tdata;
9923 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9924 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9925 tdata.plaintext.data[0] += 1;
9926 res = test_authenticated_decryption(&tdata);
9927 if (res == TEST_SKIPPED)
9929 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9930 return TEST_SUCCESS;
9934 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9936 struct aead_test_data tdata;
9939 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9940 tdata.ciphertext.data[0] += 1;
9941 res = test_authenticated_decryption(&tdata);
9942 if (res == TEST_SKIPPED)
9944 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9945 return TEST_SUCCESS;
9949 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9951 struct aead_test_data tdata;
9954 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9956 res = test_authenticated_decryption(&tdata);
9957 if (res == TEST_SKIPPED)
9959 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9960 return TEST_SUCCESS;
9964 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9966 struct aead_test_data tdata;
9967 uint8_t aad[gcm_test_case_7.aad.len];
9970 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9971 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9973 tdata.aad.data = aad;
9974 res = test_authenticated_decryption(&tdata);
9975 if (res == TEST_SKIPPED)
9977 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9978 return TEST_SUCCESS;
9982 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9984 struct aead_test_data tdata;
9987 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9988 tdata.auth_tag.data[0] += 1;
9989 res = test_authenticated_decryption(&tdata);
9990 if (res == TEST_SKIPPED)
9992 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9993 return TEST_SUCCESS;
9997 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9999 struct crypto_testsuite_params *ts_params = &testsuite_params;
10000 struct crypto_unittest_params *ut_params = &unittest_params;
10003 uint8_t *ciphertext, *auth_tag;
10004 uint16_t plaintext_pad_len;
10006 /* Verify the capabilities */
10007 struct rte_cryptodev_sym_capability_idx cap_idx;
10008 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10009 cap_idx.algo.aead = tdata->algo;
10010 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10012 return TEST_SKIPPED;
10014 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10015 return TEST_SKIPPED;
10017 /* not supported with CPU crypto */
10018 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10019 return TEST_SKIPPED;
10021 /* Create AEAD session */
10022 retval = create_aead_session(ts_params->valid_devs[0],
10024 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10025 tdata->key.data, tdata->key.len,
10026 tdata->aad.len, tdata->auth_tag.len,
10031 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10032 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10034 /* clear mbuf payload */
10035 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10036 rte_pktmbuf_tailroom(ut_params->ibuf));
10037 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10038 rte_pktmbuf_tailroom(ut_params->obuf));
10040 /* Create AEAD operation */
10041 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10045 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10047 ut_params->op->sym->m_src = ut_params->ibuf;
10048 ut_params->op->sym->m_dst = ut_params->obuf;
10050 /* Process crypto operation */
10051 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10052 ut_params->op), "failed to process sym crypto op");
10054 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10055 "crypto op processing failed");
10057 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10059 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10060 ut_params->op->sym->cipher.data.offset);
10061 auth_tag = ciphertext + plaintext_pad_len;
10063 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10064 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10066 /* Validate obuf */
10067 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10069 tdata->ciphertext.data,
10070 tdata->ciphertext.len,
10071 "Ciphertext data not as expected");
10073 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10075 tdata->auth_tag.data,
10076 tdata->auth_tag.len,
10077 "Generated auth tag not as expected");
10084 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10086 return test_authenticated_encryption_oop(&gcm_test_case_5);
10090 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10092 struct crypto_testsuite_params *ts_params = &testsuite_params;
10093 struct crypto_unittest_params *ut_params = &unittest_params;
10096 uint8_t *plaintext;
10098 /* Verify the capabilities */
10099 struct rte_cryptodev_sym_capability_idx cap_idx;
10100 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10101 cap_idx.algo.aead = tdata->algo;
10102 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10104 return TEST_SKIPPED;
10106 /* not supported with CPU crypto and raw data-path APIs*/
10107 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10108 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10109 return TEST_SKIPPED;
10111 /* Create AEAD session */
10112 retval = create_aead_session(ts_params->valid_devs[0],
10114 RTE_CRYPTO_AEAD_OP_DECRYPT,
10115 tdata->key.data, tdata->key.len,
10116 tdata->aad.len, tdata->auth_tag.len,
10121 /* alloc mbuf and set payload */
10122 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10123 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10125 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10126 rte_pktmbuf_tailroom(ut_params->ibuf));
10127 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10128 rte_pktmbuf_tailroom(ut_params->obuf));
10130 /* Create AEAD operation */
10131 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10135 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10137 ut_params->op->sym->m_src = ut_params->ibuf;
10138 ut_params->op->sym->m_dst = ut_params->obuf;
10140 /* Process crypto operation */
10141 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10142 ut_params->op), "failed to process sym crypto op");
10144 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10145 "crypto op processing failed");
10147 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10148 ut_params->op->sym->cipher.data.offset);
10150 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10152 /* Validate obuf */
10153 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10155 tdata->plaintext.data,
10156 tdata->plaintext.len,
10157 "Plaintext data not as expected");
10159 TEST_ASSERT_EQUAL(ut_params->op->status,
10160 RTE_CRYPTO_OP_STATUS_SUCCESS,
10161 "Authentication failed");
10166 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10168 return test_authenticated_decryption_oop(&gcm_test_case_5);
10172 test_authenticated_encryption_sessionless(
10173 const struct aead_test_data *tdata)
10175 struct crypto_testsuite_params *ts_params = &testsuite_params;
10176 struct crypto_unittest_params *ut_params = &unittest_params;
10179 uint8_t *ciphertext, *auth_tag;
10180 uint16_t plaintext_pad_len;
10181 uint8_t key[tdata->key.len + 1];
10182 struct rte_cryptodev_info dev_info;
10184 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10185 uint64_t feat_flags = dev_info.feature_flags;
10187 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10188 printf("Device doesn't support Sessionless ops.\n");
10189 return TEST_SKIPPED;
10192 /* not supported with CPU crypto */
10193 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10194 return TEST_SKIPPED;
10196 /* Verify the capabilities */
10197 struct rte_cryptodev_sym_capability_idx cap_idx;
10198 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10199 cap_idx.algo.aead = tdata->algo;
10200 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10202 return TEST_SKIPPED;
10204 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10206 /* clear mbuf payload */
10207 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10208 rte_pktmbuf_tailroom(ut_params->ibuf));
10210 /* Create AEAD operation */
10211 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10215 /* Create GCM xform */
10216 memcpy(key, tdata->key.data, tdata->key.len);
10217 retval = create_aead_xform(ut_params->op,
10219 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10220 key, tdata->key.len,
10221 tdata->aad.len, tdata->auth_tag.len,
10226 ut_params->op->sym->m_src = ut_params->ibuf;
10228 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10229 RTE_CRYPTO_OP_SESSIONLESS,
10230 "crypto op session type not sessionless");
10232 /* Process crypto operation */
10233 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10234 ut_params->op), "failed to process sym crypto op");
10236 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10238 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10239 "crypto op status not success");
10241 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10243 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10244 ut_params->op->sym->cipher.data.offset);
10245 auth_tag = ciphertext + plaintext_pad_len;
10247 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10248 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10250 /* Validate obuf */
10251 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10253 tdata->ciphertext.data,
10254 tdata->ciphertext.len,
10255 "Ciphertext data not as expected");
10257 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10259 tdata->auth_tag.data,
10260 tdata->auth_tag.len,
10261 "Generated auth tag not as expected");
10268 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10270 return test_authenticated_encryption_sessionless(
10275 test_authenticated_decryption_sessionless(
10276 const struct aead_test_data *tdata)
10278 struct crypto_testsuite_params *ts_params = &testsuite_params;
10279 struct crypto_unittest_params *ut_params = &unittest_params;
10282 uint8_t *plaintext;
10283 uint8_t key[tdata->key.len + 1];
10284 struct rte_cryptodev_info dev_info;
10286 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10287 uint64_t feat_flags = dev_info.feature_flags;
10289 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10290 printf("Device doesn't support Sessionless ops.\n");
10291 return TEST_SKIPPED;
10294 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10295 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10296 printf("Device doesn't support RAW data-path APIs.\n");
10297 return TEST_SKIPPED;
10300 /* not supported with CPU crypto */
10301 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10302 return TEST_SKIPPED;
10304 /* Verify the capabilities */
10305 struct rte_cryptodev_sym_capability_idx cap_idx;
10306 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10307 cap_idx.algo.aead = tdata->algo;
10308 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10310 return TEST_SKIPPED;
10312 /* alloc mbuf and set payload */
10313 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10315 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10316 rte_pktmbuf_tailroom(ut_params->ibuf));
10318 /* Create AEAD operation */
10319 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10323 /* Create AEAD xform */
10324 memcpy(key, tdata->key.data, tdata->key.len);
10325 retval = create_aead_xform(ut_params->op,
10327 RTE_CRYPTO_AEAD_OP_DECRYPT,
10328 key, tdata->key.len,
10329 tdata->aad.len, tdata->auth_tag.len,
10334 ut_params->op->sym->m_src = ut_params->ibuf;
10336 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10337 RTE_CRYPTO_OP_SESSIONLESS,
10338 "crypto op session type not sessionless");
10340 /* Process crypto operation */
10341 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10342 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10343 ut_params->op, 0, 0, 0, 0);
10345 TEST_ASSERT_NOT_NULL(process_crypto_request(
10346 ts_params->valid_devs[0], ut_params->op),
10347 "failed to process sym crypto op");
10349 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10351 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10352 "crypto op status not success");
10354 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10355 ut_params->op->sym->cipher.data.offset);
10357 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10359 /* Validate obuf */
10360 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10362 tdata->plaintext.data,
10363 tdata->plaintext.len,
10364 "Plaintext data not as expected");
10366 TEST_ASSERT_EQUAL(ut_params->op->status,
10367 RTE_CRYPTO_OP_STATUS_SUCCESS,
10368 "Authentication failed");
10373 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10375 return test_authenticated_decryption_sessionless(
10380 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10382 return test_authenticated_encryption(&ccm_test_case_128_1);
10386 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10388 return test_authenticated_encryption(&ccm_test_case_128_2);
10392 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10394 return test_authenticated_encryption(&ccm_test_case_128_3);
10398 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10400 return test_authenticated_decryption(&ccm_test_case_128_1);
10404 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10406 return test_authenticated_decryption(&ccm_test_case_128_2);
10410 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10412 return test_authenticated_decryption(&ccm_test_case_128_3);
10416 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10418 return test_authenticated_encryption(&ccm_test_case_192_1);
10422 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10424 return test_authenticated_encryption(&ccm_test_case_192_2);
10428 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10430 return test_authenticated_encryption(&ccm_test_case_192_3);
10434 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10436 return test_authenticated_decryption(&ccm_test_case_192_1);
10440 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10442 return test_authenticated_decryption(&ccm_test_case_192_2);
10446 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10448 return test_authenticated_decryption(&ccm_test_case_192_3);
10452 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10454 return test_authenticated_encryption(&ccm_test_case_256_1);
10458 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10460 return test_authenticated_encryption(&ccm_test_case_256_2);
10464 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10466 return test_authenticated_encryption(&ccm_test_case_256_3);
10470 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10472 return test_authenticated_decryption(&ccm_test_case_256_1);
10476 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10478 return test_authenticated_decryption(&ccm_test_case_256_2);
10482 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10484 return test_authenticated_decryption(&ccm_test_case_256_3);
10490 struct crypto_testsuite_params *ts_params = &testsuite_params;
10491 struct rte_cryptodev_stats stats;
10493 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10494 return TEST_SKIPPED;
10496 /* Verify the capabilities */
10497 struct rte_cryptodev_sym_capability_idx cap_idx;
10498 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10499 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10500 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10502 return TEST_SKIPPED;
10503 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10504 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10505 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10507 return TEST_SKIPPED;
10509 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10511 return TEST_SKIPPED;
10513 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10514 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10515 &stats) == -ENODEV),
10516 "rte_cryptodev_stats_get invalid dev failed");
10517 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10518 "rte_cryptodev_stats_get invalid Param failed");
10520 /* Test expected values */
10521 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10522 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10524 "rte_cryptodev_stats_get failed");
10525 TEST_ASSERT((stats.enqueued_count == 1),
10526 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10527 TEST_ASSERT((stats.dequeued_count == 1),
10528 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10529 TEST_ASSERT((stats.enqueue_err_count == 0),
10530 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10531 TEST_ASSERT((stats.dequeue_err_count == 0),
10532 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10534 /* invalid device but should ignore and not reset device stats*/
10535 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10536 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10538 "rte_cryptodev_stats_get failed");
10539 TEST_ASSERT((stats.enqueued_count == 1),
10540 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10542 /* check that a valid reset clears stats */
10543 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10544 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10546 "rte_cryptodev_stats_get failed");
10547 TEST_ASSERT((stats.enqueued_count == 0),
10548 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10549 TEST_ASSERT((stats.dequeued_count == 0),
10550 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10552 return TEST_SUCCESS;
10555 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10556 struct crypto_unittest_params *ut_params,
10557 enum rte_crypto_auth_operation op,
10558 const struct HMAC_MD5_vector *test_case)
10562 memcpy(key, test_case->key.data, test_case->key.len);
10564 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10565 ut_params->auth_xform.next = NULL;
10566 ut_params->auth_xform.auth.op = op;
10568 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10570 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10571 ut_params->auth_xform.auth.key.length = test_case->key.len;
10572 ut_params->auth_xform.auth.key.data = key;
10574 ut_params->sess = rte_cryptodev_sym_session_create(
10575 ts_params->session_mpool);
10577 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10578 ut_params->sess, &ut_params->auth_xform,
10579 ts_params->session_priv_mpool);
10581 if (ut_params->sess == NULL)
10582 return TEST_FAILED;
10584 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10586 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10587 rte_pktmbuf_tailroom(ut_params->ibuf));
10592 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10593 const struct HMAC_MD5_vector *test_case,
10594 uint8_t **plaintext)
10596 uint16_t plaintext_pad_len;
10598 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10600 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10603 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10604 plaintext_pad_len);
10605 memcpy(*plaintext, test_case->plaintext.data,
10606 test_case->plaintext.len);
10608 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10609 ut_params->ibuf, MD5_DIGEST_LEN);
10610 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10611 "no room to append digest");
10612 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10613 ut_params->ibuf, plaintext_pad_len);
10615 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10616 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10617 test_case->auth_tag.len);
10620 sym_op->auth.data.offset = 0;
10621 sym_op->auth.data.length = test_case->plaintext.len;
10623 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10624 ut_params->op->sym->m_src = ut_params->ibuf;
10630 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10632 uint16_t plaintext_pad_len;
10633 uint8_t *plaintext, *auth_tag;
10635 struct crypto_testsuite_params *ts_params = &testsuite_params;
10636 struct crypto_unittest_params *ut_params = &unittest_params;
10637 struct rte_cryptodev_info dev_info;
10639 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10640 uint64_t feat_flags = dev_info.feature_flags;
10642 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10643 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10644 printf("Device doesn't support RAW data-path APIs.\n");
10645 return TEST_SKIPPED;
10648 /* Verify the capabilities */
10649 struct rte_cryptodev_sym_capability_idx cap_idx;
10650 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10651 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10652 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10654 return TEST_SKIPPED;
10656 if (MD5_HMAC_create_session(ts_params, ut_params,
10657 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10658 return TEST_FAILED;
10660 /* Generate Crypto op data structure */
10661 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10662 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10663 TEST_ASSERT_NOT_NULL(ut_params->op,
10664 "Failed to allocate symmetric crypto operation struct");
10666 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10669 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10670 return TEST_FAILED;
10672 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10673 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10675 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10676 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10677 ut_params->op, 0, 1, 0, 0);
10679 TEST_ASSERT_NOT_NULL(
10680 process_crypto_request(ts_params->valid_devs[0],
10682 "failed to process sym crypto op");
10684 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10685 "crypto op processing failed");
10687 if (ut_params->op->sym->m_dst) {
10688 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10689 uint8_t *, plaintext_pad_len);
10691 auth_tag = plaintext + plaintext_pad_len;
10694 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10696 test_case->auth_tag.data,
10697 test_case->auth_tag.len,
10698 "HMAC_MD5 generated tag not as expected");
10700 return TEST_SUCCESS;
10704 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10706 uint8_t *plaintext;
10708 struct crypto_testsuite_params *ts_params = &testsuite_params;
10709 struct crypto_unittest_params *ut_params = &unittest_params;
10710 struct rte_cryptodev_info dev_info;
10712 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10713 uint64_t feat_flags = dev_info.feature_flags;
10715 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10716 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10717 printf("Device doesn't support RAW data-path APIs.\n");
10718 return TEST_SKIPPED;
10721 /* Verify the capabilities */
10722 struct rte_cryptodev_sym_capability_idx cap_idx;
10723 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10724 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10725 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10727 return TEST_SKIPPED;
10729 if (MD5_HMAC_create_session(ts_params, ut_params,
10730 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10731 return TEST_FAILED;
10734 /* Generate Crypto op data structure */
10735 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10736 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10737 TEST_ASSERT_NOT_NULL(ut_params->op,
10738 "Failed to allocate symmetric crypto operation struct");
10740 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10741 return TEST_FAILED;
10743 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10744 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10746 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10747 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10748 ut_params->op, 0, 1, 0, 0);
10750 TEST_ASSERT_NOT_NULL(
10751 process_crypto_request(ts_params->valid_devs[0],
10753 "failed to process sym crypto op");
10755 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10756 "HMAC_MD5 crypto op processing failed");
10758 return TEST_SUCCESS;
10762 test_MD5_HMAC_generate_case_1(void)
10764 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10768 test_MD5_HMAC_verify_case_1(void)
10770 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10774 test_MD5_HMAC_generate_case_2(void)
10776 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10780 test_MD5_HMAC_verify_case_2(void)
10782 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10786 test_multi_session(void)
10788 struct crypto_testsuite_params *ts_params = &testsuite_params;
10789 struct crypto_unittest_params *ut_params = &unittest_params;
10791 struct rte_cryptodev_info dev_info;
10792 struct rte_cryptodev_sym_session **sessions;
10796 /* Verify the capabilities */
10797 struct rte_cryptodev_sym_capability_idx cap_idx;
10798 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10799 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10800 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10802 return TEST_SKIPPED;
10803 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10804 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10805 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10807 return TEST_SKIPPED;
10809 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10810 aes_cbc_key, hmac_sha512_key);
10813 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10815 sessions = rte_malloc(NULL,
10816 (sizeof(struct rte_cryptodev_sym_session *) *
10817 MAX_NB_SESSIONS) + 1, 0);
10819 /* Create multiple crypto sessions*/
10820 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10822 sessions[i] = rte_cryptodev_sym_session_create(
10823 ts_params->session_mpool);
10825 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10826 sessions[i], &ut_params->auth_xform,
10827 ts_params->session_priv_mpool);
10828 TEST_ASSERT_NOT_NULL(sessions[i],
10829 "Session creation failed at session number %u",
10832 /* Attempt to send a request on each session */
10833 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10837 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10838 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10840 "Failed to perform decrypt on request number %u.", i);
10841 /* free crypto operation structure */
10843 rte_crypto_op_free(ut_params->op);
10846 * free mbuf - both obuf and ibuf are usually the same,
10847 * so check if they point at the same address is necessary,
10848 * to avoid freeing the mbuf twice.
10850 if (ut_params->obuf) {
10851 rte_pktmbuf_free(ut_params->obuf);
10852 if (ut_params->ibuf == ut_params->obuf)
10853 ut_params->ibuf = 0;
10854 ut_params->obuf = 0;
10856 if (ut_params->ibuf) {
10857 rte_pktmbuf_free(ut_params->ibuf);
10858 ut_params->ibuf = 0;
10862 /* Next session create should fail */
10863 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10864 sessions[i], &ut_params->auth_xform,
10865 ts_params->session_priv_mpool);
10866 TEST_ASSERT_NULL(sessions[i],
10867 "Session creation succeeded unexpectedly!");
10869 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10870 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10872 rte_cryptodev_sym_session_free(sessions[i]);
10875 rte_free(sessions);
10877 return TEST_SUCCESS;
10880 struct multi_session_params {
10881 struct crypto_unittest_params ut_params;
10882 uint8_t *cipher_key;
10884 const uint8_t *cipher;
10885 const uint8_t *digest;
10889 #define MB_SESSION_NUMBER 3
10892 test_multi_session_random_usage(void)
10894 struct crypto_testsuite_params *ts_params = &testsuite_params;
10895 struct rte_cryptodev_info dev_info;
10896 struct rte_cryptodev_sym_session **sessions;
10898 struct multi_session_params ut_paramz[] = {
10901 .cipher_key = ms_aes_cbc_key0,
10902 .hmac_key = ms_hmac_key0,
10903 .cipher = ms_aes_cbc_cipher0,
10904 .digest = ms_hmac_digest0,
10905 .iv = ms_aes_cbc_iv0
10908 .cipher_key = ms_aes_cbc_key1,
10909 .hmac_key = ms_hmac_key1,
10910 .cipher = ms_aes_cbc_cipher1,
10911 .digest = ms_hmac_digest1,
10912 .iv = ms_aes_cbc_iv1
10915 .cipher_key = ms_aes_cbc_key2,
10916 .hmac_key = ms_hmac_key2,
10917 .cipher = ms_aes_cbc_cipher2,
10918 .digest = ms_hmac_digest2,
10919 .iv = ms_aes_cbc_iv2
10924 /* Verify the capabilities */
10925 struct rte_cryptodev_sym_capability_idx cap_idx;
10926 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10927 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10928 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10930 return TEST_SKIPPED;
10931 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10932 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10933 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10935 return TEST_SKIPPED;
10937 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10939 sessions = rte_malloc(NULL,
10940 (sizeof(struct rte_cryptodev_sym_session *)
10941 * MAX_NB_SESSIONS) + 1, 0);
10943 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10944 sessions[i] = rte_cryptodev_sym_session_create(
10945 ts_params->session_mpool);
10947 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10948 sizeof(struct crypto_unittest_params));
10950 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10951 &ut_paramz[i].ut_params,
10952 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10954 /* Create multiple crypto sessions*/
10955 rte_cryptodev_sym_session_init(
10956 ts_params->valid_devs[0],
10958 &ut_paramz[i].ut_params.auth_xform,
10959 ts_params->session_priv_mpool);
10961 TEST_ASSERT_NOT_NULL(sessions[i],
10962 "Session creation failed at session number %u",
10968 for (i = 0; i < 40000; i++) {
10970 j = rand() % MB_SESSION_NUMBER;
10972 TEST_ASSERT_SUCCESS(
10973 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10975 &ut_paramz[j].ut_params,
10976 ts_params, ut_paramz[j].cipher,
10977 ut_paramz[j].digest,
10979 "Failed to perform decrypt on request number %u.", i);
10981 if (ut_paramz[j].ut_params.op)
10982 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10985 * free mbuf - both obuf and ibuf are usually the same,
10986 * so check if they point at the same address is necessary,
10987 * to avoid freeing the mbuf twice.
10989 if (ut_paramz[j].ut_params.obuf) {
10990 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10991 if (ut_paramz[j].ut_params.ibuf
10992 == ut_paramz[j].ut_params.obuf)
10993 ut_paramz[j].ut_params.ibuf = 0;
10994 ut_paramz[j].ut_params.obuf = 0;
10996 if (ut_paramz[j].ut_params.ibuf) {
10997 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10998 ut_paramz[j].ut_params.ibuf = 0;
11002 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11003 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11005 rte_cryptodev_sym_session_free(sessions[i]);
11008 rte_free(sessions);
11010 return TEST_SUCCESS;
11013 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11014 0xab, 0xab, 0xab, 0xab,
11015 0xab, 0xab, 0xab, 0xab,
11016 0xab, 0xab, 0xab, 0xab};
11019 test_null_invalid_operation(void)
11021 struct crypto_testsuite_params *ts_params = &testsuite_params;
11022 struct crypto_unittest_params *ut_params = &unittest_params;
11025 /* This test is for NULL PMD only */
11026 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11027 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11028 return TEST_SKIPPED;
11030 /* Setup Cipher Parameters */
11031 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11032 ut_params->cipher_xform.next = NULL;
11034 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11035 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11037 ut_params->sess = rte_cryptodev_sym_session_create(
11038 ts_params->session_mpool);
11040 /* Create Crypto session*/
11041 ret = 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(ret < 0,
11045 "Session creation succeeded unexpectedly");
11048 /* Setup HMAC Parameters */
11049 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11050 ut_params->auth_xform.next = NULL;
11052 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11053 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11055 ut_params->sess = rte_cryptodev_sym_session_create(
11056 ts_params->session_mpool);
11058 /* Create Crypto session*/
11059 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11060 ut_params->sess, &ut_params->auth_xform,
11061 ts_params->session_priv_mpool);
11062 TEST_ASSERT(ret < 0,
11063 "Session creation succeeded unexpectedly");
11065 return TEST_SUCCESS;
11069 #define NULL_BURST_LENGTH (32)
11072 test_null_burst_operation(void)
11074 struct crypto_testsuite_params *ts_params = &testsuite_params;
11075 struct crypto_unittest_params *ut_params = &unittest_params;
11077 unsigned i, burst_len = NULL_BURST_LENGTH;
11079 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11080 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11082 /* This test is for NULL PMD only */
11083 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11084 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11085 return TEST_SKIPPED;
11087 /* Setup Cipher Parameters */
11088 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11089 ut_params->cipher_xform.next = &ut_params->auth_xform;
11091 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11092 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11094 /* Setup HMAC Parameters */
11095 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11096 ut_params->auth_xform.next = NULL;
11098 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11099 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11101 ut_params->sess = rte_cryptodev_sym_session_create(
11102 ts_params->session_mpool);
11104 /* Create Crypto session*/
11105 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11106 ut_params->sess, &ut_params->cipher_xform,
11107 ts_params->session_priv_mpool);
11108 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11110 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11111 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11112 burst_len, "failed to generate burst of crypto ops");
11114 /* Generate an operation for each mbuf in burst */
11115 for (i = 0; i < burst_len; i++) {
11116 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11118 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11120 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11124 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11126 burst[i]->sym->m_src = m;
11129 /* Process crypto operation */
11130 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11131 0, burst, burst_len),
11133 "Error enqueuing burst");
11135 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11136 0, burst_dequeued, burst_len),
11138 "Error dequeuing burst");
11141 for (i = 0; i < burst_len; i++) {
11143 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11144 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11146 "data not as expected");
11148 rte_pktmbuf_free(burst[i]->sym->m_src);
11149 rte_crypto_op_free(burst[i]);
11152 return TEST_SUCCESS;
11156 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11157 uint16_t nb_ops, void *user_param)
11159 RTE_SET_USED(dev_id);
11160 RTE_SET_USED(qp_id);
11162 RTE_SET_USED(user_param);
11164 printf("crypto enqueue callback called\n");
11169 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11170 uint16_t nb_ops, void *user_param)
11172 RTE_SET_USED(dev_id);
11173 RTE_SET_USED(qp_id);
11175 RTE_SET_USED(user_param);
11177 printf("crypto dequeue callback called\n");
11182 * Thread using enqueue/dequeue callback with RCU.
11185 test_enqdeq_callback_thread(void *arg)
11188 /* DP thread calls rte_cryptodev_enqueue_burst()/
11189 * rte_cryptodev_dequeue_burst() and invokes callback.
11191 test_null_burst_operation();
11196 test_enq_callback_setup(void)
11198 struct crypto_testsuite_params *ts_params = &testsuite_params;
11199 struct rte_cryptodev_info dev_info;
11200 struct rte_cryptodev_qp_conf qp_conf = {
11201 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11204 struct rte_cryptodev_cb *cb;
11205 uint16_t qp_id = 0;
11207 /* Stop the device in case it's started so it can be configured */
11208 rte_cryptodev_stop(ts_params->valid_devs[0]);
11210 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11212 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11214 "Failed to configure cryptodev %u",
11215 ts_params->valid_devs[0]);
11217 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11218 qp_conf.mp_session = ts_params->session_mpool;
11219 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11221 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11222 ts_params->valid_devs[0], qp_id, &qp_conf,
11223 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11225 "rte_cryptodev_queue_pair_setup: num_inflights "
11226 "%u on qp %u on cryptodev %u",
11227 qp_conf.nb_descriptors, qp_id,
11228 ts_params->valid_devs[0]);
11230 /* Test with invalid crypto device */
11231 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11232 qp_id, test_enq_callback, NULL);
11233 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11234 "cryptodev %u did not fail",
11235 qp_id, RTE_CRYPTO_MAX_DEVS);
11237 /* Test with invalid queue pair */
11238 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11239 dev_info.max_nb_queue_pairs + 1,
11240 test_enq_callback, NULL);
11241 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11242 "cryptodev %u did not fail",
11243 dev_info.max_nb_queue_pairs + 1,
11244 ts_params->valid_devs[0]);
11246 /* Test with NULL callback */
11247 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11248 qp_id, NULL, NULL);
11249 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11250 "cryptodev %u did not fail",
11251 qp_id, ts_params->valid_devs[0]);
11253 /* Test with valid configuration */
11254 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11255 qp_id, test_enq_callback, NULL);
11256 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11257 "qp %u on cryptodev %u",
11258 qp_id, ts_params->valid_devs[0]);
11260 rte_cryptodev_start(ts_params->valid_devs[0]);
11262 /* Launch a thread */
11263 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11264 rte_get_next_lcore(-1, 1, 0));
11266 /* Wait until reader exited. */
11267 rte_eal_mp_wait_lcore();
11269 /* Test with invalid crypto device */
11270 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11271 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11272 "Expected call to fail as crypto device is invalid");
11274 /* Test with invalid queue pair */
11275 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11276 ts_params->valid_devs[0],
11277 dev_info.max_nb_queue_pairs + 1, cb),
11278 "Expected call to fail as queue pair is invalid");
11280 /* Test with NULL callback */
11281 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11282 ts_params->valid_devs[0], qp_id, NULL),
11283 "Expected call to fail as callback is NULL");
11285 /* Test with valid configuration */
11286 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11287 ts_params->valid_devs[0], qp_id, cb),
11288 "Failed test to remove callback on "
11289 "qp %u on cryptodev %u",
11290 qp_id, ts_params->valid_devs[0]);
11292 return TEST_SUCCESS;
11296 test_deq_callback_setup(void)
11298 struct crypto_testsuite_params *ts_params = &testsuite_params;
11299 struct rte_cryptodev_info dev_info;
11300 struct rte_cryptodev_qp_conf qp_conf = {
11301 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11304 struct rte_cryptodev_cb *cb;
11305 uint16_t qp_id = 0;
11307 /* Stop the device in case it's started so it can be configured */
11308 rte_cryptodev_stop(ts_params->valid_devs[0]);
11310 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11312 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11314 "Failed to configure cryptodev %u",
11315 ts_params->valid_devs[0]);
11317 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11318 qp_conf.mp_session = ts_params->session_mpool;
11319 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11321 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11322 ts_params->valid_devs[0], qp_id, &qp_conf,
11323 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11325 "rte_cryptodev_queue_pair_setup: num_inflights "
11326 "%u on qp %u on cryptodev %u",
11327 qp_conf.nb_descriptors, qp_id,
11328 ts_params->valid_devs[0]);
11330 /* Test with invalid crypto device */
11331 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11332 qp_id, test_deq_callback, NULL);
11333 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11334 "cryptodev %u did not fail",
11335 qp_id, RTE_CRYPTO_MAX_DEVS);
11337 /* Test with invalid queue pair */
11338 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11339 dev_info.max_nb_queue_pairs + 1,
11340 test_deq_callback, NULL);
11341 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11342 "cryptodev %u did not fail",
11343 dev_info.max_nb_queue_pairs + 1,
11344 ts_params->valid_devs[0]);
11346 /* Test with NULL callback */
11347 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11348 qp_id, NULL, NULL);
11349 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11350 "cryptodev %u did not fail",
11351 qp_id, ts_params->valid_devs[0]);
11353 /* Test with valid configuration */
11354 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11355 qp_id, test_deq_callback, NULL);
11356 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11357 "qp %u on cryptodev %u",
11358 qp_id, ts_params->valid_devs[0]);
11360 rte_cryptodev_start(ts_params->valid_devs[0]);
11362 /* Launch a thread */
11363 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11364 rte_get_next_lcore(-1, 1, 0));
11366 /* Wait until reader exited. */
11367 rte_eal_mp_wait_lcore();
11369 /* Test with invalid crypto device */
11370 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11371 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11372 "Expected call to fail as crypto device is invalid");
11374 /* Test with invalid queue pair */
11375 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11376 ts_params->valid_devs[0],
11377 dev_info.max_nb_queue_pairs + 1, cb),
11378 "Expected call to fail as queue pair is invalid");
11380 /* Test with NULL callback */
11381 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11382 ts_params->valid_devs[0], qp_id, NULL),
11383 "Expected call to fail as callback is NULL");
11385 /* Test with valid configuration */
11386 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11387 ts_params->valid_devs[0], qp_id, cb),
11388 "Failed test to remove callback on "
11389 "qp %u on cryptodev %u",
11390 qp_id, ts_params->valid_devs[0]);
11392 return TEST_SUCCESS;
11396 generate_gmac_large_plaintext(uint8_t *data)
11400 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11401 memcpy(&data[i], &data[0], 32);
11405 create_gmac_operation(enum rte_crypto_auth_operation op,
11406 const struct gmac_test_data *tdata)
11408 struct crypto_testsuite_params *ts_params = &testsuite_params;
11409 struct crypto_unittest_params *ut_params = &unittest_params;
11410 struct rte_crypto_sym_op *sym_op;
11412 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11414 /* Generate Crypto op data structure */
11415 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11416 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11417 TEST_ASSERT_NOT_NULL(ut_params->op,
11418 "Failed to allocate symmetric crypto operation struct");
11420 sym_op = ut_params->op->sym;
11422 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11423 ut_params->ibuf, tdata->gmac_tag.len);
11424 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11425 "no room to append digest");
11427 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11428 ut_params->ibuf, plaintext_pad_len);
11430 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11431 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11432 tdata->gmac_tag.len);
11433 debug_hexdump(stdout, "digest:",
11434 sym_op->auth.digest.data,
11435 tdata->gmac_tag.len);
11438 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11439 uint8_t *, IV_OFFSET);
11441 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11443 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11445 sym_op->cipher.data.length = 0;
11446 sym_op->cipher.data.offset = 0;
11448 sym_op->auth.data.offset = 0;
11449 sym_op->auth.data.length = tdata->plaintext.len;
11455 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11456 const struct gmac_test_data *tdata,
11457 void *digest_mem, uint64_t digest_phys)
11459 struct crypto_testsuite_params *ts_params = &testsuite_params;
11460 struct crypto_unittest_params *ut_params = &unittest_params;
11461 struct rte_crypto_sym_op *sym_op;
11463 /* Generate Crypto op data structure */
11464 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11465 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11466 TEST_ASSERT_NOT_NULL(ut_params->op,
11467 "Failed to allocate symmetric crypto operation struct");
11469 sym_op = ut_params->op->sym;
11471 sym_op->auth.digest.data = digest_mem;
11472 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11473 "no room to append digest");
11475 sym_op->auth.digest.phys_addr = digest_phys;
11477 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11478 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11479 tdata->gmac_tag.len);
11480 debug_hexdump(stdout, "digest:",
11481 sym_op->auth.digest.data,
11482 tdata->gmac_tag.len);
11485 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11486 uint8_t *, IV_OFFSET);
11488 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11490 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11492 sym_op->cipher.data.length = 0;
11493 sym_op->cipher.data.offset = 0;
11495 sym_op->auth.data.offset = 0;
11496 sym_op->auth.data.length = tdata->plaintext.len;
11501 static int create_gmac_session(uint8_t dev_id,
11502 const struct gmac_test_data *tdata,
11503 enum rte_crypto_auth_operation auth_op)
11505 uint8_t auth_key[tdata->key.len];
11507 struct crypto_testsuite_params *ts_params = &testsuite_params;
11508 struct crypto_unittest_params *ut_params = &unittest_params;
11510 memcpy(auth_key, tdata->key.data, tdata->key.len);
11512 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11513 ut_params->auth_xform.next = NULL;
11515 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11516 ut_params->auth_xform.auth.op = auth_op;
11517 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11518 ut_params->auth_xform.auth.key.length = tdata->key.len;
11519 ut_params->auth_xform.auth.key.data = auth_key;
11520 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11521 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11524 ut_params->sess = rte_cryptodev_sym_session_create(
11525 ts_params->session_mpool);
11527 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11528 &ut_params->auth_xform,
11529 ts_params->session_priv_mpool);
11531 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11537 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11539 struct crypto_testsuite_params *ts_params = &testsuite_params;
11540 struct crypto_unittest_params *ut_params = &unittest_params;
11541 struct rte_cryptodev_info dev_info;
11543 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11544 uint64_t feat_flags = dev_info.feature_flags;
11546 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11547 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11548 printf("Device doesn't support RAW data-path APIs.\n");
11549 return TEST_SKIPPED;
11554 uint8_t *auth_tag, *plaintext;
11555 uint16_t plaintext_pad_len;
11557 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11558 "No GMAC length in the source data");
11560 /* Verify the capabilities */
11561 struct rte_cryptodev_sym_capability_idx cap_idx;
11562 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11563 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11564 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11566 return TEST_SKIPPED;
11568 retval = create_gmac_session(ts_params->valid_devs[0],
11569 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11574 if (tdata->plaintext.len > MBUF_SIZE)
11575 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11577 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11578 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11579 "Failed to allocate input buffer in mempool");
11581 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11582 rte_pktmbuf_tailroom(ut_params->ibuf));
11584 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11586 * Runtime generate the large plain text instead of use hard code
11587 * plain text vector. It is done to avoid create huge source file
11588 * with the test vector.
11590 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11591 generate_gmac_large_plaintext(tdata->plaintext.data);
11593 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11594 plaintext_pad_len);
11595 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11597 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11598 debug_hexdump(stdout, "plaintext:", plaintext,
11599 tdata->plaintext.len);
11601 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11607 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11609 ut_params->op->sym->m_src = ut_params->ibuf;
11611 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11612 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11614 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11615 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11616 ut_params->op, 0, 1, 0, 0);
11618 TEST_ASSERT_NOT_NULL(
11619 process_crypto_request(ts_params->valid_devs[0],
11620 ut_params->op), "failed to process sym crypto op");
11622 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11623 "crypto op processing failed");
11625 if (ut_params->op->sym->m_dst) {
11626 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11627 uint8_t *, plaintext_pad_len);
11629 auth_tag = plaintext + plaintext_pad_len;
11632 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11634 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11636 tdata->gmac_tag.data,
11637 tdata->gmac_tag.len,
11638 "GMAC Generated auth tag not as expected");
11644 test_AES_GMAC_authentication_test_case_1(void)
11646 return test_AES_GMAC_authentication(&gmac_test_case_1);
11650 test_AES_GMAC_authentication_test_case_2(void)
11652 return test_AES_GMAC_authentication(&gmac_test_case_2);
11656 test_AES_GMAC_authentication_test_case_3(void)
11658 return test_AES_GMAC_authentication(&gmac_test_case_3);
11662 test_AES_GMAC_authentication_test_case_4(void)
11664 return test_AES_GMAC_authentication(&gmac_test_case_4);
11668 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11670 struct crypto_testsuite_params *ts_params = &testsuite_params;
11671 struct crypto_unittest_params *ut_params = &unittest_params;
11673 uint32_t plaintext_pad_len;
11674 uint8_t *plaintext;
11675 struct rte_cryptodev_info dev_info;
11677 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11678 uint64_t feat_flags = dev_info.feature_flags;
11680 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11681 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11682 printf("Device doesn't support RAW data-path APIs.\n");
11683 return TEST_SKIPPED;
11686 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11687 "No GMAC length in the source data");
11689 /* Verify the capabilities */
11690 struct rte_cryptodev_sym_capability_idx cap_idx;
11691 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11692 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11693 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11695 return TEST_SKIPPED;
11697 retval = create_gmac_session(ts_params->valid_devs[0],
11698 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11703 if (tdata->plaintext.len > MBUF_SIZE)
11704 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11706 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11707 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11708 "Failed to allocate input buffer in mempool");
11710 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11711 rte_pktmbuf_tailroom(ut_params->ibuf));
11713 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11716 * Runtime generate the large plain text instead of use hard code
11717 * plain text vector. It is done to avoid create huge source file
11718 * with the test vector.
11720 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11721 generate_gmac_large_plaintext(tdata->plaintext.data);
11723 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11724 plaintext_pad_len);
11725 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11727 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11728 debug_hexdump(stdout, "plaintext:", plaintext,
11729 tdata->plaintext.len);
11731 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11737 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11739 ut_params->op->sym->m_src = ut_params->ibuf;
11741 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11742 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11744 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11745 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11746 ut_params->op, 0, 1, 0, 0);
11748 TEST_ASSERT_NOT_NULL(
11749 process_crypto_request(ts_params->valid_devs[0],
11750 ut_params->op), "failed to process sym crypto op");
11752 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11753 "crypto op processing failed");
11760 test_AES_GMAC_authentication_verify_test_case_1(void)
11762 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11766 test_AES_GMAC_authentication_verify_test_case_2(void)
11768 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11772 test_AES_GMAC_authentication_verify_test_case_3(void)
11774 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11778 test_AES_GMAC_authentication_verify_test_case_4(void)
11780 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11784 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11787 struct crypto_testsuite_params *ts_params = &testsuite_params;
11788 struct crypto_unittest_params *ut_params = &unittest_params;
11789 struct rte_cryptodev_info dev_info;
11790 uint64_t feature_flags;
11791 unsigned int trn_data = 0;
11792 void *digest_mem = NULL;
11794 unsigned int to_trn = 0;
11795 struct rte_mbuf *buf = NULL;
11796 uint8_t *auth_tag, *plaintext;
11799 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11800 "No GMAC length in the source data");
11802 /* Verify the capabilities */
11803 struct rte_cryptodev_sym_capability_idx cap_idx;
11804 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11805 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11806 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11808 return TEST_SKIPPED;
11810 /* Check for any input SGL support */
11811 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11812 feature_flags = dev_info.feature_flags;
11814 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11815 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11816 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11817 return TEST_SKIPPED;
11819 if (fragsz > tdata->plaintext.len)
11820 fragsz = tdata->plaintext.len;
11822 uint16_t plaintext_len = fragsz;
11824 retval = create_gmac_session(ts_params->valid_devs[0],
11825 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11830 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11831 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11832 "Failed to allocate input buffer in mempool");
11834 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11835 rte_pktmbuf_tailroom(ut_params->ibuf));
11837 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11839 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11841 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11843 trn_data += plaintext_len;
11845 buf = ut_params->ibuf;
11848 * Loop until no more fragments
11851 while (trn_data < tdata->plaintext.len) {
11853 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11854 (tdata->plaintext.len - trn_data) : fragsz;
11856 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11859 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11860 rte_pktmbuf_tailroom(buf));
11862 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11865 memcpy(plaintext, tdata->plaintext.data + trn_data,
11867 trn_data += to_trn;
11868 if (trn_data == tdata->plaintext.len)
11869 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11870 tdata->gmac_tag.len);
11872 ut_params->ibuf->nb_segs = segs;
11875 * Place digest at the end of the last buffer
11877 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11880 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11881 + tdata->gmac_tag.len);
11882 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11883 tdata->plaintext.len);
11886 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11887 tdata, digest_mem, digest_phys);
11892 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11894 ut_params->op->sym->m_src = ut_params->ibuf;
11896 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11897 return TEST_SKIPPED;
11899 TEST_ASSERT_NOT_NULL(
11900 process_crypto_request(ts_params->valid_devs[0],
11901 ut_params->op), "failed to process sym crypto op");
11903 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11904 "crypto op processing failed");
11906 auth_tag = digest_mem;
11907 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11908 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11910 tdata->gmac_tag.data,
11911 tdata->gmac_tag.len,
11912 "GMAC Generated auth tag not as expected");
11917 /* Segment size not multiple of block size (16B) */
11919 test_AES_GMAC_authentication_SGL_40B(void)
11921 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11925 test_AES_GMAC_authentication_SGL_80B(void)
11927 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11931 test_AES_GMAC_authentication_SGL_2048B(void)
11933 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11936 /* Segment size not multiple of block size (16B) */
11938 test_AES_GMAC_authentication_SGL_2047B(void)
11940 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11943 struct test_crypto_vector {
11944 enum rte_crypto_cipher_algorithm crypto_algo;
11945 unsigned int cipher_offset;
11946 unsigned int cipher_len;
11959 const uint8_t *data;
11964 const uint8_t *data;
11968 enum rte_crypto_auth_algorithm auth_algo;
11969 unsigned int auth_offset;
11977 const uint8_t *data;
11987 static const struct test_crypto_vector
11988 hmac_sha1_test_crypto_vector = {
11989 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11991 .data = plaintext_hash,
11996 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11997 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11998 0xDE, 0xF4, 0xDE, 0xAD
12004 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12005 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12006 0x3F, 0x91, 0x64, 0x59
12012 static const struct test_crypto_vector
12013 aes128_gmac_test_vector = {
12014 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12016 .data = plaintext_hash,
12021 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12022 0x08, 0x09, 0x0A, 0x0B
12028 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12029 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12035 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12036 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12042 static const struct test_crypto_vector
12043 aes128cbc_hmac_sha1_test_vector = {
12044 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12045 .cipher_offset = 0,
12049 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12050 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12056 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12057 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12062 .data = plaintext_hash,
12066 .data = ciphertext512_aes128cbc,
12069 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12073 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12074 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12075 0xDE, 0xF4, 0xDE, 0xAD
12081 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12082 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12083 0x18, 0x8C, 0x1D, 0x32
12089 static const struct test_crypto_vector
12090 aes128cbc_hmac_sha1_aad_test_vector = {
12091 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12092 .cipher_offset = 8,
12096 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12097 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12103 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12104 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12109 .data = plaintext_hash,
12113 .data = ciphertext512_aes128cbc_aad,
12116 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12120 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12121 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12122 0xDE, 0xF4, 0xDE, 0xAD
12128 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12129 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12130 0x62, 0x0F, 0xFB, 0x10
12137 data_corruption(uint8_t *data)
12143 tag_corruption(uint8_t *data, unsigned int tag_offset)
12145 data[tag_offset] += 1;
12149 create_auth_session(struct crypto_unittest_params *ut_params,
12151 const struct test_crypto_vector *reference,
12152 enum rte_crypto_auth_operation auth_op)
12154 struct crypto_testsuite_params *ts_params = &testsuite_params;
12155 uint8_t auth_key[reference->auth_key.len + 1];
12157 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12159 /* Setup Authentication Parameters */
12160 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12161 ut_params->auth_xform.auth.op = auth_op;
12162 ut_params->auth_xform.next = NULL;
12163 ut_params->auth_xform.auth.algo = reference->auth_algo;
12164 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12165 ut_params->auth_xform.auth.key.data = auth_key;
12166 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12168 /* Create Crypto session*/
12169 ut_params->sess = rte_cryptodev_sym_session_create(
12170 ts_params->session_mpool);
12172 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12173 &ut_params->auth_xform,
12174 ts_params->session_priv_mpool);
12176 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12182 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12184 const struct test_crypto_vector *reference,
12185 enum rte_crypto_auth_operation auth_op,
12186 enum rte_crypto_cipher_operation cipher_op)
12188 struct crypto_testsuite_params *ts_params = &testsuite_params;
12189 uint8_t cipher_key[reference->cipher_key.len + 1];
12190 uint8_t auth_key[reference->auth_key.len + 1];
12192 memcpy(cipher_key, reference->cipher_key.data,
12193 reference->cipher_key.len);
12194 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12196 /* Setup Authentication Parameters */
12197 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12198 ut_params->auth_xform.auth.op = auth_op;
12199 ut_params->auth_xform.auth.algo = reference->auth_algo;
12200 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12201 ut_params->auth_xform.auth.key.data = auth_key;
12202 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12204 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12205 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12206 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12208 ut_params->auth_xform.next = &ut_params->cipher_xform;
12210 /* Setup Cipher Parameters */
12211 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12212 ut_params->cipher_xform.next = NULL;
12213 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12214 ut_params->cipher_xform.cipher.op = cipher_op;
12215 ut_params->cipher_xform.cipher.key.data = cipher_key;
12216 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12217 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12218 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12221 /* Create Crypto session*/
12222 ut_params->sess = rte_cryptodev_sym_session_create(
12223 ts_params->session_mpool);
12225 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12226 &ut_params->auth_xform,
12227 ts_params->session_priv_mpool);
12229 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12235 create_auth_operation(struct crypto_testsuite_params *ts_params,
12236 struct crypto_unittest_params *ut_params,
12237 const struct test_crypto_vector *reference,
12238 unsigned int auth_generate)
12240 /* Generate Crypto op data structure */
12241 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12242 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12243 TEST_ASSERT_NOT_NULL(ut_params->op,
12244 "Failed to allocate pktmbuf offload");
12246 /* Set crypto operation data parameters */
12247 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12249 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12251 /* set crypto operation source mbuf */
12252 sym_op->m_src = ut_params->ibuf;
12255 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12256 ut_params->ibuf, reference->digest.len);
12258 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12259 "no room to append auth tag");
12261 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12262 ut_params->ibuf, reference->plaintext.len);
12265 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12267 memcpy(sym_op->auth.digest.data,
12268 reference->digest.data,
12269 reference->digest.len);
12271 debug_hexdump(stdout, "digest:",
12272 sym_op->auth.digest.data,
12273 reference->digest.len);
12275 sym_op->auth.data.length = reference->plaintext.len;
12276 sym_op->auth.data.offset = 0;
12282 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12283 struct crypto_unittest_params *ut_params,
12284 const struct test_crypto_vector *reference,
12285 unsigned int auth_generate)
12287 /* Generate Crypto op data structure */
12288 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12289 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12290 TEST_ASSERT_NOT_NULL(ut_params->op,
12291 "Failed to allocate pktmbuf offload");
12293 /* Set crypto operation data parameters */
12294 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12296 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12298 /* set crypto operation source mbuf */
12299 sym_op->m_src = ut_params->ibuf;
12302 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12303 ut_params->ibuf, reference->digest.len);
12305 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12306 "no room to append auth tag");
12308 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12309 ut_params->ibuf, reference->ciphertext.len);
12312 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12314 memcpy(sym_op->auth.digest.data,
12315 reference->digest.data,
12316 reference->digest.len);
12318 debug_hexdump(stdout, "digest:",
12319 sym_op->auth.digest.data,
12320 reference->digest.len);
12322 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12323 reference->iv.data, reference->iv.len);
12325 sym_op->cipher.data.length = 0;
12326 sym_op->cipher.data.offset = 0;
12328 sym_op->auth.data.length = reference->plaintext.len;
12329 sym_op->auth.data.offset = 0;
12335 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12336 struct crypto_unittest_params *ut_params,
12337 const struct test_crypto_vector *reference,
12338 unsigned int auth_generate)
12340 /* Generate Crypto op data structure */
12341 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12342 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12343 TEST_ASSERT_NOT_NULL(ut_params->op,
12344 "Failed to allocate pktmbuf offload");
12346 /* Set crypto operation data parameters */
12347 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12349 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12351 /* set crypto operation source mbuf */
12352 sym_op->m_src = ut_params->ibuf;
12355 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12356 ut_params->ibuf, reference->digest.len);
12358 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12359 "no room to append auth tag");
12361 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12362 ut_params->ibuf, reference->ciphertext.len);
12365 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12367 memcpy(sym_op->auth.digest.data,
12368 reference->digest.data,
12369 reference->digest.len);
12371 debug_hexdump(stdout, "digest:",
12372 sym_op->auth.digest.data,
12373 reference->digest.len);
12375 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12376 reference->iv.data, reference->iv.len);
12378 sym_op->cipher.data.length = reference->cipher_len;
12379 sym_op->cipher.data.offset = reference->cipher_offset;
12381 sym_op->auth.data.length = reference->plaintext.len;
12382 sym_op->auth.data.offset = reference->auth_offset;
12388 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12389 struct crypto_unittest_params *ut_params,
12390 const struct test_crypto_vector *reference)
12392 return create_auth_operation(ts_params, ut_params, reference, 0);
12396 create_auth_verify_GMAC_operation(
12397 struct crypto_testsuite_params *ts_params,
12398 struct crypto_unittest_params *ut_params,
12399 const struct test_crypto_vector *reference)
12401 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12405 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12406 struct crypto_unittest_params *ut_params,
12407 const struct test_crypto_vector *reference)
12409 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12413 test_authentication_verify_fail_when_data_corruption(
12414 struct crypto_testsuite_params *ts_params,
12415 struct crypto_unittest_params *ut_params,
12416 const struct test_crypto_vector *reference,
12417 unsigned int data_corrupted)
12421 uint8_t *plaintext;
12422 struct rte_cryptodev_info dev_info;
12424 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12425 uint64_t feat_flags = dev_info.feature_flags;
12427 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12428 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12429 printf("Device doesn't support RAW data-path APIs.\n");
12430 return TEST_SKIPPED;
12433 /* Verify the capabilities */
12434 struct rte_cryptodev_sym_capability_idx cap_idx;
12435 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12436 cap_idx.algo.auth = reference->auth_algo;
12437 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12439 return TEST_SKIPPED;
12442 /* Create session */
12443 retval = create_auth_session(ut_params,
12444 ts_params->valid_devs[0],
12446 RTE_CRYPTO_AUTH_OP_VERIFY);
12450 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12451 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12452 "Failed to allocate input buffer in mempool");
12454 /* clear mbuf payload */
12455 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12456 rte_pktmbuf_tailroom(ut_params->ibuf));
12458 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12459 reference->plaintext.len);
12460 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12461 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12463 debug_hexdump(stdout, "plaintext:", plaintext,
12464 reference->plaintext.len);
12466 /* Create operation */
12467 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12472 if (data_corrupted)
12473 data_corruption(plaintext);
12475 tag_corruption(plaintext, reference->plaintext.len);
12477 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12478 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12480 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12481 RTE_CRYPTO_OP_STATUS_SUCCESS,
12482 "authentication not failed");
12483 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12484 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12485 ut_params->op, 0, 1, 0, 0);
12487 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12489 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12496 test_authentication_verify_GMAC_fail_when_corruption(
12497 struct crypto_testsuite_params *ts_params,
12498 struct crypto_unittest_params *ut_params,
12499 const struct test_crypto_vector *reference,
12500 unsigned int data_corrupted)
12503 uint8_t *plaintext;
12504 struct rte_cryptodev_info dev_info;
12506 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12507 uint64_t feat_flags = dev_info.feature_flags;
12509 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12510 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12511 printf("Device doesn't support RAW data-path APIs.\n");
12512 return TEST_SKIPPED;
12515 /* Verify the capabilities */
12516 struct rte_cryptodev_sym_capability_idx cap_idx;
12517 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12518 cap_idx.algo.auth = reference->auth_algo;
12519 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12521 return TEST_SKIPPED;
12523 /* Create session */
12524 retval = create_auth_cipher_session(ut_params,
12525 ts_params->valid_devs[0],
12527 RTE_CRYPTO_AUTH_OP_VERIFY,
12528 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12532 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12533 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12534 "Failed to allocate input buffer in mempool");
12536 /* clear mbuf payload */
12537 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12538 rte_pktmbuf_tailroom(ut_params->ibuf));
12540 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12541 reference->plaintext.len);
12542 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12543 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12545 debug_hexdump(stdout, "plaintext:", plaintext,
12546 reference->plaintext.len);
12548 /* Create operation */
12549 retval = create_auth_verify_GMAC_operation(ts_params,
12556 if (data_corrupted)
12557 data_corruption(plaintext);
12559 tag_corruption(plaintext, reference->aad.len);
12561 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12562 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12564 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12565 RTE_CRYPTO_OP_STATUS_SUCCESS,
12566 "authentication not failed");
12567 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12568 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12569 ut_params->op, 0, 1, 0, 0);
12571 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12573 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12580 test_authenticated_decryption_fail_when_corruption(
12581 struct crypto_testsuite_params *ts_params,
12582 struct crypto_unittest_params *ut_params,
12583 const struct test_crypto_vector *reference,
12584 unsigned int data_corrupted)
12588 uint8_t *ciphertext;
12589 struct rte_cryptodev_info dev_info;
12591 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12592 uint64_t feat_flags = dev_info.feature_flags;
12594 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12595 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12596 printf("Device doesn't support RAW data-path APIs.\n");
12597 return TEST_SKIPPED;
12600 /* Verify the capabilities */
12601 struct rte_cryptodev_sym_capability_idx cap_idx;
12602 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12603 cap_idx.algo.auth = reference->auth_algo;
12604 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12606 return TEST_SKIPPED;
12607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12608 cap_idx.algo.cipher = reference->crypto_algo;
12609 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12611 return TEST_SKIPPED;
12613 /* Create session */
12614 retval = create_auth_cipher_session(ut_params,
12615 ts_params->valid_devs[0],
12617 RTE_CRYPTO_AUTH_OP_VERIFY,
12618 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12622 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12623 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12624 "Failed to allocate input buffer in mempool");
12626 /* clear mbuf payload */
12627 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12628 rte_pktmbuf_tailroom(ut_params->ibuf));
12630 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12631 reference->ciphertext.len);
12632 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12633 memcpy(ciphertext, reference->ciphertext.data,
12634 reference->ciphertext.len);
12636 /* Create operation */
12637 retval = create_cipher_auth_verify_operation(ts_params,
12644 if (data_corrupted)
12645 data_corruption(ciphertext);
12647 tag_corruption(ciphertext, reference->ciphertext.len);
12649 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12650 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12652 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12653 RTE_CRYPTO_OP_STATUS_SUCCESS,
12654 "authentication not failed");
12655 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12656 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12657 ut_params->op, 1, 1, 0, 0);
12659 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12661 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12668 test_authenticated_encryt_with_esn(
12669 struct crypto_testsuite_params *ts_params,
12670 struct crypto_unittest_params *ut_params,
12671 const struct test_crypto_vector *reference)
12675 uint8_t *authciphertext, *plaintext, *auth_tag;
12676 uint16_t plaintext_pad_len;
12677 uint8_t cipher_key[reference->cipher_key.len + 1];
12678 uint8_t auth_key[reference->auth_key.len + 1];
12679 struct rte_cryptodev_info dev_info;
12681 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12682 uint64_t feat_flags = dev_info.feature_flags;
12684 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12685 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12686 printf("Device doesn't support RAW data-path APIs.\n");
12687 return TEST_SKIPPED;
12690 /* Verify the capabilities */
12691 struct rte_cryptodev_sym_capability_idx cap_idx;
12692 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12693 cap_idx.algo.auth = reference->auth_algo;
12694 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12696 return TEST_SKIPPED;
12697 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12698 cap_idx.algo.cipher = reference->crypto_algo;
12699 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12701 return TEST_SKIPPED;
12703 /* Create session */
12704 memcpy(cipher_key, reference->cipher_key.data,
12705 reference->cipher_key.len);
12706 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12708 /* Setup Cipher Parameters */
12709 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12710 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12711 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12712 ut_params->cipher_xform.cipher.key.data = cipher_key;
12713 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12714 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12715 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12717 ut_params->cipher_xform.next = &ut_params->auth_xform;
12719 /* Setup Authentication Parameters */
12720 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12721 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12722 ut_params->auth_xform.auth.algo = reference->auth_algo;
12723 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12724 ut_params->auth_xform.auth.key.data = auth_key;
12725 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12726 ut_params->auth_xform.next = NULL;
12728 /* Create Crypto session*/
12729 ut_params->sess = rte_cryptodev_sym_session_create(
12730 ts_params->session_mpool);
12732 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12734 &ut_params->cipher_xform,
12735 ts_params->session_priv_mpool);
12737 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12739 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12740 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12741 "Failed to allocate input buffer in mempool");
12743 /* clear mbuf payload */
12744 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12745 rte_pktmbuf_tailroom(ut_params->ibuf));
12747 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12748 reference->plaintext.len);
12749 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12750 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12752 /* Create operation */
12753 retval = create_cipher_auth_operation(ts_params,
12760 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12761 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12763 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12764 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12765 ut_params->op, 1, 1, 0, 0);
12767 ut_params->op = process_crypto_request(
12768 ts_params->valid_devs[0], ut_params->op);
12770 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12772 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12773 "crypto op processing failed");
12775 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12777 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12778 ut_params->op->sym->auth.data.offset);
12779 auth_tag = authciphertext + plaintext_pad_len;
12780 debug_hexdump(stdout, "ciphertext:", authciphertext,
12781 reference->ciphertext.len);
12782 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12784 /* Validate obuf */
12785 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12787 reference->ciphertext.data,
12788 reference->ciphertext.len,
12789 "Ciphertext data not as expected");
12791 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12793 reference->digest.data,
12794 reference->digest.len,
12795 "Generated digest not as expected");
12797 return TEST_SUCCESS;
12802 test_authenticated_decrypt_with_esn(
12803 struct crypto_testsuite_params *ts_params,
12804 struct crypto_unittest_params *ut_params,
12805 const struct test_crypto_vector *reference)
12809 uint8_t *ciphertext;
12810 uint8_t cipher_key[reference->cipher_key.len + 1];
12811 uint8_t auth_key[reference->auth_key.len + 1];
12812 struct rte_cryptodev_info dev_info;
12814 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12815 uint64_t feat_flags = dev_info.feature_flags;
12817 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12818 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12819 printf("Device doesn't support RAW data-path APIs.\n");
12820 return TEST_SKIPPED;
12823 /* Verify the capabilities */
12824 struct rte_cryptodev_sym_capability_idx cap_idx;
12825 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12826 cap_idx.algo.auth = reference->auth_algo;
12827 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12829 return TEST_SKIPPED;
12830 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12831 cap_idx.algo.cipher = reference->crypto_algo;
12832 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12834 return TEST_SKIPPED;
12836 /* Create session */
12837 memcpy(cipher_key, reference->cipher_key.data,
12838 reference->cipher_key.len);
12839 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12841 /* Setup Authentication Parameters */
12842 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12843 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12844 ut_params->auth_xform.auth.algo = reference->auth_algo;
12845 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12846 ut_params->auth_xform.auth.key.data = auth_key;
12847 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12848 ut_params->auth_xform.next = &ut_params->cipher_xform;
12850 /* Setup Cipher Parameters */
12851 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12852 ut_params->cipher_xform.next = NULL;
12853 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12854 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12855 ut_params->cipher_xform.cipher.key.data = cipher_key;
12856 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12857 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12858 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12860 /* Create Crypto session*/
12861 ut_params->sess = rte_cryptodev_sym_session_create(
12862 ts_params->session_mpool);
12864 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12866 &ut_params->auth_xform,
12867 ts_params->session_priv_mpool);
12869 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12871 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12872 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12873 "Failed to allocate input buffer in mempool");
12875 /* clear mbuf payload */
12876 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12877 rte_pktmbuf_tailroom(ut_params->ibuf));
12879 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12880 reference->ciphertext.len);
12881 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12882 memcpy(ciphertext, reference->ciphertext.data,
12883 reference->ciphertext.len);
12885 /* Create operation */
12886 retval = create_cipher_auth_verify_operation(ts_params,
12893 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12894 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12896 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12897 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12898 ut_params->op, 1, 1, 0, 0);
12900 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12903 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12904 TEST_ASSERT_EQUAL(ut_params->op->status,
12905 RTE_CRYPTO_OP_STATUS_SUCCESS,
12906 "crypto op processing passed");
12908 ut_params->obuf = ut_params->op->sym->m_src;
12909 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12915 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12916 const struct aead_test_data *tdata,
12917 void *digest_mem, uint64_t digest_phys)
12919 struct crypto_testsuite_params *ts_params = &testsuite_params;
12920 struct crypto_unittest_params *ut_params = &unittest_params;
12922 const unsigned int auth_tag_len = tdata->auth_tag.len;
12923 const unsigned int iv_len = tdata->iv.len;
12924 unsigned int aad_len = tdata->aad.len;
12925 unsigned int aad_len_pad = 0;
12927 /* Generate Crypto op data structure */
12928 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12929 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12930 TEST_ASSERT_NOT_NULL(ut_params->op,
12931 "Failed to allocate symmetric crypto operation struct");
12933 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12935 sym_op->aead.digest.data = digest_mem;
12937 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12938 "no room to append digest");
12940 sym_op->aead.digest.phys_addr = digest_phys;
12942 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12943 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12945 debug_hexdump(stdout, "digest:",
12946 sym_op->aead.digest.data,
12950 /* Append aad data */
12951 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12952 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12953 uint8_t *, IV_OFFSET);
12955 /* Copy IV 1 byte after the IV pointer, according to the API */
12956 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12958 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12960 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12961 ut_params->ibuf, aad_len);
12962 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12963 "no room to prepend aad");
12964 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12967 memset(sym_op->aead.aad.data, 0, aad_len);
12968 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12969 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12971 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12972 debug_hexdump(stdout, "aad:",
12973 sym_op->aead.aad.data, aad_len);
12975 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12976 uint8_t *, IV_OFFSET);
12978 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12980 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12982 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12983 ut_params->ibuf, aad_len_pad);
12984 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12985 "no room to prepend aad");
12986 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12989 memset(sym_op->aead.aad.data, 0, aad_len);
12990 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12992 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12993 debug_hexdump(stdout, "aad:",
12994 sym_op->aead.aad.data, aad_len);
12997 sym_op->aead.data.length = tdata->plaintext.len;
12998 sym_op->aead.data.offset = aad_len_pad;
13003 #define SGL_MAX_NO 16
13006 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13007 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13009 struct crypto_testsuite_params *ts_params = &testsuite_params;
13010 struct crypto_unittest_params *ut_params = &unittest_params;
13011 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13014 int to_trn_tbl[SGL_MAX_NO];
13016 unsigned int trn_data = 0;
13017 uint8_t *plaintext, *ciphertext, *auth_tag;
13018 struct rte_cryptodev_info dev_info;
13020 /* Verify the capabilities */
13021 struct rte_cryptodev_sym_capability_idx cap_idx;
13022 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13023 cap_idx.algo.aead = tdata->algo;
13024 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13026 return TEST_SKIPPED;
13028 /* OOP not supported with CPU crypto */
13029 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13030 return TEST_SKIPPED;
13032 /* Detailed check for the particular SGL support flag */
13033 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13035 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13036 if (sgl_in && (!(dev_info.feature_flags &
13037 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13038 return TEST_SKIPPED;
13040 uint64_t feat_flags = dev_info.feature_flags;
13042 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13043 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13044 printf("Device doesn't support RAW data-path APIs.\n");
13045 return TEST_SKIPPED;
13048 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13049 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13050 tdata->plaintext.len;
13051 /* Raw data path API does not support OOP */
13052 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13053 return TEST_SKIPPED;
13054 if (sgl_in && !sgl_out) {
13055 if (!(dev_info.feature_flags &
13056 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13057 return TEST_SKIPPED;
13058 } else if (!sgl_in && sgl_out) {
13059 if (!(dev_info.feature_flags &
13060 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13061 return TEST_SKIPPED;
13062 } else if (sgl_in && sgl_out) {
13063 if (!(dev_info.feature_flags &
13064 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13065 return TEST_SKIPPED;
13069 if (fragsz > tdata->plaintext.len)
13070 fragsz = tdata->plaintext.len;
13072 uint16_t plaintext_len = fragsz;
13073 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13075 if (fragsz_oop > tdata->plaintext.len)
13076 frag_size_oop = tdata->plaintext.len;
13079 void *digest_mem = NULL;
13081 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13083 if (tdata->plaintext.len % fragsz != 0) {
13084 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13087 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13092 * For out-op-place we need to alloc another mbuf
13095 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13096 rte_pktmbuf_append(ut_params->obuf,
13097 frag_size_oop + prepend_len);
13098 buf_oop = ut_params->obuf;
13101 /* Create AEAD session */
13102 retval = create_aead_session(ts_params->valid_devs[0],
13104 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13105 tdata->key.data, tdata->key.len,
13106 tdata->aad.len, tdata->auth_tag.len,
13111 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13113 /* clear mbuf payload */
13114 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13115 rte_pktmbuf_tailroom(ut_params->ibuf));
13117 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13120 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13122 trn_data += plaintext_len;
13124 buf = ut_params->ibuf;
13127 * Loop until no more fragments
13130 while (trn_data < tdata->plaintext.len) {
13132 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13133 (tdata->plaintext.len - trn_data) : fragsz;
13135 to_trn_tbl[ecx++] = to_trn;
13137 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13140 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13141 rte_pktmbuf_tailroom(buf));
13144 if (oop && !fragsz_oop) {
13145 buf_last_oop = buf_oop->next =
13146 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13147 buf_oop = buf_oop->next;
13148 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13149 0, rte_pktmbuf_tailroom(buf_oop));
13150 rte_pktmbuf_append(buf_oop, to_trn);
13153 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13156 memcpy(plaintext, tdata->plaintext.data + trn_data,
13158 trn_data += to_trn;
13159 if (trn_data == tdata->plaintext.len) {
13162 digest_mem = rte_pktmbuf_append(buf_oop,
13163 tdata->auth_tag.len);
13165 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13166 tdata->auth_tag.len);
13170 uint64_t digest_phys = 0;
13172 ut_params->ibuf->nb_segs = segs;
13175 if (fragsz_oop && oop) {
13179 if (frag_size_oop == tdata->plaintext.len) {
13180 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13181 tdata->auth_tag.len);
13183 digest_phys = rte_pktmbuf_iova_offset(
13185 tdata->plaintext.len + prepend_len);
13188 trn_data = frag_size_oop;
13189 while (trn_data < tdata->plaintext.len) {
13192 (tdata->plaintext.len - trn_data <
13194 (tdata->plaintext.len - trn_data) :
13197 to_trn_tbl[ecx++] = to_trn;
13199 buf_last_oop = buf_oop->next =
13200 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13201 buf_oop = buf_oop->next;
13202 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13203 0, rte_pktmbuf_tailroom(buf_oop));
13204 rte_pktmbuf_append(buf_oop, to_trn);
13206 trn_data += to_trn;
13208 if (trn_data == tdata->plaintext.len) {
13209 digest_mem = rte_pktmbuf_append(buf_oop,
13210 tdata->auth_tag.len);
13214 ut_params->obuf->nb_segs = segs;
13218 * Place digest at the end of the last buffer
13221 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13222 if (oop && buf_last_oop)
13223 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13225 if (!digest_mem && !oop) {
13226 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13227 + tdata->auth_tag.len);
13228 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13229 tdata->plaintext.len);
13232 /* Create AEAD operation */
13233 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13234 tdata, digest_mem, digest_phys);
13239 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13241 ut_params->op->sym->m_src = ut_params->ibuf;
13243 ut_params->op->sym->m_dst = ut_params->obuf;
13245 /* Process crypto operation */
13246 if (oop == IN_PLACE &&
13247 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13248 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13249 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13250 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13251 ut_params->op, 0, 0, 0, 0);
13253 TEST_ASSERT_NOT_NULL(
13254 process_crypto_request(ts_params->valid_devs[0],
13255 ut_params->op), "failed to process sym crypto op");
13257 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13258 "crypto op processing failed");
13261 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13262 uint8_t *, prepend_len);
13264 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13265 uint8_t *, prepend_len);
13269 fragsz = fragsz_oop;
13271 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13273 tdata->ciphertext.data,
13275 "Ciphertext data not as expected");
13277 buf = ut_params->op->sym->m_src->next;
13279 buf = ut_params->op->sym->m_dst->next;
13281 unsigned int off = fragsz;
13285 ciphertext = rte_pktmbuf_mtod(buf,
13288 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13290 tdata->ciphertext.data + off,
13292 "Ciphertext data not as expected");
13294 off += to_trn_tbl[ecx++];
13298 auth_tag = digest_mem;
13299 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13301 tdata->auth_tag.data,
13302 tdata->auth_tag.len,
13303 "Generated auth tag not as expected");
13309 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13311 return test_authenticated_encryption_SGL(
13312 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13316 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13318 return test_authenticated_encryption_SGL(
13319 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13323 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13325 return test_authenticated_encryption_SGL(
13326 &gcm_test_case_8, OUT_OF_PLACE, 400,
13327 gcm_test_case_8.plaintext.len);
13331 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13333 /* This test is not for OPENSSL PMD */
13334 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13335 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13336 return TEST_SKIPPED;
13338 return test_authenticated_encryption_SGL(
13339 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13343 test_authentication_verify_fail_when_data_corrupted(
13344 struct crypto_testsuite_params *ts_params,
13345 struct crypto_unittest_params *ut_params,
13346 const struct test_crypto_vector *reference)
13348 return test_authentication_verify_fail_when_data_corruption(
13349 ts_params, ut_params, reference, 1);
13353 test_authentication_verify_fail_when_tag_corrupted(
13354 struct crypto_testsuite_params *ts_params,
13355 struct crypto_unittest_params *ut_params,
13356 const struct test_crypto_vector *reference)
13358 return test_authentication_verify_fail_when_data_corruption(
13359 ts_params, ut_params, reference, 0);
13363 test_authentication_verify_GMAC_fail_when_data_corrupted(
13364 struct crypto_testsuite_params *ts_params,
13365 struct crypto_unittest_params *ut_params,
13366 const struct test_crypto_vector *reference)
13368 return test_authentication_verify_GMAC_fail_when_corruption(
13369 ts_params, ut_params, reference, 1);
13373 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13374 struct crypto_testsuite_params *ts_params,
13375 struct crypto_unittest_params *ut_params,
13376 const struct test_crypto_vector *reference)
13378 return test_authentication_verify_GMAC_fail_when_corruption(
13379 ts_params, ut_params, reference, 0);
13383 test_authenticated_decryption_fail_when_data_corrupted(
13384 struct crypto_testsuite_params *ts_params,
13385 struct crypto_unittest_params *ut_params,
13386 const struct test_crypto_vector *reference)
13388 return test_authenticated_decryption_fail_when_corruption(
13389 ts_params, ut_params, reference, 1);
13393 test_authenticated_decryption_fail_when_tag_corrupted(
13394 struct crypto_testsuite_params *ts_params,
13395 struct crypto_unittest_params *ut_params,
13396 const struct test_crypto_vector *reference)
13398 return test_authenticated_decryption_fail_when_corruption(
13399 ts_params, ut_params, reference, 0);
13403 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13405 return test_authentication_verify_fail_when_data_corrupted(
13406 &testsuite_params, &unittest_params,
13407 &hmac_sha1_test_crypto_vector);
13411 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13413 return test_authentication_verify_fail_when_tag_corrupted(
13414 &testsuite_params, &unittest_params,
13415 &hmac_sha1_test_crypto_vector);
13419 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13421 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13422 &testsuite_params, &unittest_params,
13423 &aes128_gmac_test_vector);
13427 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13429 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13430 &testsuite_params, &unittest_params,
13431 &aes128_gmac_test_vector);
13435 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13437 return test_authenticated_decryption_fail_when_data_corrupted(
13440 &aes128cbc_hmac_sha1_test_vector);
13444 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13446 return test_authenticated_decryption_fail_when_tag_corrupted(
13449 &aes128cbc_hmac_sha1_test_vector);
13453 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13455 return test_authenticated_encryt_with_esn(
13458 &aes128cbc_hmac_sha1_aad_test_vector);
13462 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13464 return test_authenticated_decrypt_with_esn(
13467 &aes128cbc_hmac_sha1_aad_test_vector);
13471 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13473 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13477 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13479 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13482 #ifdef RTE_CRYPTO_SCHEDULER
13484 /* global AESNI worker IDs for the scheduler test */
13485 uint8_t aesni_ids[2];
13488 scheduler_testsuite_setup(void)
13491 int32_t nb_devs, ret;
13492 char vdev_args[VDEV_ARGS_SIZE] = {""};
13493 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
13494 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
13495 uint16_t worker_core_count = 0;
13496 uint16_t socket_id = 0;
13498 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13499 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
13501 /* Identify the Worker Cores
13502 * Use 2 worker cores for the device args
13504 RTE_LCORE_FOREACH_WORKER(i) {
13505 if (worker_core_count > 1)
13507 snprintf(vdev_args, sizeof(vdev_args),
13508 "%s%d", temp_str, i);
13509 strcpy(temp_str, vdev_args);
13510 strlcat(temp_str, ";", sizeof(temp_str));
13511 worker_core_count++;
13512 socket_id = rte_lcore_to_socket_id(i);
13514 if (worker_core_count != 2) {
13515 RTE_LOG(ERR, USER1,
13516 "Cryptodev scheduler test require at least "
13517 "two worker cores to run. "
13518 "Please use the correct coremask.\n");
13519 return TEST_FAILED;
13521 strcpy(temp_str, vdev_args);
13522 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
13523 temp_str, socket_id);
13524 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
13525 nb_devs = rte_cryptodev_device_count_by_driver(
13526 rte_cryptodev_driver_id_get(
13527 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
13529 ret = rte_vdev_init(
13530 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
13532 TEST_ASSERT(ret == 0,
13533 "Failed to create instance %u of pmd : %s",
13534 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13537 return testsuite_setup();
13541 test_scheduler_attach_slave_op(void)
13543 struct crypto_testsuite_params *ts_params = &testsuite_params;
13544 uint8_t sched_id = ts_params->valid_devs[0];
13545 uint32_t nb_devs, i, nb_devs_attached = 0;
13547 char vdev_name[32];
13549 /* create 2 AESNI_MB if necessary */
13550 nb_devs = rte_cryptodev_device_count_by_driver(
13551 rte_cryptodev_driver_id_get(
13552 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13554 for (i = nb_devs; i < 2; i++) {
13555 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13556 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13558 ret = rte_vdev_init(vdev_name, NULL);
13560 TEST_ASSERT(ret == 0,
13561 "Failed to create instance %u of"
13563 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13567 /* attach 2 AESNI_MB cdevs */
13568 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13570 struct rte_cryptodev_info info;
13571 unsigned int session_size;
13573 rte_cryptodev_info_get(i, &info);
13574 if (info.driver_id != rte_cryptodev_driver_id_get(
13575 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13578 session_size = rte_cryptodev_sym_get_private_session_size(i);
13580 * Create the session mempool again, since now there are new devices
13581 * to use the mempool.
13583 if (ts_params->session_mpool) {
13584 rte_mempool_free(ts_params->session_mpool);
13585 ts_params->session_mpool = NULL;
13587 if (ts_params->session_priv_mpool) {
13588 rte_mempool_free(ts_params->session_priv_mpool);
13589 ts_params->session_priv_mpool = NULL;
13592 if (info.sym.max_nb_sessions != 0 &&
13593 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13594 RTE_LOG(ERR, USER1,
13595 "Device does not support "
13596 "at least %u sessions\n",
13598 return TEST_FAILED;
13601 * Create mempool with maximum number of sessions,
13602 * to include the session headers
13604 if (ts_params->session_mpool == NULL) {
13605 ts_params->session_mpool =
13606 rte_cryptodev_sym_session_pool_create(
13608 MAX_NB_SESSIONS, 0, 0, 0,
13610 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13611 "session mempool allocation failed");
13615 * Create mempool with maximum number of sessions,
13616 * to include device specific session private data
13618 if (ts_params->session_priv_mpool == NULL) {
13619 ts_params->session_priv_mpool = rte_mempool_create(
13620 "test_sess_mp_priv",
13623 0, 0, NULL, NULL, NULL,
13624 NULL, SOCKET_ID_ANY,
13627 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13628 "session mempool allocation failed");
13631 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13632 ts_params->qp_conf.mp_session_private =
13633 ts_params->session_priv_mpool;
13635 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13638 TEST_ASSERT(ret == 0,
13639 "Failed to attach device %u of pmd : %s", i,
13640 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13642 aesni_ids[nb_devs_attached] = (uint8_t)i;
13644 nb_devs_attached++;
13651 test_scheduler_detach_slave_op(void)
13653 struct crypto_testsuite_params *ts_params = &testsuite_params;
13654 uint8_t sched_id = ts_params->valid_devs[0];
13658 for (i = 0; i < 2; i++) {
13659 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13661 TEST_ASSERT(ret == 0,
13662 "Failed to detach device %u", aesni_ids[i]);
13669 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13671 struct crypto_testsuite_params *ts_params = &testsuite_params;
13672 uint8_t sched_id = ts_params->valid_devs[0];
13674 return rte_cryptodev_scheduler_mode_set(sched_id,
13679 test_scheduler_mode_roundrobin_op(void)
13681 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13682 0, "Failed to set roundrobin mode");
13688 test_scheduler_mode_multicore_op(void)
13690 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13691 0, "Failed to set multicore mode");
13697 test_scheduler_mode_failover_op(void)
13699 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13700 0, "Failed to set failover mode");
13706 test_scheduler_mode_pkt_size_distr_op(void)
13708 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13709 0, "Failed to set pktsize mode");
13715 scheduler_multicore_testsuite_setup(void)
13717 if (test_scheduler_attach_slave_op() < 0)
13718 return TEST_SKIPPED;
13719 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
13720 return TEST_SKIPPED;
13725 scheduler_roundrobin_testsuite_setup(void)
13727 if (test_scheduler_attach_slave_op() < 0)
13728 return TEST_SKIPPED;
13729 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
13730 return TEST_SKIPPED;
13735 scheduler_failover_testsuite_setup(void)
13737 if (test_scheduler_attach_slave_op() < 0)
13738 return TEST_SKIPPED;
13739 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
13740 return TEST_SKIPPED;
13745 scheduler_pkt_size_distr_testsuite_setup(void)
13747 if (test_scheduler_attach_slave_op() < 0)
13748 return TEST_SKIPPED;
13749 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
13750 return TEST_SKIPPED;
13755 scheduler_mode_testsuite_teardown(void)
13757 test_scheduler_detach_slave_op();
13760 #endif /* RTE_CRYPTO_SCHEDULER */
13762 static struct unit_test_suite end_testsuite = {
13763 .suite_name = NULL,
13766 .unit_test_suites = NULL
13769 #ifdef RTE_LIB_SECURITY
13770 static struct unit_test_suite pdcp_proto_testsuite = {
13771 .suite_name = "PDCP Proto Unit Test Suite",
13772 .setup = pdcp_proto_testsuite_setup,
13773 .unit_test_cases = {
13774 TEST_CASE_ST(ut_setup_security, ut_teardown,
13775 test_PDCP_PROTO_all),
13776 TEST_CASES_END() /**< NULL terminate unit test array */
13780 static struct unit_test_suite docsis_proto_testsuite = {
13781 .suite_name = "Docsis Proto Unit Test Suite",
13782 .setup = docsis_proto_testsuite_setup,
13783 .unit_test_cases = {
13784 TEST_CASE_ST(ut_setup_security, ut_teardown,
13785 test_DOCSIS_PROTO_all),
13786 TEST_CASES_END() /**< NULL terminate unit test array */
13791 static struct unit_test_suite cryptodev_gen_testsuite = {
13792 .suite_name = "Crypto General Unit Test Suite",
13793 .setup = crypto_gen_testsuite_setup,
13794 .unit_test_cases = {
13795 TEST_CASE_ST(ut_setup, ut_teardown,
13796 test_device_configure_invalid_dev_id),
13797 TEST_CASE_ST(ut_setup, ut_teardown,
13798 test_queue_pair_descriptor_setup),
13799 TEST_CASE_ST(ut_setup, ut_teardown,
13800 test_device_configure_invalid_queue_pair_ids),
13801 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13802 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13803 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13804 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13805 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
13806 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
13807 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
13808 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13809 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13810 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13811 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13812 TEST_CASES_END() /**< NULL terminate unit test array */
13816 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
13817 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
13818 .setup = negative_hmac_sha1_testsuite_setup,
13819 .unit_test_cases = {
13820 /** Negative tests */
13821 TEST_CASE_ST(ut_setup, ut_teardown,
13822 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13823 TEST_CASE_ST(ut_setup, ut_teardown,
13824 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13825 TEST_CASE_ST(ut_setup, ut_teardown,
13826 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13827 TEST_CASE_ST(ut_setup, ut_teardown,
13828 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13830 TEST_CASES_END() /**< NULL terminate unit test array */
13834 static struct unit_test_suite cryptodev_multi_session_testsuite = {
13835 .suite_name = "Multi Session Unit Test Suite",
13836 .setup = multi_session_testsuite_setup,
13837 .unit_test_cases = {
13838 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13839 TEST_CASE_ST(ut_setup, ut_teardown,
13840 test_multi_session_random_usage),
13842 TEST_CASES_END() /**< NULL terminate unit test array */
13846 static struct unit_test_suite cryptodev_null_testsuite = {
13847 .suite_name = "NULL Test Suite",
13848 .setup = null_testsuite_setup,
13849 .unit_test_cases = {
13850 TEST_CASE_ST(ut_setup, ut_teardown,
13851 test_null_invalid_operation),
13852 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13857 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
13858 .suite_name = "AES CCM Authenticated Test Suite",
13859 .setup = aes_ccm_auth_testsuite_setup,
13860 .unit_test_cases = {
13861 /** AES CCM Authenticated Encryption 128 bits key*/
13862 TEST_CASE_ST(ut_setup, ut_teardown,
13863 test_AES_CCM_authenticated_encryption_test_case_128_1),
13864 TEST_CASE_ST(ut_setup, ut_teardown,
13865 test_AES_CCM_authenticated_encryption_test_case_128_2),
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_AES_CCM_authenticated_encryption_test_case_128_3),
13869 /** AES CCM Authenticated Decryption 128 bits key*/
13870 TEST_CASE_ST(ut_setup, ut_teardown,
13871 test_AES_CCM_authenticated_decryption_test_case_128_1),
13872 TEST_CASE_ST(ut_setup, ut_teardown,
13873 test_AES_CCM_authenticated_decryption_test_case_128_2),
13874 TEST_CASE_ST(ut_setup, ut_teardown,
13875 test_AES_CCM_authenticated_decryption_test_case_128_3),
13877 /** AES CCM Authenticated Encryption 192 bits key */
13878 TEST_CASE_ST(ut_setup, ut_teardown,
13879 test_AES_CCM_authenticated_encryption_test_case_192_1),
13880 TEST_CASE_ST(ut_setup, ut_teardown,
13881 test_AES_CCM_authenticated_encryption_test_case_192_2),
13882 TEST_CASE_ST(ut_setup, ut_teardown,
13883 test_AES_CCM_authenticated_encryption_test_case_192_3),
13885 /** AES CCM Authenticated Decryption 192 bits key*/
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_AES_CCM_authenticated_decryption_test_case_192_1),
13888 TEST_CASE_ST(ut_setup, ut_teardown,
13889 test_AES_CCM_authenticated_decryption_test_case_192_2),
13890 TEST_CASE_ST(ut_setup, ut_teardown,
13891 test_AES_CCM_authenticated_decryption_test_case_192_3),
13893 /** AES CCM Authenticated Encryption 256 bits key */
13894 TEST_CASE_ST(ut_setup, ut_teardown,
13895 test_AES_CCM_authenticated_encryption_test_case_256_1),
13896 TEST_CASE_ST(ut_setup, ut_teardown,
13897 test_AES_CCM_authenticated_encryption_test_case_256_2),
13898 TEST_CASE_ST(ut_setup, ut_teardown,
13899 test_AES_CCM_authenticated_encryption_test_case_256_3),
13901 /** AES CCM Authenticated Decryption 256 bits key*/
13902 TEST_CASE_ST(ut_setup, ut_teardown,
13903 test_AES_CCM_authenticated_decryption_test_case_256_1),
13904 TEST_CASE_ST(ut_setup, ut_teardown,
13905 test_AES_CCM_authenticated_decryption_test_case_256_2),
13906 TEST_CASE_ST(ut_setup, ut_teardown,
13907 test_AES_CCM_authenticated_decryption_test_case_256_3),
13912 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
13913 .suite_name = "AES GCM Authenticated Test Suite",
13914 .setup = aes_gcm_auth_testsuite_setup,
13915 .unit_test_cases = {
13916 /** AES GCM Authenticated Encryption */
13917 TEST_CASE_ST(ut_setup, ut_teardown,
13918 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13919 TEST_CASE_ST(ut_setup, ut_teardown,
13920 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13921 TEST_CASE_ST(ut_setup, ut_teardown,
13922 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13923 TEST_CASE_ST(ut_setup, ut_teardown,
13924 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13925 TEST_CASE_ST(ut_setup, ut_teardown,
13926 test_AES_GCM_authenticated_encryption_test_case_1),
13927 TEST_CASE_ST(ut_setup, ut_teardown,
13928 test_AES_GCM_authenticated_encryption_test_case_2),
13929 TEST_CASE_ST(ut_setup, ut_teardown,
13930 test_AES_GCM_authenticated_encryption_test_case_3),
13931 TEST_CASE_ST(ut_setup, ut_teardown,
13932 test_AES_GCM_authenticated_encryption_test_case_4),
13933 TEST_CASE_ST(ut_setup, ut_teardown,
13934 test_AES_GCM_authenticated_encryption_test_case_5),
13935 TEST_CASE_ST(ut_setup, ut_teardown,
13936 test_AES_GCM_authenticated_encryption_test_case_6),
13937 TEST_CASE_ST(ut_setup, ut_teardown,
13938 test_AES_GCM_authenticated_encryption_test_case_7),
13939 TEST_CASE_ST(ut_setup, ut_teardown,
13940 test_AES_GCM_authenticated_encryption_test_case_8),
13941 TEST_CASE_ST(ut_setup, ut_teardown,
13942 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13944 /** AES GCM Authenticated Decryption */
13945 TEST_CASE_ST(ut_setup, ut_teardown,
13946 test_AES_GCM_authenticated_decryption_test_case_1),
13947 TEST_CASE_ST(ut_setup, ut_teardown,
13948 test_AES_GCM_authenticated_decryption_test_case_2),
13949 TEST_CASE_ST(ut_setup, ut_teardown,
13950 test_AES_GCM_authenticated_decryption_test_case_3),
13951 TEST_CASE_ST(ut_setup, ut_teardown,
13952 test_AES_GCM_authenticated_decryption_test_case_4),
13953 TEST_CASE_ST(ut_setup, ut_teardown,
13954 test_AES_GCM_authenticated_decryption_test_case_5),
13955 TEST_CASE_ST(ut_setup, ut_teardown,
13956 test_AES_GCM_authenticated_decryption_test_case_6),
13957 TEST_CASE_ST(ut_setup, ut_teardown,
13958 test_AES_GCM_authenticated_decryption_test_case_7),
13959 TEST_CASE_ST(ut_setup, ut_teardown,
13960 test_AES_GCM_authenticated_decryption_test_case_8),
13961 TEST_CASE_ST(ut_setup, ut_teardown,
13962 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13964 /** AES GCM Authenticated Encryption 192 bits key */
13965 TEST_CASE_ST(ut_setup, ut_teardown,
13966 test_AES_GCM_auth_encryption_test_case_192_1),
13967 TEST_CASE_ST(ut_setup, ut_teardown,
13968 test_AES_GCM_auth_encryption_test_case_192_2),
13969 TEST_CASE_ST(ut_setup, ut_teardown,
13970 test_AES_GCM_auth_encryption_test_case_192_3),
13971 TEST_CASE_ST(ut_setup, ut_teardown,
13972 test_AES_GCM_auth_encryption_test_case_192_4),
13973 TEST_CASE_ST(ut_setup, ut_teardown,
13974 test_AES_GCM_auth_encryption_test_case_192_5),
13975 TEST_CASE_ST(ut_setup, ut_teardown,
13976 test_AES_GCM_auth_encryption_test_case_192_6),
13977 TEST_CASE_ST(ut_setup, ut_teardown,
13978 test_AES_GCM_auth_encryption_test_case_192_7),
13980 /** AES GCM Authenticated Decryption 192 bits key */
13981 TEST_CASE_ST(ut_setup, ut_teardown,
13982 test_AES_GCM_auth_decryption_test_case_192_1),
13983 TEST_CASE_ST(ut_setup, ut_teardown,
13984 test_AES_GCM_auth_decryption_test_case_192_2),
13985 TEST_CASE_ST(ut_setup, ut_teardown,
13986 test_AES_GCM_auth_decryption_test_case_192_3),
13987 TEST_CASE_ST(ut_setup, ut_teardown,
13988 test_AES_GCM_auth_decryption_test_case_192_4),
13989 TEST_CASE_ST(ut_setup, ut_teardown,
13990 test_AES_GCM_auth_decryption_test_case_192_5),
13991 TEST_CASE_ST(ut_setup, ut_teardown,
13992 test_AES_GCM_auth_decryption_test_case_192_6),
13993 TEST_CASE_ST(ut_setup, ut_teardown,
13994 test_AES_GCM_auth_decryption_test_case_192_7),
13996 /** AES GCM Authenticated Encryption 256 bits key */
13997 TEST_CASE_ST(ut_setup, ut_teardown,
13998 test_AES_GCM_auth_encryption_test_case_256_1),
13999 TEST_CASE_ST(ut_setup, ut_teardown,
14000 test_AES_GCM_auth_encryption_test_case_256_2),
14001 TEST_CASE_ST(ut_setup, ut_teardown,
14002 test_AES_GCM_auth_encryption_test_case_256_3),
14003 TEST_CASE_ST(ut_setup, ut_teardown,
14004 test_AES_GCM_auth_encryption_test_case_256_4),
14005 TEST_CASE_ST(ut_setup, ut_teardown,
14006 test_AES_GCM_auth_encryption_test_case_256_5),
14007 TEST_CASE_ST(ut_setup, ut_teardown,
14008 test_AES_GCM_auth_encryption_test_case_256_6),
14009 TEST_CASE_ST(ut_setup, ut_teardown,
14010 test_AES_GCM_auth_encryption_test_case_256_7),
14012 /** AES GCM Authenticated Decryption 256 bits key */
14013 TEST_CASE_ST(ut_setup, ut_teardown,
14014 test_AES_GCM_auth_decryption_test_case_256_1),
14015 TEST_CASE_ST(ut_setup, ut_teardown,
14016 test_AES_GCM_auth_decryption_test_case_256_2),
14017 TEST_CASE_ST(ut_setup, ut_teardown,
14018 test_AES_GCM_auth_decryption_test_case_256_3),
14019 TEST_CASE_ST(ut_setup, ut_teardown,
14020 test_AES_GCM_auth_decryption_test_case_256_4),
14021 TEST_CASE_ST(ut_setup, ut_teardown,
14022 test_AES_GCM_auth_decryption_test_case_256_5),
14023 TEST_CASE_ST(ut_setup, ut_teardown,
14024 test_AES_GCM_auth_decryption_test_case_256_6),
14025 TEST_CASE_ST(ut_setup, ut_teardown,
14026 test_AES_GCM_auth_decryption_test_case_256_7),
14028 /** AES GCM Authenticated Encryption big aad size */
14029 TEST_CASE_ST(ut_setup, ut_teardown,
14030 test_AES_GCM_auth_encryption_test_case_aad_1),
14031 TEST_CASE_ST(ut_setup, ut_teardown,
14032 test_AES_GCM_auth_encryption_test_case_aad_2),
14034 /** AES GCM Authenticated Decryption big aad size */
14035 TEST_CASE_ST(ut_setup, ut_teardown,
14036 test_AES_GCM_auth_decryption_test_case_aad_1),
14037 TEST_CASE_ST(ut_setup, ut_teardown,
14038 test_AES_GCM_auth_decryption_test_case_aad_2),
14040 /** Out of place tests */
14041 TEST_CASE_ST(ut_setup, ut_teardown,
14042 test_AES_GCM_authenticated_encryption_oop_test_case_1),
14043 TEST_CASE_ST(ut_setup, ut_teardown,
14044 test_AES_GCM_authenticated_decryption_oop_test_case_1),
14046 /** Session-less tests */
14047 TEST_CASE_ST(ut_setup, ut_teardown,
14048 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
14049 TEST_CASE_ST(ut_setup, ut_teardown,
14050 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
14056 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
14057 .suite_name = "AES GMAC Authentication Test Suite",
14058 .setup = aes_gmac_auth_testsuite_setup,
14059 .unit_test_cases = {
14060 TEST_CASE_ST(ut_setup, ut_teardown,
14061 test_AES_GMAC_authentication_test_case_1),
14062 TEST_CASE_ST(ut_setup, ut_teardown,
14063 test_AES_GMAC_authentication_verify_test_case_1),
14064 TEST_CASE_ST(ut_setup, ut_teardown,
14065 test_AES_GMAC_authentication_test_case_2),
14066 TEST_CASE_ST(ut_setup, ut_teardown,
14067 test_AES_GMAC_authentication_verify_test_case_2),
14068 TEST_CASE_ST(ut_setup, ut_teardown,
14069 test_AES_GMAC_authentication_test_case_3),
14070 TEST_CASE_ST(ut_setup, ut_teardown,
14071 test_AES_GMAC_authentication_verify_test_case_3),
14072 TEST_CASE_ST(ut_setup, ut_teardown,
14073 test_AES_GMAC_authentication_test_case_4),
14074 TEST_CASE_ST(ut_setup, ut_teardown,
14075 test_AES_GMAC_authentication_verify_test_case_4),
14076 TEST_CASE_ST(ut_setup, ut_teardown,
14077 test_AES_GMAC_authentication_SGL_40B),
14078 TEST_CASE_ST(ut_setup, ut_teardown,
14079 test_AES_GMAC_authentication_SGL_80B),
14080 TEST_CASE_ST(ut_setup, ut_teardown,
14081 test_AES_GMAC_authentication_SGL_2048B),
14082 TEST_CASE_ST(ut_setup, ut_teardown,
14083 test_AES_GMAC_authentication_SGL_2047B),
14089 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14090 .suite_name = "Chacha20-Poly1305 Test Suite",
14091 .setup = chacha20_poly1305_testsuite_setup,
14092 .unit_test_cases = {
14093 TEST_CASE_ST(ut_setup, ut_teardown,
14094 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14095 TEST_CASE_ST(ut_setup, ut_teardown,
14096 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14101 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14102 .suite_name = "SNOW 3G Test Suite",
14103 .setup = snow3g_testsuite_setup,
14104 .unit_test_cases = {
14105 /** SNOW 3G encrypt only (UEA2) */
14106 TEST_CASE_ST(ut_setup, ut_teardown,
14107 test_snow3g_encryption_test_case_1),
14108 TEST_CASE_ST(ut_setup, ut_teardown,
14109 test_snow3g_encryption_test_case_2),
14110 TEST_CASE_ST(ut_setup, ut_teardown,
14111 test_snow3g_encryption_test_case_3),
14112 TEST_CASE_ST(ut_setup, ut_teardown,
14113 test_snow3g_encryption_test_case_4),
14114 TEST_CASE_ST(ut_setup, ut_teardown,
14115 test_snow3g_encryption_test_case_5),
14117 TEST_CASE_ST(ut_setup, ut_teardown,
14118 test_snow3g_encryption_test_case_1_oop),
14119 TEST_CASE_ST(ut_setup, ut_teardown,
14120 test_snow3g_encryption_test_case_1_oop_sgl),
14121 TEST_CASE_ST(ut_setup, ut_teardown,
14122 test_snow3g_encryption_test_case_1_offset_oop),
14123 TEST_CASE_ST(ut_setup, ut_teardown,
14124 test_snow3g_decryption_test_case_1_oop),
14126 /** SNOW 3G generate auth, then encrypt (UEA2) */
14127 TEST_CASE_ST(ut_setup, ut_teardown,
14128 test_snow3g_auth_cipher_test_case_1),
14129 TEST_CASE_ST(ut_setup, ut_teardown,
14130 test_snow3g_auth_cipher_test_case_2),
14131 TEST_CASE_ST(ut_setup, ut_teardown,
14132 test_snow3g_auth_cipher_test_case_2_oop),
14133 TEST_CASE_ST(ut_setup, ut_teardown,
14134 test_snow3g_auth_cipher_part_digest_enc),
14135 TEST_CASE_ST(ut_setup, ut_teardown,
14136 test_snow3g_auth_cipher_part_digest_enc_oop),
14137 TEST_CASE_ST(ut_setup, ut_teardown,
14138 test_snow3g_auth_cipher_test_case_3_sgl),
14139 TEST_CASE_ST(ut_setup, ut_teardown,
14140 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14141 TEST_CASE_ST(ut_setup, ut_teardown,
14142 test_snow3g_auth_cipher_part_digest_enc_sgl),
14143 TEST_CASE_ST(ut_setup, ut_teardown,
14144 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14146 /** SNOW 3G decrypt (UEA2), then verify auth */
14147 TEST_CASE_ST(ut_setup, ut_teardown,
14148 test_snow3g_auth_cipher_verify_test_case_1),
14149 TEST_CASE_ST(ut_setup, ut_teardown,
14150 test_snow3g_auth_cipher_verify_test_case_2),
14151 TEST_CASE_ST(ut_setup, ut_teardown,
14152 test_snow3g_auth_cipher_verify_test_case_2_oop),
14153 TEST_CASE_ST(ut_setup, ut_teardown,
14154 test_snow3g_auth_cipher_verify_part_digest_enc),
14155 TEST_CASE_ST(ut_setup, ut_teardown,
14156 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14157 TEST_CASE_ST(ut_setup, ut_teardown,
14158 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14159 TEST_CASE_ST(ut_setup, ut_teardown,
14160 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14161 TEST_CASE_ST(ut_setup, ut_teardown,
14162 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14163 TEST_CASE_ST(ut_setup, ut_teardown,
14164 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14166 /** SNOW 3G decrypt only (UEA2) */
14167 TEST_CASE_ST(ut_setup, ut_teardown,
14168 test_snow3g_decryption_test_case_1),
14169 TEST_CASE_ST(ut_setup, ut_teardown,
14170 test_snow3g_decryption_test_case_2),
14171 TEST_CASE_ST(ut_setup, ut_teardown,
14172 test_snow3g_decryption_test_case_3),
14173 TEST_CASE_ST(ut_setup, ut_teardown,
14174 test_snow3g_decryption_test_case_4),
14175 TEST_CASE_ST(ut_setup, ut_teardown,
14176 test_snow3g_decryption_test_case_5),
14177 TEST_CASE_ST(ut_setup, ut_teardown,
14178 test_snow3g_decryption_with_digest_test_case_1),
14179 TEST_CASE_ST(ut_setup, ut_teardown,
14180 test_snow3g_hash_generate_test_case_1),
14181 TEST_CASE_ST(ut_setup, ut_teardown,
14182 test_snow3g_hash_generate_test_case_2),
14183 TEST_CASE_ST(ut_setup, ut_teardown,
14184 test_snow3g_hash_generate_test_case_3),
14186 /* Tests with buffers which length is not byte-aligned */
14187 TEST_CASE_ST(ut_setup, ut_teardown,
14188 test_snow3g_hash_generate_test_case_4),
14189 TEST_CASE_ST(ut_setup, ut_teardown,
14190 test_snow3g_hash_generate_test_case_5),
14191 TEST_CASE_ST(ut_setup, ut_teardown,
14192 test_snow3g_hash_generate_test_case_6),
14193 TEST_CASE_ST(ut_setup, ut_teardown,
14194 test_snow3g_hash_verify_test_case_1),
14195 TEST_CASE_ST(ut_setup, ut_teardown,
14196 test_snow3g_hash_verify_test_case_2),
14197 TEST_CASE_ST(ut_setup, ut_teardown,
14198 test_snow3g_hash_verify_test_case_3),
14200 /* Tests with buffers which length is not byte-aligned */
14201 TEST_CASE_ST(ut_setup, ut_teardown,
14202 test_snow3g_hash_verify_test_case_4),
14203 TEST_CASE_ST(ut_setup, ut_teardown,
14204 test_snow3g_hash_verify_test_case_5),
14205 TEST_CASE_ST(ut_setup, ut_teardown,
14206 test_snow3g_hash_verify_test_case_6),
14207 TEST_CASE_ST(ut_setup, ut_teardown,
14208 test_snow3g_cipher_auth_test_case_1),
14209 TEST_CASE_ST(ut_setup, ut_teardown,
14210 test_snow3g_auth_cipher_with_digest_test_case_1),
14215 static struct unit_test_suite cryptodev_zuc_testsuite = {
14216 .suite_name = "ZUC Test Suite",
14217 .setup = zuc_testsuite_setup,
14218 .unit_test_cases = {
14219 /** ZUC encrypt only (EEA3) */
14220 TEST_CASE_ST(ut_setup, ut_teardown,
14221 test_zuc_encryption_test_case_1),
14222 TEST_CASE_ST(ut_setup, ut_teardown,
14223 test_zuc_encryption_test_case_2),
14224 TEST_CASE_ST(ut_setup, ut_teardown,
14225 test_zuc_encryption_test_case_3),
14226 TEST_CASE_ST(ut_setup, ut_teardown,
14227 test_zuc_encryption_test_case_4),
14228 TEST_CASE_ST(ut_setup, ut_teardown,
14229 test_zuc_encryption_test_case_5),
14230 TEST_CASE_ST(ut_setup, ut_teardown,
14231 test_zuc_encryption_test_case_6_sgl),
14233 /** ZUC authenticate (EIA3) */
14234 TEST_CASE_ST(ut_setup, ut_teardown,
14235 test_zuc_hash_generate_test_case_1),
14236 TEST_CASE_ST(ut_setup, ut_teardown,
14237 test_zuc_hash_generate_test_case_2),
14238 TEST_CASE_ST(ut_setup, ut_teardown,
14239 test_zuc_hash_generate_test_case_3),
14240 TEST_CASE_ST(ut_setup, ut_teardown,
14241 test_zuc_hash_generate_test_case_4),
14242 TEST_CASE_ST(ut_setup, ut_teardown,
14243 test_zuc_hash_generate_test_case_5),
14244 TEST_CASE_ST(ut_setup, ut_teardown,
14245 test_zuc_hash_generate_test_case_6),
14246 TEST_CASE_ST(ut_setup, ut_teardown,
14247 test_zuc_hash_generate_test_case_7),
14248 TEST_CASE_ST(ut_setup, ut_teardown,
14249 test_zuc_hash_generate_test_case_8),
14251 /** ZUC alg-chain (EEA3/EIA3) */
14252 TEST_CASE_ST(ut_setup, ut_teardown,
14253 test_zuc_cipher_auth_test_case_1),
14254 TEST_CASE_ST(ut_setup, ut_teardown,
14255 test_zuc_cipher_auth_test_case_2),
14257 /** ZUC generate auth, then encrypt (EEA3) */
14258 TEST_CASE_ST(ut_setup, ut_teardown,
14259 test_zuc_auth_cipher_test_case_1),
14260 TEST_CASE_ST(ut_setup, ut_teardown,
14261 test_zuc_auth_cipher_test_case_1_oop),
14262 TEST_CASE_ST(ut_setup, ut_teardown,
14263 test_zuc_auth_cipher_test_case_1_sgl),
14264 TEST_CASE_ST(ut_setup, ut_teardown,
14265 test_zuc_auth_cipher_test_case_1_oop_sgl),
14267 /** ZUC decrypt (EEA3), then verify auth */
14268 TEST_CASE_ST(ut_setup, ut_teardown,
14269 test_zuc_auth_cipher_verify_test_case_1),
14270 TEST_CASE_ST(ut_setup, ut_teardown,
14271 test_zuc_auth_cipher_verify_test_case_1_oop),
14272 TEST_CASE_ST(ut_setup, ut_teardown,
14273 test_zuc_auth_cipher_verify_test_case_1_sgl),
14274 TEST_CASE_ST(ut_setup, ut_teardown,
14275 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14280 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14281 .suite_name = "HMAC_MD5 Authentication Test Suite",
14282 .setup = hmac_md5_auth_testsuite_setup,
14283 .unit_test_cases = {
14284 TEST_CASE_ST(ut_setup, ut_teardown,
14285 test_MD5_HMAC_generate_case_1),
14286 TEST_CASE_ST(ut_setup, ut_teardown,
14287 test_MD5_HMAC_verify_case_1),
14288 TEST_CASE_ST(ut_setup, ut_teardown,
14289 test_MD5_HMAC_generate_case_2),
14290 TEST_CASE_ST(ut_setup, ut_teardown,
14291 test_MD5_HMAC_verify_case_2),
14296 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14297 .suite_name = "Kasumi Test Suite",
14298 .setup = kasumi_testsuite_setup,
14299 .unit_test_cases = {
14300 /** KASUMI hash only (UIA1) */
14301 TEST_CASE_ST(ut_setup, ut_teardown,
14302 test_kasumi_hash_generate_test_case_1),
14303 TEST_CASE_ST(ut_setup, ut_teardown,
14304 test_kasumi_hash_generate_test_case_2),
14305 TEST_CASE_ST(ut_setup, ut_teardown,
14306 test_kasumi_hash_generate_test_case_3),
14307 TEST_CASE_ST(ut_setup, ut_teardown,
14308 test_kasumi_hash_generate_test_case_4),
14309 TEST_CASE_ST(ut_setup, ut_teardown,
14310 test_kasumi_hash_generate_test_case_5),
14311 TEST_CASE_ST(ut_setup, ut_teardown,
14312 test_kasumi_hash_generate_test_case_6),
14314 TEST_CASE_ST(ut_setup, ut_teardown,
14315 test_kasumi_hash_verify_test_case_1),
14316 TEST_CASE_ST(ut_setup, ut_teardown,
14317 test_kasumi_hash_verify_test_case_2),
14318 TEST_CASE_ST(ut_setup, ut_teardown,
14319 test_kasumi_hash_verify_test_case_3),
14320 TEST_CASE_ST(ut_setup, ut_teardown,
14321 test_kasumi_hash_verify_test_case_4),
14322 TEST_CASE_ST(ut_setup, ut_teardown,
14323 test_kasumi_hash_verify_test_case_5),
14325 /** KASUMI encrypt only (UEA1) */
14326 TEST_CASE_ST(ut_setup, ut_teardown,
14327 test_kasumi_encryption_test_case_1),
14328 TEST_CASE_ST(ut_setup, ut_teardown,
14329 test_kasumi_encryption_test_case_1_sgl),
14330 TEST_CASE_ST(ut_setup, ut_teardown,
14331 test_kasumi_encryption_test_case_1_oop),
14332 TEST_CASE_ST(ut_setup, ut_teardown,
14333 test_kasumi_encryption_test_case_1_oop_sgl),
14334 TEST_CASE_ST(ut_setup, ut_teardown,
14335 test_kasumi_encryption_test_case_2),
14336 TEST_CASE_ST(ut_setup, ut_teardown,
14337 test_kasumi_encryption_test_case_3),
14338 TEST_CASE_ST(ut_setup, ut_teardown,
14339 test_kasumi_encryption_test_case_4),
14340 TEST_CASE_ST(ut_setup, ut_teardown,
14341 test_kasumi_encryption_test_case_5),
14343 /** KASUMI decrypt only (UEA1) */
14344 TEST_CASE_ST(ut_setup, ut_teardown,
14345 test_kasumi_decryption_test_case_1),
14346 TEST_CASE_ST(ut_setup, ut_teardown,
14347 test_kasumi_decryption_test_case_2),
14348 TEST_CASE_ST(ut_setup, ut_teardown,
14349 test_kasumi_decryption_test_case_3),
14350 TEST_CASE_ST(ut_setup, ut_teardown,
14351 test_kasumi_decryption_test_case_4),
14352 TEST_CASE_ST(ut_setup, ut_teardown,
14353 test_kasumi_decryption_test_case_5),
14354 TEST_CASE_ST(ut_setup, ut_teardown,
14355 test_kasumi_decryption_test_case_1_oop),
14357 TEST_CASE_ST(ut_setup, ut_teardown,
14358 test_kasumi_cipher_auth_test_case_1),
14360 /** KASUMI generate auth, then encrypt (F8) */
14361 TEST_CASE_ST(ut_setup, ut_teardown,
14362 test_kasumi_auth_cipher_test_case_1),
14363 TEST_CASE_ST(ut_setup, ut_teardown,
14364 test_kasumi_auth_cipher_test_case_2),
14365 TEST_CASE_ST(ut_setup, ut_teardown,
14366 test_kasumi_auth_cipher_test_case_2_oop),
14367 TEST_CASE_ST(ut_setup, ut_teardown,
14368 test_kasumi_auth_cipher_test_case_2_sgl),
14369 TEST_CASE_ST(ut_setup, ut_teardown,
14370 test_kasumi_auth_cipher_test_case_2_oop_sgl),
14372 /** KASUMI decrypt (F8), then verify auth */
14373 TEST_CASE_ST(ut_setup, ut_teardown,
14374 test_kasumi_auth_cipher_verify_test_case_1),
14375 TEST_CASE_ST(ut_setup, ut_teardown,
14376 test_kasumi_auth_cipher_verify_test_case_2),
14377 TEST_CASE_ST(ut_setup, ut_teardown,
14378 test_kasumi_auth_cipher_verify_test_case_2_oop),
14379 TEST_CASE_ST(ut_setup, ut_teardown,
14380 test_kasumi_auth_cipher_verify_test_case_2_sgl),
14381 TEST_CASE_ST(ut_setup, ut_teardown,
14382 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14388 static struct unit_test_suite cryptodev_esn_testsuite = {
14389 .suite_name = "ESN Test Suite",
14390 .setup = esn_testsuite_setup,
14391 .unit_test_cases = {
14392 TEST_CASE_ST(ut_setup, ut_teardown,
14393 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14394 TEST_CASE_ST(ut_setup, ut_teardown,
14395 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14400 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
14401 .suite_name = "Negative AES GCM Test Suite",
14402 .setup = negative_aes_gcm_testsuite_setup,
14403 .unit_test_cases = {
14404 TEST_CASE_ST(ut_setup, ut_teardown,
14405 test_AES_GCM_auth_encryption_fail_iv_corrupt),
14406 TEST_CASE_ST(ut_setup, ut_teardown,
14407 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14408 TEST_CASE_ST(ut_setup, ut_teardown,
14409 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14410 TEST_CASE_ST(ut_setup, ut_teardown,
14411 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14412 TEST_CASE_ST(ut_setup, ut_teardown,
14413 test_AES_GCM_auth_encryption_fail_aad_corrupt),
14414 TEST_CASE_ST(ut_setup, ut_teardown,
14415 test_AES_GCM_auth_encryption_fail_tag_corrupt),
14416 TEST_CASE_ST(ut_setup, ut_teardown,
14417 test_AES_GCM_auth_decryption_fail_iv_corrupt),
14418 TEST_CASE_ST(ut_setup, ut_teardown,
14419 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
14420 TEST_CASE_ST(ut_setup, ut_teardown,
14421 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
14422 TEST_CASE_ST(ut_setup, ut_teardown,
14423 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
14424 TEST_CASE_ST(ut_setup, ut_teardown,
14425 test_AES_GCM_auth_decryption_fail_aad_corrupt),
14426 TEST_CASE_ST(ut_setup, ut_teardown,
14427 test_AES_GCM_auth_decryption_fail_tag_corrupt),
14433 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
14434 .suite_name = "Negative AES GMAC Test Suite",
14435 .setup = negative_aes_gmac_testsuite_setup,
14436 .unit_test_cases = {
14437 TEST_CASE_ST(ut_setup, ut_teardown,
14438 authentication_verify_AES128_GMAC_fail_data_corrupt),
14439 TEST_CASE_ST(ut_setup, ut_teardown,
14440 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14446 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
14447 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
14448 .setup = mixed_cipher_hash_testsuite_setup,
14449 .unit_test_cases = {
14450 /** AUTH AES CMAC + CIPHER AES CTR */
14451 TEST_CASE_ST(ut_setup, ut_teardown,
14452 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
14453 TEST_CASE_ST(ut_setup, ut_teardown,
14454 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14455 TEST_CASE_ST(ut_setup, ut_teardown,
14456 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14457 TEST_CASE_ST(ut_setup, ut_teardown,
14458 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14459 TEST_CASE_ST(ut_setup, ut_teardown,
14460 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
14461 TEST_CASE_ST(ut_setup, ut_teardown,
14462 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14463 TEST_CASE_ST(ut_setup, ut_teardown,
14464 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14465 TEST_CASE_ST(ut_setup, ut_teardown,
14466 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14468 /** AUTH ZUC + CIPHER SNOW3G */
14469 TEST_CASE_ST(ut_setup, ut_teardown,
14470 test_auth_zuc_cipher_snow_test_case_1),
14471 TEST_CASE_ST(ut_setup, ut_teardown,
14472 test_verify_auth_zuc_cipher_snow_test_case_1),
14473 /** AUTH AES CMAC + CIPHER SNOW3G */
14474 TEST_CASE_ST(ut_setup, ut_teardown,
14475 test_auth_aes_cmac_cipher_snow_test_case_1),
14476 TEST_CASE_ST(ut_setup, ut_teardown,
14477 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
14478 /** AUTH ZUC + CIPHER AES CTR */
14479 TEST_CASE_ST(ut_setup, ut_teardown,
14480 test_auth_zuc_cipher_aes_ctr_test_case_1),
14481 TEST_CASE_ST(ut_setup, ut_teardown,
14482 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
14483 /** AUTH SNOW3G + CIPHER AES CTR */
14484 TEST_CASE_ST(ut_setup, ut_teardown,
14485 test_auth_snow_cipher_aes_ctr_test_case_1),
14486 TEST_CASE_ST(ut_setup, ut_teardown,
14487 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
14488 /** AUTH SNOW3G + CIPHER ZUC */
14489 TEST_CASE_ST(ut_setup, ut_teardown,
14490 test_auth_snow_cipher_zuc_test_case_1),
14491 TEST_CASE_ST(ut_setup, ut_teardown,
14492 test_verify_auth_snow_cipher_zuc_test_case_1),
14493 /** AUTH AES CMAC + CIPHER ZUC */
14494 TEST_CASE_ST(ut_setup, ut_teardown,
14495 test_auth_aes_cmac_cipher_zuc_test_case_1),
14496 TEST_CASE_ST(ut_setup, ut_teardown,
14497 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
14499 /** AUTH NULL + CIPHER SNOW3G */
14500 TEST_CASE_ST(ut_setup, ut_teardown,
14501 test_auth_null_cipher_snow_test_case_1),
14502 TEST_CASE_ST(ut_setup, ut_teardown,
14503 test_verify_auth_null_cipher_snow_test_case_1),
14504 /** AUTH NULL + CIPHER ZUC */
14505 TEST_CASE_ST(ut_setup, ut_teardown,
14506 test_auth_null_cipher_zuc_test_case_1),
14507 TEST_CASE_ST(ut_setup, ut_teardown,
14508 test_verify_auth_null_cipher_zuc_test_case_1),
14509 /** AUTH SNOW3G + CIPHER NULL */
14510 TEST_CASE_ST(ut_setup, ut_teardown,
14511 test_auth_snow_cipher_null_test_case_1),
14512 TEST_CASE_ST(ut_setup, ut_teardown,
14513 test_verify_auth_snow_cipher_null_test_case_1),
14514 /** AUTH ZUC + CIPHER NULL */
14515 TEST_CASE_ST(ut_setup, ut_teardown,
14516 test_auth_zuc_cipher_null_test_case_1),
14517 TEST_CASE_ST(ut_setup, ut_teardown,
14518 test_verify_auth_zuc_cipher_null_test_case_1),
14519 /** AUTH NULL + CIPHER AES CTR */
14520 TEST_CASE_ST(ut_setup, ut_teardown,
14521 test_auth_null_cipher_aes_ctr_test_case_1),
14522 TEST_CASE_ST(ut_setup, ut_teardown,
14523 test_verify_auth_null_cipher_aes_ctr_test_case_1),
14524 /** AUTH AES CMAC + CIPHER NULL */
14525 TEST_CASE_ST(ut_setup, ut_teardown,
14526 test_auth_aes_cmac_cipher_null_test_case_1),
14527 TEST_CASE_ST(ut_setup, ut_teardown,
14528 test_verify_auth_aes_cmac_cipher_null_test_case_1),
14534 run_cryptodev_testsuite(const char *pmd_name)
14536 uint8_t ret, j, i = 0;
14537 struct unit_test_suite *static_suites[] = {
14538 &cryptodev_multi_session_testsuite,
14539 &cryptodev_null_testsuite,
14540 &cryptodev_aes_ccm_auth_testsuite,
14541 &cryptodev_aes_gcm_auth_testsuite,
14542 &cryptodev_aes_gmac_auth_testsuite,
14543 &cryptodev_snow3g_testsuite,
14544 &cryptodev_chacha20_poly1305_testsuite,
14545 &cryptodev_zuc_testsuite,
14546 &cryptodev_hmac_md5_auth_testsuite,
14547 &cryptodev_kasumi_testsuite,
14548 &cryptodev_esn_testsuite,
14549 &cryptodev_negative_aes_gcm_testsuite,
14550 &cryptodev_negative_aes_gmac_testsuite,
14551 &cryptodev_mixed_cipher_hash_testsuite,
14552 &cryptodev_negative_hmac_sha1_testsuite,
14553 &cryptodev_gen_testsuite,
14554 #ifdef RTE_LIB_SECURITY
14555 &pdcp_proto_testsuite,
14556 &docsis_proto_testsuite,
14560 static struct unit_test_suite ts = {
14561 .suite_name = "Cryptodev Unit Test Suite",
14562 .setup = testsuite_setup,
14563 .teardown = testsuite_teardown,
14564 .unit_test_cases = {TEST_CASES_END()}
14567 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
14569 if (gbl_driver_id == -1) {
14570 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
14571 return TEST_FAILED;
14574 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14575 RTE_DIM(static_suites));
14577 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14578 ret = unit_test_suite_runner(&ts);
14580 free(ts.unit_test_suites);
14585 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14587 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14591 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14593 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14597 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14599 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14603 test_cryptodev_cpu_aesni_mb(void)
14606 enum rte_security_session_action_type at = gbl_action_type;
14607 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14608 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14609 gbl_action_type = at;
14614 test_cryptodev_openssl(void)
14616 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14620 test_cryptodev_aesni_gcm(void)
14622 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14626 test_cryptodev_cpu_aesni_gcm(void)
14629 enum rte_security_session_action_type at = gbl_action_type;
14630 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14631 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14632 gbl_action_type = at;
14637 test_cryptodev_null(void)
14639 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14643 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14645 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14649 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14651 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14655 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14657 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14661 test_cryptodev_armv8(void)
14663 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14667 test_cryptodev_mrvl(void)
14669 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14672 #ifdef RTE_CRYPTO_SCHEDULER
14675 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14677 uint8_t ret, j, i = 0;
14678 static struct unit_test_suite scheduler_multicore = {
14679 .suite_name = "Scheduler Multicore Unit Test Suite",
14680 .setup = scheduler_multicore_testsuite_setup,
14681 .teardown = scheduler_mode_testsuite_teardown,
14682 .unit_test_cases = {
14683 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14684 TEST_CASE_ST(ut_setup, ut_teardown,
14685 test_AES_cipheronly_all),
14686 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14690 static struct unit_test_suite scheduler_round_robin = {
14691 .suite_name = "Scheduler Round Robin Unit Test Suite",
14692 .setup = scheduler_roundrobin_testsuite_setup,
14693 .teardown = scheduler_mode_testsuite_teardown,
14694 .unit_test_cases = {
14695 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14696 TEST_CASE_ST(ut_setup, ut_teardown,
14697 test_AES_cipheronly_all),
14698 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14702 static struct unit_test_suite scheduler_failover = {
14703 .suite_name = "Scheduler Failover Unit Test Suite",
14704 .setup = scheduler_failover_testsuite_setup,
14705 .teardown = scheduler_mode_testsuite_teardown,
14706 .unit_test_cases = {
14707 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14708 TEST_CASE_ST(ut_setup, ut_teardown,
14709 test_AES_cipheronly_all),
14710 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14714 static struct unit_test_suite scheduler_pkt_size_distr = {
14715 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
14716 .setup = scheduler_pkt_size_distr_testsuite_setup,
14717 .teardown = scheduler_mode_testsuite_teardown,
14718 .unit_test_cases = {
14719 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14720 TEST_CASE_ST(ut_setup, ut_teardown,
14721 test_AES_cipheronly_all),
14722 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14726 struct unit_test_suite *sched_mode_suites[] = {
14727 &scheduler_multicore,
14728 &scheduler_round_robin,
14729 &scheduler_failover,
14730 &scheduler_pkt_size_distr
14732 static struct unit_test_suite scheduler_config = {
14733 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
14734 .unit_test_cases = {
14735 TEST_CASE(test_scheduler_attach_slave_op),
14736 TEST_CASE(test_scheduler_mode_multicore_op),
14737 TEST_CASE(test_scheduler_mode_roundrobin_op),
14738 TEST_CASE(test_scheduler_mode_failover_op),
14739 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
14740 TEST_CASE(test_scheduler_detach_slave_op),
14742 TEST_CASES_END() /**< NULL terminate array */
14745 struct unit_test_suite *static_suites[] = {
14749 static struct unit_test_suite ts = {
14750 .suite_name = "Scheduler Unit Test Suite",
14751 .setup = scheduler_testsuite_setup,
14752 .teardown = testsuite_teardown,
14753 .unit_test_cases = {TEST_CASES_END()}
14756 gbl_driver_id = rte_cryptodev_driver_id_get(
14757 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14759 if (gbl_driver_id == -1) {
14760 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14761 return TEST_SKIPPED;
14764 if (rte_cryptodev_driver_id_get(
14765 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14766 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14767 return TEST_SKIPPED;
14770 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14771 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
14772 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
14773 RTE_DIM(sched_mode_suites));
14774 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14775 ret = unit_test_suite_runner(&ts);
14777 free(ts.unit_test_suites);
14781 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14786 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14788 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14792 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14794 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14798 test_cryptodev_ccp(void)
14800 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14804 test_cryptodev_octeontx(void)
14806 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14810 test_cryptodev_octeontx2(void)
14812 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14816 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14818 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14822 test_cryptodev_nitrox(void)
14824 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14828 test_cryptodev_bcmfs(void)
14830 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14834 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14838 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14839 ret = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14840 global_api_test_type = CRYPTODEV_API_TEST;
14845 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14846 test_cryptodev_qat_raw_api);
14847 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14848 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14849 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14850 test_cryptodev_cpu_aesni_mb);
14851 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14852 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14853 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14854 test_cryptodev_cpu_aesni_gcm);
14855 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14856 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14857 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14858 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14859 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14860 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14861 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14862 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14863 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14864 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14865 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14866 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14867 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14868 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14869 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);