ed25519_cert.h 43 KB

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