Merge "Bluetooth: Fix redundant encryption when receiving Security Request"
This commit is contained in:
commit
bf5bec39f4
|
@ -730,16 +730,36 @@ static u8 smp_ltk_encrypt(struct l2cap_conn *conn, u8 sec_level)
|
|||
return 1;
|
||||
|
||||
}
|
||||
bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level)
|
||||
{
|
||||
if (sec_level == BT_SECURITY_LOW) {
|
||||
BT_INFO("TRUE:(sec_level == BT_SECURITY_LOW)");
|
||||
return true;
|
||||
}
|
||||
if (hcon->sec_level >= sec_level) {
|
||||
BT_INFO("TRUE:(hcon->sec_level >= sec_level)");
|
||||
return true;
|
||||
}
|
||||
BT_INFO("return false");
|
||||
return false;
|
||||
}
|
||||
|
||||
static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
|
||||
{
|
||||
struct smp_cmd_security_req *rp = (void *) skb->data;
|
||||
struct smp_cmd_pairing cp;
|
||||
struct hci_conn *hcon = conn->hcon;
|
||||
struct smp_chan *smp;
|
||||
u8 sec_level;
|
||||
|
||||
BT_DBG("conn %p", conn);
|
||||
|
||||
hcon->pending_sec_level = authreq_to_seclevel(rp->auth_req);
|
||||
sec_level = authreq_to_seclevel(rp->auth_req);
|
||||
if (smp_sufficient_security(hcon, sec_level))
|
||||
return 0;
|
||||
|
||||
if (sec_level > hcon->pending_sec_level)
|
||||
hcon->pending_sec_level = sec_level;
|
||||
|
||||
if (smp_ltk_encrypt(conn, hcon->pending_sec_level))
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue