Skip to content

Commit 651a723

Browse files
ahasztagjukkar
authored andcommitted
suit: Pass manifest component ID through platform API
This commit adds the additional manifest component ID to multiple functions in the platform API. This is an enabler for such functionalities as validating the KEY ID for decryption. Signed-off-by: Artur Hadasz <[email protected]>
1 parent aff8951 commit 651a723

File tree

17 files changed

+87
-42
lines changed

17 files changed

+87
-42
lines changed

subsys/suit/platform/app/src/suit_plat_copy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
LOG_MODULE_REGISTER(suit_plat_copy, CONFIG_SUIT_LOG_LEVEL);
1111

1212
int suit_plat_check_copy(suit_component_t dst_handle, suit_component_t src_handle,
13+
struct zcbor_string *manifest_component_id,
1314
struct suit_encryption_info *enc_info)
1415
{
1516
return SUIT_ERR_UNSUPPORTED_COMMAND;
1617
}
1718

1819
int suit_plat_copy(suit_component_t dst_handle, suit_component_t src_handle,
20+
struct zcbor_string *manifest_component_id,
1921
struct suit_encryption_info *enc_info)
2022
{
2123
return SUIT_ERR_UNSUPPORTED_COMMAND;

subsys/suit/platform/app/src/suit_plat_swap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
#include <suit_platform.h>
88

99
int suit_plat_check_swap(suit_component_t dst_handle, suit_component_t src_handle,
10+
struct zcbor_string *manifest_component_id,
1011
struct suit_encryption_info *enc_info)
1112
{
1213
return SUIT_ERR_UNSUPPORTED_COMMAND;
1314
}
1415

1516
int suit_plat_swap(suit_component_t dst_handle, suit_component_t src_handle,
17+
struct zcbor_string *manifest_component_id,
1618
struct suit_encryption_info *enc_info)
1719
{
1820
return SUIT_ERR_UNSUPPORTED_COMMAND;

subsys/suit/platform/app/src/suit_plat_write.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
LOG_MODULE_REGISTER(suit_plat_write, CONFIG_SUIT_LOG_LEVEL);
1111

1212
int suit_plat_check_write(suit_component_t dst_handle, struct zcbor_string *content,
13+
struct zcbor_string *manifest_component_id,
1314
struct suit_encryption_info *enc_info)
1415
{
1516
LOG_ERR("SUIT directive write is not supported for app");
1617
return SUIT_ERR_UNSUPPORTED_COMMAND;
1718
}
1819

1920
int suit_plat_write(suit_component_t dst_handle, struct zcbor_string *content,
21+
struct zcbor_string *manifest_component_id,
2022
struct suit_encryption_info *enc_info)
2123
{
2224
LOG_ERR("SUIT directive write is not supported for app");

subsys/suit/platform/sdfw/src/suit_plat_copy.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
LOG_MODULE_REGISTER(suit_plat_copy, CONFIG_SUIT_LOG_LEVEL);
3737

3838
int suit_plat_check_copy(suit_component_t dst_handle, suit_component_t src_handle,
39+
struct zcbor_string *manifest_component_id,
3940
struct suit_encryption_info *enc_info)
4041
{
4142
#ifdef CONFIG_SUIT_STREAM
@@ -48,6 +49,7 @@ int suit_plat_check_copy(suit_component_t dst_handle, suit_component_t src_handl
4849
suit_component_type_t dst_component_type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
4950
suit_plat_err_t plat_ret = SUIT_PLAT_SUCCESS;
5051
int ret = SUIT_SUCCESS;
52+
(void)manifest_component_id;
5153

5254
/*
5355
* Validate streaming operation.
@@ -138,6 +140,7 @@ int suit_plat_check_copy(suit_component_t dst_handle, suit_component_t src_handl
138140
}
139141

140142
int suit_plat_copy(suit_component_t dst_handle, suit_component_t src_handle,
143+
struct zcbor_string *manifest_component_id,
141144
struct suit_encryption_info *enc_info)
142145
{
143146
#ifdef CONFIG_SUIT_STREAM
@@ -151,6 +154,7 @@ int suit_plat_copy(suit_component_t dst_handle, suit_component_t src_handle,
151154
suit_component_type_t dst_component_type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
152155
suit_plat_err_t plat_ret = SUIT_PLAT_SUCCESS;
153156
int ret = SUIT_SUCCESS;
157+
(void)manifest_component_id;
154158

155159
/*
156160
* Validate streaming operation.

subsys/suit/platform/sdfw/src/suit_plat_retrieve_manifest_sdfw_specific.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ int suit_plat_retrieve_manifest_domain_specific(struct zcbor_string *component_i
2727
case SUIT_COMPONENT_TYPE_INSTLD_MFST: {
2828
suit_manifest_class_id_t *class_id;
2929

30-
if (suit_plat_decode_manifest_class_id(component_id, &class_id)
31-
!= SUIT_PLAT_SUCCESS) {
30+
if (suit_plat_decode_manifest_class_id(component_id, &class_id) !=
31+
SUIT_PLAT_SUCCESS) {
3232
LOG_ERR("Unable to decode manifest class ID");
3333
ret = SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
3434
break;

subsys/suit/platform/sdfw/src/suit_plat_swap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
#include <suit_platform.h>
88

99
int suit_plat_check_swap(suit_component_t dst_handle, suit_component_t src_handle,
10+
struct zcbor_string *manifest_component_id,
1011
struct suit_encryption_info *enc_info)
1112
{
1213
return SUIT_ERR_UNSUPPORTED_COMMAND;
1314
}
1415

1516
int suit_plat_swap(suit_component_t dst_handle, suit_component_t src_handle,
17+
struct zcbor_string *manifest_component_id,
1618
struct suit_encryption_info *enc_info)
1719
{
1820
return SUIT_ERR_UNSUPPORTED_COMMAND;

subsys/suit/platform/sdfw/src/suit_plat_write.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@
3333
LOG_MODULE_REGISTER(suit_plat_write, CONFIG_SUIT_LOG_LEVEL);
3434

3535
int suit_plat_check_write(suit_component_t dst_handle, struct zcbor_string *content,
36+
struct zcbor_string *manifest_component_id,
3637
struct suit_encryption_info *enc_info)
3738
{
3839
#ifdef CONFIG_SUIT_STREAM
3940
struct stream_sink dst_sink;
4041
suit_component_type_t dst_component_type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
4142
suit_plat_err_t plat_ret = SUIT_PLAT_SUCCESS;
4243
int ret = SUIT_SUCCESS;
44+
(void)manifest_component_id;
4345

4446
/*
4547
* Validate streaming operation.
@@ -102,13 +104,15 @@ int suit_plat_check_write(suit_component_t dst_handle, struct zcbor_string *cont
102104
}
103105

104106
int suit_plat_write(suit_component_t dst_handle, struct zcbor_string *content,
107+
struct zcbor_string *manifest_component_id,
105108
struct suit_encryption_info *enc_info)
106109
{
107110
#ifdef CONFIG_SUIT_STREAM
108111
struct stream_sink dst_sink;
109112
suit_component_type_t dst_component_type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
110113
suit_plat_err_t plat_ret = SUIT_PLAT_SUCCESS;
111114
int ret = SUIT_SUCCESS;
115+
(void)manifest_component_id;
112116

113117
/*
114118
* Validate streaming operation.

subsys/suit/platform/src/suit_plat_fetch.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ static int verify_and_get_sink(suit_component_t dst_handle, struct stream_sink *
9292
#endif /* CONFIG_SUIT_STREAM */
9393

9494
int suit_plat_check_fetch(suit_component_t dst_handle, struct zcbor_string *uri,
95+
struct zcbor_string *manifest_component_id,
9596
struct suit_encryption_info *enc_info)
9697
{
9798
#ifdef CONFIG_SUIT_STREAM
9899
suit_component_type_t dst_component_type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
99100
struct stream_sink dst_sink = {0};
100101
suit_plat_err_t plat_ret = SUIT_PLAT_SUCCESS;
101102
int ret = SUIT_SUCCESS;
103+
(void)manifest_component_id;
102104

103105
/*
104106
* Validate streaming operation.
@@ -141,13 +143,15 @@ int suit_plat_check_fetch(suit_component_t dst_handle, struct zcbor_string *uri,
141143
}
142144

143145
int suit_plat_fetch(suit_component_t dst_handle, struct zcbor_string *uri,
146+
struct zcbor_string *manifest_component_id,
144147
struct suit_encryption_info *enc_info)
145148
{
146149
#ifdef CONFIG_SUIT_STREAM
147150
struct stream_sink dst_sink = {0};
148151
suit_component_type_t dst_component_type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
149152
suit_plat_err_t plat_ret = SUIT_PLAT_SUCCESS;
150153
int ret = SUIT_SUCCESS;
154+
(void)manifest_component_id;
151155

152156
/*
153157
* Validate streaming operation.
@@ -222,13 +226,15 @@ int suit_plat_fetch(suit_component_t dst_handle, struct zcbor_string *uri,
222226
}
223227

224228
int suit_plat_check_fetch_integrated(suit_component_t dst_handle, struct zcbor_string *payload,
229+
struct zcbor_string *manifest_component_id,
225230
struct suit_encryption_info *enc_info)
226231
{
227232
#ifdef CONFIG_SUIT_STREAM
228233
struct stream_sink dst_sink;
229234
suit_component_type_t dst_component_type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
230235
suit_plat_err_t plat_ret = SUIT_PLAT_SUCCESS;
231236
int ret = SUIT_SUCCESS;
237+
(void)manifest_component_id;
232238

233239
/*
234240
* Validate streaming operation.
@@ -289,13 +295,15 @@ int suit_plat_check_fetch_integrated(suit_component_t dst_handle, struct zcbor_s
289295
}
290296

291297
int suit_plat_fetch_integrated(suit_component_t dst_handle, struct zcbor_string *payload,
298+
struct zcbor_string *manifest_component_id,
292299
struct suit_encryption_info *enc_info)
293300
{
294301
#ifdef CONFIG_SUIT_STREAM
295302
struct stream_sink dst_sink;
296303
suit_component_type_t dst_component_type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
297304
suit_plat_err_t plat_ret = SUIT_PLAT_SUCCESS;
298305
int ret = SUIT_SUCCESS;
306+
(void)manifest_component_id;
299307

300308
/*
301309
* Validate streaming operation.

tests/subsys/suit/cache_pool_digest/src/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ static struct zcbor_string unexp_digest = {
3939
.len = sizeof(invalid_digest),
4040
};
4141

42+
static struct zcbor_string valid_manifest_component_id = {
43+
.value = (const uint8_t *)0x1234,
44+
.len = 123,
45+
};
46+
4247
/* Mocks of functions provided via SSF services */
4348
FAKE_VALUE_FUNC(int, suit_plat_component_compatibility_check, suit_manifest_class_id_t *,
4449
struct zcbor_string *);
@@ -116,7 +121,7 @@ ZTEST(cache_pool_digest_tests, test_cache_get_slot_ok)
116121
.len = sizeof(uri),
117122
};
118123

119-
ret = suit_plat_fetch(dst_component, &src_uri, NULL);
124+
ret = suit_plat_fetch(dst_component, &src_uri, &valid_manifest_component_id, NULL);
120125
zassert_equal(ret, SUIT_SUCCESS, "suit_plat_fetch failed - error %i", ret);
121126

122127
ret = suit_plat_check_image_match(dst_component, suit_cose_sha256, &exp_digest);

tests/subsys/suit/copy/src/main.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ static void test_before(void *data)
2828
FFF_RESET_HISTORY();
2929
}
3030

31+
static struct zcbor_string valid_manifest_component_id = {
32+
.value = (const uint8_t *)0x1234,
33+
.len = 123,
34+
};
35+
3136
ZTEST_SUITE(copy_tests, NULL, NULL, test_before, NULL, NULL);
3237

3338
ZTEST(copy_tests, test_integrated_fetch_to_memptr_and_copy_to_msink_OK)
@@ -49,7 +54,7 @@ ZTEST(copy_tests, test_integrated_fetch_to_memptr_and_copy_to_msink_OK)
4954

5055
zassert_equal(ret, SUIT_SUCCESS, "create_component_handle failed - error %i", ret);
5156

52-
ret = suit_plat_fetch_integrated(src_handle, &source, NULL);
57+
ret = suit_plat_fetch_integrated(src_handle, &source, &valid_manifest_component_id, NULL);
5358
zassert_equal(ret, SUIT_SUCCESS, "suit_plat_fetch failed - error %i", ret);
5459

5560
ret = suit_plat_component_impl_data_get(src_handle, &handle);
@@ -89,7 +94,7 @@ ZTEST(copy_tests, test_integrated_fetch_to_memptr_and_copy_to_msink_OK)
8994
ret = suit_plat_ipuc_write(dst_handle, 0, (uintptr_t)test_data, sizeof(test_data), true);
9095
zassert_equal(ret, SUIT_PLAT_SUCCESS, "cannot write to in-place updateable component");
9196

92-
ret = suit_plat_copy(dst_handle, src_handle, NULL);
97+
ret = suit_plat_copy(dst_handle, src_handle, &valid_manifest_component_id, NULL);
9398
zassert_equal(ret, SUIT_SUCCESS, "suit_plat_copy failed - error %i", ret);
9499

95100
ret = suit_plat_ipuc_write(dst_handle, 0, (uintptr_t)test_data, sizeof(test_data), true);
@@ -126,7 +131,7 @@ ZTEST(copy_tests, test_integrated_fetch_to_memptr_and_copy_to_msink_NOK_dst_hand
126131

127132
zassert_equal(ret, SUIT_SUCCESS, "create_component_handle failed - error %i", ret);
128133

129-
ret = suit_plat_fetch_integrated(src_handle, &source, NULL);
134+
ret = suit_plat_fetch_integrated(src_handle, &source, &valid_manifest_component_id, NULL);
130135
zassert_equal(ret, SUIT_SUCCESS, "suit_plat_fetch failed - error %i", ret);
131136

132137
ret = suit_plat_component_impl_data_get(src_handle, &handle);
@@ -160,7 +165,7 @@ ZTEST(copy_tests, test_integrated_fetch_to_memptr_and_copy_to_msink_NOK_dst_hand
160165
ret = suit_plat_release_component_handle(dst_handle);
161166
zassert_equal(ret, SUIT_SUCCESS, "dst_handle release failed - error %i", ret);
162167

163-
ret = suit_plat_copy(dst_handle, src_handle, NULL);
168+
ret = suit_plat_copy(dst_handle, src_handle, &valid_manifest_component_id, NULL);
164169
zassert_not_equal(ret, SUIT_SUCCESS,
165170
"suit_plat_copy should have failed - dst_handle released");
166171

@@ -191,7 +196,7 @@ ZTEST(copy_tests, test_integrated_fetch_to_memptr_and_copy_to_msink_NOK_src_hand
191196

192197
zassert_equal(ret, SUIT_SUCCESS, "create_component_handle failed - error %i", ret);
193198

194-
ret = suit_plat_fetch_integrated(src_handle, &source, NULL);
199+
ret = suit_plat_fetch_integrated(src_handle, &source, &valid_manifest_component_id, NULL);
195200
zassert_equal(ret, SUIT_SUCCESS, "suit_plat_fetch failed - error %i", ret);
196201

197202
ret = suit_plat_component_impl_data_get(src_handle, &handle);
@@ -225,7 +230,7 @@ ZTEST(copy_tests, test_integrated_fetch_to_memptr_and_copy_to_msink_NOK_src_hand
225230
ret = suit_plat_release_component_handle(src_handle);
226231
zassert_equal(ret, SUIT_SUCCESS, "src_handle release failed - error %i", ret);
227232

228-
ret = suit_plat_copy(dst_handle, src_handle, NULL);
233+
ret = suit_plat_copy(dst_handle, src_handle, &valid_manifest_component_id, NULL);
229234
zassert_not_equal(ret, SUIT_SUCCESS,
230235
"suit_plat_copy should have failed - src_handle released");
231236

@@ -267,7 +272,7 @@ ZTEST(copy_tests, test_integrated_fetch_to_memptr_and_copy_to_msink_NOK_memptr_e
267272
ret = suit_plat_create_component_handle(&valid_dst_component_id, false, &dst_handle);
268273
zassert_equal(ret, SUIT_SUCCESS, "create_component_handle failed - error %i", ret);
269274

270-
ret = suit_plat_copy(dst_handle, src_handle, NULL);
275+
ret = suit_plat_copy(dst_handle, src_handle, &valid_manifest_component_id, NULL);
271276
zassert_not_equal(ret, SUIT_SUCCESS, "suit_plat_copy should have failed - memptr empty");
272277

273278
ret = suit_plat_release_component_handle(dst_handle);

0 commit comments

Comments
 (0)