Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions subsys/bluetooth/host/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,15 @@ config BT_CONN_DISABLE_SECURITY
WARNING: This option enables anyone to snoop on-air traffic.
Use of this feature in production is strongly discouraged.

config BT_SMP_LEGACY_PAIR_ONLY
bool "Force legacy pairing"
depends on BT_TESTING
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not allowed to only support legacy pairing in recent version of the core spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's allowed, but since Zephyr 3.0 the use of legacy pairing has been discouraged for being less/not secure, so I didn't want this Kconfig to imply otherwise. Zephyr-devices support legacy pairing with devices that do not support secure connections, but since Zephyr-devices do support it they will always default to this (and thus this config is needed to force it).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should allow setting this without BT_TESTING, but treat it as a warning for the above reasons. That would be similar to how we treat e.g. BT_USE_DEBUG_KEYS, where we have both Kconfig and CMake warnings if it's enabled.

Alternatively we should consider adding the same depends on BT_TESTING for things like BT_USE_DEBUG_KEYS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both suggestions are fine by me, do you have any thoughts @jhedberg?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think depends on BT_TESTING is the right way. BT_USE_DEBUG_KEYS should have it as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhedberg Should we apply depends on BT_TESTING for all the other similar configs? And then if we do, should we remove the warning for them as well, and add/keep only a warning for BT_TESTING?

depends on !(BT_SMP_SC_PAIR_ONLY || BT_SMP_SC_ONLY)
help
This option enforces legacy pairing. This is required for testing
legacy pairing between two Zephyr Bluetooth devices, as without this
option the devices will default to using Secure Connections pairing.

rsource "./classic/Kconfig"

config BT_HCI_VS_EVT_USER
Expand Down
11 changes: 6 additions & 5 deletions subsys/bluetooth/host/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,21 @@
#if defined(CONFIG_BT_CLASSIC)

#define BT_SMP_AUTH_MASK_SC 0x2f
#if defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
#if defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) || defined(CONFIG_BT_SMP_LEGACY_PAIR_ONLY)
#define BT_SMP_AUTH_DEFAULT (BT_SMP_AUTH_BONDING_FLAGS | BT_SMP_AUTH_CT2)
#else
#define BT_SMP_AUTH_DEFAULT (BT_SMP_AUTH_BONDING_FLAGS | BT_SMP_AUTH_CT2 |\
BT_SMP_AUTH_SC)
#endif /* CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY */
#endif /* CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY || CONFIG_BT_SMP_LEGACY_PAIR_ONLY */

#else

#define BT_SMP_AUTH_MASK_SC 0x0f
#if defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
#if defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) || defined(CONFIG_BT_SMP_LEGACY_PAIR_ONLY)
#define BT_SMP_AUTH_DEFAULT (BT_SMP_AUTH_BONDING_FLAGS)
#else
#define BT_SMP_AUTH_DEFAULT (BT_SMP_AUTH_BONDING_FLAGS | BT_SMP_AUTH_SC)
#endif /* CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY */
#endif /* CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY || CONFIG_BT_SMP_LEGACY_PAIR_ONLY */

#endif /* CONFIG_BT_CLASSIC */

Expand Down Expand Up @@ -322,7 +322,8 @@

static bool le_sc_supported(void)
{
if (IS_ENABLED(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)) {
if (IS_ENABLED(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) ||

Check warning on line 325 in subsys/bluetooth/host/smp.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Identical sub-expressions on both sides of operator "||".

See more on https://sonarcloud.io/project/issues?id=zephyrproject-rtos_zephyr&issues=AZqhYqtlO7-2aqJKN4x6&open=AZqhYqtlO7-2aqJKN4x6&pullRequest=99742
IS_ENABLED(CONFIG_BT_SMP_LEGACY_PAIR_ONLY)) {
return false;
}

Expand Down