Merge branch 'bug29693_040_radical_squashed' into maint-0.4.0
[tor.git] / src / trunnel / link_handshake.h
blob6a23483adcb1311c6f6ecef3a10573f777526e5b
1 /* link_handshake.h -- generated by Trunnel v1.5.2.
2 * https://gitweb.torproject.org/trunnel.git
3 * You probably shouldn't edit this file.
4 */
5 #ifndef TRUNNEL_LINK_HANDSHAKE_H
6 #define TRUNNEL_LINK_HANDSHAKE_H
8 #include <stdint.h>
9 #include "trunnel.h"
11 #define CERTTYPE_RSA1024_ID_LINK 1
12 #define CERTTYPE_RSA1024_ID_ID 2
13 #define CERTTYPE_RSA1024_ID_AUTH 3
14 #define CERTTYPE_ED_ID_SIGN 4
15 #define CERTTYPE_ED_SIGN_LINK 5
16 #define CERTTYPE_ED_SIGN_AUTH 6
17 #define CERTTYPE_RSA1024_ID_EDID 7
18 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_AUTH_CHALLENGE_CELL)
19 struct auth_challenge_cell_st {
20 uint8_t challenge[32];
21 uint16_t n_methods;
22 TRUNNEL_DYNARRAY_HEAD(, uint16_t) methods;
23 uint8_t trunnel_error_code_;
25 #endif
26 typedef struct auth_challenge_cell_st auth_challenge_cell_t;
27 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_AUTH_CTX)
28 struct auth_ctx_st {
29 uint8_t is_ed;
30 uint8_t trunnel_error_code_;
32 #endif
33 typedef struct auth_ctx_st auth_ctx_t;
34 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CERTS_CELL_CERT)
35 struct certs_cell_cert_st {
36 uint8_t cert_type;
37 uint16_t cert_len;
38 TRUNNEL_DYNARRAY_HEAD(, uint8_t) body;
39 uint8_t trunnel_error_code_;
41 #endif
42 typedef struct certs_cell_cert_st certs_cell_cert_t;
43 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_RSA_ED_CROSSCERT)
44 struct rsa_ed_crosscert_st {
45 uint8_t ed_key[32];
46 uint32_t expiration;
47 const uint8_t *end_of_signed;
48 uint8_t sig_len;
49 TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
50 uint8_t trunnel_error_code_;
52 #endif
53 typedef struct rsa_ed_crosscert_st rsa_ed_crosscert_t;
54 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_AUTH1)
55 struct auth1_st {
56 uint8_t type[8];
57 uint8_t cid[32];
58 uint8_t sid[32];
59 uint8_t u1_cid_ed[32];
60 uint8_t u1_sid_ed[32];
61 uint8_t slog[32];
62 uint8_t clog[32];
63 uint8_t scert[32];
64 uint8_t tlssecrets[32];
65 const uint8_t *end_of_fixed_part;
66 uint8_t rand[24];
67 const uint8_t *end_of_signed;
68 TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
69 uint8_t trunnel_error_code_;
71 #endif
72 typedef struct auth1_st auth1_t;
73 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CERTS_CELL)
74 struct certs_cell_st {
75 uint8_t n_certs;
76 TRUNNEL_DYNARRAY_HEAD(, struct certs_cell_cert_st *) certs;
77 uint8_t trunnel_error_code_;
79 #endif
80 typedef struct certs_cell_st certs_cell_t;
81 /** Return a newly allocated auth_challenge_cell with all elements set
82 * to zero.
84 auth_challenge_cell_t *auth_challenge_cell_new(void);
85 /** Release all storage held by the auth_challenge_cell in 'victim'.
86 * (Do nothing if 'victim' is NULL.)
88 void auth_challenge_cell_free(auth_challenge_cell_t *victim);
89 /** Try to parse a auth_challenge_cell from the buffer in 'input',
90 * using up to 'len_in' bytes from the input buffer. On success,
91 * return the number of bytes consumed and set *output to the newly
92 * allocated auth_challenge_cell_t. On failure, return -2 if the input
93 * appears truncated, and -1 if the input is otherwise invalid.
95 ssize_t auth_challenge_cell_parse(auth_challenge_cell_t **output, const uint8_t *input, const size_t len_in);
96 /** Return the number of bytes we expect to need to encode the
97 * auth_challenge_cell in 'obj'. On failure, return a negative value.
98 * Note that this value may be an overestimate, and can even be an
99 * underestimate for certain unencodeable objects.
101 ssize_t auth_challenge_cell_encoded_len(const auth_challenge_cell_t *obj);
102 /** Try to encode the auth_challenge_cell from 'input' into the buffer
103 * at 'output', using up to 'avail' bytes of the output buffer. On
104 * success, return the number of bytes used. On failure, return -2 if
105 * the buffer was not long enough, and -1 if the input was invalid.
107 ssize_t auth_challenge_cell_encode(uint8_t *output, size_t avail, const auth_challenge_cell_t *input);
108 /** Check whether the internal state of the auth_challenge_cell in
109 * 'obj' is consistent. Return NULL if it is, and a short message if
110 * it is not.
112 const char *auth_challenge_cell_check(const auth_challenge_cell_t *obj);
113 /** Clear any errors that were set on the object 'obj' by its setter
114 * functions. Return true iff errors were cleared.
116 int auth_challenge_cell_clear_errors(auth_challenge_cell_t *obj);
117 /** Return the (constant) length of the array holding the challenge
118 * field of the auth_challenge_cell_t in 'inp'.
120 size_t auth_challenge_cell_getlen_challenge(const auth_challenge_cell_t *inp);
121 /** Return the element at position 'idx' of the fixed array field
122 * challenge of the auth_challenge_cell_t in 'inp'.
124 uint8_t auth_challenge_cell_get_challenge(auth_challenge_cell_t *inp, size_t idx);
125 /** As auth_challenge_cell_get_challenge, but take and return a const
126 * pointer
128 uint8_t auth_challenge_cell_getconst_challenge(const auth_challenge_cell_t *inp, size_t idx);
129 /** Change the element at position 'idx' of the fixed array field
130 * challenge of the auth_challenge_cell_t in 'inp', so that it will
131 * hold the value 'elt'.
133 int auth_challenge_cell_set_challenge(auth_challenge_cell_t *inp, size_t idx, uint8_t elt);
134 /** Return a pointer to the 32-element array field challenge of 'inp'.
136 uint8_t * auth_challenge_cell_getarray_challenge(auth_challenge_cell_t *inp);
137 /** As auth_challenge_cell_get_challenge, but take and return a const
138 * pointer
140 const uint8_t * auth_challenge_cell_getconstarray_challenge(const auth_challenge_cell_t *inp);
141 /** Return the value of the n_methods field of the
142 * auth_challenge_cell_t in 'inp'
144 uint16_t auth_challenge_cell_get_n_methods(const auth_challenge_cell_t *inp);
145 /** Set the value of the n_methods field of the auth_challenge_cell_t
146 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
147 * code on 'inp' on failure.
149 int auth_challenge_cell_set_n_methods(auth_challenge_cell_t *inp, uint16_t val);
150 /** Return the length of the dynamic array holding the methods field
151 * of the auth_challenge_cell_t in 'inp'.
153 size_t auth_challenge_cell_getlen_methods(const auth_challenge_cell_t *inp);
154 /** Return the element at position 'idx' of the dynamic array field
155 * methods of the auth_challenge_cell_t in 'inp'.
157 uint16_t auth_challenge_cell_get_methods(auth_challenge_cell_t *inp, size_t idx);
158 /** As auth_challenge_cell_get_methods, but take and return a const
159 * pointer
161 uint16_t auth_challenge_cell_getconst_methods(const auth_challenge_cell_t *inp, size_t idx);
162 /** Change the element at position 'idx' of the dynamic array field
163 * methods of the auth_challenge_cell_t in 'inp', so that it will hold
164 * the value 'elt'.
166 int auth_challenge_cell_set_methods(auth_challenge_cell_t *inp, size_t idx, uint16_t elt);
167 /** Append a new element 'elt' to the dynamic array field methods of
168 * the auth_challenge_cell_t in 'inp'.
170 int auth_challenge_cell_add_methods(auth_challenge_cell_t *inp, uint16_t elt);
171 /** Return a pointer to the variable-length array field methods of
172 * 'inp'.
174 uint16_t * auth_challenge_cell_getarray_methods(auth_challenge_cell_t *inp);
175 /** As auth_challenge_cell_get_methods, but take and return a const
176 * pointer
178 const uint16_t * auth_challenge_cell_getconstarray_methods(const auth_challenge_cell_t *inp);
179 /** Change the length of the variable-length array field methods of
180 * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
181 * return -1 and set the error code on 'inp' on failure.
183 int auth_challenge_cell_setlen_methods(auth_challenge_cell_t *inp, size_t newlen);
184 /** Return a newly allocated auth_ctx with all elements set to zero.
186 auth_ctx_t *auth_ctx_new(void);
187 /** Release all storage held by the auth_ctx in 'victim'. (Do nothing
188 * if 'victim' is NULL.)
190 void auth_ctx_free(auth_ctx_t *victim);
191 /** Return the value of the is_ed field of the auth_ctx_t in 'inp'
193 uint8_t auth_ctx_get_is_ed(const auth_ctx_t *inp);
194 /** Set the value of the is_ed field of the auth_ctx_t in 'inp' to
195 * 'val'. Return 0 on success; return -1 and set the error code on
196 * 'inp' on failure.
198 int auth_ctx_set_is_ed(auth_ctx_t *inp, uint8_t val);
199 /** Return a newly allocated certs_cell_cert with all elements set to
200 * zero.
202 certs_cell_cert_t *certs_cell_cert_new(void);
203 /** Release all storage held by the certs_cell_cert in 'victim'. (Do
204 * nothing if 'victim' is NULL.)
206 void certs_cell_cert_free(certs_cell_cert_t *victim);
207 /** Try to parse a certs_cell_cert from the buffer in 'input', using
208 * up to 'len_in' bytes from the input buffer. On success, return the
209 * number of bytes consumed and set *output to the newly allocated
210 * certs_cell_cert_t. On failure, return -2 if the input appears
211 * truncated, and -1 if the input is otherwise invalid.
213 ssize_t certs_cell_cert_parse(certs_cell_cert_t **output, const uint8_t *input, const size_t len_in);
214 /** Return the number of bytes we expect to need to encode the
215 * certs_cell_cert in 'obj'. On failure, return a negative value. Note
216 * that this value may be an overestimate, and can even be an
217 * underestimate for certain unencodeable objects.
219 ssize_t certs_cell_cert_encoded_len(const certs_cell_cert_t *obj);
220 /** Try to encode the certs_cell_cert from 'input' into the buffer at
221 * 'output', using up to 'avail' bytes of the output buffer. On
222 * success, return the number of bytes used. On failure, return -2 if
223 * the buffer was not long enough, and -1 if the input was invalid.
225 ssize_t certs_cell_cert_encode(uint8_t *output, size_t avail, const certs_cell_cert_t *input);
226 /** Check whether the internal state of the certs_cell_cert in 'obj'
227 * is consistent. Return NULL if it is, and a short message if it is
228 * not.
230 const char *certs_cell_cert_check(const certs_cell_cert_t *obj);
231 /** Clear any errors that were set on the object 'obj' by its setter
232 * functions. Return true iff errors were cleared.
234 int certs_cell_cert_clear_errors(certs_cell_cert_t *obj);
235 /** Return the value of the cert_type field of the certs_cell_cert_t
236 * in 'inp'
238 uint8_t certs_cell_cert_get_cert_type(const certs_cell_cert_t *inp);
239 /** Set the value of the cert_type field of the certs_cell_cert_t in
240 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
241 * code on 'inp' on failure.
243 int certs_cell_cert_set_cert_type(certs_cell_cert_t *inp, uint8_t val);
244 /** Return the value of the cert_len field of the certs_cell_cert_t in
245 * 'inp'
247 uint16_t certs_cell_cert_get_cert_len(const certs_cell_cert_t *inp);
248 /** Set the value of the cert_len field of the certs_cell_cert_t in
249 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
250 * code on 'inp' on failure.
252 int certs_cell_cert_set_cert_len(certs_cell_cert_t *inp, uint16_t val);
253 /** Return the length of the dynamic array holding the body field of
254 * the certs_cell_cert_t in 'inp'.
256 size_t certs_cell_cert_getlen_body(const certs_cell_cert_t *inp);
257 /** Return the element at position 'idx' of the dynamic array field
258 * body of the certs_cell_cert_t in 'inp'.
260 uint8_t certs_cell_cert_get_body(certs_cell_cert_t *inp, size_t idx);
261 /** As certs_cell_cert_get_body, but take and return a const pointer
263 uint8_t certs_cell_cert_getconst_body(const certs_cell_cert_t *inp, size_t idx);
264 /** Change the element at position 'idx' of the dynamic array field
265 * body of the certs_cell_cert_t in 'inp', so that it will hold the
266 * value 'elt'.
268 int certs_cell_cert_set_body(certs_cell_cert_t *inp, size_t idx, uint8_t elt);
269 /** Append a new element 'elt' to the dynamic array field body of the
270 * certs_cell_cert_t in 'inp'.
272 int certs_cell_cert_add_body(certs_cell_cert_t *inp, uint8_t elt);
273 /** Return a pointer to the variable-length array field body of 'inp'.
275 uint8_t * certs_cell_cert_getarray_body(certs_cell_cert_t *inp);
276 /** As certs_cell_cert_get_body, but take and return a const pointer
278 const uint8_t * certs_cell_cert_getconstarray_body(const certs_cell_cert_t *inp);
279 /** Change the length of the variable-length array field body of 'inp'
280 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
281 * -1 and set the error code on 'inp' on failure.
283 int certs_cell_cert_setlen_body(certs_cell_cert_t *inp, size_t newlen);
284 /** Return a newly allocated rsa_ed_crosscert with all elements set to
285 * zero.
287 rsa_ed_crosscert_t *rsa_ed_crosscert_new(void);
288 /** Release all storage held by the rsa_ed_crosscert in 'victim'. (Do
289 * nothing if 'victim' is NULL.)
291 void rsa_ed_crosscert_free(rsa_ed_crosscert_t *victim);
292 /** Try to parse a rsa_ed_crosscert from the buffer in 'input', using
293 * up to 'len_in' bytes from the input buffer. On success, return the
294 * number of bytes consumed and set *output to the newly allocated
295 * rsa_ed_crosscert_t. On failure, return -2 if the input appears
296 * truncated, and -1 if the input is otherwise invalid.
298 ssize_t rsa_ed_crosscert_parse(rsa_ed_crosscert_t **output, const uint8_t *input, const size_t len_in);
299 /** Return the number of bytes we expect to need to encode the
300 * rsa_ed_crosscert in 'obj'. On failure, return a negative value.
301 * Note that this value may be an overestimate, and can even be an
302 * underestimate for certain unencodeable objects.
304 ssize_t rsa_ed_crosscert_encoded_len(const rsa_ed_crosscert_t *obj);
305 /** Try to encode the rsa_ed_crosscert from 'input' into the buffer at
306 * 'output', using up to 'avail' bytes of the output buffer. On
307 * success, return the number of bytes used. On failure, return -2 if
308 * the buffer was not long enough, and -1 if the input was invalid.
310 ssize_t rsa_ed_crosscert_encode(uint8_t *output, size_t avail, const rsa_ed_crosscert_t *input);
311 /** Check whether the internal state of the rsa_ed_crosscert in 'obj'
312 * is consistent. Return NULL if it is, and a short message if it is
313 * not.
315 const char *rsa_ed_crosscert_check(const rsa_ed_crosscert_t *obj);
316 /** Clear any errors that were set on the object 'obj' by its setter
317 * functions. Return true iff errors were cleared.
319 int rsa_ed_crosscert_clear_errors(rsa_ed_crosscert_t *obj);
320 /** Return the (constant) length of the array holding the ed_key field
321 * of the rsa_ed_crosscert_t in 'inp'.
323 size_t rsa_ed_crosscert_getlen_ed_key(const rsa_ed_crosscert_t *inp);
324 /** Return the element at position 'idx' of the fixed array field
325 * ed_key of the rsa_ed_crosscert_t in 'inp'.
327 uint8_t rsa_ed_crosscert_get_ed_key(rsa_ed_crosscert_t *inp, size_t idx);
328 /** As rsa_ed_crosscert_get_ed_key, but take and return a const
329 * pointer
331 uint8_t rsa_ed_crosscert_getconst_ed_key(const rsa_ed_crosscert_t *inp, size_t idx);
332 /** Change the element at position 'idx' of the fixed array field
333 * ed_key of the rsa_ed_crosscert_t in 'inp', so that it will hold the
334 * value 'elt'.
336 int rsa_ed_crosscert_set_ed_key(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt);
337 /** Return a pointer to the 32-element array field ed_key of 'inp'.
339 uint8_t * rsa_ed_crosscert_getarray_ed_key(rsa_ed_crosscert_t *inp);
340 /** As rsa_ed_crosscert_get_ed_key, but take and return a const
341 * pointer
343 const uint8_t * rsa_ed_crosscert_getconstarray_ed_key(const rsa_ed_crosscert_t *inp);
344 /** Return the value of the expiration field of the rsa_ed_crosscert_t
345 * in 'inp'
347 uint32_t rsa_ed_crosscert_get_expiration(const rsa_ed_crosscert_t *inp);
348 /** Set the value of the expiration field of the rsa_ed_crosscert_t in
349 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
350 * code on 'inp' on failure.
352 int rsa_ed_crosscert_set_expiration(rsa_ed_crosscert_t *inp, uint32_t val);
353 /** Return the position for end_of_signed when we parsed this object
355 const uint8_t * rsa_ed_crosscert_get_end_of_signed(const rsa_ed_crosscert_t *inp);
356 /** Return the value of the sig_len field of the rsa_ed_crosscert_t in
357 * 'inp'
359 uint8_t rsa_ed_crosscert_get_sig_len(const rsa_ed_crosscert_t *inp);
360 /** Set the value of the sig_len field of the rsa_ed_crosscert_t in
361 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
362 * code on 'inp' on failure.
364 int rsa_ed_crosscert_set_sig_len(rsa_ed_crosscert_t *inp, uint8_t val);
365 /** Return the length of the dynamic array holding the sig field of
366 * the rsa_ed_crosscert_t in 'inp'.
368 size_t rsa_ed_crosscert_getlen_sig(const rsa_ed_crosscert_t *inp);
369 /** Return the element at position 'idx' of the dynamic array field
370 * sig of the rsa_ed_crosscert_t in 'inp'.
372 uint8_t rsa_ed_crosscert_get_sig(rsa_ed_crosscert_t *inp, size_t idx);
373 /** As rsa_ed_crosscert_get_sig, but take and return a const pointer
375 uint8_t rsa_ed_crosscert_getconst_sig(const rsa_ed_crosscert_t *inp, size_t idx);
376 /** Change the element at position 'idx' of the dynamic array field
377 * sig of the rsa_ed_crosscert_t in 'inp', so that it will hold the
378 * value 'elt'.
380 int rsa_ed_crosscert_set_sig(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt);
381 /** Append a new element 'elt' to the dynamic array field sig of the
382 * rsa_ed_crosscert_t in 'inp'.
384 int rsa_ed_crosscert_add_sig(rsa_ed_crosscert_t *inp, uint8_t elt);
385 /** Return a pointer to the variable-length array field sig of 'inp'.
387 uint8_t * rsa_ed_crosscert_getarray_sig(rsa_ed_crosscert_t *inp);
388 /** As rsa_ed_crosscert_get_sig, but take and return a const pointer
390 const uint8_t * rsa_ed_crosscert_getconstarray_sig(const rsa_ed_crosscert_t *inp);
391 /** Change the length of the variable-length array field sig of 'inp'
392 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
393 * -1 and set the error code on 'inp' on failure.
395 int rsa_ed_crosscert_setlen_sig(rsa_ed_crosscert_t *inp, size_t newlen);
396 /** Return a newly allocated auth1 with all elements set to zero.
398 auth1_t *auth1_new(void);
399 /** Release all storage held by the auth1 in 'victim'. (Do nothing if
400 * 'victim' is NULL.)
402 void auth1_free(auth1_t *victim);
403 /** Try to parse a auth1 from the buffer in 'input', using up to
404 * 'len_in' bytes from the input buffer. On success, return the number
405 * of bytes consumed and set *output to the newly allocated auth1_t.
406 * On failure, return -2 if the input appears truncated, and -1 if the
407 * input is otherwise invalid.
409 ssize_t auth1_parse(auth1_t **output, const uint8_t *input, const size_t len_in, const auth_ctx_t *auth_ctx_ctx);
410 /** Return the number of bytes we expect to need to encode the auth1
411 * in 'obj'. On failure, return a negative value. Note that this value
412 * may be an overestimate, and can even be an underestimate for
413 * certain unencodeable objects.
415 ssize_t auth1_encoded_len(const auth1_t *obj, const auth_ctx_t *auth_ctx_ctx);
416 /** Try to encode the auth1 from 'input' into the buffer at 'output',
417 * using up to 'avail' bytes of the output buffer. On success, return
418 * the number of bytes used. On failure, return -2 if the buffer was
419 * not long enough, and -1 if the input was invalid.
421 ssize_t auth1_encode(uint8_t *output, size_t avail, const auth1_t *input, const auth_ctx_t *auth_ctx_ctx);
422 /** Check whether the internal state of the auth1 in 'obj' is
423 * consistent. Return NULL if it is, and a short message if it is not.
425 const char *auth1_check(const auth1_t *obj, const auth_ctx_t *auth_ctx_ctx);
426 /** Clear any errors that were set on the object 'obj' by its setter
427 * functions. Return true iff errors were cleared.
429 int auth1_clear_errors(auth1_t *obj);
430 /** Return the (constant) length of the array holding the type field
431 * of the auth1_t in 'inp'.
433 size_t auth1_getlen_type(const auth1_t *inp);
434 /** Return the element at position 'idx' of the fixed array field type
435 * of the auth1_t in 'inp'.
437 uint8_t auth1_get_type(auth1_t *inp, size_t idx);
438 /** As auth1_get_type, but take and return a const pointer
440 uint8_t auth1_getconst_type(const auth1_t *inp, size_t idx);
441 /** Change the element at position 'idx' of the fixed array field type
442 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
444 int auth1_set_type(auth1_t *inp, size_t idx, uint8_t elt);
445 /** Return a pointer to the 8-element array field type of 'inp'.
447 uint8_t * auth1_getarray_type(auth1_t *inp);
448 /** As auth1_get_type, but take and return a const pointer
450 const uint8_t * auth1_getconstarray_type(const auth1_t *inp);
451 /** Return the (constant) length of the array holding the cid field of
452 * the auth1_t in 'inp'.
454 size_t auth1_getlen_cid(const auth1_t *inp);
455 /** Return the element at position 'idx' of the fixed array field cid
456 * of the auth1_t in 'inp'.
458 uint8_t auth1_get_cid(auth1_t *inp, size_t idx);
459 /** As auth1_get_cid, but take and return a const pointer
461 uint8_t auth1_getconst_cid(const auth1_t *inp, size_t idx);
462 /** Change the element at position 'idx' of the fixed array field cid
463 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
465 int auth1_set_cid(auth1_t *inp, size_t idx, uint8_t elt);
466 /** Return a pointer to the 32-element array field cid of 'inp'.
468 uint8_t * auth1_getarray_cid(auth1_t *inp);
469 /** As auth1_get_cid, but take and return a const pointer
471 const uint8_t * auth1_getconstarray_cid(const auth1_t *inp);
472 /** Return the (constant) length of the array holding the sid field of
473 * the auth1_t in 'inp'.
475 size_t auth1_getlen_sid(const auth1_t *inp);
476 /** Return the element at position 'idx' of the fixed array field sid
477 * of the auth1_t in 'inp'.
479 uint8_t auth1_get_sid(auth1_t *inp, size_t idx);
480 /** As auth1_get_sid, but take and return a const pointer
482 uint8_t auth1_getconst_sid(const auth1_t *inp, size_t idx);
483 /** Change the element at position 'idx' of the fixed array field sid
484 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
486 int auth1_set_sid(auth1_t *inp, size_t idx, uint8_t elt);
487 /** Return a pointer to the 32-element array field sid of 'inp'.
489 uint8_t * auth1_getarray_sid(auth1_t *inp);
490 /** As auth1_get_sid, but take and return a const pointer
492 const uint8_t * auth1_getconstarray_sid(const auth1_t *inp);
493 /** Return the (constant) length of the array holding the u1_cid_ed
494 * field of the auth1_t in 'inp'.
496 size_t auth1_getlen_u1_cid_ed(const auth1_t *inp);
497 /** Return the element at position 'idx' of the fixed array field
498 * u1_cid_ed of the auth1_t in 'inp'.
500 uint8_t auth1_get_u1_cid_ed(auth1_t *inp, size_t idx);
501 /** As auth1_get_u1_cid_ed, but take and return a const pointer
503 uint8_t auth1_getconst_u1_cid_ed(const auth1_t *inp, size_t idx);
504 /** Change the element at position 'idx' of the fixed array field
505 * u1_cid_ed of the auth1_t in 'inp', so that it will hold the value
506 * 'elt'.
508 int auth1_set_u1_cid_ed(auth1_t *inp, size_t idx, uint8_t elt);
509 /** Return a pointer to the 32-element array field u1_cid_ed of 'inp'.
511 uint8_t * auth1_getarray_u1_cid_ed(auth1_t *inp);
512 /** As auth1_get_u1_cid_ed, but take and return a const pointer
514 const uint8_t * auth1_getconstarray_u1_cid_ed(const auth1_t *inp);
515 /** Return the (constant) length of the array holding the u1_sid_ed
516 * field of the auth1_t in 'inp'.
518 size_t auth1_getlen_u1_sid_ed(const auth1_t *inp);
519 /** Return the element at position 'idx' of the fixed array field
520 * u1_sid_ed of the auth1_t in 'inp'.
522 uint8_t auth1_get_u1_sid_ed(auth1_t *inp, size_t idx);
523 /** As auth1_get_u1_sid_ed, but take and return a const pointer
525 uint8_t auth1_getconst_u1_sid_ed(const auth1_t *inp, size_t idx);
526 /** Change the element at position 'idx' of the fixed array field
527 * u1_sid_ed of the auth1_t in 'inp', so that it will hold the value
528 * 'elt'.
530 int auth1_set_u1_sid_ed(auth1_t *inp, size_t idx, uint8_t elt);
531 /** Return a pointer to the 32-element array field u1_sid_ed of 'inp'.
533 uint8_t * auth1_getarray_u1_sid_ed(auth1_t *inp);
534 /** As auth1_get_u1_sid_ed, but take and return a const pointer
536 const uint8_t * auth1_getconstarray_u1_sid_ed(const auth1_t *inp);
537 /** Return the (constant) length of the array holding the slog field
538 * of the auth1_t in 'inp'.
540 size_t auth1_getlen_slog(const auth1_t *inp);
541 /** Return the element at position 'idx' of the fixed array field slog
542 * of the auth1_t in 'inp'.
544 uint8_t auth1_get_slog(auth1_t *inp, size_t idx);
545 /** As auth1_get_slog, but take and return a const pointer
547 uint8_t auth1_getconst_slog(const auth1_t *inp, size_t idx);
548 /** Change the element at position 'idx' of the fixed array field slog
549 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
551 int auth1_set_slog(auth1_t *inp, size_t idx, uint8_t elt);
552 /** Return a pointer to the 32-element array field slog of 'inp'.
554 uint8_t * auth1_getarray_slog(auth1_t *inp);
555 /** As auth1_get_slog, but take and return a const pointer
557 const uint8_t * auth1_getconstarray_slog(const auth1_t *inp);
558 /** Return the (constant) length of the array holding the clog field
559 * of the auth1_t in 'inp'.
561 size_t auth1_getlen_clog(const auth1_t *inp);
562 /** Return the element at position 'idx' of the fixed array field clog
563 * of the auth1_t in 'inp'.
565 uint8_t auth1_get_clog(auth1_t *inp, size_t idx);
566 /** As auth1_get_clog, but take and return a const pointer
568 uint8_t auth1_getconst_clog(const auth1_t *inp, size_t idx);
569 /** Change the element at position 'idx' of the fixed array field clog
570 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
572 int auth1_set_clog(auth1_t *inp, size_t idx, uint8_t elt);
573 /** Return a pointer to the 32-element array field clog of 'inp'.
575 uint8_t * auth1_getarray_clog(auth1_t *inp);
576 /** As auth1_get_clog, but take and return a const pointer
578 const uint8_t * auth1_getconstarray_clog(const auth1_t *inp);
579 /** Return the (constant) length of the array holding the scert field
580 * of the auth1_t in 'inp'.
582 size_t auth1_getlen_scert(const auth1_t *inp);
583 /** Return the element at position 'idx' of the fixed array field
584 * scert of the auth1_t in 'inp'.
586 uint8_t auth1_get_scert(auth1_t *inp, size_t idx);
587 /** As auth1_get_scert, but take and return a const pointer
589 uint8_t auth1_getconst_scert(const auth1_t *inp, size_t idx);
590 /** Change the element at position 'idx' of the fixed array field
591 * scert of the auth1_t in 'inp', so that it will hold the value
592 * 'elt'.
594 int auth1_set_scert(auth1_t *inp, size_t idx, uint8_t elt);
595 /** Return a pointer to the 32-element array field scert of 'inp'.
597 uint8_t * auth1_getarray_scert(auth1_t *inp);
598 /** As auth1_get_scert, but take and return a const pointer
600 const uint8_t * auth1_getconstarray_scert(const auth1_t *inp);
601 /** Return the (constant) length of the array holding the tlssecrets
602 * field of the auth1_t in 'inp'.
604 size_t auth1_getlen_tlssecrets(const auth1_t *inp);
605 /** Return the element at position 'idx' of the fixed array field
606 * tlssecrets of the auth1_t in 'inp'.
608 uint8_t auth1_get_tlssecrets(auth1_t *inp, size_t idx);
609 /** As auth1_get_tlssecrets, but take and return a const pointer
611 uint8_t auth1_getconst_tlssecrets(const auth1_t *inp, size_t idx);
612 /** Change the element at position 'idx' of the fixed array field
613 * tlssecrets of the auth1_t in 'inp', so that it will hold the value
614 * 'elt'.
616 int auth1_set_tlssecrets(auth1_t *inp, size_t idx, uint8_t elt);
617 /** Return a pointer to the 32-element array field tlssecrets of
618 * 'inp'.
620 uint8_t * auth1_getarray_tlssecrets(auth1_t *inp);
621 /** As auth1_get_tlssecrets, but take and return a const pointer
623 const uint8_t * auth1_getconstarray_tlssecrets(const auth1_t *inp);
624 /** Return the position for end_of_fixed_part when we parsed this
625 * object
627 const uint8_t * auth1_get_end_of_fixed_part(const auth1_t *inp);
628 /** Return the (constant) length of the array holding the rand field
629 * of the auth1_t in 'inp'.
631 size_t auth1_getlen_rand(const auth1_t *inp);
632 /** Return the element at position 'idx' of the fixed array field rand
633 * of the auth1_t in 'inp'.
635 uint8_t auth1_get_rand(auth1_t *inp, size_t idx);
636 /** As auth1_get_rand, but take and return a const pointer
638 uint8_t auth1_getconst_rand(const auth1_t *inp, size_t idx);
639 /** Change the element at position 'idx' of the fixed array field rand
640 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
642 int auth1_set_rand(auth1_t *inp, size_t idx, uint8_t elt);
643 /** Return a pointer to the 24-element array field rand of 'inp'.
645 uint8_t * auth1_getarray_rand(auth1_t *inp);
646 /** As auth1_get_rand, but take and return a const pointer
648 const uint8_t * auth1_getconstarray_rand(const auth1_t *inp);
649 /** Return the position for end_of_signed when we parsed this object
651 const uint8_t * auth1_get_end_of_signed(const auth1_t *inp);
652 /** Return the length of the dynamic array holding the sig field of
653 * the auth1_t in 'inp'.
655 size_t auth1_getlen_sig(const auth1_t *inp);
656 /** Return the element at position 'idx' of the dynamic array field
657 * sig of the auth1_t in 'inp'.
659 uint8_t auth1_get_sig(auth1_t *inp, size_t idx);
660 /** As auth1_get_sig, but take and return a const pointer
662 uint8_t auth1_getconst_sig(const auth1_t *inp, size_t idx);
663 /** Change the element at position 'idx' of the dynamic array field
664 * sig of the auth1_t in 'inp', so that it will hold the value 'elt'.
666 int auth1_set_sig(auth1_t *inp, size_t idx, uint8_t elt);
667 /** Append a new element 'elt' to the dynamic array field sig of the
668 * auth1_t in 'inp'.
670 int auth1_add_sig(auth1_t *inp, uint8_t elt);
671 /** Return a pointer to the variable-length array field sig of 'inp'.
673 uint8_t * auth1_getarray_sig(auth1_t *inp);
674 /** As auth1_get_sig, but take and return a const pointer
676 const uint8_t * auth1_getconstarray_sig(const auth1_t *inp);
677 /** Change the length of the variable-length array field sig of 'inp'
678 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
679 * -1 and set the error code on 'inp' on failure.
681 int auth1_setlen_sig(auth1_t *inp, size_t newlen);
682 /** Return a newly allocated certs_cell with all elements set to zero.
684 certs_cell_t *certs_cell_new(void);
685 /** Release all storage held by the certs_cell in 'victim'. (Do
686 * nothing if 'victim' is NULL.)
688 void certs_cell_free(certs_cell_t *victim);
689 /** Try to parse a certs_cell from the buffer in 'input', using up to
690 * 'len_in' bytes from the input buffer. On success, return the number
691 * of bytes consumed and set *output to the newly allocated
692 * certs_cell_t. On failure, return -2 if the input appears truncated,
693 * and -1 if the input is otherwise invalid.
695 ssize_t certs_cell_parse(certs_cell_t **output, const uint8_t *input, const size_t len_in);
696 /** Return the number of bytes we expect to need to encode the
697 * certs_cell in 'obj'. On failure, return a negative value. Note that
698 * this value may be an overestimate, and can even be an underestimate
699 * for certain unencodeable objects.
701 ssize_t certs_cell_encoded_len(const certs_cell_t *obj);
702 /** Try to encode the certs_cell from 'input' into the buffer at
703 * 'output', using up to 'avail' bytes of the output buffer. On
704 * success, return the number of bytes used. On failure, return -2 if
705 * the buffer was not long enough, and -1 if the input was invalid.
707 ssize_t certs_cell_encode(uint8_t *output, size_t avail, const certs_cell_t *input);
708 /** Check whether the internal state of the certs_cell in 'obj' is
709 * consistent. Return NULL if it is, and a short message if it is not.
711 const char *certs_cell_check(const certs_cell_t *obj);
712 /** Clear any errors that were set on the object 'obj' by its setter
713 * functions. Return true iff errors were cleared.
715 int certs_cell_clear_errors(certs_cell_t *obj);
716 /** Return the value of the n_certs field of the certs_cell_t in 'inp'
718 uint8_t certs_cell_get_n_certs(const certs_cell_t *inp);
719 /** Set the value of the n_certs field of the certs_cell_t in 'inp' to
720 * 'val'. Return 0 on success; return -1 and set the error code on
721 * 'inp' on failure.
723 int certs_cell_set_n_certs(certs_cell_t *inp, uint8_t val);
724 /** Return the length of the dynamic array holding the certs field of
725 * the certs_cell_t in 'inp'.
727 size_t certs_cell_getlen_certs(const certs_cell_t *inp);
728 /** Return the element at position 'idx' of the dynamic array field
729 * certs of the certs_cell_t in 'inp'.
731 struct certs_cell_cert_st * certs_cell_get_certs(certs_cell_t *inp, size_t idx);
732 /** As certs_cell_get_certs, but take and return a const pointer
734 const struct certs_cell_cert_st * certs_cell_getconst_certs(const certs_cell_t *inp, size_t idx);
735 /** Change the element at position 'idx' of the dynamic array field
736 * certs of the certs_cell_t in 'inp', so that it will hold the value
737 * 'elt'. Free the previous value, if any.
739 int certs_cell_set_certs(certs_cell_t *inp, size_t idx, struct certs_cell_cert_st * elt);
740 /** As certs_cell_set_certs, but does not free the previous value.
742 int certs_cell_set0_certs(certs_cell_t *inp, size_t idx, struct certs_cell_cert_st * elt);
743 /** Append a new element 'elt' to the dynamic array field certs of the
744 * certs_cell_t in 'inp'.
746 int certs_cell_add_certs(certs_cell_t *inp, struct certs_cell_cert_st * elt);
747 /** Return a pointer to the variable-length array field certs of
748 * 'inp'.
750 struct certs_cell_cert_st * * certs_cell_getarray_certs(certs_cell_t *inp);
751 /** As certs_cell_get_certs, but take and return a const pointer
753 const struct certs_cell_cert_st * const * certs_cell_getconstarray_certs(const certs_cell_t *inp);
754 /** Change the length of the variable-length array field certs of
755 * 'inp' to 'newlen'.Fill extra elements with NULL; free removed
756 * elements. Return 0 on success; return -1 and set the error code on
757 * 'inp' on failure.
759 int certs_cell_setlen_certs(certs_cell_t *inp, size_t newlen);
762 #endif