/src/qtbase/src/network/ssl/qsslkeyingmaterial.h
Line | Count | Source |
1 | | // Copyright (C) 2026 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 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #ifndef QSSLKEYINGMATERIAL_H |
6 | | #define QSSLKEYINGMATERIAL_H |
7 | | |
8 | | #include <QtNetwork/qtnetworkglobal.h> |
9 | | |
10 | | QT_REQUIRE_CONFIG(ssl); |
11 | | |
12 | | #include <QtCore/QString> |
13 | | #include <QtCore/QMetaType> |
14 | | |
15 | | QT_BEGIN_NAMESPACE |
16 | | |
17 | | namespace QTlsPrivate { |
18 | | class TlsCryptographOpenSSL; |
19 | | } |
20 | | |
21 | | class QDebug; |
22 | | |
23 | | class QSslKeyingMaterial |
24 | | { |
25 | | public: |
26 | | QSslKeyingMaterial() = default; |
27 | | explicit QSslKeyingMaterial(const QByteArray &label, qsizetype size) |
28 | | : keyingLabel(label) |
29 | | , keyingValueSize(size) |
30 | 0 | { |
31 | 0 | } |
32 | | explicit QSslKeyingMaterial(const QByteArray &label, |
33 | | qsizetype size, |
34 | | const QByteArray &context) |
35 | | : keyingLabel(label) |
36 | | , keyingContext(context) |
37 | | , keyingValueSize(size) |
38 | 0 | { |
39 | 0 | } |
40 | | |
41 | | bool isValid() const noexcept |
42 | 0 | { |
43 | 0 | return !label().isEmpty() && requestedSize() > 0; |
44 | 0 | } |
45 | | |
46 | | QByteArray label() const noexcept |
47 | 0 | { |
48 | 0 | return keyingLabel; |
49 | 0 | } |
50 | | |
51 | | QByteArray context() const noexcept |
52 | 0 | { |
53 | 0 | return keyingContext; |
54 | 0 | } |
55 | | |
56 | | QByteArray value() const noexcept |
57 | 0 | { |
58 | 0 | return keyingValue; |
59 | 0 | } |
60 | | |
61 | | qsizetype requestedSize() const noexcept |
62 | 0 | { |
63 | 0 | return keyingValueSize; |
64 | 0 | } |
65 | | |
66 | | void swap(QSslKeyingMaterial &other) noexcept |
67 | 0 | { |
68 | 0 | keyingLabel.swap(other.keyingLabel); |
69 | 0 | keyingContext.swap(other.keyingContext); |
70 | 0 | keyingValue.swap(other.keyingValue); |
71 | 0 | std::swap(keyingValueSize, other.keyingValueSize); |
72 | 0 | } |
73 | | |
74 | | private: |
75 | | QByteArray keyingLabel; |
76 | | QByteArray keyingContext; |
77 | | QByteArray keyingValue; |
78 | | qsizetype keyingValueSize = 0; |
79 | | |
80 | | friend bool comparesEqual(const QSslKeyingMaterial &lhs, |
81 | | const QSslKeyingMaterial &rhs) noexcept |
82 | 0 | { |
83 | 0 | return lhs.keyingLabel == rhs.keyingLabel |
84 | 0 | && lhs.keyingContext == rhs.keyingContext |
85 | 0 | && lhs.keyingValue == rhs.keyingValue |
86 | 0 | && lhs.keyingValueSize == rhs.keyingValueSize; |
87 | 0 | } |
88 | 0 | Q_DECLARE_EQUALITY_COMPARABLE(QSslKeyingMaterial) Unexecuted instantiation: operator==(QSslKeyingMaterial const&, QSslKeyingMaterial const&) Unexecuted instantiation: operator!=(QSslKeyingMaterial const&, QSslKeyingMaterial const&) |
89 | 0 |
|
90 | 0 | friend size_t qHash(const QSslKeyingMaterial &material) noexcept |
91 | 0 | { return qHash(material, 0); } |
92 | | friend Q_NETWORK_EXPORT size_t qHash(const QSslKeyingMaterial &material, size_t seed) noexcept; |
93 | | |
94 | | #ifndef QT_NO_DEBUG_STREAM |
95 | | friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslKeyingMaterial &keying); |
96 | | #endif // QT_NO_DEBUG_STREAM |
97 | | |
98 | | friend class QTlsPrivate::TlsCryptographOpenSSL; |
99 | | }; |
100 | | |
101 | | Q_DECLARE_SHARED(QSslKeyingMaterial) |
102 | | |
103 | | QT_END_NAMESPACE |
104 | | |
105 | | #endif // QSSLKEYINGMATERIAL_H |