1 /*
2  * Generated using zcbor version 0.8.0
3  * https://github.com/NordicSemiconductor/zcbor
4  * Generated with a --default-max-qty of 3
5  */
6 
7 #include <stdint.h>
8 #include <stdbool.h>
9 #include <stddef.h>
10 #include <string.h>
11 #include "zcbor_decode.h"
12 #include "cbor/edhoc_decode_id_cred_x.h"
13 #include "zcbor_print.h"
14 
15 #if DEFAULT_MAX_QTY != 3
16 #error "The type file was generated with a different default_max_qty than this file"
17 #endif
18 
19 static bool decode_repeated_id_cred_x_map_kid(zcbor_state_t *state, struct id_cred_x_map_kid_r *result);
20 static bool decode_repeated_id_cred_x_map_x5bag(zcbor_state_t *state, struct id_cred_x_map_x5bag *result);
21 static bool decode_repeated_id_cred_x_map_x5chain(zcbor_state_t *state, struct id_cred_x_map_x5chain *result);
22 static bool decode_repeated_id_cred_x_map_x5t(zcbor_state_t *state, struct id_cred_x_map_x5t_r *result);
23 static bool decode_repeated_id_cred_x_map_x5u(zcbor_state_t *state, struct id_cred_x_map_x5u *result);
24 static bool decode_repeated_id_cred_x_map_c5b(zcbor_state_t *state, struct id_cred_x_map_c5b *result);
25 static bool decode_repeated_id_cred_x_map_c5c(zcbor_state_t *state, struct id_cred_x_map_c5c *result);
26 static bool decode_repeated_id_cred_x_map_c5t(zcbor_state_t *state, struct id_cred_x_map_c5t_r *result);
27 static bool decode_repeated_id_cred_x_map_c5u(zcbor_state_t *state, struct id_cred_x_map_c5u *result);
28 static bool decode_id_cred_x_map(zcbor_state_t *state, struct id_cred_x_map *result);
29 
30 
decode_repeated_id_cred_x_map_kid(zcbor_state_t * state,struct id_cred_x_map_kid_r * result)31 static bool decode_repeated_id_cred_x_map_kid(
32 		zcbor_state_t *state, struct id_cred_x_map_kid_r *result)
33 {
34 	zcbor_log("%s\r\n", __func__);
35 	bool int_res;
36 
37 	bool tmp_result = ((((zcbor_uint32_expect(state, (4))))
38 	&& (zcbor_union_start_code(state) && (int_res = ((((zcbor_int32_decode(state, (&(*result).id_cred_x_map_kid_int)))) && (((*result).id_cred_x_map_kid_choice = id_cred_x_map_kid_int_c), true))
39 	|| (((zcbor_bstr_decode(state, (&(*result).id_cred_x_map_kid_bstr)))) && (((*result).id_cred_x_map_kid_choice = id_cred_x_map_kid_bstr_c), true))), zcbor_union_end_code(state), int_res))));
40 
41 	if (!tmp_result) {
42 		zcbor_trace_file(state);
43 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
44 	} else {
45 		zcbor_log("%s success\r\n", __func__);
46 	}
47 
48 	return tmp_result;
49 }
50 
decode_repeated_id_cred_x_map_x5bag(zcbor_state_t * state,struct id_cred_x_map_x5bag * result)51 static bool decode_repeated_id_cred_x_map_x5bag(
52 		zcbor_state_t *state, struct id_cred_x_map_x5bag *result)
53 {
54 	zcbor_log("%s\r\n", __func__);
55 
56 	bool tmp_result = ((((zcbor_uint32_expect(state, (32))))
57 	&& (zcbor_bstr_decode(state, (&(*result).id_cred_x_map_x5bag)))));
58 
59 	if (!tmp_result) {
60 		zcbor_trace_file(state);
61 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
62 	} else {
63 		zcbor_log("%s success\r\n", __func__);
64 	}
65 
66 	return tmp_result;
67 }
68 
decode_repeated_id_cred_x_map_x5chain(zcbor_state_t * state,struct id_cred_x_map_x5chain * result)69 static bool decode_repeated_id_cred_x_map_x5chain(
70 		zcbor_state_t *state, struct id_cred_x_map_x5chain *result)
71 {
72 	zcbor_log("%s\r\n", __func__);
73 
74 	bool tmp_result = ((((zcbor_uint32_expect(state, (33))))
75 	&& (zcbor_bstr_decode(state, (&(*result).id_cred_x_map_x5chain)))));
76 
77 	if (!tmp_result) {
78 		zcbor_trace_file(state);
79 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
80 	} else {
81 		zcbor_log("%s success\r\n", __func__);
82 	}
83 
84 	return tmp_result;
85 }
86 
decode_repeated_id_cred_x_map_x5t(zcbor_state_t * state,struct id_cred_x_map_x5t_r * result)87 static bool decode_repeated_id_cred_x_map_x5t(
88 		zcbor_state_t *state, struct id_cred_x_map_x5t_r *result)
89 {
90 	zcbor_log("%s\r\n", __func__);
91 	bool int_res;
92 
93 	bool tmp_result = ((((zcbor_uint32_expect(state, (34))))
94 	&& (zcbor_list_start_decode(state) && ((((zcbor_union_start_code(state) && (int_res = ((((zcbor_int32_decode(state, (&(*result).id_cred_x_map_x5t_alg_int)))) && (((*result).id_cred_x_map_x5t_alg_choice = id_cred_x_map_x5t_alg_int_c), true))
95 	|| (((zcbor_tstr_decode(state, (&(*result).id_cred_x_map_x5t_alg_tstr)))) && (((*result).id_cred_x_map_x5t_alg_choice = id_cred_x_map_x5t_alg_tstr_c), true))), zcbor_union_end_code(state), int_res)))
96 	&& ((zcbor_bstr_decode(state, (&(*result).id_cred_x_map_x5t_hash))))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state))));
97 
98 	if (!tmp_result) {
99 		zcbor_trace_file(state);
100 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
101 	} else {
102 		zcbor_log("%s success\r\n", __func__);
103 	}
104 
105 	return tmp_result;
106 }
107 
decode_repeated_id_cred_x_map_x5u(zcbor_state_t * state,struct id_cred_x_map_x5u * result)108 static bool decode_repeated_id_cred_x_map_x5u(
109 		zcbor_state_t *state, struct id_cred_x_map_x5u *result)
110 {
111 	zcbor_log("%s\r\n", __func__);
112 
113 	bool tmp_result = ((((zcbor_uint32_expect(state, (35))))
114 	&& (zcbor_bstr_decode(state, (&(*result).id_cred_x_map_x5u)))));
115 
116 	if (!tmp_result) {
117 		zcbor_trace_file(state);
118 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
119 	} else {
120 		zcbor_log("%s success\r\n", __func__);
121 	}
122 
123 	return tmp_result;
124 }
125 
decode_repeated_id_cred_x_map_c5b(zcbor_state_t * state,struct id_cred_x_map_c5b * result)126 static bool decode_repeated_id_cred_x_map_c5b(
127 		zcbor_state_t *state, struct id_cred_x_map_c5b *result)
128 {
129 	zcbor_log("%s\r\n", __func__);
130 
131 	bool tmp_result = ((((zcbor_uint32_expect(state, (52))))
132 	&& (zcbor_bstr_decode(state, (&(*result).id_cred_x_map_c5b)))));
133 
134 	if (!tmp_result) {
135 		zcbor_trace_file(state);
136 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
137 	} else {
138 		zcbor_log("%s success\r\n", __func__);
139 	}
140 
141 	return tmp_result;
142 }
143 
decode_repeated_id_cred_x_map_c5c(zcbor_state_t * state,struct id_cred_x_map_c5c * result)144 static bool decode_repeated_id_cred_x_map_c5c(
145 		zcbor_state_t *state, struct id_cred_x_map_c5c *result)
146 {
147 	zcbor_log("%s\r\n", __func__);
148 
149 	bool tmp_result = ((((zcbor_uint32_expect(state, (53))))
150 	&& (zcbor_bstr_decode(state, (&(*result).id_cred_x_map_c5c)))));
151 
152 	if (!tmp_result) {
153 		zcbor_trace_file(state);
154 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
155 	} else {
156 		zcbor_log("%s success\r\n", __func__);
157 	}
158 
159 	return tmp_result;
160 }
161 
decode_repeated_id_cred_x_map_c5t(zcbor_state_t * state,struct id_cred_x_map_c5t_r * result)162 static bool decode_repeated_id_cred_x_map_c5t(
163 		zcbor_state_t *state, struct id_cred_x_map_c5t_r *result)
164 {
165 	zcbor_log("%s\r\n", __func__);
166 	bool int_res;
167 
168 	bool tmp_result = ((((zcbor_uint32_expect(state, (54))))
169 	&& (zcbor_list_start_decode(state) && ((((zcbor_union_start_code(state) && (int_res = ((((zcbor_int32_decode(state, (&(*result).id_cred_x_map_c5t_alg_int)))) && (((*result).id_cred_x_map_c5t_alg_choice = id_cred_x_map_c5t_alg_int_c), true))
170 	|| (((zcbor_tstr_decode(state, (&(*result).id_cred_x_map_c5t_alg_tstr)))) && (((*result).id_cred_x_map_c5t_alg_choice = id_cred_x_map_c5t_alg_tstr_c), true))), zcbor_union_end_code(state), int_res)))
171 	&& ((zcbor_bstr_decode(state, (&(*result).id_cred_x_map_c5t_hash))))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state))));
172 
173 	if (!tmp_result) {
174 		zcbor_trace_file(state);
175 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
176 	} else {
177 		zcbor_log("%s success\r\n", __func__);
178 	}
179 
180 	return tmp_result;
181 }
182 
decode_repeated_id_cred_x_map_c5u(zcbor_state_t * state,struct id_cred_x_map_c5u * result)183 static bool decode_repeated_id_cred_x_map_c5u(
184 		zcbor_state_t *state, struct id_cred_x_map_c5u *result)
185 {
186 	zcbor_log("%s\r\n", __func__);
187 
188 	bool tmp_result = ((((zcbor_uint32_expect(state, (55))))
189 	&& (zcbor_bstr_decode(state, (&(*result).id_cred_x_map_c5u)))));
190 
191 	if (!tmp_result) {
192 		zcbor_trace_file(state);
193 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
194 	} else {
195 		zcbor_log("%s success\r\n", __func__);
196 	}
197 
198 	return tmp_result;
199 }
200 
decode_id_cred_x_map(zcbor_state_t * state,struct id_cred_x_map * result)201 static bool decode_id_cred_x_map(
202 		zcbor_state_t *state, struct id_cred_x_map *result)
203 {
204 	zcbor_log("%s\r\n", __func__);
205 
206 	bool tmp_result = (((zcbor_map_start_decode(state) && ((zcbor_present_decode(&((*result).id_cred_x_map_kid_present), (zcbor_decoder_t *)decode_repeated_id_cred_x_map_kid, state, (&(*result).id_cred_x_map_kid))
207 	&& zcbor_present_decode(&((*result).id_cred_x_map_x5bag_present), (zcbor_decoder_t *)decode_repeated_id_cred_x_map_x5bag, state, (&(*result).id_cred_x_map_x5bag))
208 	&& zcbor_present_decode(&((*result).id_cred_x_map_x5chain_present), (zcbor_decoder_t *)decode_repeated_id_cred_x_map_x5chain, state, (&(*result).id_cred_x_map_x5chain))
209 	&& zcbor_present_decode(&((*result).id_cred_x_map_x5t_present), (zcbor_decoder_t *)decode_repeated_id_cred_x_map_x5t, state, (&(*result).id_cred_x_map_x5t))
210 	&& zcbor_present_decode(&((*result).id_cred_x_map_x5u_present), (zcbor_decoder_t *)decode_repeated_id_cred_x_map_x5u, state, (&(*result).id_cred_x_map_x5u))
211 	&& zcbor_present_decode(&((*result).id_cred_x_map_c5b_present), (zcbor_decoder_t *)decode_repeated_id_cred_x_map_c5b, state, (&(*result).id_cred_x_map_c5b))
212 	&& zcbor_present_decode(&((*result).id_cred_x_map_c5c_present), (zcbor_decoder_t *)decode_repeated_id_cred_x_map_c5c, state, (&(*result).id_cred_x_map_c5c))
213 	&& zcbor_present_decode(&((*result).id_cred_x_map_c5t_present), (zcbor_decoder_t *)decode_repeated_id_cred_x_map_c5t, state, (&(*result).id_cred_x_map_c5t))
214 	&& zcbor_present_decode(&((*result).id_cred_x_map_c5u_present), (zcbor_decoder_t *)decode_repeated_id_cred_x_map_c5u, state, (&(*result).id_cred_x_map_c5u))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_map_end_decode(state))));
215 
216 	if (!tmp_result) {
217 		zcbor_trace_file(state);
218 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
219 	} else {
220 		zcbor_log("%s success\r\n", __func__);
221 	}
222 
223 	return tmp_result;
224 }
225 
226 
227 
cbor_decode_id_cred_x_map(const uint8_t * payload,size_t payload_len,struct id_cred_x_map * result,size_t * payload_len_out)228 int cbor_decode_id_cred_x_map(
229 		const uint8_t *payload, size_t payload_len,
230 		struct id_cred_x_map *result,
231 		size_t *payload_len_out)
232 {
233 	zcbor_state_t states[5];
234 
235 	return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
236 		(zcbor_decoder_t *)decode_id_cred_x_map, sizeof(states) / sizeof(zcbor_state_t), 1);
237 }
238