1 | // Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk> |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | |
5 | #ifndef QSSLDIFFIEHELLMANPARAMETERS_H |
6 | #define QSSLDIFFIEHELLMANPARAMETERS_H |
7 | |
8 | #include <QtNetwork/qssl.h> |
9 | #include <QtCore/qnamespace.h> |
10 | #include <QtCore/qbytearray.h> |
11 | #include <QtCore/qshareddata.h> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | #ifndef QT_NO_SSL |
16 | |
17 | class QIODevice; |
18 | class QSslContext; |
19 | class QSslDiffieHellmanParametersPrivate; |
20 | |
21 | class QSslDiffieHellmanParameters; |
22 | // qHash is a friend, but we can't use default arguments for friends (ยง8.3.6.4) |
23 | Q_NETWORK_EXPORT size_t qHash(const QSslDiffieHellmanParameters &dhparam, size_t seed = 0) noexcept; |
24 | |
25 | #ifndef QT_NO_DEBUG_STREAM |
26 | class QDebug; |
27 | Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparams); |
28 | #endif |
29 | |
30 | class Q_NETWORK_EXPORT QSslDiffieHellmanParameters |
31 | { |
32 | public: |
33 | enum Error { |
34 | NoError, |
35 | InvalidInputDataError, |
36 | UnsafeParametersError |
37 | }; |
38 | |
39 | static QSslDiffieHellmanParameters defaultParameters(); |
40 | |
41 | QSslDiffieHellmanParameters(); |
42 | QSslDiffieHellmanParameters(const QSslDiffieHellmanParameters &other); |
43 | QSslDiffieHellmanParameters(QSslDiffieHellmanParameters &&other) noexcept : d(other.d) { other.d = nullptr; } |
44 | ~QSslDiffieHellmanParameters(); |
45 | |
46 | QSslDiffieHellmanParameters &operator=(const QSslDiffieHellmanParameters &other); |
47 | QSslDiffieHellmanParameters &operator=(QSslDiffieHellmanParameters &&other) noexcept { swap(other); return *this; } |
48 | |
49 | void swap(QSslDiffieHellmanParameters &other) noexcept { qt_ptr_swap(lhs&: d, rhs&: other.d); } |
50 | |
51 | static QSslDiffieHellmanParameters fromEncoded(const QByteArray &encoded, QSsl::EncodingFormat format = QSsl::Pem); |
52 | static QSslDiffieHellmanParameters fromEncoded(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem); |
53 | |
54 | bool isEmpty() const noexcept; |
55 | bool isValid() const noexcept; |
56 | Error error() const noexcept; |
57 | QString errorString() const noexcept; |
58 | |
59 | private: |
60 | QSslDiffieHellmanParametersPrivate *d; |
61 | friend class QSslContext; |
62 | |
63 | bool isEqual(const QSslDiffieHellmanParameters &other) const noexcept; |
64 | friend bool (const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept |
65 | { return lhs.isEqual(other: rhs); } |
66 | friend bool (const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept |
67 | { return !lhs.isEqual(other: rhs); } |
68 | |
69 | #ifndef QT_NO_DEBUG_STREAM |
70 | friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam); |
71 | #endif |
72 | friend Q_NETWORK_EXPORT size_t qHash(const QSslDiffieHellmanParameters &dhparam, size_t seed) noexcept; |
73 | }; |
74 | |
75 | Q_DECLARE_SHARED(QSslDiffieHellmanParameters) |
76 | |
77 | #endif // QT_NO_SSL |
78 | |
79 | QT_END_NAMESPACE |
80 | |
81 | #endif |
82 | |