1 /*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/ztest.h>
8 #ifdef MANIFEST16
9 #include "manifest16_decode.h"
10 #else
11 #include "manifest14_decode.h"
12 #endif
13 #include <example0.h>
14
15
ZTEST(cbor_decode_test9,test_suit14_ex0_auth)16 ZTEST(cbor_decode_test9, test_suit14_ex0_auth)
17 {
18 struct SUIT_Envelope envelope;
19 struct SUIT_Digest *digest;
20 struct COSE_Sign1 *cose_sign1;
21 size_t out_len;
22 uint8_t exp_digest[] = {
23 0xa6, 0xc4, 0x59, 0x0a, 0xc5, 0x30, 0x43, 0xa9,
24 0x8e, 0x8c, 0x41, 0x06, 0xe1, 0xe3, 0x1b, 0x30,
25 0x55, 0x16, 0xd7, 0xcf, 0x0a, 0x65, 0x5e, 0xdd,
26 0xfa, 0xc6, 0xd4, 0x5c, 0x81, 0x0e, 0x03, 0x6a,
27 };
28 uint8_t exp_signature[] = {
29 0xd1, 0x1a, 0x2d, 0xd9, 0x61, 0x0f, 0xb6, 0x2a,
30 0x70, 0x73, 0x35, 0xf5, 0x84, 0x07, 0x92, 0x25,
31 0x70, 0x9f, 0x96, 0xe8, 0x11, 0x7e, 0x7e, 0xee,
32 0xd9, 0x8a, 0x2f, 0x20, 0x7d, 0x05, 0xc8, 0xec,
33 0xfb, 0xa1, 0x75, 0x52, 0x08, 0xf6, 0xab, 0xea,
34 0x97, 0x7b, 0x8a, 0x6e, 0xfe, 0x3b, 0xc2, 0xca,
35 0x32, 0x15, 0xe1, 0x19, 0x3b, 0xe2, 0x01, 0x46,
36 0x7d, 0x05, 0x2b, 0x42, 0xdb, 0x6b, 0x72, 0x87,
37 };
38
39 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Envelope_Tagged(example0, sizeof(example0), &envelope, &out_len), NULL);
40 zassert_equal(sizeof(example0), out_len, NULL);
41
42 digest = &envelope.SUIT_Envelope_suit_authentication_wrapper_cbor.SUIT_Authentication_SUIT_Digest_bstr_cbor;
43 zassert_equal(suit_cose_hash_algs_cose_alg_sha_256_m_c,
44 digest->SUIT_Digest_suit_digest_algorithm_id.suit_cose_hash_algs_choice, NULL);
45 zassert_equal(sizeof(exp_digest),
46 digest->SUIT_Digest_suit_digest_bytes.len, NULL);
47 zassert_mem_equal(exp_digest,
48 digest->SUIT_Digest_suit_digest_bytes.value,
49 digest->SUIT_Digest_suit_digest_bytes.len, NULL);
50 zassert_equal(1, envelope.SUIT_Envelope_suit_authentication_wrapper_cbor.SUIT_Authentication_Block_bstr_count, NULL);
51 zassert_equal(SUIT_Authentication_Block_COSE_Sign1_Tagged_m_c,
52 envelope.SUIT_Envelope_suit_authentication_wrapper_cbor.SUIT_Authentication_Block_bstr[0].SUIT_Authentication_Block_bstr_cbor.SUIT_Authentication_Block_choice, NULL);
53 cose_sign1 = &envelope.SUIT_Envelope_suit_authentication_wrapper_cbor.SUIT_Authentication_Block_bstr[0].SUIT_Authentication_Block_bstr_cbor.SUIT_Authentication_Block_COSE_Sign1_Tagged_m;
54 zassert_equal(empty_or_serialized_map_header_map_bstr_c,
55 cose_sign1->COSE_Sign1_Headers_m.Headers_protected.empty_or_serialized_map_choice, NULL);
56 zassert_equal(0, cose_sign1->COSE_Sign1_Headers_m.Headers_protected.empty_or_serialized_map_header_map_bstr_cbor.header_map_label_count, NULL);
57 zassert_true(cose_sign1->COSE_Sign1_Headers_m.Headers_protected.empty_or_serialized_map_header_map_bstr_cbor.header_map_Generic_Headers_m.Generic_Headers_uint1union_present, NULL);
58 zassert_false(cose_sign1->COSE_Sign1_Headers_m.Headers_protected.empty_or_serialized_map_header_map_bstr_cbor.header_map_Generic_Headers_m.Generic_Headers_label_m_l_present, NULL);
59 zassert_false(cose_sign1->COSE_Sign1_Headers_m.Headers_protected.empty_or_serialized_map_header_map_bstr_cbor.header_map_Generic_Headers_m.Generic_Headers_uint3union_present, NULL);
60 zassert_false(cose_sign1->COSE_Sign1_Headers_m.Headers_protected.empty_or_serialized_map_header_map_bstr_cbor.header_map_Generic_Headers_m.Generic_Headers_uint4bstr_present, NULL);
61 zassert_false(cose_sign1->COSE_Sign1_Headers_m.Headers_protected.empty_or_serialized_map_header_map_bstr_cbor.header_map_Generic_Headers_m.Generic_Headers_uint5bstr_present, NULL);
62 zassert_false(cose_sign1->COSE_Sign1_Headers_m.Headers_protected.empty_or_serialized_map_header_map_bstr_cbor.header_map_Generic_Headers_m.Generic_Headers_uint6bstr_present, NULL);
63 zassert_equal(Generic_Headers_uint1union_int_c,
64 cose_sign1->COSE_Sign1_Headers_m.Headers_protected.empty_or_serialized_map_header_map_bstr_cbor.header_map_Generic_Headers_m.Generic_Headers_uint1union.Generic_Headers_uint1union_choice, NULL);
65 zassert_equal(-7,
66 cose_sign1->COSE_Sign1_Headers_m.Headers_protected.empty_or_serialized_map_header_map_bstr_cbor.header_map_Generic_Headers_m.Generic_Headers_uint1union.Generic_Headers_uint1union_int, NULL);
67 zassert_equal(sizeof(exp_signature), cose_sign1->COSE_Sign1_signature.len, NULL);
68 zassert_mem_equal(exp_signature, cose_sign1->COSE_Sign1_signature.value,
69 cose_sign1->COSE_Sign1_signature.len, NULL);
70 zassert_equal(COSE_Sign1_payload_nil_c, cose_sign1->COSE_Sign1_payload_choice, NULL);
71 }
72
73
74 /* Check the common sequence. */
ZTEST(cbor_decode_test9,test_suit14_ex0_common_sequence)75 ZTEST(cbor_decode_test9, test_suit14_ex0_common_sequence)
76 {
77 struct SUIT_Envelope envelope;
78 struct SUIT_Manifest manifest;
79 struct SUIT_Common_Sequence common_sequence;
80 struct SUIT_Command_Sequence command_sequence;
81 struct SUIT_Parameters_r *parameter;
82 struct SUIT_Condition_r *condition;
83 size_t out_len;
84 uint8_t exp_vendor_id[] = {
85 0xfa, 0x6b, 0x4a, 0x53, 0xd5, 0xad, 0x5f, 0xdf,
86 0xbe, 0x9d, 0xe6, 0x63, 0xe4, 0xd4, 0x1f, 0xfe,
87 };
88 uint8_t exp_class_id[] = {
89 0x14, 0x92, 0xaf, 0x14, 0x25, 0x69, 0x5e, 0x48,
90 0xbf, 0x42, 0x9b, 0x2d, 0x51, 0xf2, 0xab, 0x45,
91 };
92 uint8_t exp_digest[] = {
93 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
94 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
95 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
96 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
97 };
98 uint32_t exp_rep_policy = (
99 (1 << suit_reporting_bits_suit_send_record_success_c)
100 | (1 << suit_reporting_bits_suit_send_record_failure_c)
101 | (1 << suit_reporting_bits_suit_send_sysinfo_success_c)
102 | (1 << suit_reporting_bits_suit_send_sysinfo_failure_c));
103
104 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Envelope_Tagged(example0, sizeof(example0), &envelope, &out_len), NULL);
105 zassert_equal(sizeof(example0), out_len, NULL);
106 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Manifest(envelope.SUIT_Envelope_suit_manifest.value,
107 envelope.SUIT_Envelope_suit_manifest.len, &manifest, &out_len), NULL);
108 zassert_equal(envelope.SUIT_Envelope_suit_manifest.len, out_len, NULL);
109 zassert_true(manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_components_present, NULL);
110 zassert_true(manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence_present, NULL);
111 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Common_Sequence(
112 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.value,
113 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.len,
114 &common_sequence, &out_len), NULL);
115 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Command_Sequence(
116 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.value,
117 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.len,
118 &command_sequence, &out_len), NULL);
119 zassert_equal(
120 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.len,
121 out_len, NULL);
122 zassert_equal(3, common_sequence.SUIT_Common_Sequence_union_count, NULL);
123 zassert_equal(SUIT_Common_Sequence_union_SUIT_Common_Commands_m_c, common_sequence.SUIT_Common_Sequence_union[0].SUIT_Common_Sequence_union_choice, NULL);
124 zassert_equal(SUIT_Common_Commands_suit_directive_override_parameters_m_l_c, common_sequence.SUIT_Common_Sequence_union[0].SUIT_Common_Sequence_union_SUIT_Common_Commands_m.SUIT_Common_Commands_choice, NULL);
125 zassert_equal(4, common_sequence.SUIT_Common_Sequence_union[0].SUIT_Common_Sequence_union_SUIT_Common_Commands_m.suit_directive_override_parameters_m_l_map_SUIT_Parameters_m_count, NULL);
126 parameter = &common_sequence.SUIT_Common_Sequence_union[0].SUIT_Common_Sequence_union_SUIT_Common_Commands_m.suit_directive_override_parameters_m_l_map_SUIT_Parameters_m[0].suit_directive_override_parameters_m_l_map_SUIT_Parameters_m;
127 zassert_equal(
128 SUIT_Parameters_suit_parameter_vendor_identifier_c,
129 parameter->SUIT_Parameters_choice, NULL);
130 zassert_equal(
131 SUIT_Parameters_suit_parameter_vendor_identifier_RFC4122_UUID_m_c,
132 parameter->SUIT_Parameters_suit_parameter_vendor_identifier_choice, NULL);
133 zassert_equal(
134 parameter->SUIT_Parameters_suit_parameter_vendor_identifier_RFC4122_UUID_m.len,
135 sizeof(exp_vendor_id), NULL);
136 zassert_mem_equal(exp_vendor_id,
137 parameter->SUIT_Parameters_suit_parameter_vendor_identifier_RFC4122_UUID_m.value,
138 parameter->SUIT_Parameters_suit_parameter_vendor_identifier_RFC4122_UUID_m.len, NULL);
139
140 parameter = &common_sequence.SUIT_Common_Sequence_union[0].SUIT_Common_Sequence_union_SUIT_Common_Commands_m.suit_directive_override_parameters_m_l_map_SUIT_Parameters_m[1].suit_directive_override_parameters_m_l_map_SUIT_Parameters_m;
141 zassert_equal(
142 SUIT_Parameters_suit_parameter_class_identifier_c,
143 parameter->SUIT_Parameters_choice, NULL);
144 zassert_equal(
145 parameter->SUIT_Parameters_suit_parameter_class_identifier.len,
146 sizeof(exp_class_id), NULL);
147 zassert_mem_equal(exp_class_id,
148 parameter->SUIT_Parameters_suit_parameter_class_identifier.value,
149 parameter->SUIT_Parameters_suit_parameter_class_identifier.len, NULL);
150
151 parameter = &common_sequence.SUIT_Common_Sequence_union[0].SUIT_Common_Sequence_union_SUIT_Common_Commands_m.suit_directive_override_parameters_m_l_map_SUIT_Parameters_m[2].suit_directive_override_parameters_m_l_map_SUIT_Parameters_m;
152 zassert_equal(
153 SUIT_Parameters_suit_parameter_image_digest_c,
154 parameter->SUIT_Parameters_choice, NULL);
155 zassert_equal(
156 parameter->SUIT_Parameters_suit_parameter_image_digest_cbor.SUIT_Digest_suit_digest_bytes.len,
157 sizeof(exp_digest), NULL);
158 zassert_equal(suit_cose_hash_algs_cose_alg_sha_256_m_c,
159 parameter->SUIT_Parameters_suit_parameter_image_digest_cbor.SUIT_Digest_suit_digest_algorithm_id.suit_cose_hash_algs_choice, NULL);
160 zassert_mem_equal(exp_digest,
161 parameter->SUIT_Parameters_suit_parameter_image_digest_cbor.SUIT_Digest_suit_digest_bytes.value,
162 parameter->SUIT_Parameters_suit_parameter_image_digest_cbor.SUIT_Digest_suit_digest_bytes.len, NULL);
163
164 parameter = &common_sequence.SUIT_Common_Sequence_union[0].SUIT_Common_Sequence_union_SUIT_Common_Commands_m.suit_directive_override_parameters_m_l_map_SUIT_Parameters_m[3].suit_directive_override_parameters_m_l_map_SUIT_Parameters_m;
165 zassert_equal(
166 SUIT_Parameters_suit_parameter_image_size_c,
167 parameter->SUIT_Parameters_choice, NULL);
168 zassert_equal(34768, parameter->SUIT_Parameters_suit_parameter_image_size, NULL);
169
170 zassert_equal(SUIT_Common_Sequence_union_SUIT_Condition_m_c, common_sequence.SUIT_Common_Sequence_union[1].SUIT_Common_Sequence_union_choice, NULL);
171 condition = &common_sequence.SUIT_Common_Sequence_union[1].SUIT_Common_Sequence_union_SUIT_Condition_m;
172 zassert_equal(SUIT_Condition_suit_condition_vendor_identifier_m_l_c,
173 condition->SUIT_Condition_choice, NULL);
174 zassert_equal(exp_rep_policy,
175 condition->SUIT_Condition_suit_condition_vendor_identifier_m_l_SUIT_Rep_Policy_m, NULL);
176 zassert_equal(exp_rep_policy,
177 condition->SUIT_Condition_suit_condition_class_identifier_m_l_SUIT_Rep_Policy_m, NULL);
178
179 zassert_equal(SUIT_Common_Sequence_union_SUIT_Condition_m_c, common_sequence.SUIT_Common_Sequence_union[2].SUIT_Common_Sequence_union_choice, NULL);
180 condition = &common_sequence.SUIT_Common_Sequence_union[2].SUIT_Common_Sequence_union_SUIT_Condition_m;
181 zassert_equal(SUIT_Condition_suit_condition_class_identifier_m_l_c,
182 condition->SUIT_Condition_choice, NULL);
183 zassert_equal(exp_rep_policy,
184 condition->SUIT_Condition_suit_condition_class_identifier_m_l_SUIT_Rep_Policy_m, NULL);
185 }
186
187 /* Check the common sequence when decoded as a command sequence.
188 * This should work fine because SUIT_Common_Sequence is a subset of
189 * SUIT_Command_Sequence.
190 */
ZTEST(cbor_decode_test9,test_suit14_ex0_common_sequence_as_command_sequence)191 ZTEST(cbor_decode_test9, test_suit14_ex0_common_sequence_as_command_sequence)
192 {
193 struct SUIT_Envelope envelope;
194 struct SUIT_Manifest manifest;
195 struct SUIT_Common_Sequence common_sequence;
196 struct SUIT_Command_Sequence command_sequence;
197 struct SUIT_Parameters_r *parameter;
198 struct SUIT_Condition_r *condition;
199 size_t out_len;
200 uint8_t exp_vendor_id[] = {
201 0xfa, 0x6b, 0x4a, 0x53, 0xd5, 0xad, 0x5f, 0xdf,
202 0xbe, 0x9d, 0xe6, 0x63, 0xe4, 0xd4, 0x1f, 0xfe,
203 };
204 uint8_t exp_class_id[] = {
205 0x14, 0x92, 0xaf, 0x14, 0x25, 0x69, 0x5e, 0x48,
206 0xbf, 0x42, 0x9b, 0x2d, 0x51, 0xf2, 0xab, 0x45,
207 };
208 uint8_t exp_digest[] = {
209 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
210 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
211 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
212 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
213 };
214 uint32_t exp_rep_policy = (
215 (1 << suit_reporting_bits_suit_send_record_success_c)
216 | (1 << suit_reporting_bits_suit_send_record_failure_c)
217 | (1 << suit_reporting_bits_suit_send_sysinfo_success_c)
218 | (1 << suit_reporting_bits_suit_send_sysinfo_failure_c));
219
220 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Envelope_Tagged(example0, sizeof(example0), &envelope, &out_len), NULL);
221 zassert_equal(sizeof(example0), out_len, NULL);
222 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Manifest(envelope.SUIT_Envelope_suit_manifest.value,
223 envelope.SUIT_Envelope_suit_manifest.len, &manifest, &out_len), NULL);
224 zassert_equal(envelope.SUIT_Envelope_suit_manifest.len, out_len, NULL);
225 zassert_true(manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_components_present, NULL);
226 zassert_true(manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence_present, NULL);
227 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Common_Sequence(
228 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.value,
229 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.len,
230 &common_sequence, &out_len), NULL);
231 zassert_equal(
232 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.len,
233 out_len, NULL);
234 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Command_Sequence(
235 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.value,
236 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.len,
237 &command_sequence, &out_len), NULL);
238 zassert_equal(
239 manifest.SUIT_Manifest_suit_common_cbor.SUIT_Common_suit_common_sequence.SUIT_Common_suit_common_sequence.len,
240 out_len, NULL);
241 zassert_equal(3, command_sequence.SUIT_Command_Sequence_union_count, NULL);
242 zassert_equal(SUIT_Command_Sequence_union_SUIT_Directive_m_c, command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_choice, NULL);
243 zassert_equal(SUIT_Directive_suit_directive_override_parameters_m_l_c, command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_SUIT_Directive_m.SUIT_Directive_choice, NULL);
244 zassert_equal(4, command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_SUIT_Directive_m.suit_directive_override_parameters_m_l_map_SUIT_Parameters_m_count, NULL);
245
246 parameter = &command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_SUIT_Directive_m.suit_directive_override_parameters_m_l_map_SUIT_Parameters_m[0].suit_directive_override_parameters_m_l_map_SUIT_Parameters_m;
247 zassert_equal(
248 SUIT_Parameters_suit_parameter_vendor_identifier_c,
249 parameter->SUIT_Parameters_choice, NULL);
250 zassert_equal(
251 SUIT_Parameters_suit_parameter_vendor_identifier_RFC4122_UUID_m_c,
252 parameter->SUIT_Parameters_suit_parameter_vendor_identifier_choice, NULL);
253 zassert_equal(
254 parameter->SUIT_Parameters_suit_parameter_vendor_identifier_RFC4122_UUID_m.len,
255 sizeof(exp_vendor_id), NULL);
256 zassert_mem_equal(exp_vendor_id,
257 parameter->SUIT_Parameters_suit_parameter_vendor_identifier_RFC4122_UUID_m.value,
258 parameter->SUIT_Parameters_suit_parameter_vendor_identifier_RFC4122_UUID_m.len, NULL);
259
260 parameter = &command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_SUIT_Directive_m.suit_directive_override_parameters_m_l_map_SUIT_Parameters_m[1].suit_directive_override_parameters_m_l_map_SUIT_Parameters_m;
261 zassert_equal(
262 SUIT_Parameters_suit_parameter_class_identifier_c,
263 parameter->SUIT_Parameters_choice, NULL);
264 zassert_equal(
265 parameter->SUIT_Parameters_suit_parameter_class_identifier.len,
266 sizeof(exp_class_id), NULL);
267 zassert_mem_equal(exp_class_id,
268 parameter->SUIT_Parameters_suit_parameter_class_identifier.value,
269 parameter->SUIT_Parameters_suit_parameter_class_identifier.len, NULL);
270
271 parameter = &command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_SUIT_Directive_m.suit_directive_override_parameters_m_l_map_SUIT_Parameters_m[2].suit_directive_override_parameters_m_l_map_SUIT_Parameters_m;
272 zassert_equal(
273 SUIT_Parameters_suit_parameter_image_digest_c,
274 parameter->SUIT_Parameters_choice, NULL);
275 zassert_equal(
276 parameter->SUIT_Parameters_suit_parameter_image_digest_cbor.SUIT_Digest_suit_digest_bytes.len,
277 sizeof(exp_digest), NULL);
278 zassert_equal(suit_cose_hash_algs_cose_alg_sha_256_m_c,
279 parameter->SUIT_Parameters_suit_parameter_image_digest_cbor.SUIT_Digest_suit_digest_algorithm_id.suit_cose_hash_algs_choice, NULL);
280 zassert_mem_equal(exp_digest,
281 parameter->SUIT_Parameters_suit_parameter_image_digest_cbor.SUIT_Digest_suit_digest_bytes.value,
282 parameter->SUIT_Parameters_suit_parameter_image_digest_cbor.SUIT_Digest_suit_digest_bytes.len, NULL);
283
284 parameter = &command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_SUIT_Directive_m.suit_directive_override_parameters_m_l_map_SUIT_Parameters_m[3].suit_directive_override_parameters_m_l_map_SUIT_Parameters_m;
285 zassert_equal(
286 SUIT_Parameters_suit_parameter_image_size_c,
287 parameter->SUIT_Parameters_choice, NULL);
288 zassert_equal(34768, parameter->SUIT_Parameters_suit_parameter_image_size, NULL);
289
290 zassert_equal(SUIT_Command_Sequence_union_SUIT_Condition_m_c, command_sequence.SUIT_Command_Sequence_union[1].SUIT_Command_Sequence_union_choice, NULL);
291 condition = &command_sequence.SUIT_Command_Sequence_union[1].SUIT_Command_Sequence_union_SUIT_Condition_m;
292 zassert_equal(SUIT_Condition_suit_condition_vendor_identifier_m_l_c,
293 condition->SUIT_Condition_choice, NULL);
294 zassert_equal(exp_rep_policy,
295 condition->SUIT_Condition_suit_condition_vendor_identifier_m_l_SUIT_Rep_Policy_m, NULL);
296 zassert_equal(exp_rep_policy,
297 condition->SUIT_Condition_suit_condition_class_identifier_m_l_SUIT_Rep_Policy_m, NULL);
298
299 zassert_equal(SUIT_Command_Sequence_union_SUIT_Condition_m_c, command_sequence.SUIT_Command_Sequence_union[2].SUIT_Command_Sequence_union_choice, NULL);
300 condition = &command_sequence.SUIT_Command_Sequence_union[2].SUIT_Command_Sequence_union_SUIT_Condition_m;
301 zassert_equal(SUIT_Condition_suit_condition_class_identifier_m_l_c,
302 condition->SUIT_Condition_choice, NULL);
303 zassert_equal(exp_rep_policy,
304 condition->SUIT_Condition_suit_condition_class_identifier_m_l_SUIT_Rep_Policy_m, NULL);
305 }
306
ZTEST(cbor_decode_test9,test_suit14_ex0_validate_run)307 ZTEST(cbor_decode_test9, test_suit14_ex0_validate_run)
308 {
309 struct SUIT_Envelope envelope;
310 struct SUIT_Manifest manifest;
311 struct SUIT_Command_Sequence command_sequence;
312 struct SUIT_Condition_r *condition;
313 struct SUIT_Directive_r *directive;
314 size_t out_len;
315 uint32_t exp_rep_policy1 = (
316 (1 << suit_reporting_bits_suit_send_record_success_c)
317 | (1 << suit_reporting_bits_suit_send_record_failure_c)
318 | (1 << suit_reporting_bits_suit_send_sysinfo_success_c)
319 | (1 << suit_reporting_bits_suit_send_sysinfo_failure_c));
320 uint32_t exp_rep_policy2 = (1 << suit_reporting_bits_suit_send_record_failure_c);
321
322 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Envelope_Tagged(example0, sizeof(example0), &envelope, &out_len), NULL);
323 zassert_equal(sizeof(example0), out_len, NULL);
324 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Manifest(envelope.SUIT_Envelope_suit_manifest.value,
325 envelope.SUIT_Envelope_suit_manifest.len, &manifest, &out_len), NULL);
326 zassert_equal(envelope.SUIT_Envelope_suit_manifest.len, out_len, NULL);
327 zassert_true(manifest.SUIT_Manifest_SUIT_Unseverable_Members_m.SUIT_Unseverable_Members_suit_validate_present, NULL);
328 zassert_false(manifest.SUIT_Manifest_SUIT_Unseverable_Members_m.SUIT_Unseverable_Members_suit_load_present, NULL);
329 zassert_true(manifest.SUIT_Manifest_SUIT_Unseverable_Members_m.SUIT_Unseverable_Members_suit_run_present, NULL);
330
331 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Command_Sequence(
332 manifest.SUIT_Manifest_SUIT_Unseverable_Members_m.SUIT_Unseverable_Members_suit_validate.SUIT_Unseverable_Members_suit_validate.value,
333 manifest.SUIT_Manifest_SUIT_Unseverable_Members_m.SUIT_Unseverable_Members_suit_validate.SUIT_Unseverable_Members_suit_validate.len,
334 &command_sequence, &out_len), NULL);
335 zassert_equal(
336 manifest.SUIT_Manifest_SUIT_Unseverable_Members_m.SUIT_Unseverable_Members_suit_validate.SUIT_Unseverable_Members_suit_validate.len,
337 out_len, NULL);
338 zassert_equal(1, command_sequence.SUIT_Command_Sequence_union_count, NULL);
339 zassert_equal(SUIT_Command_Sequence_union_SUIT_Condition_m_c, command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_choice, NULL);
340 condition = &command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_SUIT_Condition_m;
341 zassert_equal(SUIT_Condition_suit_condition_image_match_m_l_c,
342 condition->SUIT_Condition_choice, NULL);
343 zassert_equal(exp_rep_policy1,
344 condition->SUIT_Condition_suit_condition_image_match_m_l_SUIT_Rep_Policy_m, NULL);
345
346 zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Command_Sequence(
347 manifest.SUIT_Manifest_SUIT_Unseverable_Members_m.SUIT_Unseverable_Members_suit_run.SUIT_Unseverable_Members_suit_run.value,
348 manifest.SUIT_Manifest_SUIT_Unseverable_Members_m.SUIT_Unseverable_Members_suit_run.SUIT_Unseverable_Members_suit_run.len,
349 &command_sequence, &out_len), NULL);
350 zassert_equal(
351 manifest.SUIT_Manifest_SUIT_Unseverable_Members_m.SUIT_Unseverable_Members_suit_run.SUIT_Unseverable_Members_suit_run.len,
352 out_len, NULL);
353 zassert_equal(1, command_sequence.SUIT_Command_Sequence_union_count, NULL);
354 zassert_equal(SUIT_Command_Sequence_union_SUIT_Directive_m_c, command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_choice, NULL);
355 directive = &command_sequence.SUIT_Command_Sequence_union[0].SUIT_Command_Sequence_union_SUIT_Directive_m;
356 zassert_equal(SUIT_Directive_suit_directive_run_m_l_c,
357 directive->SUIT_Directive_choice, NULL);
358 zassert_equal(exp_rep_policy2,
359 directive->SUIT_Directive_suit_directive_run_m_l_SUIT_Rep_Policy_m, NULL);
360
361 }
362
363 ZTEST_SUITE(cbor_decode_test9, NULL, NULL, NULL, NULL, NULL);
364