Skip to content

Commit bdb4e00

Browse files
joerchangmarull
authored andcommitted
[nrf fromtree] Bluetooth: host: Fix SMP local keys check when starting encryption
Fix SMP check of existing local keys when attempting to start security with required security mode 1 level 4. The logic for checking the conditions was wrong, leading to a situation where encryption would be attempted to be started by the central instead of initiating a new pairing procedure. This would fail when the connection was encrypted and the connection would be disconnected. Signed-off-by: Joakim Andersson <[email protected]> (cherry picked from commit 83d5402) Signed-off-by: Herman Berget <[email protected]>
1 parent 7e951d0 commit bdb4e00

File tree

1 file changed

+5
-5
lines changed
  • subsys/bluetooth/host

1 file changed

+5
-5
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,15 @@ static bool smp_keys_check(struct bt_conn *conn)
374374
return false;
375375
}
376376

377-
if (conn->required_sec_level > BT_SECURITY_L2 &&
377+
if (conn->required_sec_level >= BT_SECURITY_L3 &&
378378
!(conn->le.keys->flags & BT_KEYS_AUTHENTICATED)) {
379379
return false;
380380
}
381381

382-
if (conn->required_sec_level > BT_SECURITY_L3 &&
383-
!(conn->le.keys->flags & BT_KEYS_AUTHENTICATED) &&
384-
!(conn->le.keys->keys & BT_KEYS_LTK_P256) &&
385-
!(conn->le.keys->enc_size == BT_SMP_MAX_ENC_KEY_SIZE)) {
382+
if (conn->required_sec_level >= BT_SECURITY_L4 &&
383+
!((conn->le.keys->flags & BT_KEYS_AUTHENTICATED) &&
384+
(conn->le.keys->keys & BT_KEYS_LTK_P256) &&
385+
(conn->le.keys->enc_size == BT_SMP_MAX_ENC_KEY_SIZE))) {
386386
return false;
387387
}
388388

0 commit comments

Comments
 (0)