tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

link_handshake.h (32392B)


      1 /* link_handshake.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_LINK_HANDSHAKE_H
      6 #define TRUNNEL_LINK_HANDSHAKE_H
      7 
      8 #include <stdint.h>
      9 #include "trunnel.h"
     10 
     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_AUTH1)
     19 struct auth1_st {
     20  uint8_t type[8];
     21  uint8_t cid[32];
     22  uint8_t sid[32];
     23  uint8_t cid_ed[32];
     24  uint8_t sid_ed[32];
     25  uint8_t slog[32];
     26  uint8_t clog[32];
     27  uint8_t scert[32];
     28  uint8_t tlssecrets[32];
     29  const uint8_t *end_of_fixed_part;
     30  uint8_t rand[24];
     31  const uint8_t *end_of_signed;
     32  TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
     33  uint8_t trunnel_error_code_;
     34 };
     35 #endif
     36 typedef struct auth1_st auth1_t;
     37 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_AUTH_CHALLENGE_CELL)
     38 struct auth_challenge_cell_st {
     39  uint8_t challenge[32];
     40  uint16_t n_methods;
     41  TRUNNEL_DYNARRAY_HEAD(, uint16_t) methods;
     42  uint8_t trunnel_error_code_;
     43 };
     44 #endif
     45 typedef struct auth_challenge_cell_st auth_challenge_cell_t;
     46 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CERTS_CELL_CERT)
     47 struct certs_cell_cert_st {
     48  uint8_t cert_type;
     49  uint16_t cert_len;
     50  TRUNNEL_DYNARRAY_HEAD(, uint8_t) body;
     51  uint8_t trunnel_error_code_;
     52 };
     53 #endif
     54 typedef struct certs_cell_cert_st certs_cell_cert_t;
     55 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_RSA_ED_CROSSCERT)
     56 struct rsa_ed_crosscert_st {
     57  uint8_t ed_key[32];
     58  uint32_t expiration;
     59  const uint8_t *end_of_signed;
     60  uint8_t sig_len;
     61  TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
     62  uint8_t trunnel_error_code_;
     63 };
     64 #endif
     65 typedef struct rsa_ed_crosscert_st rsa_ed_crosscert_t;
     66 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CERTS_CELL)
     67 struct certs_cell_st {
     68  uint8_t n_certs;
     69  TRUNNEL_DYNARRAY_HEAD(, struct certs_cell_cert_st *) certs;
     70  uint8_t trunnel_error_code_;
     71 };
     72 #endif
     73 typedef struct certs_cell_st certs_cell_t;
     74 /** Return a newly allocated auth1 with all elements set to zero.
     75 */
     76 auth1_t *auth1_new(void);
     77 /** Release all storage held by the auth1 in 'victim'. (Do nothing if
     78 * 'victim' is NULL.)
     79 */
     80 void auth1_free(auth1_t *victim);
     81 /** Try to parse a auth1 from the buffer in 'input', using up to
     82 * 'len_in' bytes from the input buffer. On success, return the number
     83 * of bytes consumed and set *output to the newly allocated auth1_t.
     84 * On failure, return -2 if the input appears truncated, and -1 if the
     85 * input is otherwise invalid.
     86 */
     87 ssize_t auth1_parse(auth1_t **output, const uint8_t *input, const size_t len_in);
     88 /** Return the number of bytes we expect to need to encode the auth1
     89 * in 'obj'. On failure, return a negative value. Note that this value
     90 * may be an overestimate, and can even be an underestimate for
     91 * certain unencodeable objects.
     92 */
     93 ssize_t auth1_encoded_len(const auth1_t *obj);
     94 /** Try to encode the auth1 from 'input' into the buffer at 'output',
     95 * using up to 'avail' bytes of the output buffer. On success, return
     96 * the number of bytes used. On failure, return -2 if the buffer was
     97 * not long enough, and -1 if the input was invalid.
     98 */
     99 ssize_t auth1_encode(uint8_t *output, size_t avail, const auth1_t *input);
    100 /** Check whether the internal state of the auth1 in 'obj' is
    101 * consistent. Return NULL if it is, and a short message if it is not.
    102 */
    103 const char *auth1_check(const auth1_t *obj);
    104 /** Clear any errors that were set on the object 'obj' by its setter
    105 * functions. Return true iff errors were cleared.
    106 */
    107 int auth1_clear_errors(auth1_t *obj);
    108 /** Return the (constant) length of the array holding the type field
    109 * of the auth1_t in 'inp'.
    110 */
    111 size_t auth1_getlen_type(const auth1_t *inp);
    112 /** Return the element at position 'idx' of the fixed array field type
    113 * of the auth1_t in 'inp'.
    114 */
    115 uint8_t auth1_get_type(auth1_t *inp, size_t idx);
    116 /** As auth1_get_type, but take and return a const pointer
    117 */
    118 uint8_t auth1_getconst_type(const auth1_t *inp, size_t idx);
    119 /** Change the element at position 'idx' of the fixed array field type
    120 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
    121 */
    122 int auth1_set_type(auth1_t *inp, size_t idx, uint8_t elt);
    123 /** Return a pointer to the 8-element array field type of 'inp'.
    124 */
    125 uint8_t * auth1_getarray_type(auth1_t *inp);
    126 /** As auth1_get_type, but take and return a const pointer
    127 */
    128 const uint8_t  * auth1_getconstarray_type(const auth1_t *inp);
    129 /** Return the (constant) length of the array holding the cid field of
    130 * the auth1_t in 'inp'.
    131 */
    132 size_t auth1_getlen_cid(const auth1_t *inp);
    133 /** Return the element at position 'idx' of the fixed array field cid
    134 * of the auth1_t in 'inp'.
    135 */
    136 uint8_t auth1_get_cid(auth1_t *inp, size_t idx);
    137 /** As auth1_get_cid, but take and return a const pointer
    138 */
    139 uint8_t auth1_getconst_cid(const auth1_t *inp, size_t idx);
    140 /** Change the element at position 'idx' of the fixed array field cid
    141 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
    142 */
    143 int auth1_set_cid(auth1_t *inp, size_t idx, uint8_t elt);
    144 /** Return a pointer to the 32-element array field cid of 'inp'.
    145 */
    146 uint8_t * auth1_getarray_cid(auth1_t *inp);
    147 /** As auth1_get_cid, but take and return a const pointer
    148 */
    149 const uint8_t  * auth1_getconstarray_cid(const auth1_t *inp);
    150 /** Return the (constant) length of the array holding the sid field of
    151 * the auth1_t in 'inp'.
    152 */
    153 size_t auth1_getlen_sid(const auth1_t *inp);
    154 /** Return the element at position 'idx' of the fixed array field sid
    155 * of the auth1_t in 'inp'.
    156 */
    157 uint8_t auth1_get_sid(auth1_t *inp, size_t idx);
    158 /** As auth1_get_sid, but take and return a const pointer
    159 */
    160 uint8_t auth1_getconst_sid(const auth1_t *inp, size_t idx);
    161 /** Change the element at position 'idx' of the fixed array field sid
    162 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
    163 */
    164 int auth1_set_sid(auth1_t *inp, size_t idx, uint8_t elt);
    165 /** Return a pointer to the 32-element array field sid of 'inp'.
    166 */
    167 uint8_t * auth1_getarray_sid(auth1_t *inp);
    168 /** As auth1_get_sid, but take and return a const pointer
    169 */
    170 const uint8_t  * auth1_getconstarray_sid(const auth1_t *inp);
    171 /** Return the (constant) length of the array holding the cid_ed field
    172 * of the auth1_t in 'inp'.
    173 */
    174 size_t auth1_getlen_cid_ed(const auth1_t *inp);
    175 /** Return the element at position 'idx' of the fixed array field
    176 * cid_ed of the auth1_t in 'inp'.
    177 */
    178 uint8_t auth1_get_cid_ed(auth1_t *inp, size_t idx);
    179 /** As auth1_get_cid_ed, but take and return a const pointer
    180 */
    181 uint8_t auth1_getconst_cid_ed(const auth1_t *inp, size_t idx);
    182 /** Change the element at position 'idx' of the fixed array field
    183 * cid_ed of the auth1_t in 'inp', so that it will hold the value
    184 * 'elt'.
    185 */
    186 int auth1_set_cid_ed(auth1_t *inp, size_t idx, uint8_t elt);
    187 /** Return a pointer to the 32-element array field cid_ed of 'inp'.
    188 */
    189 uint8_t * auth1_getarray_cid_ed(auth1_t *inp);
    190 /** As auth1_get_cid_ed, but take and return a const pointer
    191 */
    192 const uint8_t  * auth1_getconstarray_cid_ed(const auth1_t *inp);
    193 /** Return the (constant) length of the array holding the sid_ed field
    194 * of the auth1_t in 'inp'.
    195 */
    196 size_t auth1_getlen_sid_ed(const auth1_t *inp);
    197 /** Return the element at position 'idx' of the fixed array field
    198 * sid_ed of the auth1_t in 'inp'.
    199 */
    200 uint8_t auth1_get_sid_ed(auth1_t *inp, size_t idx);
    201 /** As auth1_get_sid_ed, but take and return a const pointer
    202 */
    203 uint8_t auth1_getconst_sid_ed(const auth1_t *inp, size_t idx);
    204 /** Change the element at position 'idx' of the fixed array field
    205 * sid_ed of the auth1_t in 'inp', so that it will hold the value
    206 * 'elt'.
    207 */
    208 int auth1_set_sid_ed(auth1_t *inp, size_t idx, uint8_t elt);
    209 /** Return a pointer to the 32-element array field sid_ed of 'inp'.
    210 */
    211 uint8_t * auth1_getarray_sid_ed(auth1_t *inp);
    212 /** As auth1_get_sid_ed, but take and return a const pointer
    213 */
    214 const uint8_t  * auth1_getconstarray_sid_ed(const auth1_t *inp);
    215 /** Return the (constant) length of the array holding the slog field
    216 * of the auth1_t in 'inp'.
    217 */
    218 size_t auth1_getlen_slog(const auth1_t *inp);
    219 /** Return the element at position 'idx' of the fixed array field slog
    220 * of the auth1_t in 'inp'.
    221 */
    222 uint8_t auth1_get_slog(auth1_t *inp, size_t idx);
    223 /** As auth1_get_slog, but take and return a const pointer
    224 */
    225 uint8_t auth1_getconst_slog(const auth1_t *inp, size_t idx);
    226 /** Change the element at position 'idx' of the fixed array field slog
    227 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
    228 */
    229 int auth1_set_slog(auth1_t *inp, size_t idx, uint8_t elt);
    230 /** Return a pointer to the 32-element array field slog of 'inp'.
    231 */
    232 uint8_t * auth1_getarray_slog(auth1_t *inp);
    233 /** As auth1_get_slog, but take and return a const pointer
    234 */
    235 const uint8_t  * auth1_getconstarray_slog(const auth1_t *inp);
    236 /** Return the (constant) length of the array holding the clog field
    237 * of the auth1_t in 'inp'.
    238 */
    239 size_t auth1_getlen_clog(const auth1_t *inp);
    240 /** Return the element at position 'idx' of the fixed array field clog
    241 * of the auth1_t in 'inp'.
    242 */
    243 uint8_t auth1_get_clog(auth1_t *inp, size_t idx);
    244 /** As auth1_get_clog, but take and return a const pointer
    245 */
    246 uint8_t auth1_getconst_clog(const auth1_t *inp, size_t idx);
    247 /** Change the element at position 'idx' of the fixed array field clog
    248 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
    249 */
    250 int auth1_set_clog(auth1_t *inp, size_t idx, uint8_t elt);
    251 /** Return a pointer to the 32-element array field clog of 'inp'.
    252 */
    253 uint8_t * auth1_getarray_clog(auth1_t *inp);
    254 /** As auth1_get_clog, but take and return a const pointer
    255 */
    256 const uint8_t  * auth1_getconstarray_clog(const auth1_t *inp);
    257 /** Return the (constant) length of the array holding the scert field
    258 * of the auth1_t in 'inp'.
    259 */
    260 size_t auth1_getlen_scert(const auth1_t *inp);
    261 /** Return the element at position 'idx' of the fixed array field
    262 * scert of the auth1_t in 'inp'.
    263 */
    264 uint8_t auth1_get_scert(auth1_t *inp, size_t idx);
    265 /** As auth1_get_scert, but take and return a const pointer
    266 */
    267 uint8_t auth1_getconst_scert(const auth1_t *inp, size_t idx);
    268 /** Change the element at position 'idx' of the fixed array field
    269 * scert of the auth1_t in 'inp', so that it will hold the value
    270 * 'elt'.
    271 */
    272 int auth1_set_scert(auth1_t *inp, size_t idx, uint8_t elt);
    273 /** Return a pointer to the 32-element array field scert of 'inp'.
    274 */
    275 uint8_t * auth1_getarray_scert(auth1_t *inp);
    276 /** As auth1_get_scert, but take and return a const pointer
    277 */
    278 const uint8_t  * auth1_getconstarray_scert(const auth1_t *inp);
    279 /** Return the (constant) length of the array holding the tlssecrets
    280 * field of the auth1_t in 'inp'.
    281 */
    282 size_t auth1_getlen_tlssecrets(const auth1_t *inp);
    283 /** Return the element at position 'idx' of the fixed array field
    284 * tlssecrets of the auth1_t in 'inp'.
    285 */
    286 uint8_t auth1_get_tlssecrets(auth1_t *inp, size_t idx);
    287 /** As auth1_get_tlssecrets, but take and return a const pointer
    288 */
    289 uint8_t auth1_getconst_tlssecrets(const auth1_t *inp, size_t idx);
    290 /** Change the element at position 'idx' of the fixed array field
    291 * tlssecrets of the auth1_t in 'inp', so that it will hold the value
    292 * 'elt'.
    293 */
    294 int auth1_set_tlssecrets(auth1_t *inp, size_t idx, uint8_t elt);
    295 /** Return a pointer to the 32-element array field tlssecrets of
    296 * 'inp'.
    297 */
    298 uint8_t * auth1_getarray_tlssecrets(auth1_t *inp);
    299 /** As auth1_get_tlssecrets, but take and return a const pointer
    300 */
    301 const uint8_t  * auth1_getconstarray_tlssecrets(const auth1_t *inp);
    302 /** Return the position for end_of_fixed_part when we parsed this
    303 * object
    304 */
    305 const uint8_t * auth1_get_end_of_fixed_part(const auth1_t *inp);
    306 /** Return the (constant) length of the array holding the rand field
    307 * of the auth1_t in 'inp'.
    308 */
    309 size_t auth1_getlen_rand(const auth1_t *inp);
    310 /** Return the element at position 'idx' of the fixed array field rand
    311 * of the auth1_t in 'inp'.
    312 */
    313 uint8_t auth1_get_rand(auth1_t *inp, size_t idx);
    314 /** As auth1_get_rand, but take and return a const pointer
    315 */
    316 uint8_t auth1_getconst_rand(const auth1_t *inp, size_t idx);
    317 /** Change the element at position 'idx' of the fixed array field rand
    318 * of the auth1_t in 'inp', so that it will hold the value 'elt'.
    319 */
    320 int auth1_set_rand(auth1_t *inp, size_t idx, uint8_t elt);
    321 /** Return a pointer to the 24-element array field rand of 'inp'.
    322 */
    323 uint8_t * auth1_getarray_rand(auth1_t *inp);
    324 /** As auth1_get_rand, but take and return a const pointer
    325 */
    326 const uint8_t  * auth1_getconstarray_rand(const auth1_t *inp);
    327 /** Return the position for end_of_signed when we parsed this object
    328 */
    329 const uint8_t * auth1_get_end_of_signed(const auth1_t *inp);
    330 /** Return the length of the dynamic array holding the sig field of
    331 * the auth1_t in 'inp'.
    332 */
    333 size_t auth1_getlen_sig(const auth1_t *inp);
    334 /** Return the element at position 'idx' of the dynamic array field
    335 * sig of the auth1_t in 'inp'.
    336 */
    337 uint8_t auth1_get_sig(auth1_t *inp, size_t idx);
    338 /** As auth1_get_sig, but take and return a const pointer
    339 */
    340 uint8_t auth1_getconst_sig(const auth1_t *inp, size_t idx);
    341 /** Change the element at position 'idx' of the dynamic array field
    342 * sig of the auth1_t in 'inp', so that it will hold the value 'elt'.
    343 */
    344 int auth1_set_sig(auth1_t *inp, size_t idx, uint8_t elt);
    345 /** Append a new element 'elt' to the dynamic array field sig of the
    346 * auth1_t in 'inp'.
    347 */
    348 int auth1_add_sig(auth1_t *inp, uint8_t elt);
    349 /** Return a pointer to the variable-length array field sig of 'inp'.
    350 */
    351 uint8_t * auth1_getarray_sig(auth1_t *inp);
    352 /** As auth1_get_sig, but take and return a const pointer
    353 */
    354 const uint8_t  * auth1_getconstarray_sig(const auth1_t *inp);
    355 /** Change the length of the variable-length array field sig of 'inp'
    356 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
    357 * -1 and set the error code on 'inp' on failure.
    358 */
    359 int auth1_setlen_sig(auth1_t *inp, size_t newlen);
    360 /** Return a newly allocated auth_challenge_cell with all elements set
    361 * to zero.
    362 */
    363 auth_challenge_cell_t *auth_challenge_cell_new(void);
    364 /** Release all storage held by the auth_challenge_cell in 'victim'.
    365 * (Do nothing if 'victim' is NULL.)
    366 */
    367 void auth_challenge_cell_free(auth_challenge_cell_t *victim);
    368 /** Try to parse a auth_challenge_cell from the buffer in 'input',
    369 * using up to 'len_in' bytes from the input buffer. On success,
    370 * return the number of bytes consumed and set *output to the newly
    371 * allocated auth_challenge_cell_t. On failure, return -2 if the input
    372 * appears truncated, and -1 if the input is otherwise invalid.
    373 */
    374 ssize_t auth_challenge_cell_parse(auth_challenge_cell_t **output, const uint8_t *input, const size_t len_in);
    375 /** Return the number of bytes we expect to need to encode the
    376 * auth_challenge_cell in 'obj'. On failure, return a negative value.
    377 * Note that this value may be an overestimate, and can even be an
    378 * underestimate for certain unencodeable objects.
    379 */
    380 ssize_t auth_challenge_cell_encoded_len(const auth_challenge_cell_t *obj);
    381 /** Try to encode the auth_challenge_cell from 'input' into the buffer
    382 * at 'output', using up to 'avail' bytes of the output buffer. On
    383 * success, return the number of bytes used. On failure, return -2 if
    384 * the buffer was not long enough, and -1 if the input was invalid.
    385 */
    386 ssize_t auth_challenge_cell_encode(uint8_t *output, size_t avail, const auth_challenge_cell_t *input);
    387 /** Check whether the internal state of the auth_challenge_cell in
    388 * 'obj' is consistent. Return NULL if it is, and a short message if
    389 * it is not.
    390 */
    391 const char *auth_challenge_cell_check(const auth_challenge_cell_t *obj);
    392 /** Clear any errors that were set on the object 'obj' by its setter
    393 * functions. Return true iff errors were cleared.
    394 */
    395 int auth_challenge_cell_clear_errors(auth_challenge_cell_t *obj);
    396 /** Return the (constant) length of the array holding the challenge
    397 * field of the auth_challenge_cell_t in 'inp'.
    398 */
    399 size_t auth_challenge_cell_getlen_challenge(const auth_challenge_cell_t *inp);
    400 /** Return the element at position 'idx' of the fixed array field
    401 * challenge of the auth_challenge_cell_t in 'inp'.
    402 */
    403 uint8_t auth_challenge_cell_get_challenge(auth_challenge_cell_t *inp, size_t idx);
    404 /** As auth_challenge_cell_get_challenge, but take and return a const
    405 * pointer
    406 */
    407 uint8_t auth_challenge_cell_getconst_challenge(const auth_challenge_cell_t *inp, size_t idx);
    408 /** Change the element at position 'idx' of the fixed array field
    409 * challenge of the auth_challenge_cell_t in 'inp', so that it will
    410 * hold the value 'elt'.
    411 */
    412 int auth_challenge_cell_set_challenge(auth_challenge_cell_t *inp, size_t idx, uint8_t elt);
    413 /** Return a pointer to the 32-element array field challenge of 'inp'.
    414 */
    415 uint8_t * auth_challenge_cell_getarray_challenge(auth_challenge_cell_t *inp);
    416 /** As auth_challenge_cell_get_challenge, but take and return a const
    417 * pointer
    418 */
    419 const uint8_t  * auth_challenge_cell_getconstarray_challenge(const auth_challenge_cell_t *inp);
    420 /** Return the value of the n_methods field of the
    421 * auth_challenge_cell_t in 'inp'
    422 */
    423 uint16_t auth_challenge_cell_get_n_methods(const auth_challenge_cell_t *inp);
    424 /** Set the value of the n_methods field of the auth_challenge_cell_t
    425 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
    426 * code on 'inp' on failure.
    427 */
    428 int auth_challenge_cell_set_n_methods(auth_challenge_cell_t *inp, uint16_t val);
    429 /** Return the length of the dynamic array holding the methods field
    430 * of the auth_challenge_cell_t in 'inp'.
    431 */
    432 size_t auth_challenge_cell_getlen_methods(const auth_challenge_cell_t *inp);
    433 /** Return the element at position 'idx' of the dynamic array field
    434 * methods of the auth_challenge_cell_t in 'inp'.
    435 */
    436 uint16_t auth_challenge_cell_get_methods(auth_challenge_cell_t *inp, size_t idx);
    437 /** As auth_challenge_cell_get_methods, but take and return a const
    438 * pointer
    439 */
    440 uint16_t auth_challenge_cell_getconst_methods(const auth_challenge_cell_t *inp, size_t idx);
    441 /** Change the element at position 'idx' of the dynamic array field
    442 * methods of the auth_challenge_cell_t in 'inp', so that it will hold
    443 * the value 'elt'.
    444 */
    445 int auth_challenge_cell_set_methods(auth_challenge_cell_t *inp, size_t idx, uint16_t elt);
    446 /** Append a new element 'elt' to the dynamic array field methods of
    447 * the auth_challenge_cell_t in 'inp'.
    448 */
    449 int auth_challenge_cell_add_methods(auth_challenge_cell_t *inp, uint16_t elt);
    450 /** Return a pointer to the variable-length array field methods of
    451 * 'inp'.
    452 */
    453 uint16_t * auth_challenge_cell_getarray_methods(auth_challenge_cell_t *inp);
    454 /** As auth_challenge_cell_get_methods, but take and return a const
    455 * pointer
    456 */
    457 const uint16_t  * auth_challenge_cell_getconstarray_methods(const auth_challenge_cell_t *inp);
    458 /** Change the length of the variable-length array field methods of
    459 * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
    460 * return -1 and set the error code on 'inp' on failure.
    461 */
    462 int auth_challenge_cell_setlen_methods(auth_challenge_cell_t *inp, size_t newlen);
    463 /** Return a newly allocated certs_cell_cert with all elements set to
    464 * zero.
    465 */
    466 certs_cell_cert_t *certs_cell_cert_new(void);
    467 /** Release all storage held by the certs_cell_cert in 'victim'. (Do
    468 * nothing if 'victim' is NULL.)
    469 */
    470 void certs_cell_cert_free(certs_cell_cert_t *victim);
    471 /** Try to parse a certs_cell_cert from the buffer in 'input', using
    472 * up to 'len_in' bytes from the input buffer. On success, return the
    473 * number of bytes consumed and set *output to the newly allocated
    474 * certs_cell_cert_t. On failure, return -2 if the input appears
    475 * truncated, and -1 if the input is otherwise invalid.
    476 */
    477 ssize_t certs_cell_cert_parse(certs_cell_cert_t **output, const uint8_t *input, const size_t len_in);
    478 /** Return the number of bytes we expect to need to encode the
    479 * certs_cell_cert in 'obj'. On failure, return a negative value. Note
    480 * that this value may be an overestimate, and can even be an
    481 * underestimate for certain unencodeable objects.
    482 */
    483 ssize_t certs_cell_cert_encoded_len(const certs_cell_cert_t *obj);
    484 /** Try to encode the certs_cell_cert from 'input' into the buffer at
    485 * 'output', using up to 'avail' bytes of the output buffer. On
    486 * success, return the number of bytes used. On failure, return -2 if
    487 * the buffer was not long enough, and -1 if the input was invalid.
    488 */
    489 ssize_t certs_cell_cert_encode(uint8_t *output, size_t avail, const certs_cell_cert_t *input);
    490 /** Check whether the internal state of the certs_cell_cert in 'obj'
    491 * is consistent. Return NULL if it is, and a short message if it is
    492 * not.
    493 */
    494 const char *certs_cell_cert_check(const certs_cell_cert_t *obj);
    495 /** Clear any errors that were set on the object 'obj' by its setter
    496 * functions. Return true iff errors were cleared.
    497 */
    498 int certs_cell_cert_clear_errors(certs_cell_cert_t *obj);
    499 /** Return the value of the cert_type field of the certs_cell_cert_t
    500 * in 'inp'
    501 */
    502 uint8_t certs_cell_cert_get_cert_type(const certs_cell_cert_t *inp);
    503 /** Set the value of the cert_type field of the certs_cell_cert_t in
    504 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
    505 * code on 'inp' on failure.
    506 */
    507 int certs_cell_cert_set_cert_type(certs_cell_cert_t *inp, uint8_t val);
    508 /** Return the value of the cert_len field of the certs_cell_cert_t in
    509 * 'inp'
    510 */
    511 uint16_t certs_cell_cert_get_cert_len(const certs_cell_cert_t *inp);
    512 /** Set the value of the cert_len field of the certs_cell_cert_t in
    513 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
    514 * code on 'inp' on failure.
    515 */
    516 int certs_cell_cert_set_cert_len(certs_cell_cert_t *inp, uint16_t val);
    517 /** Return the length of the dynamic array holding the body field of
    518 * the certs_cell_cert_t in 'inp'.
    519 */
    520 size_t certs_cell_cert_getlen_body(const certs_cell_cert_t *inp);
    521 /** Return the element at position 'idx' of the dynamic array field
    522 * body of the certs_cell_cert_t in 'inp'.
    523 */
    524 uint8_t certs_cell_cert_get_body(certs_cell_cert_t *inp, size_t idx);
    525 /** As certs_cell_cert_get_body, but take and return a const pointer
    526 */
    527 uint8_t certs_cell_cert_getconst_body(const certs_cell_cert_t *inp, size_t idx);
    528 /** Change the element at position 'idx' of the dynamic array field
    529 * body of the certs_cell_cert_t in 'inp', so that it will hold the
    530 * value 'elt'.
    531 */
    532 int certs_cell_cert_set_body(certs_cell_cert_t *inp, size_t idx, uint8_t elt);
    533 /** Append a new element 'elt' to the dynamic array field body of the
    534 * certs_cell_cert_t in 'inp'.
    535 */
    536 int certs_cell_cert_add_body(certs_cell_cert_t *inp, uint8_t elt);
    537 /** Return a pointer to the variable-length array field body of 'inp'.
    538 */
    539 uint8_t * certs_cell_cert_getarray_body(certs_cell_cert_t *inp);
    540 /** As certs_cell_cert_get_body, but take and return a const pointer
    541 */
    542 const uint8_t  * certs_cell_cert_getconstarray_body(const certs_cell_cert_t *inp);
    543 /** Change the length of the variable-length array field body of 'inp'
    544 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
    545 * -1 and set the error code on 'inp' on failure.
    546 */
    547 int certs_cell_cert_setlen_body(certs_cell_cert_t *inp, size_t newlen);
    548 /** Return a newly allocated rsa_ed_crosscert with all elements set to
    549 * zero.
    550 */
    551 rsa_ed_crosscert_t *rsa_ed_crosscert_new(void);
    552 /** Release all storage held by the rsa_ed_crosscert in 'victim'. (Do
    553 * nothing if 'victim' is NULL.)
    554 */
    555 void rsa_ed_crosscert_free(rsa_ed_crosscert_t *victim);
    556 /** Try to parse a rsa_ed_crosscert from the buffer in 'input', using
    557 * up to 'len_in' bytes from the input buffer. On success, return the
    558 * number of bytes consumed and set *output to the newly allocated
    559 * rsa_ed_crosscert_t. On failure, return -2 if the input appears
    560 * truncated, and -1 if the input is otherwise invalid.
    561 */
    562 ssize_t rsa_ed_crosscert_parse(rsa_ed_crosscert_t **output, const uint8_t *input, const size_t len_in);
    563 /** Return the number of bytes we expect to need to encode the
    564 * rsa_ed_crosscert in 'obj'. On failure, return a negative value.
    565 * Note that this value may be an overestimate, and can even be an
    566 * underestimate for certain unencodeable objects.
    567 */
    568 ssize_t rsa_ed_crosscert_encoded_len(const rsa_ed_crosscert_t *obj);
    569 /** Try to encode the rsa_ed_crosscert from 'input' into the buffer at
    570 * 'output', using up to 'avail' bytes of the output buffer. On
    571 * success, return the number of bytes used. On failure, return -2 if
    572 * the buffer was not long enough, and -1 if the input was invalid.
    573 */
    574 ssize_t rsa_ed_crosscert_encode(uint8_t *output, size_t avail, const rsa_ed_crosscert_t *input);
    575 /** Check whether the internal state of the rsa_ed_crosscert in 'obj'
    576 * is consistent. Return NULL if it is, and a short message if it is
    577 * not.
    578 */
    579 const char *rsa_ed_crosscert_check(const rsa_ed_crosscert_t *obj);
    580 /** Clear any errors that were set on the object 'obj' by its setter
    581 * functions. Return true iff errors were cleared.
    582 */
    583 int rsa_ed_crosscert_clear_errors(rsa_ed_crosscert_t *obj);
    584 /** Return the (constant) length of the array holding the ed_key field
    585 * of the rsa_ed_crosscert_t in 'inp'.
    586 */
    587 size_t rsa_ed_crosscert_getlen_ed_key(const rsa_ed_crosscert_t *inp);
    588 /** Return the element at position 'idx' of the fixed array field
    589 * ed_key of the rsa_ed_crosscert_t in 'inp'.
    590 */
    591 uint8_t rsa_ed_crosscert_get_ed_key(rsa_ed_crosscert_t *inp, size_t idx);
    592 /** As rsa_ed_crosscert_get_ed_key, but take and return a const
    593 * pointer
    594 */
    595 uint8_t rsa_ed_crosscert_getconst_ed_key(const rsa_ed_crosscert_t *inp, size_t idx);
    596 /** Change the element at position 'idx' of the fixed array field
    597 * ed_key of the rsa_ed_crosscert_t in 'inp', so that it will hold the
    598 * value 'elt'.
    599 */
    600 int rsa_ed_crosscert_set_ed_key(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt);
    601 /** Return a pointer to the 32-element array field ed_key of 'inp'.
    602 */
    603 uint8_t * rsa_ed_crosscert_getarray_ed_key(rsa_ed_crosscert_t *inp);
    604 /** As rsa_ed_crosscert_get_ed_key, but take and return a const
    605 * pointer
    606 */
    607 const uint8_t  * rsa_ed_crosscert_getconstarray_ed_key(const rsa_ed_crosscert_t *inp);
    608 /** Return the value of the expiration field of the rsa_ed_crosscert_t
    609 * in 'inp'
    610 */
    611 uint32_t rsa_ed_crosscert_get_expiration(const rsa_ed_crosscert_t *inp);
    612 /** Set the value of the expiration field of the rsa_ed_crosscert_t in
    613 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
    614 * code on 'inp' on failure.
    615 */
    616 int rsa_ed_crosscert_set_expiration(rsa_ed_crosscert_t *inp, uint32_t val);
    617 /** Return the position for end_of_signed when we parsed this object
    618 */
    619 const uint8_t * rsa_ed_crosscert_get_end_of_signed(const rsa_ed_crosscert_t *inp);
    620 /** Return the value of the sig_len field of the rsa_ed_crosscert_t in
    621 * 'inp'
    622 */
    623 uint8_t rsa_ed_crosscert_get_sig_len(const rsa_ed_crosscert_t *inp);
    624 /** Set the value of the sig_len field of the rsa_ed_crosscert_t in
    625 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
    626 * code on 'inp' on failure.
    627 */
    628 int rsa_ed_crosscert_set_sig_len(rsa_ed_crosscert_t *inp, uint8_t val);
    629 /** Return the length of the dynamic array holding the sig field of
    630 * the rsa_ed_crosscert_t in 'inp'.
    631 */
    632 size_t rsa_ed_crosscert_getlen_sig(const rsa_ed_crosscert_t *inp);
    633 /** Return the element at position 'idx' of the dynamic array field
    634 * sig of the rsa_ed_crosscert_t in 'inp'.
    635 */
    636 uint8_t rsa_ed_crosscert_get_sig(rsa_ed_crosscert_t *inp, size_t idx);
    637 /** As rsa_ed_crosscert_get_sig, but take and return a const pointer
    638 */
    639 uint8_t rsa_ed_crosscert_getconst_sig(const rsa_ed_crosscert_t *inp, size_t idx);
    640 /** Change the element at position 'idx' of the dynamic array field
    641 * sig of the rsa_ed_crosscert_t in 'inp', so that it will hold the
    642 * value 'elt'.
    643 */
    644 int rsa_ed_crosscert_set_sig(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt);
    645 /** Append a new element 'elt' to the dynamic array field sig of the
    646 * rsa_ed_crosscert_t in 'inp'.
    647 */
    648 int rsa_ed_crosscert_add_sig(rsa_ed_crosscert_t *inp, uint8_t elt);
    649 /** Return a pointer to the variable-length array field sig of 'inp'.
    650 */
    651 uint8_t * rsa_ed_crosscert_getarray_sig(rsa_ed_crosscert_t *inp);
    652 /** As rsa_ed_crosscert_get_sig, but take and return a const pointer
    653 */
    654 const uint8_t  * rsa_ed_crosscert_getconstarray_sig(const rsa_ed_crosscert_t *inp);
    655 /** Change the length of the variable-length array field sig of 'inp'
    656 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
    657 * -1 and set the error code on 'inp' on failure.
    658 */
    659 int rsa_ed_crosscert_setlen_sig(rsa_ed_crosscert_t *inp, size_t newlen);
    660 /** Return a newly allocated certs_cell with all elements set to zero.
    661 */
    662 certs_cell_t *certs_cell_new(void);
    663 /** Release all storage held by the certs_cell in 'victim'. (Do
    664 * nothing if 'victim' is NULL.)
    665 */
    666 void certs_cell_free(certs_cell_t *victim);
    667 /** Try to parse a certs_cell from the buffer in 'input', using up to
    668 * 'len_in' bytes from the input buffer. On success, return the number
    669 * of bytes consumed and set *output to the newly allocated
    670 * certs_cell_t. On failure, return -2 if the input appears truncated,
    671 * and -1 if the input is otherwise invalid.
    672 */
    673 ssize_t certs_cell_parse(certs_cell_t **output, const uint8_t *input, const size_t len_in);
    674 /** Return the number of bytes we expect to need to encode the
    675 * certs_cell in 'obj'. On failure, return a negative value. Note that
    676 * this value may be an overestimate, and can even be an underestimate
    677 * for certain unencodeable objects.
    678 */
    679 ssize_t certs_cell_encoded_len(const certs_cell_t *obj);
    680 /** Try to encode the certs_cell from 'input' into the buffer at
    681 * 'output', using up to 'avail' bytes of the output buffer. On
    682 * success, return the number of bytes used. On failure, return -2 if
    683 * the buffer was not long enough, and -1 if the input was invalid.
    684 */
    685 ssize_t certs_cell_encode(uint8_t *output, size_t avail, const certs_cell_t *input);
    686 /** Check whether the internal state of the certs_cell in 'obj' is
    687 * consistent. Return NULL if it is, and a short message if it is not.
    688 */
    689 const char *certs_cell_check(const certs_cell_t *obj);
    690 /** Clear any errors that were set on the object 'obj' by its setter
    691 * functions. Return true iff errors were cleared.
    692 */
    693 int certs_cell_clear_errors(certs_cell_t *obj);
    694 /** Return the value of the n_certs field of the certs_cell_t in 'inp'
    695 */
    696 uint8_t certs_cell_get_n_certs(const certs_cell_t *inp);
    697 /** Set the value of the n_certs field of the certs_cell_t in 'inp' to
    698 * 'val'. Return 0 on success; return -1 and set the error code on
    699 * 'inp' on failure.
    700 */
    701 int certs_cell_set_n_certs(certs_cell_t *inp, uint8_t val);
    702 /** Return the length of the dynamic array holding the certs field of
    703 * the certs_cell_t in 'inp'.
    704 */
    705 size_t certs_cell_getlen_certs(const certs_cell_t *inp);
    706 /** Return the element at position 'idx' of the dynamic array field
    707 * certs of the certs_cell_t in 'inp'.
    708 */
    709 struct certs_cell_cert_st * certs_cell_get_certs(certs_cell_t *inp, size_t idx);
    710 /** As certs_cell_get_certs, but take and return a const pointer
    711 */
    712 const struct certs_cell_cert_st * certs_cell_getconst_certs(const certs_cell_t *inp, size_t idx);
    713 /** Change the element at position 'idx' of the dynamic array field
    714 * certs of the certs_cell_t in 'inp', so that it will hold the value
    715 * 'elt'. Free the previous value, if any.
    716 */
    717 int certs_cell_set_certs(certs_cell_t *inp, size_t idx, struct certs_cell_cert_st * elt);
    718 /** As certs_cell_set_certs, but does not free the previous value.
    719 */
    720 int certs_cell_set0_certs(certs_cell_t *inp, size_t idx, struct certs_cell_cert_st * elt);
    721 /** Append a new element 'elt' to the dynamic array field certs of the
    722 * certs_cell_t in 'inp'.
    723 */
    724 int certs_cell_add_certs(certs_cell_t *inp, struct certs_cell_cert_st * elt);
    725 /** Return a pointer to the variable-length array field certs of
    726 * 'inp'.
    727 */
    728 struct certs_cell_cert_st * * certs_cell_getarray_certs(certs_cell_t *inp);
    729 /** As certs_cell_get_certs, but take and return a const pointer
    730 */
    731 const struct certs_cell_cert_st *  const  * certs_cell_getconstarray_certs(const certs_cell_t *inp);
    732 /** Change the length of the variable-length array field certs of
    733 * 'inp' to 'newlen'.Fill extra elements with NULL; free removed
    734 * elements. Return 0 on success; return -1 and set the error code on
    735 * 'inp' on failure.
    736 */
    737 int certs_cell_setlen_certs(certs_cell_t *inp, size_t newlen);
    738 
    739 
    740 #endif