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