Skip to content

Commit f132cf2

Browse files
committed
protocomm security1: Restart security session if SESSION_STATE_CMD0 is received
With the introduction of cookies to track a session, it is possible that the clients restart the provisioning on the same session, specifically when a user cancels a current provisioning attempt. This can result in an error as the state on the device side and client side will go out of sync. This has now been changed such that if SESSION_STATE_CMD0 is received on an existing session, the state is reset and flow allowed to continue.
1 parent 7755d39 commit f132cf2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

components/protocomm/src/security/security1.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ static esp_err_t handle_session_command1(session_t *cur_session,
175175
return ESP_OK;
176176
}
177177

178+
static esp_err_t sec1_new_session(protocomm_security_handle_t handle, uint32_t session_id);
179+
178180
static esp_err_t handle_session_command0(session_t *cur_session,
179181
uint32_t session_id,
180182
SessionData *req, SessionData *resp,
@@ -186,8 +188,9 @@ static esp_err_t handle_session_command0(session_t *cur_session,
186188
int mbed_err;
187189

188190
if (cur_session->state != SESSION_STATE_CMD0) {
189-
ESP_LOGE(TAG, "Invalid state of session %d (expected %d)", SESSION_STATE_CMD0, cur_session->state);
190-
return ESP_ERR_INVALID_STATE;
191+
ESP_LOGW(TAG, "Invalid state of session %d (expected %d). Restarting session.",
192+
SESSION_STATE_CMD0, cur_session->state);
193+
sec1_new_session(cur_session, session_id);
191194
}
192195

193196
if (in->sc0->client_pubkey.len != PUBLIC_KEY_LEN) {

0 commit comments

Comments
 (0)