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