Skip to content

Commit 7d94614

Browse files
committed
platform: Pass dependency flag
Pass dependency flag through platform API, so it can compare it with the component ID value. Ref: NCSDK-28616 Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent d28bcc8 commit 7d94614

File tree

17 files changed

+58
-58
lines changed

17 files changed

+58
-58
lines changed

include/suit_platform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ int suit_plat_authorize_unsigned_manifest(struct zcbor_string *manifest_componen
7070
* If so, create and return a component handle for it.
7171
*
7272
* @param[in] component_id The CBOR-encoded component identifier.
73+
* @param[in] dependency True if a component is a dependency component.
7374
* @param[out] component_handle A reference for use with other functions in
7475
* this API, instead of always passing the
7576
* @p parts.
7677
*
7778
* @returns SUIT_SUCCESS if the component handle was created, error code otherwise.
7879
*/
79-
int suit_plat_create_component_handle(struct zcbor_string *component_id,
80-
suit_component_t *handle);
80+
int suit_plat_create_component_handle(struct zcbor_string *component_id, bool dependency, suit_component_t *handle);
8181

8282
/** @brief Release loaded component properties and handles assigned to them.
8383
*

src/suit_manifest.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static struct suit_manifest_params *components;
1212
static size_t components_count;
1313

1414

15-
static int assign_component_index(struct zcbor_string *component_id, size_t *assigned_index)
15+
static int assign_component_index(struct zcbor_string *component_id, size_t *assigned_index, bool dependency)
1616
{
1717
int ret = SUIT_ERR_OVERFLOW;
1818

@@ -34,7 +34,7 @@ static int assign_component_index(struct zcbor_string *component_id, size_t *ass
3434
components[i].component_id = *component_id;
3535
*assigned_index = i;
3636

37-
ret = suit_plat_create_component_handle(component_id, &components[i].component_handle);
37+
ret = suit_plat_create_component_handle(component_id, dependency, &components[i].component_handle);
3838

3939
if (ret == SUIT_SUCCESS) {
4040
components[*assigned_index].ref_count++;
@@ -115,7 +115,7 @@ int suit_manifest_append_dependency(struct suit_manifest_state *manifest, struct
115115
return SUIT_ERR_MANIFEST_VALIDATION;
116116
}
117117

118-
int ret = assign_component_index(component_id, &index);
118+
int ret = assign_component_index(component_id, &index, true);
119119

120120
if (ret == SUIT_SUCCESS) {
121121
if (components[index].is_dependency == suit_bool_false) {
@@ -158,7 +158,7 @@ int suit_manifest_append_component(struct suit_manifest_state *manifest, struct
158158
return SUIT_ERR_MANIFEST_VALIDATION;
159159
}
160160

161-
int ret = assign_component_index(component_id, &index);
161+
int ret = assign_component_index(component_id, &index, false);
162162

163163
if (ret == SUIT_SUCCESS) {
164164
if (components[index].is_dependency == suit_bool_true) {

tests/unit/decoder/include/suit_platform_mock_ext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ int __check_digest_callback(enum suit_cose_alg alg_id, struct zcbor_string *dige
8888
}
8989
int __authenticate_manifest_callback(struct zcbor_string *manifest_component_id, enum suit_cose_alg alg_id, struct zcbor_string *key_id, struct zcbor_string *signature, struct zcbor_string *data, int cmock_num_calls);
9090

91-
#define __cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(component_id, handle, cmock_retval) { \
91+
#define __cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(component_id, dependency, handle, cmock_retval) { \
9292
extern complex_arg_q_t __get_component_handle_callback_queue; \
9393
push_complex_arg(component_id, assert_zcbor_string, __get_component_handle_callback_queue); \
9494
push_retval_arg(cmock_retval, __get_component_handle_callback_queue); \
9595
__cmock_suit_plat_create_component_handle_AddCallback(__get_component_handle_callback); \
96-
__cmock_suit_plat_create_component_handle_ExpectAndReturn(component_id, handle, cmock_retval); \
96+
__cmock_suit_plat_create_component_handle_ExpectAndReturn(component_id, dependency, handle, cmock_retval); \
9797
__cmock_suit_plat_create_component_handle_IgnoreArg_component_id(); \
9898
}
99-
int __get_component_handle_callback(struct zcbor_string *component_id, suit_component_t *handle, int cmock_num_calls);
99+
int __get_component_handle_callback(struct zcbor_string *component_id, bool dependency, suit_component_t *handle, int cmock_num_calls);
100100

101101
#define __cmock_suit_plat_check_image_match_ExpectComplexArgsAndReturn(image_handle, alg_id, digest, cmock_retval) { \
102102
extern complex_arg_q_t __check_image_match_callback_queue; \

tests/unit/decoder/src/suit_platform_mock_ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int __authenticate_manifest_callback(struct zcbor_string *manifest_component_id,
4545
}
4646

4747
COMPLEX_ARG_Q_DEFINE(__get_component_handle_callback_queue);
48-
int __get_component_handle_callback(struct zcbor_string *component_id, suit_component_t *component_handle, int cmock_num_calls)
48+
int __get_component_handle_callback(struct zcbor_string *component_id, bool dependency, suit_component_t *component_handle, int cmock_num_calls)
4949
{
5050
(void)assert_complex_arg(&__get_component_handle_callback_queue, component_id);
5151
return assert_complex_arg(&__get_component_handle_callback_queue, NULL);

tests/unit/fetch_integrated_manifests/include/suit_platform_mock_ext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ int __check_digest_callback(enum suit_cose_alg alg_id, struct zcbor_string *dige
8888
}
8989
int __authenticate_manifest_callback(struct zcbor_string *manifest_component_id, enum suit_cose_alg alg_id, struct zcbor_string *key_id, struct zcbor_string *signature, struct zcbor_string *data, int cmock_num_calls);
9090

91-
#define __cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(component_id, handle, cmock_retval) { \
91+
#define __cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(component_id, dependency, handle, cmock_retval) { \
9292
extern complex_arg_q_t __get_component_handle_callback_queue; \
9393
push_complex_arg(component_id, assert_zcbor_string, __get_component_handle_callback_queue); \
9494
push_retval_arg(cmock_retval, __get_component_handle_callback_queue); \
9595
__cmock_suit_plat_create_component_handle_AddCallback(__get_component_handle_callback); \
96-
__cmock_suit_plat_create_component_handle_ExpectAndReturn(component_id, handle, cmock_retval); \
96+
__cmock_suit_plat_create_component_handle_ExpectAndReturn(component_id, dependency, handle, cmock_retval); \
9797
__cmock_suit_plat_create_component_handle_IgnoreArg_component_id(); \
9898
}
99-
int __get_component_handle_callback(struct zcbor_string *component_id, suit_component_t *handle, int cmock_num_calls);
99+
int __get_component_handle_callback(struct zcbor_string *component_id, bool dependency, suit_component_t *handle, int cmock_num_calls);
100100

101101
#define __cmock_suit_plat_check_image_match_ExpectComplexArgsAndReturn(image_handle, alg_id, digest, cmock_retval) { \
102102
extern complex_arg_q_t __check_image_match_callback_queue; \

tests/unit/fetch_integrated_manifests/src/app.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ void app_assert_envelope_integrity(bool installed)
149149

150150
/* component creation */
151151
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_app_manifest_id, &exp_app_fw_id, SUIT_SUCCESS);
152-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_app_fw_id, NULL, SUIT_SUCCESS);
152+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_app_fw_id, false, NULL, SUIT_SUCCESS);
153153
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
154154
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&app_fw_component_handle);
155155

156156
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_app_manifest_id, &exp_fw_memptr_id, SUIT_SUCCESS);
157-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_fw_memptr_id, NULL, SUIT_SUCCESS);
157+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_fw_memptr_id, false, NULL, SUIT_SUCCESS);
158158
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
159159
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&app_fw_memptr_component_handle);
160160

@@ -181,12 +181,12 @@ void app_assert_envelope_authorization(bool installed)
181181
void app_assert_component_creation(void)
182182
{
183183
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_app_manifest_id, &exp_app_fw_id, SUIT_SUCCESS);
184-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_app_fw_id, NULL, SUIT_SUCCESS);
184+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_app_fw_id, false, NULL, SUIT_SUCCESS);
185185
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
186186
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&app_fw_component_handle);
187187

188188
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_app_manifest_id, &exp_fw_memptr_id, SUIT_SUCCESS);
189-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_fw_memptr_id, NULL, SUIT_SUCCESS);
189+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_fw_memptr_id, false, NULL, SUIT_SUCCESS);
190190
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
191191
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&app_fw_memptr_component_handle);
192192
}

tests/unit/fetch_integrated_manifests/src/radio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ void radio_assert_envelope_integrity(bool installed)
149149

150150
/* component creation */
151151
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_radio_manifest_id, &exp_radio_fw_id, SUIT_SUCCESS);
152-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_radio_fw_id, NULL, SUIT_SUCCESS);
152+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_radio_fw_id, false, NULL, SUIT_SUCCESS);
153153
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
154154
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&radio_fw_component_handle);
155155

156156
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_radio_manifest_id, &exp_fw_memptr_id, SUIT_SUCCESS);
157-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_fw_memptr_id, NULL, SUIT_SUCCESS);
157+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_fw_memptr_id, false, NULL, SUIT_SUCCESS);
158158
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
159159
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&radio_fw_memptr_component_handle);
160160

@@ -181,12 +181,12 @@ void radio_assert_envelope_authorization(bool installed)
181181
void radio_assert_component_creation(void)
182182
{
183183
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_radio_manifest_id, &exp_radio_fw_id, SUIT_SUCCESS);
184-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_radio_fw_id, NULL, SUIT_SUCCESS);
184+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_radio_fw_id, false, NULL, SUIT_SUCCESS);
185185
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
186186
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&radio_fw_component_handle);
187187

188188
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_radio_manifest_id, &exp_fw_memptr_id, SUIT_SUCCESS);
189-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_fw_memptr_id, NULL, SUIT_SUCCESS);
189+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_fw_memptr_id, false, NULL, SUIT_SUCCESS);
190190
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
191191
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&radio_fw_memptr_component_handle);
192192
}

tests/unit/fetch_integrated_manifests/src/root.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void root_assert_component_creation(void)
9797
};
9898

9999
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_root_manifest_id, &exp_manifest_candidate_id, SUIT_SUCCESS);
100-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_manifest_candidate_id, NULL, SUIT_SUCCESS);
100+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_manifest_candidate_id, true, NULL, SUIT_SUCCESS);
101101
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
102102
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&candidate_component_handle);
103103

@@ -115,7 +115,7 @@ void root_assert_component_creation(void)
115115
};
116116

117117
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_root_manifest_id, &exp_radio_manifest_id, SUIT_SUCCESS);
118-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_radio_manifest_id, NULL, SUIT_SUCCESS);
118+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_radio_manifest_id, true, NULL, SUIT_SUCCESS);
119119
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
120120
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&radio_component_handle);
121121

@@ -133,7 +133,7 @@ void root_assert_component_creation(void)
133133
};
134134

135135
__cmock_suit_plat_authorize_component_id_ExpectComplexArgsAndReturn(&exp_root_manifest_id, &exp_app_manifest_id, SUIT_SUCCESS);
136-
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_app_manifest_id, NULL, SUIT_SUCCESS);
136+
__cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(&exp_app_manifest_id, true, NULL, SUIT_SUCCESS);
137137
__cmock_suit_plat_create_component_handle_IgnoreArg_handle();
138138
__cmock_suit_plat_create_component_handle_ReturnThruPtr_handle(&app_component_handle);
139139
}

tests/unit/fetch_integrated_manifests/src/suit_platform_mock_ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int __authenticate_manifest_callback(struct zcbor_string *manifest_component_id,
4545
}
4646

4747
COMPLEX_ARG_Q_DEFINE(__get_component_handle_callback_queue);
48-
int __get_component_handle_callback(struct zcbor_string *component_id, suit_component_t *component_handle, int cmock_num_calls)
48+
int __get_component_handle_callback(struct zcbor_string *component_id, bool dependency, suit_component_t *component_handle, int cmock_num_calls)
4949
{
5050
(void)assert_complex_arg(&__get_component_handle_callback_queue, component_id);
5151
return assert_complex_arg(&__get_component_handle_callback_queue, NULL);

tests/unit/fetch_integrated_payload/include/suit_platform_mock_ext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ int __check_digest_callback(enum suit_cose_alg alg_id, struct zcbor_string *dige
8888
}
8989
int __authenticate_manifest_callback(struct zcbor_string *manifest_component_id, enum suit_cose_alg alg_id, struct zcbor_string *key_id, struct zcbor_string *signature, struct zcbor_string *data, int cmock_num_calls);
9090

91-
#define __cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(component_id, handle, cmock_retval) { \
91+
#define __cmock_suit_plat_create_component_handle_ExpectComplexArgsAndReturn(component_id, dependency, handle, cmock_retval) { \
9292
extern complex_arg_q_t __get_component_handle_callback_queue; \
9393
push_complex_arg(component_id, assert_zcbor_string, __get_component_handle_callback_queue); \
9494
push_retval_arg(cmock_retval, __get_component_handle_callback_queue); \
9595
__cmock_suit_plat_create_component_handle_AddCallback(__get_component_handle_callback); \
96-
__cmock_suit_plat_create_component_handle_ExpectAndReturn(component_id, handle, cmock_retval); \
96+
__cmock_suit_plat_create_component_handle_ExpectAndReturn(component_id, dependency, handle, cmock_retval); \
9797
__cmock_suit_plat_create_component_handle_IgnoreArg_component_id(); \
9898
}
99-
int __get_component_handle_callback(struct zcbor_string *component_id, suit_component_t *handle, int cmock_num_calls);
99+
int __get_component_handle_callback(struct zcbor_string *component_id, bool dependency, suit_component_t *handle, int cmock_num_calls);
100100

101101
#define __cmock_suit_plat_check_image_match_ExpectComplexArgsAndReturn(image_handle, alg_id, digest, cmock_retval) { \
102102
extern complex_arg_q_t __check_image_match_callback_queue; \

0 commit comments

Comments
 (0)