From 2424bfd8699d9b6a38e0d609a1d6760f1e6c6c34 Mon Sep 17 00:00:00 2001 From: Lyle Zhu Date: Fri, 7 Jun 2024 17:49:54 +0800 Subject: [PATCH] Bluetooth: BR: improve br_sufficient_key_size Currently, the minimum value of encryption key size is `BT_HCI_ENCRYPTION_KEY_SIZE_MIN`. Add a new Kconfig `BT_BR_MIN_ENC_KEY_SIZE`. It is used to set the specific minimum encryption key size. The default value is `BT_SMP_MIN_ENC_KEY_SIZE`. And it can be configured if `BT_SMP_SC_ONLY` is not enabled. Use `CONFIG_BT_BR_MIN_ENC_KEY_SIZE` as minimum encryption key size in `br_sufficient_key_size`. Signed-off-by: Lyle Zhu --- subsys/bluetooth/host/classic/Kconfig | 9 +++++++++ subsys/bluetooth/host/classic/br.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/classic/Kconfig b/subsys/bluetooth/host/classic/Kconfig index 5c084f03609..3723e117620 100644 --- a/subsys/bluetooth/host/classic/Kconfig +++ b/subsys/bluetooth/host/classic/Kconfig @@ -18,6 +18,15 @@ config BT_CLASSIC This option enables Bluetooth BR/EDR support if BT_CLASSIC +config BT_BR_MIN_ENC_KEY_SIZE + int + prompt "Minimum encryption key size accepted in octets" if !BT_SMP_SC_ONLY + default BT_SMP_MIN_ENC_KEY_SIZE + range 7 16 + help + This option sets the minimum encryption key size accepted during pairing + for classic. + config BT_MAX_SCO_CONN int "Maximum number of simultaneous SCO connections" default 1 diff --git a/subsys/bluetooth/host/classic/br.c b/subsys/bluetooth/host/classic/br.c index 65a0fe80125..afdbb0b1d9e 100644 --- a/subsys/bluetooth/host/classic/br.c +++ b/subsys/bluetooth/host/classic/br.c @@ -141,7 +141,7 @@ static bool br_sufficient_key_size(struct bt_conn *conn) return key_size == BT_HCI_ENCRYPTION_KEY_SIZE_MAX; } - return key_size >= BT_HCI_ENCRYPTION_KEY_SIZE_MIN; + return key_size >= CONFIG_BT_BR_MIN_ENC_KEY_SIZE; } bool bt_br_update_sec_level(struct bt_conn *conn)