summaryrefslogtreecommitdiffstats
path: root/src/security.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-02-04 22:30:21 +0100
committerMarcel Holtmann <marcel@holtmann.org>2009-02-04 22:30:21 +0100
commit2a797e647f8fd17ec6d86a5b0bf122cc0a05aeb2 (patch)
tree7c5a9505a9d9fa14aeafb16833f5b5e7c566bfb6 /src/security.c
parent2ca8fbe3596acaa06d75c6fe98cb9f5b7f1020de (diff)
Store the old link key type for changed combination keys
Diffstat (limited to 'src/security.c')
-rw-r--r--src/security.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/security.c b/src/security.c
index 05788721..6a7a8a2c 100644
--- a/src/security.c
+++ b/src/security.c
@@ -344,18 +344,24 @@ static void link_key_notify(int dev, bdaddr_t *sba, void *ptr)
char sa[18], da[18];
int dev_id, err;
unsigned char old_key[16];
- uint8_t old_key_type;
+ uint8_t old_key_type, new_key_type;
ba2str(sba, sa); ba2str(dba, da);
- info("link_key_notify (sba=%s, dba=%s)", sa, da);
+ info("link_key_notify (sba=%s, dba=%s, type=%d)", sa, da,
+ evt->key_type);
err = read_link_key(sba, dba, old_key, &old_key_type);
if (err < 0)
- old_key_type = 0xFF;
+ old_key_type = 0xff;
+
+ if (evt->key_type == 0x06 && old_key_type != 0xff)
+ new_key_type = old_key_type;
+ else
+ new_key_type = evt->key_type;
dev_id = hci_devid(sa);
- err = write_link_key(sba, dba, evt->link_key, evt->key_type,
+ err = write_link_key(sba, dba, evt->link_key, new_key_type,
io_data[dev_id].pin_length);
if (err < 0) {
uint16_t handle;
@@ -375,7 +381,8 @@ static void link_key_notify(int dev, bdaddr_t *sba, void *ptr)
DISCONNECT_CP_SIZE, &cp);
}
} else
- hcid_dbus_link_key_notify(sba, dba, evt->key_type, old_key_type);
+ hcid_dbus_link_key_notify(sba, dba, evt->key_type,
+ old_key_type);
io_data[dev_id].pin_length = -1;
}