Skip to content

Commit 0b0cfd5

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: Classic: SSP: Correct pairing method
In current implementation, if the MITM flag of both sides is disabled, the pairing method is incorrect. Such as, the IOCAP of both sides is `display_yesorno`, the pairing method is `PASSKEY_CONFIRM`. But actually, it should be `JUST_WORKS` in this case. Fix the issue by setting the pairing method to `JUST_WORKS` if the MITM flag of both sides is false. Signed-off-by: Lyle Zhu <[email protected]>
1 parent 31646fd commit 0b0cfd5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

subsys/bluetooth/host/classic/ssp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,20 @@ static void ssp_pairing_complete(struct bt_conn *conn, uint8_t status)
248248
}
249249
}
250250

251+
#define BR_SSP_AUTH_MITM_DISABLED(auth) (((auth) & BT_MITM) == 0)
252+
251253
static void ssp_auth(struct bt_conn *conn, uint32_t passkey)
252254
{
253255
conn->br.pairing_method = ssp_pair_method(conn);
254256

257+
if (BR_SSP_AUTH_MITM_DISABLED(conn->br.local_auth) &&
258+
BR_SSP_AUTH_MITM_DISABLED(conn->br.remote_auth)) {
259+
/*
260+
* If the MITM flag of both sides is false, the pairing method is `just works`.
261+
*/
262+
conn->br.pairing_method = JUST_WORKS;
263+
}
264+
255265
/*
256266
* If local required security is HIGH then MITM is mandatory.
257267
* MITM protection is no achievable when SSP 'justworks' is applied.
@@ -757,6 +767,8 @@ void bt_hci_io_capa_req(struct net_buf *buf)
757767
auth = BT_HCI_SET_NO_BONDING(auth);
758768
}
759769

770+
conn->br.local_auth = auth;
771+
760772
resp_buf = bt_hci_cmd_create(BT_HCI_OP_IO_CAPABILITY_REPLY, sizeof(*cp));
761773
if (!resp_buf) {
762774
LOG_ERR("Out of command buffers");

subsys/bluetooth/host/conn_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ struct bt_conn_br {
150150
bt_addr_t dst;
151151
uint8_t remote_io_capa;
152152
uint8_t remote_auth;
153+
uint8_t local_auth;
153154
uint8_t pairing_method;
154155
/* remote LMP features pages per 8 bytes each */
155156
uint8_t features[LMP_MAX_PAGES][8];

0 commit comments

Comments
 (0)