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