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

source code of qtbase/src/plugins/tls/openssl/qsslsocket_openssl_symbols_p.h