diff options
-rw-r--r-- | net/bluetooth/smp.c | 48 | ||||
-rw-r--r-- | net/bluetooth/smp.h | 8 |
2 files changed, 7 insertions, 49 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index b952041bf4ac..10a8e622ab2b 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -556,20 +556,6 @@ error: | |||
556 | smp_failure(conn, reason); | 556 | smp_failure(conn, reason); |
557 | } | 557 | } |
558 | 558 | ||
559 | static void smp_reencrypt(struct work_struct *work) | ||
560 | { | ||
561 | struct smp_chan *smp = container_of(work, struct smp_chan, | ||
562 | reencrypt.work); | ||
563 | struct l2cap_conn *conn = smp->conn; | ||
564 | struct hci_conn *hcon = conn->hcon; | ||
565 | struct smp_ltk *ltk = smp->ltk; | ||
566 | |||
567 | BT_DBG(""); | ||
568 | |||
569 | hci_le_start_enc(hcon, ltk->ediv, ltk->rand, ltk->val); | ||
570 | hcon->enc_key_size = ltk->enc_size; | ||
571 | } | ||
572 | |||
573 | static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) | 559 | static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) |
574 | { | 560 | { |
575 | struct smp_chan *smp; | 561 | struct smp_chan *smp; |
@@ -580,7 +566,6 @@ static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) | |||
580 | 566 | ||
581 | INIT_WORK(&smp->confirm, confirm_work); | 567 | INIT_WORK(&smp->confirm, confirm_work); |
582 | INIT_WORK(&smp->random, random_work); | 568 | INIT_WORK(&smp->random, random_work); |
583 | INIT_DELAYED_WORK(&smp->reencrypt, smp_reencrypt); | ||
584 | 569 | ||
585 | smp->conn = conn; | 570 | smp->conn = conn; |
586 | conn->smp_chan = smp; | 571 | conn->smp_chan = smp; |
@@ -598,8 +583,6 @@ void smp_chan_destroy(struct l2cap_conn *conn) | |||
598 | 583 | ||
599 | BUG_ON(!smp); | 584 | BUG_ON(!smp); |
600 | 585 | ||
601 | cancel_delayed_work_sync(&smp->reencrypt); | ||
602 | |||
603 | complete = test_bit(SMP_FLAG_COMPLETE, &smp->smp_flags); | 586 | complete = test_bit(SMP_FLAG_COMPLETE, &smp->smp_flags); |
604 | mgmt_smp_complete(conn->hcon, complete); | 587 | mgmt_smp_complete(conn->hcon, complete); |
605 | 588 | ||
@@ -1276,7 +1259,6 @@ int smp_distribute_keys(struct l2cap_conn *conn) | |||
1276 | struct smp_chan *smp = conn->smp_chan; | 1259 | struct smp_chan *smp = conn->smp_chan; |
1277 | struct hci_conn *hcon = conn->hcon; | 1260 | struct hci_conn *hcon = conn->hcon; |
1278 | struct hci_dev *hdev = hcon->hdev; | 1261 | struct hci_dev *hdev = hcon->hdev; |
1279 | bool ltk_encrypt; | ||
1280 | __u8 *keydist; | 1262 | __u8 *keydist; |
1281 | 1263 | ||
1282 | BT_DBG("conn %p", conn); | 1264 | BT_DBG("conn %p", conn); |
@@ -1376,32 +1358,12 @@ int smp_distribute_keys(struct l2cap_conn *conn) | |||
1376 | if ((smp->remote_key_dist & 0x07)) | 1358 | if ((smp->remote_key_dist & 0x07)) |
1377 | return 0; | 1359 | return 0; |
1378 | 1360 | ||
1379 | /* Check if we should try to re-encrypt the link with the LTK. | 1361 | clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags); |
1380 | * SMP_FLAG_LTK_ENCRYPT flag is used to track whether we've | 1362 | cancel_delayed_work_sync(&conn->security_timer); |
1381 | * already tried this (in which case we shouldn't try again). | 1363 | set_bit(SMP_FLAG_COMPLETE, &smp->smp_flags); |
1382 | * | 1364 | smp_notify_keys(conn); |
1383 | * The request will trigger an encryption key refresh event | ||
1384 | * which will cause a call to auth_cfm and eventually lead to | ||
1385 | * l2cap_core.c calling this smp_distribute_keys function again | ||
1386 | * and thereby completing the process. | ||
1387 | */ | ||
1388 | if (smp->ltk) | ||
1389 | ltk_encrypt = !test_and_set_bit(SMP_FLAG_LTK_ENCRYPT, | ||
1390 | &smp->smp_flags); | ||
1391 | else | ||
1392 | ltk_encrypt = false; | ||
1393 | 1365 | ||
1394 | /* Re-encrypt the link with LTK if possible */ | 1366 | smp_chan_destroy(conn); |
1395 | if (ltk_encrypt && hcon->out) { | ||
1396 | queue_delayed_work(hdev->req_workqueue, &smp->reencrypt, | ||
1397 | SMP_REENCRYPT_TIMEOUT); | ||
1398 | } else { | ||
1399 | clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags); | ||
1400 | cancel_delayed_work_sync(&conn->security_timer); | ||
1401 | set_bit(SMP_FLAG_COMPLETE, &smp->smp_flags); | ||
1402 | smp_notify_keys(conn); | ||
1403 | smp_chan_destroy(conn); | ||
1404 | } | ||
1405 | 1367 | ||
1406 | return 0; | 1368 | return 0; |
1407 | } | 1369 | } |
diff --git a/net/bluetooth/smp.h b/net/bluetooth/smp.h index 0d536b8b3f9a..1277147a9150 100644 --- a/net/bluetooth/smp.h +++ b/net/bluetooth/smp.h | |||
@@ -118,11 +118,8 @@ struct smp_cmd_security_req { | |||
118 | #define SMP_FLAG_TK_VALID 1 | 118 | #define SMP_FLAG_TK_VALID 1 |
119 | #define SMP_FLAG_CFM_PENDING 2 | 119 | #define SMP_FLAG_CFM_PENDING 2 |
120 | #define SMP_FLAG_MITM_AUTH 3 | 120 | #define SMP_FLAG_MITM_AUTH 3 |
121 | #define SMP_FLAG_LTK_ENCRYPT 4 | 121 | #define SMP_FLAG_COMPLETE 4 |
122 | #define SMP_FLAG_COMPLETE 5 | 122 | #define SMP_FLAG_INITIATOR 5 |
123 | #define SMP_FLAG_INITIATOR 6 | ||
124 | |||
125 | #define SMP_REENCRYPT_TIMEOUT msecs_to_jiffies(500) | ||
126 | 123 | ||
127 | struct smp_chan { | 124 | struct smp_chan { |
128 | struct l2cap_conn *conn; | 125 | struct l2cap_conn *conn; |
@@ -145,7 +142,6 @@ struct smp_chan { | |||
145 | unsigned long smp_flags; | 142 | unsigned long smp_flags; |
146 | struct work_struct confirm; | 143 | struct work_struct confirm; |
147 | struct work_struct random; | 144 | struct work_struct random; |
148 | struct delayed_work reencrypt; | ||
149 | }; | 145 | }; |
150 | 146 | ||
151 | /* SMP Commands */ | 147 | /* SMP Commands */ |