aboutsummaryrefslogtreecommitdiff
path: root/src/trunnel/link_handshake.h
blob: 0c7ac36b1b949a74a122797a682cfc76066def14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
/* link_handshake.h -- generated by Trunnel v1.5.3.
 * https://gitweb.torproject.org/trunnel.git
 * You probably shouldn't edit this file.
 */
#ifndef TRUNNEL_LINK_HANDSHAKE_H
#define TRUNNEL_LINK_HANDSHAKE_H

#include <stdint.h>
#include "trunnel.h"

#define CERTTYPE_RSA1024_ID_LINK 1
#define CERTTYPE_RSA1024_ID_ID 2
#define CERTTYPE_RSA1024_ID_AUTH 3
#define CERTTYPE_ED_ID_SIGN 4
#define CERTTYPE_ED_SIGN_LINK 5
#define CERTTYPE_ED_SIGN_AUTH 6
#define CERTTYPE_RSA1024_ID_EDID 7
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_AUTH_CHALLENGE_CELL)
struct auth_challenge_cell_st {
  uint8_t challenge[32];
  uint16_t n_methods;
  TRUNNEL_DYNARRAY_HEAD(, uint16_t) methods;
  uint8_t trunnel_error_code_;
};
#endif
typedef struct auth_challenge_cell_st auth_challenge_cell_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_AUTH_CTX)
struct auth_ctx_st {
  uint8_t is_ed;
  uint8_t trunnel_error_code_;
};
#endif
typedef struct auth_ctx_st auth_ctx_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CERTS_CELL_CERT)
struct certs_cell_cert_st {
  uint8_t cert_type;
  uint16_t cert_len;
  TRUNNEL_DYNARRAY_HEAD(, uint8_t) body;
  uint8_t trunnel_error_code_;
};
#endif
typedef struct certs_cell_cert_st certs_cell_cert_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_RSA_ED_CROSSCERT)
struct rsa_ed_crosscert_st {
  uint8_t ed_key[32];
  uint32_t expiration;
  const uint8_t *end_of_signed;
  uint8_t sig_len;
  TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
  uint8_t trunnel_error_code_;
};
#endif
typedef struct rsa_ed_crosscert_st rsa_ed_crosscert_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_AUTH1)
struct auth1_st {
  uint8_t type[8];
  uint8_t cid[32];
  uint8_t sid[32];
  uint8_t u1_cid_ed[32];
  uint8_t u1_sid_ed[32];
  uint8_t slog[32];
  uint8_t clog[32];
  uint8_t scert[32];
  uint8_t tlssecrets[32];
  const uint8_t *end_of_fixed_part;
  uint8_t rand[24];
  const uint8_t *end_of_signed;
  TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
  uint8_t trunnel_error_code_;
};
#endif
typedef struct auth1_st auth1_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CERTS_CELL)
struct certs_cell_st {
  uint8_t n_certs;
  TRUNNEL_DYNARRAY_HEAD(, struct certs_cell_cert_st *) certs;
  uint8_t trunnel_error_code_;
};
#endif
typedef struct certs_cell_st certs_cell_t;
/** Return a newly allocated auth_challenge_cell with all elements set
 * to zero.
 */
auth_challenge_cell_t *auth_challenge_cell_new(void);
/** Release all storage held by the auth_challenge_cell in 'victim'.
 * (Do nothing if 'victim' is NULL.)
 */
void auth_challenge_cell_free(auth_challenge_cell_t *victim);
/** Try to parse a auth_challenge_cell from the buffer in 'input',
 * using up to 'len_in' bytes from the input buffer. On success,
 * return the number of bytes consumed and set *output to the newly
 * allocated auth_challenge_cell_t. On failure, return -2 if the input
 * appears truncated, and -1 if the input is otherwise invalid.
 */
ssize_t auth_challenge_cell_parse(auth_challenge_cell_t **output, const uint8_t *input, const size_t len_in);
/** Return the number of bytes we expect to need to encode the
 * auth_challenge_cell in 'obj'. On failure, return a negative value.
 * Note that this value may be an overestimate, and can even be an
 * underestimate for certain unencodeable objects.
 */
ssize_t auth_challenge_cell_encoded_len(const auth_challenge_cell_t *obj);
/** Try to encode the auth_challenge_cell from 'input' into the buffer
 * at 'output', using up to 'avail' bytes of the output buffer. On
 * success, return the number of bytes used. On failure, return -2 if
 * the buffer was not long enough, and -1 if the input was invalid.
 */
ssize_t auth_challenge_cell_encode(uint8_t *output, size_t avail, const auth_challenge_cell_t *input);
/** Check whether the internal state of the auth_challenge_cell in
 * 'obj' is consistent. Return NULL if it is, and a short message if
 * it is not.
 */
const char *auth_challenge_cell_check(const auth_challenge_cell_t *obj);
/** Clear any errors that were set on the object 'obj' by its setter
 * functions. Return true iff errors were cleared.
 */
int auth_challenge_cell_clear_errors(auth_challenge_cell_t *obj);
/** Return the (constant) length of the array holding the challenge
 * field of the auth_challenge_cell_t in 'inp'.
 */
size_t auth_challenge_cell_getlen_challenge(const auth_challenge_cell_t *inp);
/** Return the element at position 'idx' of the fixed array field
 * challenge of the auth_challenge_cell_t in 'inp'.
 */
uint8_t auth_challenge_cell_get_challenge(auth_challenge_cell_t *inp, size_t idx);
/** As auth_challenge_cell_get_challenge, but take and return a const
 * pointer
 */
uint8_t auth_challenge_cell_getconst_challenge(const auth_challenge_cell_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
 * challenge of the auth_challenge_cell_t in 'inp', so that it will
 * hold the value 'elt'.
 */
int auth_challenge_cell_set_challenge(auth_challenge_cell_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field challenge of 'inp'.
 */
uint8_t * auth_challenge_cell_getarray_challenge(auth_challenge_cell_t *inp);
/** As auth_challenge_cell_get_challenge, but take and return a const
 * pointer
 */
const uint8_t  * auth_challenge_cell_getconstarray_challenge(const auth_challenge_cell_t *inp);
/** Return the value of the n_methods field of the
 * auth_challenge_cell_t in 'inp'
 */
uint16_t auth_challenge_cell_get_n_methods(const auth_challenge_cell_t *inp);
/** Set the value of the n_methods field of the auth_challenge_cell_t
 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
 * code on 'inp' on failure.
 */
int auth_challenge_cell_set_n_methods(auth_challenge_cell_t *inp, uint16_t val);
/** Return the length of the dynamic array holding the methods field
 * of the auth_challenge_cell_t in 'inp'.
 */
size_t auth_challenge_cell_getlen_methods(const auth_challenge_cell_t *inp);
/** Return the element at position 'idx' of the dynamic array field
 * methods of the auth_challenge_cell_t in 'inp'.
 */
uint16_t auth_challenge_cell_get_methods(auth_challenge_cell_t *inp, size_t idx);
/** As auth_challenge_cell_get_methods, but take and return a const
 * pointer
 */
uint16_t auth_challenge_cell_getconst_methods(const auth_challenge_cell_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
 * methods of the auth_challenge_cell_t in 'inp', so that it will hold
 * the value 'elt'.
 */
int auth_challenge_cell_set_methods(auth_challenge_cell_t *inp, size_t idx, uint16_t elt);
/** Append a new element 'elt' to the dynamic array field methods of
 * the auth_challenge_cell_t in 'inp'.
 */
int auth_challenge_cell_add_methods(auth_challenge_cell_t *inp, uint16_t elt);
/** Return a pointer to the variable-length array field methods of
 * 'inp'.
 */
uint16_t * auth_challenge_cell_getarray_methods(auth_challenge_cell_t *inp);
/** As auth_challenge_cell_get_methods, but take and return a const
 * pointer
 */
const uint16_t  * auth_challenge_cell_getconstarray_methods(const auth_challenge_cell_t *inp);
/** Change the length of the variable-length array field methods of
 * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
 * return -1 and set the error code on 'inp' on failure.
 */
int auth_challenge_cell_setlen_methods(auth_challenge_cell_t *inp, size_t newlen);
/** Return a newly allocated auth_ctx with all elements set to zero.
 */
auth_ctx_t *auth_ctx_new(void);
/** Release all storage held by the auth_ctx in 'victim'. (Do nothing
 * if 'victim' is NULL.)
 */
void auth_ctx_free(auth_ctx_t *victim);
/** Return the value of the is_ed field of the auth_ctx_t in 'inp'
 */
uint8_t auth_ctx_get_is_ed(const auth_ctx_t *inp);
/** Set the value of the is_ed field of the auth_ctx_t in 'inp' to
 * 'val'. Return 0 on success; return -1 and set the error code on
 * 'inp' on failure.
 */
int auth_ctx_set_is_ed(auth_ctx_t *inp, uint8_t val);
/** Return a newly allocated certs_cell_cert with all elements set to
 * zero.
 */
certs_cell_cert_t *certs_cell_cert_new(void);
/** Release all storage held by the certs_cell_cert in 'victim'. (Do
 * nothing if 'victim' is NULL.)
 */
void certs_cell_cert_free(certs_cell_cert_t *victim);
/** Try to parse a certs_cell_cert from the buffer in 'input', using
 * up to 'len_in' bytes from the input buffer. On success, return the
 * number of bytes consumed and set *output to the newly allocated
 * certs_cell_cert_t. On failure, return -2 if the input appears
 * truncated, and -1 if the input is otherwise invalid.
 */
ssize_t certs_cell_cert_parse(certs_cell_cert_t **output, const uint8_t *input, const size_t len_in);
/** Return the number of bytes we expect to need to encode the
 * certs_cell_cert in 'obj'. On failure, return a negative value. Note
 * that this value may be an overestimate, and can even be an
 * underestimate for certain unencodeable objects.
 */
ssize_t certs_cell_cert_encoded_len(const certs_cell_cert_t *obj);
/** Try to encode the certs_cell_cert from 'input' into the buffer at
 * 'output', using up to 'avail' bytes of the output buffer. On
 * success, return the number of bytes used. On failure, return -2 if
 * the buffer was not long enough, and -1 if the input was invalid.
 */
ssize_t certs_cell_cert_encode(uint8_t *output, size_t avail, const certs_cell_cert_t *input);
/** Check whether the internal state of the certs_cell_cert in 'obj'
 * is consistent. Return NULL if it is, and a short message if it is
 * not.
 */
const char *certs_cell_cert_check(const certs_cell_cert_t *obj);
/** Clear any errors that were set on the object 'obj' by its setter
 * functions. Return true iff errors were cleared.
 */
int certs_cell_cert_clear_errors(certs_cell_cert_t *obj);
/** Return the value of the cert_type field of the certs_cell_cert_t
 * in 'inp'
 */
uint8_t certs_cell_cert_get_cert_type(const certs_cell_cert_t *inp);
/** Set the value of the cert_type field of the certs_cell_cert_t in
 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
 * code on 'inp' on failure.
 */
int certs_cell_cert_set_cert_type(certs_cell_cert_t *inp, uint8_t val);
/** Return the value of the cert_len field of the certs_cell_cert_t in
 * 'inp'
 */
uint16_t certs_cell_cert_get_cert_len(const certs_cell_cert_t *inp);
/** Set the value of the cert_len field of the certs_cell_cert_t in
 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
 * code on 'inp' on failure.
 */
int certs_cell_cert_set_cert_len(certs_cell_cert_t *inp, uint16_t val);
/** Return the length of the dynamic array holding the body field of
 * the certs_cell_cert_t in 'inp'.
 */
size_t certs_cell_cert_getlen_body(const certs_cell_cert_t *inp);
/** Return the element at position 'idx' of the dynamic array field
 * body of the certs_cell_cert_t in 'inp'.
 */
uint8_t certs_cell_cert_get_body(certs_cell_cert_t *inp, size_t idx);
/** As certs_cell_cert_get_body, but take and return a const pointer
 */
uint8_t certs_cell_cert_getconst_body(const certs_cell_cert_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
 * body of the certs_cell_cert_t in 'inp', so that it will hold the
 * value 'elt'.
 */
int certs_cell_cert_set_body(certs_cell_cert_t *inp, size_t idx, uint8_t elt);
/** Append a new element 'elt' to the dynamic array field body of the
 * certs_cell_cert_t in 'inp'.
 */
int certs_cell_cert_add_body(certs_cell_cert_t *inp, uint8_t elt);
/** Return a pointer to the variable-length array field body of 'inp'.
 */
uint8_t * certs_cell_cert_getarray_body(certs_cell_cert_t *inp);
/** As certs_cell_cert_get_body, but take and return a const pointer
 */
const uint8_t  * certs_cell_cert_getconstarray_body(const certs_cell_cert_t *inp);
/** Change the length of the variable-length array field body of 'inp'
 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
 * -1 and set the error code on 'inp' on failure.
 */
int certs_cell_cert_setlen_body(certs_cell_cert_t *inp, size_t newlen);
/** Return a newly allocated rsa_ed_crosscert with all elements set to
 * zero.
 */
rsa_ed_crosscert_t *rsa_ed_crosscert_new(void);
/** Release all storage held by the rsa_ed_crosscert in 'victim'. (Do
 * nothing if 'victim' is NULL.)
 */
void rsa_ed_crosscert_free(rsa_ed_crosscert_t *victim);
/** Try to parse a rsa_ed_crosscert from the buffer in 'input', using
 * up to 'len_in' bytes from the input buffer. On success, return the
 * number of bytes consumed and set *output to the newly allocated
 * rsa_ed_crosscert_t. On failure, return -2 if the input appears
 * truncated, and -1 if the input is otherwise invalid.
 */
ssize_t rsa_ed_crosscert_parse(rsa_ed_crosscert_t **output, const uint8_t *input, const size_t len_in);
/** Return the number of bytes we expect to need to encode the
 * rsa_ed_crosscert in 'obj'. On failure, return a negative value.
 * Note that this value may be an overestimate, and can even be an
 * underestimate for certain unencodeable objects.
 */
ssize_t rsa_ed_crosscert_encoded_len(const rsa_ed_crosscert_t *obj);
/** Try to encode the rsa_ed_crosscert from 'input' into the buffer at
 * 'output', using up to 'avail' bytes of the output buffer. On
 * success, return the number of bytes used. On failure, return -2 if
 * the buffer was not long enough, and -1 if the input was invalid.
 */
ssize_t rsa_ed_crosscert_encode(uint8_t *output, size_t avail, const rsa_ed_crosscert_t *input);
/** Check whether the internal state of the rsa_ed_crosscert in 'obj'
 * is consistent. Return NULL if it is, and a short message if it is
 * not.
 */
const char *rsa_ed_crosscert_check(const rsa_ed_crosscert_t *obj);
/** Clear any errors that were set on the object 'obj' by its setter
 * functions. Return true iff errors were cleared.
 */
int rsa_ed_crosscert_clear_errors(rsa_ed_crosscert_t *obj);
/** Return the (constant) length of the array holding the ed_key field
 * of the rsa_ed_crosscert_t in 'inp'.
 */
size_t rsa_ed_crosscert_getlen_ed_key(const rsa_ed_crosscert_t *inp);
/** Return the element at position 'idx' of the fixed array field
 * ed_key of the rsa_ed_crosscert_t in 'inp'.
 */
uint8_t rsa_ed_crosscert_get_ed_key(rsa_ed_crosscert_t *inp, size_t idx);
/** As rsa_ed_crosscert_get_ed_key, but take and return a const
 * pointer
 */
uint8_t rsa_ed_crosscert_getconst_ed_key(const rsa_ed_crosscert_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
 * ed_key of the rsa_ed_crosscert_t in 'inp', so that it will hold the
 * value 'elt'.
 */
int rsa_ed_crosscert_set_ed_key(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field ed_key of 'inp'.
 */
uint8_t * rsa_ed_crosscert_getarray_ed_key(rsa_ed_crosscert_t *inp);
/** As rsa_ed_crosscert_get_ed_key, but take and return a const
 * pointer
 */
const uint8_t  * rsa_ed_crosscert_getconstarray_ed_key(const rsa_ed_crosscert_t *inp);
/** Return the value of the expiration field of the rsa_ed_crosscert_t
 * in 'inp'
 */
uint32_t rsa_ed_crosscert_get_expiration(const rsa_ed_crosscert_t *inp);
/** Set the value of the expiration field of the rsa_ed_crosscert_t in
 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
 * code on 'inp' on failure.
 */
int rsa_ed_crosscert_set_expiration(rsa_ed_crosscert_t *inp, uint32_t val);
/** Return the position for end_of_signed when we parsed this object
 */
const uint8_t * rsa_ed_crosscert_get_end_of_signed(const rsa_ed_crosscert_t *inp);
/** Return the value of the sig_len field of the rsa_ed_crosscert_t in
 * 'inp'
 */
uint8_t rsa_ed_crosscert_get_sig_len(const rsa_ed_crosscert_t *inp);
/** Set the value of the sig_len field of the rsa_ed_crosscert_t in
 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
 * code on 'inp' on failure.
 */
int rsa_ed_crosscert_set_sig_len(rsa_ed_crosscert_t *inp, uint8_t val);
/** Return the length of the dynamic array holding the sig field of
 * the rsa_ed_crosscert_t in 'inp'.
 */
size_t rsa_ed_crosscert_getlen_sig(const rsa_ed_crosscert_t *inp);
/** Return the element at position 'idx' of the dynamic array field
 * sig of the rsa_ed_crosscert_t in 'inp'.
 */
uint8_t rsa_ed_crosscert_get_sig(rsa_ed_crosscert_t *inp, size_t idx);
/** As rsa_ed_crosscert_get_sig, but take and return a const pointer
 */
uint8_t rsa_ed_crosscert_getconst_sig(const rsa_ed_crosscert_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
 * sig of the rsa_ed_crosscert_t in 'inp', so that it will hold the
 * value 'elt'.
 */
int rsa_ed_crosscert_set_sig(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt);
/** Append a new element 'elt' to the dynamic array field sig of the
 * rsa_ed_crosscert_t in 'inp'.
 */
int rsa_ed_crosscert_add_sig(rsa_ed_crosscert_t *inp, uint8_t elt);
/** Return a pointer to the variable-length array field sig of 'inp'.
 */
uint8_t * rsa_ed_crosscert_getarray_sig(rsa_ed_crosscert_t *inp);
/** As rsa_ed_crosscert_get_sig, but take and return a const pointer
 */
const uint8_t  * rsa_ed_crosscert_getconstarray_sig(const rsa_ed_crosscert_t *inp);
/** Change the length of the variable-length array field sig of 'inp'
 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
 * -1 and set the error code on 'inp' on failure.
 */
int rsa_ed_crosscert_setlen_sig(rsa_ed_crosscert_t *inp, size_t newlen);
/** Return a newly allocated auth1 with all elements set to zero.
 */
auth1_t *auth1_new(void);
/** Release all storage held by the auth1 in 'victim'. (Do nothing if
 * 'victim' is NULL.)
 */
void auth1_free(auth1_t *victim);
/** Try to parse a auth1 from the buffer in 'input', using up to
 * 'len_in' bytes from the input buffer. On success, return the number
 * of bytes consumed and set *output to the newly allocated auth1_t.
 * On failure, return -2 if the input appears truncated, and -1 if the
 * input is otherwise invalid.
 */
ssize_t auth1_parse(auth1_t **output, const uint8_t *input, const size_t len_in, const auth_ctx_t *auth_ctx_ctx);
/** Return the number of bytes we expect to need to encode the auth1
 * in 'obj'. On failure, return a negative value. Note that this value
 * may be an overestimate, and can even be an underestimate for
 * certain unencodeable objects.
 */
ssize_t auth1_encoded_len(const auth1_t *obj, const auth_ctx_t *auth_ctx_ctx);
/** Try to encode the auth1 from 'input' into the buffer at 'output',
 * using up to 'avail' bytes of the output buffer. On success, return
 * the number of bytes used. On failure, return -2 if the buffer was
 * not long enough, and -1 if the input was invalid.
 */
ssize_t auth1_encode(uint8_t *output, size_t avail, const auth1_t *input, const auth_ctx_t *auth_ctx_ctx);
/** Check whether the internal state of the auth1 in 'obj' is
 * consistent. Return NULL if it is, and a short message if it is not.
 */
const char *auth1_check(const auth1_t *obj, const auth_ctx_t *auth_ctx_ctx);
/** Clear any errors that were set on the object 'obj' by its setter
 * functions. Return true iff errors were cleared.
 */
int auth1_clear_errors(auth1_t *obj);
/** Return the (constant) length of the array holding the type field
 * of the auth1_t in 'inp'.
 */
size_t auth1_getlen_type(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field type
 * of the auth1_t in 'inp'.
 */
uint8_t auth1_get_type(auth1_t *inp, size_t idx);
/** As auth1_get_type, but take and return a const pointer
 */
uint8_t auth1_getconst_type(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field type
 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
 */
int auth1_set_type(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 8-element array field type of 'inp'.
 */
uint8_t * auth1_getarray_type(auth1_t *inp);
/** As auth1_get_type, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_type(const auth1_t *inp);
/** Return the (constant) length of the array holding the cid field of
 * the auth1_t in 'inp'.
 */
size_t auth1_getlen_cid(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field cid
 * of the auth1_t in 'inp'.
 */
uint8_t auth1_get_cid(auth1_t *inp, size_t idx);
/** As auth1_get_cid, but take and return a const pointer
 */
uint8_t auth1_getconst_cid(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field cid
 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
 */
int auth1_set_cid(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field cid of 'inp'.
 */
uint8_t * auth1_getarray_cid(auth1_t *inp);
/** As auth1_get_cid, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_cid(const auth1_t *inp);
/** Return the (constant) length of the array holding the sid field of
 * the auth1_t in 'inp'.
 */
size_t auth1_getlen_sid(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field sid
 * of the auth1_t in 'inp'.
 */
uint8_t auth1_get_sid(auth1_t *inp, size_t idx);
/** As auth1_get_sid, but take and return a const pointer
 */
uint8_t auth1_getconst_sid(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field sid
 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
 */
int auth1_set_sid(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field sid of 'inp'.
 */
uint8_t * auth1_getarray_sid(auth1_t *inp);
/** As auth1_get_sid, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_sid(const auth1_t *inp);
/** Return the (constant) length of the array holding the u1_cid_ed
 * field of the auth1_t in 'inp'.
 */
size_t auth1_getlen_u1_cid_ed(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field
 * u1_cid_ed of the auth1_t in 'inp'.
 */
uint8_t auth1_get_u1_cid_ed(auth1_t *inp, size_t idx);
/** As auth1_get_u1_cid_ed, but take and return a const pointer
 */
uint8_t auth1_getconst_u1_cid_ed(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
 * u1_cid_ed of the auth1_t in 'inp', so that it will hold the value
 * 'elt'.
 */
int auth1_set_u1_cid_ed(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field u1_cid_ed of 'inp'.
 */
uint8_t * auth1_getarray_u1_cid_ed(auth1_t *inp);
/** As auth1_get_u1_cid_ed, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_u1_cid_ed(const auth1_t *inp);
/** Return the (constant) length of the array holding the u1_sid_ed
 * field of the auth1_t in 'inp'.
 */
size_t auth1_getlen_u1_sid_ed(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field
 * u1_sid_ed of the auth1_t in 'inp'.
 */
uint8_t auth1_get_u1_sid_ed(auth1_t *inp, size_t idx);
/** As auth1_get_u1_sid_ed, but take and return a const pointer
 */
uint8_t auth1_getconst_u1_sid_ed(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
 * u1_sid_ed of the auth1_t in 'inp', so that it will hold the value
 * 'elt'.
 */
int auth1_set_u1_sid_ed(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field u1_sid_ed of 'inp'.
 */
uint8_t * auth1_getarray_u1_sid_ed(auth1_t *inp);
/** As auth1_get_u1_sid_ed, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_u1_sid_ed(const auth1_t *inp);
/** Return the (constant) length of the array holding the slog field
 * of the auth1_t in 'inp'.
 */
size_t auth1_getlen_slog(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field slog
 * of the auth1_t in 'inp'.
 */
uint8_t auth1_get_slog(auth1_t *inp, size_t idx);
/** As auth1_get_slog, but take and return a const pointer
 */
uint8_t auth1_getconst_slog(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field slog
 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
 */
int auth1_set_slog(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field slog of 'inp'.
 */
uint8_t * auth1_getarray_slog(auth1_t *inp);
/** As auth1_get_slog, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_slog(const auth1_t *inp);
/** Return the (constant) length of the array holding the clog field
 * of the auth1_t in 'inp'.
 */
size_t auth1_getlen_clog(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field clog
 * of the auth1_t in 'inp'.
 */
uint8_t auth1_get_clog(auth1_t *inp, size_t idx);
/** As auth1_get_clog, but take and return a const pointer
 */
uint8_t auth1_getconst_clog(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field clog
 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
 */
int auth1_set_clog(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field clog of 'inp'.
 */
uint8_t * auth1_getarray_clog(auth1_t *inp);
/** As auth1_get_clog, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_clog(const auth1_t *inp);
/** Return the (constant) length of the array holding the scert field
 * of the auth1_t in 'inp'.
 */
size_t auth1_getlen_scert(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field
 * scert of the auth1_t in 'inp'.
 */
uint8_t auth1_get_scert(auth1_t *inp, size_t idx);
/** As auth1_get_scert, but take and return a const pointer
 */
uint8_t auth1_getconst_scert(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
 * scert of the auth1_t in 'inp', so that it will hold the value
 * 'elt'.
 */
int auth1_set_scert(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field scert of 'inp'.
 */
uint8_t * auth1_getarray_scert(auth1_t *inp);
/** As auth1_get_scert, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_scert(const auth1_t *inp);
/** Return the (constant) length of the array holding the tlssecrets
 * field of the auth1_t in 'inp'.
 */
size_t auth1_getlen_tlssecrets(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field
 * tlssecrets of the auth1_t in 'inp'.
 */
uint8_t auth1_get_tlssecrets(auth1_t *inp, size_t idx);
/** As auth1_get_tlssecrets, but take and return a const pointer
 */
uint8_t auth1_getconst_tlssecrets(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
 * tlssecrets of the auth1_t in 'inp', so that it will hold the value
 * 'elt'.
 */
int auth1_set_tlssecrets(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field tlssecrets of
 * 'inp'.
 */
uint8_t * auth1_getarray_tlssecrets(auth1_t *inp);
/** As auth1_get_tlssecrets, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_tlssecrets(const auth1_t *inp);
/** Return the position for end_of_fixed_part when we parsed this
 * object
 */
const uint8_t * auth1_get_end_of_fixed_part(const auth1_t *inp);
/** Return the (constant) length of the array holding the rand field
 * of the auth1_t in 'inp'.
 */
size_t auth1_getlen_rand(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field rand
 * of the auth1_t in 'inp'.
 */
uint8_t auth1_get_rand(auth1_t *inp, size_t idx);
/** As auth1_get_rand, but take and return a const pointer
 */
uint8_t auth1_getconst_rand(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field rand
 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
 */
int auth1_set_rand(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 24-element array field rand of 'inp'.
 */
uint8_t * auth1_getarray_rand(auth1_t *inp);
/** As auth1_get_rand, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_rand(const auth1_t *inp);
/** Return the position for end_of_signed when we parsed this object
 */
const uint8_t * auth1_get_end_of_signed(const auth1_t *inp);
/** Return the length of the dynamic array holding the sig field of
 * the auth1_t in 'inp'.
 */
size_t auth1_getlen_sig(const auth1_t *inp);
/** Return the element at position 'idx' of the dynamic array field
 * sig of the auth1_t in 'inp'.
 */
uint8_t auth1_get_sig(auth1_t *inp, size_t idx);
/** As auth1_get_sig, but take and return a const pointer
 */
uint8_t auth1_getconst_sig(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
 * sig of the auth1_t in 'inp', so that it will hold the value 'elt'.
 */
int auth1_set_sig(auth1_t *inp, size_t idx, uint8_t elt);
/** Append a new element 'elt' to the dynamic array field sig of the
 * auth1_t in 'inp'.
 */
int auth1_add_sig(auth1_t *inp, uint8_t elt);
/** Return a pointer to the variable-length array field sig of 'inp'.
 */
uint8_t * auth1_getarray_sig(auth1_t *inp);
/** As auth1_get_sig, but take and return a const pointer
 */
const uint8_t  * auth1_getconstarray_sig(const auth1_t *inp);
/** Change the length of the variable-length array field sig of 'inp'
 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
 * -1 and set the error code on 'inp' on failure.
 */
int auth1_setlen_sig(auth1_t *inp, size_t newlen);
/** Return a newly allocated certs_cell with all elements set to zero.
 */
certs_cell_t *certs_cell_new(void);
/** Release all storage held by the certs_cell in 'victim'. (Do
 * nothing if 'victim' is NULL.)
 */
void certs_cell_free(certs_cell_t *victim);
/** Try to parse a certs_cell from the buffer in 'input', using up to
 * 'len_in' bytes from the input buffer. On success, return the number
 * of bytes consumed and set *output to the newly allocated
 * certs_cell_t. On failure, return -2 if the input appears truncated,
 * and -1 if the input is otherwise invalid.
 */
ssize_t certs_cell_parse(certs_cell_t **output, const uint8_t *input, const size_t len_in);
/** Return the number of bytes we expect to need to encode the
 * certs_cell in 'obj'. On failure, return a negative value. Note that
 * this value may be an overestimate, and can even be an underestimate
 * for certain unencodeable objects.
 */
ssize_t certs_cell_encoded_len(const certs_cell_t *obj);
/** Try to encode the certs_cell from 'input' into the buffer at
 * 'output', using up to 'avail' bytes of the output buffer. On
 * success, return the number of bytes used. On failure, return -2 if
 * the buffer was not long enough, and -1 if the input was invalid.
 */
ssize_t certs_cell_encode(uint8_t *output, size_t avail, const certs_cell_t *input);
/** Check whether the internal state of the certs_cell in 'obj' is
 * consistent. Return NULL if it is, and a short message if it is not.
 */
const char *certs_cell_check(const certs_cell_t *obj);
/** Clear any errors that were set on the object 'obj' by its setter
 * functions. Return true iff errors were cleared.
 */
int certs_cell_clear_errors(certs_cell_t *obj);
/** Return the value of the n_certs field of the certs_cell_t in 'inp'
 */
uint8_t certs_cell_get_n_certs(const certs_cell_t *inp);
/** Set the value of the n_certs field of the certs_cell_t in 'inp' to
 * 'val'. Return 0 on success; return -1 and set the error code on
 * 'inp' on failure.
 */
int certs_cell_set_n_certs(certs_cell_t *inp, uint8_t val);
/** Return the length of the dynamic array holding the certs field of
 * the certs_cell_t in 'inp'.
 */
size_t certs_cell_getlen_certs(const certs_cell_t *inp);
/** Return the element at position 'idx' of the dynamic array field
 * certs of the certs_cell_t in 'inp'.
 */
struct certs_cell_cert_st * certs_cell_get_certs(certs_cell_t *inp, size_t idx);
/** As certs_cell_get_certs, but take and return a const pointer
 */
 const struct certs_cell_cert_st * certs_cell_getconst_certs(const certs_cell_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
 * certs of the certs_cell_t in 'inp', so that it will hold the value
 * 'elt'. Free the previous value, if any.
 */
int certs_cell_set_certs(certs_cell_t *inp, size_t idx, struct certs_cell_cert_st * elt);
/** As certs_cell_set_certs, but does not free the previous value.
 */
int certs_cell_set0_certs(certs_cell_t *inp, size_t idx, struct certs_cell_cert_st * elt);
/** Append a new element 'elt' to the dynamic array field certs of the
 * certs_cell_t in 'inp'.
 */
int certs_cell_add_certs(certs_cell_t *inp, struct certs_cell_cert_st * elt);
/** Return a pointer to the variable-length array field certs of
 * 'inp'.
 */
struct certs_cell_cert_st * * certs_cell_getarray_certs(certs_cell_t *inp);
/** As certs_cell_get_certs, but take and return a const pointer
 */
const struct certs_cell_cert_st *  const  * certs_cell_getconstarray_certs(const certs_cell_t *inp);
/** Change the length of the variable-length array field certs of
 * 'inp' to 'newlen'.Fill extra elements with NULL; free removed
 * elements. Return 0 on success; return -1 and set the error code on
 * 'inp' on failure.
 */
int certs_cell_setlen_certs(certs_cell_t *inp, size_t newlen);


#endif