Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsslsocket_openssl_symbols.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// Copyright (C) 2014 BlackBerry Limited. All rights reserved.
3// Copyright (C) 2016 Richard J. Moore <rich@kde.org>
4// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
5// Qt-Security score:critical reason:execute-external-code
6
7/****************************************************************************
8**
9** In addition, as a special exception, the copyright holders listed above give
10** permission to link the code of its release of Qt with the OpenSSL project's
11** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
12** same license as the original version), and distribute the linked executables.
13**
14** You must comply with the GNU General Public License version 2 in all
15** respects for all of the code used other than the "OpenSSL" code. If you
16** modify this file, you may extend this exception to your version of the file,
17** but you are not obligated to do so. If you do not wish to do so, delete
18** this exception statement from your version of this file.
19**
20****************************************************************************/
21
24
25#include <QtNetwork/private/qssl_p.h>
26
27#ifdef Q_OS_WIN
28# include <QtCore/private/qsystemlibrary_p.h>
29#elif QT_CONFIG(library)
30# include <QtCore/qlibrary.h>
31#endif
32#include <QtCore/qdatetime.h>
33#if defined(Q_OS_UNIX)
34#include <QtCore/qdir.h>
35#include <QtCore/qdirlisting.h>
36#endif
37#include <QtCore/private/qduplicatetracker_p.h>
38#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
39#include <link.h>
40#endif
41#ifdef Q_OS_DARWIN
42#include <QtCore/private/qcore_mac_p.h>
43#endif
44
45#include <algorithm>
46
47QT_BEGIN_NAMESPACE
48
49using namespace Qt::StringLiterals;
50
51/*
52 Note to maintainer:
53 -------------------
54
55 We load OpenSSL symbols dynamically. Because symbols are known to
56 disappear, and signatures sometimes change, between releases, we need to
57 be careful about how this is done. To ensure we don't end up dereferencing
58 null function pointers, and continue running even if certain functions are
59 missing, we define helper functions for each of the symbols we load from
60 OpenSSL, all prefixed with "q_" (declared in
61 qsslsocket_openssl_symbols_p.h). So instead of calling SSL_connect
62 directly, we call q_SSL_connect, which is a function that checks if the
63 actual SSL_connect fptr is null, and returns a failure if it is, or calls
64 SSL_connect if it isn't.
65
66 This requires a somewhat tedious process of declaring each function we
67 want to call in OpenSSL thrice: once with the q_, in _p.h, once using the
68 DEFINEFUNC macros below, and once in the function that actually resolves
69 the symbols, below the DEFINEFUNC declarations below.
70
71 There's one DEFINEFUNC macro declared for every number of arguments
72 exposed by OpenSSL (feel free to extend when needed). The easiest thing to
73 do is to find an existing entry that matches the arg count of the function
74 you want to import, and do the same.
75
76 The first macro arg is the function return type. The second is the
77 verbatim name of the function/symbol. Then follows a list of N pairs of
78 argument types with a variable name, and just the variable name (char *a,
79 a, char *b, b, etc). Finally there's two arguments - a suitable return
80 statement for the error case (for an int function, return 0 or return -1
81 is usually right). Then either just "return" or DUMMYARG, the latter being
82 for void functions.
83
84 Note: Take into account that these macros and declarations are processed
85 at compile-time, and the result depends on the OpenSSL headers the
86 compiling host has installed, but the symbols are resolved at run-time,
87 possibly with a different version of OpenSSL.
88*/
89
90#ifndef QT_LINKED_OPENSSL
91
92namespace {
93void qsslSocketUnresolvedSymbolWarning(const char *functionName)
94{
95 qCWarning(lcTlsBackend, "QSslSocket: cannot call unresolved function %s", functionName);
96}
97
98#if QT_CONFIG(library)
99void qsslSocketCannotResolveSymbolWarning(const char *functionName)
100{
101 qCWarning(lcTlsBackend, "QSslSocket: cannot resolve %s", functionName);
102}
103#endif
104
105}
106
107#endif // QT_LINKED_OPENSSL
108
109DEFINEFUNC(const unsigned char *, ASN1_STRING_get0_data, const ASN1_STRING *a, a, return nullptr, return)
110DEFINEFUNC2(int, OPENSSL_init_ssl, uint64_t opts, opts, const OPENSSL_INIT_SETTINGS *settings, settings, return 0, return)
111DEFINEFUNC2(int, OPENSSL_init_crypto, uint64_t opts, opts, const OPENSSL_INIT_SETTINGS *settings, settings, return 0, return)
112DEFINEFUNC(BIO *, BIO_new, const BIO_METHOD *a, a, return nullptr, return)
113DEFINEFUNC(const BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return nullptr, return)
114DEFINEFUNC2(int, BN_is_word, BIGNUM *a, a, BN_ULONG w, w, return 0, return)
115DEFINEFUNC(int, EVP_CIPHER_CTX_reset, EVP_CIPHER_CTX *c, c, return 0, return)
116DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
117DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
118DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
119DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
120DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
121DEFINEFUNC2(void, OPENSSL_sk_pop_free, OPENSSL_STACK *a, a, void (*b)(void*), b, return, DUMMYARG)
122DEFINEFUNC(OPENSSL_STACK *, OPENSSL_sk_new_null, DUMMYARG, DUMMYARG, return nullptr, return)
123DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMMYARG)
124DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
125DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
126DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
127DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
128using info_callback = void (*) (const SSL *ssl, int type, int val);
129DEFINEFUNC2(void, SSL_set_info_callback, SSL *ssl, ssl, info_callback cb, cb, return, return)
130DEFINEFUNC(const char *, SSL_alert_type_string, int value, value, return nullptr, return)
131DEFINEFUNC(const char *, SSL_alert_desc_string_long, int value, value, return nullptr, return)
132DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
133DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
134#ifdef TLS1_3_VERSION
135DEFINEFUNC2(int, SSL_CTX_set_ciphersuites, SSL_CTX *ctx, ctx, const char *str, str, return 0, return)
136DEFINEFUNC2(void, SSL_set_psk_use_session_callback, SSL *ssl, ssl, q_SSL_psk_use_session_cb_func_t callback, callback, return, DUMMYARG)
137DEFINEFUNC2(void, SSL_CTX_sess_set_new_cb, SSL_CTX *ctx, ctx, NewSessionCallback cb, cb, return, return)
138DEFINEFUNC(int, SSL_SESSION_is_resumable, const SSL_SESSION *s, s, return 0, return)
139#endif
140DEFINEFUNC3(size_t, SSL_get_client_random, SSL *a, a, unsigned char *out, out, size_t outlen, outlen, return 0, return)
141DEFINEFUNC3(size_t, SSL_SESSION_get_master_key, const SSL_SESSION *ses, ses, unsigned char *out, out, size_t outlen, outlen, return 0, return)
142DEFINEFUNC6(int, CRYPTO_get_ex_new_index, int class_index, class_index, long argl, argl, void *argp, argp, CRYPTO_EX_new *new_func, new_func, CRYPTO_EX_dup *dup_func, dup_func, CRYPTO_EX_free *free_func, free_func, return -1, return)
143DEFINEFUNC2(unsigned long, SSL_set_options, SSL *ssl, ssl, unsigned long op, op, return 0, return)
144
145DEFINEFUNC(const SSL_METHOD *, TLS_method, DUMMYARG, DUMMYARG, return nullptr, return)
146DEFINEFUNC(const SSL_METHOD *, TLS_client_method, DUMMYARG, DUMMYARG, return nullptr, return)
147DEFINEFUNC(const SSL_METHOD *, TLS_server_method, DUMMYARG, DUMMYARG, return nullptr, return)
148DEFINEFUNC(void, X509_up_ref, X509 *a, a, return, DUMMYARG)
149DEFINEFUNC(ASN1_TIME *, X509_getm_notBefore, X509 *a, a, return nullptr, return)
150DEFINEFUNC(ASN1_TIME *, X509_getm_notAfter, X509 *a, a, return nullptr, return)
151DEFINEFUNC2(void, ASN1_item_free, ASN1_VALUE *val, val, const ASN1_ITEM *it, it, return, return)
152DEFINEFUNC(void, X509V3_conf_free, CONF_VALUE *val, val, return, return)
153DEFINEFUNC(long, X509_get_version, X509 *a, a, return -1, return)
154DEFINEFUNC(EVP_PKEY *, X509_get_pubkey, X509 *a, a, return nullptr, return)
155DEFINEFUNC2(void, X509_STORE_set_verify_cb, X509_STORE *a, a, X509_STORE_CTX_verify_cb verify_cb, verify_cb, return, DUMMYARG)
156DEFINEFUNC3(int, X509_STORE_set_ex_data, X509_STORE *a, a, int idx, idx, void *data, data, return 0, return)
157DEFINEFUNC2(void *, X509_STORE_get_ex_data, X509_STORE *r, r, int idx, idx, return nullptr, return)
158DEFINEFUNC(STACK_OF(X509) *, X509_STORE_CTX_get0_chain, X509_STORE_CTX *a, a, return nullptr, return)
159DEFINEFUNC3(void, CRYPTO_free, void *str, str, const char *file, file, int line, line, return, DUMMYARG)
160DEFINEFUNC3(int, CRYPTO_memcmp, const void * in_a, in_a, const void * in_b, in_b, size_t len, len, return 1, return);
161DEFINEFUNC(long, OpenSSL_version_num, void, DUMMYARG, return 0, return)
162DEFINEFUNC(const char *, OpenSSL_version, int a, a, return nullptr, return)
163DEFINEFUNC(unsigned long, SSL_SESSION_get_ticket_lifetime_hint, const SSL_SESSION *session, session, return 0, return)
164
165#if QT_CONFIG(dtls)
166DEFINEFUNC2(int, DTLSv1_listen, SSL *s, s, BIO_ADDR *c, c, return -1, return)
167DEFINEFUNC(BIO_ADDR *, BIO_ADDR_new, DUMMYARG, DUMMYARG, return nullptr, return)
168DEFINEFUNC(void, BIO_ADDR_free, BIO_ADDR *ap, ap, return, DUMMYARG)
169DEFINEFUNC2(BIO_METHOD *, BIO_meth_new, int type, type, const char *name, name, return nullptr, return)
170DEFINEFUNC(void, BIO_meth_free, BIO_METHOD *biom, biom, return, DUMMYARG)
171DEFINEFUNC2(int, BIO_meth_set_write, BIO_METHOD *biom, biom, DgramWriteCallback write, write, return 0, return)
172DEFINEFUNC2(int, BIO_meth_set_read, BIO_METHOD *biom, biom, DgramReadCallback read, read, return 0, return)
173DEFINEFUNC2(int, BIO_meth_set_puts, BIO_METHOD *biom, biom, DgramPutsCallback puts, puts, return 0, return)
174DEFINEFUNC2(int, BIO_meth_set_ctrl, BIO_METHOD *biom, biom, DgramCtrlCallback ctrl, ctrl, return 0, return)
175DEFINEFUNC2(int, BIO_meth_set_create, BIO_METHOD *biom, biom, DgramCreateCallback crt, crt, return 0, return)
176DEFINEFUNC2(int, BIO_meth_set_destroy, BIO_METHOD *biom, biom, DgramDestroyCallback dtr, dtr, return 0, return)
177#endif // dtls
178
179#if QT_CONFIG(ocsp)
180DEFINEFUNC(const OCSP_CERTID *, OCSP_SINGLERESP_get0_id, const OCSP_SINGLERESP *x, x, return nullptr, return)
181DEFINEFUNC3(OCSP_RESPONSE *, d2i_OCSP_RESPONSE, OCSP_RESPONSE **a, a, const unsigned char **in, in, long len, len, return nullptr, return)
182DEFINEFUNC(void, OCSP_RESPONSE_free, OCSP_RESPONSE *rs, rs, return, DUMMYARG)
183DEFINEFUNC(OCSP_BASICRESP *, OCSP_response_get1_basic, OCSP_RESPONSE *resp, resp, return nullptr, return)
184DEFINEFUNC(void, OCSP_BASICRESP_free, OCSP_BASICRESP *bs, bs, return, DUMMYARG)
185DEFINEFUNC(int, OCSP_response_status, OCSP_RESPONSE *resp, resp, return OCSP_RESPONSE_STATUS_INTERNALERROR, return)
186DEFINEFUNC4(int, OCSP_basic_verify, OCSP_BASICRESP *bs, bs, STACK_OF(X509) *certs, certs, X509_STORE *st, st, unsigned long flags, flags, return -1, return)
187DEFINEFUNC(int, OCSP_resp_count, OCSP_BASICRESP *bs, bs, return 0, return)
188DEFINEFUNC2(OCSP_SINGLERESP *, OCSP_resp_get0, OCSP_BASICRESP *bs, bs, int idx, idx, return nullptr, return)
189DEFINEFUNC5(int, OCSP_single_get0_status, OCSP_SINGLERESP *single, single, int *reason, reason, ASN1_GENERALIZEDTIME **revtime, revtime,
190 ASN1_GENERALIZEDTIME **thisupd, thisupd, ASN1_GENERALIZEDTIME **nextupd, nextupd, return -1, return)
191DEFINEFUNC4(int, OCSP_check_validity, ASN1_GENERALIZEDTIME *thisupd, thisupd, ASN1_GENERALIZEDTIME *nextupd, nextupd, long nsec, nsec, long maxsec, maxsec, return 0, return)
192DEFINEFUNC3(OCSP_CERTID *, OCSP_cert_to_id, const EVP_MD *dgst, dgst, X509 *subject, subject, X509 *issuer, issuer, return nullptr, return)
193DEFINEFUNC(void, OCSP_CERTID_free, OCSP_CERTID *cid, cid, return, DUMMYARG)
194DEFINEFUNC5(int, OCSP_id_get0_info, ASN1_OCTET_STRING **piNameHash, piNameHash, ASN1_OBJECT **pmd, pmd,
195 ASN1_OCTET_STRING **piKeyHash, piKeyHash, ASN1_INTEGER **pserial, pserial, OCSP_CERTID *cid, cid,
196 return 0, return)
197DEFINEFUNC2(OCSP_RESPONSE *, OCSP_response_create, int status, status, OCSP_BASICRESP *bs, bs, return nullptr, return)
198DEFINEFUNC(const STACK_OF(X509) *, OCSP_resp_get0_certs, const OCSP_BASICRESP *bs, bs, return nullptr, return)
199DEFINEFUNC2(int, OCSP_id_cmp, OCSP_CERTID *a, a, OCSP_CERTID *b, b, return -1, return)
200DEFINEFUNC7(OCSP_SINGLERESP *, OCSP_basic_add1_status, OCSP_BASICRESP *r, r, OCSP_CERTID *c, c, int s, s,
201 int re, re, ASN1_TIME *rt, rt, ASN1_TIME *t, t, ASN1_TIME *n, n, return nullptr, return)
202DEFINEFUNC(OCSP_BASICRESP *, OCSP_BASICRESP_new, DUMMYARG, DUMMYARG, return nullptr, return)
203DEFINEFUNC2(int, i2d_OCSP_RESPONSE, OCSP_RESPONSE *r, r, unsigned char **ppout, ppout, return 0, return)
204DEFINEFUNC6(int, OCSP_basic_sign, OCSP_BASICRESP *br, br, X509 *signer, signer, EVP_PKEY *key, key,
205 const EVP_MD *dg, dg, STACK_OF(X509) *cs, cs, unsigned long flags, flags, return 0, return)
206#endif // ocsp
207
208DEFINEFUNC(void, AUTHORITY_INFO_ACCESS_free, AUTHORITY_INFO_ACCESS *p, p, return, return)
209DEFINEFUNC2(void, BIO_set_data, BIO *a, a, void *ptr, ptr, return, DUMMYARG)
210DEFINEFUNC(void *, BIO_get_data, BIO *a, a, return nullptr, return)
211DEFINEFUNC2(void, BIO_set_init, BIO *a, a, int init, init, return, DUMMYARG)
212DEFINEFUNC(int, BIO_get_shutdown, BIO *a, a, return -1, return)
213DEFINEFUNC2(void, BIO_set_shutdown, BIO *a, a, int shut, shut, return, DUMMYARG)
214
215DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return)
216DEFINEFUNC2(int, ASN1_INTEGER_cmp, const ASN1_INTEGER *a, a, const ASN1_INTEGER *b, b, return 1, return)
217DEFINEFUNC(int, ASN1_STRING_length, const ASN1_STRING *a, a, return 0, return)
218DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, const ASN1_STRING *b, b, return 0, return)
219DEFINEFUNC2(int, ASN1_TIME_to_tm, const ASN1_TIME *s, s, struct tm *tm, tm, return 0, return)
220DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return)
221DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return)
222DEFINEFUNC2(BIO *, BIO_new_mem_buf, void *a, a, int b, b, return nullptr, return)
223DEFINEFUNC3(int, BIO_read, BIO *a, a, void *b, b, int c, c, return -1, return)
224
225DEFINEFUNC3(int, BIO_write, BIO *a, a, const void *b, b, int c, c, return -1, return)
226DEFINEFUNC(int, BN_num_bits, const BIGNUM *a, a, return 0, return)
227DEFINEFUNC2(BN_ULONG, BN_mod_word, const BIGNUM *a, a, BN_ULONG w, w, return static_cast<BN_ULONG>(-1), return)
228DEFINEFUNC3(X509 *, d2i_X509, X509 **a, a, const unsigned char **b, b, long c, c, return nullptr, return)
229DEFINEFUNC2(char *, ERR_error_string, unsigned long a, a, char *b, b, return nullptr, return)
230DEFINEFUNC3(void, ERR_error_string_n, unsigned long e, e, char *b, b, size_t len, len, return, DUMMYARG)
231DEFINEFUNC(unsigned long, ERR_get_error, DUMMYARG, DUMMYARG, return 0, return)
232DEFINEFUNC(EVP_CIPHER_CTX *, EVP_CIPHER_CTX_new, void, DUMMYARG, return nullptr, return)
233DEFINEFUNC(void, EVP_CIPHER_CTX_free, EVP_CIPHER_CTX *a, a, return, DUMMYARG)
234DEFINEFUNC4(int, EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX *ctx, ctx, int type, type, int arg, arg, void *ptr, ptr, return 0, return)
235DEFINEFUNC2(int, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX *ctx, ctx, int keylen, keylen, return 0, return)
236DEFINEFUNC5(int, EVP_CipherInit, EVP_CIPHER_CTX *ctx, ctx, const EVP_CIPHER *type, type, const unsigned char *key, key, const unsigned char *iv, iv, int enc, enc, return 0, return)
237DEFINEFUNC6(int, EVP_CipherInit_ex, EVP_CIPHER_CTX *ctx, ctx, const EVP_CIPHER *cipher, cipher, ENGINE *impl, impl, const unsigned char *key, key, const unsigned char *iv, iv, int enc, enc, return 0, return)
238DEFINEFUNC5(int, EVP_CipherUpdate, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, const unsigned char *in, in, int inl, inl, return 0, return)
239DEFINEFUNC3(int, EVP_CipherFinal, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, return 0, return)
240DEFINEFUNC(const EVP_MD *, EVP_get_digestbyname, const char *name, name, return nullptr, return)
241#ifndef OPENSSL_NO_DES
242DEFINEFUNC(const EVP_CIPHER *, EVP_des_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
243DEFINEFUNC(const EVP_CIPHER *, EVP_des_ede3_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
244#endif
245#ifndef OPENSSL_NO_RC2
246DEFINEFUNC(const EVP_CIPHER *, EVP_rc2_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
247#endif
248#ifndef OPENSSL_NO_AES
249DEFINEFUNC(const EVP_CIPHER *, EVP_aes_128_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
250DEFINEFUNC(const EVP_CIPHER *, EVP_aes_192_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
251DEFINEFUNC(const EVP_CIPHER *, EVP_aes_256_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
252#endif
253DEFINEFUNC(const EVP_MD *, EVP_sha1, DUMMYARG, DUMMYARG, return nullptr, return)
254DEFINEFUNC(void, EVP_PKEY_free, EVP_PKEY *a, a, return, DUMMYARG)
255DEFINEFUNC(EVP_PKEY *, EVP_PKEY_new, DUMMYARG, DUMMYARG, return nullptr, return)
256DEFINEFUNC(int, EVP_PKEY_type, int a, a, return NID_undef, return)
257DEFINEFUNC2(int, i2d_X509, X509 *a, a, unsigned char **b, b, return -1, return)
258DEFINEFUNC(const char *, OBJ_nid2sn, int a, a, return nullptr, return)
259DEFINEFUNC(const char *, OBJ_nid2ln, int a, a, return nullptr, return)
260DEFINEFUNC(int, OBJ_sn2nid, const char *s, s, return 0, return)
261DEFINEFUNC(int, OBJ_ln2nid, const char *s, s, return 0, return)
262DEFINEFUNC3(int, i2t_ASN1_OBJECT, char *a, a, int b, b, ASN1_OBJECT *c, c, return -1, return)
263DEFINEFUNC4(int, OBJ_obj2txt, char *a, a, int b, b, const ASN1_OBJECT *c, c, int d, d, return -1, return)
264DEFINEFUNC(int, OBJ_obj2nid, const ASN1_OBJECT *a, a, return NID_undef, return)
265DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PrivateKey, BIO *a, a, EVP_PKEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
266
267DEFINEFUNC7(int, PEM_write_bio_PrivateKey, BIO *a, a, EVP_PKEY *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
268DEFINEFUNC7(int, PEM_write_bio_PrivateKey_traditional, BIO *a, a, EVP_PKEY *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
269DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PUBKEY, BIO *a, a, EVP_PKEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
270DEFINEFUNC2(int, PEM_write_bio_PUBKEY, BIO *a, a, EVP_PKEY *b, b, return 0, return)
271DEFINEFUNC2(void, RAND_seed, const void *a, a, int b, b, return, DUMMYARG)
272DEFINEFUNC(int, RAND_status, void, DUMMYARG, return -1, return)
273DEFINEFUNC2(int, RAND_bytes, unsigned char *b, b, int n, n, return 0, return)
274DEFINEFUNC(int, SSL_accept, SSL *a, a, return -1, return)
275DEFINEFUNC(int, SSL_clear, SSL *a, a, return -1, return)
276DEFINEFUNC3(char *, SSL_CIPHER_description, const SSL_CIPHER *a, a, char *b, b, int c, c, return nullptr, return)
277DEFINEFUNC2(int, SSL_CIPHER_get_bits, const SSL_CIPHER *a, a, int *b, b, return 0, return)
278DEFINEFUNC(BIO *, SSL_get_rbio, const SSL *s, s, return nullptr, return)
279DEFINEFUNC(int, SSL_connect, SSL *a, a, return -1, return)
280DEFINEFUNC(int, SSL_CTX_check_private_key, const SSL_CTX *a, a, return -1, return)
281DEFINEFUNC4(long, SSL_CTX_ctrl, SSL_CTX *a, a, int b, b, long c, c, void *d, d, return -1, return)
282DEFINEFUNC(void, SSL_CTX_free, SSL_CTX *a, a, return, DUMMYARG)
283DEFINEFUNC(SSL_CTX *, SSL_CTX_new, const SSL_METHOD *a, a, return nullptr, return)
284DEFINEFUNC2(int, SSL_CTX_set_cipher_list, SSL_CTX *a, a, const char *b, b, return -1, return)
285DEFINEFUNC3(long, SSL_CTX_callback_ctrl, SSL_CTX *ctx, ctx, int dst, dst, GenericCallbackType cb, cb, return 0, return)
286DEFINEFUNC(int, SSL_CTX_set_default_verify_paths, SSL_CTX *a, a, return -1, return)
287DEFINEFUNC3(void, SSL_CTX_set_verify, SSL_CTX *a, a, int b, b, int (*c)(int, X509_STORE_CTX *), c, return, DUMMYARG)
288DEFINEFUNC2(void, SSL_CTX_set_verify_depth, SSL_CTX *a, a, int b, b, return, DUMMYARG)
289DEFINEFUNC2(int, SSL_CTX_use_certificate, SSL_CTX *a, a, X509 *b, b, return -1, return)
290DEFINEFUNC3(int, SSL_CTX_use_certificate_file, SSL_CTX *a, a, const char *b, b, int c, c, return -1, return)
291DEFINEFUNC2(int, SSL_CTX_use_PrivateKey, SSL_CTX *a, a, EVP_PKEY *b, b, return -1, return)
292DEFINEFUNC3(int, SSL_CTX_use_PrivateKey_file, SSL_CTX *a, a, const char *b, b, int c, c, return -1, return)
293DEFINEFUNC(X509_STORE *, SSL_CTX_get_cert_store, const SSL_CTX *a, a, return nullptr, return)
294DEFINEFUNC(SSL_CONF_CTX *, SSL_CONF_CTX_new, DUMMYARG, DUMMYARG, return nullptr, return);
295DEFINEFUNC(void, SSL_CONF_CTX_free, SSL_CONF_CTX *a, a, return ,return);
296DEFINEFUNC2(void, SSL_CONF_CTX_set_ssl_ctx, SSL_CONF_CTX *a, a, SSL_CTX *b, b, return, return);
297DEFINEFUNC2(unsigned int, SSL_CONF_CTX_set_flags, SSL_CONF_CTX *a, a, unsigned int b, b, return 0, return);
298DEFINEFUNC(int, SSL_CONF_CTX_finish, SSL_CONF_CTX *a, a, return 0, return);
299DEFINEFUNC3(int, SSL_CONF_cmd, SSL_CONF_CTX *a, a, const char *b, b, const char *c, c, return 0, return);
300DEFINEFUNC(void, SSL_free, SSL *a, a, return, DUMMYARG)
301DEFINEFUNC(STACK_OF(SSL_CIPHER) *, SSL_get_ciphers, const SSL *a, a, return nullptr, return)
302DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr, return)
303DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
304DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
305DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
306
307#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
308DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
309DEFINEFUNC(int, EVP_PKEY_get_bits, const EVP_PKEY *pkey, pkey, return -1, return)
310DEFINEFUNC(int, EVP_PKEY_get_security_bits, const EVP_PKEY *pkey, pkey, return -1, return)
311DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
312DEFINEFUNC(const char *, EVP_PKEY_get0_type_name, const EVP_PKEY *pkey, pkey, return nullptr, return)
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(QT_OPENSSL4_CONST ASN1_OBJECT *, X509_EXTENSION_get_object, QT_OPENSSL4_CONST 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(QT_OPENSSL4_CONST 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, QT_OPENSSL4_CONST X509_EXTENSION *a, a, return nullptr, return)
356DEFINEFUNC(void *, X509V3_EXT_d2i, QT_OPENSSL4_CONST X509_EXTENSION *a, a, return nullptr, return)
357DEFINEFUNC(int, X509_EXTENSION_get_critical, const X509_EXTENSION *a, a, return 0, return)
358DEFINEFUNC(QT_OPENSSL4_CONST ASN1_OCTET_STRING *, X509_EXTENSION_get_data, QT_OPENSSL4_CONST 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(QT_OPENSSL4_CONST X509_NAME *, X509_get_issuer_name, X509 *a, a, return nullptr, return)
365DEFINEFUNC(QT_OPENSSL4_CONST 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, const X509_NAME *a, a, return 0, return)
369DEFINEFUNC2(QT_OPENSSL4_CONST X509_NAME_ENTRY *, X509_NAME_get_entry, const X509_NAME *a, a, int b, b, return nullptr, return)
370DEFINEFUNC(QT_OPENSSL4_CONST ASN1_STRING *, X509_NAME_ENTRY_get_data, const X509_NAME_ENTRY *a, a, return nullptr, return)
371DEFINEFUNC(QT_OPENSSL4_CONST ASN1_OBJECT *, X509_NAME_ENTRY_get_object, const 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) && !defined(Q_OS_HARMONY)
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_HARMONY)
615 paths << "/system/lib64/platformsdk"_L1;
616 paths << "/system/lib64/chipset-sdk"_L1;
617 paths << "/system/lib64/chipset-sdk-sp"_L1;
618#elif defined(Q_OS_LINUX)
619 // discover paths of already loaded libraries
620 QDuplicateTracker<QString> loadedPaths;
621 dl_iterate_phdr(dlIterateCallback, &loadedPaths);
622 std::move(loadedPaths).appendTo(paths);
623#endif
624
625 return paths;
626}
627
628Q_NEVER_INLINE
629static QStringList findAllLibs(QLatin1StringView filter)
630{
631 const QStringList paths = libraryPathList();
632 QStringList found;
633 const QStringList filters((QString(filter)));
634
635 using F = QDirListing::IteratorFlag;
636 for (const QString &path : paths) {
637 QStringList entryList;
638 for (const auto &dirEntry : QDirListing(path, filters, F::FilesOnly))
639 entryList.emplace_back(dirEntry.fileName());
640
641 std::sort(entryList.begin(), entryList.end(), LibGreaterThan());
642 for (const QString &entry : std::as_const(entryList))
643 found << path + u'/' + entry;
644 }
645
646 return found;
647}
648
649static QStringList findAllLibSsl()
650{
651#if defined(Q_OS_HARMONY)
652 return findAllLibs("libssl_openssl*"_L1);
653#else
654 return findAllLibs("libssl.*"_L1);
655#endif
656}
657
658static QStringList findAllLibCrypto()
659{
660#if defined(Q_OS_HARMONY)
661 return findAllLibs("libcrypto_openssl*"_L1);
662#else
663 return findAllLibs("libcrypto.*"_L1);
664#endif
665}
666# endif
667
668#if (OPENSSL_VERSION_NUMBER >> 28) < 3
669#define QT_OPENSSL_VERSION "1_1"
670#elif OPENSSL_VERSION_MAJOR >= 3
671#define QT_OPENSSL_VERSION QT_STRINGIFY(OPENSSL_VERSION_MAJOR)
672#endif
673
674#ifdef Q_OS_WIN
675
676struct LoadedOpenSsl {
677 std::unique_ptr<QSystemLibrary> ssl, crypto;
678};
679
680static bool tryToLoadOpenSslWin32Library(QLatin1StringView ssleay32LibName, QLatin1StringView libeay32LibName, LoadedOpenSsl &result)
681{
682 auto ssleay32 = std::make_unique<QSystemLibrary>(ssleay32LibName);
683 if (!ssleay32->load(false)) {
684 return FALSE;
685 }
686
687 auto libeay32 = std::make_unique<QSystemLibrary>(libeay32LibName);
688 if (!libeay32->load(false)) {
689 return FALSE;
690 }
691
692 result.ssl = std::move(ssleay32);
693 result.crypto = std::move(libeay32);
694 return TRUE;
695}
696
697static LoadedOpenSsl loadOpenSsl()
698{
699 LoadedOpenSsl result;
700
701 // With OpenSSL 1.1 the names have changed to libssl-1_1 and libcrypto-1_1 for builds using
702 // MSVC and GCC. For 3.0 the version suffix changed again, to just '3'.
703 // For non-x86 builds, an architecture suffix is also appended.
704
705#if defined(Q_PROCESSOR_X86_64)
706#define QT_SSL_SUFFIX "-x64"
707#elif defined(Q_PROCESSOR_ARM_64)
708#define QT_SSL_SUFFIX "-arm64"
709#elif defined(Q_PROCESSOR_ARM_32)
710#define QT_SSL_SUFFIX "-arm"
711#else
712#define QT_SSL_SUFFIX
713#endif
714
715 tryToLoadOpenSslWin32Library("libssl-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1,
716 "libcrypto-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1, result);
717
718#undef QT_SSL_SUFFIX
719 return result;
720}
721#else // !Q_OS_WIN:
722
723struct LoadedOpenSsl {
724 std::unique_ptr<QLibrary> ssl, crypto;
725};
726
727static LoadedOpenSsl loadOpenSsl()
728{
729 LoadedOpenSsl result = { std::make_unique<QLibrary>(), std::make_unique<QLibrary>() };
730
731# if defined(Q_OS_UNIX)
732 QLibrary * const libssl = result.ssl.get();
733 QLibrary * const libcrypto = result.crypto.get();
734
735 // Try to find the libssl library on the system.
736 //
737 // Up until Qt 4.3, this only searched for the "ssl" library at version -1, that
738 // is, libssl.so on most Unix systems. However, the .so file isn't present in
739 // user installations because it's considered a development file.
740 //
741 // The right thing to do is to load the library at the major version we know how
742 // to work with: the SHLIB_VERSION_NUMBER version (macro defined in opensslv.h)
743 //
744 // However, OpenSSL is a well-known case of binary-compatibility breakage. To
745 // avoid such problems, many system integrators and Linux distributions change
746 // the soname of the binary, letting the full version number be the soname. So
747 // we'll find libssl.so.0.9.7, libssl.so.0.9.8, etc. in the system. For that
748 // reason, we will search a few common paths (see findAllLibSsl() above) in hopes
749 // we find one that works.
750 //
751 // If that fails, for OpenSSL 1.0 we also try some fallbacks -- look up
752 // libssl.so with a hardcoded soname. The reason is QTBUG-68156: the binary
753 // builds of Qt happen (at the time of this writing) on RHEL machines,
754 // which change SHLIB_VERSION_NUMBER to a non-portable string. When running
755 // those binaries on the target systems, this code won't pick up
756 // libssl.so.MODIFIED_SHLIB_VERSION_NUMBER because it doesn't exist there.
757 // Given that the only 1.0 supported release (at the time of this writing)
758 // is 1.0.2, with soname "1.0.0", give that a try too. Note that we mandate
759 // OpenSSL >= 1.0.0 with a configure-time check, and OpenSSL has kept binary
760 // compatibility between 1.0.0 and 1.0.2.
761 //
762 // It is important, however, to try the canonical name and the unversioned name
763 // without going through the loop. By not specifying a path, we let the system
764 // dlopen(3) function determine it for us. This will include any DT_RUNPATH or
765 // DT_RPATH tags on our library header as well as other system-specific search
766 // paths. See the man page for dlopen(3) on your system for more information.
767
768#ifdef Q_OS_OPENBSD
769 libcrypto->setLoadHints(QLibrary::ExportExternalSymbolsHint);
770#endif
771
772#if !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so
773
774#if defined(OPENSSL_SHLIB_VERSION)
775 // OpenSSL v.3 does not have SLIB_VERSION_NUMBER but has OPENSSL_SHLIB_VERSION.
776 // The comment about OPENSSL_SHLIB_VERSION in opensslv.h is a bit troublesome:
777 // "This is defined in free form."
778 auto shlibVersion = QString("%1"_L1).arg(OPENSSL_SHLIB_VERSION);
779 libssl->setFileNameAndVersion("ssl"_L1, shlibVersion);
780 libcrypto->setFileNameAndVersion("crypto"_L1, shlibVersion);
781#elif defined(SHLIB_VERSION_NUMBER)
782 // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
783 libssl->setFileNameAndVersion("ssl"_L1, SHLIB_VERSION_NUMBER ""_L1);
784 libcrypto->setFileNameAndVersion("crypto"_L1, SHLIB_VERSION_NUMBER ""_L1);
785#endif // OPENSSL_SHLIB_VERSION
786
787 if (libcrypto->load() && libssl->load()) {
788 // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
789 return result;
790 } else {
791 libssl->unload();
792 libcrypto->unload();
793 }
794#endif // !defined(Q_OS_QNX)
795
796#ifndef Q_OS_DARWIN
797 // second attempt: find the development files libssl.so and libcrypto.so
798 //
799 // disabled on macOS/iOS:
800 // macOS's /usr/lib/libssl.dylib, /usr/lib/libcrypto.dylib will be picked up in the third
801 // attempt, _after_ <bundle>/Contents/Frameworks has been searched.
802 // iOS does not ship a system libssl.dylib, libcrypto.dylib in the first place.
803# if defined(Q_OS_ANDROID)
804 // 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
805 auto openSSLSuffix = [](const QByteArray &defaultSuffix = {}) {
806 auto suffix = qgetenv("ANDROID_OPENSSL_SUFFIX");
807 if (suffix.isEmpty())
808 return defaultSuffix;
809 return suffix;
810 };
811
812 static QString suffix = QString::fromLatin1(openSSLSuffix("_" QT_OPENSSL_VERSION));
813
814 libssl->setFileNameAndVersion("ssl"_L1 + suffix, -1);
815 libcrypto->setFileNameAndVersion("crypto"_L1 + suffix, -1);
816# else
817 libssl->setFileNameAndVersion("ssl"_L1, -1);
818 libcrypto->setFileNameAndVersion("crypto"_L1, -1);
819# endif
820 if (libcrypto->load() && libssl->load()) {
821 // libssl.so.0 and libcrypto.so.0 found
822 return result;
823 } else {
824 libssl->unload();
825 libcrypto->unload();
826 }
827#endif
828
829 // third attempt: loop on the most common library paths and find libssl
830 const QStringList sslList = findAllLibSsl();
831 const QStringList cryptoList = findAllLibCrypto();
832
833 for (const QString &crypto : cryptoList) {
834#ifdef Q_OS_DARWIN
835 // Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI
836 if (crypto.endsWith("libcrypto.dylib"_L1))
837 continue;
838#endif
839 libcrypto->setFileNameAndVersion(crypto, -1);
840 if (libcrypto->load()) {
841 QFileInfo fi(crypto);
842 QString version = fi.completeSuffix();
843
844 for (const QString &ssl : sslList) {
845 if (!ssl.endsWith(version))
846 continue;
847
848 libssl->setFileNameAndVersion(ssl, -1);
849
850 if (libssl->load()) {
851 // libssl.so.x and libcrypto.so.x found
852 return result;
853 } else {
854 libssl->unload();
855 }
856 }
857 }
858 libcrypto->unload();
859 }
860
861 // failed to load anything
862 result = {};
863 return result;
864
865# else
866 // not implemented for this platform yet
867 return result;
868# endif
869}
870#endif
871
873{
874 static bool symbolsResolved = []() {
875 LoadedOpenSsl libs = loadOpenSsl();
876 if (!libs.ssl || !libs.crypto) {
877 qCWarning(lcTlsBackend, "Failed to load libssl/libcrypto.");
878 return false;
879 }
880
881 RESOLVEFUNC(OPENSSL_init_ssl)
882 RESOLVEFUNC(OPENSSL_init_crypto)
883 RESOLVEFUNC(ASN1_STRING_get0_data)
884 RESOLVEFUNC(EVP_CIPHER_CTX_reset)
885 RESOLVEFUNC(AUTHORITY_INFO_ACCESS_free)
886 RESOLVEFUNC(EVP_PKEY_up_ref)
887 RESOLVEFUNC(EVP_PKEY_CTX_new)
888 RESOLVEFUNC(EVP_PKEY_param_check)
889 RESOLVEFUNC(EVP_PKEY_CTX_free)
890 RESOLVEFUNC(OPENSSL_sk_new_null)
891 RESOLVEFUNC(OPENSSL_sk_push)
892 RESOLVEFUNC(OPENSSL_sk_free)
893 RESOLVEFUNC(OPENSSL_sk_num)
894 RESOLVEFUNC(OPENSSL_sk_pop_free)
895 RESOLVEFUNC(OPENSSL_sk_value)
896 RESOLVEFUNC(SSL_CTX_set_options)
897 RESOLVEFUNC(SSL_set_info_callback)
898 RESOLVEFUNC(SSL_alert_type_string)
899 RESOLVEFUNC(SSL_alert_desc_string_long)
900 RESOLVEFUNC(SSL_CTX_get_security_level)
901 RESOLVEFUNC(SSL_CTX_set_security_level)
902#ifdef TLS1_3_VERSION
903 RESOLVEFUNC(SSL_CTX_set_ciphersuites)
904 RESOLVEFUNC(SSL_set_psk_use_session_callback)
905 RESOLVEFUNC(SSL_CTX_sess_set_new_cb)
906 RESOLVEFUNC(SSL_SESSION_is_resumable)
907#endif // TLS 1.3 or OpenSSL > 1.1.1
908
909 RESOLVEFUNC(SSL_get_client_random)
910 RESOLVEFUNC(SSL_SESSION_get_master_key)
911 RESOLVEFUNC(SSL_session_reused)
912 RESOLVEFUNC(SSL_get_session)
913 RESOLVEFUNC(SSL_set_options)
914 RESOLVEFUNC(CRYPTO_get_ex_new_index)
915 RESOLVEFUNC(TLS_method)
916 RESOLVEFUNC(TLS_client_method)
917 RESOLVEFUNC(TLS_server_method)
918 RESOLVEFUNC(X509_up_ref)
919 RESOLVEFUNC(X509_STORE_CTX_get0_chain)
920 RESOLVEFUNC(X509_getm_notBefore)
921 RESOLVEFUNC(X509_getm_notAfter)
922 RESOLVEFUNC(ASN1_item_free)
923 RESOLVEFUNC(X509V3_conf_free)
924 RESOLVEFUNC(X509_get_version)
925 RESOLVEFUNC(X509_get_pubkey)
926 RESOLVEFUNC(X509_STORE_set_verify_cb)
927 RESOLVEFUNC(X509_STORE_set_ex_data)
928 RESOLVEFUNC(X509_STORE_get_ex_data)
929 RESOLVEFUNC(CRYPTO_free)
930 RESOLVEFUNC(CRYPTO_memcmp)
931 RESOLVEFUNC(OpenSSL_version_num)
932 RESOLVEFUNC(OpenSSL_version)
933
934 if (!_q_OpenSSL_version || !_q_OpenSSL_version_num) {
935 // Apparently, we were built with OpenSSL 1.1 enabled but are now using
936 // a wrong library.
937 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL");
938 return false;
939 }
940
941#if OPENSSL_VERSION_NUMBER >= 0x30000000
942 if (q_OpenSSL_version_num() < 0x30000000) {
943 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL (built with OpenSSL >= 3.x, runtime version is < 3.x)");
944 return false;
945 }
946#else
947 if (q_OpenSSL_version_num() >= 0x30000000) {
948 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL (built with OpenSSL 1.x, runtime version is >= 3.x)");
949 return false;
950 }
951#endif // OPENSSL_VERSION_NUMBER
952
953 RESOLVEFUNC(SSL_SESSION_get_ticket_lifetime_hint)
954
955#if QT_CONFIG(dtls)
956 RESOLVEFUNC(DTLSv1_listen)
957 RESOLVEFUNC(BIO_ADDR_new)
958 RESOLVEFUNC(BIO_ADDR_free)
959 RESOLVEFUNC(BIO_meth_new)
960 RESOLVEFUNC(BIO_meth_free)
961 RESOLVEFUNC(BIO_meth_set_write)
962 RESOLVEFUNC(BIO_meth_set_read)
963 RESOLVEFUNC(BIO_meth_set_puts)
964 RESOLVEFUNC(BIO_meth_set_ctrl)
965 RESOLVEFUNC(BIO_meth_set_create)
966 RESOLVEFUNC(BIO_meth_set_destroy)
967#endif // dtls
968
969#if QT_CONFIG(ocsp)
970 RESOLVEFUNC(OCSP_SINGLERESP_get0_id)
971 RESOLVEFUNC(d2i_OCSP_RESPONSE)
972 RESOLVEFUNC(OCSP_RESPONSE_free)
973 RESOLVEFUNC(OCSP_response_status)
974 RESOLVEFUNC(OCSP_response_get1_basic)
975 RESOLVEFUNC(OCSP_BASICRESP_free)
976 RESOLVEFUNC(OCSP_basic_verify)
977 RESOLVEFUNC(OCSP_resp_count)
978 RESOLVEFUNC(OCSP_resp_get0)
979 RESOLVEFUNC(OCSP_single_get0_status)
980 RESOLVEFUNC(OCSP_check_validity)
981 RESOLVEFUNC(OCSP_cert_to_id)
982 RESOLVEFUNC(OCSP_id_get0_info)
983 RESOLVEFUNC(OCSP_resp_get0_certs)
984 RESOLVEFUNC(OCSP_basic_sign)
985 RESOLVEFUNC(OCSP_response_create)
986 RESOLVEFUNC(i2d_OCSP_RESPONSE)
987 RESOLVEFUNC(OCSP_basic_add1_status)
988 RESOLVEFUNC(OCSP_BASICRESP_new)
989 RESOLVEFUNC(OCSP_CERTID_free)
990 RESOLVEFUNC(OCSP_cert_to_id)
991 RESOLVEFUNC(OCSP_id_cmp)
992#endif // ocsp
993
994 RESOLVEFUNC(BIO_set_data)
995 RESOLVEFUNC(BIO_get_data)
996 RESOLVEFUNC(BIO_set_init)
997 RESOLVEFUNC(BIO_get_shutdown)
998 RESOLVEFUNC(BIO_set_shutdown)
999 RESOLVEFUNC(ASN1_INTEGER_get)
1000 RESOLVEFUNC(ASN1_INTEGER_cmp)
1001 RESOLVEFUNC(ASN1_STRING_length)
1002 RESOLVEFUNC(ASN1_STRING_to_UTF8)
1003 RESOLVEFUNC(ASN1_TIME_to_tm)
1004 RESOLVEFUNC(BIO_ctrl)
1005 RESOLVEFUNC(BIO_free)
1006 RESOLVEFUNC(BIO_new)
1007 RESOLVEFUNC(BIO_new_mem_buf)
1008 RESOLVEFUNC(BIO_read)
1009 RESOLVEFUNC(BIO_s_mem)
1010 RESOLVEFUNC(BIO_write)
1011 RESOLVEFUNC(BIO_set_flags)
1012 RESOLVEFUNC(BIO_clear_flags)
1013 RESOLVEFUNC(BIO_set_ex_data)
1014 RESOLVEFUNC(BIO_get_ex_data)
1015 RESOLVEFUNC(BN_num_bits)
1016 RESOLVEFUNC(BN_is_word)
1017 RESOLVEFUNC(BN_mod_word)
1018 RESOLVEFUNC(ERR_error_string)
1019 RESOLVEFUNC(ERR_error_string_n)
1020 RESOLVEFUNC(ERR_get_error)
1021 RESOLVEFUNC(EVP_CIPHER_CTX_new)
1022 RESOLVEFUNC(EVP_CIPHER_CTX_free)
1023 RESOLVEFUNC(EVP_CIPHER_CTX_ctrl)
1024 RESOLVEFUNC(EVP_CIPHER_CTX_set_key_length)
1025 RESOLVEFUNC(EVP_CipherInit)
1026 RESOLVEFUNC(EVP_CipherInit_ex)
1027 RESOLVEFUNC(EVP_CipherUpdate)
1028 RESOLVEFUNC(EVP_CipherFinal)
1029 RESOLVEFUNC(EVP_get_digestbyname)
1030#ifndef OPENSSL_NO_DES
1031 RESOLVEFUNC(EVP_des_cbc)
1032 RESOLVEFUNC(EVP_des_ede3_cbc)
1033#endif
1034#ifndef OPENSSL_NO_RC2
1035 RESOLVEFUNC(EVP_rc2_cbc)
1036#endif
1037#ifndef OPENSSL_NO_AES
1038 RESOLVEFUNC(EVP_aes_128_cbc)
1039 RESOLVEFUNC(EVP_aes_192_cbc)
1040 RESOLVEFUNC(EVP_aes_256_cbc)
1041#endif
1042 RESOLVEFUNC(EVP_sha1)
1043 RESOLVEFUNC(EVP_PKEY_free)
1044 RESOLVEFUNC(EVP_PKEY_new)
1045 RESOLVEFUNC(EVP_PKEY_type)
1046 RESOLVEFUNC(OBJ_nid2sn)
1047 RESOLVEFUNC(OBJ_nid2ln)
1048 RESOLVEFUNC(OBJ_sn2nid)
1049 RESOLVEFUNC(OBJ_ln2nid)
1050 RESOLVEFUNC(i2t_ASN1_OBJECT)
1051 RESOLVEFUNC(OBJ_obj2txt)
1052 RESOLVEFUNC(OBJ_obj2nid)
1053 RESOLVEFUNC(PEM_read_bio_PrivateKey)
1054 RESOLVEFUNC(PEM_write_bio_PrivateKey)
1055 RESOLVEFUNC(PEM_write_bio_PrivateKey_traditional)
1056 RESOLVEFUNC(PEM_read_bio_PUBKEY)
1057 RESOLVEFUNC(PEM_write_bio_PUBKEY)
1058 RESOLVEFUNC(RAND_seed)
1059 RESOLVEFUNC(RAND_status)
1060 RESOLVEFUNC(RAND_bytes)
1061 RESOLVEFUNC(SSL_CIPHER_description)
1062 RESOLVEFUNC(SSL_CIPHER_get_bits)
1063 RESOLVEFUNC(SSL_get_rbio)
1064 RESOLVEFUNC(SSL_CTX_check_private_key)
1065 RESOLVEFUNC(SSL_CTX_ctrl)
1066 RESOLVEFUNC(SSL_CTX_free)
1067 RESOLVEFUNC(SSL_CTX_new)
1068 RESOLVEFUNC(SSL_CTX_set_cipher_list)
1069 RESOLVEFUNC(SSL_CTX_callback_ctrl)
1070 RESOLVEFUNC(SSL_CTX_set_default_verify_paths)
1071 RESOLVEFUNC(SSL_CTX_set_verify)
1072 RESOLVEFUNC(SSL_CTX_set_verify_depth)
1073 RESOLVEFUNC(SSL_CTX_use_certificate)
1074 RESOLVEFUNC(SSL_CTX_use_certificate_file)
1075 RESOLVEFUNC(SSL_CTX_use_PrivateKey)
1076 RESOLVEFUNC(SSL_CTX_use_PrivateKey_file)
1077 RESOLVEFUNC(SSL_CTX_get_cert_store);
1078 RESOLVEFUNC(SSL_CONF_CTX_new);
1079 RESOLVEFUNC(SSL_CONF_CTX_free);
1080 RESOLVEFUNC(SSL_CONF_CTX_set_ssl_ctx);
1081 RESOLVEFUNC(SSL_CONF_CTX_set_flags);
1082 RESOLVEFUNC(SSL_CONF_CTX_finish);
1083 RESOLVEFUNC(SSL_CONF_cmd);
1084 RESOLVEFUNC(SSL_accept)
1085 RESOLVEFUNC(SSL_clear)
1086 RESOLVEFUNC(SSL_connect)
1087 RESOLVEFUNC(SSL_free)
1088 RESOLVEFUNC(SSL_get_ciphers)
1089 RESOLVEFUNC(SSL_get_current_cipher)
1090 RESOLVEFUNC(SSL_version)
1091 RESOLVEFUNC(SSL_get_error)
1092 RESOLVEFUNC(SSL_get_peer_cert_chain)
1093
1094#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
1095 RESOLVEFUNC(SSL_get1_peer_certificate)
1096 RESOLVEFUNC(EVP_PKEY_get_bits)
1097 RESOLVEFUNC(EVP_PKEY_get_security_bits)
1098 RESOLVEFUNC(EVP_PKEY_get_base_id)
1099 RESOLVEFUNC(EVP_PKEY_get0_type_name)
1100#else
1101 RESOLVEFUNC(SSL_get_peer_certificate)
1102 RESOLVEFUNC(EVP_PKEY_base_id)
1103#endif // OPENSSL_VERSION_MAJOR >= 3
1104
1105#ifndef OPENSSL_NO_DEPRECATED_3_0
1106 RESOLVEFUNC(DH_new)
1107 RESOLVEFUNC(DH_free)
1108 RESOLVEFUNC(DH_check)
1109 RESOLVEFUNC(DH_get0_pqg)
1110
1111 RESOLVEFUNC(d2i_DHparams)
1112 RESOLVEFUNC(i2d_DHparams)
1113
1114 RESOLVEFUNC(PEM_read_bio_DHparams)
1115
1116 RESOLVEFUNC(EVP_PKEY_assign)
1117 RESOLVEFUNC(EVP_PKEY_cmp)
1118
1119 RESOLVEFUNC(EVP_PKEY_set1_RSA)
1120 RESOLVEFUNC(EVP_PKEY_set1_DSA)
1121 RESOLVEFUNC(EVP_PKEY_set1_DH)
1122
1123 RESOLVEFUNC(EVP_PKEY_get1_DSA)
1124 RESOLVEFUNC(EVP_PKEY_get1_RSA)
1125 RESOLVEFUNC(EVP_PKEY_get1_DH)
1126
1127 RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY)
1128 RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY)
1129 RESOLVEFUNC(PEM_read_bio_DSAPrivateKey)
1130 RESOLVEFUNC(PEM_read_bio_RSAPrivateKey)
1131
1132 RESOLVEFUNC(PEM_write_bio_DSA_PUBKEY)
1133 RESOLVEFUNC(PEM_write_bio_RSA_PUBKEY)
1134 RESOLVEFUNC(PEM_write_bio_DSAPrivateKey)
1135 RESOLVEFUNC(PEM_write_bio_RSAPrivateKey)
1136 RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey)
1137
1138 RESOLVEFUNC(DSA_new)
1139 RESOLVEFUNC(DSA_free)
1140
1141 RESOLVEFUNC(RSA_new)
1142 RESOLVEFUNC(RSA_free)
1143
1144 RESOLVEFUNC(DH_bits)
1145 RESOLVEFUNC(DSA_bits)
1146 RESOLVEFUNC(RSA_bits)
1147
1148#ifndef OPENSSL_NO_EC
1149
1150 RESOLVEFUNC(EVP_PKEY_set1_EC_KEY)
1151 RESOLVEFUNC(EVP_PKEY_get1_EC_KEY)
1152 RESOLVEFUNC(PEM_read_bio_EC_PUBKEY)
1153 RESOLVEFUNC(PEM_read_bio_ECPrivateKey)
1154 RESOLVEFUNC(PEM_write_bio_EC_PUBKEY)
1155 RESOLVEFUNC(PEM_write_bio_ECPrivateKey)
1156 RESOLVEFUNC(EC_KEY_get0_group)
1157 RESOLVEFUNC(EC_GROUP_get_degree)
1158 RESOLVEFUNC(EC_KEY_dup)
1159 RESOLVEFUNC(EC_KEY_new_by_curve_name)
1160 RESOLVEFUNC(EC_KEY_free)
1161
1162#endif // OPENSSL_NO_EC
1163
1164#endif // OPENSSL_NO_DEPRECATED_3_0
1165
1166 RESOLVEFUNC(SSL_get_verify_result)
1167 RESOLVEFUNC(SSL_new)
1168 RESOLVEFUNC(SSL_get_SSL_CTX)
1169 RESOLVEFUNC(SSL_ctrl)
1170 RESOLVEFUNC(SSL_read)
1171 RESOLVEFUNC(SSL_set_accept_state)
1172 RESOLVEFUNC(SSL_set_bio)
1173 RESOLVEFUNC(SSL_set_connect_state)
1174 RESOLVEFUNC(SSL_shutdown)
1175 RESOLVEFUNC(SSL_in_init)
1176 RESOLVEFUNC(SSL_get_shutdown)
1177 RESOLVEFUNC(SSL_set_session)
1178 RESOLVEFUNC(SSL_SESSION_free)
1179 RESOLVEFUNC(SSL_get1_session)
1180 RESOLVEFUNC(SSL_get_session)
1181 RESOLVEFUNC(SSL_set_ex_data)
1182 RESOLVEFUNC(SSL_get_ex_data)
1183 RESOLVEFUNC(SSL_get_ex_data_X509_STORE_CTX_idx)
1184
1185#ifndef OPENSSL_NO_PSK
1186 RESOLVEFUNC(SSL_set_psk_client_callback)
1187 RESOLVEFUNC(SSL_set_psk_server_callback)
1188 RESOLVEFUNC(SSL_CTX_use_psk_identity_hint)
1189#endif // !OPENSSL_NO_PSK
1190
1191 RESOLVEFUNC(SSL_write)
1192 RESOLVEFUNC(X509_NAME_entry_count)
1193 RESOLVEFUNC(X509_NAME_get_entry)
1194 RESOLVEFUNC(X509_NAME_ENTRY_get_data)
1195 RESOLVEFUNC(X509_NAME_ENTRY_get_object)
1196 RESOLVEFUNC(X509_PUBKEY_get)
1197 RESOLVEFUNC(X509_STORE_free)
1198 RESOLVEFUNC(X509_STORE_new)
1199 RESOLVEFUNC(X509_STORE_add_cert)
1200 RESOLVEFUNC(X509_STORE_CTX_free)
1201 RESOLVEFUNC(X509_STORE_CTX_init)
1202 RESOLVEFUNC(X509_STORE_CTX_new)
1203 RESOLVEFUNC(X509_STORE_CTX_set_purpose)
1204 RESOLVEFUNC(X509_STORE_CTX_get_error)
1205 RESOLVEFUNC(X509_STORE_CTX_get_error_depth)
1206 RESOLVEFUNC(X509_STORE_CTX_get_current_cert)
1207 RESOLVEFUNC(X509_STORE_CTX_get0_store)
1208 RESOLVEFUNC(SSL_export_keying_material)
1209 RESOLVEFUNC(X509_cmp)
1210 RESOLVEFUNC(X509_STORE_CTX_get_ex_data)
1211 RESOLVEFUNC(X509_dup)
1212 RESOLVEFUNC(X509_print)
1213 RESOLVEFUNC(X509_digest)
1214 RESOLVEFUNC(X509_EXTENSION_get_object)
1215 RESOLVEFUNC(X509_free)
1216 RESOLVEFUNC(X509_gmtime_adj)
1217 RESOLVEFUNC(ASN1_TIME_free)
1218 RESOLVEFUNC(X509_get_ext)
1219 RESOLVEFUNC(X509_get_ext_count)
1220 RESOLVEFUNC(X509_get_ext_d2i)
1221 RESOLVEFUNC(X509V3_EXT_get)
1222 RESOLVEFUNC(X509V3_EXT_d2i)
1223 RESOLVEFUNC(X509_EXTENSION_get_critical)
1224 RESOLVEFUNC(X509_EXTENSION_get_data)
1225 RESOLVEFUNC(BASIC_CONSTRAINTS_free)
1226 RESOLVEFUNC(AUTHORITY_KEYID_free)
1227 RESOLVEFUNC(GENERAL_NAME_free)
1228 RESOLVEFUNC(ASN1_STRING_print)
1229 RESOLVEFUNC(X509_check_issued)
1230 RESOLVEFUNC(X509_get_issuer_name)
1231 RESOLVEFUNC(X509_get_subject_name)
1232 RESOLVEFUNC(X509_get_serialNumber)
1233 RESOLVEFUNC(X509_verify_cert)
1234 RESOLVEFUNC(d2i_X509)
1235 RESOLVEFUNC(i2d_X509)
1236#if OPENSSL_VERSION_MAJOR < 3
1237 RESOLVEFUNC(SSL_CTX_load_verify_locations)
1238#else
1239 RESOLVEFUNC(SSL_CTX_load_verify_dir)
1240#endif // OPENSSL_VERSION_MAJOR
1241 RESOLVEFUNC(i2d_SSL_SESSION)
1242 RESOLVEFUNC(d2i_SSL_SESSION)
1243
1244#ifndef OPENSSL_NO_NEXTPROTONEG
1245 RESOLVEFUNC(SSL_select_next_proto)
1246 RESOLVEFUNC(SSL_CTX_set_next_proto_select_cb)
1247 RESOLVEFUNC(SSL_get0_next_proto_negotiated)
1248 RESOLVEFUNC(SSL_set_alpn_protos)
1249 RESOLVEFUNC(SSL_CTX_set_alpn_select_cb)
1250 RESOLVEFUNC(SSL_get0_alpn_selected)
1251#endif // !OPENSSL_NO_NEXTPROTONEG
1252
1253#if QT_CONFIG(dtls)
1254 RESOLVEFUNC(SSL_CTX_set_cookie_generate_cb)
1255 RESOLVEFUNC(SSL_CTX_set_cookie_verify_cb)
1256 RESOLVEFUNC(DTLS_server_method)
1257 RESOLVEFUNC(DTLS_client_method)
1258#endif // dtls
1259
1260 RESOLVEFUNC(CRYPTO_malloc)
1261 RESOLVEFUNC(BN_bin2bn)
1262
1263#ifndef OPENSSL_NO_EC
1264 RESOLVEFUNC(EC_get_builtin_curves)
1265#endif // OPENSSL_NO_EC
1266
1267 RESOLVEFUNC(PKCS12_parse)
1268 RESOLVEFUNC(d2i_PKCS12_bio)
1269 RESOLVEFUNC(PKCS12_free)
1270 return true;
1271 }();
1272
1273 return symbolsResolved;
1274}
1275#endif // QT_CONFIG(library)
1276
1277#else // !defined QT_LINKED_OPENSSL
1278
1279bool q_resolveOpenSslSymbols()
1280{
1281#ifdef QT_NO_OPENSSL
1282 return false;
1283#endif
1284 return true;
1285}
1286#endif // !defined QT_LINKED_OPENSSL
1287
1288QT_END_NAMESPACE
#define DEFINEFUNC(ret, func, args, argcall, funcret)
#define QT_OPENSSL4_CONST
Definition qopenssl_p.h:75
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)