Update geoip files to match ipfire location db, 2023/07/12.
[tor.git] / src / trunnel / ed25519_cert.h
blobbd91ce1055086a87d772c9550abaa9f4e097b667
1 /* ed25519_cert.h -- generated by Trunnel v1.5.3.
2 * https://gitweb.torproject.org/trunnel.git
3 * You probably shouldn't edit this file.
4 */
5 #ifndef TRUNNEL_ED25519_CERT_H
6 #define TRUNNEL_ED25519_CERT_H
8 #include <stdint.h>
9 #include "trunnel.h"
11 #define CERTEXT_SIGNED_WITH_KEY 4
12 #define CERTEXT_FLAG_AFFECTS_VALIDATION 1
13 #define LS_IPV4 0
14 #define LS_IPV6 1
15 #define LS_LEGACY_ID 2
16 #define LS_ED25519_ID 3
17 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CREATE2_CELL_BODY)
18 struct create2_cell_body_st {
19 uint16_t handshake_type;
20 uint16_t handshake_len;
21 TRUNNEL_DYNARRAY_HEAD(, uint8_t) handshake_data;
22 uint8_t trunnel_error_code_;
24 #endif
25 typedef struct create2_cell_body_st create2_cell_body_t;
26 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_ED25519_CERT_EXTENSION)
27 struct ed25519_cert_extension_st {
28 uint16_t ext_length;
29 uint8_t ext_type;
30 uint8_t ext_flags;
31 uint8_t un_signing_key[32];
32 TRUNNEL_DYNARRAY_HEAD(, uint8_t) un_unparsed;
33 uint8_t trunnel_error_code_;
35 #endif
36 typedef struct ed25519_cert_extension_st ed25519_cert_extension_t;
37 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_EXTEND1_CELL_BODY)
38 struct extend1_cell_body_st {
39 uint32_t ipv4addr;
40 uint16_t port;
41 uint8_t onionskin[186];
42 uint8_t identity[20];
43 uint8_t trunnel_error_code_;
45 #endif
46 typedef struct extend1_cell_body_st extend1_cell_body_t;
47 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_LINK_SPECIFIER)
48 struct link_specifier_st {
49 uint8_t ls_type;
50 uint8_t ls_len;
51 uint32_t un_ipv4_addr;
52 uint16_t un_ipv4_port;
53 uint8_t un_ipv6_addr[16];
54 uint16_t un_ipv6_port;
55 uint8_t un_legacy_id[20];
56 uint8_t un_ed25519_id[32];
57 TRUNNEL_DYNARRAY_HEAD(, uint8_t) un_unrecognized;
58 uint8_t trunnel_error_code_;
60 #endif
61 typedef struct link_specifier_st link_specifier_t;
62 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_ED25519_CERT)
63 struct ed25519_cert_st {
64 uint8_t version;
65 uint8_t cert_type;
66 uint32_t exp_field;
67 uint8_t cert_key_type;
68 uint8_t certified_key[32];
69 uint8_t n_extensions;
70 TRUNNEL_DYNARRAY_HEAD(, struct ed25519_cert_extension_st *) ext;
71 uint8_t signature[64];
72 uint8_t trunnel_error_code_;
74 #endif
75 typedef struct ed25519_cert_st ed25519_cert_t;
76 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_EXTEND2_CELL_BODY)
77 struct extend2_cell_body_st {
78 uint8_t n_spec;
79 TRUNNEL_DYNARRAY_HEAD(, struct link_specifier_st *) ls;
80 struct create2_cell_body_st *create2;
81 uint8_t trunnel_error_code_;
83 #endif
84 typedef struct extend2_cell_body_st extend2_cell_body_t;
85 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_LINK_SPECIFIER_LIST)
86 struct link_specifier_list_st {
87 uint8_t n_spec;
88 TRUNNEL_DYNARRAY_HEAD(, struct link_specifier_st *) spec;
89 uint8_t trunnel_error_code_;
91 #endif
92 typedef struct link_specifier_list_st link_specifier_list_t;
93 /** Return a newly allocated create2_cell_body with all elements set
94 * to zero.
96 create2_cell_body_t *create2_cell_body_new(void);
97 /** Release all storage held by the create2_cell_body in 'victim'. (Do
98 * nothing if 'victim' is NULL.)
100 void create2_cell_body_free(create2_cell_body_t *victim);
101 /** Try to parse a create2_cell_body from the buffer in 'input', using
102 * up to 'len_in' bytes from the input buffer. On success, return the
103 * number of bytes consumed and set *output to the newly allocated
104 * create2_cell_body_t. On failure, return -2 if the input appears
105 * truncated, and -1 if the input is otherwise invalid.
107 ssize_t create2_cell_body_parse(create2_cell_body_t **output, const uint8_t *input, const size_t len_in);
108 /** Return the number of bytes we expect to need to encode the
109 * create2_cell_body in 'obj'. On failure, return a negative value.
110 * Note that this value may be an overestimate, and can even be an
111 * underestimate for certain unencodeable objects.
113 ssize_t create2_cell_body_encoded_len(const create2_cell_body_t *obj);
114 /** Try to encode the create2_cell_body from 'input' into the buffer
115 * at 'output', using up to 'avail' bytes of the output buffer. On
116 * success, return the number of bytes used. On failure, return -2 if
117 * the buffer was not long enough, and -1 if the input was invalid.
119 ssize_t create2_cell_body_encode(uint8_t *output, size_t avail, const create2_cell_body_t *input);
120 /** Check whether the internal state of the create2_cell_body in 'obj'
121 * is consistent. Return NULL if it is, and a short message if it is
122 * not.
124 const char *create2_cell_body_check(const create2_cell_body_t *obj);
125 /** Clear any errors that were set on the object 'obj' by its setter
126 * functions. Return true iff errors were cleared.
128 int create2_cell_body_clear_errors(create2_cell_body_t *obj);
129 /** Return the value of the handshake_type field of the
130 * create2_cell_body_t in 'inp'
132 uint16_t create2_cell_body_get_handshake_type(const create2_cell_body_t *inp);
133 /** Set the value of the handshake_type field of the
134 * create2_cell_body_t in 'inp' to 'val'. Return 0 on success; return
135 * -1 and set the error code on 'inp' on failure.
137 int create2_cell_body_set_handshake_type(create2_cell_body_t *inp, uint16_t val);
138 /** Return the value of the handshake_len field of the
139 * create2_cell_body_t in 'inp'
141 uint16_t create2_cell_body_get_handshake_len(const create2_cell_body_t *inp);
142 /** Set the value of the handshake_len field of the
143 * create2_cell_body_t in 'inp' to 'val'. Return 0 on success; return
144 * -1 and set the error code on 'inp' on failure.
146 int create2_cell_body_set_handshake_len(create2_cell_body_t *inp, uint16_t val);
147 /** Return the length of the dynamic array holding the handshake_data
148 * field of the create2_cell_body_t in 'inp'.
150 size_t create2_cell_body_getlen_handshake_data(const create2_cell_body_t *inp);
151 /** Return the element at position 'idx' of the dynamic array field
152 * handshake_data of the create2_cell_body_t in 'inp'.
154 uint8_t create2_cell_body_get_handshake_data(create2_cell_body_t *inp, size_t idx);
155 /** As create2_cell_body_get_handshake_data, but take and return a
156 * const pointer
158 uint8_t create2_cell_body_getconst_handshake_data(const create2_cell_body_t *inp, size_t idx);
159 /** Change the element at position 'idx' of the dynamic array field
160 * handshake_data of the create2_cell_body_t in 'inp', so that it will
161 * hold the value 'elt'.
163 int create2_cell_body_set_handshake_data(create2_cell_body_t *inp, size_t idx, uint8_t elt);
164 /** Append a new element 'elt' to the dynamic array field
165 * handshake_data of the create2_cell_body_t in 'inp'.
167 int create2_cell_body_add_handshake_data(create2_cell_body_t *inp, uint8_t elt);
168 /** Return a pointer to the variable-length array field handshake_data
169 * of 'inp'.
171 uint8_t * create2_cell_body_getarray_handshake_data(create2_cell_body_t *inp);
172 /** As create2_cell_body_get_handshake_data, but take and return a
173 * const pointer
175 const uint8_t * create2_cell_body_getconstarray_handshake_data(const create2_cell_body_t *inp);
176 /** Change the length of the variable-length array field
177 * handshake_data of 'inp' to 'newlen'.Fill extra elements with 0.
178 * Return 0 on success; return -1 and set the error code on 'inp' on
179 * failure.
181 int create2_cell_body_setlen_handshake_data(create2_cell_body_t *inp, size_t newlen);
182 /** Return a newly allocated ed25519_cert_extension with all elements
183 * set to zero.
185 ed25519_cert_extension_t *ed25519_cert_extension_new(void);
186 /** Release all storage held by the ed25519_cert_extension in
187 * 'victim'. (Do nothing if 'victim' is NULL.)
189 void ed25519_cert_extension_free(ed25519_cert_extension_t *victim);
190 /** Try to parse a ed25519_cert_extension from the buffer in 'input',
191 * using up to 'len_in' bytes from the input buffer. On success,
192 * return the number of bytes consumed and set *output to the newly
193 * allocated ed25519_cert_extension_t. On failure, return -2 if the
194 * input appears truncated, and -1 if the input is otherwise invalid.
196 ssize_t ed25519_cert_extension_parse(ed25519_cert_extension_t **output, const uint8_t *input, const size_t len_in);
197 /** Return the number of bytes we expect to need to encode the
198 * ed25519_cert_extension in 'obj'. On failure, return a negative
199 * value. Note that this value may be an overestimate, and can even be
200 * an underestimate for certain unencodeable objects.
202 ssize_t ed25519_cert_extension_encoded_len(const ed25519_cert_extension_t *obj);
203 /** Try to encode the ed25519_cert_extension from 'input' into the
204 * buffer at 'output', using up to 'avail' bytes of the output buffer.
205 * On success, return the number of bytes used. On failure, return -2
206 * if the buffer was not long enough, and -1 if the input was invalid.
208 ssize_t ed25519_cert_extension_encode(uint8_t *output, size_t avail, const ed25519_cert_extension_t *input);
209 /** Check whether the internal state of the ed25519_cert_extension in
210 * 'obj' is consistent. Return NULL if it is, and a short message if
211 * it is not.
213 const char *ed25519_cert_extension_check(const ed25519_cert_extension_t *obj);
214 /** Clear any errors that were set on the object 'obj' by its setter
215 * functions. Return true iff errors were cleared.
217 int ed25519_cert_extension_clear_errors(ed25519_cert_extension_t *obj);
218 /** Return the value of the ext_length field of the
219 * ed25519_cert_extension_t in 'inp'
221 uint16_t ed25519_cert_extension_get_ext_length(const ed25519_cert_extension_t *inp);
222 /** Set the value of the ext_length field of the
223 * ed25519_cert_extension_t in 'inp' to 'val'. Return 0 on success;
224 * return -1 and set the error code on 'inp' on failure.
226 int ed25519_cert_extension_set_ext_length(ed25519_cert_extension_t *inp, uint16_t val);
227 /** Return the value of the ext_type field of the
228 * ed25519_cert_extension_t in 'inp'
230 uint8_t ed25519_cert_extension_get_ext_type(const ed25519_cert_extension_t *inp);
231 /** Set the value of the ext_type field of the
232 * ed25519_cert_extension_t in 'inp' to 'val'. Return 0 on success;
233 * return -1 and set the error code on 'inp' on failure.
235 int ed25519_cert_extension_set_ext_type(ed25519_cert_extension_t *inp, uint8_t val);
236 /** Return the value of the ext_flags field of the
237 * ed25519_cert_extension_t in 'inp'
239 uint8_t ed25519_cert_extension_get_ext_flags(const ed25519_cert_extension_t *inp);
240 /** Set the value of the ext_flags field of the
241 * ed25519_cert_extension_t in 'inp' to 'val'. Return 0 on success;
242 * return -1 and set the error code on 'inp' on failure.
244 int ed25519_cert_extension_set_ext_flags(ed25519_cert_extension_t *inp, uint8_t val);
245 /** Return the (constant) length of the array holding the
246 * un_signing_key field of the ed25519_cert_extension_t in 'inp'.
248 size_t ed25519_cert_extension_getlen_un_signing_key(const ed25519_cert_extension_t *inp);
249 /** Return the element at position 'idx' of the fixed array field
250 * un_signing_key of the ed25519_cert_extension_t in 'inp'.
252 uint8_t ed25519_cert_extension_get_un_signing_key(ed25519_cert_extension_t *inp, size_t idx);
253 /** As ed25519_cert_extension_get_un_signing_key, but take and return
254 * a const pointer
256 uint8_t ed25519_cert_extension_getconst_un_signing_key(const ed25519_cert_extension_t *inp, size_t idx);
257 /** Change the element at position 'idx' of the fixed array field
258 * un_signing_key of the ed25519_cert_extension_t in 'inp', so that it
259 * will hold the value 'elt'.
261 int ed25519_cert_extension_set_un_signing_key(ed25519_cert_extension_t *inp, size_t idx, uint8_t elt);
262 /** Return a pointer to the 32-element array field un_signing_key of
263 * 'inp'.
265 uint8_t * ed25519_cert_extension_getarray_un_signing_key(ed25519_cert_extension_t *inp);
266 /** As ed25519_cert_extension_get_un_signing_key, but take and return
267 * a const pointer
269 const uint8_t * ed25519_cert_extension_getconstarray_un_signing_key(const ed25519_cert_extension_t *inp);
270 /** Return the length of the dynamic array holding the un_unparsed
271 * field of the ed25519_cert_extension_t in 'inp'.
273 size_t ed25519_cert_extension_getlen_un_unparsed(const ed25519_cert_extension_t *inp);
274 /** Return the element at position 'idx' of the dynamic array field
275 * un_unparsed of the ed25519_cert_extension_t in 'inp'.
277 uint8_t ed25519_cert_extension_get_un_unparsed(ed25519_cert_extension_t *inp, size_t idx);
278 /** As ed25519_cert_extension_get_un_unparsed, but take and return a
279 * const pointer
281 uint8_t ed25519_cert_extension_getconst_un_unparsed(const ed25519_cert_extension_t *inp, size_t idx);
282 /** Change the element at position 'idx' of the dynamic array field
283 * un_unparsed of the ed25519_cert_extension_t in 'inp', so that it
284 * will hold the value 'elt'.
286 int ed25519_cert_extension_set_un_unparsed(ed25519_cert_extension_t *inp, size_t idx, uint8_t elt);
287 /** Append a new element 'elt' to the dynamic array field un_unparsed
288 * of the ed25519_cert_extension_t in 'inp'.
290 int ed25519_cert_extension_add_un_unparsed(ed25519_cert_extension_t *inp, uint8_t elt);
291 /** Return a pointer to the variable-length array field un_unparsed of
292 * 'inp'.
294 uint8_t * ed25519_cert_extension_getarray_un_unparsed(ed25519_cert_extension_t *inp);
295 /** As ed25519_cert_extension_get_un_unparsed, but take and return a
296 * const pointer
298 const uint8_t * ed25519_cert_extension_getconstarray_un_unparsed(const ed25519_cert_extension_t *inp);
299 /** Change the length of the variable-length array field un_unparsed
300 * of 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on
301 * success; return -1 and set the error code on 'inp' on failure.
303 int ed25519_cert_extension_setlen_un_unparsed(ed25519_cert_extension_t *inp, size_t newlen);
304 /** Return a newly allocated extend1_cell_body with all elements set
305 * to zero.
307 extend1_cell_body_t *extend1_cell_body_new(void);
308 /** Release all storage held by the extend1_cell_body in 'victim'. (Do
309 * nothing if 'victim' is NULL.)
311 void extend1_cell_body_free(extend1_cell_body_t *victim);
312 /** Try to parse a extend1_cell_body from the buffer in 'input', using
313 * up to 'len_in' bytes from the input buffer. On success, return the
314 * number of bytes consumed and set *output to the newly allocated
315 * extend1_cell_body_t. On failure, return -2 if the input appears
316 * truncated, and -1 if the input is otherwise invalid.
318 ssize_t extend1_cell_body_parse(extend1_cell_body_t **output, const uint8_t *input, const size_t len_in);
319 /** Return the number of bytes we expect to need to encode the
320 * extend1_cell_body in 'obj'. On failure, return a negative value.
321 * Note that this value may be an overestimate, and can even be an
322 * underestimate for certain unencodeable objects.
324 ssize_t extend1_cell_body_encoded_len(const extend1_cell_body_t *obj);
325 /** Try to encode the extend1_cell_body from 'input' into the buffer
326 * at 'output', using up to 'avail' bytes of the output buffer. On
327 * success, return the number of bytes used. On failure, return -2 if
328 * the buffer was not long enough, and -1 if the input was invalid.
330 ssize_t extend1_cell_body_encode(uint8_t *output, size_t avail, const extend1_cell_body_t *input);
331 /** Check whether the internal state of the extend1_cell_body in 'obj'
332 * is consistent. Return NULL if it is, and a short message if it is
333 * not.
335 const char *extend1_cell_body_check(const extend1_cell_body_t *obj);
336 /** Clear any errors that were set on the object 'obj' by its setter
337 * functions. Return true iff errors were cleared.
339 int extend1_cell_body_clear_errors(extend1_cell_body_t *obj);
340 /** Return the value of the ipv4addr field of the extend1_cell_body_t
341 * in 'inp'
343 uint32_t extend1_cell_body_get_ipv4addr(const extend1_cell_body_t *inp);
344 /** Set the value of the ipv4addr field of the extend1_cell_body_t in
345 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
346 * code on 'inp' on failure.
348 int extend1_cell_body_set_ipv4addr(extend1_cell_body_t *inp, uint32_t val);
349 /** Return the value of the port field of the extend1_cell_body_t in
350 * 'inp'
352 uint16_t extend1_cell_body_get_port(const extend1_cell_body_t *inp);
353 /** Set the value of the port field of the extend1_cell_body_t in
354 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
355 * code on 'inp' on failure.
357 int extend1_cell_body_set_port(extend1_cell_body_t *inp, uint16_t val);
358 /** Return the (constant) length of the array holding the onionskin
359 * field of the extend1_cell_body_t in 'inp'.
361 size_t extend1_cell_body_getlen_onionskin(const extend1_cell_body_t *inp);
362 /** Return the element at position 'idx' of the fixed array field
363 * onionskin of the extend1_cell_body_t in 'inp'.
365 uint8_t extend1_cell_body_get_onionskin(extend1_cell_body_t *inp, size_t idx);
366 /** As extend1_cell_body_get_onionskin, but take and return a const
367 * pointer
369 uint8_t extend1_cell_body_getconst_onionskin(const extend1_cell_body_t *inp, size_t idx);
370 /** Change the element at position 'idx' of the fixed array field
371 * onionskin of the extend1_cell_body_t in 'inp', so that it will hold
372 * the value 'elt'.
374 int extend1_cell_body_set_onionskin(extend1_cell_body_t *inp, size_t idx, uint8_t elt);
375 /** Return a pointer to the 186-element array field onionskin of
376 * 'inp'.
378 uint8_t * extend1_cell_body_getarray_onionskin(extend1_cell_body_t *inp);
379 /** As extend1_cell_body_get_onionskin, but take and return a const
380 * pointer
382 const uint8_t * extend1_cell_body_getconstarray_onionskin(const extend1_cell_body_t *inp);
383 /** Return the (constant) length of the array holding the identity
384 * field of the extend1_cell_body_t in 'inp'.
386 size_t extend1_cell_body_getlen_identity(const extend1_cell_body_t *inp);
387 /** Return the element at position 'idx' of the fixed array field
388 * identity of the extend1_cell_body_t in 'inp'.
390 uint8_t extend1_cell_body_get_identity(extend1_cell_body_t *inp, size_t idx);
391 /** As extend1_cell_body_get_identity, but take and return a const
392 * pointer
394 uint8_t extend1_cell_body_getconst_identity(const extend1_cell_body_t *inp, size_t idx);
395 /** Change the element at position 'idx' of the fixed array field
396 * identity of the extend1_cell_body_t in 'inp', so that it will hold
397 * the value 'elt'.
399 int extend1_cell_body_set_identity(extend1_cell_body_t *inp, size_t idx, uint8_t elt);
400 /** Return a pointer to the 20-element array field identity of 'inp'.
402 uint8_t * extend1_cell_body_getarray_identity(extend1_cell_body_t *inp);
403 /** As extend1_cell_body_get_identity, but take and return a const
404 * pointer
406 const uint8_t * extend1_cell_body_getconstarray_identity(const extend1_cell_body_t *inp);
407 /** Return a newly allocated link_specifier with all elements set to
408 * zero.
410 link_specifier_t *link_specifier_new(void);
411 /** Release all storage held by the link_specifier in 'victim'. (Do
412 * nothing if 'victim' is NULL.)
414 void link_specifier_free(link_specifier_t *victim);
415 /** Try to parse a link_specifier from the buffer in 'input', using up
416 * to 'len_in' bytes from the input buffer. On success, return the
417 * number of bytes consumed and set *output to the newly allocated
418 * link_specifier_t. On failure, return -2 if the input appears
419 * truncated, and -1 if the input is otherwise invalid.
421 ssize_t link_specifier_parse(link_specifier_t **output, const uint8_t *input, const size_t len_in);
422 /** Return the number of bytes we expect to need to encode the
423 * link_specifier in 'obj'. On failure, return a negative value. Note
424 * that this value may be an overestimate, and can even be an
425 * underestimate for certain unencodeable objects.
427 ssize_t link_specifier_encoded_len(const link_specifier_t *obj);
428 /** Try to encode the link_specifier from 'input' into the buffer at
429 * 'output', using up to 'avail' bytes of the output buffer. On
430 * success, return the number of bytes used. On failure, return -2 if
431 * the buffer was not long enough, and -1 if the input was invalid.
433 ssize_t link_specifier_encode(uint8_t *output, size_t avail, const link_specifier_t *input);
434 /** Check whether the internal state of the link_specifier in 'obj' is
435 * consistent. Return NULL if it is, and a short message if it is not.
437 const char *link_specifier_check(const link_specifier_t *obj);
438 /** Clear any errors that were set on the object 'obj' by its setter
439 * functions. Return true iff errors were cleared.
441 int link_specifier_clear_errors(link_specifier_t *obj);
442 /** Return the value of the ls_type field of the link_specifier_t in
443 * 'inp'
445 uint8_t link_specifier_get_ls_type(const link_specifier_t *inp);
446 /** Set the value of the ls_type field of the link_specifier_t in
447 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
448 * code on 'inp' on failure.
450 int link_specifier_set_ls_type(link_specifier_t *inp, uint8_t val);
451 /** Return the value of the ls_len field of the link_specifier_t in
452 * 'inp'
454 uint8_t link_specifier_get_ls_len(const link_specifier_t *inp);
455 /** Set the value of the ls_len field of the link_specifier_t in 'inp'
456 * to 'val'. Return 0 on success; return -1 and set the error code on
457 * 'inp' on failure.
459 int link_specifier_set_ls_len(link_specifier_t *inp, uint8_t val);
460 /** Return the value of the un_ipv4_addr field of the link_specifier_t
461 * in 'inp'
463 uint32_t link_specifier_get_un_ipv4_addr(const link_specifier_t *inp);
464 /** Set the value of the un_ipv4_addr field of the link_specifier_t in
465 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
466 * code on 'inp' on failure.
468 int link_specifier_set_un_ipv4_addr(link_specifier_t *inp, uint32_t val);
469 /** Return the value of the un_ipv4_port field of the link_specifier_t
470 * in 'inp'
472 uint16_t link_specifier_get_un_ipv4_port(const link_specifier_t *inp);
473 /** Set the value of the un_ipv4_port field of the link_specifier_t in
474 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
475 * code on 'inp' on failure.
477 int link_specifier_set_un_ipv4_port(link_specifier_t *inp, uint16_t val);
478 /** Return the (constant) length of the array holding the un_ipv6_addr
479 * field of the link_specifier_t in 'inp'.
481 size_t link_specifier_getlen_un_ipv6_addr(const link_specifier_t *inp);
482 /** Return the element at position 'idx' of the fixed array field
483 * un_ipv6_addr of the link_specifier_t in 'inp'.
485 uint8_t link_specifier_get_un_ipv6_addr(link_specifier_t *inp, size_t idx);
486 /** As link_specifier_get_un_ipv6_addr, but take and return a const
487 * pointer
489 uint8_t link_specifier_getconst_un_ipv6_addr(const link_specifier_t *inp, size_t idx);
490 /** Change the element at position 'idx' of the fixed array field
491 * un_ipv6_addr of the link_specifier_t in 'inp', so that it will hold
492 * the value 'elt'.
494 int link_specifier_set_un_ipv6_addr(link_specifier_t *inp, size_t idx, uint8_t elt);
495 /** Return a pointer to the 16-element array field un_ipv6_addr of
496 * 'inp'.
498 uint8_t * link_specifier_getarray_un_ipv6_addr(link_specifier_t *inp);
499 /** As link_specifier_get_un_ipv6_addr, but take and return a const
500 * pointer
502 const uint8_t * link_specifier_getconstarray_un_ipv6_addr(const link_specifier_t *inp);
503 /** Return the value of the un_ipv6_port field of the link_specifier_t
504 * in 'inp'
506 uint16_t link_specifier_get_un_ipv6_port(const link_specifier_t *inp);
507 /** Set the value of the un_ipv6_port field of the link_specifier_t in
508 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
509 * code on 'inp' on failure.
511 int link_specifier_set_un_ipv6_port(link_specifier_t *inp, uint16_t val);
512 /** Return the (constant) length of the array holding the un_legacy_id
513 * field of the link_specifier_t in 'inp'.
515 size_t link_specifier_getlen_un_legacy_id(const link_specifier_t *inp);
516 /** Return the element at position 'idx' of the fixed array field
517 * un_legacy_id of the link_specifier_t in 'inp'.
519 uint8_t link_specifier_get_un_legacy_id(link_specifier_t *inp, size_t idx);
520 /** As link_specifier_get_un_legacy_id, but take and return a const
521 * pointer
523 uint8_t link_specifier_getconst_un_legacy_id(const link_specifier_t *inp, size_t idx);
524 /** Change the element at position 'idx' of the fixed array field
525 * un_legacy_id of the link_specifier_t in 'inp', so that it will hold
526 * the value 'elt'.
528 int link_specifier_set_un_legacy_id(link_specifier_t *inp, size_t idx, uint8_t elt);
529 /** Return a pointer to the 20-element array field un_legacy_id of
530 * 'inp'.
532 uint8_t * link_specifier_getarray_un_legacy_id(link_specifier_t *inp);
533 /** As link_specifier_get_un_legacy_id, but take and return a const
534 * pointer
536 const uint8_t * link_specifier_getconstarray_un_legacy_id(const link_specifier_t *inp);
537 /** Return the (constant) length of the array holding the
538 * un_ed25519_id field of the link_specifier_t in 'inp'.
540 size_t link_specifier_getlen_un_ed25519_id(const link_specifier_t *inp);
541 /** Return the element at position 'idx' of the fixed array field
542 * un_ed25519_id of the link_specifier_t in 'inp'.
544 uint8_t link_specifier_get_un_ed25519_id(link_specifier_t *inp, size_t idx);
545 /** As link_specifier_get_un_ed25519_id, but take and return a const
546 * pointer
548 uint8_t link_specifier_getconst_un_ed25519_id(const link_specifier_t *inp, size_t idx);
549 /** Change the element at position 'idx' of the fixed array field
550 * un_ed25519_id of the link_specifier_t in 'inp', so that it will
551 * hold the value 'elt'.
553 int link_specifier_set_un_ed25519_id(link_specifier_t *inp, size_t idx, uint8_t elt);
554 /** Return a pointer to the 32-element array field un_ed25519_id of
555 * 'inp'.
557 uint8_t * link_specifier_getarray_un_ed25519_id(link_specifier_t *inp);
558 /** As link_specifier_get_un_ed25519_id, but take and return a const
559 * pointer
561 const uint8_t * link_specifier_getconstarray_un_ed25519_id(const link_specifier_t *inp);
562 /** Return the length of the dynamic array holding the un_unrecognized
563 * field of the link_specifier_t in 'inp'.
565 size_t link_specifier_getlen_un_unrecognized(const link_specifier_t *inp);
566 /** Return the element at position 'idx' of the dynamic array field
567 * un_unrecognized of the link_specifier_t in 'inp'.
569 uint8_t link_specifier_get_un_unrecognized(link_specifier_t *inp, size_t idx);
570 /** As link_specifier_get_un_unrecognized, but take and return a const
571 * pointer
573 uint8_t link_specifier_getconst_un_unrecognized(const link_specifier_t *inp, size_t idx);
574 /** Change the element at position 'idx' of the dynamic array field
575 * un_unrecognized of the link_specifier_t in 'inp', so that it will
576 * hold the value 'elt'.
578 int link_specifier_set_un_unrecognized(link_specifier_t *inp, size_t idx, uint8_t elt);
579 /** Append a new element 'elt' to the dynamic array field
580 * un_unrecognized of the link_specifier_t in 'inp'.
582 int link_specifier_add_un_unrecognized(link_specifier_t *inp, uint8_t elt);
583 /** Return a pointer to the variable-length array field
584 * un_unrecognized of 'inp'.
586 uint8_t * link_specifier_getarray_un_unrecognized(link_specifier_t *inp);
587 /** As link_specifier_get_un_unrecognized, but take and return a const
588 * pointer
590 const uint8_t * link_specifier_getconstarray_un_unrecognized(const link_specifier_t *inp);
591 /** Change the length of the variable-length array field
592 * un_unrecognized of 'inp' to 'newlen'.Fill extra elements with 0.
593 * Return 0 on success; return -1 and set the error code on 'inp' on
594 * failure.
596 int link_specifier_setlen_un_unrecognized(link_specifier_t *inp, size_t newlen);
597 /** Return a newly allocated ed25519_cert with all elements set to
598 * zero.
600 ed25519_cert_t *ed25519_cert_new(void);
601 /** Release all storage held by the ed25519_cert in 'victim'. (Do
602 * nothing if 'victim' is NULL.)
604 void ed25519_cert_free(ed25519_cert_t *victim);
605 /** Try to parse a ed25519_cert from the buffer in 'input', using up
606 * to 'len_in' bytes from the input buffer. On success, return the
607 * number of bytes consumed and set *output to the newly allocated
608 * ed25519_cert_t. On failure, return -2 if the input appears
609 * truncated, and -1 if the input is otherwise invalid.
611 ssize_t ed25519_cert_parse(ed25519_cert_t **output, const uint8_t *input, const size_t len_in);
612 /** Return the number of bytes we expect to need to encode the
613 * ed25519_cert in 'obj'. On failure, return a negative value. Note
614 * that this value may be an overestimate, and can even be an
615 * underestimate for certain unencodeable objects.
617 ssize_t ed25519_cert_encoded_len(const ed25519_cert_t *obj);
618 /** Try to encode the ed25519_cert from 'input' into the buffer at
619 * 'output', using up to 'avail' bytes of the output buffer. On
620 * success, return the number of bytes used. On failure, return -2 if
621 * the buffer was not long enough, and -1 if the input was invalid.
623 ssize_t ed25519_cert_encode(uint8_t *output, size_t avail, const ed25519_cert_t *input);
624 /** Check whether the internal state of the ed25519_cert in 'obj' is
625 * consistent. Return NULL if it is, and a short message if it is not.
627 const char *ed25519_cert_check(const ed25519_cert_t *obj);
628 /** Clear any errors that were set on the object 'obj' by its setter
629 * functions. Return true iff errors were cleared.
631 int ed25519_cert_clear_errors(ed25519_cert_t *obj);
632 /** Return the value of the version field of the ed25519_cert_t in
633 * 'inp'
635 uint8_t ed25519_cert_get_version(const ed25519_cert_t *inp);
636 /** Set the value of the version field of the ed25519_cert_t in 'inp'
637 * to 'val'. Return 0 on success; return -1 and set the error code on
638 * 'inp' on failure.
640 int ed25519_cert_set_version(ed25519_cert_t *inp, uint8_t val);
641 /** Return the value of the cert_type field of the ed25519_cert_t in
642 * 'inp'
644 uint8_t ed25519_cert_get_cert_type(const ed25519_cert_t *inp);
645 /** Set the value of the cert_type field of the ed25519_cert_t in
646 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
647 * code on 'inp' on failure.
649 int ed25519_cert_set_cert_type(ed25519_cert_t *inp, uint8_t val);
650 /** Return the value of the exp_field field of the ed25519_cert_t in
651 * 'inp'
653 uint32_t ed25519_cert_get_exp_field(const ed25519_cert_t *inp);
654 /** Set the value of the exp_field field of the ed25519_cert_t in
655 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
656 * code on 'inp' on failure.
658 int ed25519_cert_set_exp_field(ed25519_cert_t *inp, uint32_t val);
659 /** Return the value of the cert_key_type field of the ed25519_cert_t
660 * in 'inp'
662 uint8_t ed25519_cert_get_cert_key_type(const ed25519_cert_t *inp);
663 /** Set the value of the cert_key_type field of the ed25519_cert_t in
664 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
665 * code on 'inp' on failure.
667 int ed25519_cert_set_cert_key_type(ed25519_cert_t *inp, uint8_t val);
668 /** Return the (constant) length of the array holding the
669 * certified_key field of the ed25519_cert_t in 'inp'.
671 size_t ed25519_cert_getlen_certified_key(const ed25519_cert_t *inp);
672 /** Return the element at position 'idx' of the fixed array field
673 * certified_key of the ed25519_cert_t in 'inp'.
675 uint8_t ed25519_cert_get_certified_key(ed25519_cert_t *inp, size_t idx);
676 /** As ed25519_cert_get_certified_key, but take and return a const
677 * pointer
679 uint8_t ed25519_cert_getconst_certified_key(const ed25519_cert_t *inp, size_t idx);
680 /** Change the element at position 'idx' of the fixed array field
681 * certified_key of the ed25519_cert_t in 'inp', so that it will hold
682 * the value 'elt'.
684 int ed25519_cert_set_certified_key(ed25519_cert_t *inp, size_t idx, uint8_t elt);
685 /** Return a pointer to the 32-element array field certified_key of
686 * 'inp'.
688 uint8_t * ed25519_cert_getarray_certified_key(ed25519_cert_t *inp);
689 /** As ed25519_cert_get_certified_key, but take and return a const
690 * pointer
692 const uint8_t * ed25519_cert_getconstarray_certified_key(const ed25519_cert_t *inp);
693 /** Return the value of the n_extensions field of the ed25519_cert_t
694 * in 'inp'
696 uint8_t ed25519_cert_get_n_extensions(const ed25519_cert_t *inp);
697 /** Set the value of the n_extensions field of the ed25519_cert_t in
698 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
699 * code on 'inp' on failure.
701 int ed25519_cert_set_n_extensions(ed25519_cert_t *inp, uint8_t val);
702 /** Return the length of the dynamic array holding the ext field of
703 * the ed25519_cert_t in 'inp'.
705 size_t ed25519_cert_getlen_ext(const ed25519_cert_t *inp);
706 /** Return the element at position 'idx' of the dynamic array field
707 * ext of the ed25519_cert_t in 'inp'.
709 struct ed25519_cert_extension_st * ed25519_cert_get_ext(ed25519_cert_t *inp, size_t idx);
710 /** As ed25519_cert_get_ext, but take and return a const pointer
712 const struct ed25519_cert_extension_st * ed25519_cert_getconst_ext(const ed25519_cert_t *inp, size_t idx);
713 /** Change the element at position 'idx' of the dynamic array field
714 * ext of the ed25519_cert_t in 'inp', so that it will hold the value
715 * 'elt'. Free the previous value, if any.
717 int ed25519_cert_set_ext(ed25519_cert_t *inp, size_t idx, struct ed25519_cert_extension_st * elt);
718 /** As ed25519_cert_set_ext, but does not free the previous value.
720 int ed25519_cert_set0_ext(ed25519_cert_t *inp, size_t idx, struct ed25519_cert_extension_st * elt);
721 /** Append a new element 'elt' to the dynamic array field ext of the
722 * ed25519_cert_t in 'inp'.
724 int ed25519_cert_add_ext(ed25519_cert_t *inp, struct ed25519_cert_extension_st * elt);
725 /** Return a pointer to the variable-length array field ext of 'inp'.
727 struct ed25519_cert_extension_st * * ed25519_cert_getarray_ext(ed25519_cert_t *inp);
728 /** As ed25519_cert_get_ext, but take and return a const pointer
730 const struct ed25519_cert_extension_st * const * ed25519_cert_getconstarray_ext(const ed25519_cert_t *inp);
731 /** Change the length of the variable-length array field ext of 'inp'
732 * to 'newlen'.Fill extra elements with NULL; free removed elements.
733 * Return 0 on success; return -1 and set the error code on 'inp' on
734 * failure.
736 int ed25519_cert_setlen_ext(ed25519_cert_t *inp, size_t newlen);
737 /** Return the (constant) length of the array holding the signature
738 * field of the ed25519_cert_t in 'inp'.
740 size_t ed25519_cert_getlen_signature(const ed25519_cert_t *inp);
741 /** Return the element at position 'idx' of the fixed array field
742 * signature of the ed25519_cert_t in 'inp'.
744 uint8_t ed25519_cert_get_signature(ed25519_cert_t *inp, size_t idx);
745 /** As ed25519_cert_get_signature, but take and return a const pointer
747 uint8_t ed25519_cert_getconst_signature(const ed25519_cert_t *inp, size_t idx);
748 /** Change the element at position 'idx' of the fixed array field
749 * signature of the ed25519_cert_t in 'inp', so that it will hold the
750 * value 'elt'.
752 int ed25519_cert_set_signature(ed25519_cert_t *inp, size_t idx, uint8_t elt);
753 /** Return a pointer to the 64-element array field signature of 'inp'.
755 uint8_t * ed25519_cert_getarray_signature(ed25519_cert_t *inp);
756 /** As ed25519_cert_get_signature, but take and return a const pointer
758 const uint8_t * ed25519_cert_getconstarray_signature(const ed25519_cert_t *inp);
759 /** Return a newly allocated extend2_cell_body with all elements set
760 * to zero.
762 extend2_cell_body_t *extend2_cell_body_new(void);
763 /** Release all storage held by the extend2_cell_body in 'victim'. (Do
764 * nothing if 'victim' is NULL.)
766 void extend2_cell_body_free(extend2_cell_body_t *victim);
767 /** Try to parse a extend2_cell_body from the buffer in 'input', using
768 * up to 'len_in' bytes from the input buffer. On success, return the
769 * number of bytes consumed and set *output to the newly allocated
770 * extend2_cell_body_t. On failure, return -2 if the input appears
771 * truncated, and -1 if the input is otherwise invalid.
773 ssize_t extend2_cell_body_parse(extend2_cell_body_t **output, const uint8_t *input, const size_t len_in);
774 /** Return the number of bytes we expect to need to encode the
775 * extend2_cell_body in 'obj'. On failure, return a negative value.
776 * Note that this value may be an overestimate, and can even be an
777 * underestimate for certain unencodeable objects.
779 ssize_t extend2_cell_body_encoded_len(const extend2_cell_body_t *obj);
780 /** Try to encode the extend2_cell_body from 'input' into the buffer
781 * at 'output', using up to 'avail' bytes of the output buffer. On
782 * success, return the number of bytes used. On failure, return -2 if
783 * the buffer was not long enough, and -1 if the input was invalid.
785 ssize_t extend2_cell_body_encode(uint8_t *output, size_t avail, const extend2_cell_body_t *input);
786 /** Check whether the internal state of the extend2_cell_body in 'obj'
787 * is consistent. Return NULL if it is, and a short message if it is
788 * not.
790 const char *extend2_cell_body_check(const extend2_cell_body_t *obj);
791 /** Clear any errors that were set on the object 'obj' by its setter
792 * functions. Return true iff errors were cleared.
794 int extend2_cell_body_clear_errors(extend2_cell_body_t *obj);
795 /** Return the value of the n_spec field of the extend2_cell_body_t in
796 * 'inp'
798 uint8_t extend2_cell_body_get_n_spec(const extend2_cell_body_t *inp);
799 /** Set the value of the n_spec field of the extend2_cell_body_t in
800 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
801 * code on 'inp' on failure.
803 int extend2_cell_body_set_n_spec(extend2_cell_body_t *inp, uint8_t val);
804 /** Return the length of the dynamic array holding the ls field of the
805 * extend2_cell_body_t in 'inp'.
807 size_t extend2_cell_body_getlen_ls(const extend2_cell_body_t *inp);
808 /** Return the element at position 'idx' of the dynamic array field ls
809 * of the extend2_cell_body_t in 'inp'.
811 struct link_specifier_st * extend2_cell_body_get_ls(extend2_cell_body_t *inp, size_t idx);
812 /** As extend2_cell_body_get_ls, but take and return a const pointer
814 const struct link_specifier_st * extend2_cell_body_getconst_ls(const extend2_cell_body_t *inp, size_t idx);
815 /** Change the element at position 'idx' of the dynamic array field ls
816 * of the extend2_cell_body_t in 'inp', so that it will hold the value
817 * 'elt'. Free the previous value, if any.
819 int extend2_cell_body_set_ls(extend2_cell_body_t *inp, size_t idx, struct link_specifier_st * elt);
820 /** As extend2_cell_body_set_ls, but does not free the previous value.
822 int extend2_cell_body_set0_ls(extend2_cell_body_t *inp, size_t idx, struct link_specifier_st * elt);
823 /** Append a new element 'elt' to the dynamic array field ls of the
824 * extend2_cell_body_t in 'inp'.
826 int extend2_cell_body_add_ls(extend2_cell_body_t *inp, struct link_specifier_st * elt);
827 /** Return a pointer to the variable-length array field ls of 'inp'.
829 struct link_specifier_st * * extend2_cell_body_getarray_ls(extend2_cell_body_t *inp);
830 /** As extend2_cell_body_get_ls, but take and return a const pointer
832 const struct link_specifier_st * const * extend2_cell_body_getconstarray_ls(const extend2_cell_body_t *inp);
833 /** Change the length of the variable-length array field ls of 'inp'
834 * to 'newlen'.Fill extra elements with NULL; free removed elements.
835 * Return 0 on success; return -1 and set the error code on 'inp' on
836 * failure.
838 int extend2_cell_body_setlen_ls(extend2_cell_body_t *inp, size_t newlen);
839 /** Return the value of the create2 field of the extend2_cell_body_t
840 * in 'inp'
842 struct create2_cell_body_st * extend2_cell_body_get_create2(extend2_cell_body_t *inp);
843 /** As extend2_cell_body_get_create2, but take and return a const
844 * pointer
846 const struct create2_cell_body_st * extend2_cell_body_getconst_create2(const extend2_cell_body_t *inp);
847 /** Set the value of the create2 field of the extend2_cell_body_t in
848 * 'inp' to 'val'. Free the old value if any. Steals the referenceto
849 * 'val'.Return 0 on success; return -1 and set the error code on
850 * 'inp' on failure.
852 int extend2_cell_body_set_create2(extend2_cell_body_t *inp, struct create2_cell_body_st *val);
853 /** As extend2_cell_body_set_create2, but does not free the previous
854 * value.
856 int extend2_cell_body_set0_create2(extend2_cell_body_t *inp, struct create2_cell_body_st *val);
857 /** Return a newly allocated link_specifier_list with all elements set
858 * to zero.
860 link_specifier_list_t *link_specifier_list_new(void);
861 /** Release all storage held by the link_specifier_list in 'victim'.
862 * (Do nothing if 'victim' is NULL.)
864 void link_specifier_list_free(link_specifier_list_t *victim);
865 /** Try to parse a link_specifier_list from the buffer in 'input',
866 * using up to 'len_in' bytes from the input buffer. On success,
867 * return the number of bytes consumed and set *output to the newly
868 * allocated link_specifier_list_t. On failure, return -2 if the input
869 * appears truncated, and -1 if the input is otherwise invalid.
871 ssize_t link_specifier_list_parse(link_specifier_list_t **output, const uint8_t *input, const size_t len_in);
872 /** Return the number of bytes we expect to need to encode the
873 * link_specifier_list in 'obj'. On failure, return a negative value.
874 * Note that this value may be an overestimate, and can even be an
875 * underestimate for certain unencodeable objects.
877 ssize_t link_specifier_list_encoded_len(const link_specifier_list_t *obj);
878 /** Try to encode the link_specifier_list from 'input' into the buffer
879 * at 'output', using up to 'avail' bytes of the output buffer. On
880 * success, return the number of bytes used. On failure, return -2 if
881 * the buffer was not long enough, and -1 if the input was invalid.
883 ssize_t link_specifier_list_encode(uint8_t *output, size_t avail, const link_specifier_list_t *input);
884 /** Check whether the internal state of the link_specifier_list in
885 * 'obj' is consistent. Return NULL if it is, and a short message if
886 * it is not.
888 const char *link_specifier_list_check(const link_specifier_list_t *obj);
889 /** Clear any errors that were set on the object 'obj' by its setter
890 * functions. Return true iff errors were cleared.
892 int link_specifier_list_clear_errors(link_specifier_list_t *obj);
893 /** Return the value of the n_spec field of the link_specifier_list_t
894 * in 'inp'
896 uint8_t link_specifier_list_get_n_spec(const link_specifier_list_t *inp);
897 /** Set the value of the n_spec field of the link_specifier_list_t in
898 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
899 * code on 'inp' on failure.
901 int link_specifier_list_set_n_spec(link_specifier_list_t *inp, uint8_t val);
902 /** Return the length of the dynamic array holding the spec field of
903 * the link_specifier_list_t in 'inp'.
905 size_t link_specifier_list_getlen_spec(const link_specifier_list_t *inp);
906 /** Return the element at position 'idx' of the dynamic array field
907 * spec of the link_specifier_list_t in 'inp'.
909 struct link_specifier_st * link_specifier_list_get_spec(link_specifier_list_t *inp, size_t idx);
910 /** As link_specifier_list_get_spec, but take and return a const
911 * pointer
913 const struct link_specifier_st * link_specifier_list_getconst_spec(const link_specifier_list_t *inp, size_t idx);
914 /** Change the element at position 'idx' of the dynamic array field
915 * spec of the link_specifier_list_t in 'inp', so that it will hold
916 * the value 'elt'. Free the previous value, if any.
918 int link_specifier_list_set_spec(link_specifier_list_t *inp, size_t idx, struct link_specifier_st * elt);
919 /** As link_specifier_list_set_spec, but does not free the previous
920 * value.
922 int link_specifier_list_set0_spec(link_specifier_list_t *inp, size_t idx, struct link_specifier_st * elt);
923 /** Append a new element 'elt' to the dynamic array field spec of the
924 * link_specifier_list_t in 'inp'.
926 int link_specifier_list_add_spec(link_specifier_list_t *inp, struct link_specifier_st * elt);
927 /** Return a pointer to the variable-length array field spec of 'inp'.
929 struct link_specifier_st * * link_specifier_list_getarray_spec(link_specifier_list_t *inp);
930 /** As link_specifier_list_get_spec, but take and return a const
931 * pointer
933 const struct link_specifier_st * const * link_specifier_list_getconstarray_spec(const link_specifier_list_t *inp);
934 /** Change the length of the variable-length array field spec of 'inp'
935 * to 'newlen'.Fill extra elements with NULL; free removed elements.
936 * Return 0 on success; return -1 and set the error code on 'inp' on
937 * failure.
939 int link_specifier_list_setlen_spec(link_specifier_list_t *inp, size_t newlen);
942 #endif