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 =
|
const ble_gap_evt_sec_info_request_t& req =
|
||||||
gap_evt.params.sec_info_request;
|
gap_evt.params.sec_info_request;
|
||||||
|
|
||||||
handler->on_ltk_request(
|
uint8_t invalid_rand[BLE_GAP_SEC_RAND_LEN] = { 0 };
|
||||||
connection,
|
if (req.master_id.ediv == 0 &&
|
||||||
ediv_t((uint8_t*)(&req.master_id.ediv)),
|
memcmp(req.master_id.rand, invalid_rand, sizeof(invalid_rand) == 0)
|
||||||
rand_t(req.master_id.rand)
|
) {
|
||||||
);
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -948,34 +956,41 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
|
||||||
peer_dist = pairing_cb->initiator_dist;
|
peer_dist = pairing_cb->initiator_dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (own_dist.get_encryption()) {
|
if (status.lesc) {
|
||||||
handler->on_keys_distributed_local_ltk(
|
handler->on_secure_connections_ltk_generated(
|
||||||
connection,
|
connection,
|
||||||
ltk_t(pairing_cb->own_enc_key.enc_info.ltk)
|
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(
|
handler->on_keys_distributed_local_ediv_rand(
|
||||||
connection,
|
connection,
|
||||||
ediv_t(reinterpret_cast<uint8_t*>(
|
ediv_t(reinterpret_cast<uint8_t*>(
|
||||||
&pairing_cb->own_enc_key.master_id.ediv
|
&pairing_cb->own_enc_key.master_id.ediv
|
||||||
)),
|
)),
|
||||||
pairing_cb->own_enc_key.master_id.rand
|
pairing_cb->own_enc_key.master_id.rand
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer_dist.get_encryption()) {
|
if (peer_dist.get_encryption()) {
|
||||||
handler->on_keys_distributed_ltk(
|
handler->on_keys_distributed_ltk(
|
||||||
connection,
|
connection,
|
||||||
ltk_t(pairing_cb->peer_enc_key.enc_info.ltk)
|
ltk_t(pairing_cb->peer_enc_key.enc_info.ltk)
|
||||||
);
|
);
|
||||||
|
|
||||||
handler->on_keys_distributed_ediv_rand(
|
handler->on_keys_distributed_ediv_rand(
|
||||||
connection,
|
connection,
|
||||||
ediv_t(reinterpret_cast<uint8_t*>(
|
ediv_t(reinterpret_cast<uint8_t*>(
|
||||||
&pairing_cb->peer_enc_key.master_id.ediv
|
&pairing_cb->peer_enc_key.master_id.ediv
|
||||||
)),
|
)),
|
||||||
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()) {
|
||||||
|
|
Loading…
Reference in New Issue