Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suit: directive fetch soft failures #17995

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions subsys/suit/platform/src/suit_plat_check_image_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,9 @@ int suit_plat_check_image_match(suit_component_t component, enum suit_cose_alg a
}
}

if (err != SUIT_SUCCESS) {
err = SUIT_FAIL_CONDITION;
}

return err;
}
31 changes: 20 additions & 11 deletions subsys/suit/platform/src/suit_plat_fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int suit_plat_check_fetch(suit_component_t dst_handle, struct zcbor_string *uri,
ret = verify_and_get_sink(dst_handle, &dst_sink, uri, &dst_component_type, false);
if (ret != SUIT_SUCCESS) {
LOG_ERR("Failed to verify component and get end sink");
return ret;
return SUIT_FAIL_CONDITION;
}

/*
Expand All @@ -119,6 +119,7 @@ int suit_plat_check_fetch(suit_component_t dst_handle, struct zcbor_string *uri,
ret = suit_decrypt_filter_get(&dst_sink, enc_info, &dst_sink);
if (ret != SUIT_PLAT_SUCCESS) {
LOG_ERR("Selecting decryption filter failed: %i", ret);
ret = SUIT_FAIL_CONDITION;
}
#else
ret = SUIT_ERR_UNSUPPORTED_PARAMETER;
Expand Down Expand Up @@ -156,7 +157,7 @@ int suit_plat_fetch(suit_component_t dst_handle, struct zcbor_string *uri,
ret = verify_and_get_sink(dst_handle, &dst_sink, uri, &dst_component_type, true);
if (ret != SUIT_SUCCESS) {
LOG_ERR("Failed to verify component end get end sink");
return ret;
return SUIT_FAIL_CONDITION;
}

/*
Expand All @@ -169,6 +170,7 @@ int suit_plat_fetch(suit_component_t dst_handle, struct zcbor_string *uri,
ret = suit_decrypt_filter_get(&dst_sink, enc_info, &dst_sink);
if (ret != SUIT_PLAT_SUCCESS) {
LOG_ERR("Selecting decryption filter failed: %i", ret);
ret = SUIT_FAIL_CONDITION;
}
#else
ret = SUIT_ERR_UNSUPPORTED_PARAMETER;
Expand Down Expand Up @@ -197,13 +199,17 @@ int suit_plat_fetch(suit_component_t dst_handle, struct zcbor_string *uri,
ret = dst_sink.erase(dst_sink.ctx);
if (ret != SUIT_PLAT_SUCCESS) {
LOG_ERR("Sink mem erase failed: %i", ret);
ret = SUIT_FAIL_CONDITION;
}
}

/* Start streaming the data. */
if (ret == SUIT_SUCCESS) {
ret = suit_plat_fetch_domain_specific(dst_handle, dst_component_type, &dst_sink,
uri);
if (ret != SUIT_SUCCESS) {
ret = SUIT_FAIL_CONDITION;
}
}

/*
Expand Down Expand Up @@ -238,12 +244,12 @@ int suit_plat_check_fetch_integrated(suit_component_t dst_handle, struct zcbor_s
ret = suit_plat_component_type_get(dst_handle, &dst_component_type);
if (ret != SUIT_SUCCESS) {
LOG_ERR("Failed to decode component type: %i", ret);
return ret;
return SUIT_FAIL_CONDITION;
}

/* Check if destination component is supported by the fetch operation. */
if (!suit_plat_fetch_integrated_domain_specific_is_type_supported(dst_component_type)) {
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
return SUIT_FAIL_CONDITION;
}

#ifndef CONFIG_SUIT_STREAM_SOURCE_MEMPTR
Expand All @@ -258,7 +264,7 @@ int suit_plat_check_fetch_integrated(suit_component_t dst_handle, struct zcbor_s
ret = suit_sink_select(dst_handle, &dst_sink);
if (ret != SUIT_SUCCESS) {
LOG_ERR("Selecting sink failed: %i", ret);
return ret;
return SUIT_FAIL_CONDITION;
}

/* Append decryption filter if encryption info is provided. */
Expand All @@ -269,7 +275,7 @@ int suit_plat_check_fetch_integrated(suit_component_t dst_handle, struct zcbor_s
LOG_ERR("Selecting decryption filter failed: %i", ret);
}
#else
ret = SUIT_ERR_UNSUPPORTED_PARAMETER;
ret = SUIT_FAIL_CONDITION;
#endif /* CONFIG_SUIT_STREAM_FILTER_DECRYPT */
}

Expand Down Expand Up @@ -305,12 +311,12 @@ int suit_plat_fetch_integrated(suit_component_t dst_handle, struct zcbor_string
ret = suit_plat_component_type_get(dst_handle, &dst_component_type);
if (ret != SUIT_SUCCESS) {
LOG_ERR("Failed to decode component type: %i", ret);
return ret;
return SUIT_FAIL_CONDITION;
}

/* Check if destination component is supported by the fetch operation. */
if (!suit_plat_fetch_integrated_domain_specific_is_type_supported(dst_component_type)) {
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
return SUIT_FAIL_CONDITION;
}

#ifndef CONFIG_SUIT_STREAM_SOURCE_MEMPTR
Expand All @@ -325,7 +331,7 @@ int suit_plat_fetch_integrated(suit_component_t dst_handle, struct zcbor_string
ret = suit_sink_select(dst_handle, &dst_sink);
if (ret != SUIT_SUCCESS) {
LOG_ERR("Selecting sink failed: %i", ret);
return ret;
return SUIT_FAIL_CONDITION;
}

/* Append decryption filter if encryption info is provided. */
Expand All @@ -336,7 +342,7 @@ int suit_plat_fetch_integrated(suit_component_t dst_handle, struct zcbor_string
LOG_ERR("Selecting decryption filter failed: %i", ret);
}
#else
ret = SUIT_ERR_UNSUPPORTED_PARAMETER;
ret = SUIT_FAIL_CONDITION;
#endif /* CONFIG_SUIT_STREAM_FILTER_DECRYPT */
}

Expand All @@ -363,14 +369,17 @@ int suit_plat_fetch_integrated(suit_component_t dst_handle, struct zcbor_string
plat_ret = dst_sink.erase(dst_sink.ctx);
if (plat_ret != SUIT_PLAT_SUCCESS) {
LOG_ERR("Sink mem erase failed, err code: %d", plat_ret);
ret = suit_plat_err_to_processor_err_convert(plat_ret);
ret = SUIT_FAIL_CONDITION;
}
}

/* Start streaming the data. */
if (ret == SUIT_SUCCESS) {
ret = suit_plat_fetch_integrated_domain_specific(dst_handle, dst_component_type,
&dst_sink, payload);
if (ret != SUIT_SUCCESS) {
ret = SUIT_FAIL_CONDITION;
}
}

/*
Expand Down
Loading