1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTLSKEY_GENERIC_P_H
#define QTLSKEY_GENERIC_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtNetwork/private/qtlsbackend_p.h>
#include "qtlskey_base_p.h"
#include <QtCore/qnamespace.h>
#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
namespace QTlsPrivate {
// This class is what previously was known as qsslkey_qt:
// it implements most of functionality needed by QSslKey
// not relying on any TLS implementation. It's used by
// our SecureTransport and Schannel backends.
class TlsKeyGeneric : public TlsKeyBase
{
public:
using TlsKeyBase::TlsKeyBase;
void decodeDer(KeyType type, KeyAlgorithm algorithm, const QByteArray &der,
const QByteArray &passPhrase, bool deepClear) override;
void decodePem(KeyType type, KeyAlgorithm algorithm, const QByteArray &pem,
const QByteArray &passPhrase, bool deepClear) override;
QByteArray toPem(const QByteArray &passPhrase) const override;
QByteArray derFromPem(const QByteArray &pem, QMap<QByteArray,
QByteArray> *headers) const override;
void fromHandle(Qt::HANDLE opaque, KeyType expectedType) override;
void clear(bool deep) override;
Qt::HANDLE handle() const override
{
return Qt::HANDLE(opaque);
}
int length() const override
{
return keyLength;
}
bool isPkcs8() const override
{
return pkcs8;
}
private:
QByteArray decryptPkcs8(const QByteArray &encrypted, const QByteArray &passPhrase);
bool pkcs8 = false;
Qt::HANDLE opaque = nullptr;
QByteArray derData;
int keyLength = -1;
};
} // namespace QTlsPrivate
QT_END_NAMESPACE
#endif // QTLSKEY_GENERIC_P_H
|