Skip to content

Commit 3712b96

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: Classic: SMP: Avoid derived LE keys be added multiple times
In current implementation, the flag `local_dist` will be cleared when the distributed key frame is performed if the local is the SMP initiator. After the distributed key is sent out, the function `smp_pairing_br_complete()` will be called if all bits of `local_dist` are cleared. It causes the function `smp_pairing_br_complete()` will be called multiple times. Add a flag `local_distributed` to flag the all sent keys. Add only the flag `local_distributed` is not set, preform the key distribution frame. Signed-off-by: Lyle Zhu <[email protected]>
1 parent 8bb67c5 commit 3712b96

File tree

1 file changed

+9
-4
lines changed
  • subsys/bluetooth/host

1 file changed

+9
-4
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ struct bt_smp_br {
262262
/* Remote key distribution */
263263
uint8_t remote_dist;
264264

265+
/* Local keys have been distributed */
266+
uint8_t local_distributed;
267+
265268
/* Encryption Key Size used for connection */
266269
uint8_t enc_key_size;
267270

@@ -1089,12 +1092,13 @@ static void smp_br_distribute_keys(struct bt_smp_br *smp)
10891092
}
10901093

10911094
#if defined(CONFIG_BT_PRIVACY)
1092-
if (smp->local_dist & BT_SMP_DIST_ID_KEY) {
1095+
if ((smp->local_dist & BT_SMP_DIST_ID_KEY) &&
1096+
((smp->local_distributed & BT_SMP_DIST_ID_KEY) == 0)) {
10931097
struct bt_smp_ident_info *id_info;
10941098
struct bt_smp_ident_addr_info *id_addr_info;
10951099
struct net_buf *buf;
10961100

1097-
smp->local_dist &= ~BT_SMP_DIST_ID_KEY;
1101+
smp->local_distributed |= BT_SMP_DIST_ID_KEY;
10981102

10991103
buf = smp_br_create_pdu(smp, BT_SMP_CMD_IDENT_INFO,
11001104
sizeof(*id_info));
@@ -1123,11 +1127,12 @@ static void smp_br_distribute_keys(struct bt_smp_br *smp)
11231127
#endif /* CONFIG_BT_PRIVACY */
11241128

11251129
#if defined(CONFIG_BT_SIGNING)
1126-
if (smp->local_dist & BT_SMP_DIST_SIGN) {
1130+
if ((smp->local_dist & BT_SMP_DIST_SIGN) &&
1131+
((smp->local_distributed & BT_SMP_DIST_SIGN) == 0)) {
11271132
struct bt_smp_signing_info *info;
11281133
struct net_buf *buf;
11291134

1130-
smp->local_dist &= ~BT_SMP_DIST_SIGN;
1135+
smp->local_distributed |= BT_SMP_DIST_SIGN;
11311136

11321137
buf = smp_br_create_pdu(smp, BT_SMP_CMD_SIGNING_INFO,
11331138
sizeof(*info));

0 commit comments

Comments
 (0)