diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2016-01-19 18:06:24 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2016-02-03 11:30:29 +0000 |
commit | c516f6157a35fbabcd204dd628a301734fc76f1a (patch) | |
tree | 1533a040e7e99e38d60ef050febef54e47761573 /src/bluetooth/qlowenergycontroller_p.h | |
parent | 92c7a1c5716d47b1e33e5dfbbe3ea89f0557aca5 (diff) |
Bluetooth LE: Add support for Signed Write command.
- This is how we get at the signature resolving key:
1) On connection from a client, we read the key from the
respective BlueZ settings file (BlueZ 5 only, as I did
not manage to find out where BlueZ 4 keeps this information).
2) Also monitor the HCI traffic for key updates (due to re-pairing).
- While there is an autotest for the actual hashing procedure, the
overall feature cannot be easily tested for various reasons (there is
no signed write support in our client API, for one). However, to help
with manual testing, the server part of our autotest now exposes a
characteristic that supports signed writes.
- This feature requires a Linux kernel >= 3.7.
Change-Id: I7ede9b430de167fe1f4519eedf8670d88d79aa25
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_p.h')
-rw-r--r-- | src/bluetooth/qlowenergycontroller_p.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bluetooth/qlowenergycontroller_p.h b/src/bluetooth/qlowenergycontroller_p.h index 095f838f..51ea5a83 100644 --- a/src/bluetooth/qlowenergycontroller_p.h +++ b/src/bluetooth/qlowenergycontroller_p.h @@ -92,6 +92,7 @@ class QLowEnergyServiceData; #if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE) class HciManager; +class LeCmacVerifier; class QSocketNotifier; #elif defined(QT_ANDROID_BLUETOOTH) class LowEnergyNotificationHub; @@ -248,6 +249,17 @@ private: }; QHash<quint64, QVector<ClientConfigurationData>> clientConfigData; + struct SigningData { + SigningData() = default; + SigningData(const quint128 &csrk, quint32 signCounter = quint32(-1)) + : key(csrk), counter(signCounter) {} + + quint128 key; + quint32 counter = quint32(-1); + }; + QHash<quint64, SigningData> signingData; + LeCmacVerifier *cmacVerifier = nullptr; + bool requestPending; quint16 mtuSize; int securityLevelValue; @@ -265,6 +277,9 @@ private: QVector<TempClientConfigurationData> gatherClientConfigData(); void storeClientConfigurations(); void restoreClientConfigurations(); + void loadSigningDataIfNecessary(); + void storeSignCounter(); + QString keySettingsFilePath() const; void sendPacket(const QByteArray &packet); void sendNextPendingRequest(); @@ -339,6 +354,9 @@ private: int checkReadPermissions(const Attribute &attr); int checkReadPermissions(QVector<Attribute> &attributes); + bool verifyMac(const QByteArray &message, const quint128 &csrk, quint32 signCounter, + quint64 expectedMac); + void updateLocalAttributeValue( QLowEnergyHandle handle, const QByteArray &value, |