Commit 0b0cfd5e authored by Lyle Zhu's avatar Lyle Zhu Committed by Benjamin Cabé
Browse files

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: default avatarLyle Zhu <lyle.zhu@nxp.com>
parent 31646fd0
Loading
Loading
Loading
Loading
+12 −0
Changes for subsys/bluetooth/host/classic/ssp.c: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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");
+1 −0
Changes for subsys/bluetooth/host/conn_internal.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -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];