QKnxSecureKey Class
The QKnxSecureKey class represents the elliptic-curve secure key to be used with the elliptic curve Diffie-Hellman (ECDH) key agreement scheme. More...
Header: | #include <QKnxSecureKey> |
qmake: | QT += knx |
Since: | Qt 5.13 |
This class was introduced in Qt 5.13.
Public Types
enum class | Type { Private, Public, Invalid } |
Public Functions
QKnxSecureKey(const QKnxSecureKey &other) | |
QKnxSecureKey() | |
QKnxSecureKey & | operator=(const QKnxSecureKey &other) |
~QKnxSecureKey() | |
QKnxByteArray | bytes() const |
bool | isNull() const |
bool | isValid() const |
QKnxSecureKey::Type | type() const |
bool | operator!=(const QKnxSecureKey &other) const |
bool | operator==(const QKnxSecureKey &other) const |
Static Public Members
QKnxSecureKey | fromBytes(QKnxSecureKey::Type type, const QKnxByteArray &data, quint16 index = 0) |
void | generateKeys(QKnxSecureKey *privateKey, QKnxSecureKey *publicKey) |
QKnxSecureKey | generatePrivateKey() |
QKnxSecureKey | publicKeyFromPrivate(const QKnxSecureKey &privateKey) |
QKnxSecureKey | publicKeyFromPrivate(const QKnxByteArray &privateKey) |
QKnxByteArray | sharedSecret(const QKnxSecureKey &privateKey, const QKnxSecureKey &peerPublicKey) |
QKnxByteArray | sharedSecret(const QKnxByteArray &privateKey, const QKnxByteArray &peerPublicKey) |
Detailed Description
This class is part of the Qt KNX module and 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.
Member Type Documentation
enum class QKnxSecureKey::Type
Describes the types of keys QKnxSecureKey supports.
Constant | Value | Description |
---|---|---|
QKnxSecureKey::Type::Private | 0 | A private key. |
QKnxSecureKey::Type::Public | 1 | A public key. |
QKnxSecureKey::Type::Invalid | 2 | An invalid key, please do not use. |
Member Function Documentation
QKnxSecureKey::QKnxSecureKey(const QKnxSecureKey &other)
Constructs a copy of other.
QKnxSecureKey::QKnxSecureKey()
Constructs an empty invalid secure key.
QKnxSecureKey &QKnxSecureKey::operator=(const QKnxSecureKey &other)
Assigns the specified other to this object.
QKnxSecureKey::~QKnxSecureKey()
Destroys the secure key and releases all allocated resources.
QKnxByteArray QKnxSecureKey::bytes() const
Returns an array of bytes that represent the Curve25519 raw secure key.
Note: The function will return an empty byte array for the private key unless OpenSLL with version 1.1.1a is used as back-end.
[static]
QKnxSecureKey QKnxSecureKey::fromBytes(QKnxSecureKey::Type type, const QKnxByteArray &data, quint16 index = 0)
Constructs the Curve25519 secure key from the byte array data starting at position index inside the array and sets the key type to type if OpenSSL is available and no error occurs; otherwise returns a default-constructed key which can be invalid.
[static]
void QKnxSecureKey::generateKeys(QKnxSecureKey *privateKey, QKnxSecureKey *publicKey)
Sets privateKey to a new valid private key and publicKey to a new valid public key derived from the freshly generated private key if OpenSSL is available and no error occurs.
[static]
QKnxSecureKey QKnxSecureKey::generatePrivateKey()
Returns a new valid private key if OpenSSL is available and no error occurs.
bool QKnxSecureKey::isNull() const
Returns true
if this is a default constructed secure key; otherwise returns false
. A secure key is considered null
if it contains no initialized values.
bool QKnxSecureKey::isValid() const
Returns true
if OpenSSL is available and if the key contains initialized values, otherwise returns false
.
[static]
QKnxSecureKey QKnxSecureKey::publicKeyFromPrivate(const QKnxSecureKey &privateKey)
Returns a new valid public key with the given private key privateKey if OpenSSL is available and no error occurs.
[static]
QKnxSecureKey QKnxSecureKey::publicKeyFromPrivate(const QKnxByteArray &privateKey)
This function overloads publicKeyFromPrivate().
[static]
QKnxByteArray QKnxSecureKey::sharedSecret(const QKnxSecureKey &privateKey, const QKnxSecureKey &peerPublicKey)
Derives and returns the shared secret from the given private key privateKey and the peer's public key peerPublicKey if OpenSSL is available and no error occurs; otherwise returns a default-constructed value which can be empty.
[static]
QKnxByteArray QKnxSecureKey::sharedSecret(const QKnxByteArray &privateKey, const QKnxByteArray &peerPublicKey)
This function overloads sharedSecret().
QKnxSecureKey::Type QKnxSecureKey::type() const
Returns the type of the key: Public or Private.
bool QKnxSecureKey::operator!=(const QKnxSecureKey &other) const
Returns true
if this key and the given other key are not equal; otherwise returns false
.
bool QKnxSecureKey::operator==(const QKnxSecureKey &other) const
Returns true
if this key and the given other key are equal; otherwise returns false
.
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.