Bluetooth: BR/EDR: Reset pairing context when needed
When pairing procedure ends regardless of the status, reset flags strictly related to pairing phase and reset security level. Thanks that next authentication will get known initial pairing 'context'. Change-Id: Ie3108c6e28e136ea929e564a6820675cc770cb95 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
22ac4fd13e
commit
bc5497f239
1 changed files with 20 additions and 13 deletions
|
@ -931,6 +931,16 @@ static int set_flow_control(void)
|
|||
#endif /* CONFIG_BLUETOOTH_CONN */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_BREDR)
|
||||
static void reset_pairing(struct bt_conn *conn)
|
||||
{
|
||||
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING);
|
||||
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING_INITIATOR);
|
||||
atomic_clear_bit(conn->flags, BT_CONN_BR_LEGACY_SECURE);
|
||||
|
||||
/* Reset required security level to current operational */
|
||||
conn->required_sec_level = conn->sec_level;
|
||||
}
|
||||
|
||||
static int reject_conn(const bt_addr_t *bdaddr, uint8_t reason)
|
||||
{
|
||||
struct bt_hci_cp_reject_conn_req *cp;
|
||||
|
@ -1711,15 +1721,7 @@ static void auth_complete(struct net_buf *buf)
|
|||
}
|
||||
|
||||
if (evt->status) {
|
||||
/*
|
||||
* Clear pairing flag since authentication failed for some
|
||||
* reasons.
|
||||
*/
|
||||
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING);
|
||||
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING_INITIATOR);
|
||||
|
||||
/* Reset required security level to current operational */
|
||||
conn->required_sec_level = conn->sec_level;
|
||||
reset_pairing(conn);
|
||||
} else {
|
||||
link_encr(handle);
|
||||
}
|
||||
|
@ -1770,8 +1772,14 @@ static void hci_encrypt_change(struct net_buf *buf)
|
|||
|
||||
if (evt->status) {
|
||||
/* TODO report error */
|
||||
/* reset required security level in case of error */
|
||||
conn->required_sec_level = conn->sec_level;
|
||||
if (conn->type == BT_CONN_TYPE_LE) {
|
||||
/* reset required security level in case of error */
|
||||
conn->required_sec_level = conn->sec_level;
|
||||
#if defined(CONFIG_BLUETOOTH_BREDR)
|
||||
} else {
|
||||
reset_pairing(conn);
|
||||
#endif /* CONFIG_BLUETOOTH_BREDR */
|
||||
}
|
||||
bt_conn_unref(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1795,8 +1803,7 @@ static void hci_encrypt_change(struct net_buf *buf)
|
|||
#if defined(CONFIG_BLUETOOTH_BREDR)
|
||||
} else {
|
||||
update_sec_level_br(conn);
|
||||
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING);
|
||||
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING_INITIATOR);
|
||||
reset_pairing(conn);
|
||||
#endif /* CONFIG_BLUETOOTH_BREDR */
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue