10#if !defined(_OSSL_OPENSSL_MISSING_H_)
11#define _OSSL_OPENSSL_MISSING_H_
13#include "ruby/config.h"
16#if !defined(OPENSSL_NO_EC)
17#if !defined(HAVE_EC_CURVE_NIST2NID)
19# define EC_curve_nist2nid ossl_EC_curve_nist2nid
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))
28#if !defined(HAVE_X509_STORE_CTX_GET0_STORE)
29# define X509_STORE_CTX_get0_store(x) ((x)->ctx)
32#if !defined(HAVE_SSL_IS_SERVER)
33# define SSL_is_server(s) ((s)->server)
37#if !defined(HAVE_BN_GENCB_NEW)
38# define BN_GENCB_new() ((BN_GENCB *)OPENSSL_malloc(sizeof(BN_GENCB)))
41#if !defined(HAVE_BN_GENCB_FREE)
42# define BN_GENCB_free(cb) OPENSSL_free(cb)
45#if !defined(HAVE_BN_GENCB_GET_ARG)
46# define BN_GENCB_get_arg(cb) (cb)->arg
49#if !defined(HAVE_EVP_MD_CTX_NEW)
50# define EVP_MD_CTX_new EVP_MD_CTX_create
53#if !defined(HAVE_EVP_MD_CTX_FREE)
54# define EVP_MD_CTX_free EVP_MD_CTX_destroy
57#if !defined(HAVE_HMAC_CTX_NEW)
59# define HMAC_CTX_new ossl_HMAC_CTX_new
62#if !defined(HAVE_HMAC_CTX_FREE)
64# define HMAC_CTX_free ossl_HMAC_CTX_free
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))
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# define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \
76 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, (l), (p), \
77 (newf), (dupf), (freef))
80#if !defined(HAVE_X509_CRL_GET0_SIGNATURE)
82# define X509_CRL_get0_signature ossl_X509_CRL_get0_signature
85#if !defined(HAVE_X509_REQ_GET0_SIGNATURE)
87# define X509_REQ_get0_signature ossl_X509_REQ_get0_signature
90#if !defined(HAVE_X509_REVOKED_GET0_SERIALNUMBER)
91# define X509_REVOKED_get0_serialNumber(x) ((x)->serialNumber)
94#if !defined(HAVE_X509_REVOKED_GET0_REVOCATIONDATE)
95# define X509_REVOKED_get0_revocationDate(x) ((x)->revocationDate)
98#if !defined(HAVE_X509_GET0_TBS_SIGALG)
99# define X509_get0_tbs_sigalg(x) ((x)->cert_info->signature)
102#if !defined(HAVE_X509_STORE_CTX_GET0_UNTRUSTED)
103# define X509_STORE_CTX_get0_untrusted(x) ((x)->untrusted)
106#if !defined(HAVE_X509_STORE_CTX_GET0_CERT)
107# define X509_STORE_CTX_get0_cert(x) ((x)->cert)
110#if !defined(HAVE_X509_STORE_CTX_GET0_CHAIN)
111# define X509_STORE_CTX_get0_chain(ctx) X509_STORE_CTX_get_chain(ctx)
114#if !defined(HAVE_OCSP_SINGLERESP_GET0_ID)
115# define OCSP_SINGLERESP_get0_id(s) ((s)->certId)
118#if !defined(HAVE_SSL_CTX_GET_CIPHERS)
119# define SSL_CTX_get_ciphers(ctx) ((ctx)->cipher_list)
122#if !defined(HAVE_X509_UP_REF)
123# define X509_up_ref(x) \
124 CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_X509)
127#if !defined(HAVE_X509_CRL_UP_REF)
128# define X509_CRL_up_ref(x) \
129 CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_X509_CRL);
132#if !defined(HAVE_X509_STORE_UP_REF)
133# define X509_STORE_up_ref(x) \
134 CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_X509_STORE);
137#if !defined(HAVE_SSL_SESSION_UP_REF)
138# define SSL_SESSION_up_ref(x) \
139 CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_SSL_SESSION);
142#if !defined(HAVE_EVP_PKEY_UP_REF)
143# define EVP_PKEY_up_ref(x) \
144 CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_EVP_PKEY);
147#if !defined(HAVE_OPAQUE_OPENSSL)
148#define IMPL_PKEY_GETTER(_type, _name) \
149static inline _type *EVP_PKEY_get0_##_type(EVP_PKEY *pkey) { \
150 return pkey->pkey._name; }
151#define IMPL_KEY_ACCESSOR2(_type, _group, a1, a2, _fail_cond) \
152static inline void _type##_get0_##_group(const _type *obj, const BIGNUM **a1, const BIGNUM **a2) { \
153 if (a1) *a1 = obj->a1; \
154 if (a2) *a2 = obj->a2; } \
155static inline int _type##_set0_##_group(_type *obj, BIGNUM *a1, BIGNUM *a2) { \
156 if (_fail_cond) return 0; \
157 BN_clear_free(obj->a1); obj->a1 = a1; \
158 BN_clear_free(obj->a2); obj->a2 = a2; \
160#define IMPL_KEY_ACCESSOR3(_type, _group, a1, a2, a3, _fail_cond) \
161static inline void _type##_get0_##_group(const _type *obj, const BIGNUM **a1, const BIGNUM **a2, const BIGNUM **a3) { \
162 if (a1) *a1 = obj->a1; \
163 if (a2) *a2 = obj->a2; \
164 if (a3) *a3 = obj->a3; } \
165static inline int _type##_set0_##_group(_type *obj, BIGNUM *a1, BIGNUM *a2, BIGNUM *a3) { \
166 if (_fail_cond) return 0; \
167 BN_clear_free(obj->a1); obj->a1 = a1; \
168 BN_clear_free(obj->a2); obj->a2 = a2; \
169 BN_clear_free(obj->a3); obj->a3 = a3; \
172#if !defined(OPENSSL_NO_RSA)
179#if !defined(OPENSSL_NO_DSA)
185#if !defined(OPENSSL_NO_DH)
189static inline ENGINE *DH_get0_engine(DH *dh) {
return dh->engine; }
192#if !defined(OPENSSL_NO_EC)
196#undef IMPL_PKEY_GETTER
197#undef IMPL_KEY_ACCESSOR2
198#undef IMPL_KEY_ACCESSOR3
201#if !defined(EVP_CTRL_AEAD_GET_TAG)
202# define EVP_CTRL_AEAD_GET_TAG EVP_CTRL_GCM_GET_TAG
203# define EVP_CTRL_AEAD_SET_TAG EVP_CTRL_GCM_SET_TAG
204# define EVP_CTRL_AEAD_SET_IVLEN EVP_CTRL_GCM_SET_IVLEN
207#if !defined(HAVE_X509_GET0_NOTBEFORE)
208# define X509_get0_notBefore(x) X509_get_notBefore(x)
209# define X509_get0_notAfter(x) X509_get_notAfter(x)
210# define X509_CRL_get0_lastUpdate(x) X509_CRL_get_lastUpdate(x)
211# define X509_CRL_get0_nextUpdate(x) X509_CRL_get_nextUpdate(x)
212# define X509_set1_notBefore(x, t) X509_set_notBefore(x, t)
213# define X509_set1_notAfter(x, t) X509_set_notAfter(x, t)
214# define X509_CRL_set1_lastUpdate(x, t) X509_CRL_set_lastUpdate(x, t)
215# define X509_CRL_set1_nextUpdate(x, t) X509_CRL_set_nextUpdate(x, t)
218#if !defined(HAVE_SSL_SESSION_GET_PROTOCOL_VERSION)
219# define SSL_SESSION_get_protocol_version(s) ((s)->ssl_version)
#define IMPL_KEY_ACCESSOR2(_type, _group, a1, a2, _fail_cond)
void ossl_HMAC_CTX_free(HMAC_CTX *)
HMAC_CTX * ossl_HMAC_CTX_new(void)
#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)