From 8493d6363e61f1ef68763aab8e65f75be7f67fac Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 4 Feb 2009 15:10:41 -0800 Subject: 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. --- src/dbus-hci.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/dbus-hci.c') 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 -- cgit