Grid Community Toolkit  6.2.1705709074 (tag: v6.2.20240202)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
openssl-compat.h
1 /*
2  * Copyright (c) 2005 Darren Tucker <[email protected]>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef _OPENSSL_COMPAT_H
18 #define _OPENSSL_COMPAT_H
19 
20 #include "includes.h"
21 #ifdef WITH_OPENSSL
22 
23 #include <openssl/opensslv.h>
24 #include <openssl/crypto.h>
25 #include <openssl/evp.h>
26 #include <openssl/rsa.h>
27 #include <openssl/dsa.h>
28 #ifdef OPENSSL_HAS_ECC
29 #include <openssl/ecdsa.h>
30 #endif
31 #include <openssl/dh.h>
32 
33 int ssh_compatible_openssl(long, long);
34 void ssh_libcrypto_init(void);
35 
36 #if (OPENSSL_VERSION_NUMBER < 0x1000100fL)
37 # error OpenSSL 1.0.1 or greater is required
38 #endif
39 
40 #ifndef OPENSSL_VERSION
41 # define OPENSSL_VERSION SSLEAY_VERSION
42 #endif
43 
44 #ifndef HAVE_OPENSSL_VERSION
45 # define OpenSSL_version(x) SSLeay_version(x)
46 #endif
47 
48 #ifndef HAVE_OPENSSL_VERSION_NUM
49 # define OpenSSL_version_num SSLeay
50 #endif
51 
52 #if OPENSSL_VERSION_NUMBER < 0x10000001L
53 # define LIBCRYPTO_EVP_INL_TYPE unsigned int
54 #else
55 # define LIBCRYPTO_EVP_INL_TYPE size_t
56 #endif
57 
58 #ifndef OPENSSL_RSA_MAX_MODULUS_BITS
59 # define OPENSSL_RSA_MAX_MODULUS_BITS 16384
60 #endif
61 #ifndef OPENSSL_DSA_MAX_MODULUS_BITS
62 # define OPENSSL_DSA_MAX_MODULUS_BITS 10000
63 #endif
64 
65 #ifdef LIBRESSL_VERSION_NUMBER
66 # if LIBRESSL_VERSION_NUMBER < 0x3010000fL
67 # define HAVE_BROKEN_CHACHA20
68 # endif
69 #endif
70 
71 /* LibreSSL/OpenSSL 1.1x API compat */
72 #ifndef HAVE_DSA_GET0_PQG
73 void DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q,
74  const BIGNUM **g);
75 #endif /* HAVE_DSA_GET0_PQG */
76 
77 #ifndef HAVE_DSA_SET0_PQG
78 int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g);
79 #endif /* HAVE_DSA_SET0_PQG */
80 
81 #ifndef HAVE_DSA_GET0_KEY
82 void DSA_get0_key(const DSA *d, const BIGNUM **pub_key,
83  const BIGNUM **priv_key);
84 #endif /* HAVE_DSA_GET0_KEY */
85 
86 #ifndef HAVE_DSA_SET0_KEY
87 int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key);
88 #endif /* HAVE_DSA_SET0_KEY */
89 
90 #ifndef HAVE_EVP_CIPHER_CTX_GET_IV
91 # ifdef HAVE_EVP_CIPHER_CTX_GET_UPDATED_IV
92 # define EVP_CIPHER_CTX_get_iv EVP_CIPHER_CTX_get_updated_iv
93 # else /* HAVE_EVP_CIPHER_CTX_GET_UPDATED_IV */
94 int EVP_CIPHER_CTX_get_iv(const EVP_CIPHER_CTX *ctx,
95  unsigned char *iv, size_t len);
96 # endif /* HAVE_EVP_CIPHER_CTX_GET_UPDATED_IV */
97 #endif /* HAVE_EVP_CIPHER_CTX_GET_IV */
98 
99 #ifndef HAVE_EVP_CIPHER_CTX_SET_IV
100 int EVP_CIPHER_CTX_set_iv(EVP_CIPHER_CTX *ctx,
101  const unsigned char *iv, size_t len);
102 #endif /* HAVE_EVP_CIPHER_CTX_SET_IV */
103 
104 #ifndef HAVE_RSA_GET0_KEY
105 void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e,
106  const BIGNUM **d);
107 #endif /* HAVE_RSA_GET0_KEY */
108 
109 #ifndef HAVE_RSA_SET0_KEY
110 int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
111 #endif /* HAVE_RSA_SET0_KEY */
112 
113 #ifndef HAVE_RSA_GET0_CRT_PARAMS
114 void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1,
115  const BIGNUM **iqmp);
116 #endif /* HAVE_RSA_GET0_CRT_PARAMS */
117 
118 #ifndef HAVE_RSA_SET0_CRT_PARAMS
119 int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
120 #endif /* HAVE_RSA_SET0_CRT_PARAMS */
121 
122 #ifndef HAVE_RSA_GET0_FACTORS
123 void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
124 #endif /* HAVE_RSA_GET0_FACTORS */
125 
126 #ifndef HAVE_RSA_SET0_FACTORS
127 int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
128 #endif /* HAVE_RSA_SET0_FACTORS */
129 
130 #ifndef DSA_SIG_GET0
131 void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
132 #endif /* DSA_SIG_GET0 */
133 
134 #ifndef DSA_SIG_SET0
135 int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);
136 #endif /* DSA_SIG_SET0 */
137 
138 #ifdef OPENSSL_HAS_ECC
139 #ifndef HAVE_ECDSA_SIG_GET0
140 void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
141 #endif /* HAVE_ECDSA_SIG_GET0 */
142 
143 #ifndef HAVE_ECDSA_SIG_SET0
144 int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s);
145 #endif /* HAVE_ECDSA_SIG_SET0 */
146 #endif /* OPENSSL_HAS_ECC */
147 
148 #ifndef HAVE_DH_GET0_PQG
149 void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q,
150  const BIGNUM **g);
151 #endif /* HAVE_DH_GET0_PQG */
152 
153 #ifndef HAVE_DH_SET0_PQG
154 int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);
155 #endif /* HAVE_DH_SET0_PQG */
156 
157 #ifndef HAVE_DH_GET0_KEY
158 void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key);
159 #endif /* HAVE_DH_GET0_KEY */
160 
161 #ifndef HAVE_DH_SET0_KEY
162 int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key);
163 #endif /* HAVE_DH_SET0_KEY */
164 
165 #ifndef HAVE_DH_SET_LENGTH
166 int DH_set_length(DH *dh, long length);
167 #endif /* HAVE_DH_SET_LENGTH */
168 
169 #ifndef HAVE_RSA_METH_FREE
170 void RSA_meth_free(RSA_METHOD *meth);
171 #endif /* HAVE_RSA_METH_FREE */
172 
173 #ifndef HAVE_RSA_METH_DUP
174 RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
175 #endif /* HAVE_RSA_METH_DUP */
176 
177 #ifndef HAVE_RSA_METH_SET1_NAME
178 int RSA_meth_set1_name(RSA_METHOD *meth, const char *name);
179 #endif /* HAVE_RSA_METH_SET1_NAME */
180 
181 #ifndef HAVE_RSA_METH_GET_FINISH
182 int (*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa);
183 #endif /* HAVE_RSA_METH_GET_FINISH */
184 
185 #ifndef HAVE_RSA_METH_SET_PRIV_ENC
186 int RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc)(int flen,
187  const unsigned char *from, unsigned char *to, RSA *rsa, int padding));
188 #endif /* HAVE_RSA_METH_SET_PRIV_ENC */
189 
190 #ifndef HAVE_RSA_METH_SET_PRIV_DEC
191 int RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec)(int flen,
192  const unsigned char *from, unsigned char *to, RSA *rsa, int padding));
193 #endif /* HAVE_RSA_METH_SET_PRIV_DEC */
194 
195 #ifndef HAVE_RSA_METH_SET_FINISH
196 int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa));
197 #endif /* HAVE_RSA_METH_SET_FINISH */
198 
199 #ifndef HAVE_EVP_PKEY_GET0_RSA
200 RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);
201 #endif /* HAVE_EVP_PKEY_GET0_RSA */
202 
203 #ifndef HAVE_EVP_MD_CTX_new
204 EVP_MD_CTX *EVP_MD_CTX_new(void);
205 #endif /* HAVE_EVP_MD_CTX_new */
206 
207 #ifndef HAVE_EVP_MD_CTX_free
208 void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
209 #endif /* HAVE_EVP_MD_CTX_free */
210 
211 #endif /* WITH_OPENSSL */
212 #endif /* _OPENSSL_COMPAT_H */