Merge pull request #15093 from bergzand/pr/suit/pol_check_before_fetch

suit: Move policy check to before fetch
This commit is contained in:
benpicco 2020-09-26 19:32:13 +02:00 committed by GitHub
commit d1afb8983e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -87,6 +87,7 @@ typedef enum {
current sequence number */
SUIT_ERR_SIGNATURE = -6, /**< Unable to verify signature */
SUIT_ERR_DIGEST_MISMATCH = -7, /**< Digest mismatch with COSE and SUIT */
SUIT_ERR_POLICY_FORBIDDEN = -8, /**< Denied because of policy mismatch */
} suit_error_t;
/**

View File

@ -270,6 +270,13 @@ static int _dtv_fetch(suit_manifest_t *manifest, int key,
const uint8_t *url;
size_t url_len;
/* Check the policy before fetching anything */
int res = suit_policy_check(manifest);
if (res) {
return SUIT_ERR_POLICY_FORBIDDEN;
}
suit_component_t *comp = _get_component(manifest);
nanocbor_value_t param_uri;
@ -289,7 +296,7 @@ static int _dtv_fetch(suit_manifest_t *manifest, int key,
int target_slot = riotboot_slot_other();
riotboot_flashwrite_init(manifest->writer, target_slot);
int res = -1;
res = -1;
if (0) {}
#ifdef MODULE_SUIT_TRANSPORT_COAP

View File

@ -379,12 +379,6 @@ static void _suit_handle_url(const char *url)
LOG_INFO("manifest parsed, but no image fetched\n");
return;
}
res = suit_policy_check(&manifest);
if (res) {
return;
}
#endif
if (res == 0) {
LOG_INFO("suit_coap: finalizing image flash\n");