1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Cavium Networks
5 #ifndef __RTA_COMPAT_H__
6 #define __RTA_COMPAT_H__
8 #if (OPENSSL_VERSION_NUMBER < 0x10100000L)
10 static __rte_always_inline int
11 set_rsa_params(RSA *rsa, BIGNUM *p, BIGNUM *q)
18 static __rte_always_inline int
19 set_rsa_crt_params(RSA *rsa, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp)
27 static __rte_always_inline int
28 set_rsa_keys(RSA *rsa, BIGNUM *n, BIGNUM *e, BIGNUM *d)
36 static __rte_always_inline int
37 set_dh_params(DH *dh, BIGNUM *p, BIGNUM *g)
45 static __rte_always_inline int
46 set_dh_priv_key(DH *dh, BIGNUM *priv_key)
48 dh->priv_key = priv_key;
52 static __rte_always_inline int
53 set_dsa_params(DSA *dsa, BIGNUM *p, BIGNUM *q, BIGNUM *g)
61 static __rte_always_inline void
62 get_dh_pub_key(DH *dh, const BIGNUM **pub_key)
64 *pub_key = dh->pub_key;
67 static __rte_always_inline void
68 get_dh_priv_key(DH *dh, const BIGNUM **priv_key)
70 *priv_key = dh->priv_key;
73 static __rte_always_inline void
74 set_dsa_sign(DSA_SIG *sign, BIGNUM *r, BIGNUM *s)
80 static __rte_always_inline void
81 get_dsa_sign(DSA_SIG *sign, const BIGNUM **r, const BIGNUM **s)
87 static __rte_always_inline int
88 set_dsa_keys(DSA *dsa, BIGNUM *pub, BIGNUM *priv)
95 static __rte_always_inline void
96 set_dsa_pub_key(DSA *dsa, BIGNUM *pub)
101 static __rte_always_inline void
102 get_dsa_priv_key(DSA *dsa, BIGNUM **priv_key)
104 *priv_key = dsa->priv_key;
109 static __rte_always_inline int
110 set_rsa_params(RSA *rsa, BIGNUM *p, BIGNUM *q)
112 return !(RSA_set0_factors(rsa, p, q));
115 static __rte_always_inline int
116 set_rsa_crt_params(RSA *rsa, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp)
118 return !(RSA_set0_crt_params(rsa, dmp1, dmq1, iqmp));
121 /* n, e must be non-null, d can be NULL */
123 static __rte_always_inline int
124 set_rsa_keys(RSA *rsa, BIGNUM *n, BIGNUM *e, BIGNUM *d)
126 return !(RSA_set0_key(rsa, n, e, d));
129 static __rte_always_inline int
130 set_dh_params(DH *dh, BIGNUM *p, BIGNUM *g)
132 return !(DH_set0_pqg(dh, p, NULL, g));
135 static __rte_always_inline int
136 set_dh_priv_key(DH *dh, BIGNUM *priv_key)
138 return !(DH_set0_key(dh, NULL, priv_key));
141 static __rte_always_inline void
142 get_dh_pub_key(DH *dh_key, const BIGNUM **pub_key)
144 DH_get0_key(dh_key, pub_key, NULL);
147 static __rte_always_inline void
148 get_dh_priv_key(DH *dh_key, const BIGNUM **priv_key)
150 DH_get0_key(dh_key, NULL, priv_key);
153 static __rte_always_inline int
154 set_dsa_params(DSA *dsa, BIGNUM *p, BIGNUM *q, BIGNUM *g)
156 return !(DSA_set0_pqg(dsa, p, q, g));
159 static __rte_always_inline void
160 set_dsa_priv_key(DSA *dsa, BIGNUM *priv_key)
162 DSA_set0_key(dsa, NULL, priv_key);
165 static __rte_always_inline void
166 set_dsa_sign(DSA_SIG *sign, BIGNUM *r, BIGNUM *s)
168 DSA_SIG_set0(sign, r, s);
171 static __rte_always_inline void
172 get_dsa_sign(DSA_SIG *sign, const BIGNUM **r, const BIGNUM **s)
174 DSA_SIG_get0(sign, r, s);
177 static __rte_always_inline int
178 set_dsa_keys(DSA *dsa, BIGNUM *pub, BIGNUM *priv)
180 return !(DSA_set0_key(dsa, pub, priv));
183 static __rte_always_inline void
184 set_dsa_pub_key(DSA *dsa, BIGNUM *pub_key)
186 DSA_set0_key(dsa, pub_key, NULL);
189 static __rte_always_inline void
190 get_dsa_priv_key(DSA *dsa, const BIGNUM **priv_key)
192 DSA_get0_key(dsa, NULL, priv_key);
195 #endif /* version < 10100000 */
197 #endif /* __RTA_COMPAT_H__ */