linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/12] Bluetooth: Add automated SSP user confirmation responses
@ 2011-04-28 18:28 johan.hedberg
  2011-04-28 18:28 ` [PATCH 02/12] Bluetooth: Add variable SSP auto-accept delay support johan.hedberg
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: johan.hedberg @ 2011-04-28 18:28 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@nokia.com>

This patch adds automated negative and positive (auto-accept) responses
for Secure Simple Pairing user confirmation requests. The responses are
only sent if the HCI_MGMT flag is set in order not to confuse older user
space versions (without management interface support).

Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
---
 net/bluetooth/hci_event.c |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 577d638..514e10e 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2483,14 +2483,47 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev,
 							struct sk_buff *skb)
 {
 	struct hci_ev_user_confirm_req *ev = (void *) skb->data;
+	int loc_mitm, rem_mitm;
+	struct hci_conn *conn;
 
 	BT_DBG("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
-	if (test_bit(HCI_MGMT, &hdev->flags))
-		mgmt_user_confirm_request(hdev->id, &ev->bdaddr, ev->passkey);
+	if (!test_bit(HCI_MGMT, &hdev->flags))
+		goto unlock;
 
+	conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
+	if (!conn)
+		goto unlock;
+
+	loc_mitm = (conn->auth_type & 0x01);
+	rem_mitm = (conn->remote_auth & 0x01);
+
+	/* If we require MITM but the remote device can't provide that
+	 * (it has NoInputNoOutput) then reject the confirmation
+	 * request. The only exception is when we're dedicated bonding
+	 * initiators (connect_cfm_cb set) since then we always have the MITM
+	 * bit set. */
+	if (!conn->connect_cfm_cb && loc_mitm && conn->remote_cap == 0x03) {
+		BT_DBG("Rejecting request: remote device can't provide MITM");
+		hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY,
+					sizeof(ev->bdaddr), &ev->bdaddr);
+		goto unlock;
+	}
+
+	/* If no side requires MITM protection; auto-accept */
+	if ((!loc_mitm || conn->remote_cap == 0x03) &&
+				(!rem_mitm || conn->io_capability == 0x03)) {
+		BT_DBG("Auto-accept of user confirmation");
+		hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY,
+						sizeof(ev->bdaddr), &ev->bdaddr);
+		goto unlock;
+	}
+
+	mgmt_user_confirm_request(hdev->id, &ev->bdaddr, ev->passkey);
+
+unlock:
 	hci_dev_unlock(hdev);
 }
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-04-28 19:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-28 18:28 [PATCH 01/12] Bluetooth: Add automated SSP user confirmation responses johan.hedberg
2011-04-28 18:28 ` [PATCH 02/12] Bluetooth: Add variable SSP auto-accept delay support johan.hedberg
2011-04-28 18:28 ` [PATCH 03/12] Bluetooth: Fix HCI_CONN_AUTH_PEND flag for all authentication requests johan.hedberg
2011-04-28 18:28 ` [PATCH 04/12] Bluetooth: Add confirm_hint parameter to user confirmation requests johan.hedberg
2011-04-28 18:28 ` [PATCH 05/12] Bluetooth: Fix reason code for pairing rejection johan.hedberg
2011-04-28 18:28 ` [PATCH 06/12] Bluetooth: Fix logic in hci_pin_code_request_evt johan.hedberg
2011-04-28 18:28 ` [PATCH 07/12] Bluetooth: Fix link key persistent storage criteria johan.hedberg
2011-04-28 18:29 ` [PATCH 08/12] Bluetooth: Fix old_key_type logic for non-persistent keys johan.hedberg
2011-04-28 18:29 ` [PATCH 09/12] Bluetooth: Fix connection key type updating for buggy controllers johan.hedberg
2011-04-28 18:29 ` [PATCH 10/12] Bluetooth: Remove old_key_type from mgmt_ev_new_key johan.hedberg
2011-04-28 18:29 ` [PATCH 11/12] Bluetooth: Add store_hint parameter to mgmt_new_key johan.hedberg
2011-04-28 18:29 ` [PATCH 12/12] Bluetooth: Fix updating conn->auth_type in hci_io_capa_request_evt johan.hedberg
2011-04-28 19:18   ` Gustavo F. Padovan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).