Revert "Bluetooth: Add support for communicating keys with userspace"
This reverts commit 5a0a8b4974
.
If we use separate messages and list for SMP specific keys we can
simplify the code.
Conflicts:
net/bluetooth/mgmt.c
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
This commit is contained in:
parent
988c5997d3
commit
a492cd52b5
|
@ -908,7 +908,7 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
||||||
struct hci_dev *hdev;
|
struct hci_dev *hdev;
|
||||||
struct mgmt_cp_load_keys *cp;
|
struct mgmt_cp_load_keys *cp;
|
||||||
u16 key_count, expected_len;
|
u16 key_count, expected_len;
|
||||||
int i, err;
|
int i;
|
||||||
|
|
||||||
cp = (void *) data;
|
cp = (void *) data;
|
||||||
|
|
||||||
|
@ -918,9 +918,9 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
||||||
key_count = get_unaligned_le16(&cp->key_count);
|
key_count = get_unaligned_le16(&cp->key_count);
|
||||||
|
|
||||||
expected_len = sizeof(*cp) + key_count * sizeof(struct mgmt_key_info);
|
expected_len = sizeof(*cp) + key_count * sizeof(struct mgmt_key_info);
|
||||||
if (expected_len > len) {
|
if (expected_len != len) {
|
||||||
BT_ERR("load_keys: expected at least %u bytes, got %u bytes",
|
BT_ERR("load_keys: expected %u bytes, got %u bytes",
|
||||||
expected_len, len);
|
len, expected_len);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -942,36 +942,17 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
||||||
else
|
else
|
||||||
clear_bit(HCI_DEBUG_KEYS, &hdev->flags);
|
clear_bit(HCI_DEBUG_KEYS, &hdev->flags);
|
||||||
|
|
||||||
len -= sizeof(*cp);
|
for (i = 0; i < key_count; i++) {
|
||||||
i = 0;
|
struct mgmt_key_info *key = &cp->keys[i];
|
||||||
|
|
||||||
while (i < len) {
|
|
||||||
struct mgmt_key_info *key = (void *) cp->keys + i;
|
|
||||||
|
|
||||||
i += sizeof(*key) + key->dlen;
|
|
||||||
|
|
||||||
if (key->type == HCI_LK_SMP_LTK) {
|
|
||||||
struct key_master_id *id = (void *) key->data;
|
|
||||||
|
|
||||||
if (key->dlen != sizeof(struct key_master_id))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
hci_add_ltk(hdev, 0, &key->bdaddr, key->pin_len,
|
|
||||||
id->ediv, id->rand, key->val);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
hci_add_link_key(hdev, NULL, 0, &key->bdaddr, key->val, key->type,
|
hci_add_link_key(hdev, NULL, 0, &key->bdaddr, key->val, key->type,
|
||||||
key->pin_len);
|
key->pin_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cmd_complete(sk, index, MGMT_OP_LOAD_KEYS, NULL, 0);
|
|
||||||
|
|
||||||
hci_dev_unlock_bh(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int remove_key(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
static int remove_key(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
||||||
|
@ -2070,28 +2051,17 @@ int mgmt_connectable(u16 index, u8 connectable)
|
||||||
|
|
||||||
int mgmt_new_key(u16 index, struct link_key *key, u8 persistent)
|
int mgmt_new_key(u16 index, struct link_key *key, u8 persistent)
|
||||||
{
|
{
|
||||||
struct mgmt_ev_new_key *ev;
|
struct mgmt_ev_new_key ev;
|
||||||
int err, total;
|
|
||||||
|
|
||||||
total = sizeof(struct mgmt_ev_new_key) + key->dlen;
|
memset(&ev, 0, sizeof(ev));
|
||||||
ev = kzalloc(total, GFP_ATOMIC);
|
|
||||||
if (!ev)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
bacpy(&ev->key.bdaddr, &key->bdaddr);
|
ev.store_hint = persistent;
|
||||||
ev->key.type = key->type;
|
bacpy(&ev.key.bdaddr, &key->bdaddr);
|
||||||
memcpy(ev->key.val, key->val, 16);
|
ev.key.type = key->type;
|
||||||
ev->key.pin_len = key->pin_len;
|
memcpy(ev.key.val, key->val, 16);
|
||||||
ev->key.dlen = key->dlen;
|
ev.key.pin_len = key->pin_len;
|
||||||
ev->store_hint = persistent;
|
|
||||||
|
|
||||||
memcpy(ev->key.data, key->data, key->dlen);
|
return mgmt_event(MGMT_EV_NEW_KEY, index, &ev, sizeof(ev), NULL);
|
||||||
|
|
||||||
err = mgmt_event(MGMT_EV_NEW_KEY, index, ev, total, NULL);
|
|
||||||
|
|
||||||
kfree(ev);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type)
|
int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type)
|
||||||
|
|
Loading…
Reference in a new issue