aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-02-16 12:59:06 -0800
committerJohan Hedberg <johan.hedberg@intel.com>2014-02-17 15:58:14 +0200
commit0fe442ff854b7bf93e57c7f3964b05a6438de3db (patch)
tree94318dc83c771c905f26b69f7bee9582828ecac9
parent490cb0b318a0619ae545e63d6773f01caf29d4a0 (diff)
Bluetooth: Fix sending wrong store hint for new long term keys
The long term keys should only be stored when they belong to an indentity address. The identity address can either be a public address or a random static address. For all other addresses (unresovable or resolvable) tell userspace that the long term key is not persistent. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--net/bluetooth/hci_core.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e7746690d62..58d2f9bf241 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2685,6 +2685,7 @@ int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
{
struct smp_ltk *key, *old_key;
bool master = ltk_type_master(type);
+ u8 persistent;
old_key = hci_find_ltk_by_addr(hdev, bdaddr, addr_type, master);
if (old_key)
@@ -2708,8 +2709,13 @@ int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
if (!new_key)
return 0;
+ if (addr_type == ADDR_LE_DEV_RANDOM && (bdaddr->b[5] & 0xc0) != 0xc0)
+ persistent = 0;
+ else
+ persistent = 1;
+
if (type == HCI_SMP_LTK || type == HCI_SMP_LTK_SLAVE)
- mgmt_new_ltk(hdev, key, 1);
+ mgmt_new_ltk(hdev, key, persistent);
return 0;
}