From 3989d684d48d052af2783f0c42f47d41d5854312 Mon Sep 17 00:00:00 2001 From: fangzhenwei Date: Tue, 25 Feb 2025 20:09:27 +0800 Subject: [PATCH] Bluetooth: GAP: SMP: check sc feature before pairing request bug: v/54624 Secure authentication shall be performed when both devices support the Secure Connections (Controller Support) and Secure Connections (Host Support) features. Signed-off-by: fangzhenwei --- include/zephyr/bluetooth/hci_types.h | 1 + subsys/bluetooth/host/hci_core.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/zephyr/bluetooth/hci_types.h b/include/zephyr/bluetooth/hci_types.h index dcb5a75d38a..70e3ba7761d 100644 --- a/include/zephyr/bluetooth/hci_types.h +++ b/include/zephyr/bluetooth/hci_types.h @@ -145,6 +145,7 @@ struct bt_hci_cmd_hdr { #define BT_FEAT_LE(feat) BT_FEAT_TEST(feat, 0, 4, 6) #define BT_FEAT_EXT_FEATURES(feat) BT_FEAT_TEST(feat, 0, 7, 7) #define BT_FEAT_HOST_SSP(feat) BT_FEAT_TEST(feat, 1, 0, 0) +#define BT_FEAT_HOST_SC(feat) BT_FEAT_TEST(feat, 1, 0, 3) #define BT_FEAT_SC(feat) BT_FEAT_TEST(feat, 2, 1, 0) #define BT_FEAT_LMP_SCO_CAPABLE(feat) BT_FEAT_TEST(feat, 0, 1, 3) diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index bd79be28f20..a69d3271bc3 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -2235,7 +2235,9 @@ static void hci_encrypt_change(struct net_buf *buf) * central on the link */ if (atomic_test_bit(conn->flags, BT_CONN_BR_PAIRED) && - conn->role == BT_CONN_ROLE_CENTRAL) { + conn->role == BT_CONN_ROLE_CENTRAL && + BT_FEAT_HOST_SC(conn->br.features) && + BT_FEAT_SC(bt_dev.features)) { bt_smp_br_send_pairing_req(conn); } }