Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
openssl_missing.h
Go to the documentation of this file.
1/*
2 * 'OpenSSL for Ruby' project
3 * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
4 * All rights reserved.
5 */
6/*
7 * This program is licensed under the same licence as Ruby.
8 * (See the file 'LICENCE'.)
9 */
10#if !defined(_OSSL_OPENSSL_MISSING_H_)
11#define _OSSL_OPENSSL_MISSING_H_
12
13#include "ruby/config.h"
14
15/* added in 1.0.2 */
16#if !defined(OPENSSL_NO_EC)
17#if !defined(HAVE_EC_CURVE_NIST2NID)
18int ossl_EC_curve_nist2nid(const char *);
19# define EC_curve_nist2nid ossl_EC_curve_nist2nid
20#endif
21#endif
22
23#if !defined(HAVE_X509_REVOKED_DUP)
24# define X509_REVOKED_dup(rev) (X509_REVOKED *)ASN1_dup((i2d_of_void *)i2d_X509_REVOKED, \
25 (d2i_of_void *)d2i_X509_REVOKED, (char *)(rev))
26#endif
27
28#if !defined(HAVE_X509_STORE_CTX_GET0_STORE)
29# define X509_STORE_CTX_get0_store(x) ((x)->ctx)
30#endif
31
32#if !defined(HAVE_SSL_IS_SERVER)
33# define SSL_is_server(s) ((s)->server)
34#endif
35
36/* added in 1.1.0 */
37#if !defined(HAVE_BN_GENCB_NEW)
38# define BN_GENCB_new() ((BN_GENCB *)OPENSSL_malloc(sizeof(BN_GENCB)))
39#endif
40
41#if !defined(HAVE_BN_GENCB_FREE)
42# define BN_GENCB_free(cb) OPENSSL_free(cb)
43#endif
44
45#if !defined(HAVE_BN_GENCB_GET_ARG)
46# define BN_GENCB_get_arg(cb) (cb)->arg
47#endif
48
49#if !defined(HAVE_EVP_MD_CTX_NEW)
50# define EVP_MD_CTX_new EVP_MD_CTX_create
51#endif
52
53#if !defined(HAVE_EVP_MD_CTX_FREE)
54# define EVP_MD_CTX_free EVP_MD_CTX_destroy
55#endif
56
57#if !defined(HAVE_HMAC_CTX_NEW)
58HMAC_CTX *ossl_HMAC_CTX_new(void);
59# define HMAC_CTX_new ossl_HMAC_CTX_new
60#endif
61
62#if !defined(HAVE_HMAC_CTX_FREE)
63void ossl_HMAC_CTX_free(HMAC_CTX *);
64# define HMAC_CTX_free ossl_HMAC_CTX_free
65#endif
66
67#if !defined(HAVE_X509_STORE_GET_EX_DATA)
68# define X509_STORE_get_ex_data(x, idx) \
69 CRYPTO_get_ex_data(&(x)->ex_data, (idx))
70#endif
71
72#if !defined(HAVE_X509_STORE_SET_EX_DATA)
73# define X509_STORE_set_ex_data(x, idx, data) \
74 CRYPTO_set_ex_data(&(x)->ex_data, (idx), (data))
75#endif
76
77#if !defined(HAVE_X509_STORE_GET_EX_NEW_INDEX) && !defined(X509_STORE_get_ex_new_index)
78# define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \
79 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, (l), (p), \
80 (newf), (dupf), (freef))
81#endif
82
83#if !defined(HAVE_X509_CRL_GET0_SIGNATURE)
84void ossl_X509_CRL_get0_signature(const X509_CRL *, const ASN1_BIT_STRING **, const X509_ALGOR **);
85# define X509_CRL_get0_signature ossl_X509_CRL_get0_signature
86#endif
87
88#if !defined(HAVE_X509_REQ_GET0_SIGNATURE)
89void ossl_X509_REQ_get0_signature(const X509_REQ *, const ASN1_BIT_STRING **, const X509_ALGOR **);
90# define X509_REQ_get0_signature ossl_X509_REQ_get0_signature
91#endif
92
93#if !defined(HAVE_X509_REVOKED_GET0_SERIALNUMBER)
94# define X509_REVOKED_get0_serialNumber(x) ((x)->serialNumber)
95#endif
96
97#if !defined(HAVE_X509_REVOKED_GET0_REVOCATIONDATE)
98# define X509_REVOKED_get0_revocationDate(x) ((x)->revocationDate)
99#endif
100
101#if !defined(HAVE_X509_GET0_TBS_SIGALG)
102# define X509_get0_tbs_sigalg(x) ((x)->cert_info->signature)
103#endif
104
105#if !defined(HAVE_X509_STORE_CTX_GET0_UNTRUSTED)
106# define X509_STORE_CTX_get0_untrusted(x) ((x)->untrusted)
107#endif
108
109#if !defined(HAVE_X509_STORE_CTX_GET0_CERT)
110# define X509_STORE_CTX_get0_cert(x) ((x)->cert)
111#endif
112
113#if !defined(HAVE_X509_STORE_CTX_GET0_CHAIN)
114# define X509_STORE_CTX_get0_chain(ctx) X509_STORE_CTX_get_chain(ctx)
115#endif
116
117#if !defined(HAVE_OCSP_SINGLERESP_GET0_ID)
118# define OCSP_SINGLERESP_get0_id(s) ((s)->certId)
119#endif
120
121#if !defined(HAVE_SSL_CTX_GET_CIPHERS)
122# define SSL_CTX_get_ciphers(ctx) ((ctx)->cipher_list)
123#endif
124
125#if !defined(HAVE_X509_UP_REF)
126# define X509_up_ref(x) \
127 CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_X509)
128#endif
129
130#if !defined(HAVE_X509_CRL_UP_REF)
131# define X509_CRL_up_ref(x) \
132 CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_X509_CRL);
133#endif
134
135#if !defined(HAVE_X509_STORE_UP_REF)
136# define X509_STORE_up_ref(x) \
137 CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_X509_STORE);
138#endif
139
140#if !defined(HAVE_SSL_SESSION_UP_REF)
141# define SSL_SESSION_up_ref(x) \
142 CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_SSL_SESSION);
143#endif
144
145#if !defined(HAVE_EVP_PKEY_UP_REF)
146# define EVP_PKEY_up_ref(x) \
147 CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_EVP_PKEY);
148#endif
149
150#if !defined(HAVE_OPAQUE_OPENSSL) && \
151 (!defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER < 0x2070000fL)
152#define IMPL_PKEY_GETTER(_type, _name) \
153static inline _type *EVP_PKEY_get0_##_type(EVP_PKEY *pkey) { \
154 return pkey->pkey._name; }
155#define IMPL_KEY_ACCESSOR2(_type, _group, a1, a2, _fail_cond) \
156static inline void _type##_get0_##_group(const _type *obj, const BIGNUM **a1, const BIGNUM **a2) { \
157 if (a1) *a1 = obj->a1; \
158 if (a2) *a2 = obj->a2; } \
159static inline int _type##_set0_##_group(_type *obj, BIGNUM *a1, BIGNUM *a2) { \
160 if (_fail_cond) return 0; \
161 BN_clear_free(obj->a1); obj->a1 = a1; \
162 BN_clear_free(obj->a2); obj->a2 = a2; \
163 return 1; }
164#define IMPL_KEY_ACCESSOR3(_type, _group, a1, a2, a3, _fail_cond) \
165static inline void _type##_get0_##_group(const _type *obj, const BIGNUM **a1, const BIGNUM **a2, const BIGNUM **a3) { \
166 if (a1) *a1 = obj->a1; \
167 if (a2) *a2 = obj->a2; \
168 if (a3) *a3 = obj->a3; } \
169static inline int _type##_set0_##_group(_type *obj, BIGNUM *a1, BIGNUM *a2, BIGNUM *a3) { \
170 if (_fail_cond) return 0; \
171 BN_clear_free(obj->a1); obj->a1 = a1; \
172 BN_clear_free(obj->a2); obj->a2 = a2; \
173 BN_clear_free(obj->a3); obj->a3 = a3; \
174 return 1; }
175
176#if !defined(OPENSSL_NO_RSA)
177IMPL_PKEY_GETTER(RSA, rsa)
178IMPL_KEY_ACCESSOR3(RSA, key, n, e, d, (n == obj->n || e == obj->e || (obj->d && d == obj->d)))
179IMPL_KEY_ACCESSOR2(RSA, factors, p, q, (p == obj->p || q == obj->q))
180IMPL_KEY_ACCESSOR3(RSA, crt_params, dmp1, dmq1, iqmp, (dmp1 == obj->dmp1 || dmq1 == obj->dmq1 || iqmp == obj->iqmp))
181#endif
182
183#if !defined(OPENSSL_NO_DSA)
184IMPL_PKEY_GETTER(DSA, dsa)
186IMPL_KEY_ACCESSOR3(DSA, pqg, p, q, g, (p == obj->p || q == obj->q || g == obj->g))
187#endif
188
189#if !defined(OPENSSL_NO_DH)
190IMPL_PKEY_GETTER(DH, dh)
191IMPL_KEY_ACCESSOR2(DH, key, pub_key, priv_key, (pub_key == obj->pub_key || (obj->priv_key && priv_key == obj->priv_key)))
192IMPL_KEY_ACCESSOR3(DH, pqg, p, q, g, (p == obj->p || (obj->q && q == obj->q) || g == obj->g))
193static inline ENGINE *DH_get0_engine(DH *dh) { return dh->engine; }
194#endif
195
196#if !defined(OPENSSL_NO_EC)
197IMPL_PKEY_GETTER(EC_KEY, ec)
198#endif
199
200#undef IMPL_PKEY_GETTER
201#undef IMPL_KEY_ACCESSOR2
202#undef IMPL_KEY_ACCESSOR3
203#endif /* HAVE_OPAQUE_OPENSSL */
204
205#if !defined(EVP_CTRL_AEAD_GET_TAG)
206# define EVP_CTRL_AEAD_GET_TAG EVP_CTRL_GCM_GET_TAG
207# define EVP_CTRL_AEAD_SET_TAG EVP_CTRL_GCM_SET_TAG
208# define EVP_CTRL_AEAD_SET_IVLEN EVP_CTRL_GCM_SET_IVLEN
209#endif
210
211#if !defined(HAVE_X509_GET0_NOTBEFORE)
212# define X509_get0_notBefore(x) X509_get_notBefore(x)
213# define X509_get0_notAfter(x) X509_get_notAfter(x)
214# define X509_CRL_get0_lastUpdate(x) X509_CRL_get_lastUpdate(x)
215# define X509_CRL_get0_nextUpdate(x) X509_CRL_get_nextUpdate(x)
216# define X509_set1_notBefore(x, t) X509_set_notBefore(x, t)
217# define X509_set1_notAfter(x, t) X509_set_notAfter(x, t)
218# define X509_CRL_set1_lastUpdate(x, t) X509_CRL_set_lastUpdate(x, t)
219# define X509_CRL_set1_nextUpdate(x, t) X509_CRL_set_nextUpdate(x, t)
220#endif
221
222#if !defined(HAVE_SSL_SESSION_GET_PROTOCOL_VERSION)
223# define SSL_SESSION_get_protocol_version(s) ((s)->ssl_version)
224#endif
225
226#if !defined(HAVE_TS_STATUS_INFO_GET0_STATUS)
227# define TS_STATUS_INFO_get0_status(a) ((a)->status)
228#endif
229
230#if !defined(HAVE_TS_STATUS_INFO_GET0_TEXT)
231# define TS_STATUS_INFO_get0_text(a) ((a)->text)
232#endif
233
234#if !defined(HAVE_TS_STATUS_INFO_GET0_FAILURE_INFO)
235# define TS_STATUS_INFO_get0_failure_info(a) ((a)->failure_info)
236#endif
237
238#if !defined(HAVE_TS_VERIFY_CTS_SET_CERTS)
239# define TS_VERIFY_CTS_set_certs(ctx, crts) ((ctx)->certs=(crts))
240#endif
241
242#if !defined(HAVE_TS_VERIFY_CTX_SET_STORE)
243# define TS_VERIFY_CTX_set_store(ctx, str) ((ctx)->store=(str))
244#endif
245
246#if !defined(HAVE_TS_VERIFY_CTX_ADD_FLAGS)
247# define TS_VERIFY_CTX_add_flags(ctx, f) ((ctx)->flags |= (f))
248#endif
249
250#if !defined(HAVE_TS_RESP_CTX_SET_TIME_CB)
251# define TS_RESP_CTX_set_time_cb(ctx, callback, dta) do { \
252 (ctx)->time_cb = (callback); \
253 (ctx)->time_cb_data = (dta); \
254 } while (0)
255#endif
256
257#endif /* _OSSL_OPENSSL_MISSING_H_ */
struct @77 g
priv_key
#define IMPL_KEY_ACCESSOR2(_type, _group, a1, a2, _fail_cond)
void ossl_HMAC_CTX_free(HMAC_CTX *)
HMAC_CTX * ossl_HMAC_CTX_new(void)
pub_key
#define IMPL_PKEY_GETTER(_type, _name)
void ossl_X509_CRL_get0_signature(const X509_CRL *, const ASN1_BIT_STRING **, const X509_ALGOR **)
void ossl_X509_REQ_get0_signature(const X509_REQ *, const ASN1_BIT_STRING **, const X509_ALGOR **)
int ossl_EC_curve_nist2nid(const char *)
#define IMPL_KEY_ACCESSOR3(_type, _group, a1, a2, a3, _fail_cond)