Skip to content

Commit da6ede3

Browse files
committed
BLE - Cordio PAL SM: Select correct on_ltk_request overload.
1 parent 628ffea commit da6ede3

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,21 @@ bool CordioSecurityManager::sm_handler(const wsfMsgHdr_t* msg) {
552552
}
553553

554554
case DM_SEC_LTK_REQ_IND: {
555+
uint8_t null_rand[HCI_RAND_LEN] = { 0 };
555556
hciLeLtkReqEvt_t* evt = (hciLeLtkReqEvt_t*) msg;
556-
handler->on_ltk_request(
557-
evt->hdr.param,
558-
reinterpret_cast<uint8_t*>(&evt->encDiversifier),
559-
evt->randNum
560-
);
557+
558+
if (evt->encDiversifier == 0 &&
559+
memcmp(evt->randNum, null_rand, sizeof(null_rand))) {
560+
handler->on_ltk_request(
561+
evt->hdr.param
562+
);
563+
} else {
564+
handler->on_ltk_request(
565+
evt->hdr.param,
566+
reinterpret_cast<uint8_t*>(&evt->encDiversifier),
567+
evt->randNum
568+
);
569+
}
561570
return true;
562571
}
563572

0 commit comments

Comments
 (0)