Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsslsocket_openssl_symbols.cpp
Go to the documentation of this file.
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
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, const ASN1_STRING *a, a, return 0, return)
218DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, const 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, const 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_security_bits, const EVP_PKEY *pkey, pkey, return -1, return)
311DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
312DEFINEFUNC(const char *, EVP_PKEY_get0_type_name, const EVP_PKEY *pkey, pkey, return nullptr, return)
313DEFINEFUNC2(OSSL_PROVIDER *, OSSL_PROVIDER_load, OSSL_LIB_CTX *libctx, libctx, const char *name, name, return nullptr, return)
314DEFINEFUNC(int, OSSL_PROVIDER_unload, OSSL_PROVIDER *prov, prov, return 0, return)
315DEFINEFUNC(int, EVP_default_properties_is_fips_enabled, OSSL_LIB_CTX *libctx, libctx, return 0, return)
316#else
317DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
318DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
319#endif // OPENSSL_VERSION_MAJOR >= 3
320
321DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
322DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
323DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
324DEFINEFUNC4(long, SSL_ctrl, SSL *a, a, int cmd, cmd, long larg, larg, void *parg, parg, return -1, return)
325DEFINEFUNC3(int, SSL_read, SSL *a, a, void *b, b, int c, c, return -1, return)
326DEFINEFUNC3(void, SSL_set_bio, SSL *a, a, BIO *b, b, BIO *c, c, return, DUMMYARG)
327DEFINEFUNC(void, SSL_set_accept_state, SSL *a, a, return, DUMMYARG)
328DEFINEFUNC(void, SSL_set_connect_state, SSL *a, a, return, DUMMYARG)
329DEFINEFUNC(int, SSL_shutdown, SSL *a, a, return -1, return)
330DEFINEFUNC(int, SSL_in_init, const SSL *a, a, return 0, return)
331DEFINEFUNC(int, SSL_get_shutdown, const SSL *ssl, ssl, return 0, return)
332DEFINEFUNC2(int, SSL_set_session, SSL* to, to, SSL_SESSION *session, session, return -1, return)
333DEFINEFUNC(void, SSL_SESSION_free, SSL_SESSION *ses, ses, return, DUMMYARG)
334DEFINEFUNC(SSL_SESSION*, SSL_get1_session, SSL *ssl, ssl, return nullptr, return)
335DEFINEFUNC(SSL_SESSION*, SSL_get_session, const SSL *ssl, ssl, return nullptr, return)
336DEFINEFUNC3(int, SSL_set_ex_data, SSL *ssl, ssl, int idx, idx, void *arg, arg, return 0, return)
337DEFINEFUNC2(void *, SSL_get_ex_data, const SSL *ssl, ssl, int idx, idx, return nullptr, return)
338
339#ifndef OPENSSL_NO_PSK
340DEFINEFUNC2(void, SSL_set_psk_client_callback, SSL* ssl, ssl, q_psk_client_callback_t callback, callback, return, DUMMYARG)
341DEFINEFUNC2(void, SSL_set_psk_server_callback, SSL* ssl, ssl, q_psk_server_callback_t callback, callback, return, DUMMYARG)
342DEFINEFUNC2(int, SSL_CTX_use_psk_identity_hint, SSL_CTX* ctx, ctx, const char *hint, hint, return 0, return)
343#endif // !OPENSSL_NO_PSK
344
345DEFINEFUNC3(int, SSL_write, SSL *a, a, const void *b, b, int c, c, return -1, return)
346DEFINEFUNC2(int, X509_cmp, X509 *a, a, X509 *b, b, return -1, return)
347DEFINEFUNC4(int, X509_digest, const X509 *x509, x509, const EVP_MD *type, type, unsigned char *md, md, unsigned int *len, len, return -1, return)
348DEFINEFUNC(X509 *, X509_dup, X509 *a, a, return nullptr, return)
349DEFINEFUNC2(void, X509_print, BIO *a, a, X509 *b, b, return, DUMMYARG);
350DEFINEFUNC(QT_OPENSSL4_CONST ASN1_OBJECT *, X509_EXTENSION_get_object, QT_OPENSSL4_CONST X509_EXTENSION *a, a, return nullptr, return)
351DEFINEFUNC(void, X509_free, X509 *a, a, return, DUMMYARG)
352//Q_AUTOTEST_EXPORT ASN1_TIME *q_X509_gmtime_adj(ASN1_TIME *s, long adj);
353DEFINEFUNC2(ASN1_TIME *, X509_gmtime_adj, ASN1_TIME *s, s, long adj, adj, return nullptr, return)
354DEFINEFUNC(void, ASN1_TIME_free, ASN1_TIME *t, t, return, DUMMYARG)
355DEFINEFUNC2(QT_OPENSSL4_CONST X509_EXTENSION *, X509_get_ext, X509 *a, a, int b, b, return nullptr, return)
356DEFINEFUNC(int, X509_get_ext_count, X509 *a, a, return 0, return)
357DEFINEFUNC4(void *, X509_get_ext_d2i, X509 *a, a, int b, b, int *c, c, int *d, d, return nullptr, return)
358DEFINEFUNC(const X509V3_EXT_METHOD *, X509V3_EXT_get, QT_OPENSSL4_CONST X509_EXTENSION *a, a, return nullptr, return)
359DEFINEFUNC(void *, X509V3_EXT_d2i, QT_OPENSSL4_CONST X509_EXTENSION *a, a, return nullptr, return)
360DEFINEFUNC(int, X509_EXTENSION_get_critical, const X509_EXTENSION *a, a, return 0, return)
361DEFINEFUNC(QT_OPENSSL4_CONST ASN1_OCTET_STRING *, X509_EXTENSION_get_data, QT_OPENSSL4_CONST X509_EXTENSION *a, a, return nullptr, return)
362DEFINEFUNC(void, BASIC_CONSTRAINTS_free, BASIC_CONSTRAINTS *a, a, return, DUMMYARG)
363DEFINEFUNC(void, AUTHORITY_KEYID_free, AUTHORITY_KEYID *a, a, return, DUMMYARG)
364DEFINEFUNC(void, GENERAL_NAME_free, GENERAL_NAME *a, a, return, DUMMYARG)
365DEFINEFUNC2(int, ASN1_STRING_print, BIO *a, a, const ASN1_STRING *b, b, return 0, return)
366DEFINEFUNC2(int, X509_check_issued, X509 *a, a, X509 *b, b, return -1, return)
367DEFINEFUNC(QT_OPENSSL4_CONST X509_NAME *, X509_get_issuer_name, X509 *a, a, return nullptr, return)
368DEFINEFUNC(QT_OPENSSL4_CONST X509_NAME *, X509_get_subject_name, X509 *a, a, return nullptr, return)
369DEFINEFUNC(ASN1_INTEGER *, X509_get_serialNumber, X509 *a, a, return nullptr, return)
370DEFINEFUNC(int, X509_verify_cert, X509_STORE_CTX *a, a, return -1, return)
371DEFINEFUNC(int, X509_NAME_entry_count, const X509_NAME *a, a, return 0, return)
372DEFINEFUNC2(QT_OPENSSL4_CONST X509_NAME_ENTRY *, X509_NAME_get_entry, const X509_NAME *a, a, int b, b, return nullptr, return)
373DEFINEFUNC(QT_OPENSSL4_CONST ASN1_STRING *, X509_NAME_ENTRY_get_data, const X509_NAME_ENTRY *a, a, return nullptr, return)
374DEFINEFUNC(QT_OPENSSL4_CONST ASN1_OBJECT *, X509_NAME_ENTRY_get_object, const X509_NAME_ENTRY *a, a, return nullptr, return)
375DEFINEFUNC(EVP_PKEY *, X509_PUBKEY_get, X509_PUBKEY *a, a, return nullptr, return)
376DEFINEFUNC(void, X509_STORE_free, X509_STORE *a, a, return, DUMMYARG)
377DEFINEFUNC(X509_STORE *, X509_STORE_new, DUMMYARG, DUMMYARG, return nullptr, return)
378DEFINEFUNC2(int, X509_STORE_add_cert, X509_STORE *a, a, X509 *b, b, return 0, return)
379DEFINEFUNC(void, X509_STORE_CTX_free, X509_STORE_CTX *a, a, return, DUMMYARG)
380DEFINEFUNC4(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)
381DEFINEFUNC2(int, X509_STORE_CTX_set_purpose, X509_STORE_CTX *a, a, int b, b, return -1, return)
382DEFINEFUNC(int, X509_STORE_CTX_get_error, X509_STORE_CTX *a, a, return -1, return)
383DEFINEFUNC(int, X509_STORE_CTX_get_error_depth, X509_STORE_CTX *a, a, return -1, return)
384DEFINEFUNC(X509 *, X509_STORE_CTX_get_current_cert, X509_STORE_CTX *a, a, return nullptr, return)
385DEFINEFUNC(X509_STORE *, X509_STORE_CTX_get0_store, X509_STORE_CTX *ctx, ctx, return nullptr, return)
386DEFINEFUNC(X509_STORE_CTX *, X509_STORE_CTX_new, DUMMYARG, DUMMYARG, return nullptr, return)
387DEFINEFUNC2(void *, X509_STORE_CTX_get_ex_data, X509_STORE_CTX *ctx, ctx, int idx, idx, return nullptr, return)
388DEFINEFUNC(int, SSL_get_ex_data_X509_STORE_CTX_idx, DUMMYARG, DUMMYARG, return -1, return)
389DEFINEFUNC8(int, SSL_export_keying_material, SSL* s, s, unsigned char* out, out, size_t out_len, out_len, const char* label, label, size_t label_len, label_len, const unsigned char* ctx, ctx, size_t ctx_len, ctx_len, int use_ctx, use_ctx, return 0, return)
390
391#if OPENSSL_VERSION_MAJOR < 3
392DEFINEFUNC3(int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx, const char *CAfile, CAfile, const char *CApath, CApath, return 0, return)
393#else
394DEFINEFUNC2(int, SSL_CTX_load_verify_dir, SSL_CTX *ctx, ctx, const char *CApath, CApath, return 0, return)
395#endif // OPENSSL_VERSION_MAJOR
396
397DEFINEFUNC2(int, i2d_SSL_SESSION, SSL_SESSION *in, in, unsigned char **pp, pp, return 0, return)
398DEFINEFUNC3(SSL_SESSION *, d2i_SSL_SESSION, SSL_SESSION **a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
399
400#ifndef OPENSSL_NO_NEXTPROTONEG
401DEFINEFUNC6(int, SSL_select_next_proto, unsigned char **out, out, unsigned char *outlen, outlen,
402 const unsigned char *in, in, unsigned int inlen, inlen,
403 const unsigned char *client, client, unsigned int client_len, client_len,
404 return -1, return)
405DEFINEFUNC3(void, SSL_CTX_set_next_proto_select_cb, SSL_CTX *s, s,
406 int (*cb) (SSL *ssl, unsigned char **out,
407 unsigned char *outlen,
408 const unsigned char *in,
409 unsigned int inlen, void *arg), cb,
410 void *arg, arg, return, DUMMYARG)
411DEFINEFUNC3(void, SSL_get0_next_proto_negotiated, const SSL *s, s,
412 const unsigned char **data, data, unsigned *len, len, return, DUMMYARG)
413DEFINEFUNC3(int, SSL_set_alpn_protos, SSL *s, s, const unsigned char *protos, protos,
414 unsigned protos_len, protos_len, return -1, return)
415DEFINEFUNC3(void, SSL_CTX_set_alpn_select_cb, SSL_CTX *s, s,
416 int (*cb) (SSL *ssl, const unsigned char **out,
417 unsigned char *outlen,
418 const unsigned char *in,
419 unsigned int inlen, void *arg), cb,
420 void *arg, arg, return, DUMMYARG)
421DEFINEFUNC3(void, SSL_get0_alpn_selected, const SSL *s, s, const unsigned char **data, data,
422 unsigned *len, len, return, DUMMYARG)
423#endif // !OPENSSL_NO_NEXTPROTONEG
424
425// DTLS:
426#if QT_CONFIG(dtls)
427DEFINEFUNC2(void, SSL_CTX_set_cookie_generate_cb, SSL_CTX *ctx, ctx, CookieGenerateCallback cb, cb, return, DUMMYARG)
428DEFINEFUNC2(void, SSL_CTX_set_cookie_verify_cb, SSL_CTX *ctx, ctx, CookieVerifyCallback cb, cb, return, DUMMYARG)
429DEFINEFUNC(const SSL_METHOD *, DTLS_server_method, DUMMYARG, DUMMYARG, return nullptr, return)
430DEFINEFUNC(const SSL_METHOD *, DTLS_client_method, DUMMYARG, DUMMYARG, return nullptr, return)
431#endif // dtls
432DEFINEFUNC2(void, BIO_set_flags, BIO *b, b, int flags, flags, return, DUMMYARG)
433DEFINEFUNC2(void, BIO_clear_flags, BIO *b, b, int flags, flags, return, DUMMYARG)
434DEFINEFUNC2(void *, BIO_get_ex_data, BIO *b, b, int idx, idx, return nullptr, return)
435DEFINEFUNC3(int, BIO_set_ex_data, BIO *b, b, int idx, idx, void *data, data, return -1, return)
436
437DEFINEFUNC3(void *, CRYPTO_malloc, size_t num, num, const char *file, file, int line, line, return nullptr, return)
438
439#ifndef OPENSSL_NO_DEPRECATED_3_0
440DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
441DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
442DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
443DEFINEFUNC4(void, DH_get0_pqg, const DH *dh, dh, const BIGNUM **p, p, const BIGNUM **q, q, const BIGNUM **g, g, return, DUMMYARG)
444
445DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
446DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
447
448DEFINEFUNC4(DH *, PEM_read_bio_DHparams, BIO *a, a, DH **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
449#endif
450DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
451
452
453#ifndef OPENSSL_NO_EC
454DEFINEFUNC2(size_t, EC_get_builtin_curves, EC_builtin_curve * r, r, size_t nitems, nitems, return 0, return)
455DEFINEFUNC(int, EC_curve_nist2nid, const char *name, name, return 0, return)
456#endif // OPENSSL_NO_EC
457
458DEFINEFUNC5(int, PKCS12_parse, PKCS12 *p12, p12, const char *pass, pass, EVP_PKEY **pkey, pkey,
459 X509 **cert, cert, STACK_OF(X509) **ca, ca, return 1, return);
460DEFINEFUNC2(PKCS12 *, d2i_PKCS12_bio, BIO *bio, bio, PKCS12 **pkcs12, pkcs12, return nullptr, return);
461DEFINEFUNC(void, PKCS12_free, PKCS12 *pkcs12, pkcs12, return, DUMMYARG)
462
463#ifndef OPENSSL_NO_DEPRECATED_3_0
464
465DEFINEFUNC4(DSA *, PEM_read_bio_DSA_PUBKEY, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
466DEFINEFUNC4(RSA *, PEM_read_bio_RSA_PUBKEY, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
467DEFINEFUNC4(DSA *, PEM_read_bio_DSAPrivateKey, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
468DEFINEFUNC4(RSA *, PEM_read_bio_RSAPrivateKey, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
469
470DEFINEFUNC2(int, PEM_write_bio_DSA_PUBKEY, BIO *a, a, DSA *b, b, return 0, return)
471DEFINEFUNC2(int, PEM_write_bio_RSA_PUBKEY, BIO *a, a, RSA *b, b, return 0, return)
472DEFINEFUNC7(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)
473DEFINEFUNC7(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)
474
475DEFINEFUNC2(int, SSL_CTX_use_RSAPrivateKey, SSL_CTX *a, a, RSA *b, b, return -1, return)
476
477DEFINEFUNC(DSA *, DSA_new, DUMMYARG, DUMMYARG, return nullptr, return)
478DEFINEFUNC(void, DSA_free, DSA *a, a, return, DUMMYARG)
479
480DEFINEFUNC(RSA *, RSA_new, DUMMYARG, DUMMYARG, return nullptr, return)
481DEFINEFUNC(void, RSA_free, RSA *a, a, return, DUMMYARG)
482
483DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
484DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
485DEFINEFUNC(int, DH_bits, DH *dh, dh, return 0, return)
486
487DEFINEFUNC(DSA *, EVP_PKEY_get1_DSA, EVP_PKEY *a, a, return nullptr, return)
488DEFINEFUNC(RSA *, EVP_PKEY_get1_RSA, EVP_PKEY *a, a, return nullptr, return)
489DEFINEFUNC(DH *, EVP_PKEY_get1_DH, EVP_PKEY *a, a, return nullptr, return)
490
491DEFINEFUNC2(int, EVP_PKEY_cmp, const EVP_PKEY *a, a, const EVP_PKEY *b, b, return -1, return)
492DEFINEFUNC3(int, EVP_PKEY_assign, EVP_PKEY *a, a, int b, b, void *r, r, return -1, return)
493
494DEFINEFUNC2(int, EVP_PKEY_set1_RSA, EVP_PKEY *a, a, RSA *b, b, return -1, return)
495DEFINEFUNC2(int, EVP_PKEY_set1_DSA, EVP_PKEY *a, a, DSA *b, b, return -1, return)
496DEFINEFUNC2(int, EVP_PKEY_set1_DH, EVP_PKEY *a, a, DH *b, b, return -1, return)
497
498#ifndef OPENSSL_NO_EC
499
500DEFINEFUNC4(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)
501DEFINEFUNC4(EC_KEY *, PEM_read_bio_ECPrivateKey, BIO *a, a, EC_KEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
502
503DEFINEFUNC2(int, PEM_write_bio_EC_PUBKEY, BIO *a, a, EC_KEY *b, b, return 0, return)
504DEFINEFUNC7(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)
505
506DEFINEFUNC(const EC_GROUP*, EC_KEY_get0_group, const EC_KEY* k, k, return nullptr, return)
507DEFINEFUNC(int, EC_GROUP_get_degree, const EC_GROUP* g, g, return 0, return)
508
509DEFINEFUNC2(int, EVP_PKEY_set1_EC_KEY, EVP_PKEY *a, a, EC_KEY *b, b, return -1, return)
510DEFINEFUNC(EC_KEY *, EVP_PKEY_get1_EC_KEY, EVP_PKEY *a, a, return nullptr, return)
511
512DEFINEFUNC(EC_KEY *, EC_KEY_dup, const EC_KEY *ec, ec, return nullptr, return)
513DEFINEFUNC(EC_KEY *, EC_KEY_new_by_curve_name, int nid, nid, return nullptr, return)
514DEFINEFUNC(void, EC_KEY_free, EC_KEY *ecdh, ecdh, return, DUMMYARG)
515
516#endif // OPENSSL_NO_EC
517
518
519
520#endif
521
522#define RESOLVEFUNC(func)
523 if (!(_q_##func = _q_PTR_##func(libs.ssl->resolve(#func)))
524 && !(_q_##func = _q_PTR_##func(libs.crypto->resolve(#func))))
525 qsslSocketCannotResolveSymbolWarning(#func);
526
527#if !defined QT_LINKED_OPENSSL
528
529#if !QT_CONFIG(library)
530bool q_resolveOpenSslSymbols()
531{
532 qCWarning(lcTlsBackend, "QSslSocket: unable to resolve symbols. Qt is configured without the "
533 "'library' feature, which means runtime resolving of libraries won't work.");
534 qCWarning(lcTlsBackend, "Either compile Qt statically or with support for runtime resolving "
535 "of libraries.");
536 return false;
537}
538#else
539
540# ifdef Q_OS_UNIX
541struct NumericallyLess
542{
543 typedef bool result_type;
544 result_type operator()(QStringView lhs, QStringView rhs) const
545 {
546 bool ok = false;
547 int b = 0;
548 int a = lhs.toInt(&ok);
549 if (ok)
550 b = rhs.toInt(&ok);
551 if (ok) {
552 // both toInt succeeded
553 return a < b;
554 } else {
555 // compare as strings;
556 return lhs < rhs;
557 }
558 }
559};
560
561struct LibGreaterThan
562{
563 typedef bool result_type;
564 result_type operator()(QStringView lhs, QStringView rhs) const
565 {
566 const auto lhsparts = lhs.split(u'.');
567 const auto rhsparts = rhs.split(u'.');
568 Q_ASSERT(lhsparts.size() > 1 && rhsparts.size() > 1);
569
570 // note: checking rhs < lhs, the same as lhs > rhs
571 return std::lexicographical_compare(rhsparts.begin() + 1, rhsparts.end(),
572 lhsparts.begin() + 1, lhsparts.end(),
573 NumericallyLess());
574 }
575};
576
577#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_OHOS)
578static int dlIterateCallback(struct dl_phdr_info *info, size_t size, void *data)
579{
580 if (size < sizeof (info->dlpi_addr) + sizeof (info->dlpi_name))
581 return 1;
582 QDuplicateTracker<QString> *paths = (QDuplicateTracker<QString> *)data;
583 QString path = QString::fromLocal8Bit(info->dlpi_name);
584 if (!path.isEmpty()) {
585 QFileInfo fi(path);
586 path = fi.absolutePath();
587 if (!path.isEmpty())
588 (void)paths->hasSeen(std::move(path));
589 }
590 return 0;
591}
592#endif
593
594static QStringList libraryPathList()
595{
596 QStringList paths;
597# ifdef Q_OS_DARWIN
598 paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH")).split(u':', Qt::SkipEmptyParts);
599
600 // search in .app/Contents/Frameworks
601 UInt32 packageType;
602 CFBundleGetPackageInfo(CFBundleGetMainBundle(), &packageType, nullptr);
603 if (packageType == FOUR_CHAR_CODE('APPL')) {
604 QUrl bundleUrl = QUrl::fromCFURL(QCFType<CFURLRef>(CFBundleCopyBundleURL(CFBundleGetMainBundle())));
605 QUrl frameworksUrl = QUrl::fromCFURL(QCFType<CFURLRef>(CFBundleCopyPrivateFrameworksURL(CFBundleGetMainBundle())));
606 paths << bundleUrl.resolved(frameworksUrl).path();
607 }
608# else
609 paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH")).split(u':', Qt::SkipEmptyParts);
610# endif
611 paths << "/lib"_L1 << "/usr/lib"_L1 << "/usr/local/lib"_L1;
612 paths << "/lib64"_L1 << "/usr/lib64"_L1 << "/usr/local/lib64"_L1;
613 paths << "/lib32"_L1 << "/usr/lib32"_L1 << "/usr/local/lib32"_L1;
614
615#if defined(Q_OS_ANDROID)
616 paths << "/system/lib"_L1;
617#elif defined(Q_OS_OHOS)
618 paths << "/system/lib64/platformsdk"_L1;
619 paths << "/system/lib64/chipset-sdk"_L1;
620 paths << "/system/lib64/chipset-sdk-sp"_L1;
621#elif defined(Q_OS_LINUX)
622 // discover paths of already loaded libraries
623 QDuplicateTracker<QString> loadedPaths;
624 dl_iterate_phdr(dlIterateCallback, &loadedPaths);
625 std::move(loadedPaths).appendTo(paths);
626#endif
627
628 return paths;
629}
630
631Q_NEVER_INLINE
632static QStringList findAllLibs(QLatin1StringView filter)
633{
634 const QStringList paths = libraryPathList();
635 QStringList found;
636 const QStringList filters((QString(filter)));
637
638 using F = QDirListing::IteratorFlag;
639 for (const QString &path : paths) {
640 QStringList entryList;
641 for (const auto &dirEntry : QDirListing(path, filters, F::FilesOnly))
642 entryList.emplace_back(dirEntry.fileName());
643
644 std::sort(entryList.begin(), entryList.end(), LibGreaterThan());
645 for (const QString &entry : std::as_const(entryList))
646 found << path + u'/' + entry;
647 }
648
649 return found;
650}
651
652static QStringList findAllLibSsl()
653{
654#if defined(Q_OS_OHOS)
655 return findAllLibs("libssl_openssl*"_L1);
656#else
657 return findAllLibs("libssl.*"_L1);
658#endif
659}
660
661static QStringList findAllLibCrypto()
662{
663#if defined(Q_OS_OHOS)
664 return findAllLibs("libcrypto_openssl*"_L1);
665#else
666 return findAllLibs("libcrypto.*"_L1);
667#endif
668}
669# endif
670
671#if (OPENSSL_VERSION_NUMBER >> 28) < 3
672#define QT_OPENSSL_VERSION "1_1"
673#elif OPENSSL_VERSION_MAJOR >= 3
674#define QT_OPENSSL_VERSION QT_STRINGIFY(OPENSSL_VERSION_MAJOR)
675#endif
676
677#ifdef Q_OS_WIN
678
679struct LoadedOpenSsl {
680 std::unique_ptr<QSystemLibrary> ssl, crypto;
681};
682
683static bool tryToLoadOpenSslWin32Library(QLatin1StringView ssleay32LibName, QLatin1StringView libeay32LibName, LoadedOpenSsl &result)
684{
685 auto ssleay32 = std::make_unique<QSystemLibrary>(ssleay32LibName);
686 if (!ssleay32->load(false)) {
687 return FALSE;
688 }
689
690 auto libeay32 = std::make_unique<QSystemLibrary>(libeay32LibName);
691 if (!libeay32->load(false)) {
692 return FALSE;
693 }
694
695 result.ssl = std::move(ssleay32);
696 result.crypto = std::move(libeay32);
697 return TRUE;
698}
699
700static LoadedOpenSsl loadOpenSsl()
701{
702 LoadedOpenSsl result;
703
704 // With OpenSSL 1.1 the names have changed to libssl-1_1 and libcrypto-1_1 for builds using
705 // MSVC and GCC. For 3.0 the version suffix changed again, to just '3'.
706 // For non-x86 builds, an architecture suffix is also appended.
707
708#if defined(Q_PROCESSOR_X86_64)
709#define QT_SSL_SUFFIX "-x64"
710#elif defined(Q_PROCESSOR_ARM_64)
711#define QT_SSL_SUFFIX "-arm64"
712#elif defined(Q_PROCESSOR_ARM_32)
713#define QT_SSL_SUFFIX "-arm"
714#else
715#define QT_SSL_SUFFIX
716#endif
717
718 tryToLoadOpenSslWin32Library("libssl-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1,
719 "libcrypto-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1, result);
720
721#undef QT_SSL_SUFFIX
722 return result;
723}
724#else // !Q_OS_WIN:
725
726struct LoadedOpenSsl {
727 std::unique_ptr<QLibrary> ssl, crypto;
728};
729
730static LoadedOpenSsl loadOpenSsl()
731{
732 LoadedOpenSsl result = { std::make_unique<QLibrary>(), std::make_unique<QLibrary>() };
733
734# if defined(Q_OS_UNIX)
735 QLibrary * const libssl = result.ssl.get();
736 QLibrary * const libcrypto = result.crypto.get();
737
738 // Try to find the libssl library on the system.
739 //
740 // Up until Qt 4.3, this only searched for the "ssl" library at version -1, that
741 // is, libssl.so on most Unix systems. However, the .so file isn't present in
742 // user installations because it's considered a development file.
743 //
744 // The right thing to do is to load the library at the major version we know how
745 // to work with: the SHLIB_VERSION_NUMBER version (macro defined in opensslv.h)
746 //
747 // However, OpenSSL is a well-known case of binary-compatibility breakage. To
748 // avoid such problems, many system integrators and Linux distributions change
749 // the soname of the binary, letting the full version number be the soname. So
750 // we'll find libssl.so.0.9.7, libssl.so.0.9.8, etc. in the system. For that
751 // reason, we will search a few common paths (see findAllLibSsl() above) in hopes
752 // we find one that works.
753 //
754 // If that fails, for OpenSSL 1.0 we also try some fallbacks -- look up
755 // libssl.so with a hardcoded soname. The reason is QTBUG-68156: the binary
756 // builds of Qt happen (at the time of this writing) on RHEL machines,
757 // which change SHLIB_VERSION_NUMBER to a non-portable string. When running
758 // those binaries on the target systems, this code won't pick up
759 // libssl.so.MODIFIED_SHLIB_VERSION_NUMBER because it doesn't exist there.
760 // Given that the only 1.0 supported release (at the time of this writing)
761 // is 1.0.2, with soname "1.0.0", give that a try too. Note that we mandate
762 // OpenSSL >= 1.0.0 with a configure-time check, and OpenSSL has kept binary
763 // compatibility between 1.0.0 and 1.0.2.
764 //
765 // It is important, however, to try the canonical name and the unversioned name
766 // without going through the loop. By not specifying a path, we let the system
767 // dlopen(3) function determine it for us. This will include any DT_RUNPATH or
768 // DT_RPATH tags on our library header as well as other system-specific search
769 // paths. See the man page for dlopen(3) on your system for more information.
770
771#ifdef Q_OS_OPENBSD
772 libcrypto->setLoadHints(QLibrary::ExportExternalSymbolsHint);
773#endif
774
775#if !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so
776
777#if defined(OPENSSL_SHLIB_VERSION)
778 // OpenSSL v.3 does not have SLIB_VERSION_NUMBER but has OPENSSL_SHLIB_VERSION.
779 // The comment about OPENSSL_SHLIB_VERSION in opensslv.h is a bit troublesome:
780 // "This is defined in free form."
781 auto shlibVersion = QString("%1"_L1).arg(OPENSSL_SHLIB_VERSION);
782 libssl->setFileNameAndVersion("ssl"_L1, shlibVersion);
783 libcrypto->setFileNameAndVersion("crypto"_L1, shlibVersion);
784#elif defined(SHLIB_VERSION_NUMBER)
785 // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
786 libssl->setFileNameAndVersion("ssl"_L1, SHLIB_VERSION_NUMBER ""_L1);
787 libcrypto->setFileNameAndVersion("crypto"_L1, SHLIB_VERSION_NUMBER ""_L1);
788#endif // OPENSSL_SHLIB_VERSION
789
790 if (libcrypto->load() && libssl->load()) {
791 // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
792 return result;
793 } else {
794 libssl->unload();
795 libcrypto->unload();
796 }
797#endif // !defined(Q_OS_QNX)
798
799#ifndef Q_OS_DARWIN
800 // second attempt: find the development files libssl.so and libcrypto.so
801 //
802 // disabled on macOS/iOS:
803 // macOS's /usr/lib/libssl.dylib, /usr/lib/libcrypto.dylib will be picked up in the third
804 // attempt, _after_ <bundle>/Contents/Frameworks has been searched.
805 // iOS does not ship a system libssl.dylib, libcrypto.dylib in the first place.
806# if defined(Q_OS_ANDROID)
807 // 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
808 auto openSSLSuffix = [](const QByteArray &defaultSuffix = {}) {
809 auto suffix = qgetenv("ANDROID_OPENSSL_SUFFIX");
810 if (suffix.isEmpty())
811 return defaultSuffix;
812 return suffix;
813 };
814
815 static QString suffix = QString::fromLatin1(openSSLSuffix("_" QT_OPENSSL_VERSION));
816
817 libssl->setFileNameAndVersion("ssl"_L1 + suffix, -1);
818 libcrypto->setFileNameAndVersion("crypto"_L1 + suffix, -1);
819# else
820 libssl->setFileNameAndVersion("ssl"_L1, -1);
821 libcrypto->setFileNameAndVersion("crypto"_L1, -1);
822# endif
823 if (libcrypto->load() && libssl->load()) {
824 // libssl.so.0 and libcrypto.so.0 found
825 return result;
826 } else {
827 libssl->unload();
828 libcrypto->unload();
829 }
830#endif
831
832 // third attempt: loop on the most common library paths and find libssl
833 const QStringList sslList = findAllLibSsl();
834 const QStringList cryptoList = findAllLibCrypto();
835
836 for (const QString &crypto : cryptoList) {
837#ifdef Q_OS_DARWIN
838 // Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI
839 if (crypto.endsWith("libcrypto.dylib"_L1))
840 continue;
841#endif
842 libcrypto->setFileNameAndVersion(crypto, -1);
843 if (libcrypto->load()) {
844 QFileInfo fi(crypto);
845 QString version = fi.completeSuffix();
846
847 for (const QString &ssl : sslList) {
848 if (!ssl.endsWith(version))
849 continue;
850
851 libssl->setFileNameAndVersion(ssl, -1);
852
853 if (libssl->load()) {
854 // libssl.so.x and libcrypto.so.x found
855 return result;
856 } else {
857 libssl->unload();
858 }
859 }
860 }
861 libcrypto->unload();
862 }
863
864 // failed to load anything
865 result = {};
866 return result;
867
868# else
869 // not implemented for this platform yet
870 return result;
871# endif
872}
873#endif
874
876{
877 static bool symbolsResolved = []() {
878 LoadedOpenSsl libs = loadOpenSsl();
879 if (!libs.ssl || !libs.crypto) {
880 qCWarning(lcTlsBackend, "Failed to load libssl/libcrypto.");
881 return false;
882 }
883
884 RESOLVEFUNC(OPENSSL_init_ssl)
885 RESOLVEFUNC(OPENSSL_init_crypto)
886 RESOLVEFUNC(ASN1_STRING_get0_data)
887 RESOLVEFUNC(EVP_CIPHER_CTX_reset)
888 RESOLVEFUNC(AUTHORITY_INFO_ACCESS_free)
889 RESOLVEFUNC(EVP_PKEY_up_ref)
890 RESOLVEFUNC(EVP_PKEY_CTX_new)
891 RESOLVEFUNC(EVP_PKEY_param_check)
892 RESOLVEFUNC(EVP_PKEY_CTX_free)
893 RESOLVEFUNC(OPENSSL_sk_new_null)
894 RESOLVEFUNC(OPENSSL_sk_push)
895 RESOLVEFUNC(OPENSSL_sk_free)
896 RESOLVEFUNC(OPENSSL_sk_num)
897 RESOLVEFUNC(OPENSSL_sk_pop_free)
898 RESOLVEFUNC(OPENSSL_sk_value)
899 RESOLVEFUNC(SSL_CTX_set_options)
900 RESOLVEFUNC(SSL_set_info_callback)
901 RESOLVEFUNC(SSL_alert_type_string)
902 RESOLVEFUNC(SSL_alert_desc_string_long)
903 RESOLVEFUNC(SSL_CTX_get_security_level)
904 RESOLVEFUNC(SSL_CTX_set_security_level)
905#ifdef TLS1_3_VERSION
906 RESOLVEFUNC(SSL_CTX_set_ciphersuites)
907 RESOLVEFUNC(SSL_set_psk_use_session_callback)
908 RESOLVEFUNC(SSL_CTX_sess_set_new_cb)
909 RESOLVEFUNC(SSL_SESSION_is_resumable)
910#endif // TLS 1.3 or OpenSSL > 1.1.1
911
912 RESOLVEFUNC(SSL_get_client_random)
913 RESOLVEFUNC(SSL_SESSION_get_master_key)
914 RESOLVEFUNC(SSL_session_reused)
915 RESOLVEFUNC(SSL_get_session)
916 RESOLVEFUNC(SSL_set_options)
917 RESOLVEFUNC(CRYPTO_get_ex_new_index)
918 RESOLVEFUNC(TLS_method)
919 RESOLVEFUNC(TLS_client_method)
920 RESOLVEFUNC(TLS_server_method)
921 RESOLVEFUNC(X509_up_ref)
922 RESOLVEFUNC(X509_STORE_CTX_get0_chain)
923 RESOLVEFUNC(X509_getm_notBefore)
924 RESOLVEFUNC(X509_getm_notAfter)
925 RESOLVEFUNC(ASN1_item_free)
926 RESOLVEFUNC(X509V3_conf_free)
927 RESOLVEFUNC(X509_get_version)
928 RESOLVEFUNC(X509_get_pubkey)
929 RESOLVEFUNC(X509_STORE_set_verify_cb)
930 RESOLVEFUNC(X509_STORE_set_ex_data)
931 RESOLVEFUNC(X509_STORE_get_ex_data)
932 RESOLVEFUNC(CRYPTO_free)
933 RESOLVEFUNC(CRYPTO_memcmp)
934 RESOLVEFUNC(OpenSSL_version_num)
935 RESOLVEFUNC(OpenSSL_version)
936
937 if (!_q_OpenSSL_version || !_q_OpenSSL_version_num) {
938 // Apparently, we were built with OpenSSL 1.1 enabled but are now using
939 // a wrong library.
940 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL");
941 return false;
942 }
943
944#if OPENSSL_VERSION_NUMBER >= 0x30000000
945 if (q_OpenSSL_version_num() < 0x30000000) {
946 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL (built with OpenSSL >= 3.x, runtime version is < 3.x)");
947 return false;
948 }
949#else
950 if (q_OpenSSL_version_num() >= 0x30000000) {
951 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL (built with OpenSSL 1.x, runtime version is >= 3.x)");
952 return false;
953 }
954#endif // OPENSSL_VERSION_NUMBER
955
956 RESOLVEFUNC(SSL_SESSION_get_ticket_lifetime_hint)
957
958#if QT_CONFIG(dtls)
959 RESOLVEFUNC(DTLSv1_listen)
960 RESOLVEFUNC(BIO_ADDR_new)
961 RESOLVEFUNC(BIO_ADDR_free)
962 RESOLVEFUNC(BIO_meth_new)
963 RESOLVEFUNC(BIO_meth_free)
964 RESOLVEFUNC(BIO_meth_set_write)
965 RESOLVEFUNC(BIO_meth_set_read)
966 RESOLVEFUNC(BIO_meth_set_puts)
967 RESOLVEFUNC(BIO_meth_set_ctrl)
968 RESOLVEFUNC(BIO_meth_set_create)
969 RESOLVEFUNC(BIO_meth_set_destroy)
970#endif // dtls
971
972#if QT_CONFIG(ocsp)
973 RESOLVEFUNC(OCSP_SINGLERESP_get0_id)
974 RESOLVEFUNC(d2i_OCSP_RESPONSE)
975 RESOLVEFUNC(OCSP_RESPONSE_free)
976 RESOLVEFUNC(OCSP_response_status)
977 RESOLVEFUNC(OCSP_response_get1_basic)
978 RESOLVEFUNC(OCSP_BASICRESP_free)
979 RESOLVEFUNC(OCSP_basic_verify)
980 RESOLVEFUNC(OCSP_resp_count)
981 RESOLVEFUNC(OCSP_resp_get0)
982 RESOLVEFUNC(OCSP_single_get0_status)
983 RESOLVEFUNC(OCSP_check_validity)
984 RESOLVEFUNC(OCSP_cert_to_id)
985 RESOLVEFUNC(OCSP_id_get0_info)
986 RESOLVEFUNC(OCSP_resp_get0_certs)
987 RESOLVEFUNC(OCSP_basic_sign)
988 RESOLVEFUNC(OCSP_response_create)
989 RESOLVEFUNC(i2d_OCSP_RESPONSE)
990 RESOLVEFUNC(OCSP_basic_add1_status)
991 RESOLVEFUNC(OCSP_BASICRESP_new)
992 RESOLVEFUNC(OCSP_CERTID_free)
993 RESOLVEFUNC(OCSP_cert_to_id)
994 RESOLVEFUNC(OCSP_id_cmp)
995#endif // ocsp
996
997 RESOLVEFUNC(BIO_set_data)
998 RESOLVEFUNC(BIO_get_data)
999 RESOLVEFUNC(BIO_set_init)
1000 RESOLVEFUNC(BIO_get_shutdown)
1001 RESOLVEFUNC(BIO_set_shutdown)
1002 RESOLVEFUNC(ASN1_INTEGER_get)
1003 RESOLVEFUNC(ASN1_INTEGER_cmp)
1004 RESOLVEFUNC(ASN1_STRING_length)
1005 RESOLVEFUNC(ASN1_STRING_to_UTF8)
1006 RESOLVEFUNC(ASN1_TIME_to_tm)
1007 RESOLVEFUNC(BIO_ctrl)
1008 RESOLVEFUNC(BIO_free)
1009 RESOLVEFUNC(BIO_new)
1010 RESOLVEFUNC(BIO_new_mem_buf)
1011 RESOLVEFUNC(BIO_read)
1012 RESOLVEFUNC(BIO_s_mem)
1013 RESOLVEFUNC(BIO_write)
1014 RESOLVEFUNC(BIO_set_flags)
1015 RESOLVEFUNC(BIO_clear_flags)
1016 RESOLVEFUNC(BIO_set_ex_data)
1017 RESOLVEFUNC(BIO_get_ex_data)
1018 RESOLVEFUNC(BN_num_bits)
1019 RESOLVEFUNC(BN_is_word)
1020 RESOLVEFUNC(BN_mod_word)
1021 RESOLVEFUNC(ERR_error_string)
1022 RESOLVEFUNC(ERR_error_string_n)
1023 RESOLVEFUNC(ERR_get_error)
1024 RESOLVEFUNC(EVP_CIPHER_CTX_new)
1025 RESOLVEFUNC(EVP_CIPHER_CTX_free)
1026 RESOLVEFUNC(EVP_CIPHER_CTX_ctrl)
1027 RESOLVEFUNC(EVP_CIPHER_CTX_set_key_length)
1028 RESOLVEFUNC(EVP_CipherInit)
1029 RESOLVEFUNC(EVP_CipherInit_ex)
1030 RESOLVEFUNC(EVP_CipherUpdate)
1031 RESOLVEFUNC(EVP_CipherFinal)
1032 RESOLVEFUNC(EVP_get_digestbyname)
1033#ifndef OPENSSL_NO_DES
1034 RESOLVEFUNC(EVP_des_cbc)
1035 RESOLVEFUNC(EVP_des_ede3_cbc)
1036#endif
1037#ifndef OPENSSL_NO_RC2
1038 RESOLVEFUNC(EVP_rc2_cbc)
1039#endif
1040#ifndef OPENSSL_NO_AES
1041 RESOLVEFUNC(EVP_aes_128_cbc)
1042 RESOLVEFUNC(EVP_aes_192_cbc)
1043 RESOLVEFUNC(EVP_aes_256_cbc)
1044#endif
1045 RESOLVEFUNC(EVP_sha1)
1046 RESOLVEFUNC(EVP_PKEY_free)
1047 RESOLVEFUNC(EVP_PKEY_new)
1048 RESOLVEFUNC(EVP_PKEY_type)
1049 RESOLVEFUNC(OBJ_nid2sn)
1050 RESOLVEFUNC(OBJ_nid2ln)
1051 RESOLVEFUNC(OBJ_sn2nid)
1052 RESOLVEFUNC(OBJ_ln2nid)
1053 RESOLVEFUNC(i2t_ASN1_OBJECT)
1054 RESOLVEFUNC(OBJ_obj2txt)
1055 RESOLVEFUNC(OBJ_obj2nid)
1056 RESOLVEFUNC(PEM_read_bio_PrivateKey)
1057 RESOLVEFUNC(PEM_write_bio_PrivateKey)
1058 RESOLVEFUNC(PEM_write_bio_PrivateKey_traditional)
1059 RESOLVEFUNC(PEM_read_bio_PUBKEY)
1060 RESOLVEFUNC(PEM_write_bio_PUBKEY)
1061 RESOLVEFUNC(RAND_seed)
1062 RESOLVEFUNC(RAND_status)
1063 RESOLVEFUNC(RAND_bytes)
1064 RESOLVEFUNC(SSL_CIPHER_description)
1065 RESOLVEFUNC(SSL_CIPHER_get_bits)
1066 RESOLVEFUNC(SSL_get_rbio)
1067 RESOLVEFUNC(SSL_CTX_check_private_key)
1068 RESOLVEFUNC(SSL_CTX_ctrl)
1069 RESOLVEFUNC(SSL_CTX_free)
1070 RESOLVEFUNC(SSL_CTX_new)
1071 RESOLVEFUNC(SSL_CTX_set_cipher_list)
1072 RESOLVEFUNC(SSL_CTX_callback_ctrl)
1073 RESOLVEFUNC(SSL_CTX_set_default_verify_paths)
1074 RESOLVEFUNC(SSL_CTX_set_verify)
1075 RESOLVEFUNC(SSL_CTX_set_verify_depth)
1076 RESOLVEFUNC(SSL_CTX_use_certificate)
1077 RESOLVEFUNC(SSL_CTX_use_certificate_file)
1078 RESOLVEFUNC(SSL_CTX_use_PrivateKey)
1079 RESOLVEFUNC(SSL_CTX_use_PrivateKey_file)
1080 RESOLVEFUNC(SSL_CTX_get_cert_store);
1081 RESOLVEFUNC(SSL_CONF_CTX_new);
1082 RESOLVEFUNC(SSL_CONF_CTX_free);
1083 RESOLVEFUNC(SSL_CONF_CTX_set_ssl_ctx);
1084 RESOLVEFUNC(SSL_CONF_CTX_set_flags);
1085 RESOLVEFUNC(SSL_CONF_CTX_finish);
1086 RESOLVEFUNC(SSL_CONF_cmd);
1087 RESOLVEFUNC(SSL_accept)
1088 RESOLVEFUNC(SSL_clear)
1089 RESOLVEFUNC(SSL_connect)
1090 RESOLVEFUNC(SSL_free)
1091 RESOLVEFUNC(SSL_get_ciphers)
1092 RESOLVEFUNC(SSL_get_current_cipher)
1093 RESOLVEFUNC(SSL_version)
1094 RESOLVEFUNC(SSL_get_error)
1095 RESOLVEFUNC(SSL_get_peer_cert_chain)
1096
1097#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
1098 RESOLVEFUNC(SSL_get1_peer_certificate)
1099 RESOLVEFUNC(EVP_PKEY_get_bits)
1100 RESOLVEFUNC(EVP_PKEY_get_security_bits)
1101 RESOLVEFUNC(EVP_PKEY_get_base_id)
1102 RESOLVEFUNC(EVP_PKEY_get0_type_name)
1103 RESOLVEFUNC(OSSL_PROVIDER_load)
1104 RESOLVEFUNC(OSSL_PROVIDER_unload)
1105 RESOLVEFUNC(EVP_default_properties_is_fips_enabled)
1106#else
1107 RESOLVEFUNC(SSL_get_peer_certificate)
1108 RESOLVEFUNC(EVP_PKEY_base_id)
1109#endif // OPENSSL_VERSION_MAJOR >= 3
1110
1111#ifndef OPENSSL_NO_DEPRECATED_3_0
1112 RESOLVEFUNC(DH_new)
1113 RESOLVEFUNC(DH_free)
1114 RESOLVEFUNC(DH_check)
1115 RESOLVEFUNC(DH_get0_pqg)
1116
1117 RESOLVEFUNC(d2i_DHparams)
1118 RESOLVEFUNC(i2d_DHparams)
1119
1120 RESOLVEFUNC(PEM_read_bio_DHparams)
1121
1122 RESOLVEFUNC(EVP_PKEY_assign)
1123 RESOLVEFUNC(EVP_PKEY_cmp)
1124
1125 RESOLVEFUNC(EVP_PKEY_set1_RSA)
1126 RESOLVEFUNC(EVP_PKEY_set1_DSA)
1127 RESOLVEFUNC(EVP_PKEY_set1_DH)
1128
1129 RESOLVEFUNC(EVP_PKEY_get1_DSA)
1130 RESOLVEFUNC(EVP_PKEY_get1_RSA)
1131 RESOLVEFUNC(EVP_PKEY_get1_DH)
1132
1133 RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY)
1134 RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY)
1135 RESOLVEFUNC(PEM_read_bio_DSAPrivateKey)
1136 RESOLVEFUNC(PEM_read_bio_RSAPrivateKey)
1137
1138 RESOLVEFUNC(PEM_write_bio_DSA_PUBKEY)
1139 RESOLVEFUNC(PEM_write_bio_RSA_PUBKEY)
1140 RESOLVEFUNC(PEM_write_bio_DSAPrivateKey)
1141 RESOLVEFUNC(PEM_write_bio_RSAPrivateKey)
1142 RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey)
1143
1144 RESOLVEFUNC(DSA_new)
1145 RESOLVEFUNC(DSA_free)
1146
1147 RESOLVEFUNC(RSA_new)
1148 RESOLVEFUNC(RSA_free)
1149
1150 RESOLVEFUNC(DH_bits)
1151 RESOLVEFUNC(DSA_bits)
1152 RESOLVEFUNC(RSA_bits)
1153
1154#ifndef OPENSSL_NO_EC
1155
1156 RESOLVEFUNC(EVP_PKEY_set1_EC_KEY)
1157 RESOLVEFUNC(EVP_PKEY_get1_EC_KEY)
1158 RESOLVEFUNC(PEM_read_bio_EC_PUBKEY)
1159 RESOLVEFUNC(PEM_read_bio_ECPrivateKey)
1160 RESOLVEFUNC(PEM_write_bio_EC_PUBKEY)
1161 RESOLVEFUNC(PEM_write_bio_ECPrivateKey)
1162 RESOLVEFUNC(EC_KEY_get0_group)
1163 RESOLVEFUNC(EC_GROUP_get_degree)
1164 RESOLVEFUNC(EC_KEY_dup)
1165 RESOLVEFUNC(EC_KEY_new_by_curve_name)
1166 RESOLVEFUNC(EC_KEY_free)
1167
1168#endif // OPENSSL_NO_EC
1169
1170#endif // OPENSSL_NO_DEPRECATED_3_0
1171
1172 RESOLVEFUNC(SSL_get_verify_result)
1173 RESOLVEFUNC(SSL_new)
1174 RESOLVEFUNC(SSL_get_SSL_CTX)
1175 RESOLVEFUNC(SSL_ctrl)
1176 RESOLVEFUNC(SSL_read)
1177 RESOLVEFUNC(SSL_set_accept_state)
1178 RESOLVEFUNC(SSL_set_bio)
1179 RESOLVEFUNC(SSL_set_connect_state)
1180 RESOLVEFUNC(SSL_shutdown)
1181 RESOLVEFUNC(SSL_in_init)
1182 RESOLVEFUNC(SSL_get_shutdown)
1183 RESOLVEFUNC(SSL_set_session)
1184 RESOLVEFUNC(SSL_SESSION_free)
1185 RESOLVEFUNC(SSL_get1_session)
1186 RESOLVEFUNC(SSL_get_session)
1187 RESOLVEFUNC(SSL_set_ex_data)
1188 RESOLVEFUNC(SSL_get_ex_data)
1189 RESOLVEFUNC(SSL_get_ex_data_X509_STORE_CTX_idx)
1190
1191#ifndef OPENSSL_NO_PSK
1192 RESOLVEFUNC(SSL_set_psk_client_callback)
1193 RESOLVEFUNC(SSL_set_psk_server_callback)
1194 RESOLVEFUNC(SSL_CTX_use_psk_identity_hint)
1195#endif // !OPENSSL_NO_PSK
1196
1197 RESOLVEFUNC(SSL_write)
1198 RESOLVEFUNC(X509_NAME_entry_count)
1199 RESOLVEFUNC(X509_NAME_get_entry)
1200 RESOLVEFUNC(X509_NAME_ENTRY_get_data)
1201 RESOLVEFUNC(X509_NAME_ENTRY_get_object)
1202 RESOLVEFUNC(X509_PUBKEY_get)
1203 RESOLVEFUNC(X509_STORE_free)
1204 RESOLVEFUNC(X509_STORE_new)
1205 RESOLVEFUNC(X509_STORE_add_cert)
1206 RESOLVEFUNC(X509_STORE_CTX_free)
1207 RESOLVEFUNC(X509_STORE_CTX_init)
1208 RESOLVEFUNC(X509_STORE_CTX_new)
1209 RESOLVEFUNC(X509_STORE_CTX_set_purpose)
1210 RESOLVEFUNC(X509_STORE_CTX_get_error)
1211 RESOLVEFUNC(X509_STORE_CTX_get_error_depth)
1212 RESOLVEFUNC(X509_STORE_CTX_get_current_cert)
1213 RESOLVEFUNC(X509_STORE_CTX_get0_store)
1214 RESOLVEFUNC(SSL_export_keying_material)
1215 RESOLVEFUNC(X509_cmp)
1216 RESOLVEFUNC(X509_STORE_CTX_get_ex_data)
1217 RESOLVEFUNC(X509_dup)
1218 RESOLVEFUNC(X509_print)
1219 RESOLVEFUNC(X509_digest)
1220 RESOLVEFUNC(X509_EXTENSION_get_object)
1221 RESOLVEFUNC(X509_free)
1222 RESOLVEFUNC(X509_gmtime_adj)
1223 RESOLVEFUNC(ASN1_TIME_free)
1224 RESOLVEFUNC(X509_get_ext)
1225 RESOLVEFUNC(X509_get_ext_count)
1226 RESOLVEFUNC(X509_get_ext_d2i)
1227 RESOLVEFUNC(X509V3_EXT_get)
1228 RESOLVEFUNC(X509V3_EXT_d2i)
1229 RESOLVEFUNC(X509_EXTENSION_get_critical)
1230 RESOLVEFUNC(X509_EXTENSION_get_data)
1231 RESOLVEFUNC(BASIC_CONSTRAINTS_free)
1232 RESOLVEFUNC(AUTHORITY_KEYID_free)
1233 RESOLVEFUNC(GENERAL_NAME_free)
1234 RESOLVEFUNC(ASN1_STRING_print)
1235 RESOLVEFUNC(X509_check_issued)
1236 RESOLVEFUNC(X509_get_issuer_name)
1237 RESOLVEFUNC(X509_get_subject_name)
1238 RESOLVEFUNC(X509_get_serialNumber)
1239 RESOLVEFUNC(X509_verify_cert)
1240 RESOLVEFUNC(d2i_X509)
1241 RESOLVEFUNC(i2d_X509)
1242#if OPENSSL_VERSION_MAJOR < 3
1243 RESOLVEFUNC(SSL_CTX_load_verify_locations)
1244#else
1245 RESOLVEFUNC(SSL_CTX_load_verify_dir)
1246#endif // OPENSSL_VERSION_MAJOR
1247 RESOLVEFUNC(i2d_SSL_SESSION)
1248 RESOLVEFUNC(d2i_SSL_SESSION)
1249
1250#ifndef OPENSSL_NO_NEXTPROTONEG
1251 RESOLVEFUNC(SSL_select_next_proto)
1252 RESOLVEFUNC(SSL_CTX_set_next_proto_select_cb)
1253 RESOLVEFUNC(SSL_get0_next_proto_negotiated)
1254 RESOLVEFUNC(SSL_set_alpn_protos)
1255 RESOLVEFUNC(SSL_CTX_set_alpn_select_cb)
1256 RESOLVEFUNC(SSL_get0_alpn_selected)
1257#endif // !OPENSSL_NO_NEXTPROTONEG
1258
1259#if QT_CONFIG(dtls)
1260 RESOLVEFUNC(SSL_CTX_set_cookie_generate_cb)
1261 RESOLVEFUNC(SSL_CTX_set_cookie_verify_cb)
1262 RESOLVEFUNC(DTLS_server_method)
1263 RESOLVEFUNC(DTLS_client_method)
1264#endif // dtls
1265
1266 RESOLVEFUNC(CRYPTO_malloc)
1267 RESOLVEFUNC(BN_bin2bn)
1268
1269#ifndef OPENSSL_NO_EC
1270 RESOLVEFUNC(EC_get_builtin_curves)
1271#endif // OPENSSL_NO_EC
1272
1273 RESOLVEFUNC(PKCS12_parse)
1274 RESOLVEFUNC(d2i_PKCS12_bio)
1275 RESOLVEFUNC(PKCS12_free)
1276 return true;
1277 }();
1278
1279 return symbolsResolved;
1280}
1281#endif // QT_CONFIG(library)
1282
1283#else // !defined QT_LINKED_OPENSSL
1284
1285bool q_resolveOpenSslSymbols()
1286{
1287#ifdef QT_NO_OPENSSL
1288 return false;
1289#endif
1290 return true;
1291}
1292#endif // !defined QT_LINKED_OPENSSL
1293
1294QT_END_NAMESPACE
#define DEFINEFUNC(ret, func, args, argcall, funcret)
#define QT_OPENSSL4_CONST
Definition qopenssl_p.h:78
SSL_CTX int void DUMMYARG SSL const unsigned char * protos
SSL_CTX int void * arg
SSL_CTX int void DUMMYARG SSL const unsigned char unsigned return const SSL const unsigned char ** data
#define RESOLVEFUNC(func)
SSL_CTX int void DUMMYARG SSL const unsigned char unsigned return const SSL const unsigned char unsigned * len
SSL_CTX int void DUMMYARG SSL const unsigned char unsigned protos_len
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define DEFINEFUNC5(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, err, funcret)
#define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret)
bool q_resolveOpenSslSymbols()
unsigned int(* q_psk_server_callback_t)(SSL *ssl, const char *identity, unsigned char *psk, unsigned int max_psk_len)
void(* GenericCallbackType)()
#define DEFINEFUNC7(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, err, funcret)
#define DEFINEFUNC2(ret, func, arg1, a, arg2, b, err, funcret)
int(* q_SSL_psk_use_session_cb_func_t)(SSL *, const EVP_MD *, const unsigned char **, size_t *, SSL_SESSION **)
#define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret)
size_t q_EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems)
#define DEFINEFUNC3(ret, func, arg1, a, arg2, b, arg3, c, err, funcret)
unsigned int(* q_psk_client_callback_t)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)
size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen)
#define DEFINEFUNC8(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, arg8, h, err, funcret)
long q_OpenSSL_version_num()
size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen)