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;
72 enum rte_crypto_sym_xform_type type;
74 enum rte_crypto_cipher_algorithm cipher;
75 enum rte_crypto_auth_algorithm auth;
76 enum rte_crypto_aead_algorithm aead;
80 uint16_t digest_length;
83 static const struct crypto_param aead_list[] = {
85 .type = RTE_CRYPTO_SYM_XFORM_AEAD,
86 .alg.aead = RTE_CRYPTO_AEAD_AES_GCM,
90 .type = RTE_CRYPTO_SYM_XFORM_AEAD,
91 .alg.aead = RTE_CRYPTO_AEAD_AES_GCM,
95 .type = RTE_CRYPTO_SYM_XFORM_AEAD,
96 .alg.aead = RTE_CRYPTO_AEAD_AES_GCM,
101 static const struct crypto_param cipher_list[] = {
103 .type = RTE_CRYPTO_SYM_XFORM_CIPHER,
104 .alg.cipher = RTE_CRYPTO_CIPHER_NULL,
109 .type = RTE_CRYPTO_SYM_XFORM_CIPHER,
110 .alg.cipher = RTE_CRYPTO_CIPHER_AES_CBC,
115 .type = RTE_CRYPTO_SYM_XFORM_CIPHER,
116 .alg.cipher = RTE_CRYPTO_CIPHER_AES_CTR,
121 .type = RTE_CRYPTO_SYM_XFORM_CIPHER,
122 .alg.cipher = RTE_CRYPTO_CIPHER_AES_CTR,
127 .type = RTE_CRYPTO_SYM_XFORM_CIPHER,
128 .alg.cipher = RTE_CRYPTO_CIPHER_AES_CTR,
134 static const struct crypto_param auth_list[] = {
136 .type = RTE_CRYPTO_SYM_XFORM_AUTH,
137 .alg.auth = RTE_CRYPTO_AUTH_NULL,
140 .type = RTE_CRYPTO_SYM_XFORM_AUTH,
141 .alg.auth = RTE_CRYPTO_AUTH_SHA256_HMAC,
146 .type = RTE_CRYPTO_SYM_XFORM_AUTH,
147 .alg.auth = RTE_CRYPTO_AUTH_SHA384_HMAC,
152 .type = RTE_CRYPTO_SYM_XFORM_AUTH,
153 .alg.auth = RTE_CRYPTO_AUTH_SHA512_HMAC,
158 .type = RTE_CRYPTO_SYM_XFORM_AUTH,
159 .alg.auth = RTE_CRYPTO_AUTH_AES_XCBC_MAC,
165 struct crypto_param_comb {
166 const struct crypto_param *param1;
167 const struct crypto_param *param2;
170 extern struct ipsec_test_data pkt_aes_256_gcm;
171 extern struct ipsec_test_data pkt_aes_256_gcm_v6;
172 extern struct ipsec_test_data pkt_aes_128_cbc_hmac_sha256;
173 extern struct ipsec_test_data pkt_aes_128_cbc_hmac_sha256_v6;
175 extern struct crypto_param_comb alg_list[RTE_DIM(aead_list) +
176 (RTE_DIM(cipher_list) *
177 RTE_DIM(auth_list))];
179 void test_ipsec_alg_list_populate(void);
181 int test_ipsec_sec_caps_verify(struct rte_security_ipsec_xform *ipsec_xform,
182 const struct rte_security_capability *sec_cap,
185 int test_ipsec_crypto_caps_aead_verify(
186 const struct rte_security_capability *sec_cap,
187 struct rte_crypto_sym_xform *aead);
189 int test_ipsec_crypto_caps_cipher_verify(
190 const struct rte_security_capability *sec_cap,
191 struct rte_crypto_sym_xform *cipher);
193 int test_ipsec_crypto_caps_auth_verify(
194 const struct rte_security_capability *sec_cap,
195 struct rte_crypto_sym_xform *auth);
197 void test_ipsec_td_in_from_out(const struct ipsec_test_data *td_out,
198 struct ipsec_test_data *td_in);
200 void test_ipsec_td_prepare(const struct crypto_param *param1,
201 const struct crypto_param *param2,
202 const struct ipsec_test_flags *flags,
203 struct ipsec_test_data *td_array,
206 void test_ipsec_td_update(struct ipsec_test_data td_inb[],
207 const struct ipsec_test_data td_outb[],
209 const struct ipsec_test_flags *flags);
211 void test_ipsec_display_alg(const struct crypto_param *param1,
212 const struct crypto_param *param2);
214 int test_ipsec_post_process(struct rte_mbuf *m,
215 const struct ipsec_test_data *td,
216 struct ipsec_test_data *res_d, bool silent,
217 const struct ipsec_test_flags *flags);
219 int test_ipsec_status_check(struct rte_crypto_op *op,
220 const struct ipsec_test_flags *flags,
221 enum rte_security_ipsec_sa_direction dir,
224 int test_ipsec_stats_verify(struct rte_security_ctx *ctx,
225 struct rte_security_session *sess,
226 const struct ipsec_test_flags *flags,
227 enum rte_security_ipsec_sa_direction dir);