浏览代码

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>
Johan Hedberg 10 年之前
父节点
当前提交
4cd3928a8b
共有 4 个文件被更改,包括 16 次插入5 次删除
  1. 1 1
      include/net/bluetooth/hci_core.h
  2. 6 1
      include/net/bluetooth/mgmt.h
  3. 1 1
      net/bluetooth/mgmt.c
  4. 8 2
      net/bluetooth/smp.c

+ 1 - 1
include/net/bluetooth/hci_core.h

@@ -108,7 +108,7 @@ struct bt_uuid {
 struct smp_csrk {
 struct smp_csrk {
 	bdaddr_t bdaddr;
 	bdaddr_t bdaddr;
 	u8 bdaddr_type;
 	u8 bdaddr_type;
-	u8 master;
+	u8 type;
 	u8 val[16];
 	u8 val[16];
 };
 };
 
 

+ 6 - 1
include/net/bluetooth/mgmt.h

@@ -647,9 +647,14 @@ struct mgmt_ev_new_irk {
 	struct mgmt_irk_info irk;
 	struct mgmt_irk_info irk;
 } __packed;
 } __packed;
 
 
+#define MGMT_CSRK_LOCAL_UNAUTHENTICATED		0x00
+#define MGMT_CSRK_REMOTE_UNAUTHENTICATED	0x01
+#define MGMT_CSRK_LOCAL_AUTHENTICATED		0x02
+#define MGMT_CSRK_REMOTE_AUTHENTICATED		0x03
+
 struct mgmt_csrk_info {
 struct mgmt_csrk_info {
 	struct mgmt_addr_info addr;
 	struct mgmt_addr_info addr;
-	__u8 master;
+	__u8 type;
 	__u8 val[16];
 	__u8 val[16];
 } __packed;
 } __packed;
 
 

+ 1 - 1
net/bluetooth/mgmt.c

@@ -6664,7 +6664,7 @@ void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk,
 
 
 	bacpy(&ev.key.addr.bdaddr, &csrk->bdaddr);
 	bacpy(&ev.key.addr.bdaddr, &csrk->bdaddr);
 	ev.key.addr.type = link_to_bdaddr(LE_LINK, csrk->bdaddr_type);
 	ev.key.addr.type = link_to_bdaddr(LE_LINK, csrk->bdaddr_type);
-	ev.key.master = csrk->master;
+	ev.key.type = csrk->type;
 	memcpy(ev.key.val, csrk->val, sizeof(csrk->val));
 	memcpy(ev.key.val, csrk->val, sizeof(csrk->val));
 
 
 	mgmt_event(MGMT_EV_NEW_CSRK, hdev, &ev, sizeof(ev), NULL);
 	mgmt_event(MGMT_EV_NEW_CSRK, hdev, &ev, sizeof(ev), NULL);

+ 8 - 2
net/bluetooth/smp.c

@@ -1252,7 +1252,10 @@ static void smp_distribute_keys(struct smp_chan *smp)
 
 
 		csrk = kzalloc(sizeof(*csrk), GFP_KERNEL);
 		csrk = kzalloc(sizeof(*csrk), GFP_KERNEL);
 		if (csrk) {
 		if (csrk) {
-			csrk->master = 0x00;
+			if (hcon->sec_level > BT_SECURITY_MEDIUM)
+				csrk->type = MGMT_CSRK_LOCAL_AUTHENTICATED;
+			else
+				csrk->type = MGMT_CSRK_LOCAL_UNAUTHENTICATED;
 			memcpy(csrk->val, sign.csrk, sizeof(csrk->val));
 			memcpy(csrk->val, sign.csrk, sizeof(csrk->val));
 		}
 		}
 		smp->slave_csrk = csrk;
 		smp->slave_csrk = csrk;
@@ -2352,7 +2355,10 @@ static int smp_cmd_sign_info(struct l2cap_conn *conn, struct sk_buff *skb)
 
 
 	csrk = kzalloc(sizeof(*csrk), GFP_KERNEL);
 	csrk = kzalloc(sizeof(*csrk), GFP_KERNEL);
 	if (csrk) {
 	if (csrk) {
-		csrk->master = 0x01;
+		if (conn->hcon->sec_level > BT_SECURITY_MEDIUM)
+			csrk->type = MGMT_CSRK_REMOTE_AUTHENTICATED;
+		else
+			csrk->type = MGMT_CSRK_REMOTE_UNAUTHENTICATED;
 		memcpy(csrk->val, rp->csrk, sizeof(csrk->val));
 		memcpy(csrk->val, rp->csrk, sizeof(csrk->val));
 	}
 	}
 	smp->csrk = csrk;
 	smp->csrk = csrk;