1// Copyright (C) 2017 The Qt Company Ltd.
2// Copyright (C) 2014 BlackBerry Limited. All rights reserved.
3// Copyright (C) 2016 Richard J. Moore <rich@kde.org>
4// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
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#include "qsslsocket_openssl_symbols_p.h"
22#include "qtlsbackend_openssl_p.h"
23
24#include <QtNetwork/private/qssl_p.h>
25
26#ifdef Q_OS_WIN
27# include <QtCore/private/qsystemlibrary_p.h>
28#elif QT_CONFIG(library)
29# include <QtCore/qlibrary.h>
30#endif
31#include <QtCore/qdatetime.h>
32#if defined(Q_OS_UNIX)
33#include <QtCore/qdir.h>
34#endif
35#include <QtCore/private/qduplicatetracker_p.h>
36#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
37#include <link.h>
38#endif
39#ifdef Q_OS_DARWIN
40#include <QtCore/private/qcore_mac_p.h>
41#endif
42
43#include <algorithm>
44
45QT_BEGIN_NAMESPACE
46
47using namespace Qt::StringLiterals;
48
49/*
50 Note to maintainer:
51 -------------------
52
53 We load OpenSSL symbols dynamically. Because symbols are known to
54 disappear, and signatures sometimes change, between releases, we need to
55 be careful about how this is done. To ensure we don't end up dereferencing
56 null function pointers, and continue running even if certain functions are
57 missing, we define helper functions for each of the symbols we load from
58 OpenSSL, all prefixed with "q_" (declared in
59 qsslsocket_openssl_symbols_p.h). So instead of calling SSL_connect
60 directly, we call q_SSL_connect, which is a function that checks if the
61 actual SSL_connect fptr is null, and returns a failure if it is, or calls
62 SSL_connect if it isn't.
63
64 This requires a somewhat tedious process of declaring each function we
65 want to call in OpenSSL thrice: once with the q_, in _p.h, once using the
66 DEFINEFUNC macros below, and once in the function that actually resolves
67 the symbols, below the DEFINEFUNC declarations below.
68
69 There's one DEFINEFUNC macro declared for every number of arguments
70 exposed by OpenSSL (feel free to extend when needed). The easiest thing to
71 do is to find an existing entry that matches the arg count of the function
72 you want to import, and do the same.
73
74 The first macro arg is the function return type. The second is the
75 verbatim name of the function/symbol. Then follows a list of N pairs of
76 argument types with a variable name, and just the variable name (char *a,
77 a, char *b, b, etc). Finally there's two arguments - a suitable return
78 statement for the error case (for an int function, return 0 or return -1
79 is usually right). Then either just "return" or DUMMYARG, the latter being
80 for void functions.
81
82 Note: Take into account that these macros and declarations are processed
83 at compile-time, and the result depends on the OpenSSL headers the
84 compiling host has installed, but the symbols are resolved at run-time,
85 possibly with a different version of OpenSSL.
86*/
87
88#ifndef QT_LINKED_OPENSSL
89
90namespace {
91void qsslSocketUnresolvedSymbolWarning(const char *functionName)
92{
93 qCWarning(lcTlsBackend, "QSslSocket: cannot call unresolved function %s", functionName);
94}
95
96#if QT_CONFIG(library)
97void qsslSocketCannotResolveSymbolWarning(const char *functionName)
98{
99 qCWarning(lcTlsBackend, "QSslSocket: cannot resolve %s", functionName);
100}
101#endif
102
103}
104
105#endif // QT_LINKED_OPENSSL
106
107DEFINEFUNC(const unsigned char *, ASN1_STRING_get0_data, const ASN1_STRING *a, a, return nullptr, return)
108DEFINEFUNC2(int, OPENSSL_init_ssl, uint64_t opts, opts, const OPENSSL_INIT_SETTINGS *settings, settings, return 0, return)
109DEFINEFUNC2(int, OPENSSL_init_crypto, uint64_t opts, opts, const OPENSSL_INIT_SETTINGS *settings, settings, return 0, return)
110DEFINEFUNC(BIO *, BIO_new, const BIO_METHOD *a, a, return nullptr, return)
111DEFINEFUNC(const BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return nullptr, return)
112DEFINEFUNC2(int, BN_is_word, BIGNUM *a, a, BN_ULONG w, w, return 0, return)
113DEFINEFUNC(int, EVP_CIPHER_CTX_reset, EVP_CIPHER_CTX *c, c, return 0, return)
114DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
115DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
116DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
117DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
118DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
119DEFINEFUNC2(void, OPENSSL_sk_pop_free, OPENSSL_STACK *a, a, void (*b)(void*), b, return, DUMMYARG)
120DEFINEFUNC(OPENSSL_STACK *, OPENSSL_sk_new_null, DUMMYARG, DUMMYARG, return nullptr, return)
121DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMMYARG)
122DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
123DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
124DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
125DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
126using info_callback = void (*) (const SSL *ssl, int type, int val);
127DEFINEFUNC2(void, SSL_set_info_callback, SSL *ssl, ssl, info_callback cb, cb, return, return)
128DEFINEFUNC(const char *, SSL_alert_type_string, int value, value, return nullptr, return)
129DEFINEFUNC(const char *, SSL_alert_desc_string_long, int value, value, return nullptr, return)
130DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
131DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
132#ifdef TLS1_3_VERSION
133DEFINEFUNC2(int, SSL_CTX_set_ciphersuites, SSL_CTX *ctx, ctx, const char *str, str, return 0, return)
134DEFINEFUNC2(void, SSL_set_psk_use_session_callback, SSL *ssl, ssl, q_SSL_psk_use_session_cb_func_t callback, callback, return, DUMMYARG)
135DEFINEFUNC2(void, SSL_CTX_sess_set_new_cb, SSL_CTX *ctx, ctx, NewSessionCallback cb, cb, return, return)
136DEFINEFUNC(int, SSL_SESSION_is_resumable, const SSL_SESSION *s, s, return 0, return)
137#endif
138DEFINEFUNC3(size_t, SSL_get_client_random, SSL *a, a, unsigned char *out, out, size_t outlen, outlen, return 0, return)
139DEFINEFUNC3(size_t, SSL_SESSION_get_master_key, const SSL_SESSION *ses, ses, unsigned char *out, out, size_t outlen, outlen, return 0, return)
140DEFINEFUNC6(int, CRYPTO_get_ex_new_index, int class_index, class_index, long argl, argl, void *argp, argp, CRYPTO_EX_new *new_func, new_func, CRYPTO_EX_dup *dup_func, dup_func, CRYPTO_EX_free *free_func, free_func, return -1, return)
141DEFINEFUNC2(unsigned long, SSL_set_options, SSL *ssl, ssl, unsigned long op, op, return 0, return)
142
143DEFINEFUNC(const SSL_METHOD *, TLS_method, DUMMYARG, DUMMYARG, return nullptr, return)
144DEFINEFUNC(const SSL_METHOD *, TLS_client_method, DUMMYARG, DUMMYARG, return nullptr, return)
145DEFINEFUNC(const SSL_METHOD *, TLS_server_method, DUMMYARG, DUMMYARG, return nullptr, return)
146DEFINEFUNC(void, X509_up_ref, X509 *a, a, return, DUMMYARG)
147DEFINEFUNC(ASN1_TIME *, X509_getm_notBefore, X509 *a, a, return nullptr, return)
148DEFINEFUNC(ASN1_TIME *, X509_getm_notAfter, X509 *a, a, return nullptr, return)
149DEFINEFUNC2(void, ASN1_item_free, ASN1_VALUE *val, val, const ASN1_ITEM *it, it, return, return)
150DEFINEFUNC(void, X509V3_conf_free, CONF_VALUE *val, val, return, return)
151DEFINEFUNC(long, X509_get_version, X509 *a, a, return -1, return)
152DEFINEFUNC(EVP_PKEY *, X509_get_pubkey, X509 *a, a, return nullptr, return)
153DEFINEFUNC2(void, X509_STORE_set_verify_cb, X509_STORE *a, a, X509_STORE_CTX_verify_cb verify_cb, verify_cb, return, DUMMYARG)
154DEFINEFUNC3(int, X509_STORE_set_ex_data, X509_STORE *a, a, int idx, idx, void *data, data, return 0, return)
155DEFINEFUNC2(void *, X509_STORE_get_ex_data, X509_STORE *r, r, int idx, idx, return nullptr, return)
156DEFINEFUNC(STACK_OF(X509) *, X509_STORE_CTX_get0_chain, X509_STORE_CTX *a, a, return nullptr, return)
157DEFINEFUNC3(void, CRYPTO_free, void *str, str, const char *file, file, int line, line, return, DUMMYARG)
158DEFINEFUNC3(int, CRYPTO_memcmp, const void * in_a, in_a, const void * in_b, in_b, size_t len, len, return 1, return);
159DEFINEFUNC(long, OpenSSL_version_num, void, DUMMYARG, return 0, return)
160DEFINEFUNC(const char *, OpenSSL_version, int a, a, return nullptr, return)
161DEFINEFUNC(unsigned long, SSL_SESSION_get_ticket_lifetime_hint, const SSL_SESSION *session, session, return 0, return)
162
163#if QT_CONFIG(dtls)
164DEFINEFUNC2(int, DTLSv1_listen, SSL *s, s, BIO_ADDR *c, c, return -1, return)
165DEFINEFUNC(BIO_ADDR *, BIO_ADDR_new, DUMMYARG, DUMMYARG, return nullptr, return)
166DEFINEFUNC(void, BIO_ADDR_free, BIO_ADDR *ap, ap, return, DUMMYARG)
167DEFINEFUNC2(BIO_METHOD *, BIO_meth_new, int type, type, const char *name, name, return nullptr, return)
168DEFINEFUNC(void, BIO_meth_free, BIO_METHOD *biom, biom, return, DUMMYARG)
169DEFINEFUNC2(int, BIO_meth_set_write, BIO_METHOD *biom, biom, DgramWriteCallback write, write, return 0, return)
170DEFINEFUNC2(int, BIO_meth_set_read, BIO_METHOD *biom, biom, DgramReadCallback read, read, return 0, return)
171DEFINEFUNC2(int, BIO_meth_set_puts, BIO_METHOD *biom, biom, DgramPutsCallback puts, puts, return 0, return)
172DEFINEFUNC2(int, BIO_meth_set_ctrl, BIO_METHOD *biom, biom, DgramCtrlCallback ctrl, ctrl, return 0, return)
173DEFINEFUNC2(int, BIO_meth_set_create, BIO_METHOD *biom, biom, DgramCreateCallback crt, crt, return 0, return)
174DEFINEFUNC2(int, BIO_meth_set_destroy, BIO_METHOD *biom, biom, DgramDestroyCallback dtr, dtr, return 0, return)
175#endif // dtls
176
177#if QT_CONFIG(ocsp)
178DEFINEFUNC(const OCSP_CERTID *, OCSP_SINGLERESP_get0_id, const OCSP_SINGLERESP *x, x, return nullptr, return)
179DEFINEFUNC3(OCSP_RESPONSE *, d2i_OCSP_RESPONSE, OCSP_RESPONSE **a, a, const unsigned char **in, in, long len, len, return nullptr, return)
180DEFINEFUNC(void, OCSP_RESPONSE_free, OCSP_RESPONSE *rs, rs, return, DUMMYARG)
181DEFINEFUNC(OCSP_BASICRESP *, OCSP_response_get1_basic, OCSP_RESPONSE *resp, resp, return nullptr, return)
182DEFINEFUNC(void, OCSP_BASICRESP_free, OCSP_BASICRESP *bs, bs, return, DUMMYARG)
183DEFINEFUNC(int, OCSP_response_status, OCSP_RESPONSE *resp, resp, return OCSP_RESPONSE_STATUS_INTERNALERROR, return)
184DEFINEFUNC4(int, OCSP_basic_verify, OCSP_BASICRESP *bs, bs, STACK_OF(X509) *certs, certs, X509_STORE *st, st, unsigned long flags, flags, return -1, return)
185DEFINEFUNC(int, OCSP_resp_count, OCSP_BASICRESP *bs, bs, return 0, return)
186DEFINEFUNC2(OCSP_SINGLERESP *, OCSP_resp_get0, OCSP_BASICRESP *bs, bs, int idx, idx, return nullptr, return)
187DEFINEFUNC5(int, OCSP_single_get0_status, OCSP_SINGLERESP *single, single, int *reason, reason, ASN1_GENERALIZEDTIME **revtime, revtime,
188 ASN1_GENERALIZEDTIME **thisupd, thisupd, ASN1_GENERALIZEDTIME **nextupd, nextupd, return -1, return)
189DEFINEFUNC4(int, OCSP_check_validity, ASN1_GENERALIZEDTIME *thisupd, thisupd, ASN1_GENERALIZEDTIME *nextupd, nextupd, long nsec, nsec, long maxsec, maxsec, return 0, return)
190DEFINEFUNC3(OCSP_CERTID *, OCSP_cert_to_id, const EVP_MD *dgst, dgst, X509 *subject, subject, X509 *issuer, issuer, return nullptr, return)
191DEFINEFUNC(void, OCSP_CERTID_free, OCSP_CERTID *cid, cid, return, DUMMYARG)
192DEFINEFUNC5(int, OCSP_id_get0_info, ASN1_OCTET_STRING **piNameHash, piNameHash, ASN1_OBJECT **pmd, pmd,
193 ASN1_OCTET_STRING **piKeyHash, piKeyHash, ASN1_INTEGER **pserial, pserial, OCSP_CERTID *cid, cid,
194 return 0, return)
195DEFINEFUNC2(OCSP_RESPONSE *, OCSP_response_create, int status, status, OCSP_BASICRESP *bs, bs, return nullptr, return)
196DEFINEFUNC(const STACK_OF(X509) *, OCSP_resp_get0_certs, const OCSP_BASICRESP *bs, bs, return nullptr, return)
197DEFINEFUNC2(int, OCSP_id_cmp, OCSP_CERTID *a, a, OCSP_CERTID *b, b, return -1, return)
198DEFINEFUNC7(OCSP_SINGLERESP *, OCSP_basic_add1_status, OCSP_BASICRESP *r, r, OCSP_CERTID *c, c, int s, s,
199 int re, re, ASN1_TIME *rt, rt, ASN1_TIME *t, t, ASN1_TIME *n, n, return nullptr, return)
200DEFINEFUNC(OCSP_BASICRESP *, OCSP_BASICRESP_new, DUMMYARG, DUMMYARG, return nullptr, return)
201DEFINEFUNC2(int, i2d_OCSP_RESPONSE, OCSP_RESPONSE *r, r, unsigned char **ppout, ppout, return 0, return)
202DEFINEFUNC6(int, OCSP_basic_sign, OCSP_BASICRESP *br, br, X509 *signer, signer, EVP_PKEY *key, key,
203 const EVP_MD *dg, dg, STACK_OF(X509) *cs, cs, unsigned long flags, flags, return 0, return)
204#endif // ocsp
205
206DEFINEFUNC(void, AUTHORITY_INFO_ACCESS_free, AUTHORITY_INFO_ACCESS *p, p, return, return)
207DEFINEFUNC2(void, BIO_set_data, BIO *a, a, void *ptr, ptr, return, DUMMYARG)
208DEFINEFUNC(void *, BIO_get_data, BIO *a, a, return nullptr, return)
209DEFINEFUNC2(void, BIO_set_init, BIO *a, a, int init, init, return, DUMMYARG)
210DEFINEFUNC(int, BIO_get_shutdown, BIO *a, a, return -1, return)
211DEFINEFUNC2(void, BIO_set_shutdown, BIO *a, a, int shut, shut, return, DUMMYARG)
212
213DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return)
214DEFINEFUNC2(int, ASN1_INTEGER_cmp, const ASN1_INTEGER *a, a, const ASN1_INTEGER *b, b, return 1, return)
215DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return)
216DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, ASN1_STRING *b, b, return 0, return)
217DEFINEFUNC2(int, ASN1_TIME_to_tm, const ASN1_TIME *s, s, struct tm *tm, tm, return 0, return)
218DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return)
219DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return)
220DEFINEFUNC2(BIO *, BIO_new_mem_buf, void *a, a, int b, b, return nullptr, return)
221DEFINEFUNC3(int, BIO_read, BIO *a, a, void *b, b, int c, c, return -1, return)
222
223DEFINEFUNC3(int, BIO_write, BIO *a, a, const void *b, b, int c, c, return -1, return)
224DEFINEFUNC(int, BN_num_bits, const BIGNUM *a, a, return 0, return)
225DEFINEFUNC2(BN_ULONG, BN_mod_word, const BIGNUM *a, a, BN_ULONG w, w, return static_cast<BN_ULONG>(-1), return)
226DEFINEFUNC3(X509 *, d2i_X509, X509 **a, a, const unsigned char **b, b, long c, c, return nullptr, return)
227DEFINEFUNC2(char *, ERR_error_string, unsigned long a, a, char *b, b, return nullptr, return)
228DEFINEFUNC3(void, ERR_error_string_n, unsigned long e, e, char *b, b, size_t len, len, return, DUMMYARG)
229DEFINEFUNC(unsigned long, ERR_get_error, DUMMYARG, DUMMYARG, return 0, return)
230DEFINEFUNC(EVP_CIPHER_CTX *, EVP_CIPHER_CTX_new, void, DUMMYARG, return nullptr, return)
231DEFINEFUNC(void, EVP_CIPHER_CTX_free, EVP_CIPHER_CTX *a, a, return, DUMMYARG)
232DEFINEFUNC4(int, EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX *ctx, ctx, int type, type, int arg, arg, void *ptr, ptr, return 0, return)
233DEFINEFUNC2(int, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX *ctx, ctx, int keylen, keylen, return 0, return)
234DEFINEFUNC5(int, EVP_CipherInit, EVP_CIPHER_CTX *ctx, ctx, const EVP_CIPHER *type, type, const unsigned char *key, key, const unsigned char *iv, iv, int enc, enc, return 0, return)
235DEFINEFUNC6(int, EVP_CipherInit_ex, EVP_CIPHER_CTX *ctx, ctx, const EVP_CIPHER *cipher, cipher, ENGINE *impl, impl, const unsigned char *key, key, const unsigned char *iv, iv, int enc, enc, return 0, return)
236DEFINEFUNC5(int, EVP_CipherUpdate, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, const unsigned char *in, in, int inl, inl, return 0, return)
237DEFINEFUNC3(int, EVP_CipherFinal, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, return 0, return)
238DEFINEFUNC(const EVP_MD *, EVP_get_digestbyname, const char *name, name, return nullptr, return)
239#ifndef OPENSSL_NO_DES
240DEFINEFUNC(const EVP_CIPHER *, EVP_des_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
241DEFINEFUNC(const EVP_CIPHER *, EVP_des_ede3_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
242#endif
243#ifndef OPENSSL_NO_RC2
244DEFINEFUNC(const EVP_CIPHER *, EVP_rc2_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
245#endif
246#ifndef OPENSSL_NO_AES
247DEFINEFUNC(const EVP_CIPHER *, EVP_aes_128_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
248DEFINEFUNC(const EVP_CIPHER *, EVP_aes_192_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
249DEFINEFUNC(const EVP_CIPHER *, EVP_aes_256_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
250#endif
251DEFINEFUNC(const EVP_MD *, EVP_sha1, DUMMYARG, DUMMYARG, return nullptr, return)
252DEFINEFUNC(void, EVP_PKEY_free, EVP_PKEY *a, a, return, DUMMYARG)
253DEFINEFUNC(EVP_PKEY *, EVP_PKEY_new, DUMMYARG, DUMMYARG, return nullptr, return)
254DEFINEFUNC(int, EVP_PKEY_type, int a, a, return NID_undef, return)
255DEFINEFUNC2(int, i2d_X509, X509 *a, a, unsigned char **b, b, return -1, return)
256DEFINEFUNC(const char *, OBJ_nid2sn, int a, a, return nullptr, return)
257DEFINEFUNC(const char *, OBJ_nid2ln, int a, a, return nullptr, return)
258DEFINEFUNC(int, OBJ_sn2nid, const char *s, s, return 0, return)
259DEFINEFUNC(int, OBJ_ln2nid, const char *s, s, return 0, return)
260DEFINEFUNC3(int, i2t_ASN1_OBJECT, char *a, a, int b, b, ASN1_OBJECT *c, c, return -1, return)
261DEFINEFUNC4(int, OBJ_obj2txt, char *a, a, int b, b, ASN1_OBJECT *c, c, int d, d, return -1, return)
262DEFINEFUNC(int, OBJ_obj2nid, const ASN1_OBJECT *a, a, return NID_undef, return)
263DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PrivateKey, BIO *a, a, EVP_PKEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
264
265DEFINEFUNC7(int, PEM_write_bio_PrivateKey, BIO *a, a, EVP_PKEY *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
266DEFINEFUNC7(int, PEM_write_bio_PrivateKey_traditional, BIO *a, a, EVP_PKEY *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
267DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PUBKEY, BIO *a, a, EVP_PKEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
268DEFINEFUNC2(int, PEM_write_bio_PUBKEY, BIO *a, a, EVP_PKEY *b, b, return 0, return)
269DEFINEFUNC2(void, RAND_seed, const void *a, a, int b, b, return, DUMMYARG)
270DEFINEFUNC(int, RAND_status, void, DUMMYARG, return -1, return)
271DEFINEFUNC2(int, RAND_bytes, unsigned char *b, b, int n, n, return 0, return)
272DEFINEFUNC(int, SSL_accept, SSL *a, a, return -1, return)
273DEFINEFUNC(int, SSL_clear, SSL *a, a, return -1, return)
274DEFINEFUNC3(char *, SSL_CIPHER_description, const SSL_CIPHER *a, a, char *b, b, int c, c, return nullptr, return)
275DEFINEFUNC2(int, SSL_CIPHER_get_bits, const SSL_CIPHER *a, a, int *b, b, return 0, return)
276DEFINEFUNC(BIO *, SSL_get_rbio, const SSL *s, s, return nullptr, return)
277DEFINEFUNC(int, SSL_connect, SSL *a, a, return -1, return)
278DEFINEFUNC(int, SSL_CTX_check_private_key, const SSL_CTX *a, a, return -1, return)
279DEFINEFUNC4(long, SSL_CTX_ctrl, SSL_CTX *a, a, int b, b, long c, c, void *d, d, return -1, return)
280DEFINEFUNC(void, SSL_CTX_free, SSL_CTX *a, a, return, DUMMYARG)
281DEFINEFUNC(SSL_CTX *, SSL_CTX_new, const SSL_METHOD *a, a, return nullptr, return)
282DEFINEFUNC2(int, SSL_CTX_set_cipher_list, SSL_CTX *a, a, const char *b, b, return -1, return)
283DEFINEFUNC3(long, SSL_CTX_callback_ctrl, SSL_CTX *ctx, ctx, int dst, dst, GenericCallbackType cb, cb, return 0, return)
284DEFINEFUNC(int, SSL_CTX_set_default_verify_paths, SSL_CTX *a, a, return -1, return)
285DEFINEFUNC3(void, SSL_CTX_set_verify, SSL_CTX *a, a, int b, b, int (*c)(int, X509_STORE_CTX *), c, return, DUMMYARG)
286DEFINEFUNC2(void, SSL_CTX_set_verify_depth, SSL_CTX *a, a, int b, b, return, DUMMYARG)
287DEFINEFUNC2(int, SSL_CTX_use_certificate, SSL_CTX *a, a, X509 *b, b, return -1, return)
288DEFINEFUNC3(int, SSL_CTX_use_certificate_file, SSL_CTX *a, a, const char *b, b, int c, c, return -1, return)
289DEFINEFUNC2(int, SSL_CTX_use_PrivateKey, SSL_CTX *a, a, EVP_PKEY *b, b, return -1, return)
290DEFINEFUNC3(int, SSL_CTX_use_PrivateKey_file, SSL_CTX *a, a, const char *b, b, int c, c, return -1, return)
291DEFINEFUNC(X509_STORE *, SSL_CTX_get_cert_store, const SSL_CTX *a, a, return nullptr, return)
292DEFINEFUNC(SSL_CONF_CTX *, SSL_CONF_CTX_new, DUMMYARG, DUMMYARG, return nullptr, return);
293DEFINEFUNC(void, SSL_CONF_CTX_free, SSL_CONF_CTX *a, a, return ,return);
294DEFINEFUNC2(void, SSL_CONF_CTX_set_ssl_ctx, SSL_CONF_CTX *a, a, SSL_CTX *b, b, return, return);
295DEFINEFUNC2(unsigned int, SSL_CONF_CTX_set_flags, SSL_CONF_CTX *a, a, unsigned int b, b, return 0, return);
296DEFINEFUNC(int, SSL_CONF_CTX_finish, SSL_CONF_CTX *a, a, return 0, return);
297DEFINEFUNC3(int, SSL_CONF_cmd, SSL_CONF_CTX *a, a, const char *b, b, const char *c, c, return 0, return);
298DEFINEFUNC(void, SSL_free, SSL *a, a, return, DUMMYARG)
299DEFINEFUNC(STACK_OF(SSL_CIPHER) *, SSL_get_ciphers, const SSL *a, a, return nullptr, return)
300DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr, return)
301DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
302DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
303DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
304
305#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
306DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
307DEFINEFUNC(int, EVP_PKEY_get_bits, const EVP_PKEY *pkey, pkey, return -1, return)
308DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
309#else
310DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
311DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
312#endif // OPENSSL_VERSION_MAJOR >= 3
313
314DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
315DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
316DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
317DEFINEFUNC4(long, SSL_ctrl, SSL *a, a, int cmd, cmd, long larg, larg, void *parg, parg, return -1, return)
318DEFINEFUNC3(int, SSL_read, SSL *a, a, void *b, b, int c, c, return -1, return)
319DEFINEFUNC3(void, SSL_set_bio, SSL *a, a, BIO *b, b, BIO *c, c, return, DUMMYARG)
320DEFINEFUNC(void, SSL_set_accept_state, SSL *a, a, return, DUMMYARG)
321DEFINEFUNC(void, SSL_set_connect_state, SSL *a, a, return, DUMMYARG)
322DEFINEFUNC(int, SSL_shutdown, SSL *a, a, return -1, return)
323DEFINEFUNC(int, SSL_in_init, const SSL *a, a, return 0, return)
324DEFINEFUNC(int, SSL_get_shutdown, const SSL *ssl, ssl, return 0, return)
325DEFINEFUNC2(int, SSL_set_session, SSL* to, to, SSL_SESSION *session, session, return -1, return)
326DEFINEFUNC(void, SSL_SESSION_free, SSL_SESSION *ses, ses, return, DUMMYARG)
327DEFINEFUNC(SSL_SESSION*, SSL_get1_session, SSL *ssl, ssl, return nullptr, return)
328DEFINEFUNC(SSL_SESSION*, SSL_get_session, const SSL *ssl, ssl, return nullptr, return)
329DEFINEFUNC3(int, SSL_set_ex_data, SSL *ssl, ssl, int idx, idx, void *arg, arg, return 0, return)
330DEFINEFUNC2(void *, SSL_get_ex_data, const SSL *ssl, ssl, int idx, idx, return nullptr, return)
331
332#ifndef OPENSSL_NO_PSK
333DEFINEFUNC2(void, SSL_set_psk_client_callback, SSL* ssl, ssl, q_psk_client_callback_t callback, callback, return, DUMMYARG)
334DEFINEFUNC2(void, SSL_set_psk_server_callback, SSL* ssl, ssl, q_psk_server_callback_t callback, callback, return, DUMMYARG)
335DEFINEFUNC2(int, SSL_CTX_use_psk_identity_hint, SSL_CTX* ctx, ctx, const char *hint, hint, return 0, return)
336#endif // !OPENSSL_NO_PSK
337
338DEFINEFUNC3(int, SSL_write, SSL *a, a, const void *b, b, int c, c, return -1, return)
339DEFINEFUNC2(int, X509_cmp, X509 *a, a, X509 *b, b, return -1, return)
340DEFINEFUNC4(int, X509_digest, const X509 *x509, x509, const EVP_MD *type, type, unsigned char *md, md, unsigned int *len, len, return -1, return)
341DEFINEFUNC(X509 *, X509_dup, X509 *a, a, return nullptr, return)
342DEFINEFUNC2(void, X509_print, BIO *a, a, X509 *b, b, return, DUMMYARG);
343DEFINEFUNC(ASN1_OBJECT *, X509_EXTENSION_get_object, X509_EXTENSION *a, a, return nullptr, return)
344DEFINEFUNC(void, X509_free, X509 *a, a, return, DUMMYARG)
345//Q_AUTOTEST_EXPORT ASN1_TIME *q_X509_gmtime_adj(ASN1_TIME *s, long adj);
346DEFINEFUNC2(ASN1_TIME *, X509_gmtime_adj, ASN1_TIME *s, s, long adj, adj, return nullptr, return)
347DEFINEFUNC(void, ASN1_TIME_free, ASN1_TIME *t, t, return, DUMMYARG)
348DEFINEFUNC2(X509_EXTENSION *, X509_get_ext, X509 *a, a, int b, b, return nullptr, return)
349DEFINEFUNC(int, X509_get_ext_count, X509 *a, a, return 0, return)
350DEFINEFUNC4(void *, X509_get_ext_d2i, X509 *a, a, int b, b, int *c, c, int *d, d, return nullptr, return)
351DEFINEFUNC(const X509V3_EXT_METHOD *, X509V3_EXT_get, X509_EXTENSION *a, a, return nullptr, return)
352DEFINEFUNC(void *, X509V3_EXT_d2i, X509_EXTENSION *a, a, return nullptr, return)
353DEFINEFUNC(int, X509_EXTENSION_get_critical, X509_EXTENSION *a, a, return 0, return)
354DEFINEFUNC(ASN1_OCTET_STRING *, X509_EXTENSION_get_data, X509_EXTENSION *a, a, return nullptr, return)
355DEFINEFUNC(void, BASIC_CONSTRAINTS_free, BASIC_CONSTRAINTS *a, a, return, DUMMYARG)
356DEFINEFUNC(void, AUTHORITY_KEYID_free, AUTHORITY_KEYID *a, a, return, DUMMYARG)
357DEFINEFUNC(void, GENERAL_NAME_free, GENERAL_NAME *a, a, return, DUMMYARG)
358DEFINEFUNC2(int, ASN1_STRING_print, BIO *a, a, const ASN1_STRING *b, b, return 0, return)
359DEFINEFUNC2(int, X509_check_issued, X509 *a, a, X509 *b, b, return -1, return)
360DEFINEFUNC(X509_NAME *, X509_get_issuer_name, X509 *a, a, return nullptr, return)
361DEFINEFUNC(X509_NAME *, X509_get_subject_name, X509 *a, a, return nullptr, return)
362DEFINEFUNC(ASN1_INTEGER *, X509_get_serialNumber, X509 *a, a, return nullptr, return)
363DEFINEFUNC(int, X509_verify_cert, X509_STORE_CTX *a, a, return -1, return)
364DEFINEFUNC(int, X509_NAME_entry_count, X509_NAME *a, a, return 0, return)
365DEFINEFUNC2(X509_NAME_ENTRY *, X509_NAME_get_entry, X509_NAME *a, a, int b, b, return nullptr, return)
366DEFINEFUNC(ASN1_STRING *, X509_NAME_ENTRY_get_data, X509_NAME_ENTRY *a, a, return nullptr, return)
367DEFINEFUNC(ASN1_OBJECT *, X509_NAME_ENTRY_get_object, X509_NAME_ENTRY *a, a, return nullptr, return)
368DEFINEFUNC(EVP_PKEY *, X509_PUBKEY_get, X509_PUBKEY *a, a, return nullptr, return)
369DEFINEFUNC(void, X509_STORE_free, X509_STORE *a, a, return, DUMMYARG)
370DEFINEFUNC(X509_STORE *, X509_STORE_new, DUMMYARG, DUMMYARG, return nullptr, return)
371DEFINEFUNC2(int, X509_STORE_add_cert, X509_STORE *a, a, X509 *b, b, return 0, return)
372DEFINEFUNC(void, X509_STORE_CTX_free, X509_STORE_CTX *a, a, return, DUMMYARG)
373DEFINEFUNC4(int, X509_STORE_CTX_init, X509_STORE_CTX *a, a, X509_STORE *b, b, X509 *c, c, STACK_OF(X509) *d, d, return -1, return)
374DEFINEFUNC2(int, X509_STORE_CTX_set_purpose, X509_STORE_CTX *a, a, int b, b, return -1, return)
375DEFINEFUNC(int, X509_STORE_CTX_get_error, X509_STORE_CTX *a, a, return -1, return)
376DEFINEFUNC(int, X509_STORE_CTX_get_error_depth, X509_STORE_CTX *a, a, return -1, return)
377DEFINEFUNC(X509 *, X509_STORE_CTX_get_current_cert, X509_STORE_CTX *a, a, return nullptr, return)
378DEFINEFUNC(X509_STORE *, X509_STORE_CTX_get0_store, X509_STORE_CTX *ctx, ctx, return nullptr, return)
379DEFINEFUNC(X509_STORE_CTX *, X509_STORE_CTX_new, DUMMYARG, DUMMYARG, return nullptr, return)
380DEFINEFUNC2(void *, X509_STORE_CTX_get_ex_data, X509_STORE_CTX *ctx, ctx, int idx, idx, return nullptr, return)
381DEFINEFUNC(int, SSL_get_ex_data_X509_STORE_CTX_idx, DUMMYARG, DUMMYARG, return -1, return)
382
383#if OPENSSL_VERSION_MAJOR < 3
384DEFINEFUNC3(int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx, const char *CAfile, CAfile, const char *CApath, CApath, return 0, return)
385#else
386DEFINEFUNC2(int, SSL_CTX_load_verify_dir, SSL_CTX *ctx, ctx, const char *CApath, CApath, return 0, return)
387#endif // OPENSSL_VERSION_MAJOR
388
389DEFINEFUNC2(int, i2d_SSL_SESSION, SSL_SESSION *in, in, unsigned char **pp, pp, return 0, return)
390DEFINEFUNC3(SSL_SESSION *, d2i_SSL_SESSION, SSL_SESSION **a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
391
392#ifndef OPENSSL_NO_NEXTPROTONEG
393DEFINEFUNC6(int, SSL_select_next_proto, unsigned char **out, out, unsigned char *outlen, outlen,
394 const unsigned char *in, in, unsigned int inlen, inlen,
395 const unsigned char *client, client, unsigned int client_len, client_len,
396 return -1, return)
397DEFINEFUNC3(void, SSL_CTX_set_next_proto_select_cb, SSL_CTX *s, s,
398 int (*cb) (SSL *ssl, unsigned char **out,
399 unsigned char *outlen,
400 const unsigned char *in,
401 unsigned int inlen, void *arg), cb,
402 void *arg, arg, return, DUMMYARG)
403DEFINEFUNC3(void, SSL_get0_next_proto_negotiated, const SSL *s, s,
404 const unsigned char **data, data, unsigned *len, len, return, DUMMYARG)
405DEFINEFUNC3(int, SSL_set_alpn_protos, SSL *s, s, const unsigned char *protos, protos,
406 unsigned protos_len, protos_len, return -1, return)
407DEFINEFUNC3(void, SSL_CTX_set_alpn_select_cb, SSL_CTX *s, s,
408 int (*cb) (SSL *ssl, const unsigned char **out,
409 unsigned char *outlen,
410 const unsigned char *in,
411 unsigned int inlen, void *arg), cb,
412 void *arg, arg, return, DUMMYARG)
413DEFINEFUNC3(void, SSL_get0_alpn_selected, const SSL *s, s, const unsigned char **data, data,
414 unsigned *len, len, return, DUMMYARG)
415#endif // !OPENSSL_NO_NEXTPROTONEG
416
417// DTLS:
418#if QT_CONFIG(dtls)
419DEFINEFUNC2(void, SSL_CTX_set_cookie_generate_cb, SSL_CTX *ctx, ctx, CookieGenerateCallback cb, cb, return, DUMMYARG)
420DEFINEFUNC2(void, SSL_CTX_set_cookie_verify_cb, SSL_CTX *ctx, ctx, CookieVerifyCallback cb, cb, return, DUMMYARG)
421DEFINEFUNC(const SSL_METHOD *, DTLS_server_method, DUMMYARG, DUMMYARG, return nullptr, return)
422DEFINEFUNC(const SSL_METHOD *, DTLS_client_method, DUMMYARG, DUMMYARG, return nullptr, return)
423#endif // dtls
424DEFINEFUNC2(void, BIO_set_flags, BIO *b, b, int flags, flags, return, DUMMYARG)
425DEFINEFUNC2(void, BIO_clear_flags, BIO *b, b, int flags, flags, return, DUMMYARG)
426DEFINEFUNC2(void *, BIO_get_ex_data, BIO *b, b, int idx, idx, return nullptr, return)
427DEFINEFUNC3(int, BIO_set_ex_data, BIO *b, b, int idx, idx, void *data, data, return -1, return)
428
429DEFINEFUNC3(void *, CRYPTO_malloc, size_t num, num, const char *file, file, int line, line, return nullptr, return)
430
431#ifndef OPENSSL_NO_DEPRECATED_3_0
432DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
433DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
434DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
435DEFINEFUNC4(void, DH_get0_pqg, const DH *dh, dh, const BIGNUM **p, p, const BIGNUM **q, q, const BIGNUM **g, g, return, DUMMYARG)
436
437DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
438DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
439
440DEFINEFUNC4(DH *, PEM_read_bio_DHparams, BIO *a, a, DH **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
441#endif
442DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
443
444
445#ifndef OPENSSL_NO_EC
446DEFINEFUNC2(size_t, EC_get_builtin_curves, EC_builtin_curve * r, r, size_t nitems, nitems, return 0, return)
447DEFINEFUNC(int, EC_curve_nist2nid, const char *name, name, return 0, return)
448#endif // OPENSSL_NO_EC
449
450DEFINEFUNC5(int, PKCS12_parse, PKCS12 *p12, p12, const char *pass, pass, EVP_PKEY **pkey, pkey, \
451 X509 **cert, cert, STACK_OF(X509) **ca, ca, return 1, return);
452DEFINEFUNC2(PKCS12 *, d2i_PKCS12_bio, BIO *bio, bio, PKCS12 **pkcs12, pkcs12, return nullptr, return);
453DEFINEFUNC(void, PKCS12_free, PKCS12 *pkcs12, pkcs12, return, DUMMYARG)
454
455#ifndef OPENSSL_NO_DEPRECATED_3_0
456
457DEFINEFUNC4(DSA *, PEM_read_bio_DSA_PUBKEY, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
458DEFINEFUNC4(RSA *, PEM_read_bio_RSA_PUBKEY, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
459DEFINEFUNC4(DSA *, PEM_read_bio_DSAPrivateKey, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
460DEFINEFUNC4(RSA *, PEM_read_bio_RSAPrivateKey, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
461
462DEFINEFUNC2(int, PEM_write_bio_DSA_PUBKEY, BIO *a, a, DSA *b, b, return 0, return)
463DEFINEFUNC2(int, PEM_write_bio_RSA_PUBKEY, BIO *a, a, RSA *b, b, return 0, return)
464DEFINEFUNC7(int, PEM_write_bio_DSAPrivateKey, BIO *a, a, DSA *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
465DEFINEFUNC7(int, PEM_write_bio_RSAPrivateKey, BIO *a, a, RSA *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
466
467DEFINEFUNC2(int, SSL_CTX_use_RSAPrivateKey, SSL_CTX *a, a, RSA *b, b, return -1, return)
468
469DEFINEFUNC(DSA *, DSA_new, DUMMYARG, DUMMYARG, return nullptr, return)
470DEFINEFUNC(void, DSA_free, DSA *a, a, return, DUMMYARG)
471
472DEFINEFUNC(RSA *, RSA_new, DUMMYARG, DUMMYARG, return nullptr, return)
473DEFINEFUNC(void, RSA_free, RSA *a, a, return, DUMMYARG)
474
475DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
476DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
477DEFINEFUNC(int, DH_bits, DH *dh, dh, return 0, return)
478
479DEFINEFUNC(DSA *, EVP_PKEY_get1_DSA, EVP_PKEY *a, a, return nullptr, return)
480DEFINEFUNC(RSA *, EVP_PKEY_get1_RSA, EVP_PKEY *a, a, return nullptr, return)
481DEFINEFUNC(DH *, EVP_PKEY_get1_DH, EVP_PKEY *a, a, return nullptr, return)
482
483DEFINEFUNC2(int, EVP_PKEY_cmp, const EVP_PKEY *a, a, const EVP_PKEY *b, b, return -1, return)
484DEFINEFUNC3(int, EVP_PKEY_assign, EVP_PKEY *a, a, int b, b, void *r, r, return -1, return)
485
486DEFINEFUNC2(int, EVP_PKEY_set1_RSA, EVP_PKEY *a, a, RSA *b, b, return -1, return)
487DEFINEFUNC2(int, EVP_PKEY_set1_DSA, EVP_PKEY *a, a, DSA *b, b, return -1, return)
488DEFINEFUNC2(int, EVP_PKEY_set1_DH, EVP_PKEY *a, a, DH *b, b, return -1, return)
489
490#ifndef OPENSSL_NO_EC
491
492DEFINEFUNC4(EC_KEY *, PEM_read_bio_EC_PUBKEY, BIO *a, a, EC_KEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
493DEFINEFUNC4(EC_KEY *, PEM_read_bio_ECPrivateKey, BIO *a, a, EC_KEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
494
495DEFINEFUNC2(int, PEM_write_bio_EC_PUBKEY, BIO *a, a, EC_KEY *b, b, return 0, return)
496DEFINEFUNC7(int, PEM_write_bio_ECPrivateKey, BIO *a, a, EC_KEY *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
497
498DEFINEFUNC(const EC_GROUP*, EC_KEY_get0_group, const EC_KEY* k, k, return nullptr, return)
499DEFINEFUNC(int, EC_GROUP_get_degree, const EC_GROUP* g, g, return 0, return)
500
501DEFINEFUNC2(int, EVP_PKEY_set1_EC_KEY, EVP_PKEY *a, a, EC_KEY *b, b, return -1, return)
502DEFINEFUNC(EC_KEY *, EVP_PKEY_get1_EC_KEY, EVP_PKEY *a, a, return nullptr, return)
503
504DEFINEFUNC(EC_KEY *, EC_KEY_dup, const EC_KEY *ec, ec, return nullptr, return)
505DEFINEFUNC(EC_KEY *, EC_KEY_new_by_curve_name, int nid, nid, return nullptr, return)
506DEFINEFUNC(void, EC_KEY_free, EC_KEY *ecdh, ecdh, return, DUMMYARG)
507
508#endif // OPENSSL_NO_EC
509
510
511
512#endif
513
514#define RESOLVEFUNC(func) \
515 if (!(_q_##func = _q_PTR_##func(libs.ssl->resolve(#func))) \
516 && !(_q_##func = _q_PTR_##func(libs.crypto->resolve(#func)))) \
517 qsslSocketCannotResolveSymbolWarning(#func);
518
519#if !defined QT_LINKED_OPENSSL
520
521#if !QT_CONFIG(library)
522bool q_resolveOpenSslSymbols()
523{
524 qCWarning(lcTlsBackend, "QSslSocket: unable to resolve symbols. Qt is configured without the "
525 "'library' feature, which means runtime resolving of libraries won't work.");
526 qCWarning(lcTlsBackend, "Either compile Qt statically or with support for runtime resolving "
527 "of libraries.");
528 return false;
529}
530#else
531
532# ifdef Q_OS_UNIX
533struct NumericallyLess
534{
535 typedef bool result_type;
536 result_type operator()(QStringView lhs, QStringView rhs) const
537 {
538 bool ok = false;
539 int b = 0;
540 int a = lhs.toInt(ok: &ok);
541 if (ok)
542 b = rhs.toInt(ok: &ok);
543 if (ok) {
544 // both toInt succeeded
545 return a < b;
546 } else {
547 // compare as strings;
548 return lhs < rhs;
549 }
550 }
551};
552
553struct LibGreaterThan
554{
555 typedef bool result_type;
556 result_type operator()(QStringView lhs, QStringView rhs) const
557 {
558 const auto lhsparts = lhs.split(sep: u'.');
559 const auto rhsparts = rhs.split(sep: u'.');
560 Q_ASSERT(lhsparts.size() > 1 && rhsparts.size() > 1);
561
562 // note: checking rhs < lhs, the same as lhs > rhs
563 return std::lexicographical_compare(first1: rhsparts.begin() + 1, last1: rhsparts.end(),
564 first2: lhsparts.begin() + 1, last2: lhsparts.end(),
565 comp: NumericallyLess());
566 }
567};
568
569#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
570static int dlIterateCallback(struct dl_phdr_info *info, size_t size, void *data)
571{
572 if (size < sizeof (info->dlpi_addr) + sizeof (info->dlpi_name))
573 return 1;
574 QDuplicateTracker<QString> *paths = (QDuplicateTracker<QString> *)data;
575 QString path = QString::fromLocal8Bit(ba: info->dlpi_name);
576 if (!path.isEmpty()) {
577 QFileInfo fi(path);
578 path = fi.absolutePath();
579 if (!path.isEmpty())
580 (void)paths->hasSeen(s: std::move(path));
581 }
582 return 0;
583}
584#endif
585
586static QStringList libraryPathList()
587{
588 QStringList paths;
589# ifdef Q_OS_DARWIN
590 paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH")).split(u':', Qt::SkipEmptyParts);
591
592 // search in .app/Contents/Frameworks
593 UInt32 packageType;
594 CFBundleGetPackageInfo(CFBundleGetMainBundle(), &packageType, nullptr);
595 if (packageType == FOUR_CHAR_CODE('APPL')) {
596 QUrl bundleUrl = QUrl::fromCFURL(QCFType<CFURLRef>(CFBundleCopyBundleURL(CFBundleGetMainBundle())));
597 QUrl frameworksUrl = QUrl::fromCFURL(QCFType<CFURLRef>(CFBundleCopyPrivateFrameworksURL(CFBundleGetMainBundle())));
598 paths << bundleUrl.resolved(frameworksUrl).path();
599 }
600# else
601 paths = QString::fromLatin1(ba: qgetenv(varName: "LD_LIBRARY_PATH")).split(sep: u':', behavior: Qt::SkipEmptyParts);
602# endif
603 paths << "/lib"_L1 << "/usr/lib"_L1 << "/usr/local/lib"_L1;
604 paths << "/lib64"_L1 << "/usr/lib64"_L1 << "/usr/local/lib64"_L1;
605 paths << "/lib32"_L1 << "/usr/lib32"_L1 << "/usr/local/lib32"_L1;
606
607#if defined(Q_OS_ANDROID)
608 paths << "/system/lib"_L1;
609#elif defined(Q_OS_LINUX)
610 // discover paths of already loaded libraries
611 QDuplicateTracker<QString> loadedPaths;
612 dl_iterate_phdr(callback: dlIterateCallback, data: &loadedPaths);
613 std::move(loadedPaths).appendTo(c&: paths);
614#endif
615
616 return paths;
617}
618
619Q_NEVER_INLINE
620static QStringList findAllLibs(QLatin1StringView filter)
621{
622 const QStringList paths = libraryPathList();
623 QStringList found;
624 const QStringList filters((QString(filter)));
625
626 for (const QString &path : paths) {
627 QDir dir(path);
628 QStringList entryList = dir.entryList(nameFilters: filters, filters: QDir::Files);
629
630 std::sort(first: entryList.begin(), last: entryList.end(), comp: LibGreaterThan());
631 for (const QString &entry : std::as_const(t&: entryList))
632 found << path + u'/' + entry;
633 }
634
635 return found;
636}
637
638static QStringList findAllLibSsl()
639{
640 return findAllLibs(filter: "libssl.*"_L1);
641}
642
643static QStringList findAllLibCrypto()
644{
645 return findAllLibs(filter: "libcrypto.*"_L1);
646}
647# endif
648
649#if (OPENSSL_VERSION_NUMBER >> 28) < 3
650#define QT_OPENSSL_VERSION "1_1"
651#elif OPENSSL_VERSION_MAJOR == 3 // Starting with 3.0 this define is available
652#define QT_OPENSSL_VERSION "3"
653#endif // > 3 intentionally left undefined
654
655#ifdef Q_OS_WIN
656
657struct LoadedOpenSsl {
658 std::unique_ptr<QSystemLibrary> ssl, crypto;
659};
660
661static bool tryToLoadOpenSslWin32Library(QLatin1StringView ssleay32LibName, QLatin1StringView libeay32LibName, LoadedOpenSsl &result)
662{
663 auto ssleay32 = std::make_unique<QSystemLibrary>(ssleay32LibName);
664 if (!ssleay32->load(false)) {
665 return FALSE;
666 }
667
668 auto libeay32 = std::make_unique<QSystemLibrary>(libeay32LibName);
669 if (!libeay32->load(false)) {
670 return FALSE;
671 }
672
673 result.ssl = std::move(ssleay32);
674 result.crypto = std::move(libeay32);
675 return TRUE;
676}
677
678static LoadedOpenSsl loadOpenSsl()
679{
680 LoadedOpenSsl result;
681
682 // With OpenSSL 1.1 the names have changed to libssl-1_1 and libcrypto-1_1 for builds using
683 // MSVC and GCC. For 3.0 the version suffix changed again, to just '3'.
684 // For non-x86 builds, an architecture suffix is also appended.
685
686#if defined(Q_PROCESSOR_X86_64)
687#define QT_SSL_SUFFIX "-x64"
688#elif defined(Q_PROCESSOR_ARM_64)
689#define QT_SSL_SUFFIX "-arm64"
690#elif defined(Q_PROCESSOR_ARM_32)
691#define QT_SSL_SUFFIX "-arm"
692#else
693#define QT_SSL_SUFFIX
694#endif
695
696 tryToLoadOpenSslWin32Library("libssl-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1,
697 "libcrypto-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1, result);
698
699#undef QT_SSL_SUFFIX
700 return result;
701}
702#else // !Q_OS_WIN:
703
704struct LoadedOpenSsl {
705 std::unique_ptr<QLibrary> ssl, crypto;
706};
707
708static LoadedOpenSsl loadOpenSsl()
709{
710 LoadedOpenSsl result = { .ssl: std::make_unique<QLibrary>(), .crypto: std::make_unique<QLibrary>() };
711
712# if defined(Q_OS_UNIX)
713 QLibrary * const libssl = result.ssl.get();
714 QLibrary * const libcrypto = result.crypto.get();
715
716 // Try to find the libssl library on the system.
717 //
718 // Up until Qt 4.3, this only searched for the "ssl" library at version -1, that
719 // is, libssl.so on most Unix systems. However, the .so file isn't present in
720 // user installations because it's considered a development file.
721 //
722 // The right thing to do is to load the library at the major version we know how
723 // to work with: the SHLIB_VERSION_NUMBER version (macro defined in opensslv.h)
724 //
725 // However, OpenSSL is a well-known case of binary-compatibility breakage. To
726 // avoid such problems, many system integrators and Linux distributions change
727 // the soname of the binary, letting the full version number be the soname. So
728 // we'll find libssl.so.0.9.7, libssl.so.0.9.8, etc. in the system. For that
729 // reason, we will search a few common paths (see findAllLibSsl() above) in hopes
730 // we find one that works.
731 //
732 // If that fails, for OpenSSL 1.0 we also try some fallbacks -- look up
733 // libssl.so with a hardcoded soname. The reason is QTBUG-68156: the binary
734 // builds of Qt happen (at the time of this writing) on RHEL machines,
735 // which change SHLIB_VERSION_NUMBER to a non-portable string. When running
736 // those binaries on the target systems, this code won't pick up
737 // libssl.so.MODIFIED_SHLIB_VERSION_NUMBER because it doesn't exist there.
738 // Given that the only 1.0 supported release (at the time of this writing)
739 // is 1.0.2, with soname "1.0.0", give that a try too. Note that we mandate
740 // OpenSSL >= 1.0.0 with a configure-time check, and OpenSSL has kept binary
741 // compatibility between 1.0.0 and 1.0.2.
742 //
743 // It is important, however, to try the canonical name and the unversioned name
744 // without going through the loop. By not specifying a path, we let the system
745 // dlopen(3) function determine it for us. This will include any DT_RUNPATH or
746 // DT_RPATH tags on our library header as well as other system-specific search
747 // paths. See the man page for dlopen(3) on your system for more information.
748
749#ifdef Q_OS_OPENBSD
750 libcrypto->setLoadHints(QLibrary::ExportExternalSymbolsHint);
751#endif
752#if defined(SHLIB_VERSION_NUMBER) && !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so
753 // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
754 libssl->setFileNameAndVersion("ssl"_L1, SHLIB_VERSION_NUMBER ""_L1);
755 libcrypto->setFileNameAndVersion("crypto"_L1, SHLIB_VERSION_NUMBER ""_L1);
756 if (libcrypto->load() && libssl->load()) {
757 // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
758 return result;
759 } else {
760 libssl->unload();
761 libcrypto->unload();
762 }
763#endif
764
765#ifndef Q_OS_DARWIN
766 // second attempt: find the development files libssl.so and libcrypto.so
767 //
768 // disabled on macOS/iOS:
769 // macOS's /usr/lib/libssl.dylib, /usr/lib/libcrypto.dylib will be picked up in the third
770 // attempt, _after_ <bundle>/Contents/Frameworks has been searched.
771 // iOS does not ship a system libssl.dylib, libcrypto.dylib in the first place.
772# if defined(Q_OS_ANDROID)
773 // OpenSSL 1.1.x must be suffixed otherwise it will use the system libcrypto.so libssl.so which on API-21 are OpenSSL 1.0 not 1.1
774 auto openSSLSuffix = [](const QByteArray &defaultSuffix = {}) {
775 auto suffix = qgetenv("ANDROID_OPENSSL_SUFFIX");
776 if (suffix.isEmpty())
777 return defaultSuffix;
778 return suffix;
779 };
780
781 static QString suffix = QString::fromLatin1(openSSLSuffix("_" QT_OPENSSL_VERSION));
782
783 libssl->setFileNameAndVersion("ssl"_L1 + suffix, -1);
784 libcrypto->setFileNameAndVersion("crypto"_L1 + suffix, -1);
785# else
786 libssl->setFileNameAndVersion(fileName: "ssl"_L1, verNum: -1);
787 libcrypto->setFileNameAndVersion(fileName: "crypto"_L1, verNum: -1);
788# endif
789 if (libcrypto->load() && libssl->load()) {
790 // libssl.so.0 and libcrypto.so.0 found
791 return result;
792 } else {
793 libssl->unload();
794 libcrypto->unload();
795 }
796#endif
797
798 // third attempt: loop on the most common library paths and find libssl
799 const QStringList sslList = findAllLibSsl();
800 const QStringList cryptoList = findAllLibCrypto();
801
802 for (const QString &crypto : cryptoList) {
803#ifdef Q_OS_DARWIN
804 // Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI
805 if (crypto.endsWith("libcrypto.dylib"))
806 continue;
807#endif
808 libcrypto->setFileNameAndVersion(fileName: crypto, verNum: -1);
809 if (libcrypto->load()) {
810 QFileInfo fi(crypto);
811 QString version = fi.completeSuffix();
812
813 for (const QString &ssl : sslList) {
814 if (!ssl.endsWith(s: version))
815 continue;
816
817 libssl->setFileNameAndVersion(fileName: ssl, verNum: -1);
818
819 if (libssl->load()) {
820 // libssl.so.x and libcrypto.so.x found
821 return result;
822 } else {
823 libssl->unload();
824 }
825 }
826 }
827 libcrypto->unload();
828 }
829
830 // failed to load anything
831 result = {};
832 return result;
833
834# else
835 // not implemented for this platform yet
836 return result;
837# endif
838}
839#endif
840
841bool q_resolveOpenSslSymbols()
842{
843 static bool symbolsResolved = []() {
844 LoadedOpenSsl libs = loadOpenSsl();
845 if (!libs.ssl || !libs.crypto) {
846 qCWarning(lcTlsBackend, "Failed to load libssl/libcrypto.");
847 return false;
848 }
849
850 RESOLVEFUNC(OPENSSL_init_ssl)
851 RESOLVEFUNC(OPENSSL_init_crypto)
852 RESOLVEFUNC(ASN1_STRING_get0_data)
853 RESOLVEFUNC(EVP_CIPHER_CTX_reset)
854 RESOLVEFUNC(AUTHORITY_INFO_ACCESS_free)
855 RESOLVEFUNC(EVP_PKEY_up_ref)
856 RESOLVEFUNC(EVP_PKEY_CTX_new)
857 RESOLVEFUNC(EVP_PKEY_param_check)
858 RESOLVEFUNC(EVP_PKEY_CTX_free)
859 RESOLVEFUNC(OPENSSL_sk_new_null)
860 RESOLVEFUNC(OPENSSL_sk_push)
861 RESOLVEFUNC(OPENSSL_sk_free)
862 RESOLVEFUNC(OPENSSL_sk_num)
863 RESOLVEFUNC(OPENSSL_sk_pop_free)
864 RESOLVEFUNC(OPENSSL_sk_value)
865 RESOLVEFUNC(SSL_CTX_set_options)
866 RESOLVEFUNC(SSL_set_info_callback)
867 RESOLVEFUNC(SSL_alert_type_string)
868 RESOLVEFUNC(SSL_alert_desc_string_long)
869 RESOLVEFUNC(SSL_CTX_get_security_level)
870 RESOLVEFUNC(SSL_CTX_set_security_level)
871#ifdef TLS1_3_VERSION
872 RESOLVEFUNC(SSL_CTX_set_ciphersuites)
873 RESOLVEFUNC(SSL_set_psk_use_session_callback)
874 RESOLVEFUNC(SSL_CTX_sess_set_new_cb)
875 RESOLVEFUNC(SSL_SESSION_is_resumable)
876#endif // TLS 1.3 or OpenSSL > 1.1.1
877
878 RESOLVEFUNC(SSL_get_client_random)
879 RESOLVEFUNC(SSL_SESSION_get_master_key)
880 RESOLVEFUNC(SSL_session_reused)
881 RESOLVEFUNC(SSL_get_session)
882 RESOLVEFUNC(SSL_set_options)
883 RESOLVEFUNC(CRYPTO_get_ex_new_index)
884 RESOLVEFUNC(TLS_method)
885 RESOLVEFUNC(TLS_client_method)
886 RESOLVEFUNC(TLS_server_method)
887 RESOLVEFUNC(X509_up_ref)
888 RESOLVEFUNC(X509_STORE_CTX_get0_chain)
889 RESOLVEFUNC(X509_getm_notBefore)
890 RESOLVEFUNC(X509_getm_notAfter)
891 RESOLVEFUNC(ASN1_item_free)
892 RESOLVEFUNC(X509V3_conf_free)
893 RESOLVEFUNC(X509_get_version)
894 RESOLVEFUNC(X509_get_pubkey)
895 RESOLVEFUNC(X509_STORE_set_verify_cb)
896 RESOLVEFUNC(X509_STORE_set_ex_data)
897 RESOLVEFUNC(X509_STORE_get_ex_data)
898 RESOLVEFUNC(CRYPTO_free)
899 RESOLVEFUNC(CRYPTO_memcmp)
900 RESOLVEFUNC(OpenSSL_version_num)
901 RESOLVEFUNC(OpenSSL_version)
902
903 if (!_q_OpenSSL_version || !_q_OpenSSL_version_num) {
904 // Apparently, we were built with OpenSSL 1.1 enabled but are now using
905 // a wrong library.
906 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL");
907 return false;
908 }
909
910#if OPENSSL_VERSION_NUMBER >= 0x30000000
911 if (q_OpenSSL_version_num() < 0x30000000) {
912 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL (built with OpenSSL >= 3.x, runtime version is < 3.x)");
913 return false;
914 }
915#else
916 if (q_OpenSSL_version_num() >= 0x30000000) {
917 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL (built with OpenSSL 1.x, runtime version is >= 3.x)");
918 return false;
919 }
920#endif // OPENSSL_VERSION_NUMBER
921
922 RESOLVEFUNC(SSL_SESSION_get_ticket_lifetime_hint)
923
924#if QT_CONFIG(dtls)
925 RESOLVEFUNC(DTLSv1_listen)
926 RESOLVEFUNC(BIO_ADDR_new)
927 RESOLVEFUNC(BIO_ADDR_free)
928 RESOLVEFUNC(BIO_meth_new)
929 RESOLVEFUNC(BIO_meth_free)
930 RESOLVEFUNC(BIO_meth_set_write)
931 RESOLVEFUNC(BIO_meth_set_read)
932 RESOLVEFUNC(BIO_meth_set_puts)
933 RESOLVEFUNC(BIO_meth_set_ctrl)
934 RESOLVEFUNC(BIO_meth_set_create)
935 RESOLVEFUNC(BIO_meth_set_destroy)
936#endif // dtls
937
938#if QT_CONFIG(ocsp)
939 RESOLVEFUNC(OCSP_SINGLERESP_get0_id)
940 RESOLVEFUNC(d2i_OCSP_RESPONSE)
941 RESOLVEFUNC(OCSP_RESPONSE_free)
942 RESOLVEFUNC(OCSP_response_status)
943 RESOLVEFUNC(OCSP_response_get1_basic)
944 RESOLVEFUNC(OCSP_BASICRESP_free)
945 RESOLVEFUNC(OCSP_basic_verify)
946 RESOLVEFUNC(OCSP_resp_count)
947 RESOLVEFUNC(OCSP_resp_get0)
948 RESOLVEFUNC(OCSP_single_get0_status)
949 RESOLVEFUNC(OCSP_check_validity)
950 RESOLVEFUNC(OCSP_cert_to_id)
951 RESOLVEFUNC(OCSP_id_get0_info)
952 RESOLVEFUNC(OCSP_resp_get0_certs)
953 RESOLVEFUNC(OCSP_basic_sign)
954 RESOLVEFUNC(OCSP_response_create)
955 RESOLVEFUNC(i2d_OCSP_RESPONSE)
956 RESOLVEFUNC(OCSP_basic_add1_status)
957 RESOLVEFUNC(OCSP_BASICRESP_new)
958 RESOLVEFUNC(OCSP_CERTID_free)
959 RESOLVEFUNC(OCSP_cert_to_id)
960 RESOLVEFUNC(OCSP_id_cmp)
961#endif // ocsp
962
963 RESOLVEFUNC(BIO_set_data)
964 RESOLVEFUNC(BIO_get_data)
965 RESOLVEFUNC(BIO_set_init)
966 RESOLVEFUNC(BIO_get_shutdown)
967 RESOLVEFUNC(BIO_set_shutdown)
968 RESOLVEFUNC(ASN1_INTEGER_get)
969 RESOLVEFUNC(ASN1_INTEGER_cmp)
970 RESOLVEFUNC(ASN1_STRING_length)
971 RESOLVEFUNC(ASN1_STRING_to_UTF8)
972 RESOLVEFUNC(ASN1_TIME_to_tm)
973 RESOLVEFUNC(BIO_ctrl)
974 RESOLVEFUNC(BIO_free)
975 RESOLVEFUNC(BIO_new)
976 RESOLVEFUNC(BIO_new_mem_buf)
977 RESOLVEFUNC(BIO_read)
978 RESOLVEFUNC(BIO_s_mem)
979 RESOLVEFUNC(BIO_write)
980 RESOLVEFUNC(BIO_set_flags)
981 RESOLVEFUNC(BIO_clear_flags)
982 RESOLVEFUNC(BIO_set_ex_data)
983 RESOLVEFUNC(BIO_get_ex_data)
984 RESOLVEFUNC(BN_num_bits)
985 RESOLVEFUNC(BN_is_word)
986 RESOLVEFUNC(BN_mod_word)
987 RESOLVEFUNC(ERR_error_string)
988 RESOLVEFUNC(ERR_error_string_n)
989 RESOLVEFUNC(ERR_get_error)
990 RESOLVEFUNC(EVP_CIPHER_CTX_new)
991 RESOLVEFUNC(EVP_CIPHER_CTX_free)
992 RESOLVEFUNC(EVP_CIPHER_CTX_ctrl)
993 RESOLVEFUNC(EVP_CIPHER_CTX_set_key_length)
994 RESOLVEFUNC(EVP_CipherInit)
995 RESOLVEFUNC(EVP_CipherInit_ex)
996 RESOLVEFUNC(EVP_CipherUpdate)
997 RESOLVEFUNC(EVP_CipherFinal)
998 RESOLVEFUNC(EVP_get_digestbyname)
999#ifndef OPENSSL_NO_DES
1000 RESOLVEFUNC(EVP_des_cbc)
1001 RESOLVEFUNC(EVP_des_ede3_cbc)
1002#endif
1003#ifndef OPENSSL_NO_RC2
1004 RESOLVEFUNC(EVP_rc2_cbc)
1005#endif
1006#ifndef OPENSSL_NO_AES
1007 RESOLVEFUNC(EVP_aes_128_cbc)
1008 RESOLVEFUNC(EVP_aes_192_cbc)
1009 RESOLVEFUNC(EVP_aes_256_cbc)
1010#endif
1011 RESOLVEFUNC(EVP_sha1)
1012 RESOLVEFUNC(EVP_PKEY_free)
1013 RESOLVEFUNC(EVP_PKEY_new)
1014 RESOLVEFUNC(EVP_PKEY_type)
1015 RESOLVEFUNC(OBJ_nid2sn)
1016 RESOLVEFUNC(OBJ_nid2ln)
1017 RESOLVEFUNC(OBJ_sn2nid)
1018 RESOLVEFUNC(OBJ_ln2nid)
1019 RESOLVEFUNC(i2t_ASN1_OBJECT)
1020 RESOLVEFUNC(OBJ_obj2txt)
1021 RESOLVEFUNC(OBJ_obj2nid)
1022 RESOLVEFUNC(PEM_read_bio_PrivateKey)
1023 RESOLVEFUNC(PEM_write_bio_PrivateKey)
1024 RESOLVEFUNC(PEM_write_bio_PrivateKey_traditional)
1025 RESOLVEFUNC(PEM_read_bio_PUBKEY)
1026 RESOLVEFUNC(PEM_write_bio_PUBKEY)
1027 RESOLVEFUNC(RAND_seed)
1028 RESOLVEFUNC(RAND_status)
1029 RESOLVEFUNC(RAND_bytes)
1030 RESOLVEFUNC(SSL_CIPHER_description)
1031 RESOLVEFUNC(SSL_CIPHER_get_bits)
1032 RESOLVEFUNC(SSL_get_rbio)
1033 RESOLVEFUNC(SSL_CTX_check_private_key)
1034 RESOLVEFUNC(SSL_CTX_ctrl)
1035 RESOLVEFUNC(SSL_CTX_free)
1036 RESOLVEFUNC(SSL_CTX_new)
1037 RESOLVEFUNC(SSL_CTX_set_cipher_list)
1038 RESOLVEFUNC(SSL_CTX_callback_ctrl)
1039 RESOLVEFUNC(SSL_CTX_set_default_verify_paths)
1040 RESOLVEFUNC(SSL_CTX_set_verify)
1041 RESOLVEFUNC(SSL_CTX_set_verify_depth)
1042 RESOLVEFUNC(SSL_CTX_use_certificate)
1043 RESOLVEFUNC(SSL_CTX_use_certificate_file)
1044 RESOLVEFUNC(SSL_CTX_use_PrivateKey)
1045 RESOLVEFUNC(SSL_CTX_use_PrivateKey_file)
1046 RESOLVEFUNC(SSL_CTX_get_cert_store);
1047 RESOLVEFUNC(SSL_CONF_CTX_new);
1048 RESOLVEFUNC(SSL_CONF_CTX_free);
1049 RESOLVEFUNC(SSL_CONF_CTX_set_ssl_ctx);
1050 RESOLVEFUNC(SSL_CONF_CTX_set_flags);
1051 RESOLVEFUNC(SSL_CONF_CTX_finish);
1052 RESOLVEFUNC(SSL_CONF_cmd);
1053 RESOLVEFUNC(SSL_accept)
1054 RESOLVEFUNC(SSL_clear)
1055 RESOLVEFUNC(SSL_connect)
1056 RESOLVEFUNC(SSL_free)
1057 RESOLVEFUNC(SSL_get_ciphers)
1058 RESOLVEFUNC(SSL_get_current_cipher)
1059 RESOLVEFUNC(SSL_version)
1060 RESOLVEFUNC(SSL_get_error)
1061 RESOLVEFUNC(SSL_get_peer_cert_chain)
1062
1063#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
1064 RESOLVEFUNC(SSL_get1_peer_certificate)
1065 RESOLVEFUNC(EVP_PKEY_get_bits)
1066 RESOLVEFUNC(EVP_PKEY_get_base_id)
1067#else
1068 RESOLVEFUNC(SSL_get_peer_certificate)
1069 RESOLVEFUNC(EVP_PKEY_base_id)
1070#endif // OPENSSL_VERSION_MAJOR >= 3
1071
1072#ifndef OPENSSL_NO_DEPRECATED_3_0
1073 RESOLVEFUNC(DH_new)
1074 RESOLVEFUNC(DH_free)
1075 RESOLVEFUNC(DH_check)
1076 RESOLVEFUNC(DH_get0_pqg)
1077
1078 RESOLVEFUNC(d2i_DHparams)
1079 RESOLVEFUNC(i2d_DHparams)
1080
1081 RESOLVEFUNC(PEM_read_bio_DHparams)
1082
1083 RESOLVEFUNC(EVP_PKEY_assign)
1084 RESOLVEFUNC(EVP_PKEY_cmp)
1085
1086 RESOLVEFUNC(EVP_PKEY_set1_RSA)
1087 RESOLVEFUNC(EVP_PKEY_set1_DSA)
1088 RESOLVEFUNC(EVP_PKEY_set1_DH)
1089
1090 RESOLVEFUNC(EVP_PKEY_get1_DSA)
1091 RESOLVEFUNC(EVP_PKEY_get1_RSA)
1092 RESOLVEFUNC(EVP_PKEY_get1_DH)
1093
1094 RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY)
1095 RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY)
1096 RESOLVEFUNC(PEM_read_bio_DSAPrivateKey)
1097 RESOLVEFUNC(PEM_read_bio_RSAPrivateKey)
1098
1099 RESOLVEFUNC(PEM_write_bio_DSA_PUBKEY)
1100 RESOLVEFUNC(PEM_write_bio_RSA_PUBKEY)
1101 RESOLVEFUNC(PEM_write_bio_DSAPrivateKey)
1102 RESOLVEFUNC(PEM_write_bio_RSAPrivateKey)
1103 RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey)
1104
1105 RESOLVEFUNC(DSA_new)
1106 RESOLVEFUNC(DSA_free)
1107
1108 RESOLVEFUNC(RSA_new)
1109 RESOLVEFUNC(RSA_free)
1110
1111 RESOLVEFUNC(DH_bits)
1112 RESOLVEFUNC(DSA_bits)
1113 RESOLVEFUNC(RSA_bits)
1114
1115#ifndef OPENSSL_NO_EC
1116
1117 RESOLVEFUNC(EVP_PKEY_set1_EC_KEY)
1118 RESOLVEFUNC(EVP_PKEY_get1_EC_KEY)
1119 RESOLVEFUNC(PEM_read_bio_EC_PUBKEY)
1120 RESOLVEFUNC(PEM_read_bio_ECPrivateKey)
1121 RESOLVEFUNC(PEM_write_bio_EC_PUBKEY)
1122 RESOLVEFUNC(PEM_write_bio_ECPrivateKey)
1123 RESOLVEFUNC(EC_KEY_get0_group)
1124 RESOLVEFUNC(EC_GROUP_get_degree)
1125 RESOLVEFUNC(EC_KEY_dup)
1126 RESOLVEFUNC(EC_KEY_new_by_curve_name)
1127 RESOLVEFUNC(EC_KEY_free)
1128
1129#endif // OPENSSL_NO_EC
1130
1131#endif // OPENSSL_NO_DEPRECATED_3_0
1132
1133 RESOLVEFUNC(SSL_get_verify_result)
1134 RESOLVEFUNC(SSL_new)
1135 RESOLVEFUNC(SSL_get_SSL_CTX)
1136 RESOLVEFUNC(SSL_ctrl)
1137 RESOLVEFUNC(SSL_read)
1138 RESOLVEFUNC(SSL_set_accept_state)
1139 RESOLVEFUNC(SSL_set_bio)
1140 RESOLVEFUNC(SSL_set_connect_state)
1141 RESOLVEFUNC(SSL_shutdown)
1142 RESOLVEFUNC(SSL_in_init)
1143 RESOLVEFUNC(SSL_get_shutdown)
1144 RESOLVEFUNC(SSL_set_session)
1145 RESOLVEFUNC(SSL_SESSION_free)
1146 RESOLVEFUNC(SSL_get1_session)
1147 RESOLVEFUNC(SSL_get_session)
1148 RESOLVEFUNC(SSL_set_ex_data)
1149 RESOLVEFUNC(SSL_get_ex_data)
1150 RESOLVEFUNC(SSL_get_ex_data_X509_STORE_CTX_idx)
1151
1152#ifndef OPENSSL_NO_PSK
1153 RESOLVEFUNC(SSL_set_psk_client_callback)
1154 RESOLVEFUNC(SSL_set_psk_server_callback)
1155 RESOLVEFUNC(SSL_CTX_use_psk_identity_hint)
1156#endif // !OPENSSL_NO_PSK
1157
1158 RESOLVEFUNC(SSL_write)
1159 RESOLVEFUNC(X509_NAME_entry_count)
1160 RESOLVEFUNC(X509_NAME_get_entry)
1161 RESOLVEFUNC(X509_NAME_ENTRY_get_data)
1162 RESOLVEFUNC(X509_NAME_ENTRY_get_object)
1163 RESOLVEFUNC(X509_PUBKEY_get)
1164 RESOLVEFUNC(X509_STORE_free)
1165 RESOLVEFUNC(X509_STORE_new)
1166 RESOLVEFUNC(X509_STORE_add_cert)
1167 RESOLVEFUNC(X509_STORE_CTX_free)
1168 RESOLVEFUNC(X509_STORE_CTX_init)
1169 RESOLVEFUNC(X509_STORE_CTX_new)
1170 RESOLVEFUNC(X509_STORE_CTX_set_purpose)
1171 RESOLVEFUNC(X509_STORE_CTX_get_error)
1172 RESOLVEFUNC(X509_STORE_CTX_get_error_depth)
1173 RESOLVEFUNC(X509_STORE_CTX_get_current_cert)
1174 RESOLVEFUNC(X509_STORE_CTX_get0_store)
1175 RESOLVEFUNC(X509_cmp)
1176 RESOLVEFUNC(X509_STORE_CTX_get_ex_data)
1177 RESOLVEFUNC(X509_dup)
1178 RESOLVEFUNC(X509_print)
1179 RESOLVEFUNC(X509_digest)
1180 RESOLVEFUNC(X509_EXTENSION_get_object)
1181 RESOLVEFUNC(X509_free)
1182 RESOLVEFUNC(X509_gmtime_adj)
1183 RESOLVEFUNC(ASN1_TIME_free)
1184 RESOLVEFUNC(X509_get_ext)
1185 RESOLVEFUNC(X509_get_ext_count)
1186 RESOLVEFUNC(X509_get_ext_d2i)
1187 RESOLVEFUNC(X509V3_EXT_get)
1188 RESOLVEFUNC(X509V3_EXT_d2i)
1189 RESOLVEFUNC(X509_EXTENSION_get_critical)
1190 RESOLVEFUNC(X509_EXTENSION_get_data)
1191 RESOLVEFUNC(BASIC_CONSTRAINTS_free)
1192 RESOLVEFUNC(AUTHORITY_KEYID_free)
1193 RESOLVEFUNC(GENERAL_NAME_free)
1194 RESOLVEFUNC(ASN1_STRING_print)
1195 RESOLVEFUNC(X509_check_issued)
1196 RESOLVEFUNC(X509_get_issuer_name)
1197 RESOLVEFUNC(X509_get_subject_name)
1198 RESOLVEFUNC(X509_get_serialNumber)
1199 RESOLVEFUNC(X509_verify_cert)
1200 RESOLVEFUNC(d2i_X509)
1201 RESOLVEFUNC(i2d_X509)
1202#if OPENSSL_VERSION_MAJOR < 3
1203 RESOLVEFUNC(SSL_CTX_load_verify_locations)
1204#else
1205 RESOLVEFUNC(SSL_CTX_load_verify_dir)
1206#endif // OPENSSL_VERSION_MAJOR
1207 RESOLVEFUNC(i2d_SSL_SESSION)
1208 RESOLVEFUNC(d2i_SSL_SESSION)
1209
1210#ifndef OPENSSL_NO_NEXTPROTONEG
1211 RESOLVEFUNC(SSL_select_next_proto)
1212 RESOLVEFUNC(SSL_CTX_set_next_proto_select_cb)
1213 RESOLVEFUNC(SSL_get0_next_proto_negotiated)
1214 RESOLVEFUNC(SSL_set_alpn_protos)
1215 RESOLVEFUNC(SSL_CTX_set_alpn_select_cb)
1216 RESOLVEFUNC(SSL_get0_alpn_selected)
1217#endif // !OPENSSL_NO_NEXTPROTONEG
1218
1219#if QT_CONFIG(dtls)
1220 RESOLVEFUNC(SSL_CTX_set_cookie_generate_cb)
1221 RESOLVEFUNC(SSL_CTX_set_cookie_verify_cb)
1222 RESOLVEFUNC(DTLS_server_method)
1223 RESOLVEFUNC(DTLS_client_method)
1224#endif // dtls
1225
1226 RESOLVEFUNC(CRYPTO_malloc)
1227 RESOLVEFUNC(BN_bin2bn)
1228
1229#ifndef OPENSSL_NO_EC
1230 RESOLVEFUNC(EC_get_builtin_curves)
1231#endif // OPENSSL_NO_EC
1232
1233 RESOLVEFUNC(PKCS12_parse)
1234 RESOLVEFUNC(d2i_PKCS12_bio)
1235 RESOLVEFUNC(PKCS12_free)
1236 return true;
1237 }();
1238
1239 return symbolsResolved;
1240}
1241#endif // QT_CONFIG(library)
1242
1243#else // !defined QT_LINKED_OPENSSL
1244
1245bool q_resolveOpenSslSymbols()
1246{
1247#ifdef QT_NO_OPENSSL
1248 return false;
1249#endif
1250 return true;
1251}
1252#endif // !defined QT_LINKED_OPENSSL
1253
1254QT_END_NAMESPACE
1255

source code of qtbase/src/plugins/tls/openssl/qsslsocket_openssl_symbols.cpp