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
4#ifndef QTLSKEY_BASE_P_H
5#define QTLSKEY_BASE_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 <QtNetwork/qssl.h>
23
24#include <QtCore/qglobal.h>
25
26QT_BEGIN_NAMESPACE
27
28namespace QTlsPrivate {
29
30class TlsKeyBase : public TlsKey
31{
32public:
33 TlsKeyBase(KeyType type = QSsl::PublicKey, KeyAlgorithm algorithm = QSsl::Opaque)
34 : keyType(type),
35 keyAlgorithm(algorithm)
36 {
37 }
38
39 bool isNull() const override
40 {
41 return keyIsNull;
42 }
43 KeyType type() const override
44 {
45 return keyType;
46 }
47 KeyAlgorithm algorithm() const override
48 {
49 return keyAlgorithm;
50 }
51 bool isPkcs8 () const override
52 {
53 return false;
54 }
55
56 QByteArray pemFromDer(const QByteArray &der, const QMap<QByteArray, QByteArray> &headers) const override;
57
58protected:
59 static QByteArray pkcs8Header(bool encrypted);
60 static QByteArray pkcs8Footer(bool encrypted);
61 static bool isEncryptedPkcs8(const QByteArray &der);
62
63 bool keyIsNull = true;
64 KeyType keyType = QSsl::PublicKey;
65 KeyAlgorithm keyAlgorithm = QSsl::Opaque;
66};
67
68} // namespace QTlsPrivate
69
70QT_END_NAMESPACE
71
72#endif // QTLSKEY_BASE_P_H
73

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