| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
| 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 | #ifndef QX509_GENERIC_P_H |
| 5 | #define QX509_GENERIC_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtNetwork/private/qtnetworkglobal_p.h> |
| 19 | |
| 20 | #include <QtNetwork/private/qtlsbackend_p.h> |
| 21 | |
| 22 | #include "qx509_base_p.h" |
| 23 | |
| 24 | #include <QtCore/qbytearray.h> |
| 25 | #include <QtCore/qglobal.h> |
| 26 | |
| 27 | QT_BEGIN_NAMESPACE |
| 28 | |
| 29 | namespace QTlsPrivate { |
| 30 | |
| 31 | // A part of SecureTransport and Schannel plugin. |
| 32 | class X509CertificateGeneric : public X509CertificateBase |
| 33 | { |
| 34 | public: |
| 35 | bool isEqual(const X509Certificate &rhs) const override; |
| 36 | bool isSelfSigned() const override; |
| 37 | |
| 38 | QMultiMap<QSsl::AlternativeNameEntryType, QString> subjectAlternativeNames() const override; |
| 39 | QByteArray toPem() const override; |
| 40 | QByteArray toDer() const override; |
| 41 | QString toText() const override; |
| 42 | Qt::HANDLE handle() const override; |
| 43 | |
| 44 | size_t hash(size_t seed) const noexcept override; |
| 45 | |
| 46 | static QList<QSslCertificate> certificatesFromPem(const QByteArray &pem, int count); |
| 47 | static QList<QSslCertificate> certificatesFromDer(const QByteArray &der, int count); |
| 48 | |
| 49 | protected: |
| 50 | |
| 51 | bool subjectMatchesIssuer = false; |
| 52 | QSsl::KeyAlgorithm publicKeyAlgorithm = QSsl::Rsa; |
| 53 | QByteArray publicKeyDerData; |
| 54 | |
| 55 | QMultiMap<QSsl::AlternativeNameEntryType, QString> saNames; |
| 56 | QByteArray derData; |
| 57 | |
| 58 | bool parse(const QByteArray &data); |
| 59 | bool parseExtension(const QByteArray &data, X509CertificateExtension &extension); |
| 60 | }; |
| 61 | |
| 62 | } // namespace QTlsPrivate |
| 63 | |
| 64 | QT_END_NAMESPACE |
| 65 | |
| 66 | #endif // QX509_GENERIC_P_H |
| 67 | |