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
5#ifndef QTLSKEY_BASE_P_H
6#define QTLSKEY_BASE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtNetwork/private/qtnetworkglobal_p.h>
20
21#include <QtNetwork/private/qtlsbackend_p.h>
22
23#include <QtNetwork/qssl.h>
24
25#include <QtCore/qglobal.h>
26
27QT_BEGIN_NAMESPACE
28
29namespace QTlsPrivate {
30
31class TlsKeyBase : public TlsKey
32{
33public:
34 TlsKeyBase(KeyType type = QSsl::PublicKey, KeyAlgorithm algorithm = QSsl::Opaque)
35 : keyType(type),
36 keyAlgorithm(algorithm)
37 {
38 }
39
40 bool isNull() const override
41 {
42 return keyIsNull;
43 }
44 KeyType type() const override
45 {
46 return keyType;
47 }
48 KeyAlgorithm algorithm() const override
49 {
50 return keyAlgorithm;
51 }
52 bool isPkcs8 () const override
53 {
54 return false;
55 }
56
57 QByteArray pemFromDer(const QByteArray &der, const QMap<QByteArray, QByteArray> &headers) const override;
58
59protected:
60 static QByteArray pkcs8Header(bool encrypted);
61 static QByteArray pkcs8Footer(bool encrypted);
62 static bool isEncryptedPkcs8(const QByteArray &der);
63
64 bool keyIsNull = true;
65 KeyType keyType = QSsl::PublicKey;
66 KeyAlgorithm keyAlgorithm = QSsl::Opaque;
67};
68
69} // namespace QTlsPrivate
70
71QT_END_NAMESPACE
72
73#endif // QTLSKEY_BASE_P_H
74

source code of qtbase/src/plugins/tls/shared/qtlskey_base_p.h