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 QDTLS_BASE_P_H
5#define QDTLS_BASE_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
20QT_REQUIRE_CONFIG(dtls);
21
22#include <QtNetwork/private/qtlsbackend_p.h>
23
24#include <QtNetwork/qsslconfiguration.h>
25#include <QtNetwork/qsslcipher.h>
26#include <QtNetwork/qsslsocket.h>
27#include <QtNetwork/qssl.h>
28
29#include <QtNetwork/qhostaddress.h>
30
31#include <QtCore/qcryptographichash.h>
32#include <QtCore/qbytearray.h>
33#include <QtCore/qglobal.h>
34#include <QtCore/qstring.h>
35
36QT_BEGIN_NAMESPACE
37
38// This class exists to re-implement the shared error/cookie handling
39// for both QDtls and QDtlsClientVerifier classes. Use it if/when
40// you need it. Backend neutral.
41class QDtlsBasePrivate : virtual public QTlsPrivate::DtlsBase
42{
43public:
44 QDtlsBasePrivate(QSslSocket::SslMode m, const QByteArray &s) : mode(m), secret(s) {}
45 void setDtlsError(QDtlsError code, const QString &description) override;
46 QDtlsError error() const override;
47 QString errorString() const override;
48 void clearDtlsError() override;
49
50 void setConfiguration(const QSslConfiguration &configuration) override;
51 QSslConfiguration configuration() const override;
52
53 bool setCookieGeneratorParameters(const GenParams &) override;
54 GenParams cookieGeneratorParameters() const override;
55
56 static bool isDtlsProtocol(QSsl::SslProtocol protocol);
57
58 QHostAddress remoteAddress;
59 quint16 remotePort = 0;
60 quint16 mtuHint = 0;
61
62 QDtlsError errorCode = QDtlsError::NoError;
63 QString errorDescription;
64 QSslConfiguration dtlsConfiguration;
65 QSslSocket::SslMode mode = QSslSocket::SslClientMode;
66 QSslCipher sessionCipher;
67 QSsl::SslProtocol sessionProtocol = QSsl::UnknownProtocol;
68 QString peerVfyName;
69 QByteArray secret;
70
71#ifdef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
72 QCryptographicHash::Algorithm hashAlgorithm = QCryptographicHash::Sha1;
73#else
74 QCryptographicHash::Algorithm hashAlgorithm = QCryptographicHash::Sha256;
75#endif
76};
77
78QT_END_NAMESPACE
79
80#endif // QDTLS_BASE_P_H
81

source code of qtbase/src/plugins/tls/shared/qdtls_base_p.h