From 1446142b60b17cfa47008ba9514f134b07cf0080 Mon Sep 17 00:00:00 2001 From: paul-szczepanek-arm <33840200+paul-szczepanek-arm@users.noreply.github.com> Date: Tue, 6 Feb 2018 21:50:57 +0000 Subject: [PATCH] ltk for secure connections --- .../ble/generic/GenericSecurityManager.h | 5 +++++ features/FEATURE_BLE/ble/pal/PalSecurityManager.h | 12 ++++++++++++ .../source/generic/GenericSecurityManager.cpp | 15 +++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/features/FEATURE_BLE/ble/generic/GenericSecurityManager.h b/features/FEATURE_BLE/ble/generic/GenericSecurityManager.h index 42b4ebb93a..27ea717eae 100644 --- a/features/FEATURE_BLE/ble/generic/GenericSecurityManager.h +++ b/features/FEATURE_BLE/ble/generic/GenericSecurityManager.h @@ -387,6 +387,11 @@ public: // Keys // + virtual void on_secure_connections_ltk_generated( + connection_handle_t connection, + const ltk_t *ltk + ); + virtual void on_keys_distributed( connection_handle_t connection, advertising_peer_address_type_t peer_address_type, diff --git a/features/FEATURE_BLE/ble/pal/PalSecurityManager.h b/features/FEATURE_BLE/ble/pal/PalSecurityManager.h index 605907f57c..ff7ae9533b 100644 --- a/features/FEATURE_BLE/ble/pal/PalSecurityManager.h +++ b/features/FEATURE_BLE/ble/pal/PalSecurityManager.h @@ -366,6 +366,18 @@ public: // Keys // + /** + * Store the results of key generation of the stage 2 of secure connections pairing + * @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part H - 2.3.5.6.5 + * + * @param[in] connection connection handle + * @param[in] ltk long term key from the peer + */ + virtual void on_secure_connections_ltk_generated( + connection_handle_t connection, + const ltk_t *ltk + ) = 0; + /** * Store the results of key distribution after all the keys have been received. * diff --git a/features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp b/features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp index a453a2d094..2a6bdec568 100644 --- a/features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp +++ b/features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp @@ -801,6 +801,21 @@ void GenericSecurityManager::on_oob_request(connection_handle_t connection) { // Keys // +void GenericSecurityManager::on_secure_connections_ltk_generated( + connection_handle_t connection, + const ltk_t *ltk +) { + SecurityEntry_t *entry = _db.get_entry(connection); + if (!entry) { + return; + } + + entry->mitm_ltk = entry->mitm_performed; + entry->secure_connections = true; + + _db.set_entry_peer_ltk(connection, ltk); +} + void GenericSecurityManager::on_keys_distributed( connection_handle_t connection, advertising_peer_address_type_t peer_address_type,