1 | // Copyright (C) 2016 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 | |
5 | #ifndef QSSLKEY_H |
6 | #define QSSLKEY_H |
7 | |
8 | #include <QtNetwork/qtnetworkglobal.h> |
9 | #include <QtCore/qnamespace.h> |
10 | #include <QtCore/qbytearray.h> |
11 | #include <QtCore/qshareddata.h> |
12 | #include <QtNetwork/qssl.h> |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | |
17 | #ifndef QT_NO_SSL |
18 | |
19 | class QIODevice; |
20 | |
21 | class QSslKeyPrivate; |
22 | class Q_NETWORK_EXPORT QSslKey |
23 | { |
24 | public: |
25 | QSslKey(); |
26 | QSslKey(const QByteArray &encoded, QSsl::KeyAlgorithm algorithm, |
27 | QSsl::EncodingFormat format = QSsl::Pem, |
28 | QSsl::KeyType type = QSsl::PrivateKey, |
29 | const QByteArray &passPhrase = QByteArray()); |
30 | QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, |
31 | QSsl::EncodingFormat format = QSsl::Pem, |
32 | QSsl::KeyType type = QSsl::PrivateKey, |
33 | const QByteArray &passPhrase = QByteArray()); |
34 | explicit QSslKey(Qt::HANDLE handle, QSsl::KeyType type = QSsl::PrivateKey); |
35 | QSslKey(const QSslKey &other); |
36 | QSslKey(QSslKey &&other) noexcept; |
37 | QSslKey &operator=(QSslKey &&other) noexcept; |
38 | QSslKey &operator=(const QSslKey &other); |
39 | ~QSslKey(); |
40 | |
41 | void swap(QSslKey &other) noexcept { d.swap(other&: other.d); } |
42 | |
43 | bool isNull() const; |
44 | void clear(); |
45 | |
46 | int length() const; |
47 | QSsl::KeyType type() const; |
48 | QSsl::KeyAlgorithm algorithm() const; |
49 | |
50 | QByteArray toPem(const QByteArray &passPhrase = QByteArray()) const; |
51 | // ### Qt 7: drop passPhrase |
52 | QByteArray toDer(const QByteArray &passPhrase = QByteArray()) const; |
53 | |
54 | Qt::HANDLE handle() const; |
55 | |
56 | bool operator==(const QSslKey &key) const; |
57 | inline bool operator!=(const QSslKey &key) const { return !operator==(key); } |
58 | |
59 | private: |
60 | QExplicitlySharedDataPointer<QSslKeyPrivate> d; |
61 | friend class QTlsBackend; |
62 | }; |
63 | |
64 | Q_DECLARE_SHARED(QSslKey) |
65 | |
66 | #ifndef QT_NO_DEBUG_STREAM |
67 | class QDebug; |
68 | Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslKey &key); |
69 | #endif |
70 | |
71 | #endif // QT_NO_SSL |
72 | |
73 | QT_END_NAMESPACE |
74 | |
75 | #endif |
76 | |