1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTLSBACKEND_OPENSSL_P_H
5#define QTLSBACKEND_OPENSSL_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19
20#include <QtNetwork/qssldiffiehellmanparameters.h>
21#include <QtNetwork/qsslcertificate.h>
22
23#include <QtNetwork/private/qtlsbackend_p.h>
24
25#include <QtCore/qglobal.h>
26#include <QtCore/qlist.h>
27
28#include <openssl/ssl.h>
29
30QT_BEGIN_NAMESPACE
31
32class QTlsBackendOpenSSL final : public QTlsBackend
33{
34 Q_OBJECT
35 Q_PLUGIN_METADATA(IID QTlsBackend_iid)
36 Q_INTERFACES(QTlsBackend)
37
38public:
39
40 static QString getErrorsFromOpenSsl();
41 static void logAndClearErrorQueue();
42 static void clearErrorQueue();
43
44 // Index used in SSL_get_ex_data to get the matching TlsCryptographerOpenSSL:
45 static int s_indexForSSLExtraData;
46
47 static QString msgErrorsDuringHandshake();
48 static QSslCipher qt_OpenSSL_cipher_to_QSslCipher(const SSL_CIPHER *cipher);
49private:
50 static bool ensureLibraryLoaded();
51 QString backendName() const override;
52 bool isValid() const override;
53 long tlsLibraryVersionNumber() const override;
54 QString tlsLibraryVersionString() const override;
55 long tlsLibraryBuildVersionNumber() const override;
56 QString tlsLibraryBuildVersionString() const override;
57
58 void ensureInitialized() const override;
59 void ensureCiphersAndCertsLoaded() const;
60 static void resetDefaultCiphers();
61
62 QList<QSsl::SslProtocol> supportedProtocols() const override;
63 QList<QSsl::SupportedFeature> supportedFeatures() const override;
64 QList<QSsl::ImplementedClass> implementedClasses() const override;
65
66 // QSslKey:
67 QTlsPrivate::TlsKey *createKey() const override;
68
69 // QSslCertificate:
70 QTlsPrivate::X509Certificate *createCertificate() const override;
71 QList<QSslCertificate> systemCaCertificates() const override;
72
73 QTlsPrivate::TlsCryptograph *createTlsCryptograph() const override;
74 QTlsPrivate::DtlsCookieVerifier *createDtlsCookieVerifier() const override;
75 QTlsPrivate::DtlsCryptograph *createDtlsCryptograph(QDtls *q, int mode) const override;
76
77 QTlsPrivate::X509ChainVerifyPtr X509Verifier() const override;
78 QTlsPrivate::X509PemReaderPtr X509PemReader() const override;
79 QTlsPrivate::X509DerReaderPtr X509DerReader() const override;
80 QTlsPrivate::X509Pkcs12ReaderPtr X509Pkcs12Reader() const override;
81
82 // Elliptic curves:
83 QList<int> ellipticCurvesIds() const override;
84 int curveIdFromShortName(const QString &name) const override;
85 int curveIdFromLongName(const QString &name) const override;
86 QString shortNameForId(int cid) const override;
87 QString longNameForId(int cid) const override;
88 bool isTlsNamedCurve(int cid) const override;
89
90 // DH parameters:
91 using DHParams = QSslDiffieHellmanParameters;
92 int dhParametersFromDer(const QByteArray &derData, QByteArray *data) const override;
93 int dhParametersFromPem(const QByteArray &pemData, QByteArray *data) const override;
94
95 void forceAutotestSecurityLevel() override;
96};
97
98Q_DECLARE_LOGGING_CATEGORY(lcTlsBackend)
99
100QT_END_NAMESPACE
101
102#endif // QTLSBACKEND_OPENSSL_P_H
103
104
105

source code of qtbase/src/plugins/tls/openssl/qtlsbackend_openssl_p.h