diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-05-29 07:00:39 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-12-03 10:51:16 -0500 |
commit | 5378bc5622a9c221cb472ce86a5024290d6353c2 (patch) | |
tree | 5d7c42e53315e6e04e4648617d722582a2d5a0ce /net/bluetooth/hci_core.c | |
parent | a3209694f82a228c95e5e20f5e31fe63e040f33b (diff) |
Bluetooth: Update LTK lookup to correctly deal with SC LTKs
LTKs derived from Secure Connections based pairing are symmetric, i.e.
they should match both master and slave role. This patch updates the LTK
lookup functions to ignore the desired role when dealing with SC LTKs.
Furthermore, with Secure Connections the EDiv and Rand values are not
used and should always be set to zero. This patch updates the LTK lookup
to first use the bdaddr as key and then do the necessary verifications
of EDiv and Rand based on whether the found LTK is for SC or not.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r-- | net/bluetooth/hci_core.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 2586e405adb3..e091e8ffeb8e 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -3195,11 +3195,18 @@ struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, __le64 rand, | |||
3195 | if (k->ediv != ediv || k->rand != rand) | 3195 | if (k->ediv != ediv || k->rand != rand) |
3196 | continue; | 3196 | continue; |
3197 | 3197 | ||
3198 | if (ltk_role(k->type) != role) | 3198 | if (smp_ltk_is_sc(k)) { |
3199 | continue; | 3199 | if (k->type == SMP_LTK_P256_DEBUG && |
3200 | !test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->dev_flags)) | ||
3201 | continue; | ||
3202 | rcu_read_unlock(); | ||
3203 | return k; | ||
3204 | } | ||
3200 | 3205 | ||
3201 | rcu_read_unlock(); | 3206 | if (ltk_role(k->type) == role) { |
3202 | return k; | 3207 | rcu_read_unlock(); |
3208 | return k; | ||
3209 | } | ||
3203 | } | 3210 | } |
3204 | rcu_read_unlock(); | 3211 | rcu_read_unlock(); |
3205 | 3212 | ||
@@ -3213,9 +3220,18 @@ struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, | |||
3213 | 3220 | ||
3214 | rcu_read_lock(); | 3221 | rcu_read_lock(); |
3215 | list_for_each_entry_rcu(k, &hdev->long_term_keys, list) { | 3222 | list_for_each_entry_rcu(k, &hdev->long_term_keys, list) { |
3216 | if (addr_type == k->bdaddr_type && | 3223 | if (addr_type != k->bdaddr_type || bacmp(bdaddr, &k->bdaddr)) |
3217 | bacmp(bdaddr, &k->bdaddr) == 0 && | 3224 | continue; |
3218 | ltk_role(k->type) == role) { | 3225 | |
3226 | if (smp_ltk_is_sc(k)) { | ||
3227 | if (k->type == SMP_LTK_P256_DEBUG && | ||
3228 | !test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->dev_flags)) | ||
3229 | continue; | ||
3230 | rcu_read_unlock(); | ||
3231 | return k; | ||
3232 | } | ||
3233 | |||
3234 | if (ltk_role(k->type) == role) { | ||
3219 | rcu_read_unlock(); | 3235 | rcu_read_unlock(); |
3220 | return k; | 3236 | return k; |
3221 | } | 3237 | } |