aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2015-03-15 19:42:53 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2015-03-16 00:53:19 -0400
commit455c2ff0a558c04d53a2f5bb55d16093a7dee41d (patch)
tree0d97b259b522661f74543681e6a551f7381f00ef /net/bluetooth
parent4f0f155ceaf7e1b59d210a8afb24d4ea63ce13cc (diff)
Bluetooth: Fix BR/EDR out-of-band pairing with only initiator data
When only the pairing initiator is providing out-of-band data, then the receiver side was ignoring the data. For some reason the code was checking if the initiator has received out-of-band data and only then also provide the required inidication that the acceptor actually has the needed data available. For BR/EDR out-of-band pairing it is enough if one side has received out-of-band data. There are no extra checks needed here to make this work smoothly. The only thing that is needed is to tell the controller if data is present (and if it is P-192 or P-256 or both) and then let the controller actually figure out the rest. This means the check for outgoing connection or if the initiator has indicated data are completely pointless and are in fact actually causing harm. The check in question is this one: if (conn->out || test_bit(HCI_CONN_REMOTE_OOB, &conn->flags)) { After just taking the conditional check out and always executing the code for determining the type of out-of-band data, the pairing works flawlessly and prodcudes authenticated link keys. The patch itself looks more complicated due to the reformatting of the indentation, but it essentially just a two-line change. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_event.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c7376cd42b1c..10d760c46df1 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3889,41 +3889,37 @@ static u8 bredr_oob_data_present(struct hci_conn *conn)
3889 if (!data) 3889 if (!data)
3890 return 0x00; 3890 return 0x00;
3891 3891
3892 if (conn->out || test_bit(HCI_CONN_REMOTE_OOB, &conn->flags)) { 3892 if (bredr_sc_enabled(hdev)) {
3893 if (bredr_sc_enabled(hdev)) { 3893 /* When Secure Connections is enabled, then just
3894 /* When Secure Connections is enabled, then just 3894 * return the present value stored with the OOB
3895 * return the present value stored with the OOB 3895 * data. The stored value contains the right present
3896 * data. The stored value contains the right present 3896 * information. However it can only be trusted when
3897 * information. However it can only be trusted when 3897 * not in Secure Connection Only mode.
3898 * not in Secure Connection Only mode. 3898 */
3899 */ 3899 if (!hci_dev_test_flag(hdev, HCI_SC_ONLY))
3900 if (!hci_dev_test_flag(hdev, HCI_SC_ONLY)) 3900 return data->present;
3901 return data->present;
3902
3903 /* When Secure Connections Only mode is enabled, then
3904 * the P-256 values are required. If they are not
3905 * available, then do not declare that OOB data is
3906 * present.
3907 */
3908 if (!memcmp(data->rand256, ZERO_KEY, 16) ||
3909 !memcmp(data->hash256, ZERO_KEY, 16))
3910 return 0x00;
3911
3912 return 0x02;
3913 }
3914 3901
3915 /* When Secure Connections is not enabled or actually 3902 /* When Secure Connections Only mode is enabled, then
3916 * not supported by the hardware, then check that if 3903 * the P-256 values are required. If they are not
3917 * P-192 data values are present. 3904 * available, then do not declare that OOB data is
3905 * present.
3918 */ 3906 */
3919 if (!memcmp(data->rand192, ZERO_KEY, 16) || 3907 if (!memcmp(data->rand256, ZERO_KEY, 16) ||
3920 !memcmp(data->hash192, ZERO_KEY, 16)) 3908 !memcmp(data->hash256, ZERO_KEY, 16))
3921 return 0x00; 3909 return 0x00;
3922 3910
3923 return 0x01; 3911 return 0x02;
3924 } 3912 }
3925 3913
3926 return 0x00; 3914 /* When Secure Connections is not enabled or actually
3915 * not supported by the hardware, then check that if
3916 * P-192 data values are present.
3917 */
3918 if (!memcmp(data->rand192, ZERO_KEY, 16) ||
3919 !memcmp(data->hash192, ZERO_KEY, 16))
3920 return 0x00;
3921
3922 return 0x01;
3927} 3923}
3928 3924
3929static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb) 3925static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb)