|
19 | 19 | #include <sdfw/sdfw_services/suit_service.h> |
20 | 20 | #include <suit_envelope_info.h> |
21 | 21 | #include <suit_plat_mem_util.h> |
| 22 | +#include <suit_plat_decode_util.h> |
22 | 23 | #if CONFIG_SUIT_CACHE_RW |
23 | 24 | #include <suit_dfu_cache_rw.h> |
24 | 25 | #endif |
@@ -64,6 +65,40 @@ static int dfu_partition_erase(void) |
64 | 65 |
|
65 | 66 | #endif /* CONFIG_SUIT_ORCHESTRATOR_APP_CANDIDATE_PROCESSING */ |
66 | 67 |
|
| 68 | +#if CONFIG_SUIT_NORDIC_TOP_INDEPENDENT_UPDATE_FORBIDDEN |
| 69 | +static int nordic_top_disallowed_check(uint8_t *candidate_envelope_address, |
| 70 | + size_t candidate_envelope_size) |
| 71 | +{ |
| 72 | + int err = 0; |
| 73 | + struct zcbor_string manifest_component_id = { |
| 74 | + .value = NULL, |
| 75 | + .len = 0, |
| 76 | + }; |
| 77 | + suit_manifest_class_id_t *candidate_class_id = NULL; |
| 78 | + suit_ssf_manifest_class_info_t nordic_top_class_info; |
| 79 | + |
| 80 | + err = suit_processor_get_manifest_metadata( |
| 81 | + candidate_envelope_address, candidate_envelope_size, false, &manifest_component_id, |
| 82 | + NULL, NULL, NULL, NULL, NULL); |
| 83 | + |
| 84 | + if (suit_plat_decode_manifest_class_id(&manifest_component_id, &candidate_class_id) != |
| 85 | + SUIT_PLAT_SUCCESS) { |
| 86 | + LOG_ERR("Component ID of candidate is not a manifest class"); |
| 87 | + return SUIT_ERR_UNSUPPORTED_COMPONENT_ID; |
| 88 | + } |
| 89 | + |
| 90 | + suit_get_supported_manifest_info(SUIT_MANIFEST_SEC_TOP, &nordic_top_class_info); |
| 91 | + |
| 92 | + if (suit_metadata_uuid_compare(candidate_class_id, &nordic_top_class_info.class_id) == |
| 93 | + SUIT_PLAT_SUCCESS) { |
| 94 | + LOG_ERR("Nordic top manifest class ID is not allowed in the update candidate"); |
| 95 | + return -EACCES; |
| 96 | + } |
| 97 | + |
| 98 | + return 0; |
| 99 | +} |
| 100 | +#endif /* CONFIG_SUIT_NORDIC_TOP_INDEPENDENT_UPDATE_FORBIDDEN */ |
| 101 | + |
67 | 102 | int suit_dfu_initialize(void) |
68 | 103 | { |
69 | 104 | LOG_DBG("Enter"); |
@@ -182,6 +217,14 @@ int suit_dfu_candidate_preprocess(void) |
182 | 217 | LOG_INF("Update candidate envelope detected, addr: %p, size %d bytes", |
183 | 218 | (void *)candidate_envelope_address, candidate_envelope_size); |
184 | 219 |
|
| 220 | +#if CONFIG_SUIT_NORDIC_TOP_INDEPENDENT_UPDATE_FORBIDDEN |
| 221 | + err = nordic_top_disallowed_check(candidate_envelope_address, candidate_envelope_size); |
| 222 | + |
| 223 | + if (err != 0) { |
| 224 | + return err; |
| 225 | + } |
| 226 | +#endif /* CONFIG_SUIT_NORDIC_TOP_INDEPENDENT_UPDATE_FORBIDDEN */ |
| 227 | + |
185 | 228 | err = suit_process_sequence(candidate_envelope_address, candidate_envelope_size, |
186 | 229 | SUIT_SEQ_DEP_RESOLUTION); |
187 | 230 | if (err == SUIT_SUCCESS) { |
|
0 commit comments