Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdtls.h
Go to the documentation of this file.
1// Copyright (C) 2018 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_H
5#define QDTLS_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8
9#include <QtNetwork/qsslsocket.h>
10#include <QtNetwork/qssl.h>
11
12#include <QtCore/qcryptographichash.h>
13#include <QtCore/qobject.h>
14#include <QtCore/qcontainerfwd.h>
15
17
18#ifndef Q_QDOC
20#endif
21
23
36
37class QHostAddress;
38class QUdpSocket;
39class QByteArray;
40class QString;
41
43class Q_NETWORK_EXPORT QDtlsClientVerifier : public QObject
44{
46
47public:
48
49 explicit QDtlsClientVerifier(QObject *parent = nullptr);
51
59
60 bool setCookieGeneratorParameters(const GeneratorParameters &params);
61 GeneratorParameters cookieGeneratorParameters() const;
62
63 bool verifyClient(QUdpSocket *socket, const QByteArray &dgram,
65 QByteArray verifiedHello() const;
66
67 QDtlsError dtlsError() const;
68 QString dtlsErrorString() const;
69
70private:
71
72 Q_DECLARE_PRIVATE(QDtlsClientVerifier)
73 Q_DISABLE_COPY(QDtlsClientVerifier)
74};
75
78class QSslCipher;
79class QSslError;
80
81class QDtlsPrivate;
82class Q_NETWORK_EXPORT QDtls : public QObject
83{
85
86public:
87
95
96 explicit QDtls(QSslSocket::SslMode mode, QObject *parent = nullptr);
97 ~QDtls();
98
100 const QString &verificationName = {});
101 bool setPeerVerificationName(const QString &name);
102 QHostAddress peerAddress() const;
103 quint16 peerPort() const;
104 QString peerVerificationName() const;
105 QSslSocket::SslMode sslMode() const;
106
107 void setMtuHint(quint16 mtuHint);
108 quint16 mtuHint() const;
109
111 bool setCookieGeneratorParameters(const GeneratorParameters &params);
112 GeneratorParameters cookieGeneratorParameters() const;
113
114 bool setDtlsConfiguration(const QSslConfiguration &configuration);
115 QSslConfiguration dtlsConfiguration() const;
116
117 HandshakeState handshakeState() const;
118
119 bool doHandshake(QUdpSocket *socket, const QByteArray &dgram = {});
120 bool handleTimeout(QUdpSocket *socket);
121 bool resumeHandshake(QUdpSocket *socket);
122 bool abortHandshake(QUdpSocket *socket);
123 bool shutdown(QUdpSocket *socket);
124
125 bool isConnectionEncrypted() const;
126 QSslCipher sessionCipher() const;
127 QSsl::SslProtocol sessionProtocol() const;
128
129 qint64 writeDatagramEncrypted(QUdpSocket *socket, const QByteArray &dgram);
130 QByteArray decryptDatagram(QUdpSocket *socket, const QByteArray &dgram);
131
132 QDtlsError dtlsError() const;
133 QString dtlsErrorString() const;
134
135 QList<QSslError> peerVerificationErrors() const;
136 void ignoreVerificationErrors(const QList<QSslError> &errorsToIgnore);
137
139
142
143private:
144
145 bool startHandshake(QUdpSocket *socket, const QByteArray &dgram);
146 bool continueHandshake(QUdpSocket *socket, const QByteArray &dgram);
147
148 Q_DECLARE_PRIVATE(QDtls)
149 Q_DISABLE_COPY_MOVE(QDtls)
150};
151
153
154#endif // QDTLS_H
\inmodule QtCore
Definition qbytearray.h:57
This class implements server-side DTLS cookie generation and verification.
Definition qdtls.h:44
This class provides encryption for UDP sockets.
Definition qdtls.h:83
HandshakeState
Describes the current state of DTLS handshake.
Definition qdtls.h:89
@ PeerVerificationFailed
Definition qdtls.h:92
@ HandshakeNotStarted
Definition qdtls.h:90
@ HandshakeInProgress
Definition qdtls.h:91
void handshakeTimeout()
Packet loss can result in timeouts during the handshake phase.
void pskRequired(QSslPreSharedKeyAuthenticator *authenticator)
QDtls emits this signal when it negotiates a PSK ciphersuite, and therefore a PSK authentication is t...
The QHostAddress class provides an IP address.
\inmodule QtCore
Definition qobject.h:103
The QSslCipher class represents an SSL cryptographic cipher.
Definition qsslcipher.h:22
The QSslConfiguration class holds the configuration and state of an SSL connection.
The QSslError class provides an SSL error.
Definition qsslerror.h:21
The QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) cipher...
SslMode
Describes the connection modes available for QSslSocket.
Definition qsslsocket.h:33
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\reentrant
Definition qudpsocket.h:21
QHash< int, QWidget * > hash
[35multi]
SslProtocol
Describes the protocol of the cipher.
Definition qssl.h:50
Combined button and popup list for selecting options.
QDtlsError
Definition qdtls.h:25
@ TlsInitializationError
@ UnderlyingSocketError
@ InvalidInputParameters
@ PeerVerificationError
@ RemoteClosedConnectionError
EGLOutputPortEXT port
GLenum mode
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint name
void ** params
GLdouble s
[6]
Definition qopenglext.h:235
GLuint GLuint64EXT address
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
#define Q_MOC_INCLUDE(...)
#define Q_SIGNALS
unsigned short quint16
Definition qtypes.h:48
long long qint64
Definition qtypes.h:60
QTcpSocket * socket
[1]
clientDtls setPeer(address, port, peerName)
dtlsConnection setDtlsConfiguration(config)
dtls doHandshake(udpSocket)
dtls ignoreVerificationErrors(expectedSslErrors)
This class defines parameters for DTLS cookie generator.
Definition qdtls.h:53