aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-01-10 05:07:26 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2014-02-13 02:51:33 -0500
commit4d2d27962642e23f88745b0430d47c3ff75afdd3 (patch)
tree95eba06eef9a7dfc959768c474f4c9993d9d40ea /net/bluetooth/mgmt.c
parent8e99113277fb9f7b8b28fbcc866a359d2fa1ba41 (diff)
Bluetooth: Add support for local OOB data with Secure Connections
For Secure Connections support and the usage of out-of-band pairing, it is needed to read the P-256 hash and randomizer or P-192 hash and randomizer. This change will read P-192 data when Secure Connections is disabled and P-192 and P-256 data when it is enabled. The difference is between using HCI Read Local OOB Data and using the new HCI Read Local OOB Extended Data command. The first one has been introduced with Bluetooth 2.1 and returns only the P-192 data. < HCI Command: Read Local OOB Data (0x03|0x0057) plen 0 > HCI Event: Command Complete (0x0e) plen 36 Read Local OOB Data (0x03|0x0057) ncmd 1 Status: Success (0x00) Hash C from P-192: 975a59baa1c4eee391477cb410b23e6d Randomizer R with P-192: 9ee63b7dec411d3b467c5ae446df7f7d The second command has been introduced with Bluetooth 4.1 and will return P-192 and P-256 data. < HCI Command: Read Local OOB Extended Data (0x03|0x007d) plen 0 > HCI Event: Command Complete (0x0e) plen 68 Read Local OOB Extended Data (0x03|0x007d) ncmd 1 Status: Success (0x00) Hash C from P-192: 6489731804b156fa6355efb8124a1389 Randomizer R with P-192: 4781d5352fb215b2958222b3937b6026 Hash C from P-256: 69ef8a928b9d07fc149e630e74ecb991 Randomizer R with P-256: 4781d5352fb215b2958222b3937b6026 The change for the management interface is transparent and no change is required for existing userspace. The Secure Connections feature needs to be manually enabled. When it is disabled, then userspace only gets the P-192 returned and with Secure Connections enabled, userspace gets P-192 and P-256 in an extended structure. It is also acceptable to just ignore the P-256 data since it is not required to support them. The pairing with out-of-band credentials will still succeed. However then of course no Secure Connection will b established. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 9b162038acb7..a7d4ae679ab7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3078,7 +3078,12 @@ static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev,
3078 goto unlock; 3078 goto unlock;
3079 } 3079 }
3080 3080
3081 err = hci_send_cmd(hdev, HCI_OP_READ_LOCAL_OOB_DATA, 0, NULL); 3081 if (test_bit(HCI_SC_ENABLED, &hdev->dev_flags))
3082 err = hci_send_cmd(hdev, HCI_OP_READ_LOCAL_OOB_EXT_DATA,
3083 0, NULL);
3084 else
3085 err = hci_send_cmd(hdev, HCI_OP_READ_LOCAL_OOB_DATA, 0, NULL);
3086
3082 if (err < 0) 3087 if (err < 0)
3083 mgmt_pending_remove(cmd); 3088 mgmt_pending_remove(cmd);
3084 3089
@@ -5077,8 +5082,9 @@ void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status)
5077 cmd ? cmd->sk : NULL); 5082 cmd ? cmd->sk : NULL);
5078} 5083}
5079 5084
5080void mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, 5085void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192,
5081 u8 *randomizer, u8 status) 5086 u8 *randomizer192, u8 *hash256,
5087 u8 *randomizer256, u8 status)
5082{ 5088{
5083 struct pending_cmd *cmd; 5089 struct pending_cmd *cmd;
5084 5090
@@ -5092,13 +5098,32 @@ void mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
5092 cmd_status(cmd->sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, 5098 cmd_status(cmd->sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA,
5093 mgmt_status(status)); 5099 mgmt_status(status));
5094 } else { 5100 } else {
5095 struct mgmt_rp_read_local_oob_data rp; 5101 if (test_bit(HCI_SC_ENABLED, &hdev->dev_flags) &&
5102 hash256 && randomizer256) {
5103 struct mgmt_rp_read_local_oob_ext_data rp;
5104
5105 memcpy(rp.hash192, hash192, sizeof(rp.hash192));
5106 memcpy(rp.randomizer192, randomizer192,
5107 sizeof(rp.randomizer192));
5096 5108
5097 memcpy(rp.hash, hash, sizeof(rp.hash)); 5109 memcpy(rp.hash256, hash256, sizeof(rp.hash256));
5098 memcpy(rp.randomizer, randomizer, sizeof(rp.randomizer)); 5110 memcpy(rp.randomizer256, randomizer256,
5111 sizeof(rp.randomizer256));
5099 5112
5100 cmd_complete(cmd->sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, 5113 cmd_complete(cmd->sk, hdev->id,
5101 0, &rp, sizeof(rp)); 5114 MGMT_OP_READ_LOCAL_OOB_DATA, 0,
5115 &rp, sizeof(rp));
5116 } else {
5117 struct mgmt_rp_read_local_oob_data rp;
5118
5119 memcpy(rp.hash, hash192, sizeof(rp.hash));
5120 memcpy(rp.randomizer, randomizer192,
5121 sizeof(rp.randomizer));
5122
5123 cmd_complete(cmd->sk, hdev->id,
5124 MGMT_OP_READ_LOCAL_OOB_DATA, 0,
5125 &rp, sizeof(rp));
5126 }
5102 } 5127 }
5103 5128
5104 mgmt_pending_remove(cmd); 5129 mgmt_pending_remove(cmd);