Bluetooth: Add Kconfig option to disable HCI ECDH support

This adds Kconfig option to disable HCI ECDH support.
It will compile out ECDH related code, especially HCI event handlers.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit is contained in:
Mariusz Skamra 2018-11-21 13:53:35 +01:00 committed by Anas Nashif
commit b904ad387f
3 changed files with 17 additions and 2 deletions

View file

@ -273,6 +273,7 @@ config BT_SMP
select TINYCRYPT_AES
select TINYCRYPT_AES_CMAC
select BT_RPA
select BT_ECC
help
This option enables support for the Security Manager Protocol
(SMP), making it possible to pair devices over LE.
@ -488,12 +489,17 @@ config BT_ID_MAX
endif # BT_HCI_HOST
config BT_ECC
bool "Enable ECDH key generation support"
help
This option adds support for ECDH HCI commands.
config BT_TINYCRYPT_ECC
bool "Use TinyCrypt library for ECDH"
select TINYCRYPT
select TINYCRYPT_ECC_DH
depends on BT_HCI_RAW || BT_HCI_HOST
default y if BT_CTLR && (BT_SMP || BT_MESH_PROV)
depends on BT_ECC && (BT_HCI_RAW || BT_HCI_HOST)
default y if BT_CTLR
help
If this option is set TinyCrypt library is used for emulating the
ECDH HCI commands and events needed by e.g. LE Secure Connections.

View file

@ -83,9 +83,11 @@ static bt_ready_cb_t ready_cb;
static bt_le_scan_cb_t *scan_dev_found_cb;
#if defined(CONFIG_BT_ECC)
static u8_t pub_key[64];
static struct bt_pub_key_cb *pub_key_cb;
static bt_dh_key_cb_t dh_key_cb;
#endif /* CONFIG_BT_ECC */
#if defined(CONFIG_BT_BREDR)
static bt_br_discovery_cb_t *discovery_cb;
@ -2958,6 +2960,7 @@ done:
}
#endif /* CONFIG_BT_SMP */
#if defined(CONFIG_BT_ECC)
static void le_pkey_complete(struct net_buf *buf)
{
struct bt_hci_evt_le_p256_public_key_complete *evt = (void *)buf->data;
@ -2988,6 +2991,7 @@ static void le_dhkey_complete(struct net_buf *buf)
dh_key_cb = NULL;
}
}
#endif /* CONFIG_BT_ECC */
static void hci_reset_complete(struct net_buf *buf)
{
@ -3324,12 +3328,14 @@ static void hci_le_meta_event(struct net_buf *buf)
le_ltk_request(buf);
break;
#endif /* CONFIG_BT_SMP */
#if defined(CONFIG_BT_ECC)
case BT_HCI_EVT_LE_P256_PUBLIC_KEY_COMPLETE:
le_pkey_complete(buf);
break;
case BT_HCI_EVT_LE_GENERATE_DHKEY_COMPLETE:
le_dhkey_complete(buf);
break;
#endif /* CONFIG_BT_SMP */
#if defined(CONFIG_BT_OBSERVER)
case BT_HCI_EVT_LE_ADVERTISING_REPORT:
le_adv_report(buf);
@ -5740,6 +5746,7 @@ u16_t bt_hci_get_cmd_opcode(struct net_buf *buf)
return cmd(buf)->opcode;
}
#if defined(CONFIG_BT_ECC)
int bt_pub_key_gen(struct bt_pub_key_cb *new_cb)
{
struct bt_pub_key_cb *cb;
@ -5825,6 +5832,7 @@ int bt_dh_key_gen(const u8_t remote_pk[64], bt_dh_key_cb_t cb)
return 0;
}
#endif /* CONFIG_BT_ECC */
#if defined(CONFIG_BT_BREDR)
int bt_br_oob_get_local(struct bt_br_oob *oob)

View file

@ -22,6 +22,7 @@ if BT_MESH
# Virtual option enabled whenever Generic Provisioning layer is needed
config BT_MESH_PROV
bool
select BT_ECC
config BT_MESH_PB_ADV
bool "Provisioning support using the advertising bearer (PB-ADV)"