1// Copyright (C) 2011 Richard J. Moore <rich@kde.org>
2// Copyright (C) 2019 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6#ifndef QOCSPRESPONSE_H
7#define QOCSPRESPONSE_H
8
9#include <QtNetwork/qtnetworkglobal.h>
10
11#include <QtCore/qshareddata.h>
12#include <QtCore/qmetatype.h>
13#include <QtCore/qobject.h>
14
15#ifndef Q_QDOC
16QT_REQUIRE_CONFIG(ssl);
17#endif
18
19QT_BEGIN_NAMESPACE
20
21enum class QOcspCertificateStatus
22{
23 Good,
24 Revoked,
25 Unknown
26};
27
28enum class QOcspRevocationReason
29{
30 None = -1,
31 Unspecified,
32 KeyCompromise,
33 CACompromise,
34 AffiliationChanged,
35 Superseded,
36 CessationOfOperation,
37 CertificateHold,
38 RemoveFromCRL
39};
40
41namespace QTlsPrivate {
42class TlsCryptographOpenSSL;
43}
44
45class QOcspResponse;
46Q_NETWORK_EXPORT size_t qHash(const QOcspResponse &response, size_t seed = 0) noexcept;
47
48class QOcspResponsePrivate;
49class Q_NETWORK_EXPORT QOcspResponse
50{
51public:
52
53 QOcspResponse();
54 QOcspResponse(const QOcspResponse &other);
55 QOcspResponse(QOcspResponse && other) noexcept;
56 ~QOcspResponse();
57
58 QOcspResponse &operator = (const QOcspResponse &other);
59 QOcspResponse &operator = (QOcspResponse &&other) noexcept;
60
61 QOcspCertificateStatus certificateStatus() const;
62 QOcspRevocationReason revocationReason() const;
63
64 class QSslCertificate responder() const;
65 QSslCertificate subject() const;
66
67 void swap(QOcspResponse &other) noexcept { d.swap(other&: other.d); }
68
69private:
70 bool isEqual(const QOcspResponse &other) const;
71
72 friend class QTlsPrivate::TlsCryptographOpenSSL;
73 friend bool operator==(const QOcspResponse &lhs, const QOcspResponse &rhs)
74 { return lhs.isEqual(other: rhs); }
75 friend bool operator!=(const QOcspResponse &lhs, const QOcspResponse &rhs)
76 { return !lhs.isEqual(other: rhs); }
77
78 friend Q_NETWORK_EXPORT size_t qHash(const QOcspResponse &response, size_t seed) noexcept;
79
80 QSharedDataPointer<QOcspResponsePrivate> d;
81};
82
83Q_DECLARE_SHARED(QOcspResponse)
84
85QT_END_NAMESPACE
86
87QT_DECL_METATYPE_EXTERN(QOcspResponse, Q_NETWORK_EXPORT)
88
89#endif // QOCSPRESPONSE_H
90

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