diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2019-03-28 15:29:45 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2019-03-29 11:54:35 +0000 |
commit | e6aeb990e3a6ec1aa936bdc81109d86da6840949 (patch) | |
tree | 77bb90a3dff4d7020285eb68cb43b6bae652dfe0 | |
parent | a30bbcd960f5bc435b883db4e25e7c8250d88cad (diff) |
Fix missing host information for secure configurations
We can gather that field while importing a ETS keyring file and
it can help GUI applications to filter or visualize which KNX
secure device this configuration can target.
Change-Id: Ia9d902f1e06557ea630d560668f6876c9febe80c
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
-rw-r--r-- | src/knx/netip/qknxnetipsecureconfiguration.cpp | 25 | ||||
-rw-r--r-- | src/knx/netip/qknxnetipsecureconfiguration.h | 3 | ||||
-rw-r--r-- | src/knx/netip/qknxnetipsecureconfiguration_p.h | 1 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/knx/netip/qknxnetipsecureconfiguration.cpp b/src/knx/netip/qknxnetipsecureconfiguration.cpp index eacfd4d..6a75fdb 100644 --- a/src/knx/netip/qknxnetipsecureconfiguration.cpp +++ b/src/knx/netip/qknxnetipsecureconfiguration.cpp @@ -45,6 +45,7 @@ namespace QKnxPrivate QKnxNetIpSecureConfiguration s; s.setUserId(QKnxNetIp::SecureUserId(iface.UserID)); s.setPrivateKey(QKnxSecureKey::generatePrivateKey()); + s.setHost({ QKnxAddress::Type::Individual, iface.Host }); s.setUserPassword(QKnxCryptographicEngine::decodeAndDecryptPassword(pwHash, createdHash, iface.Password).toByteArray()); s.setIndividualAddress({ QKnxAddress::Type::Individual, iface.IndividualAddress }); @@ -59,6 +60,7 @@ namespace QKnxPrivate QKnxNetIpSecureConfiguration s; s.setUserId(QKnxNetIp::SecureUserId::Management); s.setPrivateKey(QKnxSecureKey::generatePrivateKey()); + s.setHost({ QKnxAddress::Type::Individual, device.IndividualAddress }); s.setUserPassword(QKnxCryptographicEngine::decodeAndDecryptPassword(pwHash, createdHash, device.ManagementPassword).toByteArray()); s.setIndividualAddress({ QKnxAddress::Type::Individual, device.IndividualAddress }); @@ -236,6 +238,28 @@ bool QKnxNetIpSecureConfiguration::isValid() const } /*! + Returns the host address of the secure KNX device this secure configuration + targets. The host address can be empty and is not required to establish a + secure session. + + The purpose of this field is more to help GUI applications to indicate + which KNX secure device can be used with this secure configuration. +*/ +QKnxAddress QKnxNetIpSecureConfiguration::host() const +{ + return d->host; +} + +/*! + Sets the secure configurations host address to \a hostAddress. The host + address can be empty and is not required to establish a secure session. +*/ +void QKnxNetIpSecureConfiguration::setHost(const QKnxAddress &hostAddress) +{ + d->host = hostAddress; +} + +/*! Returns the public \l {QKnxSecureKey} {secure key} used to establish the secure session. The public key is derived from the given private key. */ @@ -427,6 +451,7 @@ void QKnxNetIpSecureConfiguration::swap(QKnxNetIpSecureConfiguration &other) Q_D bool QKnxNetIpSecureConfiguration::operator==(const QKnxNetIpSecureConfiguration &other) const { return d == other.d || (d->privateKey == other.d->privateKey + && d->host == other.d->host && d->userId == other.d->userId && d->userPassword == other.d->userPassword && d->ia == other.d->ia diff --git a/src/knx/netip/qknxnetipsecureconfiguration.h b/src/knx/netip/qknxnetipsecureconfiguration.h index a7125d3..72b136a 100644 --- a/src/knx/netip/qknxnetipsecureconfiguration.h +++ b/src/knx/netip/qknxnetipsecureconfiguration.h @@ -62,6 +62,9 @@ public: QKnxSecureKey publicKey() const; + QKnxAddress host() const; + void setHost(const QKnxAddress &host); + QKnxSecureKey privateKey() const; bool setPrivateKey(const QKnxSecureKey &key); diff --git a/src/knx/netip/qknxnetipsecureconfiguration_p.h b/src/knx/netip/qknxnetipsecureconfiguration_p.h index c56dd1e..1cdbd3f 100644 --- a/src/knx/netip/qknxnetipsecureconfiguration_p.h +++ b/src/knx/netip/qknxnetipsecureconfiguration_p.h @@ -55,6 +55,7 @@ public: QKnxSecureKey privateKey; QKnxSecureKey publicKey; + QKnxAddress host; QKnxNetIp::SecureUserId userId { QKnxNetIp::SecureUserId::Reserved }; QByteArray userPassword; QKnxAddress ia; |