1 | // Copyright (C) 2019 The Qt Company Ltd. |
2 | // Copyright (C) 2014 BlackBerry Limited. All rights reserved. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | /**************************************************************************** |
6 | ** |
7 | ** In addition, as a special exception, the copyright holders listed above give |
8 | ** permission to link the code of its release of Qt with the OpenSSL project's |
9 | ** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the |
10 | ** same license as the original version), and distribute the linked executables. |
11 | ** |
12 | ** You must comply with the GNU General Public License version 2 in all |
13 | ** respects for all of the code used other than the "OpenSSL" code. If you |
14 | ** modify this file, you may extend this exception to your version of the file, |
15 | ** but you are not obligated to do so. If you do not wish to do so, delete |
16 | ** this exception statement from your version of this file. |
17 | ** |
18 | ****************************************************************************/ |
19 | |
20 | #ifndef OPENSSL_SYMBOLS_P_H |
21 | #define OPENSSL_SYMBOLS_P_H |
22 | |
23 | #include <openssl/asn1.h> |
24 | #include <openssl/bio.h> |
25 | #include <openssl/bn.h> |
26 | #include <openssl/err.h> |
27 | #include <openssl/evp.h> |
28 | #include <openssl/pem.h> |
29 | #include <openssl/pkcs12.h> |
30 | #include <openssl/pkcs7.h> |
31 | #include <openssl/rand.h> |
32 | #include <openssl/ssl.h> |
33 | #include <openssl/stack.h> |
34 | #include <openssl/x509.h> |
35 | #include <openssl/x509v3.h> |
36 | #include <openssl/x509_vfy.h> |
37 | #include <openssl/dsa.h> |
38 | #include <openssl/rsa.h> |
39 | #include <openssl/crypto.h> |
40 | #include <openssl/tls1.h> |
41 | |
42 | // |
43 | // W A R N I N G |
44 | // ------------- |
45 | // |
46 | // This file is not part of the Qt API. It exists purely as an |
47 | // implementation detail. This header file may change from version to |
48 | // version without notice, or even be removed. |
49 | // |
50 | // We mean it. |
51 | // |
52 | |
53 | #include <QtNetwork/private/qtnetworkglobal_p.h> |
54 | #include <QtCore/QLoggingCategory> |
55 | |
56 | #ifdef Q_OS_WIN |
57 | #include <qt_windows.h> |
58 | #if defined(X509_NAME) |
59 | #undef X509_NAME |
60 | #endif |
61 | #endif // Q_OS_WIN |
62 | |
63 | #include <QtCore/qglobal.h> |
64 | |
65 | QT_BEGIN_NAMESPACE |
66 | |
67 | Q_DECLARE_LOGGING_CATEGORY(lcSsl) |
68 | |
69 | #define DUMMYARG |
70 | |
71 | #if !defined QT_LINKED_OPENSSL |
72 | // **************** Shared declarations ****************** |
73 | // ret func(arg) |
74 | |
75 | # define DEFINEFUNC(ret, func, arg, a, err, funcret) \ |
76 | typedef ret (*_q_PTR_##func)(arg); \ |
77 | static _q_PTR_##func _q_##func = 0; \ |
78 | ret q_##func(arg) { \ |
79 | if (Q_UNLIKELY(!_q_##func)) { \ |
80 | qsslSocketUnresolvedSymbolWarning(#func); \ |
81 | err; \ |
82 | } \ |
83 | funcret _q_##func(a); \ |
84 | } |
85 | |
86 | // ret func(arg1, arg2) |
87 | # define DEFINEFUNC2(ret, func, arg1, a, arg2, b, err, funcret) \ |
88 | typedef ret (*_q_PTR_##func)(arg1, arg2); \ |
89 | static _q_PTR_##func _q_##func = 0; \ |
90 | ret q_##func(arg1, arg2) { \ |
91 | if (Q_UNLIKELY(!_q_##func)) { \ |
92 | qsslSocketUnresolvedSymbolWarning(#func);\ |
93 | err; \ |
94 | } \ |
95 | funcret _q_##func(a, b); \ |
96 | } |
97 | |
98 | // ret func(arg1, arg2, arg3) |
99 | # define DEFINEFUNC3(ret, func, arg1, a, arg2, b, arg3, c, err, funcret) \ |
100 | typedef ret (*_q_PTR_##func)(arg1, arg2, arg3); \ |
101 | static _q_PTR_##func _q_##func = 0; \ |
102 | ret q_##func(arg1, arg2, arg3) { \ |
103 | if (Q_UNLIKELY(!_q_##func)) { \ |
104 | qsslSocketUnresolvedSymbolWarning(#func); \ |
105 | err; \ |
106 | } \ |
107 | funcret _q_##func(a, b, c); \ |
108 | } |
109 | |
110 | // ret func(arg1, arg2, arg3, arg4) |
111 | # define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret) \ |
112 | typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4); \ |
113 | static _q_PTR_##func _q_##func = 0; \ |
114 | ret q_##func(arg1, arg2, arg3, arg4) { \ |
115 | if (Q_UNLIKELY(!_q_##func)) { \ |
116 | qsslSocketUnresolvedSymbolWarning(#func); \ |
117 | err; \ |
118 | } \ |
119 | funcret _q_##func(a, b, c, d); \ |
120 | } |
121 | |
122 | // ret func(arg1, arg2, arg3, arg4, arg5) |
123 | # define DEFINEFUNC5(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, err, funcret) \ |
124 | typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5); \ |
125 | static _q_PTR_##func _q_##func = 0; \ |
126 | ret q_##func(arg1, arg2, arg3, arg4, arg5) { \ |
127 | if (Q_UNLIKELY(!_q_##func)) { \ |
128 | qsslSocketUnresolvedSymbolWarning(#func); \ |
129 | err; \ |
130 | } \ |
131 | funcret _q_##func(a, b, c, d, e); \ |
132 | } |
133 | |
134 | // ret func(arg1, arg2, arg3, arg4, arg6) |
135 | # define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret) \ |
136 | typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6); \ |
137 | static _q_PTR_##func _q_##func = 0; \ |
138 | ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { \ |
139 | if (Q_UNLIKELY(!_q_##func)) { \ |
140 | qsslSocketUnresolvedSymbolWarning(#func); \ |
141 | err; \ |
142 | } \ |
143 | funcret _q_##func(a, b, c, d, e, f); \ |
144 | } |
145 | |
146 | // ret func(arg1, arg2, arg3, arg4, arg6, arg7) |
147 | # define DEFINEFUNC7(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, err, funcret) \ |
148 | typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ |
149 | static _q_PTR_##func _q_##func = 0; \ |
150 | ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \ |
151 | if (Q_UNLIKELY(!_q_##func)) { \ |
152 | qsslSocketUnresolvedSymbolWarning(#func); \ |
153 | err; \ |
154 | } \ |
155 | funcret _q_##func(a, b, c, d, e, f, g); \ |
156 | } |
157 | |
158 | // ret func(arg1, arg2, arg3, arg4, arg6, arg7, arg8, arg9) |
159 | # define DEFINEFUNC9(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, arg8, h, arg9, i, err, funcret) \ |
160 | typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ |
161 | static _q_PTR_##func _q_##func = 0; \ |
162 | ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { \ |
163 | if (Q_UNLIKELY(!_q_##func)) { \ |
164 | qsslSocketUnresolvedSymbolWarning(#func); \ |
165 | err; \ |
166 | } \ |
167 | funcret _q_##func(a, b, c, d, e, f, g, h, i); \ |
168 | } |
169 | // **************** Shared declarations ****************** |
170 | |
171 | #else // !defined QT_LINKED_OPENSSL |
172 | |
173 | // **************** Static declarations ****************** |
174 | |
175 | // ret func(arg) |
176 | # define DEFINEFUNC(ret, func, arg, a, err, funcret) \ |
177 | ret q_##func(arg) { funcret func(a); } |
178 | |
179 | // ret func(arg1, arg2) |
180 | # define DEFINEFUNC2(ret, func, arg1, a, arg2, b, err, funcret) \ |
181 | ret q_##func(arg1, arg2) { funcret func(a, b); } |
182 | |
183 | // ret func(arg1, arg2, arg3) |
184 | # define DEFINEFUNC3(ret, func, arg1, a, arg2, b, arg3, c, err, funcret) \ |
185 | ret q_##func(arg1, arg2, arg3) { funcret func(a, b, c); } |
186 | |
187 | // ret func(arg1, arg2, arg3, arg4) |
188 | # define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret) \ |
189 | ret q_##func(arg1, arg2, arg3, arg4) { funcret func(a, b, c, d); } |
190 | |
191 | // ret func(arg1, arg2, arg3, arg4, arg5) |
192 | # define DEFINEFUNC5(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, err, funcret) \ |
193 | ret q_##func(arg1, arg2, arg3, arg4, arg5) { funcret func(a, b, c, d, e); } |
194 | |
195 | // ret func(arg1, arg2, arg3, arg4, arg6) |
196 | # define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret) \ |
197 | ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { funcret func(a, b, c, d, e, f); } |
198 | |
199 | // ret func(arg1, arg2, arg3, arg4, arg6, arg7) |
200 | # define DEFINEFUNC7(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, err, funcret) \ |
201 | ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { funcret func(a, b, c, d, e, f, g); } |
202 | |
203 | // ret func(arg1, arg2, arg3, arg4, arg6, arg7, arg8, arg9) |
204 | # define DEFINEFUNC9(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, arg8, h, arg9, i, err, funcret) \ |
205 | ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { funcret func(a, b, c, d, e, f, g, h, i); } |
206 | |
207 | // **************** Static declarations ****************** |
208 | |
209 | #endif // !defined QT_LINKED_OPENSSL |
210 | |
211 | #if QT_CONFIG(opensslv11) | QT_CONFIG(opensslv30) |
212 | #include "qsslsocket_openssl11_symbols_p.h" |
213 | #else |
214 | #include "qsslsocket_opensslpre11_symbols_p.h" |
215 | #endif // QT_CONFIG |
216 | |
217 | bool q_resolveOpenSslSymbols(); |
218 | long q_ASN1_INTEGER_get(ASN1_INTEGER *a); |
219 | int q_ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y); |
220 | int q_ASN1_STRING_length(ASN1_STRING *a); |
221 | int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b); |
222 | long q_BIO_ctrl(BIO *a, int b, long c, void *d); |
223 | Q_AUTOTEST_EXPORT int q_BIO_free(BIO *a); |
224 | void q_BIO_free_all(BIO *a); |
225 | BIO *q_BIO_new_mem_buf(void *a, int b); |
226 | int q_BIO_read(BIO *a, void *b, int c); |
227 | Q_AUTOTEST_EXPORT int q_BIO_write(BIO *a, const void *b, int c); |
228 | int q_BN_num_bits(const BIGNUM *a); |
229 | |
230 | #if QT_CONFIG(opensslv11) | QT_CONFIG(opensslv30) |
231 | int q_BN_is_word(BIGNUM *a, BN_ULONG w); |
232 | #else // opensslv11 |
233 | // BN_is_word is implemented purely as a |
234 | // macro in OpenSSL < 1.1. It doesn't |
235 | // call any functions. |
236 | // |
237 | // The implementation of BN_is_word is |
238 | // 100% the same between 1.0.0, 1.0.1 |
239 | // and 1.0.2. |
240 | // |
241 | // Users are required to include <openssl/bn.h>. |
242 | #define q_BN_is_word BN_is_word |
243 | #endif // !opensslv11 |
244 | |
245 | BN_ULONG q_BN_mod_word(const BIGNUM *a, BN_ULONG w); |
246 | int q_BN_set_word(const BIGNUM *a, BN_ULONG w); |
247 | BIGNUM *q_BN_new(); |
248 | void q_BN_clear(BIGNUM *a); |
249 | void q_BN_free(BIGNUM *a); |
250 | void q_BN_clear_free(BIGNUM *a); |
251 | |
252 | #ifndef OPENSSL_NO_EC |
253 | const EC_GROUP* q_EC_KEY_get0_group(const EC_KEY* k); |
254 | int q_EC_GROUP_get_degree(const EC_GROUP* g); |
255 | #endif |
256 | DSA *q_DSA_new(); |
257 | void q_DSA_free(DSA *a); |
258 | X509 *q_d2i_X509(X509 **a, const unsigned char **b, long c); |
259 | char *q_ERR_error_string(unsigned long a, char *b); |
260 | void q_ERR_error_string_n(unsigned long e, char *buf, size_t len); |
261 | unsigned long q_ERR_get_error(); |
262 | EVP_CIPHER_CTX *q_EVP_CIPHER_CTX_new(); |
263 | void q_EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a); |
264 | int q_EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); |
265 | int q_EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); |
266 | int q_EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, const unsigned char *key, const unsigned char *iv, int enc); |
267 | int q_EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const unsigned char *key, const unsigned char *iv, int enc); |
268 | int q_EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl); |
269 | int q_EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); |
270 | const EVP_MD *q_EVP_get_digestbyname(const char *name); |
271 | X509_REQ *q_X509_REQ_new(); |
272 | void q_X509_REQ_free(X509_REQ *req); |
273 | int q_PEM_write_bio_X509_REQ(BIO *bp, X509_REQ *x); |
274 | int q_PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x); |
275 | int q_X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); |
276 | void q_X509_EXTENSION_free(X509_EXTENSION *ext); |
277 | int q_X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); |
278 | ASN1_INTEGER *q_ASN1_INTEGER_dup(const ASN1_INTEGER *x); |
279 | |
280 | #if QT_CONFIG(opensslv11) | QT_CONFIG(opensslv30) |
281 | X509_NAME *q_X509_REQ_get_subject_name(X509_REQ *req); |
282 | #define q_ERR_load_crypto_strings() \ |
283 | q_OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) |
284 | #else // opensslv11 |
285 | void q_ERR_load_crypto_strings(); |
286 | #define q_X509_REQ_get_subject_name X509_REQ_get_subject_name |
287 | #define q_X509_get_notBefore X509_get_notBefore |
288 | #define q_X509_get_notAfter X509_get_notAfter |
289 | #endif // !opensslv11 |
290 | |
291 | |
292 | int q_X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, const unsigned char *bytes, int len, int loc, int set); |
293 | int q_X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, const unsigned char *bytes, int len, int loc, int set); |
294 | ASN1_OBJECT *q_OBJ_txt2obj(const char *s, int no_name); |
295 | int q_X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); |
296 | int q_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); |
297 | int q_X509_REQ_set_version(X509_REQ *x, long version); |
298 | X509_EXTENSION *q_X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, int ext_nid, char *value); |
299 | |
300 | #ifndef OPENSSL_NO_DES |
301 | const EVP_CIPHER *q_EVP_des_cbc(); |
302 | const EVP_CIPHER *q_EVP_des_ede3_cbc(); |
303 | #endif |
304 | const EVP_CIPHER *q_EVP_aes_256_gcm(); |
305 | const EVP_CIPHER *q_EVP_aes_128_cbc(); |
306 | Q_AUTOTEST_EXPORT const EVP_MD *q_EVP_sha1(); |
307 | const EVP_MD *q_EVP_sha256(); |
308 | int q_EVP_PKEY_assign(EVP_PKEY *a, int b, char *c); |
309 | Q_AUTOTEST_EXPORT int q_EVP_PKEY_set1_RSA(EVP_PKEY *a, RSA *b); |
310 | int q_EVP_PKEY_set1_DSA(EVP_PKEY *a, DSA *b); |
311 | int q_EVP_PKEY_set1_DH(EVP_PKEY *a, DH *b); |
312 | #ifndef OPENSSL_NO_EC |
313 | int q_EVP_PKEY_set1_EC_KEY(EVP_PKEY *a, EC_KEY *b); |
314 | #endif |
315 | Q_AUTOTEST_EXPORT void q_EVP_PKEY_free(EVP_PKEY *a); |
316 | RSA *q_EVP_PKEY_get1_RSA(EVP_PKEY *a); |
317 | DSA *q_EVP_PKEY_get1_DSA(EVP_PKEY *a); |
318 | DH *q_EVP_PKEY_get1_DH(EVP_PKEY *a); |
319 | #ifndef OPENSSL_NO_EC |
320 | EC_KEY *q_EVP_PKEY_get1_EC_KEY(EVP_PKEY *a); |
321 | #endif |
322 | int q_EVP_PKEY_type(int a); |
323 | Q_AUTOTEST_EXPORT EVP_PKEY *q_EVP_PKEY_new(); |
324 | int q_i2d_X509(X509 *a, unsigned char **b); |
325 | const char *q_OBJ_nid2sn(int a); |
326 | const char *q_OBJ_nid2ln(int a); |
327 | int q_OBJ_sn2nid(const char *s); |
328 | int q_OBJ_ln2nid(const char *s); |
329 | int q_i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *obj); |
330 | int q_OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *obj, int no_name); |
331 | int q_OBJ_obj2nid(const ASN1_OBJECT *a); |
332 | #define q_EVP_get_digestbynid(a) q_EVP_get_digestbyname(q_OBJ_nid2sn(a)) |
333 | #ifdef SSLEAY_MACROS |
334 | // ### verify |
335 | void *q_PEM_ASN1_read_bio(d2i_of_void *a, const char *b, BIO *c, void **d, pem_password_cb *e, |
336 | void *f); |
337 | // ### ditto for write |
338 | #else |
339 | Q_AUTOTEST_EXPORT EVP_PKEY *q_PEM_read_bio_PrivateKey(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d); |
340 | DSA *q_PEM_read_bio_DSAPrivateKey(BIO *a, DSA **b, pem_password_cb *c, void *d); |
341 | RSA *q_PEM_read_bio_RSAPrivateKey(BIO *a, RSA **b, pem_password_cb *c, void *d); |
342 | #ifndef OPENSSL_NO_EC |
343 | EC_KEY *q_PEM_read_bio_ECPrivateKey(BIO *a, EC_KEY **b, pem_password_cb *c, void *d); |
344 | #endif |
345 | DH *q_PEM_read_bio_DHparams(BIO *a, DH **b, pem_password_cb *c, void *d); |
346 | int q_PEM_write_bio_DSAPrivateKey(BIO *a, DSA *b, const EVP_CIPHER *c, unsigned char *d, |
347 | int e, pem_password_cb *f, void *g); |
348 | int q_PEM_write_bio_RSAPrivateKey(BIO *a, RSA *b, const EVP_CIPHER *c, unsigned char *d, |
349 | int e, pem_password_cb *f, void *g); |
350 | int q_PEM_write_bio_PrivateKey(BIO *a, EVP_PKEY *b, const EVP_CIPHER *c, unsigned char *d, |
351 | int e, pem_password_cb *f, void *g); |
352 | int q_PEM_write_bio_PKCS8PrivateKey(BIO *a, EVP_PKEY *b, const EVP_CIPHER *c, char *d, |
353 | int e, pem_password_cb *f, void *g); |
354 | #ifndef OPENSSL_NO_EC |
355 | int q_PEM_write_bio_ECPrivateKey(BIO *a, EC_KEY *b, const EVP_CIPHER *c, unsigned char *d, |
356 | int e, pem_password_cb *f, void *g); |
357 | #endif |
358 | #endif // SSLEAY_MACROS |
359 | Q_AUTOTEST_EXPORT EVP_PKEY *q_PEM_read_bio_PUBKEY(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d); |
360 | DSA *q_PEM_read_bio_DSA_PUBKEY(BIO *a, DSA **b, pem_password_cb *c, void *d); |
361 | RSA *q_PEM_read_bio_RSA_PUBKEY(BIO *a, RSA **b, pem_password_cb *c, void *d); |
362 | #ifndef OPENSSL_NO_EC |
363 | EC_KEY *q_PEM_read_bio_EC_PUBKEY(BIO *a, EC_KEY **b, pem_password_cb *c, void *d); |
364 | #endif |
365 | int q_PEM_write_bio_DSA_PUBKEY(BIO *a, DSA *b); |
366 | int q_PEM_write_bio_RSA_PUBKEY(BIO *a, RSA *b); |
367 | int q_PEM_write_bio_PUBKEY(BIO *a, EVP_PKEY *b); |
368 | #ifndef OPENSSL_NO_EC |
369 | int q_PEM_write_bio_EC_PUBKEY(BIO *a, EC_KEY *b); |
370 | #endif |
371 | void q_RAND_seed(const void *a, int b); |
372 | int q_RAND_status(); |
373 | int q_RAND_bytes(unsigned char *b, int n); |
374 | RSA *q_RSA_new(); |
375 | void q_RSA_free(RSA *a); |
376 | int q_RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); |
377 | #if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK) |
378 | typedef unsigned int (*q_psk_client_callback_t)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len); |
379 | void q_SSL_set_psk_client_callback(SSL *ssl, q_psk_client_callback_t callback); |
380 | typedef unsigned int (*q_psk_server_callback_t)(SSL *ssl, const char *identity, unsigned char *psk, unsigned int max_psk_len); |
381 | #endif // OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK) |
382 | int q_SSL_write(SSL *a, const void *b, int c); |
383 | int q_X509_cmp(X509 *a, X509 *b); |
384 | #ifdef SSLEAY_MACROS |
385 | void *q_ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x); |
386 | #define q_X509_dup(x509) (X509 *)q_ASN1_dup((i2d_of_void *)q_i2d_X509, \ |
387 | (d2i_of_void *)q_d2i_X509,(char *)x509) |
388 | #else |
389 | X509 *q_X509_dup(X509 *a); |
390 | #endif |
391 | void q_X509_print(BIO *a, X509*b); |
392 | int q_X509_digest(const X509 *x509, const EVP_MD *type, unsigned char *md, unsigned int *len); |
393 | ASN1_OBJECT *q_X509_EXTENSION_get_object(X509_EXTENSION *a); |
394 | Q_AUTOTEST_EXPORT void q_X509_free(X509 *a); |
395 | Q_AUTOTEST_EXPORT ASN1_TIME *q_X509_gmtime_adj(ASN1_TIME *s, long adj); |
396 | Q_AUTOTEST_EXPORT void q_ASN1_TIME_free(ASN1_TIME *t); |
397 | X509_EXTENSION *q_X509_get_ext(X509 *a, int b); |
398 | int q_X509_get_ext_count(X509 *a); |
399 | void *q_X509_get_ext_d2i(X509 *a, int b, int *c, int *d); |
400 | const X509V3_EXT_METHOD *q_X509V3_EXT_get(X509_EXTENSION *a); |
401 | void *q_X509V3_EXT_d2i(X509_EXTENSION *a); |
402 | int q_X509_EXTENSION_get_critical(X509_EXTENSION *a); |
403 | ASN1_OCTET_STRING *q_X509_EXTENSION_get_data(X509_EXTENSION *a); |
404 | void q_BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a); |
405 | void q_AUTHORITY_KEYID_free(AUTHORITY_KEYID *a); |
406 | int q_ASN1_STRING_print(BIO *a, const ASN1_STRING *b); |
407 | int q_X509_check_issued(X509 *a, X509 *b); |
408 | X509_NAME *q_X509_get_issuer_name(X509 *a); |
409 | X509_NAME *q_X509_get_subject_name(X509 *a); |
410 | ASN1_INTEGER *q_X509_get_serialNumber(X509 *a); |
411 | int q_X509_verify_cert(X509_STORE_CTX *ctx); |
412 | int q_X509_NAME_entry_count(X509_NAME *a); |
413 | X509_NAME_ENTRY *q_X509_NAME_get_entry(X509_NAME *a,int b); |
414 | ASN1_STRING *q_X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *a); |
415 | ASN1_OBJECT *q_X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *a); |
416 | EVP_PKEY *q_X509_PUBKEY_get(X509_PUBKEY *a); |
417 | void q_X509_STORE_free(X509_STORE *store); |
418 | X509_STORE *q_X509_STORE_new(); |
419 | int q_X509_STORE_add_cert(X509_STORE *ctx, X509 *x); |
420 | void q_X509_STORE_CTX_free(X509_STORE_CTX *storeCtx); |
421 | int q_X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, |
422 | X509 *x509, STACK_OF(X509) *chain); |
423 | X509_STORE_CTX *q_X509_STORE_CTX_new(); |
424 | int q_X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); |
425 | int q_X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); |
426 | int q_X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); |
427 | X509 *q_X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); |
428 | X509 *q_X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey); |
429 | int q_PEM_write_bio_X509(BIO *bp, X509 *x); |
430 | X509 *q_X509_new(); |
431 | int q_ASN1_INTEGER_set(ASN1_INTEGER *a, long v); |
432 | int q_X509_set_pubkey(X509 *x, EVP_PKEY *key); |
433 | int q_X509_set_issuer_name(X509 *x, X509_NAME *name); |
434 | int q_X509_sign(X509 *x, EVP_PKEY *key, const EVP_MD *md); |
435 | int q_X509_add_ext(X509 *x, X509_EXTENSION *ex, int location); |
436 | int q_X509_set_version(X509 *x, long version); |
437 | int q_X509_set_subject_name(X509 *x, X509_NAME *name); |
438 | ASN1_OCTET_STRING *q_ASN1_OCTET_STRING_new(); |
439 | int q_X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len); |
440 | int q_ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len); |
441 | int q_X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, unsigned long flags); |
442 | void q_ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *a); |
443 | int q_X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, unsigned char *md, unsigned int *len); |
444 | ASN1_INTEGER *q_ASN1_INTEGER_new(); |
445 | GENERAL_NAMES *q_GENERAL_NAMES_new(); |
446 | GENERAL_NAME *q_GENERAL_NAME_new(); |
447 | X509_NAME *q_X509_NAME_dup(X509_NAME *xn); |
448 | int q_X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); |
449 | AUTHORITY_KEYID *q_AUTHORITY_KEYID_new(); |
450 | void q_ASN1_INTEGER_free(ASN1_INTEGER *a); |
451 | int q_i2d_X509_REQ_bio(BIO *bp, X509_REQ *req); |
452 | int q_i2d_X509_bio(BIO *bp, X509 *x509); |
453 | |
454 | // Diffie-Hellman support |
455 | DH *q_DH_new(); |
456 | void q_DH_free(DH *dh); |
457 | DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length); |
458 | int q_i2d_DHparams(DH *a, unsigned char **p); |
459 | int q_DH_check(DH *dh, int *codes); |
460 | |
461 | BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); |
462 | |
463 | #ifndef OPENSSL_NO_EC |
464 | // EC Diffie-Hellman support |
465 | EC_KEY *q_EC_KEY_dup(const EC_KEY *src); |
466 | EC_KEY *q_EC_KEY_new_by_curve_name(int nid); |
467 | void q_EC_KEY_free(EC_KEY *ecdh); |
468 | |
469 | // EC curves management |
470 | size_t q_EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); |
471 | #if OPENSSL_VERSION_NUMBER >= 0x10002000L |
472 | int q_EC_curve_nist2nid(const char *name); |
473 | #endif // OPENSSL_VERSION_NUMBER >= 0x10002000L |
474 | #endif // OPENSSL_NO_EC |
475 | #if OPENSSL_VERSION_NUMBER >= 0x10002000L |
476 | #define q_SSL_get_server_tmp_key(ssl, key) q_SSL_ctrl((ssl), SSL_CTRL_GET_SERVER_TMP_KEY, 0, (char *)key) |
477 | #endif // OPENSSL_VERSION_NUMBER >= 0x10002000L |
478 | |
479 | // PKCS#12 support |
480 | int q_PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca); |
481 | PKCS12 *q_d2i_PKCS12_bio(BIO *bio, PKCS12 **pkcs12); |
482 | void q_PKCS12_free(PKCS12 *pkcs12); |
483 | |
484 | #define q_BIO_get_mem_data(b, pp) (int)q_BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) |
485 | #define q_BIO_pending(b) (int)q_BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) |
486 | #define q_SSL_CTX_set_mode(ctx,op) q_SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL) |
487 | #define q_sk_GENERAL_NAME_num(st) q_SKM_sk_num(GENERAL_NAME, (st)) |
488 | #define q_sk_GENERAL_NAME_value(st, i) q_SKM_sk_value(GENERAL_NAME, (st), (i)) |
489 | #if QT_CONFIG(opensslv11) | QT_CONFIG(opensslv30) |
490 | #define q_sk_GENERAL_NAME_push(st, val) q_OPENSSL_sk_push((st), (val)) |
491 | #else |
492 | #define q_sk_GENERAL_NAME_push(st, val) q_SKM_sk_push(GENERAL_NAME, (st), (val)) |
493 | #endif |
494 | |
495 | void q_GENERAL_NAME_free(GENERAL_NAME *a); |
496 | |
497 | #define q_sk_X509_num(st) q_SKM_sk_num(X509, (st)) |
498 | #define q_sk_X509_value(st, i) q_SKM_sk_value(X509, (st), (i)) |
499 | #define q_sk_SSL_CIPHER_num(st) q_SKM_sk_num(SSL_CIPHER, (st)) |
500 | #define q_sk_SSL_CIPHER_value(st, i) q_SKM_sk_value(SSL_CIPHER, (st), (i)) |
501 | #define (ctx,x509) \ |
502 | q_SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509) |
503 | #define q_EVP_PKEY_assign_RSA(pkey,rsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ |
504 | (char *)(rsa)) |
505 | #define q_EVP_PKEY_assign_DSA(pkey,dsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ |
506 | (char *)(dsa)) |
507 | #define q_OpenSSL_add_all_algorithms() q_OPENSSL_add_all_algorithms_conf() |
508 | int q_i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp); |
509 | |
510 | void q_BIO_set_flags(BIO *b, int flags); |
511 | void q_BIO_clear_flags(BIO *b, int flags); |
512 | void *q_BIO_get_ex_data(BIO *b, int idx); |
513 | int q_BIO_set_ex_data(BIO *b, int idx, void *data); |
514 | |
515 | #define q_BIO_set_retry_read(b) q_BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) |
516 | #define q_BIO_set_retry_write(b) q_BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) |
517 | #define q_BIO_clear_retry_flags(b) q_BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) |
518 | #define q_BIO_set_app_data(s,arg) q_BIO_set_ex_data(s,0,arg) |
519 | #define q_BIO_get_app_data(s) q_BIO_get_ex_data(s,0) |
520 | |
521 | // Helper function |
522 | class QDateTime; |
523 | QDateTime q_getTimeFromASN1(const ASN1_TIME *aTime); |
524 | |
525 | void *q_CRYPTO_malloc(size_t num, const char *file, int line); |
526 | #define q_OPENSSL_malloc(num) q_CRYPTO_malloc(num, "", 0) |
527 | |
528 | QT_END_NAMESPACE |
529 | |
530 | #endif |
531 | |