| 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 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | class QSslEllipticCurve; |
| 15 | // qHash is a friend, but we can't use default arguments for friends (ยง8.3.6.4) |
| 16 | constexpr size_t qHash(QSslEllipticCurve curve, size_t seed = 0) noexcept; |
| 17 | |
| 18 | class QSslEllipticCurve { |
| 19 | public: |
| 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 | |
| 38 | private: |
| 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 | |
| 51 | Q_DECLARE_TYPEINFO(QSslEllipticCurve, Q_PRIMITIVE_TYPE); |
| 52 | |
| 53 | constexpr inline size_t qHash(QSslEllipticCurve curve, size_t seed) noexcept |
| 54 | { return qHash(key: curve.id, seed); } |
| 55 | |
| 56 | #ifndef QT_NO_DEBUG_STREAM |
| 57 | class QDebug; |
| 58 | Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, QSslEllipticCurve curve); |
| 59 | #endif |
| 60 | |
| 61 | QT_END_NAMESPACE |
| 62 | |
| 63 | QT_DECL_METATYPE_EXTERN(QSslEllipticCurve, Q_NETWORK_EXPORT) |
| 64 | |
| 65 | #endif // QSSLELLIPTICCURVE_H |
| 66 | |