Skip to content

Commit

Permalink
host: sm: callback is not triggered in case of invalid key size
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
guy-m authored Jan 8, 2025
1 parent 895ed28 commit c63ff48
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nimble/host/src/ble_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1921,18 +1921,22 @@ ble_sm_pair_rsp_rx(uint16_t conn_handle, struct os_mbuf **om,
if (rsp->max_enc_key_size < BLE_SM_PAIR_KEY_SZ_MIN) {
res->sm_err = BLE_SM_ERR_ENC_KEY_SZ;
res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_ENC_KEY_SZ);
res->enc_cb = 1;
} else if (rsp->max_enc_key_size > BLE_SM_PAIR_KEY_SZ_MAX) {
res->sm_err = BLE_SM_ERR_INVAL;
res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_INVAL);
res->enc_cb = 1;
} else if (MYNEWT_VAL(BLE_SM_SC_ONLY) && (rsp->max_enc_key_size != BLE_SM_PAIR_KEY_SZ_MAX)) {
/* Fail if Secure Connections Only mode is on and remote does not meet
* key size requirements - MITM was checked in last step
*/
res->sm_err = BLE_SM_ERR_ENC_KEY_SZ;
res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_ENC_KEY_SZ);
res->enc_cb = 1;
} else if (!ble_sm_verify_auth_requirements(rsp->authreq)) {
res->sm_err = BLE_SM_ERR_AUTHREQ;
res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_AUTHREQ);
res->enc_cb = 1;
} else {
ble_sm_pair_cfg(proc);

Expand Down

0 comments on commit c63ff48

Please sign in to comment.