1// Copyright (C) 2019 The Qt Company Ltd.
2// Copyright (C) 2014 BlackBerry Limited. All rights reserved.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5/****************************************************************************
6**
7** In addition, as a special exception, the copyright holders listed above give
8** permission to link the code of its release of Qt with the OpenSSL project's
9** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
10** same license as the original version), and distribute the linked executables.
11**
12** You must comply with the GNU General Public License version 2 in all
13** respects for all of the code used other than the "OpenSSL" code. If you
14** modify this file, you may extend this exception to your version of the file,
15** but you are not obligated to do so. If you do not wish to do so, delete
16** this exception statement from your version of this file.
17**
18****************************************************************************/
19
20#ifndef OPENSSL_SYMBOLS_P_H
21#define OPENSSL_SYMBOLS_P_H
22
23#include <openssl/asn1.h>
24#include <openssl/bio.h>
25#include <openssl/bn.h>
26#include <openssl/err.h>
27#include <openssl/evp.h>
28#include <openssl/pem.h>
29#include <openssl/pkcs12.h>
30#include <openssl/pkcs7.h>
31#include <openssl/rand.h>
32#include <openssl/ssl.h>
33#include <openssl/stack.h>
34#include <openssl/x509.h>
35#include <openssl/x509v3.h>
36#include <openssl/x509_vfy.h>
37#include <openssl/dsa.h>
38#include <openssl/rsa.h>
39#include <openssl/crypto.h>
40#include <openssl/tls1.h>
41
42//
43// W A R N I N G
44// -------------
45//
46// This file is not part of the Qt API. It exists purely as an
47// implementation detail. This header file may change from version to
48// version without notice, or even be removed.
49//
50// We mean it.
51//
52
53#include <QtNetwork/private/qtnetworkglobal_p.h>
54#include <QtCore/QLoggingCategory>
55
56#ifdef Q_OS_WIN
57#include <qt_windows.h>
58#if defined(X509_NAME)
59#undef X509_NAME
60#endif
61#endif // Q_OS_WIN
62
63#include <QtCore/qglobal.h>
64
65QT_BEGIN_NAMESPACE
66
67Q_DECLARE_LOGGING_CATEGORY(lcSsl)
68
69#define DUMMYARG
70
71#if !defined QT_LINKED_OPENSSL
72// **************** Shared declarations ******************
73// ret func(arg)
74
75# define DEFINEFUNC(ret, func, arg, a, err, funcret) \
76 typedef ret (*_q_PTR_##func)(arg); \
77 static _q_PTR_##func _q_##func = 0; \
78 ret q_##func(arg) { \
79 if (Q_UNLIKELY(!_q_##func)) { \
80 qsslSocketUnresolvedSymbolWarning(#func); \
81 err; \
82 } \
83 funcret _q_##func(a); \
84 }
85
86// ret func(arg1, arg2)
87# define DEFINEFUNC2(ret, func, arg1, a, arg2, b, err, funcret) \
88 typedef ret (*_q_PTR_##func)(arg1, arg2); \
89 static _q_PTR_##func _q_##func = 0; \
90 ret q_##func(arg1, arg2) { \
91 if (Q_UNLIKELY(!_q_##func)) { \
92 qsslSocketUnresolvedSymbolWarning(#func);\
93 err; \
94 } \
95 funcret _q_##func(a, b); \
96 }
97
98// ret func(arg1, arg2, arg3)
99# define DEFINEFUNC3(ret, func, arg1, a, arg2, b, arg3, c, err, funcret) \
100 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3); \
101 static _q_PTR_##func _q_##func = 0; \
102 ret q_##func(arg1, arg2, arg3) { \
103 if (Q_UNLIKELY(!_q_##func)) { \
104 qsslSocketUnresolvedSymbolWarning(#func); \
105 err; \
106 } \
107 funcret _q_##func(a, b, c); \
108 }
109
110// ret func(arg1, arg2, arg3, arg4)
111# define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret) \
112 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4); \
113 static _q_PTR_##func _q_##func = 0; \
114 ret q_##func(arg1, arg2, arg3, arg4) { \
115 if (Q_UNLIKELY(!_q_##func)) { \
116 qsslSocketUnresolvedSymbolWarning(#func); \
117 err; \
118 } \
119 funcret _q_##func(a, b, c, d); \
120 }
121
122// ret func(arg1, arg2, arg3, arg4, arg5)
123# define DEFINEFUNC5(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, err, funcret) \
124 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5); \
125 static _q_PTR_##func _q_##func = 0; \
126 ret q_##func(arg1, arg2, arg3, arg4, arg5) { \
127 if (Q_UNLIKELY(!_q_##func)) { \
128 qsslSocketUnresolvedSymbolWarning(#func); \
129 err; \
130 } \
131 funcret _q_##func(a, b, c, d, e); \
132 }
133
134// ret func(arg1, arg2, arg3, arg4, arg6)
135# define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret) \
136 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6); \
137 static _q_PTR_##func _q_##func = 0; \
138 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { \
139 if (Q_UNLIKELY(!_q_##func)) { \
140 qsslSocketUnresolvedSymbolWarning(#func); \
141 err; \
142 } \
143 funcret _q_##func(a, b, c, d, e, f); \
144 }
145
146// ret func(arg1, arg2, arg3, arg4, arg6, arg7)
147# define DEFINEFUNC7(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, err, funcret) \
148 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
149 static _q_PTR_##func _q_##func = 0; \
150 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \
151 if (Q_UNLIKELY(!_q_##func)) { \
152 qsslSocketUnresolvedSymbolWarning(#func); \
153 err; \
154 } \
155 funcret _q_##func(a, b, c, d, e, f, g); \
156 }
157
158// ret func(arg1, arg2, arg3, arg4, arg6, arg7, arg8, arg9)
159# define DEFINEFUNC9(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, arg8, h, arg9, i, err, funcret) \
160 typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \
161 static _q_PTR_##func _q_##func = 0; \
162 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { \
163 if (Q_UNLIKELY(!_q_##func)) { \
164 qsslSocketUnresolvedSymbolWarning(#func); \
165 err; \
166 } \
167 funcret _q_##func(a, b, c, d, e, f, g, h, i); \
168 }
169// **************** Shared declarations ******************
170
171#else // !defined QT_LINKED_OPENSSL
172
173// **************** Static declarations ******************
174
175// ret func(arg)
176# define DEFINEFUNC(ret, func, arg, a, err, funcret) \
177 ret q_##func(arg) { funcret func(a); }
178
179// ret func(arg1, arg2)
180# define DEFINEFUNC2(ret, func, arg1, a, arg2, b, err, funcret) \
181 ret q_##func(arg1, arg2) { funcret func(a, b); }
182
183// ret func(arg1, arg2, arg3)
184# define DEFINEFUNC3(ret, func, arg1, a, arg2, b, arg3, c, err, funcret) \
185 ret q_##func(arg1, arg2, arg3) { funcret func(a, b, c); }
186
187// ret func(arg1, arg2, arg3, arg4)
188# define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret) \
189 ret q_##func(arg1, arg2, arg3, arg4) { funcret func(a, b, c, d); }
190
191// ret func(arg1, arg2, arg3, arg4, arg5)
192# define DEFINEFUNC5(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, err, funcret) \
193 ret q_##func(arg1, arg2, arg3, arg4, arg5) { funcret func(a, b, c, d, e); }
194
195// ret func(arg1, arg2, arg3, arg4, arg6)
196# define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret) \
197 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { funcret func(a, b, c, d, e, f); }
198
199// ret func(arg1, arg2, arg3, arg4, arg6, arg7)
200# define DEFINEFUNC7(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, err, funcret) \
201 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { funcret func(a, b, c, d, e, f, g); }
202
203// ret func(arg1, arg2, arg3, arg4, arg6, arg7, arg8, arg9)
204# define DEFINEFUNC9(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, arg8, h, arg9, i, err, funcret) \
205 ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { funcret func(a, b, c, d, e, f, g, h, i); }
206
207// **************** Static declarations ******************
208
209#endif // !defined QT_LINKED_OPENSSL
210
211#if QT_CONFIG(opensslv11) | QT_CONFIG(opensslv30)
212#include "qsslsocket_openssl11_symbols_p.h"
213#else
214#include "qsslsocket_opensslpre11_symbols_p.h"
215#endif // QT_CONFIG
216
217bool q_resolveOpenSslSymbols();
218long q_ASN1_INTEGER_get(ASN1_INTEGER *a);
219int q_ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
220int q_ASN1_STRING_length(ASN1_STRING *a);
221int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b);
222long q_BIO_ctrl(BIO *a, int b, long c, void *d);
223Q_AUTOTEST_EXPORT int q_BIO_free(BIO *a);
224void q_BIO_free_all(BIO *a);
225BIO *q_BIO_new_mem_buf(void *a, int b);
226int q_BIO_read(BIO *a, void *b, int c);
227Q_AUTOTEST_EXPORT int q_BIO_write(BIO *a, const void *b, int c);
228int q_BN_num_bits(const BIGNUM *a);
229
230#if QT_CONFIG(opensslv11) | QT_CONFIG(opensslv30)
231int q_BN_is_word(BIGNUM *a, BN_ULONG w);
232#else // opensslv11
233// BN_is_word is implemented purely as a
234// macro in OpenSSL < 1.1. It doesn't
235// call any functions.
236//
237// The implementation of BN_is_word is
238// 100% the same between 1.0.0, 1.0.1
239// and 1.0.2.
240//
241// Users are required to include <openssl/bn.h>.
242#define q_BN_is_word BN_is_word
243#endif // !opensslv11
244
245BN_ULONG q_BN_mod_word(const BIGNUM *a, BN_ULONG w);
246int q_BN_set_word(const BIGNUM *a, BN_ULONG w);
247BIGNUM *q_BN_new();
248void q_BN_clear(BIGNUM *a);
249void q_BN_free(BIGNUM *a);
250void q_BN_clear_free(BIGNUM *a);
251
252#ifndef OPENSSL_NO_EC
253const EC_GROUP* q_EC_KEY_get0_group(const EC_KEY* k);
254int q_EC_GROUP_get_degree(const EC_GROUP* g);
255#endif
256DSA *q_DSA_new();
257void q_DSA_free(DSA *a);
258X509 *q_d2i_X509(X509 **a, const unsigned char **b, long c);
259char *q_ERR_error_string(unsigned long a, char *b);
260void q_ERR_error_string_n(unsigned long e, char *buf, size_t len);
261unsigned long q_ERR_get_error();
262EVP_CIPHER_CTX *q_EVP_CIPHER_CTX_new();
263void q_EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);
264int q_EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
265int q_EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
266int q_EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, const unsigned char *key, const unsigned char *iv, int enc);
267int q_EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const unsigned char *key, const unsigned char *iv, int enc);
268int q_EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl);
269int q_EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
270const EVP_MD *q_EVP_get_digestbyname(const char *name);
271X509_REQ *q_X509_REQ_new();
272void q_X509_REQ_free(X509_REQ *req);
273int q_PEM_write_bio_X509_REQ(BIO *bp, X509_REQ *x);
274int q_PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x);
275int q_X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
276void q_X509_EXTENSION_free(X509_EXTENSION *ext);
277int q_X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
278ASN1_INTEGER *q_ASN1_INTEGER_dup(const ASN1_INTEGER *x);
279
280#if QT_CONFIG(opensslv11) | QT_CONFIG(opensslv30)
281X509_NAME *q_X509_REQ_get_subject_name(X509_REQ *req);
282#define q_ERR_load_crypto_strings() \
283 q_OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
284#else // opensslv11
285void q_ERR_load_crypto_strings();
286#define q_X509_REQ_get_subject_name X509_REQ_get_subject_name
287#define q_X509_get_notBefore X509_get_notBefore
288#define q_X509_get_notAfter X509_get_notAfter
289#endif // !opensslv11
290
291
292int q_X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, const unsigned char *bytes, int len, int loc, int set);
293int q_X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, const unsigned char *bytes, int len, int loc, int set);
294ASN1_OBJECT *q_OBJ_txt2obj(const char *s, int no_name);
295int q_X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
296int q_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
297int q_X509_REQ_set_version(X509_REQ *x, long version);
298X509_EXTENSION *q_X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, int ext_nid, char *value);
299
300#ifndef OPENSSL_NO_DES
301const EVP_CIPHER *q_EVP_des_cbc();
302const EVP_CIPHER *q_EVP_des_ede3_cbc();
303#endif
304const EVP_CIPHER *q_EVP_aes_256_gcm();
305const EVP_CIPHER *q_EVP_aes_128_cbc();
306Q_AUTOTEST_EXPORT const EVP_MD *q_EVP_sha1();
307const EVP_MD *q_EVP_sha256();
308int q_EVP_PKEY_assign(EVP_PKEY *a, int b, char *c);
309Q_AUTOTEST_EXPORT int q_EVP_PKEY_set1_RSA(EVP_PKEY *a, RSA *b);
310int q_EVP_PKEY_set1_DSA(EVP_PKEY *a, DSA *b);
311int q_EVP_PKEY_set1_DH(EVP_PKEY *a, DH *b);
312#ifndef OPENSSL_NO_EC
313int q_EVP_PKEY_set1_EC_KEY(EVP_PKEY *a, EC_KEY *b);
314#endif
315Q_AUTOTEST_EXPORT void q_EVP_PKEY_free(EVP_PKEY *a);
316RSA *q_EVP_PKEY_get1_RSA(EVP_PKEY *a);
317DSA *q_EVP_PKEY_get1_DSA(EVP_PKEY *a);
318DH *q_EVP_PKEY_get1_DH(EVP_PKEY *a);
319#ifndef OPENSSL_NO_EC
320EC_KEY *q_EVP_PKEY_get1_EC_KEY(EVP_PKEY *a);
321#endif
322int q_EVP_PKEY_type(int a);
323Q_AUTOTEST_EXPORT EVP_PKEY *q_EVP_PKEY_new();
324int q_i2d_X509(X509 *a, unsigned char **b);
325const char *q_OBJ_nid2sn(int a);
326const char *q_OBJ_nid2ln(int a);
327int q_OBJ_sn2nid(const char *s);
328int q_OBJ_ln2nid(const char *s);
329int q_i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *obj);
330int q_OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *obj, int no_name);
331int q_OBJ_obj2nid(const ASN1_OBJECT *a);
332#define q_EVP_get_digestbynid(a) q_EVP_get_digestbyname(q_OBJ_nid2sn(a))
333#ifdef SSLEAY_MACROS
334// ### verify
335void *q_PEM_ASN1_read_bio(d2i_of_void *a, const char *b, BIO *c, void **d, pem_password_cb *e,
336 void *f);
337// ### ditto for write
338#else
339Q_AUTOTEST_EXPORT EVP_PKEY *q_PEM_read_bio_PrivateKey(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d);
340DSA *q_PEM_read_bio_DSAPrivateKey(BIO *a, DSA **b, pem_password_cb *c, void *d);
341RSA *q_PEM_read_bio_RSAPrivateKey(BIO *a, RSA **b, pem_password_cb *c, void *d);
342#ifndef OPENSSL_NO_EC
343EC_KEY *q_PEM_read_bio_ECPrivateKey(BIO *a, EC_KEY **b, pem_password_cb *c, void *d);
344#endif
345DH *q_PEM_read_bio_DHparams(BIO *a, DH **b, pem_password_cb *c, void *d);
346int q_PEM_write_bio_DSAPrivateKey(BIO *a, DSA *b, const EVP_CIPHER *c, unsigned char *d,
347 int e, pem_password_cb *f, void *g);
348int q_PEM_write_bio_RSAPrivateKey(BIO *a, RSA *b, const EVP_CIPHER *c, unsigned char *d,
349 int e, pem_password_cb *f, void *g);
350int q_PEM_write_bio_PrivateKey(BIO *a, EVP_PKEY *b, const EVP_CIPHER *c, unsigned char *d,
351 int e, pem_password_cb *f, void *g);
352int q_PEM_write_bio_PKCS8PrivateKey(BIO *a, EVP_PKEY *b, const EVP_CIPHER *c, char *d,
353 int e, pem_password_cb *f, void *g);
354#ifndef OPENSSL_NO_EC
355int q_PEM_write_bio_ECPrivateKey(BIO *a, EC_KEY *b, const EVP_CIPHER *c, unsigned char *d,
356 int e, pem_password_cb *f, void *g);
357#endif
358#endif // SSLEAY_MACROS
359Q_AUTOTEST_EXPORT EVP_PKEY *q_PEM_read_bio_PUBKEY(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d);
360DSA *q_PEM_read_bio_DSA_PUBKEY(BIO *a, DSA **b, pem_password_cb *c, void *d);
361RSA *q_PEM_read_bio_RSA_PUBKEY(BIO *a, RSA **b, pem_password_cb *c, void *d);
362#ifndef OPENSSL_NO_EC
363EC_KEY *q_PEM_read_bio_EC_PUBKEY(BIO *a, EC_KEY **b, pem_password_cb *c, void *d);
364#endif
365int q_PEM_write_bio_DSA_PUBKEY(BIO *a, DSA *b);
366int q_PEM_write_bio_RSA_PUBKEY(BIO *a, RSA *b);
367int q_PEM_write_bio_PUBKEY(BIO *a, EVP_PKEY *b);
368#ifndef OPENSSL_NO_EC
369int q_PEM_write_bio_EC_PUBKEY(BIO *a, EC_KEY *b);
370#endif
371void q_RAND_seed(const void *a, int b);
372int q_RAND_status();
373int q_RAND_bytes(unsigned char *b, int n);
374RSA *q_RSA_new();
375void q_RSA_free(RSA *a);
376int q_RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
377#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
378typedef 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);
379void q_SSL_set_psk_client_callback(SSL *ssl, q_psk_client_callback_t callback);
380typedef unsigned int (*q_psk_server_callback_t)(SSL *ssl, const char *identity, unsigned char *psk, unsigned int max_psk_len);
381#endif // OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
382int q_SSL_write(SSL *a, const void *b, int c);
383int q_X509_cmp(X509 *a, X509 *b);
384#ifdef SSLEAY_MACROS
385void *q_ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x);
386#define q_X509_dup(x509) (X509 *)q_ASN1_dup((i2d_of_void *)q_i2d_X509, \
387 (d2i_of_void *)q_d2i_X509,(char *)x509)
388#else
389X509 *q_X509_dup(X509 *a);
390#endif
391void q_X509_print(BIO *a, X509*b);
392int q_X509_digest(const X509 *x509, const EVP_MD *type, unsigned char *md, unsigned int *len);
393ASN1_OBJECT *q_X509_EXTENSION_get_object(X509_EXTENSION *a);
394Q_AUTOTEST_EXPORT void q_X509_free(X509 *a);
395Q_AUTOTEST_EXPORT ASN1_TIME *q_X509_gmtime_adj(ASN1_TIME *s, long adj);
396Q_AUTOTEST_EXPORT void q_ASN1_TIME_free(ASN1_TIME *t);
397X509_EXTENSION *q_X509_get_ext(X509 *a, int b);
398int q_X509_get_ext_count(X509 *a);
399void *q_X509_get_ext_d2i(X509 *a, int b, int *c, int *d);
400const X509V3_EXT_METHOD *q_X509V3_EXT_get(X509_EXTENSION *a);
401void *q_X509V3_EXT_d2i(X509_EXTENSION *a);
402int q_X509_EXTENSION_get_critical(X509_EXTENSION *a);
403ASN1_OCTET_STRING *q_X509_EXTENSION_get_data(X509_EXTENSION *a);
404void q_BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a);
405void q_AUTHORITY_KEYID_free(AUTHORITY_KEYID *a);
406int q_ASN1_STRING_print(BIO *a, const ASN1_STRING *b);
407int q_X509_check_issued(X509 *a, X509 *b);
408X509_NAME *q_X509_get_issuer_name(X509 *a);
409X509_NAME *q_X509_get_subject_name(X509 *a);
410ASN1_INTEGER *q_X509_get_serialNumber(X509 *a);
411int q_X509_verify_cert(X509_STORE_CTX *ctx);
412int q_X509_NAME_entry_count(X509_NAME *a);
413X509_NAME_ENTRY *q_X509_NAME_get_entry(X509_NAME *a,int b);
414ASN1_STRING *q_X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *a);
415ASN1_OBJECT *q_X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *a);
416EVP_PKEY *q_X509_PUBKEY_get(X509_PUBKEY *a);
417void q_X509_STORE_free(X509_STORE *store);
418X509_STORE *q_X509_STORE_new();
419int q_X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
420void q_X509_STORE_CTX_free(X509_STORE_CTX *storeCtx);
421int q_X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
422 X509 *x509, STACK_OF(X509) *chain);
423X509_STORE_CTX *q_X509_STORE_CTX_new();
424int q_X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
425int q_X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
426int q_X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
427X509 *q_X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
428X509 *q_X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);
429int q_PEM_write_bio_X509(BIO *bp, X509 *x);
430X509 *q_X509_new();
431int q_ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
432int q_X509_set_pubkey(X509 *x, EVP_PKEY *key);
433int q_X509_set_issuer_name(X509 *x, X509_NAME *name);
434int q_X509_sign(X509 *x, EVP_PKEY *key, const EVP_MD *md);
435int q_X509_add_ext(X509 *x, X509_EXTENSION *ex, int location);
436int q_X509_set_version(X509 *x, long version);
437int q_X509_set_subject_name(X509 *x, X509_NAME *name);
438ASN1_OCTET_STRING *q_ASN1_OCTET_STRING_new();
439int q_X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len);
440int q_ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len);
441int q_X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, unsigned long flags);
442void q_ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *a);
443int q_X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, unsigned char *md, unsigned int *len);
444ASN1_INTEGER *q_ASN1_INTEGER_new();
445GENERAL_NAMES *q_GENERAL_NAMES_new();
446GENERAL_NAME *q_GENERAL_NAME_new();
447X509_NAME *q_X509_NAME_dup(X509_NAME *xn);
448int q_X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
449AUTHORITY_KEYID *q_AUTHORITY_KEYID_new();
450void q_ASN1_INTEGER_free(ASN1_INTEGER *a);
451int q_i2d_X509_REQ_bio(BIO *bp, X509_REQ *req);
452int q_i2d_X509_bio(BIO *bp, X509 *x509);
453
454// Diffie-Hellman support
455DH *q_DH_new();
456void q_DH_free(DH *dh);
457DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
458int q_i2d_DHparams(DH *a, unsigned char **p);
459int q_DH_check(DH *dh, int *codes);
460
461BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
462
463#ifndef OPENSSL_NO_EC
464// EC Diffie-Hellman support
465EC_KEY *q_EC_KEY_dup(const EC_KEY *src);
466EC_KEY *q_EC_KEY_new_by_curve_name(int nid);
467void q_EC_KEY_free(EC_KEY *ecdh);
468
469// EC curves management
470size_t q_EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
471#if OPENSSL_VERSION_NUMBER >= 0x10002000L
472int q_EC_curve_nist2nid(const char *name);
473#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
474#endif // OPENSSL_NO_EC
475#if OPENSSL_VERSION_NUMBER >= 0x10002000L
476#define q_SSL_get_server_tmp_key(ssl, key) q_SSL_ctrl((ssl), SSL_CTRL_GET_SERVER_TMP_KEY, 0, (char *)key)
477#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
478
479// PKCS#12 support
480int q_PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca);
481PKCS12 *q_d2i_PKCS12_bio(BIO *bio, PKCS12 **pkcs12);
482void q_PKCS12_free(PKCS12 *pkcs12);
483
484#define q_BIO_get_mem_data(b, pp) (int)q_BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
485#define q_BIO_pending(b) (int)q_BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
486#define q_SSL_CTX_set_mode(ctx,op) q_SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
487#define q_sk_GENERAL_NAME_num(st) q_SKM_sk_num(GENERAL_NAME, (st))
488#define q_sk_GENERAL_NAME_value(st, i) q_SKM_sk_value(GENERAL_NAME, (st), (i))
489#if QT_CONFIG(opensslv11) | QT_CONFIG(opensslv30)
490#define q_sk_GENERAL_NAME_push(st, val) q_OPENSSL_sk_push((st), (val))
491#else
492#define q_sk_GENERAL_NAME_push(st, val) q_SKM_sk_push(GENERAL_NAME, (st), (val))
493#endif
494
495void q_GENERAL_NAME_free(GENERAL_NAME *a);
496
497#define q_sk_X509_num(st) q_SKM_sk_num(X509, (st))
498#define q_sk_X509_value(st, i) q_SKM_sk_value(X509, (st), (i))
499#define q_sk_SSL_CIPHER_num(st) q_SKM_sk_num(SSL_CIPHER, (st))
500#define q_sk_SSL_CIPHER_value(st, i) q_SKM_sk_value(SSL_CIPHER, (st), (i))
501#define q_SSL_CTX_add_extra_chain_cert(ctx,x509) \
502 q_SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)
503#define q_EVP_PKEY_assign_RSA(pkey,rsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
504 (char *)(rsa))
505#define q_EVP_PKEY_assign_DSA(pkey,dsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
506 (char *)(dsa))
507#define q_OpenSSL_add_all_algorithms() q_OPENSSL_add_all_algorithms_conf()
508int q_i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);
509
510void q_BIO_set_flags(BIO *b, int flags);
511void q_BIO_clear_flags(BIO *b, int flags);
512void *q_BIO_get_ex_data(BIO *b, int idx);
513int q_BIO_set_ex_data(BIO *b, int idx, void *data);
514
515#define q_BIO_set_retry_read(b) q_BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
516#define q_BIO_set_retry_write(b) q_BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
517#define q_BIO_clear_retry_flags(b) q_BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
518#define q_BIO_set_app_data(s,arg) q_BIO_set_ex_data(s,0,arg)
519#define q_BIO_get_app_data(s) q_BIO_get_ex_data(s,0)
520
521// Helper function
522class QDateTime;
523QDateTime q_getTimeFromASN1(const ASN1_TIME *aTime);
524
525void *q_CRYPTO_malloc(size_t num, const char *file, int line);
526#define q_OPENSSL_malloc(num) q_CRYPTO_malloc(num, "", 0)
527
528QT_END_NAMESPACE
529
530#endif
531

source code of qtopcua/src/opcua/x509/openssl_symbols_p.h