aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-02-27 03:11:13 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-02-27 12:25:48 -0500
commit4cd3928a8bee83d86fb3865bb243ab2ff1dd0eb6 (patch)
tree9a557b133bb3d26d0a9c608668daf56dd1c1999d
parent03f310efd4b19ddc2cca15ae67f48295554adbfe (diff)
Bluetooth: Update New CSRK event to match latest specification
The 'master' parameter of the New CSRK event was recently renamed to 'type', with the old values kept for backwards compatibility as unauthenticated local/remote keys. This patch updates the code to take into account the two new (authenticated) values and ensures they get used based on the security level of the connection that the respective keys get distributed over. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--include/net/bluetooth/hci_core.h2
-rw-r--r--include/net/bluetooth/mgmt.h7
-rw-r--r--net/bluetooth/mgmt.c2
-rw-r--r--net/bluetooth/smp.c10
4 files changed, 16 insertions, 5 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index a831c8ad10f1..acec9140c3f9 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -108,7 +108,7 @@ struct bt_uuid {
108struct smp_csrk { 108struct smp_csrk {
109 bdaddr_t bdaddr; 109 bdaddr_t bdaddr;
110 u8 bdaddr_type; 110 u8 bdaddr_type;
111 u8 master; 111 u8 type;
112 u8 val[16]; 112 u8 val[16];
113}; 113};
114 114
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index e218a30f2061..fe8eef00e9ca 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -647,9 +647,14 @@ struct mgmt_ev_new_irk {
647 struct mgmt_irk_info irk; 647 struct mgmt_irk_info irk;
648} __packed; 648} __packed;
649 649
650#define MGMT_CSRK_LOCAL_UNAUTHENTICATED 0x00
651#define MGMT_CSRK_REMOTE_UNAUTHENTICATED 0x01
652#define MGMT_CSRK_LOCAL_AUTHENTICATED 0x02
653#define MGMT_CSRK_REMOTE_AUTHENTICATED 0x03
654
650struct mgmt_csrk_info { 655struct mgmt_csrk_info {
651 struct mgmt_addr_info addr; 656 struct mgmt_addr_info addr;
652 __u8 master; 657 __u8 type;
653 __u8 val[16]; 658 __u8 val[16];
654} __packed; 659} __packed;
655 660
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index d5d46e7676f1..1e4635a3374d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -6664,7 +6664,7 @@ void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk,
6664 6664
6665 bacpy(&ev.key.addr.bdaddr, &csrk->bdaddr); 6665 bacpy(&ev.key.addr.bdaddr, &csrk->bdaddr);
6666 ev.key.addr.type = link_to_bdaddr(LE_LINK, csrk->bdaddr_type); 6666 ev.key.addr.type = link_to_bdaddr(LE_LINK, csrk->bdaddr_type);
6667 ev.key.master = csrk->master; 6667 ev.key.type = csrk->type;
6668 memcpy(ev.key.val, csrk->val, sizeof(csrk->val)); 6668 memcpy(ev.key.val, csrk->val, sizeof(csrk->val));
6669 6669
6670 mgmt_event(MGMT_EV_NEW_CSRK, hdev, &ev, sizeof(ev), NULL); 6670 mgmt_event(MGMT_EV_NEW_CSRK, hdev, &ev, sizeof(ev), NULL);
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index b2803bd6e0d8..c91c19bfc0a8 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1252,7 +1252,10 @@ static void smp_distribute_keys(struct smp_chan *smp)
1252 1252
1253 csrk = kzalloc(sizeof(*csrk), GFP_KERNEL); 1253 csrk = kzalloc(sizeof(*csrk), GFP_KERNEL);
1254 if (csrk) { 1254 if (csrk) {
1255 csrk->master = 0x00; 1255 if (hcon->sec_level > BT_SECURITY_MEDIUM)
1256 csrk->type = MGMT_CSRK_LOCAL_AUTHENTICATED;
1257 else
1258 csrk->type = MGMT_CSRK_LOCAL_UNAUTHENTICATED;
1256 memcpy(csrk->val, sign.csrk, sizeof(csrk->val)); 1259 memcpy(csrk->val, sign.csrk, sizeof(csrk->val));
1257 } 1260 }
1258 smp->slave_csrk = csrk; 1261 smp->slave_csrk = csrk;
@@ -2352,7 +2355,10 @@ static int smp_cmd_sign_info(struct l2cap_conn *conn, struct sk_buff *skb)
2352 2355
2353 csrk = kzalloc(sizeof(*csrk), GFP_KERNEL); 2356 csrk = kzalloc(sizeof(*csrk), GFP_KERNEL);
2354 if (csrk) { 2357 if (csrk) {
2355 csrk->master = 0x01; 2358 if (conn->hcon->sec_level > BT_SECURITY_MEDIUM)
2359 csrk->type = MGMT_CSRK_REMOTE_AUTHENTICATED;
2360 else
2361 csrk->type = MGMT_CSRK_REMOTE_UNAUTHENTICATED;
2356 memcpy(csrk->val, rp->csrk, sizeof(csrk->val)); 2362 memcpy(csrk->val, rp->csrk, sizeof(csrk->val));
2357 } 2363 }
2358 smp->csrk = csrk; 2364 smp->csrk = csrk;