1 | // Copyright (C) 2019 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 QOPCUAKEYPAIR_H |
5 | #define QOPCUAKEYPAIR_H |
6 | |
7 | #include <QtCore/qobject.h> |
8 | #include <QtCore/qstring.h> |
9 | #include <QtCore/qsharedpointer.h> |
10 | #include <QtOpcUa/qopcuaglobal.h> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QOpcUaKeyPairPrivate; |
15 | |
16 | class Q_OPCUA_EXPORT QOpcUaKeyPair : public QObject |
17 | { |
18 | Q_OBJECT |
19 | Q_DECLARE_PRIVATE(QOpcUaKeyPair) |
20 | |
21 | public: |
22 | enum class RsaKeyStrength { |
23 | Bits1024 = 1024, |
24 | Bits2048 = 2048, |
25 | Bits4096 = 4096 |
26 | }; |
27 | |
28 | enum class KeyType { |
29 | Rsa, |
30 | Empty, |
31 | Unknown |
32 | }; |
33 | |
34 | enum class Cipher { |
35 | Aes128Cbc, |
36 | Unencrypted |
37 | }; |
38 | |
39 | QOpcUaKeyPair(QObject *parent = nullptr); |
40 | |
41 | virtual ~QOpcUaKeyPair(); |
42 | bool loadFromPemData(const QByteArray &data); |
43 | QByteArray publicKeyToByteArray() const; |
44 | QByteArray privateKeyToByteArray(Cipher cipher, const QString &password) const; |
45 | KeyType type() const; |
46 | bool hasPrivateKey() const; |
47 | void generateRsaKey(QOpcUaKeyPair::RsaKeyStrength strength); |
48 | |
49 | Q_SIGNALS: |
50 | void passphraseNeeded(QString &passphrase, int maximumLength, bool writeOperation); |
51 | |
52 | friend class QOpcUaX509CertificateSigningRequestPrivate; |
53 | }; |
54 | |
55 | QT_END_NAMESPACE |
56 | |
57 | #endif // QOPCUAKEYPAIR_H |
58 | |