Debian Codegraph @

src/plugins/tls/openssl/qsslsocket_openssl_symbols_p.h

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 // Copyright (C) 2017 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 // Qt-Security score:critical reason:execute-external-code
5
6 /****************************************************************************
7 **
8 ** In addition, as a special exception, the copyright holders listed above give
9 ** permission to link the code of its release of Qt with the OpenSSL project's
10 ** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
11 ** same license as the original version), and distribute the linked executables.
12 **
13 ** You must comply with the GNU General Public License version 2 in all
14 ** respects for all of the code used other than the "OpenSSL" code. If you
15 ** modify this file, you may extend this exception to your version of the file,
16 ** but you are not obligated to do so. If you do not wish to do so, delete
17 ** this exception statement from your version of this file.
18 **
19 ****************************************************************************/
20
21 #ifndef QSSLSOCKET_OPENSSL_SYMBOLS_P_H
22 #define QSSLSOCKET_OPENSSL_SYMBOLS_P_H
23
24
25 //
26 // W A R N I N G
27 // -------------
28 //
29 // This file is not part of the Qt API. It exists purely as an
30 // implementation detail. This header file may change from version to
31 // version without notice, or even be removed.
32 //
33 // We mean it.
34 //
35
36 #include <QtNetwork/private/qtnetworkglobal_p.h>
37
38 #include "qopenssl_p.h"
39
40 #include <QtCore/qglobal.h>
41
42 #if QT_CONFIG(ocsp)
43 #include <QtNetwork/private/qocsp_p.h>
44 #endif
45
46 QT_BEGIN_NAMESPACE
47
48 #define DUMMYARG
49
50 #if !defined QT_LINKED_OPENSSL
51 // **************** Shared declarations ******************
52 // ret func(arg)
53
54 # define DEFINEFUNC(ret, func, arg, a, err, funcret) \
55 typedef ret (*_q_PTR_##func)(arg); \
56 static _q_PTR_##func _q_##func = nullptr; \
57 ret q_##func(arg) { \
58 if (Q_UNLIKELY(!_q_##func)) { \
59 qsslSocketUnresolvedSymbolWarning(#func); \
60 err; \
61 } \
62 funcret _q_##func(a); \
63 }
64
65 // ret func(arg1, arg2)
66 # define DEFINEFUNC2(ret, func, arg1, a, arg2, b, err, funcret) \
67 typedef ret (*_q_PTR_##func)(arg1, arg2); \
68 static _q_PTR_##func _q_##func = nullptr; \
69 ret q_##func(arg1, arg2) { \
70 if (Q_UNLIKELY(!_q_##func)) { \
71 qsslSocketUnresolvedSymbolWarning(#func);\
72 err; \
73 } \
74 funcret _q_##func(a, b); \
75 }
76
77 // ret func(arg1, arg2, arg3)
78 # define DEFINEFUNC3(ret, func, arg1, a, arg2, b, arg3, c, err, funcret) \
79 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3); \
80 static _q_PTR_##func _q_##func = nullptr; \
81 ret q_##func(arg1, arg2, arg3) { \
82 if (Q_UNLIKELY(!_q_##func)) { \
83 qsslSocketUnresolvedSymbolWarning(#func); \
84 err; \
85 } \
86 funcret _q_##func(a, b, c); \
87 }
88
89 // ret func(arg1, arg2, arg3, arg4)
90 # define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret) \
91 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4); \
92 static _q_PTR_##func _q_##func = nullptr; \
93 ret q_##func(arg1, arg2, arg3, arg4) { \
94 if (Q_UNLIKELY(!_q_##func)) { \
95 qsslSocketUnresolvedSymbolWarning(#func); \
96 err; \
97 } \
98 funcret _q_##func(a, b, c, d); \
99 }
100
101 // ret func(arg1, arg2, arg3, arg4, arg5)
102 # define DEFINEFUNC5(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, err, funcret) \
103 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5); \
104 static _q_PTR_##func _q_##func = nullptr; \
105 ret q_##func(arg1, arg2, arg3, arg4, arg5) { \
106 if (Q_UNLIKELY(!_q_##func)) { \
107 qsslSocketUnresolvedSymbolWarning(#func); \
108 err; \
109 } \
110 funcret _q_##func(a, b, c, d, e); \
111 }
112
113 // ret func(arg1, arg2, arg3, arg4, arg6)
114 # define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret) \
115 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6); \
116 static _q_PTR_##func _q_##func = nullptr; \
117 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { \
118 if (Q_UNLIKELY(!_q_##func)) { \
119 qsslSocketUnresolvedSymbolWarning(#func); \
120 err; \
121 } \
122 funcret _q_##func(a, b, c, d, e, f); \
123 }
124
125 // ret func(arg1, arg2, arg3, arg4, arg6, arg7)
126 # define DEFINEFUNC7(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, err, funcret) \
127 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
128 static _q_PTR_##func _q_##func = nullptr; \
129 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \
130 if (Q_UNLIKELY(!_q_##func)) { \
131 qsslSocketUnresolvedSymbolWarning(#func); \
132 err; \
133 } \
134 funcret _q_##func(a, b, c, d, e, f, g); \
135 }
136
137 // ret func(arg1, arg2, arg3, arg4, arg6, arg7, arg8, arg9)
138 # define DEFINEFUNC9(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, arg8, h, arg9, i, err, funcret) \
139 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \
140 static _q_PTR_##func _q_##func = nullptr; \
141 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { \
142 if (Q_UNLIKELY(!_q_##func)) { \
143 qsslSocketUnresolvedSymbolWarning(#func); \
144 err; \
145 } \
146 funcret _q_##func(a, b, c, d, e, f, g, h, i); \
147 }
148 // **************** Shared declarations ******************
149
150 #else // !defined QT_LINKED_OPENSSL
151
152 // **************** Static declarations ******************
153
154 // ret func(arg)
155 # define DEFINEFUNC(ret, func, arg, a, err, funcret) \
156 ret q_##func(arg) { funcret func(a); }
157
158 // ret func(arg1, arg2)
159 # define DEFINEFUNC2(ret, func, arg1, a, arg2, b, err, funcret) \
160 ret q_##func(arg1, arg2) { funcret func(a, b); }
161
162 // ret func(arg1, arg2, arg3)
163 # define DEFINEFUNC3(ret, func, arg1, a, arg2, b, arg3, c, err, funcret) \
164 ret q_##func(arg1, arg2, arg3) { funcret func(a, b, c); }
165
166 // ret func(arg1, arg2, arg3, arg4)
167 # define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret) \
168 ret q_##func(arg1, arg2, arg3, arg4) { funcret func(a, b, c, d); }
169
170 // ret func(arg1, arg2, arg3, arg4, arg5)
171 # define DEFINEFUNC5(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, err, funcret) \
172 ret q_##func(arg1, arg2, arg3, arg4, arg5) { funcret func(a, b, c, d, e); }
173
174 // ret func(arg1, arg2, arg3, arg4, arg6)
175 # define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret) \
176 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { funcret func(a, b, c, d, e, f); }
177
178 // ret func(arg1, arg2, arg3, arg4, arg6, arg7)
179 # define DEFINEFUNC7(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, err, funcret) \
180 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { funcret func(a, b, c, d, e, f, g); }
181
182 // ret func(arg1, arg2, arg3, arg4, arg6, arg7, arg8, arg9)
183 # define DEFINEFUNC9(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, arg8, h, arg9, i, err, funcret) \
184 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { funcret func(a, b, c, d, e, f, g, h, i); }
185
186 // **************** Static declarations ******************
187
188 #endif // !defined QT_LINKED_OPENSSL
189 #if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
190 typedef uint64_t qssloptions;
191 #else
192 typedef unsigned long qssloptions;
193 #endif
194 // TODO: the following lines previously were a part of 1.1 - specific header.
195 // To reduce the amount of the change, I'm directly copying and pasting the
196 // content of the header here. Later, can be better sorted/split into groups,
197 // depending on the functionality.
198
199 const unsigned char * q_ASN1_STRING_get0_data(const ASN1_STRING *x);
200
201 BIO *q_BIO_new(const BIO_METHOD *a);
202 const BIO_METHOD *q_BIO_s_mem();
203
204 void q_AUTHORITY_INFO_ACCESS_free(AUTHORITY_INFO_ACCESS *a);
205 int q_EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c);
206 int q_EVP_PKEY_up_ref(EVP_PKEY *a);
207 EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
208 void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
209 int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
210 int q_OPENSSL_sk_num(OPENSSL_STACK *a);
211 void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
212 OPENSSL_STACK *q_OPENSSL_sk_new_null();
213 void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
214 void q_OPENSSL_sk_free(OPENSSL_STACK *a);
215 void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
216 int q_SSL_session_reused(SSL *a);
217 qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
218 int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
219 size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
220 size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
221 int q_CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
222 const SSL_METHOD *q_TLS_method();
223 const SSL_METHOD *q_TLS_client_method();
224 const SSL_METHOD *q_TLS_server_method();
225 ASN1_TIME *q_X509_getm_notBefore(X509 *a);
226 ASN1_TIME *q_X509_getm_notAfter(X509 *a);
227 void q_ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
228 void q_X509V3_conf_free(CONF_VALUE *val);
229
230 void q_X509_up_ref(X509 *a);
231 long q_X509_get_version(X509 *a);
232 EVP_PKEY *q_X509_get_pubkey(X509 *a);
233 void q_X509_STORE_set_verify_cb(X509_STORE *ctx, X509_STORE_CTX_verify_cb verify_cb);
234 int q_X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data);
235 void *q_X509_STORE_get_ex_data(X509_STORE *r, int idx);
236 STACK_OF(X509) *q_X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx);
237
238 # define q_SSL_load_error_strings() q_OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \
239 | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
240
241 #define q_SKM_sk_num(st) q_OPENSSL_sk_num((OPENSSL_STACK *)st)
242 #define q_SKM_sk_value(type, st,i) (type *)q_OPENSSL_sk_value((OPENSSL_STACK *)st, i)
243
244 #define q_OPENSSL_add_all_algorithms_conf() q_OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
245 | OPENSSL_INIT_ADD_ALL_DIGESTS \
246 | OPENSSL_INIT_LOAD_CONFIG, NULL)
247 #define q_OPENSSL_add_all_algorithms_noconf() q_OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
248 | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
249
250 int q_OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
251
252 long q_OpenSSL_version_num();
253 const char *q_OpenSSL_version(int type);
254
255 unsigned long q_SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *session);
256 unsigned long q_SSL_set_options(SSL *s, unsigned long op);
257
258 #ifdef TLS1_3_VERSION
259 int q_SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str);
260
261 // The functions below do not really have to be ifdefed like this, but for now
262 // they only used in TLS 1.3 handshake (and probably future versions).
263 // Plus, 'is resumalbe' is OpenSSL 1.1.1-only (and again we need it for
264 // TLS 1.3-specific session management).
265
266 extern "C"
267 {
268 using NewSessionCallback = int (*)(SSL *, SSL_SESSION *);
269 }
270
271 void q_SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, NewSessionCallback cb);
272 int q_SSL_SESSION_is_resumable(const SSL_SESSION *s);
273
274 #define q_SSL_CTX_set_session_cache_mode(ctx,m) \
275 q_SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL)
276
277 #endif
278
279 #if QT_CONFIG(dtls)
280 // Functions and types required for DTLS support:
281 extern "C"
282 {
283
284 typedef int (*CookieVerifyCallback)(SSL *, const unsigned char *, unsigned);
285 typedef int (*DgramWriteCallback) (BIO *, const char *, int);
286 typedef int (*DgramReadCallback) (BIO *, char *, int);
287 typedef int (*DgramPutsCallback) (BIO *, const char *);
288 typedef long (*DgramCtrlCallback) (BIO *, int, long, void *);
289 typedef int (*DgramCreateCallback) (BIO *);
290 typedef int (*DgramDestroyCallback) (BIO *);
291
292 }
293
294 int q_DTLSv1_listen(SSL *s, BIO_ADDR *client);
295 BIO_ADDR *q_BIO_ADDR_new();
296 void q_BIO_ADDR_free(BIO_ADDR *ap);
297
298 // API we need for a custom dgram BIO:
299
300 BIO_METHOD *q_BIO_meth_new(int type, const char *name);
301 void q_BIO_meth_free(BIO_METHOD *biom);
302 int q_BIO_meth_set_write(BIO_METHOD *biom, DgramWriteCallback);
303 int q_BIO_meth_set_read(BIO_METHOD *biom, DgramReadCallback);
304 int q_BIO_meth_set_puts(BIO_METHOD *biom, DgramPutsCallback);
305 int q_BIO_meth_set_ctrl(BIO_METHOD *biom, DgramCtrlCallback);
306 int q_BIO_meth_set_create(BIO_METHOD *biom, DgramCreateCallback);
307 int q_BIO_meth_set_destroy(BIO_METHOD *biom, DgramDestroyCallback);
308
309 #endif // dtls
310
311 void q_BIO_set_data(BIO *a, void *ptr);
312 void *q_BIO_get_data(BIO *a);
313 void q_BIO_set_init(BIO *a, int init);
314 int q_BIO_get_shutdown(BIO *a);
315 void q_BIO_set_shutdown(BIO *a, int shut);
316
317 #if QT_CONFIG(ocsp)
318 const OCSP_CERTID *q_OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *x);
319 #endif // ocsp
320
321 #define q_SSL_CTX_set_min_proto_version(ctx, version) \
322 q_SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version, nullptr)
323
324 #define q_SSL_CTX_set_max_proto_version(ctx, version) \
325 q_SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, nullptr)
326
327 extern "C" {
328 typedef int (*q_SSL_psk_use_session_cb_func_t)(SSL *, const EVP_MD *, const unsigned char **, size_t *,
329 SSL_SESSION **);
330 }
331 void q_SSL_set_psk_use_session_callback(SSL *s, q_SSL_psk_use_session_cb_func_t);
332 // Here the content of the 1.1 header ends.
333
334 bool q_resolveOpenSslSymbols();
335 long q_ASN1_INTEGER_get(ASN1_INTEGER *a);
336 int q_ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
337 int q_ASN1_STRING_length(ASN1_STRING *a);
338 int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b);
339 int q_ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm);
340 long q_BIO_ctrl(BIO *a, int b, long c, void *d);
341 int q_BIO_free(BIO *a);
342 BIO *q_BIO_new_mem_buf(void *a, int b);
343 int q_BIO_read(BIO *a, void *b, int c);
344 int q_BIO_write(BIO *a, const void *b, int c);
345 int q_BN_num_bits(const BIGNUM *a);
346 int q_BN_is_word(BIGNUM *a, BN_ULONG w);
347 BN_ULONG q_BN_mod_word(const BIGNUM *a, BN_ULONG w);
348
349 X509 *q_d2i_X509(X509 **a, const unsigned char **b, long c);
350 char *q_ERR_error_string(unsigned long a, char *b);
351 void q_ERR_error_string_n(unsigned long e, char *buf, size_t len);
352 unsigned long q_ERR_get_error();
353 EVP_CIPHER_CTX *q_EVP_CIPHER_CTX_new();
354 void q_EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);
355 int q_EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
356 int q_EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
357 int q_EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, const unsigned char *key, const unsigned char *iv, int enc);
358 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);
359 int q_EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl);
360 int q_EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
361 const EVP_MD *q_EVP_get_digestbyname(const char *name);
362
363 #ifndef OPENSSL_NO_DES
364 const EVP_CIPHER *q_EVP_des_cbc();
365 const EVP_CIPHER *q_EVP_des_ede3_cbc();
366 #endif // OPENSSL_NO_DES
367
368 #ifndef OPENSSL_NO_RC2
369 const EVP_CIPHER *q_EVP_rc2_cbc();
370 #endif // OPENSSL_NO_RC2
371
372 #ifndef OPENSSL_NO_AES
373 const EVP_CIPHER *q_EVP_aes_128_cbc();
374 const EVP_CIPHER *q_EVP_aes_192_cbc();
375 const EVP_CIPHER *q_EVP_aes_256_cbc();
376 #endif // OPENSSL_NO_AES
377
378 const EVP_MD *q_EVP_sha1();
379
380 void q_EVP_PKEY_free(EVP_PKEY *a);
381 int q_EVP_PKEY_type(int a);
382 EVP_PKEY *q_EVP_PKEY_new();
383 int q_i2d_X509(X509 *a, unsigned char **b);
384 const char *q_OBJ_nid2sn(int a);
385 const char *q_OBJ_nid2ln(int a);
386 int q_OBJ_sn2nid(const char *s);
387 int q_OBJ_ln2nid(const char *s);
388 int q_i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *obj);
389 int q_OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *obj, int no_name);
390 int q_OBJ_obj2nid(const ASN1_OBJECT *a);
391 #define q_EVP_get_digestbynid(a) q_EVP_get_digestbyname(q_OBJ_nid2sn(a))
392 EVP_PKEY *q_PEM_read_bio_PrivateKey(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d);
393
394 int q_PEM_write_bio_PrivateKey(BIO *a, EVP_PKEY *b, const EVP_CIPHER *c, unsigned char *d,
395 int e, pem_password_cb *f, void *g);
396 int q_PEM_write_bio_PrivateKey_traditional(BIO *a, EVP_PKEY *b, const EVP_CIPHER *c, unsigned char *d,
397 int e, pem_password_cb *f, void *g);
398 EVP_PKEY *q_PEM_read_bio_PUBKEY(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d);
399 int q_PEM_write_bio_PUBKEY(BIO *a, EVP_PKEY *b);
400
401 void q_RAND_seed(const void *a, int b);
402 int q_RAND_status();
403 int q_RAND_bytes(unsigned char *b, int n);
404 int q_SSL_accept(SSL *a);
405 int q_SSL_clear(SSL *a);
406 char *q_SSL_CIPHER_description(const SSL_CIPHER *a, char *b, int c);
407 int q_SSL_CIPHER_get_bits(const SSL_CIPHER *a, int *b);
408 BIO *q_SSL_get_rbio(const SSL *s);
409 int q_SSL_connect(SSL *a);
410 int q_SSL_CTX_check_private_key(const SSL_CTX *a);
411 long q_SSL_CTX_ctrl(SSL_CTX *a, int b, long c, void *d);
412 void q_SSL_CTX_free(SSL_CTX *a);
413 SSL_CTX *q_SSL_CTX_new(const SSL_METHOD *a);
414 int q_SSL_CTX_set_cipher_list(SSL_CTX *a, const char *b);
415 int q_SSL_CTX_set_default_verify_paths(SSL_CTX *a);
416 void q_SSL_CTX_set_verify(SSL_CTX *a, int b, int (*c)(int, X509_STORE_CTX *));
417 void q_SSL_CTX_set_verify_depth(SSL_CTX *a, int b);
418 extern "C" {
419 typedef void (*GenericCallbackType)();
420 }
421 long q_SSL_CTX_callback_ctrl(SSL_CTX *, int, GenericCallbackType);
422 int q_SSL_CTX_use_certificate(SSL_CTX *a, X509 *b);
423 int q_SSL_CTX_use_certificate_file(SSL_CTX *a, const char *b, int c);
424 int q_SSL_CTX_use_PrivateKey(SSL_CTX *a, EVP_PKEY *b);
425 int q_SSL_CTX_use_PrivateKey_file(SSL_CTX *a, const char *b, int c);
426 X509_STORE *q_SSL_CTX_get_cert_store(const SSL_CTX *a);
427 SSL_CONF_CTX *q_SSL_CONF_CTX_new();
428 void q_SSL_CONF_CTX_free(SSL_CONF_CTX *a);
429 void q_SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *a, SSL_CTX *b);
430 unsigned int q_SSL_CONF_CTX_set_flags(SSL_CONF_CTX *a, unsigned int b);
431 int q_SSL_CONF_CTX_finish(SSL_CONF_CTX *a);
432 int q_SSL_CONF_cmd(SSL_CONF_CTX *a, const char *b, const char *c);
433 void q_SSL_free(SSL *a);
434 STACK_OF(SSL_CIPHER) *q_SSL_get_ciphers(const SSL *a);
435 const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
436 int q_SSL_version(const SSL *a);
437 int q_SSL_get_error(SSL *a, int b);
438 STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
439 long q_SSL_get_verify_result(const SSL *a);
440 SSL *q_SSL_new(SSL_CTX *a);
441 SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
442 long q_SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg);
443 int q_SSL_read(SSL *a, void *b, int c);
444 void q_SSL_set_bio(SSL *a, BIO *b, BIO *c);
445 void q_SSL_set_accept_state(SSL *a);
446 void q_SSL_set_connect_state(SSL *a);
447 int q_SSL_shutdown(SSL *a);
448 int q_SSL_in_init(const SSL *s);
449 int q_SSL_get_shutdown(const SSL *ssl);
450 int q_SSL_set_session(SSL *to, SSL_SESSION *session);
451 void q_SSL_SESSION_free(SSL_SESSION *ses);
452 SSL_SESSION *q_SSL_get1_session(SSL *ssl);
453 SSL_SESSION *q_SSL_get_session(const SSL *ssl);
454 int q_SSL_set_ex_data(SSL *ssl, int idx, void *arg);
455 void *q_SSL_get_ex_data(const SSL *ssl, int idx);
456 #ifndef OPENSSL_NO_PSK
457 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);
458 void q_SSL_set_psk_client_callback(SSL *ssl, q_psk_client_callback_t callback);
459 typedef unsigned int (*q_psk_server_callback_t)(SSL *ssl, const char *identity, unsigned char *psk, unsigned int max_psk_len);
460 void q_SSL_set_psk_server_callback(SSL *ssl, q_psk_server_callback_t callback);
461 int q_SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint);
462 #endif // !OPENSSL_NO_PSK
463 int q_SSL_write(SSL *a, const void *b, int c);
464 int q_X509_cmp(X509 *a, X509 *b);
465 X509 *q_X509_dup(X509 *a);
466 void q_X509_print(BIO *a, X509*b);
467 int q_X509_digest(const X509 *x509, const EVP_MD *type, unsigned char *md, unsigned int *len);
468 ASN1_OBJECT *q_X509_EXTENSION_get_object(X509_EXTENSION *a);
469 void q_X509_free(X509 *a);
470 ASN1_TIME *q_X509_gmtime_adj(ASN1_TIME *s, long adj);
471 void q_ASN1_TIME_free(ASN1_TIME *t);
472 X509_EXTENSION *q_X509_get_ext(X509 *a, int b);
473 int q_X509_get_ext_count(X509 *a);
474 void *q_X509_get_ext_d2i(X509 *a, int b, int *c, int *d);
475 const X509V3_EXT_METHOD *q_X509V3_EXT_get(X509_EXTENSION *a);
476 void *q_X509V3_EXT_d2i(X509_EXTENSION *a);
477 int q_X509_EXTENSION_get_critical(X509_EXTENSION *a);
478 ASN1_OCTET_STRING *q_X509_EXTENSION_get_data(X509_EXTENSION *a);
479 void q_BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a);
480 void q_AUTHORITY_KEYID_free(AUTHORITY_KEYID *a);
481 int q_ASN1_STRING_print(BIO *a, const ASN1_STRING *b);
482 int q_X509_check_issued(X509 *a, X509 *b);
483 X509_NAME *q_X509_get_issuer_name(X509 *a);
484 X509_NAME *q_X509_get_subject_name(X509 *a);
485 ASN1_INTEGER *q_X509_get_serialNumber(X509 *a);
486 int q_X509_verify_cert(X509_STORE_CTX *ctx);
487 int q_X509_NAME_entry_count(X509_NAME *a);
488 X509_NAME_ENTRY *q_X509_NAME_get_entry(X509_NAME *a,int b);
489 ASN1_STRING *q_X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *a);
490 ASN1_OBJECT *q_X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *a);
491 EVP_PKEY *q_X509_PUBKEY_get(X509_PUBKEY *a);
492 void q_X509_STORE_free(X509_STORE *store);
493 X509_STORE *q_X509_STORE_new();
494 int q_X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
495 void q_X509_STORE_CTX_free(X509_STORE_CTX *storeCtx);
496 int q_X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
497 X509 *x509, STACK_OF(X509) *chain);
498 X509_STORE_CTX *q_X509_STORE_CTX_new();
499 int q_X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
500 int q_X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
501 int q_X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
502 X509 *q_X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
503 X509_STORE *q_X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);
504
505 // Diffie-Hellman support
506 #ifndef OPENSSL_NO_DEPRECATED_3_0
507 DH *q_DH_new();
508 void q_DH_free(DH *dh);
509 int q_DH_check(DH *dh, int *codes);
510 void q_DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
511
512 DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
513 int q_i2d_DHparams(DH *a, unsigned char **p);
514
515 DH *q_PEM_read_bio_DHparams(BIO *a, DH **b, pem_password_cb *c, void *d);
516 #endif // OPENSSL_NO_DEPRECATED_3_0
517
518 BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
519 #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
520 #define q_SSL_CTX_set_dh_auto(ctx, onoff) q_SSL_CTX_ctrl(ctx,SSL_CTRL_SET_DH_AUTO,onoff,NULL)
521
522 #ifndef OPENSSL_NO_EC
523 // EC Diffie-Hellman support
524 #define q_SSL_CTX_set_tmp_ecdh(ctx, ecdh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_ECDH, 0, (char *)ecdh)
525
526 // EC curves management
527 size_t q_EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
528 int q_EC_curve_nist2nid(const char *name);
529 #endif // OPENSSL_NO_EC
530
531 #define q_SSL_get_server_tmp_key(ssl, key) q_SSL_ctrl((ssl), SSL_CTRL_GET_SERVER_TMP_KEY, 0, (char *)key)
532
533 // PKCS#12 support
534 int q_PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca);
535 PKCS12 *q_d2i_PKCS12_bio(BIO *bio, PKCS12 **pkcs12);
536 void q_PKCS12_free(PKCS12 *pkcs12);
537
538 #define q_BIO_get_mem_data(b, pp) (int)q_BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
539 #define q_BIO_pending(b) (int)q_BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
540 #define q_SSL_CTX_set_mode(ctx,op) q_SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
541 #define q_sk_GENERAL_NAME_num(st) q_SKM_sk_num((st))
542 #define q_sk_GENERAL_NAME_value(st, i) q_SKM_sk_value(GENERAL_NAME, (st), (i))
543
544 void q_GENERAL_NAME_free(GENERAL_NAME *a);
545
546 #define q_sk_X509_num(st) q_SKM_sk_num((st))
547 #define q_sk_X509_value(st, i) q_SKM_sk_value(X509, (st), (i))
548 #define q_sk_SSL_CIPHER_num(st) q_SKM_sk_num((st))
549 #define q_sk_SSL_CIPHER_value(st, i) q_SKM_sk_value(SSL_CIPHER, (st), (i))
550 #define q_SSL_CTX_add_extra_chain_cert(ctx,x509) \
551 q_SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)
552 #define q_OpenSSL_add_all_algorithms() q_OPENSSL_add_all_algorithms_conf()
553
554 #if OPENSSL_VERSION_MAJOR < 3
555 int q_SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, const char *CApath);
556 #else
557 int q_SSL_CTX_load_verify_dir(SSL_CTX *ctx, const char *CApath);
558 #endif // OPENSSL_VERSION_MAJOR
559
560 int q_i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);
561 SSL_SESSION *q_d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length);
562
563 #ifndef OPENSSL_NO_NEXTPROTONEG
564 int q_SSL_select_next_proto(unsigned char **out, unsigned char *outlen,
565 const unsigned char *in, unsigned int inlen,
566 const unsigned char *client, unsigned int client_len);
567 void q_SSL_CTX_set_next_proto_select_cb(SSL_CTX *s,
568 int (*cb) (SSL *ssl, unsigned char **out,
569 unsigned char *outlen,
570 const unsigned char *in,
571 unsigned int inlen, void *arg),
572 void *arg);
573 void q_SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,
574 unsigned *len);
575 int q_SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos,
576 unsigned protos_len);
577 void q_SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,
578 int (*cb) (SSL *ssl,
579 const unsigned char **out,
580 unsigned char *outlen,
581 const unsigned char *in,
582 unsigned int inlen,
583 void *arg), void *arg);
584 void q_SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data,
585 unsigned *len);
586 #endif // !OPENSSL_NO_NEXTPROTONEG
587
588
589 #if QT_CONFIG(dtls)
590
591 extern "C"
592 {
593 typedef int (*CookieGenerateCallback)(SSL *, unsigned char *, unsigned *);
594 }
595
596 void q_SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, CookieGenerateCallback cb);
597 void q_SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, CookieVerifyCallback cb);
598 const SSL_METHOD *q_DTLS_server_method();
599 const SSL_METHOD *q_DTLS_client_method();
600
601 #endif // dtls
602
603 void *q_X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx);
604 int q_SSL_get_ex_data_X509_STORE_CTX_idx();
605
606 #if QT_CONFIG(dtls)
607 #define q_DTLS_set_link_mtu(ssl, mtu) q_SSL_ctrl((ssl), DTLS_CTRL_SET_LINK_MTU, (mtu), nullptr)
608 #define q_DTLSv1_get_timeout(ssl, arg) q_SSL_ctrl(ssl, DTLS_CTRL_GET_TIMEOUT, 0, arg)
609 #define q_DTLSv1_handle_timeout(ssl) q_SSL_ctrl(ssl, DTLS_CTRL_HANDLE_TIMEOUT, 0, nullptr)
610 #endif // dtls
611
612 void q_BIO_set_flags(BIO *b, int flags);
613 void q_BIO_clear_flags(BIO *b, int flags);
614 void *q_BIO_get_ex_data(BIO *b, int idx);
615 int q_BIO_set_ex_data(BIO *b, int idx, void *data);
616
617 #define q_BIO_set_retry_read(b) q_BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
618 #define q_BIO_set_retry_write(b) q_BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
619 #define q_BIO_clear_retry_flags(b) q_BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
620 #define q_BIO_set_app_data(s,arg) q_BIO_set_ex_data(s,0,arg)
621 #define q_BIO_get_app_data(s) q_BIO_get_ex_data(s,0)
622
623 #define q_SSL_set_tlsext_status_type(ssl, type) \
624 q_SSL_ctrl((ssl), SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE, (type), nullptr)
625
626 #if QT_CONFIG(ocsp)
627
628 OCSP_RESPONSE *q_d2i_OCSP_RESPONSE(OCSP_RESPONSE **a, const unsigned char **in, long len);
629 int q_i2d_OCSP_RESPONSE(OCSP_RESPONSE *r, unsigned char **ppout);
630 OCSP_RESPONSE *q_OCSP_response_create(int status, OCSP_BASICRESP *bs);
631 void q_OCSP_RESPONSE_free(OCSP_RESPONSE *rs);
632 int q_OCSP_response_status(OCSP_RESPONSE *resp);
633 OCSP_BASICRESP *q_OCSP_response_get1_basic(OCSP_RESPONSE *resp);
634 OCSP_SINGLERESP *q_OCSP_basic_add1_status(OCSP_BASICRESP *rsp, OCSP_CERTID *cid,
635 int status, int reason, ASN1_TIME *revtime,
636 ASN1_TIME *thisupd, ASN1_TIME *nextupd);
637 int q_OCSP_basic_sign(OCSP_BASICRESP *brsp, X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,
638 STACK_OF(X509) *certs, unsigned long flags);
639 OCSP_BASICRESP *q_OCSP_BASICRESP_new();
640 void q_OCSP_BASICRESP_free(OCSP_BASICRESP *bs);
641 int q_OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, X509_STORE *st, unsigned long flags);
642 int q_OCSP_resp_count(OCSP_BASICRESP *bs);
643 OCSP_SINGLERESP *q_OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
644 int q_OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, ASN1_GENERALIZEDTIME **revtime,
645 ASN1_GENERALIZEDTIME **thisupd, ASN1_GENERALIZEDTIME **nextupd);
646 int q_OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, ASN1_GENERALIZEDTIME *nextupd, long nsec, long maxsec);
647 int q_OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, ASN1_OCTET_STRING **pikeyHash,
648 ASN1_INTEGER **pserial, OCSP_CERTID *cid);
649
650 const STACK_OF(X509) *q_OCSP_resp_get0_certs(const OCSP_BASICRESP *bs);
651 OCSP_CERTID *q_OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);
652 void q_OCSP_CERTID_free(OCSP_CERTID *cid);
653 int q_OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
654
655 #define q_SSL_get_tlsext_status_ocsp_resp(ssl, arg) \
656 q_SSL_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP, 0, arg)
657
658 #define q_SSL_CTX_set_tlsext_status_cb(ssl, cb) \
659 q_SSL_CTX_callback_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB, GenericCallbackType(cb))
660
661 # define q_SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \
662 q_SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP, arglen, arg)
663
664 #endif // ocsp
665
666
667 void *q_CRYPTO_malloc(size_t num, const char *file, int line);
668 #define q_OPENSSL_malloc(num) q_CRYPTO_malloc(num, "", 0)
669 void q_CRYPTO_free(void *str, const char *file, int line);
670 # define q_OPENSSL_free(addr) q_CRYPTO_free(addr, "", 0)
671 int q_CRYPTO_memcmp(const void * in_a, const void * in_b, size_t len);
672
673 void q_SSL_set_info_callback(SSL *ssl, void (*cb) (const SSL *ssl, int type, int val));
674 const char *q_SSL_alert_type_string(int value);
675 const char *q_SSL_alert_desc_string_long(int value);
676
677 int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
678 void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
679
680 // Here we have the ones that make difference between OpenSSL pre/post v3:
681 #if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
682 X509 *q_SSL_get1_peer_certificate(SSL *a);
683 #define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
684 int q_EVP_PKEY_get_bits(const EVP_PKEY *pkey);
685 int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
686 #define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
687 #else
688 X509 *q_SSL_get_peer_certificate(SSL *a);
689 int q_EVP_PKEY_base_id(EVP_PKEY *a);
690 #endif // OPENSSL_VERSION_MAJOR >= 3
691
692 #ifndef OPENSSL_NO_DEPRECATED_3_0
693
694 DSA *q_DSA_new();
695 void q_DSA_free(DSA *a);
696
697 RSA *q_RSA_new();
698 void q_RSA_free(RSA *a);
699
700 #ifndef OPENSSL_NO_EC
701
702 EC_KEY *q_EC_KEY_dup(const EC_KEY *src);
703 EC_KEY *q_EC_KEY_new_by_curve_name(int nid);
704 void q_EC_KEY_free(EC_KEY *ecdh);
705
706 #endif // OPENSSL_NO_EC
707
708 int q_SSL_CTX_use_RSAPrivateKey(SSL_CTX *a, RSA *b);
709
710 DSA *q_PEM_read_bio_DSA_PUBKEY(BIO *a, DSA **b, pem_password_cb *c, void *d);
711 RSA *q_PEM_read_bio_RSA_PUBKEY(BIO *a, RSA **b, pem_password_cb *c, void *d);
712
713 DSA *q_PEM_read_bio_DSAPrivateKey(BIO *a, DSA **b, pem_password_cb *c, void *d);
714 RSA *q_PEM_read_bio_RSAPrivateKey(BIO *a, RSA **b, pem_password_cb *c, void *d);
715
716 int q_PEM_write_bio_DSA_PUBKEY(BIO *a, DSA *b);
717 int q_PEM_write_bio_RSA_PUBKEY(BIO *a, RSA *b);
718
719 int q_PEM_write_bio_DSAPrivateKey(BIO *a, DSA *b, const EVP_CIPHER *c, unsigned char *d,
720 int e, pem_password_cb *f, void *g);
721 int q_PEM_write_bio_RSAPrivateKey(BIO *a, RSA *b, const EVP_CIPHER *c, unsigned char *d,
722 int e, pem_password_cb *f, void *g);
723
724 RSA *q_EVP_PKEY_get1_RSA(EVP_PKEY *a);
725 DSA *q_EVP_PKEY_get1_DSA(EVP_PKEY *a);
726 DH *q_EVP_PKEY_get1_DH(EVP_PKEY *a);
727
728 int q_EVP_PKEY_set1_RSA(EVP_PKEY *a, RSA *b);
729 int q_EVP_PKEY_set1_DSA(EVP_PKEY *a, DSA *b);
730 int q_EVP_PKEY_set1_DH(EVP_PKEY *a, DH *b);
731
732 int q_DH_bits(DH *dh);
733 int q_RSA_bits(RSA *a);
734 int q_DSA_bits(DSA *a);
735
736 int q_EVP_PKEY_assign(EVP_PKEY *a, int b, void *r);
737 int q_EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
738
739 #ifndef OPENSSL_NO_EC
740
741 EC_KEY *q_PEM_read_bio_EC_PUBKEY(BIO *a, EC_KEY **b, pem_password_cb *c, void *d);
742 EC_KEY *q_PEM_read_bio_ECPrivateKey(BIO *a, EC_KEY **b, pem_password_cb *c, void *d);
743
744 int q_PEM_write_bio_ECPrivateKey(BIO *a, EC_KEY *b, const EVP_CIPHER *c, unsigned char *d,
745 int e, pem_password_cb *f, void *g);
746 int q_PEM_write_bio_EC_PUBKEY(BIO *a, EC_KEY *b);
747
748 EC_KEY *q_EVP_PKEY_get1_EC_KEY(EVP_PKEY *a);
749 int q_EVP_PKEY_set1_EC_KEY(EVP_PKEY *a, EC_KEY *b);
750
751 const EC_GROUP* q_EC_KEY_get0_group(const EC_KEY* k);
752 int q_EC_GROUP_get_degree(const EC_GROUP* g);
753
754 #define q_EVP_PKEY_assign_RSA(pkey,rsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
755 (char *)(rsa))
756 #define q_EVP_PKEY_assign_DSA(pkey,dsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
757 (char *)(dsa))
758
759
760 #endif // OPENSSL_NO_EC
761
762 #endif // OPENSSL_NO_DEPRECATED_3_0
763
764 QT_END_NAMESPACE
765
766 #endif