call the correct ltk function when SC is used

pull/7688/head
paul-szczepanek-arm 2018-08-03 15:28:41 +01:00
parent 8292affb53
commit fbb926d77e
1 changed files with 42 additions and 27 deletions

View File

@ -846,11 +846,19 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
const ble_gap_evt_sec_info_request_t& req = const ble_gap_evt_sec_info_request_t& req =
gap_evt.params.sec_info_request; gap_evt.params.sec_info_request;
uint8_t invalid_rand[BLE_GAP_SEC_RAND_LEN] = { 0 };
if (req.master_id.ediv == 0 &&
memcmp(req.master_id.rand, invalid_rand, sizeof(invalid_rand) == 0)
) {
// request ltk generated with secure connection
handler->on_ltk_request(connection);
} else {
handler->on_ltk_request( handler->on_ltk_request(
connection, connection,
ediv_t((uint8_t*)(&req.master_id.ediv)), ediv_t((uint8_t*)(&req.master_id.ediv)),
rand_t(req.master_id.rand) rand_t(req.master_id.rand)
); );
}
return true; return true;
} }
@ -948,6 +956,12 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
peer_dist = pairing_cb->initiator_dist; peer_dist = pairing_cb->initiator_dist;
} }
if (status.lesc) {
handler->on_secure_connections_ltk_generated(
connection,
ltk_t(pairing_cb->own_enc_key.enc_info.ltk)
);
} else {
if (own_dist.get_encryption()) { if (own_dist.get_encryption()) {
handler->on_keys_distributed_local_ltk( handler->on_keys_distributed_local_ltk(
connection, connection,
@ -977,6 +991,7 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
pairing_cb->peer_enc_key.master_id.rand pairing_cb->peer_enc_key.master_id.rand
); );
} }
}
if (peer_dist.get_identity()) { if (peer_dist.get_identity()) {
handler->on_keys_distributed_irk( handler->on_keys_distributed_irk(