1// Copyright (C) 2014 Governikus GmbH & Co. KG.
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 QSSLELLIPTICCURVE_H
5#define QSSLELLIPTICCURVE_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtCore/QString>
9#include <QtCore/QMetaType>
10#include <QtCore/qhashfunctions.h>
11
12QT_BEGIN_NAMESPACE
13
14class QSslEllipticCurve;
15// qHash is a friend, but we can't use default arguments for friends (ยง8.3.6.4)
16constexpr size_t qHash(QSslEllipticCurve curve, size_t seed = 0) noexcept;
17
18class QSslEllipticCurve {
19public:
20 constexpr QSslEllipticCurve() noexcept
21 : id(0)
22 {
23 }
24
25 Q_NETWORK_EXPORT static QSslEllipticCurve fromShortName(const QString &name);
26 Q_NETWORK_EXPORT static QSslEllipticCurve fromLongName(const QString &name);
27
28 [[nodiscard]] Q_NETWORK_EXPORT QString shortName() const;
29 [[nodiscard]] Q_NETWORK_EXPORT QString longName() const;
30
31 constexpr bool isValid() const noexcept
32 {
33 return id != 0;
34 }
35
36 Q_NETWORK_EXPORT bool isTlsNamedCurve() const noexcept;
37
38private:
39 int id;
40
41 friend constexpr bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept
42 { return lhs.id == rhs.id; }
43 friend constexpr bool operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept
44 { return !(lhs == rhs); }
45 friend constexpr size_t qHash(QSslEllipticCurve curve, size_t seed) noexcept;
46
47 friend class QSslContext;
48 friend class QSslSocketPrivate;
49};
50
51Q_DECLARE_TYPEINFO(QSslEllipticCurve, Q_PRIMITIVE_TYPE);
52
53constexpr inline size_t qHash(QSslEllipticCurve curve, size_t seed) noexcept
54{ return qHash(key: curve.id, seed); }
55
56#ifndef QT_NO_DEBUG_STREAM
57class QDebug;
58Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, QSslEllipticCurve curve);
59#endif
60
61QT_END_NAMESPACE
62
63QT_DECL_METATYPE_EXTERN(QSslEllipticCurve, Q_NETWORK_EXPORT)
64
65#endif // QSSLELLIPTICCURVE_H
66

source code of qtbase/src/network/ssl/qsslellipticcurve.h