Skip to content

Commit 965dcc6

Browse files
committed
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 <lyle.zhu@nxp.com>
1 parent bf104d4 commit 965dcc6

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

subsys/bluetooth/host/classic/ssp.c

+12
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.
@@ -738,6 +748,8 @@ void bt_hci_io_capa_req(struct net_buf *buf)
738748
auth = BT_HCI_SET_NO_BONDING(auth);
739749
}
740750

751+
conn->br.local_auth = auth;
752+
741753
resp_buf = bt_hci_cmd_create(BT_HCI_OP_IO_CAPABILITY_REPLY, sizeof(*cp));
742754
if (!resp_buf) {
743755
LOG_ERR("Out of command buffers");

subsys/bluetooth/host/conn_internal.h

+1
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)