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

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