Skip to contentSkip to conversation

Bluetooth: Do not include LE SC out-of-band data if not enabled

PATCH Superseded Marcel Holtmann 1 participant 1 message Mar 16, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 1/1 Bluetooth: Do not include LE SC out-of-band data if not enabled

In case LE Secure Connections is not enabled, then the command for returning local out-of-band data should not include the confirmation and random value for LE SC pairing. All other fields are still valid, but these two need to be left out. In that case it is also no needed to generate the public/private key pair for out-of-band pairing.

---
 net/bluetooth/mgmt.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
net/bluetooth/mgmt.c +17 -11
index 5322584460c1..9a85317cc016 100644
@@ -6327,13 +6327,15 @@ static int read_local_oob_ext_data(struct sock *sk, struct hci_dev *hdev,
 					  hdev->dev_class, 3);
 		break;
 	case (BIT(BDADDR_LE_PUBLIC) | BIT(BDADDR_LE_RANDOM)):
-		if (smp_generate_oob(hdev, hash, rand) < 0) {
-			hci_dev_unlock(hdev);
-			err = mgmt_cmd_complete(sk, hdev->id,
-					 MGMT_OP_READ_LOCAL_OOB_EXT_DATA,
-					 MGMT_STATUS_FAILED,
-					 &cp->type, sizeof(cp->type));
-			goto done;
+		if (hci_dev_test_flag(hdev, HCI_SC_ENABLED)) {
+			if (smp_generate_oob(hdev, hash, rand) < 0) {
+				hci_dev_unlock(hdev);
+				err = mgmt_cmd_complete(sk, hdev->id,
+						 MGMT_OP_READ_LOCAL_OOB_EXT_DATA,
+						 MGMT_STATUS_FAILED,
+						 &cp->type, sizeof(cp->type));
+				goto done;
+			}
 		}
 
 		if (hci_dev_test_flag(hdev, HCI_PRIVACY)) {
@@ -6361,11 +6363,15 @@ static int read_local_oob_ext_data(struct sock *sk, struct hci_dev *hdev,
 		eir_len = eir_append_data(rp->eir, eir_len, EIR_LE_ROLE,
 					  &role, sizeof(role));
 
-		eir_len = eir_append_data(rp->eir, eir_len, EIR_LE_SC_CONFIRM,
-					  hash, sizeof(hash));
+		if (hci_dev_test_flag(hdev, HCI_SC_ENABLED)) {
+			eir_len = eir_append_data(rp->eir, eir_len,
+						  EIR_LE_SC_CONFIRM,
+						  hash, sizeof(hash));
 
-		eir_len = eir_append_data(rp->eir, eir_len, EIR_LE_SC_RANDOM,
-					  rand, sizeof(rand));
+			eir_len = eir_append_data(rp->eir, eir_len,
+						  EIR_LE_SC_RANDOM,
+						  rand, sizeof(rand));
+		}
 
 		flags = get_adv_discov_flags(hdev);
 
Signature · 1 line
2.1.0