Skip to content

Commit dba8951

Browse files
committed
Bluetooth: Host: Add legacy pairing test config
Adds the `CONFIG_BT_SMP_ENFORCE_LEGACY_PAIRING` Kconfig option to force devices to use legacy pairing. This has a dependency on `CONFIG_BT_TESTING` as it is only intended for testing purposes, and use of legacy pairing is discouraged. Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
1 parent 0f9932a commit dba8951

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

subsys/bluetooth/host/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,15 @@ config BT_CONN_DISABLE_SECURITY
11631163
WARNING: This option enables anyone to snoop on-air traffic.
11641164
Use of this feature in production is strongly discouraged.
11651165

1166+
config BT_SMP_ENFORCE_LEGACY_PAIRING
1167+
bool "Enforce legacy pairing"
1168+
depends on BT_TESTING
1169+
depends on !(BT_SMP_SC_PAIR_ONLY || BT_SMP_SC_ONLY)
1170+
help
1171+
This option enforces legacy pairing. This is required for testing
1172+
legacy pairing between two Zephyr Bluetooth devices, as without this
1173+
option the devices will default to using Secure Connections pairing.
1174+
11661175
rsource "./classic/Kconfig"
11671176

11681177
config BT_HCI_VS_EVT_USER

subsys/bluetooth/host/smp.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,21 @@ LOG_MODULE_REGISTER(bt_smp);
9393
#if defined(CONFIG_BT_CLASSIC)
9494

9595
#define BT_SMP_AUTH_MASK_SC 0x2f
96-
#if defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
96+
#if defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) || defined(CONFIG_BT_SMP_ENFORCE_LEGACY_PAIRING)
9797
#define BT_SMP_AUTH_DEFAULT (BT_SMP_AUTH_BONDING_FLAGS | BT_SMP_AUTH_CT2)
9898
#else
9999
#define BT_SMP_AUTH_DEFAULT (BT_SMP_AUTH_BONDING_FLAGS | BT_SMP_AUTH_CT2 |\
100100
BT_SMP_AUTH_SC)
101-
#endif /* CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY */
101+
#endif /* CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY || CONFIG_BT_SMP_ENFORCE_LEGACY_PAIRING */
102102

103103
#else
104104

105105
#define BT_SMP_AUTH_MASK_SC 0x0f
106-
#if defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
106+
#if defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) || defined(CONFIG_BT_SMP_ENFORCE_LEGACY_PAIRING)
107107
#define BT_SMP_AUTH_DEFAULT (BT_SMP_AUTH_BONDING_FLAGS)
108108
#else
109109
#define BT_SMP_AUTH_DEFAULT (BT_SMP_AUTH_BONDING_FLAGS | BT_SMP_AUTH_SC)
110-
#endif /* CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY */
110+
#endif /* CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY || CONFIG_BT_SMP_ENFORCE_LEGACY_PAIRING */
111111

112112
#endif /* CONFIG_BT_CLASSIC */
113113

@@ -322,7 +322,8 @@ static struct {
322322

323323
static bool le_sc_supported(void)
324324
{
325-
if (IS_ENABLED(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)) {
325+
if (IS_ENABLED(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) ||
326+
IS_ENABLED(CONFIG_BT_SMP_ENFORCE_LEGACY_PAIRING)) {
326327
return false;
327328
}
328329

0 commit comments

Comments
 (0)