ed25519_cert.h 43 KB

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