Skip to content

Commit 3bf1887

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: Classic: SMP: Store derived LK if SMP_FLAG_BOND is set
When deriving the new LK, remove the old LK if it exists. Store the derived LK if the flag `SMP_FLAG_BOND` of LE SMP is set. Signed-off-by: Lyle Zhu <[email protected]>
1 parent 0013976 commit 3bf1887

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
@@ -810,6 +810,12 @@ static void sc_derive_link_key(struct bt_smp *smp)
810810
return;
811811
}
812812

813+
/* Remove the bonding information */
814+
link_key = bt_keys_find_link_key(&conn->le.dst.a);
815+
if (link_key != NULL) {
816+
bt_keys_link_key_clear(link_key);
817+
}
818+
813819
/*
814820
* At this point remote device identity is known so we can use
815821
* destination address here
@@ -855,6 +861,11 @@ static void sc_derive_link_key(struct bt_smp *smp)
855861
} else {
856862
link_key->flags &= ~BT_LINK_KEY_AUTHENTICATED;
857863
}
864+
865+
if (atomic_test_bit(smp->flags, SMP_FLAG_BOND)) {
866+
/* Store the link key */
867+
bt_keys_link_key_store(link_key);
868+
}
858869
}
859870

860871
static void smp_br_reset(struct bt_smp_br *smp)

0 commit comments

Comments
 (0)