Bluetooth: Restrict long term keys to public and static addresses
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 16 Feb 2014 20:59:05 +0000 (12:59 -0800)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 17 Feb 2014 13:58:14 +0000 (15:58 +0200)
The long term keys should be associated with an identity address. Valid
identity addresses are public addresses or static addresses. So only
allow these two as valid address information for long term keys.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
net/bluetooth/mgmt.c

index ce7ef339b1c4c4827e7c08d81027d9c9f4bbe63a..70bef3d5db579a741e1d2fbd11e39657245ae25f 100644 (file)
@@ -4162,9 +4162,19 @@ static bool ltk_is_valid(struct mgmt_ltk_info *key)
 {
        if (key->master != 0x00 && key->master != 0x01)
                return false;
-       if (!bdaddr_type_is_le(key->addr.type))
-               return false;
-       return true;
+
+       switch (key->addr.type) {
+       case BDADDR_LE_PUBLIC:
+               return true;
+
+       case BDADDR_LE_RANDOM:
+               /* Two most significant bits shall be set */
+               if ((key->addr.bdaddr.b[5] & 0xc0) != 0xc0)
+                       return false;
+               return true;
+       }
+
+       return false;
 }
 
 static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
This page took 0.031741 seconds and 5 git commands to generate.