Skip to content

Commit 79db2af

Browse files
committed
BLE - Cordio PAL SM: Choose correct security level in set_ltk
1 parent 4858388 commit 79db2af

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalSecurityManager.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,19 @@ ble_error_t CordioSecurityManager::set_ltk(
210210
bool mitm,
211211
bool secure_connections
212212
) {
213-
// FIXME: get access to the security level of a key
213+
uint8_t security_level = DM_SEC_LEVEL_NONE;
214+
if (secure_connections) {
215+
security_level = DM_SEC_LEVEL_ENC_LESC;
216+
} else if(mitm) {
217+
security_level = DM_SEC_LEVEL_ENC_AUTH;
218+
} else {
219+
security_level = DM_SEC_LEVEL_ENC;
220+
}
221+
214222
DmSecLtkRsp(
215223
connection,
216224
/* key found */ true,
217-
/* sec level ??? */ DM_SEC_LEVEL_ENC_AUTH,
225+
/* sec level */ security_level,
218226
const_cast<uint8_t*>(ltk.data())
219227
);
220228
return BLE_ERROR_NONE;
@@ -226,7 +234,7 @@ ble_error_t CordioSecurityManager::set_ltk_not_found(
226234
DmSecLtkRsp(
227235
connection,
228236
/* key found */ false,
229-
/* sec level ??? */ DM_SEC_LEVEL_NONE,
237+
/* sec level */ DM_SEC_LEVEL_NONE,
230238
NULL
231239
);
232240

0 commit comments

Comments
 (0)