1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk> |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtNetwork module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | |
41 | #ifndef QSSLDIFFIEHELLMANPARAMETERS_H |
42 | #define QSSLDIFFIEHELLMANPARAMETERS_H |
43 | |
44 | #include <QtNetwork/qssl.h> |
45 | #include <QtCore/qnamespace.h> |
46 | #include <QtCore/qbytearray.h> |
47 | #include <QtCore/qshareddata.h> |
48 | |
49 | QT_BEGIN_NAMESPACE |
50 | |
51 | #ifndef QT_NO_SSL |
52 | |
53 | class QIODevice; |
54 | class QSslContext; |
55 | class QSslDiffieHellmanParametersPrivate; |
56 | |
57 | class QSslDiffieHellmanParameters; |
58 | // qHash is a friend, but we can't use default arguments for friends (ยง8.3.6.4) |
59 | Q_NETWORK_EXPORT size_t qHash(const QSslDiffieHellmanParameters &dhparam, size_t seed = 0) noexcept; |
60 | |
61 | #ifndef QT_NO_DEBUG_STREAM |
62 | class QDebug; |
63 | Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparams); |
64 | #endif |
65 | |
66 | Q_NETWORK_EXPORT bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept; |
67 | |
68 | inline bool operator!=(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept |
69 | { |
70 | return !operator==(lhs, rhs); |
71 | } |
72 | |
73 | class QSslDiffieHellmanParameters |
74 | { |
75 | public: |
76 | enum Error { |
77 | NoError, |
78 | InvalidInputDataError, |
79 | UnsafeParametersError |
80 | }; |
81 | |
82 | Q_NETWORK_EXPORT static QSslDiffieHellmanParameters defaultParameters(); |
83 | |
84 | Q_NETWORK_EXPORT QSslDiffieHellmanParameters(); |
85 | Q_NETWORK_EXPORT QSslDiffieHellmanParameters(const QSslDiffieHellmanParameters &other); |
86 | QSslDiffieHellmanParameters(QSslDiffieHellmanParameters &&other) noexcept : d(other.d) { other.d = nullptr; } |
87 | Q_NETWORK_EXPORT ~QSslDiffieHellmanParameters(); |
88 | |
89 | Q_NETWORK_EXPORT QSslDiffieHellmanParameters &operator=(const QSslDiffieHellmanParameters &other); |
90 | QSslDiffieHellmanParameters &operator=(QSslDiffieHellmanParameters &&other) noexcept { swap(other); return *this; } |
91 | |
92 | void swap(QSslDiffieHellmanParameters &other) noexcept { qSwap(d, other.d); } |
93 | |
94 | Q_NETWORK_EXPORT static QSslDiffieHellmanParameters fromEncoded(const QByteArray &encoded, QSsl::EncodingFormat format = QSsl::Pem); |
95 | Q_NETWORK_EXPORT static QSslDiffieHellmanParameters fromEncoded(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem); |
96 | |
97 | Q_NETWORK_EXPORT bool isEmpty() const noexcept; |
98 | Q_NETWORK_EXPORT bool isValid() const noexcept; |
99 | Q_NETWORK_EXPORT Error error() const noexcept; |
100 | Q_NETWORK_EXPORT QString errorString() const noexcept; |
101 | |
102 | private: |
103 | QSslDiffieHellmanParametersPrivate *d; |
104 | friend class QSslContext; |
105 | friend Q_NETWORK_EXPORT bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept; |
106 | #ifndef QT_NO_DEBUG_STREAM |
107 | friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam); |
108 | #endif |
109 | friend Q_NETWORK_EXPORT size_t qHash(const QSslDiffieHellmanParameters &dhparam, size_t seed) noexcept; |
110 | }; |
111 | |
112 | Q_DECLARE_SHARED(QSslDiffieHellmanParameters) |
113 | |
114 | #endif // QT_NO_SSL |
115 | |
116 | QT_END_NAMESPACE |
117 | |
118 | #endif |
119 | |