QtBase  v6.3.1
qtlsbackend_openssl_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2021 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtNetwork module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QTLSBACKEND_OPENSSL_P_H
41 #define QTLSBACKEND_OPENSSL_P_H
42 
43 //
44 // W A R N I N G
45 // -------------
46 //
47 // This file is not part of the Qt API. It exists purely as an
48 // implementation detail. This header file may change from version to
49 // version without notice, or even be removed.
50 //
51 // We mean it.
52 //
53 
54 #include <QtNetwork/private/qtnetworkglobal_p.h>
55 
56 #include <QtNetwork/qssldiffiehellmanparameters.h>
57 #include <QtNetwork/qsslcertificate.h>
58 
59 #include <QtNetwork/private/qtlsbackend_p.h>
60 
61 #include <QtCore/qglobal.h>
62 #include <QtCore/qlist.h>
63 
64 #include <openssl/ssl.h>
65 
67 
69 {
70  Q_OBJECT
73 
74 public:
75 
77  static void logAndClearErrorQueue();
78  static void clearErrorQueue();
79 
80  static bool ensureLibraryLoaded();
81  // Index used in SSL_get_ex_data to get the matching TlsCryptographerOpenSSL:
82  static bool s_libraryLoaded;
85 
87  static QSslCipher qt_OpenSSL_cipher_to_QSslCipher(const SSL_CIPHER *cipher);
88 private:
89 
90  QString backendName() const override;
91  bool isValid() const override;
92  long tlsLibraryVersionNumber() const override;
93  QString tlsLibraryVersionString() const override;
94  long tlsLibraryBuildVersionNumber() const override;
95  QString tlsLibraryBuildVersionString() const override;
96 
97  void ensureInitialized() const override;
98  void ensureCiphersAndCertsLoaded() const;
99  static void resetDefaultCiphers();
100 
101  QList<QSsl::SslProtocol> supportedProtocols() const override;
102  QList<QSsl::SupportedFeature> supportedFeatures() const override;
103  QList<QSsl::ImplementedClass> implementedClasses() const override;
104 
105  // QSslKey:
106  QTlsPrivate::TlsKey *createKey() const override;
107 
108  // QSslCertificate:
109  QTlsPrivate::X509Certificate *createCertificate() const override;
110  QList<QSslCertificate> systemCaCertificates() const override;
111 
112  QTlsPrivate::TlsCryptograph *createTlsCryptograph() const override;
113  QTlsPrivate::DtlsCookieVerifier *createDtlsCookieVerifier() const override;
114  QTlsPrivate::DtlsCryptograph *createDtlsCryptograph(QDtls *q, int mode) const override;
115 
116  QTlsPrivate::X509ChainVerifyPtr X509Verifier() const override;
117  QTlsPrivate::X509PemReaderPtr X509PemReader() const override;
118  QTlsPrivate::X509DerReaderPtr X509DerReader() const override;
119  QTlsPrivate::X509Pkcs12ReaderPtr X509Pkcs12Reader() const override;
120 
121  // Elliptic curves:
122  QList<int> ellipticCurvesIds() const override;
123  int curveIdFromShortName(const QString &name) const override;
124  int curveIdFromLongName(const QString &name) const override;
125  QString shortNameForId(int cid) const override;
126  QString longNameForId(int cid) const override;
127  bool isTlsNamedCurve(int cid) const override;
128 
129  // DH parameters:
131  int dhParametersFromDer(const QByteArray &derData, QByteArray *data) const override;
132  int dhParametersFromPem(const QByteArray &pemData, QByteArray *data) const override;
133 
134  void forceAutotestSecurityLevel() override;
135 };
136 
137 Q_DECLARE_LOGGING_CATEGORY(lcTlsBackend)
138 
140 
141 #endif // QTLSBACKEND_OPENSSL_P_H
142 
143 
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:85
This class provides encryption for UDP sockets.
Definition: qdtls.h:119
Definition: qlist.h:108
The QSslCipher class represents an SSL cryptographic cipher.
Definition: qsslcipher.h:58
The QSslDiffieHellmanParameters class provides an interface for Diffie-Hellman parameters for servers...
The QString class provides a Unicode character string.
Definition: qstring.h:388
static QSslCipher qt_OpenSSL_cipher_to_QSslCipher(const SSL_CIPHER *cipher)
static void logAndClearErrorQueue()
static bool ensureLibraryLoaded()
static QString msgErrorsDuringHandshake()
static bool s_loadedCiphersAndCerts
static QString getErrorsFromOpenSsl()
bool(*)(QIODevice *device, QSslKey *key, QSslCertificate *cert, QList< QSslCertificate > *caCertificates, const QByteArray &passPhrase) X509Pkcs12ReaderPtr
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLenum mode
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint name
GLdouble GLdouble GLdouble GLdouble q
Definition: qopenglext.h:259
#define QTlsBackend_iid
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define Q_PLUGIN_METADATA(x)
Definition: qtmetamacros.h:90
#define Q_INTERFACES(x)
Definition: qtmetamacros.h:91