1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
5 #ifndef _TEST_CRYPTODEV_SECURITY_IPSEC_H_
6 #define _TEST_CRYPTODEV_SECURITY_IPSEC_H_
8 #include <rte_cryptodev.h>
9 #include <rte_security.h>
11 #define IPSEC_TEST_PACKETS_MAX 32
13 struct ipsec_test_data {
40 struct rte_security_ipsec_xform ipsec_xform;
46 struct rte_crypto_sym_xform cipher;
47 struct rte_crypto_sym_xform auth;
49 struct rte_crypto_sym_xform aead;
53 struct ipsec_test_flags {
55 bool sa_expiry_pkts_soft;
56 bool sa_expiry_pkts_hard;
59 uint32_t tunnel_hdr_verify;
61 bool udp_ports_verify;
69 enum rte_crypto_sym_xform_type type;
71 enum rte_crypto_cipher_algorithm cipher;
72 enum rte_crypto_auth_algorithm auth;
73 enum rte_crypto_aead_algorithm aead;
76 uint16_t digest_length;
79 static const struct crypto_param aead_list[] = {
81 .type = RTE_CRYPTO_SYM_XFORM_AEAD,
82 .alg.aead = RTE_CRYPTO_AEAD_AES_GCM,
86 .type = RTE_CRYPTO_SYM_XFORM_AEAD,
87 .alg.aead = RTE_CRYPTO_AEAD_AES_GCM,
91 .type = RTE_CRYPTO_SYM_XFORM_AEAD,
92 .alg.aead = RTE_CRYPTO_AEAD_AES_GCM,
97 static const struct crypto_param cipher_list[] = {
99 .type = RTE_CRYPTO_SYM_XFORM_CIPHER,
100 .alg.cipher = RTE_CRYPTO_CIPHER_AES_CBC,
105 static const struct crypto_param auth_list[] = {
107 .type = RTE_CRYPTO_SYM_XFORM_AUTH,
108 .alg.auth = RTE_CRYPTO_AUTH_NULL,
111 .type = RTE_CRYPTO_SYM_XFORM_AUTH,
112 .alg.auth = RTE_CRYPTO_AUTH_SHA256_HMAC,
118 struct crypto_param_comb {
119 const struct crypto_param *param1;
120 const struct crypto_param *param2;
123 extern struct ipsec_test_data pkt_aes_256_gcm;
124 extern struct ipsec_test_data pkt_aes_256_gcm_v6;
125 extern struct ipsec_test_data pkt_aes_128_cbc_hmac_sha256;
126 extern struct ipsec_test_data pkt_aes_128_cbc_hmac_sha256_v6;
128 extern struct crypto_param_comb alg_list[RTE_DIM(aead_list) +
129 (RTE_DIM(cipher_list) *
130 RTE_DIM(auth_list))];
132 void test_ipsec_alg_list_populate(void);
134 int test_ipsec_sec_caps_verify(struct rte_security_ipsec_xform *ipsec_xform,
135 const struct rte_security_capability *sec_cap,
138 int test_ipsec_crypto_caps_aead_verify(
139 const struct rte_security_capability *sec_cap,
140 struct rte_crypto_sym_xform *aead);
142 int test_ipsec_crypto_caps_cipher_verify(
143 const struct rte_security_capability *sec_cap,
144 struct rte_crypto_sym_xform *cipher);
146 int test_ipsec_crypto_caps_auth_verify(
147 const struct rte_security_capability *sec_cap,
148 struct rte_crypto_sym_xform *auth);
150 void test_ipsec_td_in_from_out(const struct ipsec_test_data *td_out,
151 struct ipsec_test_data *td_in);
153 void test_ipsec_td_prepare(const struct crypto_param *param1,
154 const struct crypto_param *param2,
155 const struct ipsec_test_flags *flags,
156 struct ipsec_test_data *td_array,
159 void test_ipsec_td_update(struct ipsec_test_data td_inb[],
160 const struct ipsec_test_data td_outb[],
162 const struct ipsec_test_flags *flags);
164 void test_ipsec_display_alg(const struct crypto_param *param1,
165 const struct crypto_param *param2);
167 int test_ipsec_post_process(struct rte_mbuf *m,
168 const struct ipsec_test_data *td,
169 struct ipsec_test_data *res_d, bool silent,
170 const struct ipsec_test_flags *flags);
172 int test_ipsec_status_check(struct rte_crypto_op *op,
173 const struct ipsec_test_flags *flags,
174 enum rte_security_ipsec_sa_direction dir,