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