diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-07-01 12:14:12 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-07-03 11:42:54 -0400 |
commit | fe59a05f941dbeb14316449be42d059761bed62c (patch) | |
tree | a89a79a5c2e2fe8ef0f2aad0cb84d38baa0b9c87 | |
parent | 854f47278fb36f4904649b994acf559e13920232 (diff) |
Bluetooth: Add flag to track STK encryption
There are certain subtle differences in behavior when we're encrypted
with the STK, such as allowing re-encryption even though the security
level stays the same. Because of this, add a flag to track whether we're
encrypted with an STK or not.
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.h | 1 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 3 | ||||
-rw-r--r-- | net/bluetooth/smp.c | 4 |
3 files changed, 8 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index eb0add396595..9078da681f16 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -536,6 +536,7 @@ enum { | |||
536 | HCI_CONN_AUTH, | 536 | HCI_CONN_AUTH, |
537 | HCI_CONN_SECURE, | 537 | HCI_CONN_SECURE, |
538 | HCI_CONN_FIPS, | 538 | HCI_CONN_FIPS, |
539 | HCI_CONN_STK_ENCRYPT, | ||
539 | }; | 540 | }; |
540 | 541 | ||
541 | static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) | 542 | static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 8097559ebb48..b0b760dd66a3 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -4365,8 +4365,11 @@ static void hci_le_ltk_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
4365 | * using a distributed LTK. | 4365 | * using a distributed LTK. |
4366 | */ | 4366 | */ |
4367 | if (ltk->type == SMP_STK) { | 4367 | if (ltk->type == SMP_STK) { |
4368 | set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); | ||
4368 | list_del(<k->list); | 4369 | list_del(<k->list); |
4369 | kfree(ltk); | 4370 | kfree(ltk); |
4371 | } else { | ||
4372 | clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); | ||
4370 | } | 4373 | } |
4371 | 4374 | ||
4372 | hci_dev_unlock(hdev); | 4375 | hci_dev_unlock(hdev); |
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 6ce7785a2708..68e6f245581c 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -538,6 +538,7 @@ static u8 smp_random(struct smp_chan *smp) | |||
538 | 538 | ||
539 | hci_le_start_enc(hcon, ediv, rand, stk); | 539 | hci_le_start_enc(hcon, ediv, rand, stk); |
540 | hcon->enc_key_size = smp->enc_key_size; | 540 | hcon->enc_key_size = smp->enc_key_size; |
541 | set_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); | ||
541 | } else { | 542 | } else { |
542 | u8 stk[16], auth; | 543 | u8 stk[16], auth; |
543 | __le64 rand = 0; | 544 | __le64 rand = 0; |
@@ -856,6 +857,9 @@ static bool smp_ltk_encrypt(struct l2cap_conn *conn, u8 sec_level) | |||
856 | hci_le_start_enc(hcon, key->ediv, key->rand, key->val); | 857 | hci_le_start_enc(hcon, key->ediv, key->rand, key->val); |
857 | hcon->enc_key_size = key->enc_size; | 858 | hcon->enc_key_size = key->enc_size; |
858 | 859 | ||
860 | /* We never store STKs for master role, so clear this flag */ | ||
861 | clear_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); | ||
862 | |||
859 | return true; | 863 | return true; |
860 | } | 864 | } |
861 | 865 | ||