Skip to content

Commit 7df39dd

Browse files
committed
lib: peer_manager: associate peer_id after repairing check if dup bond
If duplicate bonding data is found in auth_status_success_process(), first check if repairing is allowed before associating the peer_id with the connection handle. If repairing is not allowed, then the peer_id should not be associated with the connection handle. Signed-off-by: Andreas Moltumyr <andreas.moltumyr@nordicsemi.no>
1 parent fb41975 commit 7df39dd

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

doc/nrf-bm/release_notes/release_notes_changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ Libraries
143143
* The LESC key agreement handling to clear the static RAM copy of the ECDH shared secret after the secret have been handed over to the SoftDevice using the :c:func:`sd_ble_gap_lesc_dhkey_reply` function.
144144
* The :kconfig:option:`CONFIG_PM_LESC_GENERATE_NEW_KEYS` Kconfig option to be enabled by default.
145145
This option forces the use of new ECDH key pair for each pairing procedure.
146+
* The sources of the :c:enumerator:`PM_EVT_CONN_SEC_CONFIG_REQ` event to fill the peer ID field.
147+
The value of the peer ID field should be used instead of calling the :c:func:`pm_peer_id_get` function when handling this event.
146148

147149
* Fixed:
148150

lib/bluetooth/peer_manager/modules/security_dispatcher.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,15 @@ static void sec_info_request_process(const ble_gap_evt_t *gap_evt)
465465
*
466466
* @param[in] conn_handle The connection the sec parameters are needed for.
467467
*/
468-
static void send_config_req(uint16_t conn_handle)
468+
static void send_config_req(uint16_t conn_handle, uint16_t peer_id)
469469
{
470470
struct pm_evt evt;
471471

472472
memset(&evt, 0, sizeof(evt));
473473

474474
evt.evt_id = PM_EVT_CONN_SEC_CONFIG_REQ;
475475
evt.conn_handle = conn_handle;
476+
evt.peer_id = peer_id;
476477

477478
evt_send(&evt);
478479
}
@@ -603,17 +604,17 @@ static void auth_status_success_process(const ble_gap_evt_t *gap_evt)
603604
PM_PEER_ID_INVALID);
604605

605606
if (peer_id != PM_PEER_ID_INVALID) {
606-
/* The peer has been identified as someone we have already bonded with. */
607-
im_new_peer_id(conn_handle, peer_id);
608-
609607
/* If the flag is true, the configuration has been requested before. */
610608
if (!allow_repairing(conn_handle)) {
611-
send_config_req(conn_handle);
609+
send_config_req(conn_handle, peer_id);
612610
if (!allow_repairing(conn_handle)) {
613611
pairing_success_evt_send(gap_evt, false);
614612
return;
615613
}
616614
}
615+
616+
/* The peer has been identified as someone we have already bonded with. */
617+
im_new_peer_id(conn_handle, peer_id);
617618
}
618619
}
619620

@@ -820,9 +821,10 @@ uint32_t smd_params_reply(uint16_t conn_handle, ble_gap_sec_params_t *sec_params
820821
{
821822
__ASSERT_NO_MSG(module_initialized);
822823

823-
uint8_t role = pm_conn_state_role(conn_handle);
824824
uint32_t nrf_err = NRF_SUCCESS;
825+
uint8_t role = pm_conn_state_role(conn_handle);
825826
uint8_t sec_status = BLE_GAP_SEC_STATUS_SUCCESS;
827+
uint16_t peer_id;
826828
ble_gap_sec_keyset_t sec_keyset;
827829

828830
memset(&sec_keyset, 0, sizeof(ble_gap_sec_keyset_t));
@@ -850,12 +852,13 @@ uint32_t smd_params_reply(uint16_t conn_handle, ble_gap_sec_params_t *sec_params
850852
sec_status = BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP;
851853
} else {
852854
#if defined(CONFIG_SOFTDEVICE_PERIPHERAL)
853-
if ((im_peer_id_get_by_conn_handle(conn_handle) != PM_PEER_ID_INVALID) &&
854-
(role == BLE_GAP_ROLE_PERIPH) && !allow_repairing(conn_handle)) {
855+
peer_id = im_peer_id_get_by_conn_handle(conn_handle);
856+
if ((peer_id != PM_PEER_ID_INVALID) && (role == BLE_GAP_ROLE_PERIPH) &&
857+
!allow_repairing(conn_handle)) {
855858
/* Bond already exists. Reject the pairing request if the user
856859
* doesn't intervene.
857860
*/
858-
send_config_req(conn_handle);
861+
send_config_req(conn_handle, peer_id);
859862
if (!allow_repairing(conn_handle)) {
860863
/* Reject pairing. */
861864
sec_status = BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP;

0 commit comments

Comments
 (0)