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_encode.h"
12 #include "cbor/edhoc_encode_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
encode_repeated_id_cred_x_map_kid(zcbor_state_t * state,const struct id_cred_x_map_kid_ * input)19 static bool encode_repeated_id_cred_x_map_kid(
20 zcbor_state_t *state, const struct id_cred_x_map_kid_ *input)
21 {
22 zcbor_print("%s\r\n", __func__);
23
24 bool tmp_result = ((((zcbor_uint32_put(state, (4))))
25 && (((*input)._id_cred_x_map_kid_choice == _id_cred_x_map_kid_int) ? ((zcbor_int32_encode(state, (&(*input)._id_cred_x_map_kid_int))))
26 : (((*input)._id_cred_x_map_kid_choice == _id_cred_x_map_kid_bstr) ? ((zcbor_bstr_encode(state, (&(*input)._id_cred_x_map_kid_bstr))))
27 : false))));
28
29 if (!tmp_result)
30 zcbor_trace();
31
32 return tmp_result;
33 }
34
encode_repeated_id_cred_x_map_x5bag(zcbor_state_t * state,const struct id_cred_x_map_x5bag * input)35 static bool encode_repeated_id_cred_x_map_x5bag(
36 zcbor_state_t *state, const struct id_cred_x_map_x5bag *input)
37 {
38 zcbor_print("%s\r\n", __func__);
39
40 bool tmp_result = ((((zcbor_uint32_put(state, (32))))
41 && (zcbor_bstr_encode(state, (&(*input)._id_cred_x_map_x5bag)))));
42
43 if (!tmp_result)
44 zcbor_trace();
45
46 return tmp_result;
47 }
48
encode_repeated_id_cred_x_map_x5chain(zcbor_state_t * state,const struct id_cred_x_map_x5chain * input)49 static bool encode_repeated_id_cred_x_map_x5chain(
50 zcbor_state_t *state, const struct id_cred_x_map_x5chain *input)
51 {
52 zcbor_print("%s\r\n", __func__);
53
54 bool tmp_result = ((((zcbor_uint32_put(state, (33))))
55 && (zcbor_bstr_encode(state, (&(*input)._id_cred_x_map_x5chain)))));
56
57 if (!tmp_result)
58 zcbor_trace();
59
60 return tmp_result;
61 }
62
encode_repeated_id_cred_x_map_x5t(zcbor_state_t * state,const struct id_cred_x_map_x5t_ * input)63 static bool encode_repeated_id_cred_x_map_x5t(
64 zcbor_state_t *state, const struct id_cred_x_map_x5t_ *input)
65 {
66 zcbor_print("%s\r\n", __func__);
67 bool int_res;
68
69 bool tmp_result = ((((zcbor_uint32_put(state, (34))))
70 && (zcbor_list_start_encode(state, 2) && (int_res = (((((*input)._id_cred_x_map_x5t_alg_choice == _id_cred_x_map_x5t_alg_int) ? ((zcbor_int32_encode(state, (&(*input)._id_cred_x_map_x5t_alg_int))))
71 : (((*input)._id_cred_x_map_x5t_alg_choice == _id_cred_x_map_x5t_alg_tstr) ? ((zcbor_tstr_encode(state, (&(*input)._id_cred_x_map_x5t_alg_tstr))))
72 : false)))
73 && ((zcbor_bstr_encode(state, (&(*input)._id_cred_x_map_x5t_hash))))), ((zcbor_list_end_encode(state, 2)) && int_res)))));
74
75 if (!tmp_result)
76 zcbor_trace();
77
78 return tmp_result;
79 }
80
encode_repeated_id_cred_x_map_x5u(zcbor_state_t * state,const struct id_cred_x_map_x5u * input)81 static bool encode_repeated_id_cred_x_map_x5u(
82 zcbor_state_t *state, const struct id_cred_x_map_x5u *input)
83 {
84 zcbor_print("%s\r\n", __func__);
85
86 bool tmp_result = ((((zcbor_uint32_put(state, (35))))
87 && (zcbor_bstr_encode(state, (&(*input)._id_cred_x_map_x5u)))));
88
89 if (!tmp_result)
90 zcbor_trace();
91
92 return tmp_result;
93 }
94
encode_repeated_id_cred_x_map_c5b(zcbor_state_t * state,const struct id_cred_x_map_c5b * input)95 static bool encode_repeated_id_cred_x_map_c5b(
96 zcbor_state_t *state, const struct id_cred_x_map_c5b *input)
97 {
98 zcbor_print("%s\r\n", __func__);
99
100 bool tmp_result = ((((zcbor_uint32_put(state, (52))))
101 && (zcbor_bstr_encode(state, (&(*input)._id_cred_x_map_c5b)))));
102
103 if (!tmp_result)
104 zcbor_trace();
105
106 return tmp_result;
107 }
108
encode_repeated_id_cred_x_map_c5c(zcbor_state_t * state,const struct id_cred_x_map_c5c * input)109 static bool encode_repeated_id_cred_x_map_c5c(
110 zcbor_state_t *state, const struct id_cred_x_map_c5c *input)
111 {
112 zcbor_print("%s\r\n", __func__);
113
114 bool tmp_result = ((((zcbor_uint32_put(state, (53))))
115 && (zcbor_bstr_encode(state, (&(*input)._id_cred_x_map_c5c)))));
116
117 if (!tmp_result)
118 zcbor_trace();
119
120 return tmp_result;
121 }
122
encode_repeated_id_cred_x_map_c5t(zcbor_state_t * state,const struct id_cred_x_map_c5t_ * input)123 static bool encode_repeated_id_cred_x_map_c5t(
124 zcbor_state_t *state, const struct id_cred_x_map_c5t_ *input)
125 {
126 zcbor_print("%s\r\n", __func__);
127 bool int_res;
128
129 bool tmp_result = ((((zcbor_uint32_put(state, (54))))
130 && (zcbor_list_start_encode(state, 2) && (int_res = (((((*input)._id_cred_x_map_c5t_alg_choice == _id_cred_x_map_c5t_alg_int) ? ((zcbor_int32_encode(state, (&(*input)._id_cred_x_map_c5t_alg_int))))
131 : (((*input)._id_cred_x_map_c5t_alg_choice == _id_cred_x_map_c5t_alg_tstr) ? ((zcbor_tstr_encode(state, (&(*input)._id_cred_x_map_c5t_alg_tstr))))
132 : false)))
133 && ((zcbor_bstr_encode(state, (&(*input)._id_cred_x_map_c5t_hash))))), ((zcbor_list_end_encode(state, 2)) && int_res)))));
134
135 if (!tmp_result)
136 zcbor_trace();
137
138 return tmp_result;
139 }
140
encode_repeated_id_cred_x_map_c5u(zcbor_state_t * state,const struct id_cred_x_map_c5u * input)141 static bool encode_repeated_id_cred_x_map_c5u(
142 zcbor_state_t *state, const struct id_cred_x_map_c5u *input)
143 {
144 zcbor_print("%s\r\n", __func__);
145
146 bool tmp_result = ((((zcbor_uint32_put(state, (55))))
147 && (zcbor_bstr_encode(state, (&(*input)._id_cred_x_map_c5u)))));
148
149 if (!tmp_result)
150 zcbor_trace();
151
152 return tmp_result;
153 }
154
encode_id_cred_x_map(zcbor_state_t * state,const struct id_cred_x_map * input)155 static bool encode_id_cred_x_map(
156 zcbor_state_t *state, const struct id_cred_x_map *input)
157 {
158 zcbor_print("%s\r\n", __func__);
159 bool int_res;
160
161 bool tmp_result = (((zcbor_map_start_encode(state, 9) && (int_res = (zcbor_present_encode(&((*input)._id_cred_x_map_kid_present), (zcbor_encoder_t *)encode_repeated_id_cred_x_map_kid, state, (&(*input)._id_cred_x_map_kid))
162 && zcbor_present_encode(&((*input)._id_cred_x_map_x5bag_present), (zcbor_encoder_t *)encode_repeated_id_cred_x_map_x5bag, state, (&(*input)._id_cred_x_map_x5bag))
163 && zcbor_present_encode(&((*input)._id_cred_x_map_x5chain_present), (zcbor_encoder_t *)encode_repeated_id_cred_x_map_x5chain, state, (&(*input)._id_cred_x_map_x5chain))
164 && zcbor_present_encode(&((*input)._id_cred_x_map_x5t_present), (zcbor_encoder_t *)encode_repeated_id_cred_x_map_x5t, state, (&(*input)._id_cred_x_map_x5t))
165 && zcbor_present_encode(&((*input)._id_cred_x_map_x5u_present), (zcbor_encoder_t *)encode_repeated_id_cred_x_map_x5u, state, (&(*input)._id_cred_x_map_x5u))
166 && zcbor_present_encode(&((*input)._id_cred_x_map_c5b_present), (zcbor_encoder_t *)encode_repeated_id_cred_x_map_c5b, state, (&(*input)._id_cred_x_map_c5b))
167 && zcbor_present_encode(&((*input)._id_cred_x_map_c5c_present), (zcbor_encoder_t *)encode_repeated_id_cred_x_map_c5c, state, (&(*input)._id_cred_x_map_c5c))
168 && zcbor_present_encode(&((*input)._id_cred_x_map_c5t_present), (zcbor_encoder_t *)encode_repeated_id_cred_x_map_c5t, state, (&(*input)._id_cred_x_map_c5t))
169 && zcbor_present_encode(&((*input)._id_cred_x_map_c5u_present), (zcbor_encoder_t *)encode_repeated_id_cred_x_map_c5u, state, (&(*input)._id_cred_x_map_c5u))), ((zcbor_map_end_encode(state, 9)) && int_res)))));
170
171 if (!tmp_result)
172 zcbor_trace();
173
174 return tmp_result;
175 }
176
177
178
cbor_encode_id_cred_x_map(uint8_t * payload,size_t payload_len,const struct id_cred_x_map * input,size_t * payload_len_out)179 bool cbor_encode_id_cred_x_map(
180 uint8_t *payload, size_t payload_len,
181 const struct id_cred_x_map *input,
182 size_t *payload_len_out)
183 {
184 zcbor_state_t states[5];
185
186 zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1);
187
188 bool ret = encode_id_cred_x_map(states, input);
189
190 if (ret && (payload_len_out != NULL)) {
191 *payload_len_out = MIN(payload_len,
192 (size_t)states[0].payload - (size_t)payload);
193 }
194
195 return ret;
196 }
197