mirror of https://github.com/ARMmbed/mbed-os.git
call the correct ltk function when SC is used
parent
8292affb53
commit
fbb926d77e
|
@ -846,11 +846,19 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
|
|||
const ble_gap_evt_sec_info_request_t& req =
|
||||
gap_evt.params.sec_info_request;
|
||||
|
||||
handler->on_ltk_request(
|
||||
connection,
|
||||
ediv_t((uint8_t*)(&req.master_id.ediv)),
|
||||
rand_t(req.master_id.rand)
|
||||
);
|
||||
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(
|
||||
connection,
|
||||
ediv_t((uint8_t*)(&req.master_id.ediv)),
|
||||
rand_t(req.master_id.rand)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -948,34 +956,41 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
|
|||
peer_dist = pairing_cb->initiator_dist;
|
||||
}
|
||||
|
||||
if (own_dist.get_encryption()) {
|
||||
handler->on_keys_distributed_local_ltk(
|
||||
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()) {
|
||||
handler->on_keys_distributed_local_ltk(
|
||||
connection,
|
||||
ltk_t(pairing_cb->own_enc_key.enc_info.ltk)
|
||||
);
|
||||
|
||||
handler->on_keys_distributed_local_ediv_rand(
|
||||
connection,
|
||||
ediv_t(reinterpret_cast<uint8_t*>(
|
||||
&pairing_cb->own_enc_key.master_id.ediv
|
||||
)),
|
||||
pairing_cb->own_enc_key.master_id.rand
|
||||
);
|
||||
}
|
||||
handler->on_keys_distributed_local_ediv_rand(
|
||||
connection,
|
||||
ediv_t(reinterpret_cast<uint8_t*>(
|
||||
&pairing_cb->own_enc_key.master_id.ediv
|
||||
)),
|
||||
pairing_cb->own_enc_key.master_id.rand
|
||||
);
|
||||
}
|
||||
|
||||
if (peer_dist.get_encryption()) {
|
||||
handler->on_keys_distributed_ltk(
|
||||
connection,
|
||||
ltk_t(pairing_cb->peer_enc_key.enc_info.ltk)
|
||||
);
|
||||
if (peer_dist.get_encryption()) {
|
||||
handler->on_keys_distributed_ltk(
|
||||
connection,
|
||||
ltk_t(pairing_cb->peer_enc_key.enc_info.ltk)
|
||||
);
|
||||
|
||||
handler->on_keys_distributed_ediv_rand(
|
||||
connection,
|
||||
ediv_t(reinterpret_cast<uint8_t*>(
|
||||
&pairing_cb->peer_enc_key.master_id.ediv
|
||||
)),
|
||||
pairing_cb->peer_enc_key.master_id.rand
|
||||
);
|
||||
handler->on_keys_distributed_ediv_rand(
|
||||
connection,
|
||||
ediv_t(reinterpret_cast<uint8_t*>(
|
||||
&pairing_cb->peer_enc_key.master_id.ediv
|
||||
)),
|
||||
pairing_cb->peer_enc_key.master_id.rand
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (peer_dist.get_identity()) {
|
||||
|
|
Loading…
Reference in New Issue