Skip to content

Commit 58f6ca8

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: Classic: SMP: Remove old LE keys before upgrading keys
Remove the old LE keys from resolving list and NVM before upgrading the keys. Signed-off-by: Lyle Zhu <[email protected]>
1 parent 3712b96 commit 58f6ca8

File tree

1 file changed

+11
-0
lines changed
  • subsys/bluetooth/host

1 file changed

+11
-0
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,11 @@ static void smp_br_id_add_replace(struct bt_keys *keys)
829829
{
830830
struct bt_keys *conflict;
831831

832+
/* Check whether key has been added to resolving list. */
833+
if (keys->state & BT_KEYS_ID_ADDED) {
834+
bt_id_del(keys);
835+
}
836+
832837
conflict = bt_id_find_conflict(keys);
833838
if (conflict != NULL) {
834839
int err;
@@ -995,6 +1000,12 @@ static void smp_br_derive_ltk(struct bt_smp_br *smp)
9951000
bt_addr_copy(&addr.a, &conn->br.dst);
9961001
addr.type = BT_ADDR_LE_PUBLIC;
9971002

1003+
keys = bt_keys_find_addr(conn->id, &addr);
1004+
if (keys != NULL) {
1005+
LOG_DBG("Clear the current keys for %s", bt_addr_le_str(&addr));
1006+
bt_keys_clear(keys);
1007+
}
1008+
9981009
keys = bt_keys_get_type(BT_KEYS_LTK_P256, conn->id, &addr);
9991010
if (!keys) {
10001011
LOG_ERR("Unable to get keys for %s", bt_addr_le_str(&addr));

0 commit comments

Comments
 (0)