1 /*
2 * Generated using zcbor version 0.3.99
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
14 #if DEFAULT_MAX_QTY != 3
15 #error "The type file was generated with a different default_max_qty than this file"
16 #endif
17
18
decode_repeated_id_cred_x_map_kid(zcbor_state_t * state,struct id_cred_x_map_kid_ * result)19 static bool decode_repeated_id_cred_x_map_kid(
20 zcbor_state_t *state, struct id_cred_x_map_kid_ *result)
21 {
22 zcbor_print("%s\r\n", __func__);
23 bool int_res;
24
25 bool tmp_result = ((((zcbor_uint32_expect(state, (4))))
26 && (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) || 1))
27 || (((zcbor_bstr_decode(state, (&(*result)._id_cred_x_map_kid_bstr)))) && (((*result)._id_cred_x_map_kid_choice = _id_cred_x_map_kid_bstr) || 1))), zcbor_union_end_code(state), int_res))));
28
29 if (!tmp_result)
30 zcbor_trace();
31
32 return tmp_result;
33 }
34
decode_repeated_id_cred_x_map_x5bag(zcbor_state_t * state,struct id_cred_x_map_x5bag * result)35 static bool decode_repeated_id_cred_x_map_x5bag(
36 zcbor_state_t *state, struct id_cred_x_map_x5bag *result)
37 {
38 zcbor_print("%s\r\n", __func__);
39
40 bool tmp_result = ((((zcbor_uint32_expect(state, (32))))
41 && (zcbor_bstr_decode(state, (&(*result)._id_cred_x_map_x5bag)))));
42
43 if (!tmp_result)
44 zcbor_trace();
45
46 return tmp_result;
47 }
48
decode_repeated_id_cred_x_map_x5chain(zcbor_state_t * state,struct id_cred_x_map_x5chain * result)49 static bool decode_repeated_id_cred_x_map_x5chain(
50 zcbor_state_t *state, struct id_cred_x_map_x5chain *result)
51 {
52 zcbor_print("%s\r\n", __func__);
53
54 bool tmp_result = ((((zcbor_uint32_expect(state, (33))))
55 && (zcbor_bstr_decode(state, (&(*result)._id_cred_x_map_x5chain)))));
56
57 if (!tmp_result)
58 zcbor_trace();
59
60 return tmp_result;
61 }
62
decode_repeated_id_cred_x_map_x5t(zcbor_state_t * state,struct id_cred_x_map_x5t_ * result)63 static bool decode_repeated_id_cred_x_map_x5t(
64 zcbor_state_t *state, struct id_cred_x_map_x5t_ *result)
65 {
66 zcbor_print("%s\r\n", __func__);
67 bool int_res;
68
69 bool tmp_result = ((((zcbor_uint32_expect(state, (34))))
70 && (zcbor_list_start_decode(state) && (int_res = (((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) || 1))
71 || (((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) || 1))), zcbor_union_end_code(state), int_res)))
72 && ((zcbor_bstr_decode(state, (&(*result)._id_cred_x_map_x5t_hash))))), ((zcbor_list_end_decode(state)) && int_res)))));
73
74 if (!tmp_result)
75 zcbor_trace();
76
77 return tmp_result;
78 }
79
decode_repeated_id_cred_x_map_x5u(zcbor_state_t * state,struct id_cred_x_map_x5u * result)80 static bool decode_repeated_id_cred_x_map_x5u(
81 zcbor_state_t *state, struct id_cred_x_map_x5u *result)
82 {
83 zcbor_print("%s\r\n", __func__);
84
85 bool tmp_result = ((((zcbor_uint32_expect(state, (35))))
86 && (zcbor_bstr_decode(state, (&(*result)._id_cred_x_map_x5u)))));
87
88 if (!tmp_result)
89 zcbor_trace();
90
91 return tmp_result;
92 }
93
decode_repeated_id_cred_x_map_c5b(zcbor_state_t * state,struct id_cred_x_map_c5b * result)94 static bool decode_repeated_id_cred_x_map_c5b(
95 zcbor_state_t *state, struct id_cred_x_map_c5b *result)
96 {
97 zcbor_print("%s\r\n", __func__);
98
99 bool tmp_result = ((((zcbor_uint32_expect(state, (52))))
100 && (zcbor_bstr_decode(state, (&(*result)._id_cred_x_map_c5b)))));
101
102 if (!tmp_result)
103 zcbor_trace();
104
105 return tmp_result;
106 }
107
decode_repeated_id_cred_x_map_c5c(zcbor_state_t * state,struct id_cred_x_map_c5c * result)108 static bool decode_repeated_id_cred_x_map_c5c(
109 zcbor_state_t *state, struct id_cred_x_map_c5c *result)
110 {
111 zcbor_print("%s\r\n", __func__);
112
113 bool tmp_result = ((((zcbor_uint32_expect(state, (53))))
114 && (zcbor_bstr_decode(state, (&(*result)._id_cred_x_map_c5c)))));
115
116 if (!tmp_result)
117 zcbor_trace();
118
119 return tmp_result;
120 }
121
decode_repeated_id_cred_x_map_c5t(zcbor_state_t * state,struct id_cred_x_map_c5t_ * result)122 static bool decode_repeated_id_cred_x_map_c5t(
123 zcbor_state_t *state, struct id_cred_x_map_c5t_ *result)
124 {
125 zcbor_print("%s\r\n", __func__);
126 bool int_res;
127
128 bool tmp_result = ((((zcbor_uint32_expect(state, (54))))
129 && (zcbor_list_start_decode(state) && (int_res = (((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) || 1))
130 || (((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) || 1))), zcbor_union_end_code(state), int_res)))
131 && ((zcbor_bstr_decode(state, (&(*result)._id_cred_x_map_c5t_hash))))), ((zcbor_list_end_decode(state)) && int_res)))));
132
133 if (!tmp_result)
134 zcbor_trace();
135
136 return tmp_result;
137 }
138
decode_repeated_id_cred_x_map_c5u(zcbor_state_t * state,struct id_cred_x_map_c5u * result)139 static bool decode_repeated_id_cred_x_map_c5u(
140 zcbor_state_t *state, struct id_cred_x_map_c5u *result)
141 {
142 zcbor_print("%s\r\n", __func__);
143
144 bool tmp_result = ((((zcbor_uint32_expect(state, (55))))
145 && (zcbor_bstr_decode(state, (&(*result)._id_cred_x_map_c5u)))));
146
147 if (!tmp_result)
148 zcbor_trace();
149
150 return tmp_result;
151 }
152
decode_id_cred_x_map(zcbor_state_t * state,struct id_cred_x_map * result)153 static bool decode_id_cred_x_map(
154 zcbor_state_t *state, struct id_cred_x_map *result)
155 {
156 zcbor_print("%s\r\n", __func__);
157 bool int_res;
158
159 bool tmp_result = (((zcbor_map_start_decode(state) && (int_res = (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))
160 && 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))
161 && 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))
162 && 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))
163 && 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))
164 && 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))
165 && 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))
166 && 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))
167 && 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_map_end_decode(state)) && int_res)))));
168
169 if (!tmp_result)
170 zcbor_trace();
171
172 return tmp_result;
173 }
174
175
176
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)177 bool cbor_decode_id_cred_x_map(
178 const uint8_t *payload, size_t payload_len,
179 struct id_cred_x_map *result,
180 size_t *payload_len_out)
181 {
182 zcbor_state_t states[5];
183
184 zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1);
185
186 bool ret = decode_id_cred_x_map(states, result);
187
188 if (ret && (payload_len_out != NULL)) {
189 *payload_len_out = MIN(payload_len,
190 (size_t)states[0].payload - (size_t)payload);
191 }
192
193 return ret;
194 }
195