8#include <QtNetwork/qtnetworkglobal.h>
10#include <QtNetwork/qsslsocket.h>
11#include <QtNetwork/qssl.h>
13#include <QtCore/qcryptographichash.h>
14#include <QtCore/qobject.h>
15#include <QtCore/qcontainerfwd.h>
17Q_MOC_INCLUDE(<QtNetwork/QSslPreSharedKeyAuthenticator>)
20QT_REQUIRE_CONFIG(dtls);
25enum class QDtlsError :
unsigned char
28 InvalidInputParameters,
30 UnderlyingSocketError,
31 RemoteClosedConnectionError,
32 PeerVerificationError,
33 TlsInitializationError,
50 explicit QDtlsClientVerifier(QObject *parent =
nullptr);
51 ~QDtlsClientVerifier();
53 struct Q_NETWORK_EXPORT GeneratorParameters
55 GeneratorParameters();
56 GeneratorParameters(QCryptographicHash::Algorithm a,
const QByteArray &s);
57 QCryptographicHash::Algorithm hash = QCryptographicHash::Sha1;
61 bool setCookieGeneratorParameters(
const GeneratorParameters ¶ms);
62 GeneratorParameters cookieGeneratorParameters()
const;
64 bool verifyClient(QUdpSocket *socket,
const QByteArray &dgram,
65 const QHostAddress &address, quint16 port);
66 QByteArray verifiedHello()
const;
68 QDtlsError dtlsError()
const;
69 QString dtlsErrorString()
const;
73 Q_DECLARE_PRIVATE(QDtlsClientVerifier)
74 Q_DISABLE_COPY(QDtlsClientVerifier)
78class QSslConfiguration;
83class Q_NETWORK_EXPORT
QDtls :
public QObject
93 PeerVerificationFailed,
97 explicit QDtls(QSslSocket::SslMode mode, QObject *parent =
nullptr);
100 bool setPeer(
const QHostAddress &address, quint16 port,
101 const QString &verificationName = {});
102 bool setPeerVerificationName(
const QString &name);
103 QHostAddress peerAddress()
const;
104 quint16 peerPort()
const;
105 QString peerVerificationName()
const;
106 QSslSocket::SslMode sslMode()
const;
108 void setMtuHint(quint16 mtuHint);
109 quint16 mtuHint()
const;
111 using GeneratorParameters = QDtlsClientVerifier::GeneratorParameters;
112 bool setCookieGeneratorParameters(
const GeneratorParameters ¶ms);
113 GeneratorParameters cookieGeneratorParameters()
const;
115 bool setDtlsConfiguration(
const QSslConfiguration &configuration);
116 QSslConfiguration dtlsConfiguration()
const;
118 HandshakeState handshakeState()
const;
120 bool doHandshake(QUdpSocket *socket,
const QByteArray &dgram = {});
121 bool handleTimeout(QUdpSocket *socket);
122 bool resumeHandshake(QUdpSocket *socket);
123 bool abortHandshake(QUdpSocket *socket);
124 bool shutdown(QUdpSocket *socket);
126 bool isConnectionEncrypted()
const;
127 QSslCipher sessionCipher()
const;
128 QSsl::SslProtocol sessionProtocol()
const;
130 qint64 writeDatagramEncrypted(QUdpSocket *socket,
const QByteArray &dgram);
131 QByteArray decryptDatagram(QUdpSocket *socket,
const QByteArray &dgram);
133 QDtlsError dtlsError()
const;
134 QString dtlsErrorString()
const;
136 QList<QSslError> peerVerificationErrors()
const;
137 void ignoreVerificationErrors(
const QList<QSslError> &errorsToIgnore);
141 void pskRequired(QSslPreSharedKeyAuthenticator *authenticator);
142 void handshakeTimeout();
146 bool startHandshake(QUdpSocket *socket,
const QByteArray &dgram);
147 bool continueHandshake(QUdpSocket *socket,
const QByteArray &dgram);
149 Q_DECLARE_PRIVATE(QDtls)
150 Q_DISABLE_COPY_MOVE(QDtls)
QDtlsClientVerifierPrivate()
std::unique_ptr< QTlsPrivate::DtlsCookieVerifier > backend
~QDtlsClientVerifierPrivate()
This class implements server-side DTLS cookie generation and verification.
std::unique_ptr< QTlsPrivate::DtlsCryptograph > backend
This class provides encryption for UDP sockets.
This class represents Online Certificate Status Protocol response.
The QSslCertificate class provides a convenient API for an X509 certificate.
The QSslCipher class represents an SSL cryptographic cipher.
The QSslDiffieHellmanParameters class provides an interface for Diffie-Hellman parameters for servers...
Represents an elliptic curve for use by elliptic-curve cipher algorithms.
constexpr QSslEllipticCurve() noexcept
Constructs an invalid elliptic curve.
constexpr bool isValid() const noexcept
Returns true if this elliptic curve is a valid curve, false otherwise.
friend constexpr bool operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept
Q_NETWORK_EXPORT bool isTlsNamedCurve() const noexcept
Returns true if this elliptic curve is one of the named curves that can be used in the key exchange w...
friend constexpr bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept
The QSslError class provides an SSL error.
The QSslKey class provides an interface for private and public keys.
Describes exported keying material derived from a TLS session.
The QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) cipher...
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
QTlsBackend is a factory class, providing implementations for the QSsl classes.
TlsKey is an abstract class, that allows a TLS plugin to provide an underlying implementation for the...
X509Certificate is an abstract class that allows a TLS backend to provide an implementation of the QS...
Combined button and popup list for selecting options.
Namespace containing onternal types that TLS backends implement.
bool(*)(QIODevice *device, QSslKey *key, QSslCertificate *cert, QList< QSslCertificate > *caCertificates, const QByteArray &passPhrase) X509Pkcs12ReaderPtr
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
static QT_BEGIN_NAMESPACE QString msgUnsupportedMulticastAddress()
QT_REQUIRE_CONFIG(liburing)
Q_DECLARE_INTERFACE(QNetworkAccessBackendFactory, QNetworkAccessBackendFactory_iid)
constexpr size_t qHash(QSslEllipticCurve curve, size_t seed=0) noexcept
Q_DECLARE_TYPEINFO(QSslEllipticCurve, Q_PRIMITIVE_TYPE)