From 79db2af488d7f68573c9356b901a9535d3a02b04 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Thu, 1 Mar 2018 14:53:00 +0000 Subject: [PATCH] BLE - Cordio PAL SM: Choose correct security level in set_ltk --- .../source/CordioPalSecurityManager.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalSecurityManager.cpp b/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalSecurityManager.cpp index f7e7f3028a..3c0abe798e 100644 --- a/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalSecurityManager.cpp +++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalSecurityManager.cpp @@ -210,11 +210,19 @@ ble_error_t CordioSecurityManager::set_ltk( bool mitm, bool secure_connections ) { - // FIXME: get access to the security level of a key + uint8_t security_level = DM_SEC_LEVEL_NONE; + if (secure_connections) { + security_level = DM_SEC_LEVEL_ENC_LESC; + } else if(mitm) { + security_level = DM_SEC_LEVEL_ENC_AUTH; + } else { + security_level = DM_SEC_LEVEL_ENC; + } + DmSecLtkRsp( connection, /* key found */ true, - /* sec level ??? */ DM_SEC_LEVEL_ENC_AUTH, + /* sec level */ security_level, const_cast(ltk.data()) ); return BLE_ERROR_NONE; @@ -226,7 +234,7 @@ ble_error_t CordioSecurityManager::set_ltk_not_found( DmSecLtkRsp( connection, /* key found */ false, - /* sec level ??? */ DM_SEC_LEVEL_NONE, + /* sec level */ DM_SEC_LEVEL_NONE, NULL );