Skip to content

Commit c63ff48

Browse files
authored
host: sm: callback is not triggered in case of invalid key size
pairing callback was not triggered in case of encryption key size checks failed. Fix it by setting the res->enc_cb value to 1 for check failure.
1 parent 895ed28 commit c63ff48

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

nimble/host/src/ble_sm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,18 +1921,22 @@ ble_sm_pair_rsp_rx(uint16_t conn_handle, struct os_mbuf **om,
19211921
if (rsp->max_enc_key_size < BLE_SM_PAIR_KEY_SZ_MIN) {
19221922
res->sm_err = BLE_SM_ERR_ENC_KEY_SZ;
19231923
res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_ENC_KEY_SZ);
1924+
res->enc_cb = 1;
19241925
} else if (rsp->max_enc_key_size > BLE_SM_PAIR_KEY_SZ_MAX) {
19251926
res->sm_err = BLE_SM_ERR_INVAL;
19261927
res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_INVAL);
1928+
res->enc_cb = 1;
19271929
} else if (MYNEWT_VAL(BLE_SM_SC_ONLY) && (rsp->max_enc_key_size != BLE_SM_PAIR_KEY_SZ_MAX)) {
19281930
/* Fail if Secure Connections Only mode is on and remote does not meet
19291931
* key size requirements - MITM was checked in last step
19301932
*/
19311933
res->sm_err = BLE_SM_ERR_ENC_KEY_SZ;
19321934
res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_ENC_KEY_SZ);
1935+
res->enc_cb = 1;
19331936
} else if (!ble_sm_verify_auth_requirements(rsp->authreq)) {
19341937
res->sm_err = BLE_SM_ERR_AUTHREQ;
19351938
res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_AUTHREQ);
1939+
res->enc_cb = 1;
19361940
} else {
19371941
ble_sm_pair_cfg(proc);
19381942

0 commit comments

Comments
 (0)