diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2009-02-05 16:00:10 -0800 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2009-02-05 16:00:10 -0800 |
commit | 6c4161fad34d0357f15e8c8501d2b7bfc99052ac (patch) | |
tree | 77d17de85c40587c51147def834f2e01bc44436c /src | |
parent | fcbc5b4bd0e81d7f3c062948675e7f19704ca6da (diff) |
Always store changed combination keys
Diffstat (limited to 'src')
-rw-r--r-- | src/dbus-hci.c | 11 | ||||
-rw-r--r-- | src/security.c | 9 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/dbus-hci.c b/src/dbus-hci.c index 879648e6..708c61e4 100644 --- a/src/dbus-hci.c +++ b/src/dbus-hci.c @@ -902,18 +902,23 @@ int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer, { struct btd_device *device; struct btd_adapter *adapter; - uint8_t local_auth = 0xff, remote_auth; + uint8_t local_auth = 0xff, remote_auth, new_key_type; if (!get_adapter_and_device(local, peer, &adapter, &device, TRUE)) return -ENODEV; + if (key_type == 0x06 && old_key_type != 0xff) + new_key_type = old_key_type; + else + new_key_type = key_type; + get_auth_requirements(local, peer, &local_auth); remote_auth = device_get_auth(device); /* Only store the link key if neither side had "no bonding" as a * requirement */ - if (local_auth > 0x01 && remote_auth > 0x01) { - int err = write_link_key(local, peer, key, key_type, pin_length); + if (key_type == 0x06 || (local_auth > 0x01 && remote_auth > 0x01)) { + int err = write_link_key(local, peer, key, new_key_type, pin_length); if (err < 0) { error("write_link_key: %s (%d)", strerror(-err), -err); return err; diff --git a/src/security.c b/src/security.c index ea63b3c9..a61d75fb 100644 --- a/src/security.c +++ b/src/security.c @@ -345,7 +345,7 @@ 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, new_key_type; + uint8_t old_key_type; ba2str(sba, sa); ba2str(dba, da); info("link_key_notify (sba=%s, dba=%s, type=%d)", sa, da, @@ -355,14 +355,9 @@ static void link_key_notify(int dev, bdaddr_t *sba, void *ptr) if (err < 0) 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 = hcid_dbus_link_key_notify(sba, dba, evt->link_key, new_key_type, + err = hcid_dbus_link_key_notify(sba, dba, evt->link_key, evt->key_type, io_data[dev_id].pin_length, old_key_type); if (err < 0) { |