aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_event.c
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2011-07-07 17:59:37 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-07-08 16:36:57 -0400
commitbea710feff617e3469789dd8f930b284c83a87f5 (patch)
tree2eb8a5991310a4f103269c4da41a8cb2f9b97717 /net/bluetooth/hci_event.c
parent75d262c2ad927751bb5f096f3a6a37d81e7784f2 (diff)
Bluetooth: Reject an encryption request when the key isn't found
Now that we have methods to finding keys by its parameters we can reject an encryption request if the key isn't found. Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r--net/bluetooth/hci_event.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 298cd9bfb2b5..ca5ff6eedf02 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2858,21 +2858,35 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev,
2858{ 2858{
2859 struct hci_ev_le_ltk_req *ev = (void *) skb->data; 2859 struct hci_ev_le_ltk_req *ev = (void *) skb->data;
2860 struct hci_cp_le_ltk_reply cp; 2860 struct hci_cp_le_ltk_reply cp;
2861 struct hci_cp_le_ltk_neg_reply neg;
2861 struct hci_conn *conn; 2862 struct hci_conn *conn;
2863 struct link_key *ltk;
2862 2864
2863 BT_DBG("%s handle %d", hdev->name, cpu_to_le16(ev->handle)); 2865 BT_DBG("%s handle %d", hdev->name, cpu_to_le16(ev->handle));
2864 2866
2865 hci_dev_lock(hdev); 2867 hci_dev_lock(hdev);
2866 2868
2867 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 2869 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
2870 if (conn == NULL)
2871 goto not_found;
2868 2872
2869 memset(&cp, 0, sizeof(cp)); 2873 ltk = hci_find_ltk(hdev, ev->ediv, ev->random);
2874 if (ltk == NULL)
2875 goto not_found;
2876
2877 memcpy(cp.ltk, ltk->val, sizeof(ltk->val));
2870 cp.handle = cpu_to_le16(conn->handle); 2878 cp.handle = cpu_to_le16(conn->handle);
2871 memcpy(cp.ltk, conn->ltk, sizeof(conn->ltk));
2872 2879
2873 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); 2880 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp);
2874 2881
2875 hci_dev_unlock(hdev); 2882 hci_dev_unlock(hdev);
2883
2884 return;
2885
2886not_found:
2887 neg.handle = ev->handle;
2888 hci_send_cmd(hdev, HCI_OP_LE_LTK_NEG_REPLY, sizeof(neg), &neg);
2889 hci_dev_unlock(hdev);
2876} 2890}
2877 2891
2878static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb) 2892static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)