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 "zcbor_debug.h" // Enables use of print functions when debugging tests.
14 #include <example0.h>
15 
16 
ZTEST(cbor_decode_test9,test_suit14_ex0_auth)17 ZTEST(cbor_decode_test9, test_suit14_ex0_auth)
18 {
19 	struct SUIT_Envelope envelope;
20 	struct SUIT_Digest *digest;
21 	struct COSE_Sign1 *cose_sign1;
22 	size_t out_len;
23 	uint8_t exp_digest[] = {
24 		0xa6, 0xc4, 0x59, 0x0a, 0xc5, 0x30, 0x43, 0xa9,
25 		0x8e, 0x8c, 0x41, 0x06, 0xe1, 0xe3, 0x1b, 0x30,
26 		0x55, 0x16, 0xd7, 0xcf, 0x0a, 0x65, 0x5e, 0xdd,
27 		0xfa, 0xc6, 0xd4, 0x5c, 0x81, 0x0e, 0x03, 0x6a,
28 	};
29 	uint8_t exp_signature[] = {
30 		0xd1, 0x1a, 0x2d, 0xd9, 0x61, 0x0f, 0xb6, 0x2a,
31 		0x70, 0x73, 0x35, 0xf5, 0x84, 0x07, 0x92, 0x25,
32 		0x70, 0x9f, 0x96, 0xe8, 0x11, 0x7e, 0x7e, 0xee,
33 		0xd9, 0x8a, 0x2f, 0x20, 0x7d, 0x05, 0xc8, 0xec,
34 		0xfb, 0xa1, 0x75, 0x52, 0x08, 0xf6, 0xab, 0xea,
35 		0x97, 0x7b, 0x8a, 0x6e, 0xfe, 0x3b, 0xc2, 0xca,
36 		0x32, 0x15, 0xe1, 0x19, 0x3b, 0xe2, 0x01, 0x46,
37 		0x7d, 0x05, 0x2b, 0x42, 0xdb, 0x6b, 0x72, 0x87,
38 	};
39 
40 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Envelope_Tagged(example0, sizeof(example0), &envelope, &out_len), NULL);
41 	zassert_equal(sizeof(example0), out_len, NULL);
42 
43 	digest = &envelope._SUIT_Envelope_suit_authentication_wrapper_cbor._SUIT_Authentication_SUIT_Digest_bstr_cbor;
44 	zassert_equal(_suit_cose_hash_algs__cose_alg_sha_256,
45 		digest->_SUIT_Digest_suit_digest_algorithm_id._suit_cose_hash_algs_choice, NULL);
46 	zassert_equal(sizeof(exp_digest),
47 		digest->_SUIT_Digest_suit_digest_bytes.len, NULL);
48 	zassert_mem_equal(exp_digest,
49 		digest->_SUIT_Digest_suit_digest_bytes.value,
50 		digest->_SUIT_Digest_suit_digest_bytes.len, NULL);
51 	zassert_equal(1, envelope._SUIT_Envelope_suit_authentication_wrapper_cbor._SUIT_Authentication_Block_bstr_count, NULL);
52 	zassert_equal(_SUIT_Authentication_Block__COSE_Sign1_Tagged,
53 		envelope._SUIT_Envelope_suit_authentication_wrapper_cbor._SUIT_Authentication_Block_bstr[0]._SUIT_Authentication_Block_bstr_cbor._SUIT_Authentication_Block_choice, NULL);
54 	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;
55 	zassert_equal(_empty_or_serialized_map_header_map_bstr,
56 		cose_sign1->_COSE_Sign1__Headers._Headers_protected._empty_or_serialized_map_choice, NULL);
57 	zassert_equal(0, cose_sign1->_COSE_Sign1__Headers._Headers_protected._empty_or_serialized_map_header_map_bstr_cbor._header_map_label_count, NULL);
58 	zassert_true(cose_sign1->_COSE_Sign1__Headers._Headers_protected._empty_or_serialized_map_header_map_bstr_cbor._header_map__Generic_Headers._Generic_Headers_uint1union_present, NULL);
59 	zassert_false(cose_sign1->_COSE_Sign1__Headers._Headers_protected._empty_or_serialized_map_header_map_bstr_cbor._header_map__Generic_Headers._Generic_Headers___label_present, NULL);
60 	zassert_false(cose_sign1->_COSE_Sign1__Headers._Headers_protected._empty_or_serialized_map_header_map_bstr_cbor._header_map__Generic_Headers._Generic_Headers_uint3union_present, NULL);
61 	zassert_false(cose_sign1->_COSE_Sign1__Headers._Headers_protected._empty_or_serialized_map_header_map_bstr_cbor._header_map__Generic_Headers._Generic_Headers_uint4bstr_present, NULL);
62 	zassert_false(cose_sign1->_COSE_Sign1__Headers._Headers_protected._empty_or_serialized_map_header_map_bstr_cbor._header_map__Generic_Headers._Generic_Headers_uint5bstr_present, NULL);
63 	zassert_false(cose_sign1->_COSE_Sign1__Headers._Headers_protected._empty_or_serialized_map_header_map_bstr_cbor._header_map__Generic_Headers._Generic_Headers_uint6bstr_present, NULL);
64 	zassert_equal(_Generic_Headers_uint1union_int,
65 		cose_sign1->_COSE_Sign1__Headers._Headers_protected._empty_or_serialized_map_header_map_bstr_cbor._header_map__Generic_Headers._Generic_Headers_uint1union._Generic_Headers_uint1union_choice, NULL);
66 	zassert_equal(-7,
67 		cose_sign1->_COSE_Sign1__Headers._Headers_protected._empty_or_serialized_map_header_map_bstr_cbor._header_map__Generic_Headers._Generic_Headers_uint1union._Generic_Headers_uint1union_int, NULL);
68 	zassert_equal(sizeof(exp_signature), cose_sign1->_COSE_Sign1_signature.len, NULL);
69 	zassert_mem_equal(exp_signature, cose_sign1->_COSE_Sign1_signature.value,
70 		cose_sign1->_COSE_Sign1_signature.len, NULL);
71 	zassert_equal(_COSE_Sign1_payload_nil, cose_sign1->_COSE_Sign1_payload_choice, NULL);
72 }
73 
74 
75 /* Check the common sequence. */
ZTEST(cbor_decode_test9,test_suit14_ex0_common_sequence)76 ZTEST(cbor_decode_test9, test_suit14_ex0_common_sequence)
77 {
78 	struct SUIT_Envelope envelope;
79 	struct SUIT_Manifest manifest;
80 	struct SUIT_Common_Sequence common_sequence;
81 	struct SUIT_Command_Sequence command_sequence;
82 	struct SUIT_Parameters_ *parameter;
83 	struct SUIT_Condition_ *condition;
84 	size_t out_len;
85 	uint8_t exp_vendor_id[] = {
86 		0xfa, 0x6b, 0x4a, 0x53, 0xd5, 0xad, 0x5f, 0xdf,
87 		0xbe, 0x9d, 0xe6, 0x63, 0xe4, 0xd4, 0x1f, 0xfe,
88 	};
89 	uint8_t exp_class_id[] = {
90 		0x14, 0x92, 0xaf, 0x14, 0x25, 0x69, 0x5e, 0x48,
91 		0xbf, 0x42, 0x9b, 0x2d, 0x51, 0xf2, 0xab, 0x45,
92 	};
93 	uint8_t exp_digest[] = {
94 		0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
95 		0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
96 		0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
97 		0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
98 	};
99 	uint32_t exp_rep_policy = (
100 		(1 << _suit_reporting_bits_suit_send_record_success)
101 		| (1 << _suit_reporting_bits_suit_send_record_failure)
102 		| (1 << _suit_reporting_bits_suit_send_sysinfo_success)
103 		| (1 << _suit_reporting_bits_suit_send_sysinfo_failure));
104 
105 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Envelope_Tagged(example0, sizeof(example0), &envelope, &out_len), NULL);
106 	zassert_equal(sizeof(example0), out_len, NULL);
107 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Manifest(envelope._SUIT_Envelope_suit_manifest.value,
108 		envelope._SUIT_Envelope_suit_manifest.len, &manifest, &out_len), NULL);
109 	zassert_equal(envelope._SUIT_Envelope_suit_manifest.len, out_len, NULL);
110 	zassert_true(manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_components_present, NULL);
111 	zassert_true(manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence_present, NULL);
112 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Common_Sequence(
113 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.value,
114 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.len,
115 		&common_sequence, &out_len), NULL);
116 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Command_Sequence(
117 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.value,
118 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.len,
119 		&command_sequence, &out_len), NULL);
120 	zassert_equal(
121 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.len,
122 		out_len, NULL);
123 	zassert_equal(3, common_sequence._SUIT_Common_Sequence_union_count, NULL);
124 	zassert_equal(_SUIT_Common_Sequence_union__SUIT_Common_Commands, common_sequence._SUIT_Common_Sequence_union[0]._SUIT_Common_Sequence_union_choice, NULL);
125 	zassert_equal(_SUIT_Common_Commands___suit_directive_override_parameters, common_sequence._SUIT_Common_Sequence_union[0]._SUIT_Common_Sequence_union__SUIT_Common_Commands._SUIT_Common_Commands_choice, NULL);
126 	zassert_equal(4, common_sequence._SUIT_Common_Sequence_union[0]._SUIT_Common_Sequence_union__SUIT_Common_Commands.___suit_directive_override_parameters_map__SUIT_Parameters_count, NULL);
127 	parameter = &common_sequence._SUIT_Common_Sequence_union[0]._SUIT_Common_Sequence_union__SUIT_Common_Commands.___suit_directive_override_parameters_map__SUIT_Parameters[0].___suit_directive_override_parameters_map__SUIT_Parameters;
128 	zassert_equal(
129 		_SUIT_Parameters_suit_parameter_vendor_identifier,
130 		parameter->_SUIT_Parameters_choice, NULL);
131 	zassert_equal(
132 		_SUIT_Parameters_suit_parameter_vendor_identifier__RFC4122_UUID,
133 		parameter->_SUIT_Parameters_suit_parameter_vendor_identifier_choice, NULL);
134 	zassert_equal(
135 		parameter->_SUIT_Parameters_suit_parameter_vendor_identifier__RFC4122_UUID.len,
136 		sizeof(exp_vendor_id), NULL);
137 	zassert_mem_equal(exp_vendor_id,
138 		parameter->_SUIT_Parameters_suit_parameter_vendor_identifier__RFC4122_UUID.value,
139 		parameter->_SUIT_Parameters_suit_parameter_vendor_identifier__RFC4122_UUID.len, NULL);
140 
141 	parameter = &common_sequence._SUIT_Common_Sequence_union[0]._SUIT_Common_Sequence_union__SUIT_Common_Commands.___suit_directive_override_parameters_map__SUIT_Parameters[1].___suit_directive_override_parameters_map__SUIT_Parameters;
142 	zassert_equal(
143 		_SUIT_Parameters_suit_parameter_class_identifier,
144 		parameter->_SUIT_Parameters_choice, NULL);
145 	zassert_equal(
146 		parameter->_SUIT_Parameters_suit_parameter_class_identifier.len,
147 		sizeof(exp_class_id), NULL);
148 	zassert_mem_equal(exp_class_id,
149 		parameter->_SUIT_Parameters_suit_parameter_class_identifier.value,
150 		parameter->_SUIT_Parameters_suit_parameter_class_identifier.len, NULL);
151 
152 	parameter = &common_sequence._SUIT_Common_Sequence_union[0]._SUIT_Common_Sequence_union__SUIT_Common_Commands.___suit_directive_override_parameters_map__SUIT_Parameters[2].___suit_directive_override_parameters_map__SUIT_Parameters;
153 	zassert_equal(
154 		_SUIT_Parameters_suit_parameter_image_digest,
155 		parameter->_SUIT_Parameters_choice, NULL);
156 	zassert_equal(
157 		parameter->_SUIT_Parameters_suit_parameter_image_digest_cbor._SUIT_Digest_suit_digest_bytes.len,
158 		sizeof(exp_digest), NULL);
159 	zassert_equal(_suit_cose_hash_algs__cose_alg_sha_256,
160 		parameter->_SUIT_Parameters_suit_parameter_image_digest_cbor._SUIT_Digest_suit_digest_algorithm_id._suit_cose_hash_algs_choice, NULL);
161 	zassert_mem_equal(exp_digest,
162 		parameter->_SUIT_Parameters_suit_parameter_image_digest_cbor._SUIT_Digest_suit_digest_bytes.value,
163 		parameter->_SUIT_Parameters_suit_parameter_image_digest_cbor._SUIT_Digest_suit_digest_bytes.len, NULL);
164 
165 	parameter = &common_sequence._SUIT_Common_Sequence_union[0]._SUIT_Common_Sequence_union__SUIT_Common_Commands.___suit_directive_override_parameters_map__SUIT_Parameters[3].___suit_directive_override_parameters_map__SUIT_Parameters;
166 	zassert_equal(
167 		_SUIT_Parameters_suit_parameter_image_size,
168 		parameter->_SUIT_Parameters_choice, NULL);
169 	zassert_equal(34768, parameter->_SUIT_Parameters_suit_parameter_image_size, NULL);
170 
171 	zassert_equal(_SUIT_Common_Sequence_union__SUIT_Condition, common_sequence._SUIT_Common_Sequence_union[1]._SUIT_Common_Sequence_union_choice, NULL);
172 	condition = &common_sequence._SUIT_Common_Sequence_union[1]._SUIT_Common_Sequence_union__SUIT_Condition;
173 	zassert_equal(_SUIT_Condition___suit_condition_vendor_identifier,
174 		condition->_SUIT_Condition_choice, NULL);
175 	zassert_equal(exp_rep_policy,
176 		condition->_SUIT_Condition___suit_condition_vendor_identifier__SUIT_Rep_Policy, NULL);
177 	zassert_equal(exp_rep_policy,
178 		condition->_SUIT_Condition___suit_condition_class_identifier__SUIT_Rep_Policy, NULL);
179 
180 	zassert_equal(_SUIT_Common_Sequence_union__SUIT_Condition, common_sequence._SUIT_Common_Sequence_union[2]._SUIT_Common_Sequence_union_choice, NULL);
181 	condition = &common_sequence._SUIT_Common_Sequence_union[2]._SUIT_Common_Sequence_union__SUIT_Condition;
182 	zassert_equal(_SUIT_Condition___suit_condition_class_identifier,
183 		condition->_SUIT_Condition_choice, NULL);
184 	zassert_equal(exp_rep_policy,
185 		condition->_SUIT_Condition___suit_condition_class_identifier__SUIT_Rep_Policy, NULL);
186 }
187 
188 /* Check the common sequence when decoded as a command sequence.
189  * This should work fine because SUIT_Common_Sequence is a subset of
190  * SUIT_Command_Sequence.
191  */
ZTEST(cbor_decode_test9,test_suit14_ex0_common_sequence_as_command_sequence)192 ZTEST(cbor_decode_test9, test_suit14_ex0_common_sequence_as_command_sequence)
193 {
194 	struct SUIT_Envelope envelope;
195 	struct SUIT_Manifest manifest;
196 	struct SUIT_Common_Sequence common_sequence;
197 	struct SUIT_Command_Sequence command_sequence;
198 	struct SUIT_Parameters_ *parameter;
199 	struct SUIT_Condition_ *condition;
200 	size_t out_len;
201 	uint8_t exp_vendor_id[] = {
202 		0xfa, 0x6b, 0x4a, 0x53, 0xd5, 0xad, 0x5f, 0xdf,
203 		0xbe, 0x9d, 0xe6, 0x63, 0xe4, 0xd4, 0x1f, 0xfe,
204 	};
205 	uint8_t exp_class_id[] = {
206 		0x14, 0x92, 0xaf, 0x14, 0x25, 0x69, 0x5e, 0x48,
207 		0xbf, 0x42, 0x9b, 0x2d, 0x51, 0xf2, 0xab, 0x45,
208 	};
209 	uint8_t exp_digest[] = {
210 		0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
211 		0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
212 		0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
213 		0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
214 	};
215 	uint32_t exp_rep_policy = (
216 		(1 << _suit_reporting_bits_suit_send_record_success)
217 		| (1 << _suit_reporting_bits_suit_send_record_failure)
218 		| (1 << _suit_reporting_bits_suit_send_sysinfo_success)
219 		| (1 << _suit_reporting_bits_suit_send_sysinfo_failure));
220 
221 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Envelope_Tagged(example0, sizeof(example0), &envelope, &out_len), NULL);
222 	zassert_equal(sizeof(example0), out_len, NULL);
223 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Manifest(envelope._SUIT_Envelope_suit_manifest.value,
224 		envelope._SUIT_Envelope_suit_manifest.len, &manifest, &out_len), NULL);
225 	zassert_equal(envelope._SUIT_Envelope_suit_manifest.len, out_len, NULL);
226 	zassert_true(manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_components_present, NULL);
227 	zassert_true(manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence_present, NULL);
228 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Common_Sequence(
229 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.value,
230 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.len,
231 		&common_sequence, &out_len), NULL);
232 	zassert_equal(
233 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.len,
234 		out_len, NULL);
235 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Command_Sequence(
236 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.value,
237 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.len,
238 		&command_sequence, &out_len), NULL);
239 	zassert_equal(
240 		manifest._SUIT_Manifest_suit_common_cbor._SUIT_Common_suit_common_sequence._SUIT_Common_suit_common_sequence.len,
241 		out_len, NULL);
242 	zassert_equal(3, command_sequence._SUIT_Command_Sequence_union_count, NULL);
243 	zassert_equal(_SUIT_Command_Sequence_union__SUIT_Directive, command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union_choice, NULL);
244 	zassert_equal(_SUIT_Directive___suit_directive_override_parameters, command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union__SUIT_Directive._SUIT_Directive_choice, NULL);
245 	zassert_equal(4, command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union__SUIT_Directive.___suit_directive_override_parameters_map__SUIT_Parameters_count, NULL);
246 
247 	parameter = &command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union__SUIT_Directive.___suit_directive_override_parameters_map__SUIT_Parameters[0].___suit_directive_override_parameters_map__SUIT_Parameters;
248 	zassert_equal(
249 		_SUIT_Parameters_suit_parameter_vendor_identifier,
250 		parameter->_SUIT_Parameters_choice, NULL);
251 	zassert_equal(
252 		_SUIT_Parameters_suit_parameter_vendor_identifier__RFC4122_UUID,
253 		parameter->_SUIT_Parameters_suit_parameter_vendor_identifier_choice, NULL);
254 	zassert_equal(
255 		parameter->_SUIT_Parameters_suit_parameter_vendor_identifier__RFC4122_UUID.len,
256 		sizeof(exp_vendor_id), NULL);
257 	zassert_mem_equal(exp_vendor_id,
258 		parameter->_SUIT_Parameters_suit_parameter_vendor_identifier__RFC4122_UUID.value,
259 		parameter->_SUIT_Parameters_suit_parameter_vendor_identifier__RFC4122_UUID.len, NULL);
260 
261 	parameter = &command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union__SUIT_Directive.___suit_directive_override_parameters_map__SUIT_Parameters[1].___suit_directive_override_parameters_map__SUIT_Parameters;
262 	zassert_equal(
263 		_SUIT_Parameters_suit_parameter_class_identifier,
264 		parameter->_SUIT_Parameters_choice, NULL);
265 	zassert_equal(
266 		parameter->_SUIT_Parameters_suit_parameter_class_identifier.len,
267 		sizeof(exp_class_id), NULL);
268 	zassert_mem_equal(exp_class_id,
269 		parameter->_SUIT_Parameters_suit_parameter_class_identifier.value,
270 		parameter->_SUIT_Parameters_suit_parameter_class_identifier.len, NULL);
271 
272 	parameter = &command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union__SUIT_Directive.___suit_directive_override_parameters_map__SUIT_Parameters[2].___suit_directive_override_parameters_map__SUIT_Parameters;
273 	zassert_equal(
274 		_SUIT_Parameters_suit_parameter_image_digest,
275 		parameter->_SUIT_Parameters_choice, NULL);
276 	zassert_equal(
277 		parameter->_SUIT_Parameters_suit_parameter_image_digest_cbor._SUIT_Digest_suit_digest_bytes.len,
278 		sizeof(exp_digest), NULL);
279 	zassert_equal(_suit_cose_hash_algs__cose_alg_sha_256,
280 		parameter->_SUIT_Parameters_suit_parameter_image_digest_cbor._SUIT_Digest_suit_digest_algorithm_id._suit_cose_hash_algs_choice, NULL);
281 	zassert_mem_equal(exp_digest,
282 		parameter->_SUIT_Parameters_suit_parameter_image_digest_cbor._SUIT_Digest_suit_digest_bytes.value,
283 		parameter->_SUIT_Parameters_suit_parameter_image_digest_cbor._SUIT_Digest_suit_digest_bytes.len, NULL);
284 
285 	parameter = &command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union__SUIT_Directive.___suit_directive_override_parameters_map__SUIT_Parameters[3].___suit_directive_override_parameters_map__SUIT_Parameters;
286 	zassert_equal(
287 		_SUIT_Parameters_suit_parameter_image_size,
288 		parameter->_SUIT_Parameters_choice, NULL);
289 	zassert_equal(34768, parameter->_SUIT_Parameters_suit_parameter_image_size, NULL);
290 
291 	zassert_equal(_SUIT_Command_Sequence_union__SUIT_Condition, command_sequence._SUIT_Command_Sequence_union[1]._SUIT_Command_Sequence_union_choice, NULL);
292 	condition = &command_sequence._SUIT_Command_Sequence_union[1]._SUIT_Command_Sequence_union__SUIT_Condition;
293 	zassert_equal(_SUIT_Condition___suit_condition_vendor_identifier,
294 		condition->_SUIT_Condition_choice, NULL);
295 	zassert_equal(exp_rep_policy,
296 		condition->_SUIT_Condition___suit_condition_vendor_identifier__SUIT_Rep_Policy, NULL);
297 	zassert_equal(exp_rep_policy,
298 		condition->_SUIT_Condition___suit_condition_class_identifier__SUIT_Rep_Policy, NULL);
299 
300 	zassert_equal(_SUIT_Command_Sequence_union__SUIT_Condition, command_sequence._SUIT_Command_Sequence_union[2]._SUIT_Command_Sequence_union_choice, NULL);
301 	condition = &command_sequence._SUIT_Command_Sequence_union[2]._SUIT_Command_Sequence_union__SUIT_Condition;
302 	zassert_equal(_SUIT_Condition___suit_condition_class_identifier,
303 		condition->_SUIT_Condition_choice, NULL);
304 	zassert_equal(exp_rep_policy,
305 		condition->_SUIT_Condition___suit_condition_class_identifier__SUIT_Rep_Policy, NULL);
306 }
307 
ZTEST(cbor_decode_test9,test_suit14_ex0_validate_run)308 ZTEST(cbor_decode_test9, test_suit14_ex0_validate_run)
309 {
310 	struct SUIT_Envelope envelope;
311 	struct SUIT_Manifest manifest;
312 	struct SUIT_Command_Sequence command_sequence;
313 	struct SUIT_Condition_ *condition;
314 	struct SUIT_Directive_ *directive;
315 	size_t out_len;
316 	uint32_t exp_rep_policy1 = (
317 		(1 << _suit_reporting_bits_suit_send_record_success)
318 		| (1 << _suit_reporting_bits_suit_send_record_failure)
319 		| (1 << _suit_reporting_bits_suit_send_sysinfo_success)
320 		| (1 << _suit_reporting_bits_suit_send_sysinfo_failure));
321 	uint32_t exp_rep_policy2 = (1 << _suit_reporting_bits_suit_send_record_failure);
322 
323 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Envelope_Tagged(example0, sizeof(example0), &envelope, &out_len), NULL);
324 	zassert_equal(sizeof(example0), out_len, NULL);
325 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Manifest(envelope._SUIT_Envelope_suit_manifest.value,
326 		envelope._SUIT_Envelope_suit_manifest.len, &manifest, &out_len), NULL);
327 	zassert_equal(envelope._SUIT_Envelope_suit_manifest.len, out_len, NULL);
328 	zassert_true(manifest._SUIT_Manifest__SUIT_Unseverable_Members._SUIT_Unseverable_Members_suit_validate_present, NULL);
329 	zassert_false(manifest._SUIT_Manifest__SUIT_Unseverable_Members._SUIT_Unseverable_Members_suit_load_present, NULL);
330 	zassert_true(manifest._SUIT_Manifest__SUIT_Unseverable_Members._SUIT_Unseverable_Members_suit_run_present, NULL);
331 
332 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Command_Sequence(
333 		manifest._SUIT_Manifest__SUIT_Unseverable_Members._SUIT_Unseverable_Members_suit_validate._SUIT_Unseverable_Members_suit_validate.value,
334 		manifest._SUIT_Manifest__SUIT_Unseverable_Members._SUIT_Unseverable_Members_suit_validate._SUIT_Unseverable_Members_suit_validate.len,
335 		&command_sequence, &out_len), NULL);
336 	zassert_equal(
337 		manifest._SUIT_Manifest__SUIT_Unseverable_Members._SUIT_Unseverable_Members_suit_validate._SUIT_Unseverable_Members_suit_validate.len,
338 		out_len, NULL);
339 	zassert_equal(1, command_sequence._SUIT_Command_Sequence_union_count, NULL);
340 	zassert_equal(_SUIT_Command_Sequence_union__SUIT_Condition, command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union_choice, NULL);
341 	condition = &command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union__SUIT_Condition;
342 	zassert_equal(_SUIT_Condition___suit_condition_image_match,
343 		condition->_SUIT_Condition_choice, NULL);
344 	zassert_equal(exp_rep_policy1,
345 		condition->_SUIT_Condition___suit_condition_image_match__SUIT_Rep_Policy, NULL);
346 
347 	zassert_equal(ZCBOR_SUCCESS, cbor_decode_SUIT_Command_Sequence(
348 		manifest._SUIT_Manifest__SUIT_Unseverable_Members._SUIT_Unseverable_Members_suit_run._SUIT_Unseverable_Members_suit_run.value,
349 		manifest._SUIT_Manifest__SUIT_Unseverable_Members._SUIT_Unseverable_Members_suit_run._SUIT_Unseverable_Members_suit_run.len,
350 		&command_sequence, &out_len), NULL);
351 	zassert_equal(
352 		manifest._SUIT_Manifest__SUIT_Unseverable_Members._SUIT_Unseverable_Members_suit_run._SUIT_Unseverable_Members_suit_run.len,
353 		out_len, NULL);
354 	zassert_equal(1, command_sequence._SUIT_Command_Sequence_union_count, NULL);
355 	zassert_equal(_SUIT_Command_Sequence_union__SUIT_Directive, command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union_choice, NULL);
356 	directive = &command_sequence._SUIT_Command_Sequence_union[0]._SUIT_Command_Sequence_union__SUIT_Directive;
357 	zassert_equal(_SUIT_Directive___suit_directive_run,
358 		directive->_SUIT_Directive_choice, NULL);
359 	zassert_equal(exp_rep_policy2,
360 		directive->_SUIT_Directive___suit_directive_run__SUIT_Rep_Policy, NULL);
361 
362 }
363 
364 ZTEST_SUITE(cbor_decode_test9, NULL, NULL, NULL, NULL, NULL);
365