diff options
-rw-r--r-- | net/bluetooth/smp.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 069b76e03b57..bfa839eed89b 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -35,8 +35,9 @@ | |||
35 | 35 | ||
36 | #define SMP_TIMEOUT msecs_to_jiffies(30000) | 36 | #define SMP_TIMEOUT msecs_to_jiffies(30000) |
37 | 37 | ||
38 | #define AUTH_REQ_MASK 0x07 | 38 | #define AUTH_REQ_MASK(dev) (test_bit(HCI_SC_ENABLED, &(dev)->dev_flags) ? \ |
39 | #define KEY_DIST_MASK 0x07 | 39 | 0x1f : 0x07) |
40 | #define KEY_DIST_MASK 0x07 | ||
40 | 41 | ||
41 | enum { | 42 | enum { |
42 | SMP_FLAG_TK_VALID, | 43 | SMP_FLAG_TK_VALID, |
@@ -332,7 +333,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn, | |||
332 | req->max_key_size = SMP_MAX_ENC_KEY_SIZE; | 333 | req->max_key_size = SMP_MAX_ENC_KEY_SIZE; |
333 | req->init_key_dist = local_dist; | 334 | req->init_key_dist = local_dist; |
334 | req->resp_key_dist = remote_dist; | 335 | req->resp_key_dist = remote_dist; |
335 | req->auth_req = (authreq & AUTH_REQ_MASK); | 336 | req->auth_req = (authreq & AUTH_REQ_MASK(hdev)); |
336 | 337 | ||
337 | smp->remote_key_dist = remote_dist; | 338 | smp->remote_key_dist = remote_dist; |
338 | return; | 339 | return; |
@@ -343,7 +344,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn, | |||
343 | rsp->max_key_size = SMP_MAX_ENC_KEY_SIZE; | 344 | rsp->max_key_size = SMP_MAX_ENC_KEY_SIZE; |
344 | rsp->init_key_dist = req->init_key_dist & remote_dist; | 345 | rsp->init_key_dist = req->init_key_dist & remote_dist; |
345 | rsp->resp_key_dist = req->resp_key_dist & local_dist; | 346 | rsp->resp_key_dist = req->resp_key_dist & local_dist; |
346 | rsp->auth_req = (authreq & AUTH_REQ_MASK); | 347 | rsp->auth_req = (authreq & AUTH_REQ_MASK(hdev)); |
347 | 348 | ||
348 | smp->remote_key_dist = rsp->init_key_dist; | 349 | smp->remote_key_dist = rsp->init_key_dist; |
349 | } | 350 | } |
@@ -942,7 +943,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
942 | return SMP_UNSPECIFIED; | 943 | return SMP_UNSPECIFIED; |
943 | 944 | ||
944 | /* We didn't start the pairing, so match remote */ | 945 | /* We didn't start the pairing, so match remote */ |
945 | auth = req->auth_req & AUTH_REQ_MASK; | 946 | auth = req->auth_req & AUTH_REQ_MASK(hdev); |
946 | 947 | ||
947 | if (!test_bit(HCI_BONDABLE, &hdev->dev_flags) && | 948 | if (!test_bit(HCI_BONDABLE, &hdev->dev_flags) && |
948 | (auth & SMP_AUTH_BONDING)) | 949 | (auth & SMP_AUTH_BONDING)) |
@@ -997,6 +998,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb) | |||
997 | struct smp_cmd_pairing *req, *rsp = (void *) skb->data; | 998 | struct smp_cmd_pairing *req, *rsp = (void *) skb->data; |
998 | struct l2cap_chan *chan = conn->smp; | 999 | struct l2cap_chan *chan = conn->smp; |
999 | struct smp_chan *smp = chan->data; | 1000 | struct smp_chan *smp = chan->data; |
1001 | struct hci_dev *hdev = conn->hcon->hdev; | ||
1000 | u8 key_size, auth; | 1002 | u8 key_size, auth; |
1001 | int ret; | 1003 | int ret; |
1002 | 1004 | ||
@@ -1016,7 +1018,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb) | |||
1016 | if (check_enc_key_size(conn, key_size)) | 1018 | if (check_enc_key_size(conn, key_size)) |
1017 | return SMP_ENC_KEY_SIZE; | 1019 | return SMP_ENC_KEY_SIZE; |
1018 | 1020 | ||
1019 | auth = rsp->auth_req & AUTH_REQ_MASK; | 1021 | auth = rsp->auth_req & AUTH_REQ_MASK(hdev); |
1020 | 1022 | ||
1021 | /* If we need MITM check that it can be achieved */ | 1023 | /* If we need MITM check that it can be achieved */ |
1022 | if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { | 1024 | if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { |
@@ -1151,6 +1153,7 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
1151 | struct smp_cmd_security_req *rp = (void *) skb->data; | 1153 | struct smp_cmd_security_req *rp = (void *) skb->data; |
1152 | struct smp_cmd_pairing cp; | 1154 | struct smp_cmd_pairing cp; |
1153 | struct hci_conn *hcon = conn->hcon; | 1155 | struct hci_conn *hcon = conn->hcon; |
1156 | struct hci_dev *hdev = hcon->hdev; | ||
1154 | struct smp_chan *smp; | 1157 | struct smp_chan *smp; |
1155 | u8 sec_level, auth; | 1158 | u8 sec_level, auth; |
1156 | 1159 | ||
@@ -1162,7 +1165,7 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
1162 | if (hcon->role != HCI_ROLE_MASTER) | 1165 | if (hcon->role != HCI_ROLE_MASTER) |
1163 | return SMP_CMD_NOTSUPP; | 1166 | return SMP_CMD_NOTSUPP; |
1164 | 1167 | ||
1165 | auth = rp->auth_req & AUTH_REQ_MASK; | 1168 | auth = rp->auth_req & AUTH_REQ_MASK(hdev); |
1166 | 1169 | ||
1167 | if (hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) | 1170 | if (hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) |
1168 | sec_level = BT_SECURITY_MEDIUM; | 1171 | sec_level = BT_SECURITY_MEDIUM; |