link_handshake.h 28 KB

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