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
10 changes: 10 additions & 0 deletions nimble/host/include/host/ble_hs.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,16 @@ struct ble_hs_cfg {
*/
unsigned sm_keypress:1;

/** @brief Security Manager automatic pairing on Security Request
*
* If set (default), a Security Request from a peer for which no keys are
* stored makes the host send a Pairing Request immediately. If cleared,
* such a Security Request is reported as handled but no pairing is
* started; the application initiates pairing itself
* (e.g. via ble_gap_security_initiate()).
*/
unsigned sm_sec_req_auto_pair:1;

/** @brief Security Manager Local Key Distribution Mask */
uint8_t sm_our_key_dist;

Expand Down
1 change: 1 addition & 0 deletions nimble/host/src/ble_hs_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct ble_hs_cfg ble_hs_cfg = {
.sm_mitm = MYNEWT_VAL(BLE_SM_MITM),
.sm_sc = MYNEWT_VAL(BLE_SM_SC),
.sm_keypress = MYNEWT_VAL(BLE_SM_KEYPRESS),
.sm_sec_req_auto_pair = MYNEWT_VAL(BLE_SM_SEC_REQ_AUTO_PAIR),
.sm_our_key_dist = MYNEWT_VAL(BLE_SM_OUR_KEY_DIST),
.sm_their_key_dist = MYNEWT_VAL(BLE_SM_THEIR_KEY_DIST),
};
11 changes: 10 additions & 1 deletion nimble/host/src/ble_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,16 @@ ble_sm_sec_req_rx(uint16_t conn_handle, struct os_mbuf **om,
}
}
} else {
/* no keys present, start pairing */
/* no keys present: start pairing, unless the application wants to
* initiate pairing itself. In that case only a clean "no keys"
* result is ignored; store errors are propagated.
*/
if (!ble_hs_cfg.sm_sec_req_auto_pair) {
if (res->app_status == BLE_HS_ENOENT) {
res->app_status = 0;
}
return;
}
start_pairing = true;
}

Expand Down
6 changes: 6 additions & 0 deletions nimble/host/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ syscfg.defs:
description: >
Whether keypress support is advertised during pairing. (0/1)
value: 0
BLE_SM_SEC_REQ_AUTO_PAIR:
description: >
Whether a Security Request from a peer with no stored keys
automatically starts pairing. When 0 the application is
expected to initiate pairing itself. (0/1)
value: 1
BLE_SM_OUR_KEY_DIST:
description: >
A bitmap indicating which keys to distribute during pairing. The
Expand Down
4 changes: 4 additions & 0 deletions porting/examples/linux/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@
#define MYNEWT_VAL_BLE_SM_KEYPRESS (0)
#endif

#ifndef MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR
#define MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR (1)
#endif

#ifndef MYNEWT_VAL_BLE_SM_LEGACY
#define MYNEWT_VAL_BLE_SM_LEGACY (1)
#endif
Expand Down
4 changes: 4 additions & 0 deletions porting/examples/linux_blemesh/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@
#define MYNEWT_VAL_BLE_SM_KEYPRESS (0)
#endif

#ifndef MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR
#define MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR (1)
#endif

#ifndef MYNEWT_VAL_BLE_SM_LEGACY
#define MYNEWT_VAL_BLE_SM_LEGACY (1)
#endif
Expand Down
4 changes: 4 additions & 0 deletions porting/examples/linux_blemesh_shell/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,10 @@
#define MYNEWT_VAL_BLE_SM_KEYPRESS (0)
#endif

#ifndef MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR
#define MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR (1)
#endif

#ifndef MYNEWT_VAL_BLE_SM_LEGACY
#define MYNEWT_VAL_BLE_SM_LEGACY (1)
#endif
Expand Down
4 changes: 4 additions & 0 deletions porting/examples/nuttx/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@
#define MYNEWT_VAL_BLE_SM_KEYPRESS (0)
#endif

#ifndef MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR
#define MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR (1)
#endif

#ifndef MYNEWT_VAL_BLE_SM_LEGACY
#define MYNEWT_VAL_BLE_SM_LEGACY (1)
#endif
Expand Down
4 changes: 4 additions & 0 deletions porting/nimble/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@
#define MYNEWT_VAL_BLE_SM_KEYPRESS (0)
#endif

#ifndef MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR
#define MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR (1)
#endif

#ifndef MYNEWT_VAL_BLE_SM_LEGACY
#define MYNEWT_VAL_BLE_SM_LEGACY (1)
#endif
Expand Down
4 changes: 4 additions & 0 deletions porting/npl/riot/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,10 @@
#define MYNEWT_VAL_BLE_SM_KEYPRESS (0)
#endif

#ifndef MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR
#define MYNEWT_VAL_BLE_SM_SEC_REQ_AUTO_PAIR (1)
#endif

#ifndef MYNEWT_VAL_BLE_SM_LEGACY
#define MYNEWT_VAL_BLE_SM_LEGACY (0)
#endif
Expand Down
Loading