Skip to content
Merged
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
8 changes: 8 additions & 0 deletions subsys/bluetooth/host/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,14 @@ config BT_BONDABLE
Bonding flag in AuthReq of SMP Pairing Request/Response will be set
indicating the support for this mode.

config BT_BONDING_REQUIRED
bool "Always require bonding"
depends on BT_BONDABLE
help
When this option is enabled remote devices are required to always
set the bondable flag in their pairing request. Any other kind of
requests will be rejected.

config BT_STORE_DEBUG_KEYS
bool "Store Debug Mode bonds"
help
Expand Down
12 changes: 12 additions & 0 deletions subsys/bluetooth/host/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2774,6 +2774,9 @@ static u8_t smp_pairing_req(struct bt_smp *smp, struct net_buf *buf)
if ((rsp->auth_req & BT_SMP_AUTH_BONDING) &&
(req->auth_req & BT_SMP_AUTH_BONDING)) {
atomic_set_bit(smp->flags, SMP_FLAG_BOND);
} else if (IS_ENABLED(CONFIG_BT_BONDING_REQUIRED)) {
/* Reject pairing req if not both intend to bond */
return BT_SMP_ERR_UNSPECIFIED;
}

atomic_set_bit(smp->flags, SMP_FLAG_PAIRING);
Expand Down Expand Up @@ -2955,6 +2958,9 @@ static u8_t smp_pairing_rsp(struct bt_smp *smp, struct net_buf *buf)
if ((rsp->auth_req & BT_SMP_AUTH_BONDING) &&
(req->auth_req & BT_SMP_AUTH_BONDING)) {
atomic_set_bit(smp->flags, SMP_FLAG_BOND);
} else if (IS_ENABLED(CONFIG_BT_BONDING_REQUIRED)) {
/* Reject pairing req if not both intend to bond */
return BT_SMP_ERR_UNSPECIFIED;
}

smp->method = get_pair_method(smp, rsp->io_capability);
Expand Down Expand Up @@ -3686,6 +3692,12 @@ static u8_t smp_security_request(struct bt_smp *smp, struct net_buf *buf)
auth = req->auth_req & BT_SMP_AUTH_MASK;
}

if (IS_ENABLED(CONFIG_BT_BONDING_REQUIRED) &&
!(bondable && (auth & BT_SMP_AUTH_BONDING))) {
/* Reject security req if not both intend to bond */
return BT_SMP_ERR_UNSPECIFIED;
}

if (conn->le.keys) {
/* Make sure we have an LTK to encrypt with */
if (!(conn->le.keys->keys & (BT_KEYS_LTK_P256 | BT_KEYS_LTK))) {
Expand Down