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