ed25519_cert.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /* ed25519_cert.h -- generated by by Trunnel v1.4.4.
  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_ED25519_CERT_EXTENSION)
  16. struct ed25519_cert_extension_st {
  17. uint16_t ext_length;
  18. uint8_t ext_type;
  19. uint8_t ext_flags;
  20. uint8_t un_signing_key[32];
  21. TRUNNEL_DYNARRAY_HEAD(, uint8_t) un_unparsed;
  22. uint8_t trunnel_error_code_;
  23. };
  24. #endif
  25. typedef struct ed25519_cert_extension_st ed25519_cert_extension_t;
  26. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_LINK_SPECIFIER)
  27. struct link_specifier_st {
  28. uint8_t ls_type;
  29. uint8_t ls_len;
  30. uint32_t un_ipv4_addr;
  31. uint16_t un_ipv4_port;
  32. uint8_t un_ipv6_addr[16];
  33. uint16_t un_ipv6_port;
  34. uint8_t un_legacy_id[20];
  35. uint8_t un_ed25519_id[32];
  36. TRUNNEL_DYNARRAY_HEAD(, uint8_t) un_unrecognized;
  37. uint8_t trunnel_error_code_;
  38. };
  39. #endif
  40. typedef struct link_specifier_st link_specifier_t;
  41. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_ED25519_CERT)
  42. struct ed25519_cert_st {
  43. uint8_t version;
  44. uint8_t cert_type;
  45. uint32_t exp_field;
  46. uint8_t cert_key_type;
  47. uint8_t certified_key[32];
  48. uint8_t n_extensions;
  49. TRUNNEL_DYNARRAY_HEAD(, struct ed25519_cert_extension_st *) ext;
  50. uint8_t signature[64];
  51. uint8_t trunnel_error_code_;
  52. };
  53. #endif
  54. typedef struct ed25519_cert_st ed25519_cert_t;
  55. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_LINK_SPECIFIER_LIST)
  56. struct link_specifier_list_st {
  57. uint8_t n_spec;
  58. TRUNNEL_DYNARRAY_HEAD(, struct link_specifier_st *) spec;
  59. uint8_t trunnel_error_code_;
  60. };
  61. #endif
  62. typedef struct link_specifier_list_st link_specifier_list_t;
  63. /** Return a newly allocated ed25519_cert_extension with all elements
  64. * set to zero.
  65. */
  66. ed25519_cert_extension_t *ed25519_cert_extension_new(void);
  67. /** Release all storage held by the ed25519_cert_extension in
  68. * 'victim'. (Do nothing if 'victim' is NULL.)
  69. */
  70. void ed25519_cert_extension_free(ed25519_cert_extension_t *victim);
  71. /** Try to parse a ed25519_cert_extension from the buffer in 'input',
  72. * using up to 'len_in' bytes from the input buffer. On success,
  73. * return the number of bytes consumed and set *output to the newly
  74. * allocated ed25519_cert_extension_t. On failure, return -2 if the
  75. * input appears truncated, and -1 if the input is otherwise invalid.
  76. */
  77. ssize_t ed25519_cert_extension_parse(ed25519_cert_extension_t **output, const uint8_t *input, const size_t len_in);
  78. /** Return the number of bytes we expect to need to encode the
  79. * ed25519_cert_extension in 'obj'. On failure, return a negative
  80. * value. Note that this value may be an overestimate, and can even be
  81. * an underestimate for certain unencodeable objects.
  82. */
  83. ssize_t ed25519_cert_extension_encoded_len(const ed25519_cert_extension_t *obj);
  84. /** Try to encode the ed25519_cert_extension from 'input' into the
  85. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  86. * On success, return the number of bytes used. On failure, return -2
  87. * if the buffer was not long enough, and -1 if the input was invalid.
  88. */
  89. ssize_t ed25519_cert_extension_encode(uint8_t *output, size_t avail, const ed25519_cert_extension_t *input);
  90. /** Check whether the internal state of the ed25519_cert_extension in
  91. * 'obj' is consistent. Return NULL if it is, and a short message if
  92. * it is not.
  93. */
  94. const char *ed25519_cert_extension_check(const ed25519_cert_extension_t *obj);
  95. /** Clear any errors that were set on the object 'obj' by its setter
  96. * functions. Return true iff errors were cleared.
  97. */
  98. int ed25519_cert_extension_clear_errors(ed25519_cert_extension_t *obj);
  99. /** Return the value of the ext_length field of the
  100. * ed25519_cert_extension_t in 'inp'
  101. */
  102. uint16_t ed25519_cert_extension_get_ext_length(ed25519_cert_extension_t *inp);
  103. /** Set the value of the ext_length field of the
  104. * ed25519_cert_extension_t in 'inp' to 'val'. Return 0 on success;
  105. * return -1 and set the error code on 'inp' on failure.
  106. */
  107. int ed25519_cert_extension_set_ext_length(ed25519_cert_extension_t *inp, uint16_t val);
  108. /** Return the value of the ext_type field of the
  109. * ed25519_cert_extension_t in 'inp'
  110. */
  111. uint8_t ed25519_cert_extension_get_ext_type(ed25519_cert_extension_t *inp);
  112. /** Set the value of the ext_type field of the
  113. * ed25519_cert_extension_t in 'inp' to 'val'. Return 0 on success;
  114. * return -1 and set the error code on 'inp' on failure.
  115. */
  116. int ed25519_cert_extension_set_ext_type(ed25519_cert_extension_t *inp, uint8_t val);
  117. /** Return the value of the ext_flags field of the
  118. * ed25519_cert_extension_t in 'inp'
  119. */
  120. uint8_t ed25519_cert_extension_get_ext_flags(ed25519_cert_extension_t *inp);
  121. /** Set the value of the ext_flags field of the
  122. * ed25519_cert_extension_t in 'inp' to 'val'. Return 0 on success;
  123. * return -1 and set the error code on 'inp' on failure.
  124. */
  125. int ed25519_cert_extension_set_ext_flags(ed25519_cert_extension_t *inp, uint8_t val);
  126. /** Return the (constant) length of the array holding the
  127. * un_signing_key field of the ed25519_cert_extension_t in 'inp'.
  128. */
  129. size_t ed25519_cert_extension_getlen_un_signing_key(const ed25519_cert_extension_t *inp);
  130. /** Return the element at position 'idx' of the fixed array field
  131. * un_signing_key of the ed25519_cert_extension_t in 'inp'.
  132. */
  133. uint8_t ed25519_cert_extension_get_un_signing_key(const ed25519_cert_extension_t *inp, size_t idx);
  134. /** Change the element at position 'idx' of the fixed array field
  135. * un_signing_key of the ed25519_cert_extension_t in 'inp', so that it
  136. * will hold the value 'elt'.
  137. */
  138. int ed25519_cert_extension_set_un_signing_key(ed25519_cert_extension_t *inp, size_t idx, uint8_t elt);
  139. /** Return a pointer to the 32-element array field un_signing_key of
  140. * 'inp'.
  141. */
  142. uint8_t * ed25519_cert_extension_getarray_un_signing_key(ed25519_cert_extension_t *inp);
  143. /** Return the length of the dynamic array holding the un_unparsed
  144. * field of the ed25519_cert_extension_t in 'inp'.
  145. */
  146. size_t ed25519_cert_extension_getlen_un_unparsed(const ed25519_cert_extension_t *inp);
  147. /** Return the element at position 'idx' of the dynamic array field
  148. * un_unparsed of the ed25519_cert_extension_t in 'inp'.
  149. */
  150. uint8_t ed25519_cert_extension_get_un_unparsed(ed25519_cert_extension_t *inp, size_t idx);
  151. /** Change the element at position 'idx' of the dynamic array field
  152. * un_unparsed of the ed25519_cert_extension_t in 'inp', so that it
  153. * will hold the value 'elt'.
  154. */
  155. int ed25519_cert_extension_set_un_unparsed(ed25519_cert_extension_t *inp, size_t idx, uint8_t elt);
  156. /** Append a new element 'elt' to the dynamic array field un_unparsed
  157. * of the ed25519_cert_extension_t in 'inp'.
  158. */
  159. int ed25519_cert_extension_add_un_unparsed(ed25519_cert_extension_t *inp, uint8_t elt);
  160. /** Return a pointer to the variable-length array field un_unparsed of
  161. * 'inp'.
  162. */
  163. uint8_t * ed25519_cert_extension_getarray_un_unparsed(ed25519_cert_extension_t *inp);
  164. /** Change the length of the variable-length array field un_unparsed
  165. * of 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on
  166. * success; return -1 and set the error code on 'inp' on failure.
  167. */
  168. int ed25519_cert_extension_setlen_un_unparsed(ed25519_cert_extension_t *inp, size_t newlen);
  169. /** Return a newly allocated link_specifier with all elements set to
  170. * zero.
  171. */
  172. link_specifier_t *link_specifier_new(void);
  173. /** Release all storage held by the link_specifier in 'victim'. (Do
  174. * nothing if 'victim' is NULL.)
  175. */
  176. void link_specifier_free(link_specifier_t *victim);
  177. /** Try to parse a link_specifier from the buffer in 'input', using up
  178. * to 'len_in' bytes from the input buffer. On success, return the
  179. * number of bytes consumed and set *output to the newly allocated
  180. * link_specifier_t. On failure, return -2 if the input appears
  181. * truncated, and -1 if the input is otherwise invalid.
  182. */
  183. ssize_t link_specifier_parse(link_specifier_t **output, const uint8_t *input, const size_t len_in);
  184. /** Return the number of bytes we expect to need to encode the
  185. * link_specifier in 'obj'. On failure, return a negative value. Note
  186. * that this value may be an overestimate, and can even be an
  187. * underestimate for certain unencodeable objects.
  188. */
  189. ssize_t link_specifier_encoded_len(const link_specifier_t *obj);
  190. /** Try to encode the link_specifier from 'input' into the buffer at
  191. * 'output', using up to 'avail' bytes of the output buffer. On
  192. * success, return the number of bytes used. On failure, return -2 if
  193. * the buffer was not long enough, and -1 if the input was invalid.
  194. */
  195. ssize_t link_specifier_encode(uint8_t *output, size_t avail, const link_specifier_t *input);
  196. /** Check whether the internal state of the link_specifier in 'obj' is
  197. * consistent. Return NULL if it is, and a short message if it is not.
  198. */
  199. const char *link_specifier_check(const link_specifier_t *obj);
  200. /** Clear any errors that were set on the object 'obj' by its setter
  201. * functions. Return true iff errors were cleared.
  202. */
  203. int link_specifier_clear_errors(link_specifier_t *obj);
  204. /** Return the value of the ls_type field of the link_specifier_t in
  205. * 'inp'
  206. */
  207. uint8_t link_specifier_get_ls_type(link_specifier_t *inp);
  208. /** Set the value of the ls_type field of the link_specifier_t in
  209. * 'inp' to 'val'. Return 0 on success; return -1 and set the error
  210. * code on 'inp' on failure.
  211. */
  212. int link_specifier_set_ls_type(link_specifier_t *inp, uint8_t val);
  213. /** Return the value of the ls_len field of the link_specifier_t in
  214. * 'inp'
  215. */
  216. uint8_t link_specifier_get_ls_len(link_specifier_t *inp);
  217. /** Set the value of the ls_len field of the link_specifier_t in 'inp'
  218. * to 'val'. Return 0 on success; return -1 and set the error code on
  219. * 'inp' on failure.
  220. */
  221. int link_specifier_set_ls_len(link_specifier_t *inp, uint8_t val);
  222. /** Return the value of the un_ipv4_addr field of the link_specifier_t
  223. * in 'inp'
  224. */
  225. uint32_t link_specifier_get_un_ipv4_addr(link_specifier_t *inp);
  226. /** Set the value of the un_ipv4_addr field of the link_specifier_t in
  227. * 'inp' to 'val'. Return 0 on success; return -1 and set the error
  228. * code on 'inp' on failure.
  229. */
  230. int link_specifier_set_un_ipv4_addr(link_specifier_t *inp, uint32_t val);
  231. /** Return the value of the un_ipv4_port field of the link_specifier_t
  232. * in 'inp'
  233. */
  234. uint16_t link_specifier_get_un_ipv4_port(link_specifier_t *inp);
  235. /** Set the value of the un_ipv4_port field of the link_specifier_t in
  236. * 'inp' to 'val'. Return 0 on success; return -1 and set the error
  237. * code on 'inp' on failure.
  238. */
  239. int link_specifier_set_un_ipv4_port(link_specifier_t *inp, uint16_t val);
  240. /** Return the (constant) length of the array holding the un_ipv6_addr
  241. * field of the link_specifier_t in 'inp'.
  242. */
  243. size_t link_specifier_getlen_un_ipv6_addr(const link_specifier_t *inp);
  244. /** Return the element at position 'idx' of the fixed array field
  245. * un_ipv6_addr of the link_specifier_t in 'inp'.
  246. */
  247. uint8_t link_specifier_get_un_ipv6_addr(const link_specifier_t *inp, size_t idx);
  248. /** Change the element at position 'idx' of the fixed array field
  249. * un_ipv6_addr of the link_specifier_t in 'inp', so that it will hold
  250. * the value 'elt'.
  251. */
  252. int link_specifier_set_un_ipv6_addr(link_specifier_t *inp, size_t idx, uint8_t elt);
  253. /** Return a pointer to the 16-element array field un_ipv6_addr of
  254. * 'inp'.
  255. */
  256. uint8_t * link_specifier_getarray_un_ipv6_addr(link_specifier_t *inp);
  257. /** Return the value of the un_ipv6_port field of the link_specifier_t
  258. * in 'inp'
  259. */
  260. uint16_t link_specifier_get_un_ipv6_port(link_specifier_t *inp);
  261. /** Set the value of the un_ipv6_port field of the link_specifier_t in
  262. * 'inp' to 'val'. Return 0 on success; return -1 and set the error
  263. * code on 'inp' on failure.
  264. */
  265. int link_specifier_set_un_ipv6_port(link_specifier_t *inp, uint16_t val);
  266. /** Return the (constant) length of the array holding the un_legacy_id
  267. * field of the link_specifier_t in 'inp'.
  268. */
  269. size_t link_specifier_getlen_un_legacy_id(const link_specifier_t *inp);
  270. /** Return the element at position 'idx' of the fixed array field
  271. * un_legacy_id of the link_specifier_t in 'inp'.
  272. */
  273. uint8_t link_specifier_get_un_legacy_id(const link_specifier_t *inp, size_t idx);
  274. /** Change the element at position 'idx' of the fixed array field
  275. * un_legacy_id of the link_specifier_t in 'inp', so that it will hold
  276. * the value 'elt'.
  277. */
  278. int link_specifier_set_un_legacy_id(link_specifier_t *inp, size_t idx, uint8_t elt);
  279. /** Return a pointer to the 20-element array field un_legacy_id of
  280. * 'inp'.
  281. */
  282. uint8_t * link_specifier_getarray_un_legacy_id(link_specifier_t *inp);
  283. /** Return the (constant) length of the array holding the
  284. * un_ed25519_id field of the link_specifier_t in 'inp'.
  285. */
  286. size_t link_specifier_getlen_un_ed25519_id(const link_specifier_t *inp);
  287. /** Return the element at position 'idx' of the fixed array field
  288. * un_ed25519_id of the link_specifier_t in 'inp'.
  289. */
  290. uint8_t link_specifier_get_un_ed25519_id(const link_specifier_t *inp, size_t idx);
  291. /** Change the element at position 'idx' of the fixed array field
  292. * un_ed25519_id of the link_specifier_t in 'inp', so that it will
  293. * hold the value 'elt'.
  294. */
  295. int link_specifier_set_un_ed25519_id(link_specifier_t *inp, size_t idx, uint8_t elt);
  296. /** Return a pointer to the 32-element array field un_ed25519_id of
  297. * 'inp'.
  298. */
  299. uint8_t * link_specifier_getarray_un_ed25519_id(link_specifier_t *inp);
  300. /** Return the length of the dynamic array holding the un_unrecognized
  301. * field of the link_specifier_t in 'inp'.
  302. */
  303. size_t link_specifier_getlen_un_unrecognized(const link_specifier_t *inp);
  304. /** Return the element at position 'idx' of the dynamic array field
  305. * un_unrecognized of the link_specifier_t in 'inp'.
  306. */
  307. uint8_t link_specifier_get_un_unrecognized(link_specifier_t *inp, size_t idx);
  308. /** Change the element at position 'idx' of the dynamic array field
  309. * un_unrecognized of the link_specifier_t in 'inp', so that it will
  310. * hold the value 'elt'.
  311. */
  312. int link_specifier_set_un_unrecognized(link_specifier_t *inp, size_t idx, uint8_t elt);
  313. /** Append a new element 'elt' to the dynamic array field
  314. * un_unrecognized of the link_specifier_t in 'inp'.
  315. */
  316. int link_specifier_add_un_unrecognized(link_specifier_t *inp, uint8_t elt);
  317. /** Return a pointer to the variable-length array field
  318. * un_unrecognized of 'inp'.
  319. */
  320. uint8_t * link_specifier_getarray_un_unrecognized(link_specifier_t *inp);
  321. /** Change the length of the variable-length array field
  322. * un_unrecognized of 'inp' to 'newlen'.Fill extra elements with 0.
  323. * Return 0 on success; return -1 and set the error code on 'inp' on
  324. * failure.
  325. */
  326. int link_specifier_setlen_un_unrecognized(link_specifier_t *inp, size_t newlen);
  327. /** Return a newly allocated ed25519_cert with all elements set to
  328. * zero.
  329. */
  330. ed25519_cert_t *ed25519_cert_new(void);
  331. /** Release all storage held by the ed25519_cert in 'victim'. (Do
  332. * nothing if 'victim' is NULL.)
  333. */
  334. void ed25519_cert_free(ed25519_cert_t *victim);
  335. /** Try to parse a ed25519_cert from the buffer in 'input', using up
  336. * to 'len_in' bytes from the input buffer. On success, return the
  337. * number of bytes consumed and set *output to the newly allocated
  338. * ed25519_cert_t. On failure, return -2 if the input appears
  339. * truncated, and -1 if the input is otherwise invalid.
  340. */
  341. ssize_t ed25519_cert_parse(ed25519_cert_t **output, const uint8_t *input, const size_t len_in);
  342. /** Return the number of bytes we expect to need to encode the
  343. * ed25519_cert in 'obj'. On failure, return a negative value. Note
  344. * that this value may be an overestimate, and can even be an
  345. * underestimate for certain unencodeable objects.
  346. */
  347. ssize_t ed25519_cert_encoded_len(const ed25519_cert_t *obj);
  348. /** Try to encode the ed25519_cert from 'input' into the buffer at
  349. * 'output', using up to 'avail' bytes of the output buffer. On
  350. * success, return the number of bytes used. On failure, return -2 if
  351. * the buffer was not long enough, and -1 if the input was invalid.
  352. */
  353. ssize_t ed25519_cert_encode(uint8_t *output, size_t avail, const ed25519_cert_t *input);
  354. /** Check whether the internal state of the ed25519_cert in 'obj' is
  355. * consistent. Return NULL if it is, and a short message if it is not.
  356. */
  357. const char *ed25519_cert_check(const ed25519_cert_t *obj);
  358. /** Clear any errors that were set on the object 'obj' by its setter
  359. * functions. Return true iff errors were cleared.
  360. */
  361. int ed25519_cert_clear_errors(ed25519_cert_t *obj);
  362. /** Return the value of the version field of the ed25519_cert_t in
  363. * 'inp'
  364. */
  365. uint8_t ed25519_cert_get_version(ed25519_cert_t *inp);
  366. /** Set the value of the version field of the ed25519_cert_t in 'inp'
  367. * to 'val'. Return 0 on success; return -1 and set the error code on
  368. * 'inp' on failure.
  369. */
  370. int ed25519_cert_set_version(ed25519_cert_t *inp, uint8_t val);
  371. /** Return the value of the cert_type field of the ed25519_cert_t in
  372. * 'inp'
  373. */
  374. uint8_t ed25519_cert_get_cert_type(ed25519_cert_t *inp);
  375. /** Set the value of the cert_type field of the ed25519_cert_t in
  376. * 'inp' to 'val'. Return 0 on success; return -1 and set the error
  377. * code on 'inp' on failure.
  378. */
  379. int ed25519_cert_set_cert_type(ed25519_cert_t *inp, uint8_t val);
  380. /** Return the value of the exp_field field of the ed25519_cert_t in
  381. * 'inp'
  382. */
  383. uint32_t ed25519_cert_get_exp_field(ed25519_cert_t *inp);
  384. /** Set the value of the exp_field field of the ed25519_cert_t in
  385. * 'inp' to 'val'. Return 0 on success; return -1 and set the error
  386. * code on 'inp' on failure.
  387. */
  388. int ed25519_cert_set_exp_field(ed25519_cert_t *inp, uint32_t val);
  389. /** Return the value of the cert_key_type field of the ed25519_cert_t
  390. * in 'inp'
  391. */
  392. uint8_t ed25519_cert_get_cert_key_type(ed25519_cert_t *inp);
  393. /** Set the value of the cert_key_type field of the ed25519_cert_t in
  394. * 'inp' to 'val'. Return 0 on success; return -1 and set the error
  395. * code on 'inp' on failure.
  396. */
  397. int ed25519_cert_set_cert_key_type(ed25519_cert_t *inp, uint8_t val);
  398. /** Return the (constant) length of the array holding the
  399. * certified_key field of the ed25519_cert_t in 'inp'.
  400. */
  401. size_t ed25519_cert_getlen_certified_key(const ed25519_cert_t *inp);
  402. /** Return the element at position 'idx' of the fixed array field
  403. * certified_key of the ed25519_cert_t in 'inp'.
  404. */
  405. uint8_t ed25519_cert_get_certified_key(const ed25519_cert_t *inp, size_t idx);
  406. /** Change the element at position 'idx' of the fixed array field
  407. * certified_key of the ed25519_cert_t in 'inp', so that it will hold
  408. * the value 'elt'.
  409. */
  410. int ed25519_cert_set_certified_key(ed25519_cert_t *inp, size_t idx, uint8_t elt);
  411. /** Return a pointer to the 32-element array field certified_key of
  412. * 'inp'.
  413. */
  414. uint8_t * ed25519_cert_getarray_certified_key(ed25519_cert_t *inp);
  415. /** Return the value of the n_extensions field of the ed25519_cert_t
  416. * in 'inp'
  417. */
  418. uint8_t ed25519_cert_get_n_extensions(ed25519_cert_t *inp);
  419. /** Set the value of the n_extensions field of the ed25519_cert_t in
  420. * 'inp' to 'val'. Return 0 on success; return -1 and set the error
  421. * code on 'inp' on failure.
  422. */
  423. int ed25519_cert_set_n_extensions(ed25519_cert_t *inp, uint8_t val);
  424. /** Return the length of the dynamic array holding the ext field of
  425. * the ed25519_cert_t in 'inp'.
  426. */
  427. size_t ed25519_cert_getlen_ext(const ed25519_cert_t *inp);
  428. /** Return the element at position 'idx' of the dynamic array field
  429. * ext of the ed25519_cert_t in 'inp'.
  430. */
  431. struct ed25519_cert_extension_st * ed25519_cert_get_ext(ed25519_cert_t *inp, size_t idx);
  432. /** Change the element at position 'idx' of the dynamic array field
  433. * ext of the ed25519_cert_t in 'inp', so that it will hold the value
  434. * 'elt'. Free the previous value, if any.
  435. */
  436. int ed25519_cert_set_ext(ed25519_cert_t *inp, size_t idx, struct ed25519_cert_extension_st * elt);
  437. /** As ed25519_cert_set_ext, but does not free the previous value.
  438. */
  439. int ed25519_cert_set0_ext(ed25519_cert_t *inp, size_t idx, struct ed25519_cert_extension_st * elt);
  440. /** Append a new element 'elt' to the dynamic array field ext of the
  441. * ed25519_cert_t in 'inp'.
  442. */
  443. int ed25519_cert_add_ext(ed25519_cert_t *inp, struct ed25519_cert_extension_st * elt);
  444. /** Return a pointer to the variable-length array field ext of 'inp'.
  445. */
  446. struct ed25519_cert_extension_st * * ed25519_cert_getarray_ext(ed25519_cert_t *inp);
  447. /** Change the length of the variable-length array field ext of 'inp'
  448. * to 'newlen'.Fill extra elements with NULL; free removed elements.
  449. * Return 0 on success; return -1 and set the error code on 'inp' on
  450. * failure.
  451. */
  452. int ed25519_cert_setlen_ext(ed25519_cert_t *inp, size_t newlen);
  453. /** Return the (constant) length of the array holding the signature
  454. * field of the ed25519_cert_t in 'inp'.
  455. */
  456. size_t ed25519_cert_getlen_signature(const ed25519_cert_t *inp);
  457. /** Return the element at position 'idx' of the fixed array field
  458. * signature of the ed25519_cert_t in 'inp'.
  459. */
  460. uint8_t ed25519_cert_get_signature(const ed25519_cert_t *inp, size_t idx);
  461. /** Change the element at position 'idx' of the fixed array field
  462. * signature of the ed25519_cert_t in 'inp', so that it will hold the
  463. * value 'elt'.
  464. */
  465. int ed25519_cert_set_signature(ed25519_cert_t *inp, size_t idx, uint8_t elt);
  466. /** Return a pointer to the 64-element array field signature of 'inp'.
  467. */
  468. uint8_t * ed25519_cert_getarray_signature(ed25519_cert_t *inp);
  469. /** Return a newly allocated link_specifier_list with all elements set
  470. * to zero.
  471. */
  472. link_specifier_list_t *link_specifier_list_new(void);
  473. /** Release all storage held by the link_specifier_list in 'victim'.
  474. * (Do nothing if 'victim' is NULL.)
  475. */
  476. void link_specifier_list_free(link_specifier_list_t *victim);
  477. /** Try to parse a link_specifier_list from the buffer in 'input',
  478. * using up to 'len_in' bytes from the input buffer. On success,
  479. * return the number of bytes consumed and set *output to the newly
  480. * allocated link_specifier_list_t. On failure, return -2 if the input
  481. * appears truncated, and -1 if the input is otherwise invalid.
  482. */
  483. ssize_t link_specifier_list_parse(link_specifier_list_t **output, const uint8_t *input, const size_t len_in);
  484. /** Return the number of bytes we expect to need to encode the
  485. * link_specifier_list in 'obj'. On failure, return a negative value.
  486. * Note that this value may be an overestimate, and can even be an
  487. * underestimate for certain unencodeable objects.
  488. */
  489. ssize_t link_specifier_list_encoded_len(const link_specifier_list_t *obj);
  490. /** Try to encode the link_specifier_list from 'input' into the buffer
  491. * at 'output', using up to 'avail' bytes of the output buffer. On
  492. * success, return the number of bytes used. On failure, return -2 if
  493. * the buffer was not long enough, and -1 if the input was invalid.
  494. */
  495. ssize_t link_specifier_list_encode(uint8_t *output, size_t avail, const link_specifier_list_t *input);
  496. /** Check whether the internal state of the link_specifier_list in
  497. * 'obj' is consistent. Return NULL if it is, and a short message if
  498. * it is not.
  499. */
  500. const char *link_specifier_list_check(const link_specifier_list_t *obj);
  501. /** Clear any errors that were set on the object 'obj' by its setter
  502. * functions. Return true iff errors were cleared.
  503. */
  504. int link_specifier_list_clear_errors(link_specifier_list_t *obj);
  505. /** Return the value of the n_spec field of the link_specifier_list_t
  506. * in 'inp'
  507. */
  508. uint8_t link_specifier_list_get_n_spec(link_specifier_list_t *inp);
  509. /** Set the value of the n_spec field of the link_specifier_list_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_list_set_n_spec(link_specifier_list_t *inp, uint8_t val);
  514. /** Return the length of the dynamic array holding the spec field of
  515. * the link_specifier_list_t in 'inp'.
  516. */
  517. size_t link_specifier_list_getlen_spec(const link_specifier_list_t *inp);
  518. /** Return the element at position 'idx' of the dynamic array field
  519. * spec of the link_specifier_list_t in 'inp'.
  520. */
  521. struct link_specifier_st * link_specifier_list_get_spec(link_specifier_list_t *inp, size_t idx);
  522. /** Change the element at position 'idx' of the dynamic array field
  523. * spec of the link_specifier_list_t in 'inp', so that it will hold
  524. * the value 'elt'. Free the previous value, if any.
  525. */
  526. int link_specifier_list_set_spec(link_specifier_list_t *inp, size_t idx, struct link_specifier_st * elt);
  527. /** As link_specifier_list_set_spec, but does not free the previous
  528. * value.
  529. */
  530. int link_specifier_list_set0_spec(link_specifier_list_t *inp, size_t idx, struct link_specifier_st * elt);
  531. /** Append a new element 'elt' to the dynamic array field spec of the
  532. * link_specifier_list_t in 'inp'.
  533. */
  534. int link_specifier_list_add_spec(link_specifier_list_t *inp, struct link_specifier_st * elt);
  535. /** Return a pointer to the variable-length array field spec of 'inp'.
  536. */
  537. struct link_specifier_st * * link_specifier_list_getarray_spec(link_specifier_list_t *inp);
  538. /** Change the length of the variable-length array field spec of 'inp'
  539. * to 'newlen'.Fill extra elements with NULL; free removed elements.
  540. * Return 0 on success; return -1 and set the error code on 'inp' on
  541. * failure.
  542. */
  543. int link_specifier_list_setlen_spec(link_specifier_list_t *inp, size_t newlen);
  544. #endif