QOpcUaKeyPair handles private and public key pairs. 更多...
头: | #include <QOpcUaKeyPair> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa) |
qmake: | QT += opcua |
继承: | QObject |
enum class | Cipher { Aes128Cbc, Unencrypted } |
enum class | KeyType { Rsa, Empty, Unknown } |
enum class | RsaKeyStrength { Bits1024, Bits2048, Bits4096 } |
QOpcUaKeyPair (QObject * parent = nullptr) | |
virtual | ~QOpcUaKeyPair () |
void | generateRsaKey (QOpcUaKeyPair::RsaKeyStrength strength ) |
bool | hasPrivateKey () const |
bool | loadFromPemData (const QByteArray & data ) |
QByteArray | privateKeyToByteArray (QOpcUaKeyPair::Cipher cipher , const QString & password ) const |
QByteArray | publicKeyToByteArray () const |
QOpcUaKeyPair::KeyType | type () const |
void | passphraseNeeded (QString & passphrase , int maximumLength , bool writeOperation ) |
This class is currently available as a Technology Preview, and therefore the API and functionality provided by the class may be subject to change at any time without prior notice.
It can generate, load and store keys for asymmetric encryption. Instances of this class have to be passed to functions which need a key.
Ciphers for encryption of private keys.
常量 | 值 | 描述 |
---|---|---|
QOpcUaKeyPair::Cipher::Aes128Cbc
|
0
|
Encrypting AES128 with CBC |
QOpcUaKeyPair::Cipher::Unencrypted
|
1
|
The Key will not be encrypted. |
This enum type specifies the type of a key.
常量 | 值 | 描述 |
---|---|---|
QOpcUaKeyPair::KeyType::Rsa
|
0
|
An RSA key |
QOpcUaKeyPair::KeyType::Empty
|
1
|
No key is available. |
QOpcUaKeyPair::KeyType::Unknown
|
2
|
The type of key is not handled. |
This enum type specifies the strength of a RSA key.
常量 | 值 | 描述 |
---|---|---|
QOpcUaKeyPair::RsaKeyStrength::Bits1024
|
1024
|
A key strength of 1024 bits. |
QOpcUaKeyPair::RsaKeyStrength::Bits2048
|
2048
|
A key strength of 2048 bits. |
QOpcUaKeyPair::RsaKeyStrength::Bits4096
|
4096
|
A key strength of 4096 bits. |
Creates a new empty key pair with parent 作为父级对象。
[virtual noexcept]
QOpcUaKeyPair::
~QOpcUaKeyPair
()
Destroys the key pair.
Generates a new asymmetric RSA key pair.
The length of the key is specified by strength .
返回
true
if the current key contains a private key, otherwise
false
.
Loads a key from PEM encoded data in
data
。返回
true
on success and
false
否则。
It detects from the PEM header if the data contains a private or public key. Loading encrypted keys is possible by connecting a function to the signal
passphraseNeeded
for provision of the passphrase.
[signal]
void
QOpcUaKeyPair::
passphraseNeeded
(
QString
&
passphrase
,
int
maximumLength
,
bool
writeOperation
)
This signal is emitted when a private key needs a passphrase for encryption or decryption.
writeOperation
is
true
when the passphrase is needed for exporting a key, and is
false
when the passphrase is needed for importing a key.
maximumLength specifies the maximum length in bytes for the passphrase. All characters in passphrase exceeding this limit will be ignored.
In case you have use this signal crossing thread boundaries you have to connect it with
Qt::BlockingQueuedConnection
.
Returns the PEM encoded private key. In case there is no private key, an empty byte array is returned.
The encryption of the key has to be specified using the parameters
cipher
and
password
. In order to store the key unencrypted the cipher
Cipher::Unencrypted
has to be used.
Returns the public key as a byte array.
Returns the type of the current key.