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>
This commit is contained in:
Lyle Zhu 2025-04-24 21:22:27 +08:00 committed by Benjamin Cabé
commit 0b0cfd5ec7
2 changed files with 13 additions and 0 deletions

View file

@ -248,10 +248,20 @@ static void ssp_pairing_complete(struct bt_conn *conn, uint8_t status)
}
}
#define BR_SSP_AUTH_MITM_DISABLED(auth) (((auth) & BT_MITM) == 0)
static void ssp_auth(struct bt_conn *conn, uint32_t passkey)
{
conn->br.pairing_method = ssp_pair_method(conn);
if (BR_SSP_AUTH_MITM_DISABLED(conn->br.local_auth) &&
BR_SSP_AUTH_MITM_DISABLED(conn->br.remote_auth)) {
/*
* If the MITM flag of both sides is false, the pairing method is `just works`.
*/
conn->br.pairing_method = JUST_WORKS;
}
/*
* If local required security is HIGH then MITM is mandatory.
* MITM protection is no achievable when SSP 'justworks' is applied.
@ -757,6 +767,8 @@ void bt_hci_io_capa_req(struct net_buf *buf)
auth = BT_HCI_SET_NO_BONDING(auth);
}
conn->br.local_auth = auth;
resp_buf = bt_hci_cmd_create(BT_HCI_OP_IO_CAPABILITY_REPLY, sizeof(*cp));
if (!resp_buf) {
LOG_ERR("Out of command buffers");

View file

@ -150,6 +150,7 @@ struct bt_conn_br {
bt_addr_t dst;
uint8_t remote_io_capa;
uint8_t remote_auth;
uint8_t local_auth;
uint8_t pairing_method;
/* remote LMP features pages per 8 bytes each */
uint8_t features[LMP_MAX_PAGES][8];