aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-05-23 06:19:53 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-05-23 14:24:04 -0400
commitd7b2545023ecfde94d3ea9c03c5480ac18da96c9 (patch)
tree1cacf5b693028850ada383f603609d9f5a8072a1 /net/bluetooth/mgmt.c
parent1cc6114402f864c3d090738df355d26c1fd374bb (diff)
Bluetooth: Clearly distinguish mgmt LTK type from authenticated property
On the mgmt level we have a key type parameter which currently accepts two possible values: 0x00 for unauthenticated and 0x01 for authenticated. However, in the internal struct smp_ltk representation we have an explicit "authenticated" boolean value. To make this distinction clear, add defines for the possible mgmt values and do conversion to and from the internal authenticated value. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f8ca69dd1984..5e9c21a5525f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4534,7 +4534,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
4534 4534
4535 for (i = 0; i < key_count; i++) { 4535 for (i = 0; i < key_count; i++) {
4536 struct mgmt_ltk_info *key = &cp->keys[i]; 4536 struct mgmt_ltk_info *key = &cp->keys[i];
4537 u8 type, addr_type; 4537 u8 type, addr_type, authenticated;
4538 4538
4539 if (key->addr.type == BDADDR_LE_PUBLIC) 4539 if (key->addr.type == BDADDR_LE_PUBLIC)
4540 addr_type = ADDR_LE_DEV_PUBLIC; 4540 addr_type = ADDR_LE_DEV_PUBLIC;
@@ -4546,8 +4546,13 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
4546 else 4546 else
4547 type = HCI_SMP_LTK_SLAVE; 4547 type = HCI_SMP_LTK_SLAVE;
4548 4548
4549 if (key->type == MGMT_LTK_UNAUTHENTICATED)
4550 authenticated = 0x00;
4551 else
4552 authenticated = 0x01;
4553
4549 hci_add_ltk(hdev, &key->addr.bdaddr, addr_type, type, 4554 hci_add_ltk(hdev, &key->addr.bdaddr, addr_type, type,
4550 key->type, key->val, key->enc_size, key->ediv, 4555 authenticated, key->val, key->enc_size, key->ediv,
4551 key->rand); 4556 key->rand);
4552 } 4557 }
4553 4558
@@ -5222,6 +5227,14 @@ void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
5222 mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL); 5227 mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL);
5223} 5228}
5224 5229
5230static u8 mgmt_ltk_type(struct smp_ltk *ltk)
5231{
5232 if (ltk->authenticated)
5233 return MGMT_LTK_AUTHENTICATED;
5234
5235 return MGMT_LTK_UNAUTHENTICATED;
5236}
5237
5225void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent) 5238void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent)
5226{ 5239{
5227 struct mgmt_ev_new_long_term_key ev; 5240 struct mgmt_ev_new_long_term_key ev;
@@ -5247,7 +5260,7 @@ void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent)
5247 5260
5248 bacpy(&ev.key.addr.bdaddr, &key->bdaddr); 5261 bacpy(&ev.key.addr.bdaddr, &key->bdaddr);
5249 ev.key.addr.type = link_to_bdaddr(LE_LINK, key->bdaddr_type); 5262 ev.key.addr.type = link_to_bdaddr(LE_LINK, key->bdaddr_type);
5250 ev.key.type = key->authenticated; 5263 ev.key.type = mgmt_ltk_type(key);
5251 ev.key.enc_size = key->enc_size; 5264 ev.key.enc_size = key->enc_size;
5252 ev.key.ediv = key->ediv; 5265 ev.key.ediv = key->ediv;
5253 ev.key.rand = key->rand; 5266 ev.key.rand = key->rand;