summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-02-04 15:10:41 -0800
committerJohan Hedberg <johan.hedberg@nokia.com>2009-02-04 15:10:41 -0800
commit8493d6363e61f1ef68763aab8e65f75be7f67fac (patch)
tree6e16a93a5c7ccaf16bc0393e61218e9ad2b6e0d3 /src
parent1d2672966f514507f82058782034c481800122e6 (diff)
Don't store the link key for "no bonding" cases
We should not store the link key if either side had "no bonding" as their authentication requirement.
Diffstat (limited to 'src')
-rw-r--r--src/dbus-hci.c17
-rw-r--r--src/device.c2
2 files changed, 14 insertions, 5 deletions
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index 562609e0..5238d36f 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -902,15 +902,22 @@ int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
{
struct btd_device *device;
struct btd_adapter *adapter;
- int err;
+ uint8_t local_auth = 0xff, remote_auth;
if (!get_adapter_and_device(local, peer, &adapter, &device, TRUE))
return -ENODEV;
- err = write_link_key(local, peer, key, key_type, pin_length);
- if (err < 0) {
- error("write_link_key: %s (%d)", strerror(-err), -err);
- return err;
+ 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 (err < 0) {
+ error("write_link_key: %s (%d)", strerror(-err), -err);
+ return err;
+ }
}
/* If this is not the first link key set a flag so a subsequent auth
diff --git a/src/device.c b/src/device.c
index fa8658e5..68d7bf21 100644
--- a/src/device.c
+++ b/src/device.c
@@ -640,6 +640,8 @@ struct btd_device *device_create(DBusConnection *conn, struct btd_adapter *adapt
str2ba(address, &device->bdaddr);
device->adapter = adapter;
+ device->auth = 0xff;
+
return device;
}