cell_establish_intro.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /* cell_establish_intro.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_CELL_ESTABLISH_INTRO_H
  6. #define TRUNNEL_CELL_ESTABLISH_INTRO_H
  7. #include <stdint.h>
  8. #include "trunnel.h"
  9. struct cell_extension_st;
  10. #define TRUNNEL_SHA3_256_LEN 32
  11. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_HS_CELL_ESTABLISH_INTRO)
  12. struct hs_cell_establish_intro_st {
  13. const uint8_t *start_cell;
  14. uint8_t auth_key_type;
  15. uint16_t auth_key_len;
  16. TRUNNEL_DYNARRAY_HEAD(, uint8_t) auth_key;
  17. struct cell_extension_st *extensions;
  18. const uint8_t *end_mac_fields;
  19. uint8_t handshake_mac[TRUNNEL_SHA3_256_LEN];
  20. uint16_t sig_len;
  21. const uint8_t *end_sig_fields;
  22. TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
  23. uint8_t trunnel_error_code_;
  24. };
  25. #endif
  26. typedef struct hs_cell_establish_intro_st hs_cell_establish_intro_t;
  27. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_HS_CELL_INTRO_ESTABLISHED)
  28. struct hs_cell_intro_established_st {
  29. struct cell_extension_st *extensions;
  30. uint8_t trunnel_error_code_;
  31. };
  32. #endif
  33. typedef struct hs_cell_intro_established_st hs_cell_intro_established_t;
  34. /** Return a newly allocated hs_cell_establish_intro with all elements
  35. * set to zero.
  36. */
  37. hs_cell_establish_intro_t *hs_cell_establish_intro_new(void);
  38. /** Release all storage held by the hs_cell_establish_intro in
  39. * 'victim'. (Do nothing if 'victim' is NULL.)
  40. */
  41. void hs_cell_establish_intro_free(hs_cell_establish_intro_t *victim);
  42. /** Try to parse a hs_cell_establish_intro from the buffer in 'input',
  43. * using up to 'len_in' bytes from the input buffer. On success,
  44. * return the number of bytes consumed and set *output to the newly
  45. * allocated hs_cell_establish_intro_t. On failure, return -2 if the
  46. * input appears truncated, and -1 if the input is otherwise invalid.
  47. */
  48. ssize_t hs_cell_establish_intro_parse(hs_cell_establish_intro_t **output, const uint8_t *input, const size_t len_in);
  49. /** Return the number of bytes we expect to need to encode the
  50. * hs_cell_establish_intro in 'obj'. On failure, return a negative
  51. * value. Note that this value may be an overestimate, and can even be
  52. * an underestimate for certain unencodeable objects.
  53. */
  54. ssize_t hs_cell_establish_intro_encoded_len(const hs_cell_establish_intro_t *obj);
  55. /** Try to encode the hs_cell_establish_intro from 'input' into the
  56. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  57. * On success, return the number of bytes used. On failure, return -2
  58. * if the buffer was not long enough, and -1 if the input was invalid.
  59. */
  60. ssize_t hs_cell_establish_intro_encode(uint8_t *output, size_t avail, const hs_cell_establish_intro_t *input);
  61. /** Check whether the internal state of the hs_cell_establish_intro in
  62. * 'obj' is consistent. Return NULL if it is, and a short message if
  63. * it is not.
  64. */
  65. const char *hs_cell_establish_intro_check(const hs_cell_establish_intro_t *obj);
  66. /** Clear any errors that were set on the object 'obj' by its setter
  67. * functions. Return true iff errors were cleared.
  68. */
  69. int hs_cell_establish_intro_clear_errors(hs_cell_establish_intro_t *obj);
  70. /** Return the position for start_cell when we parsed this object
  71. */
  72. const uint8_t * hs_cell_establish_intro_get_start_cell(const hs_cell_establish_intro_t *inp);
  73. /** Return the value of the auth_key_type field of the
  74. * hs_cell_establish_intro_t in 'inp'
  75. */
  76. uint8_t hs_cell_establish_intro_get_auth_key_type(const hs_cell_establish_intro_t *inp);
  77. /** Set the value of the auth_key_type field of the
  78. * hs_cell_establish_intro_t in 'inp' to 'val'. Return 0 on success;
  79. * return -1 and set the error code on 'inp' on failure.
  80. */
  81. int hs_cell_establish_intro_set_auth_key_type(hs_cell_establish_intro_t *inp, uint8_t val);
  82. /** Return the value of the auth_key_len field of the
  83. * hs_cell_establish_intro_t in 'inp'
  84. */
  85. uint16_t hs_cell_establish_intro_get_auth_key_len(const hs_cell_establish_intro_t *inp);
  86. /** Set the value of the auth_key_len field of the
  87. * hs_cell_establish_intro_t in 'inp' to 'val'. Return 0 on success;
  88. * return -1 and set the error code on 'inp' on failure.
  89. */
  90. int hs_cell_establish_intro_set_auth_key_len(hs_cell_establish_intro_t *inp, uint16_t val);
  91. /** Return the length of the dynamic array holding the auth_key field
  92. * of the hs_cell_establish_intro_t in 'inp'.
  93. */
  94. size_t hs_cell_establish_intro_getlen_auth_key(const hs_cell_establish_intro_t *inp);
  95. /** Return the element at position 'idx' of the dynamic array field
  96. * auth_key of the hs_cell_establish_intro_t in 'inp'.
  97. */
  98. uint8_t hs_cell_establish_intro_get_auth_key(hs_cell_establish_intro_t *inp, size_t idx);
  99. /** As hs_cell_establish_intro_get_auth_key, but take and return a
  100. * const pointer
  101. */
  102. uint8_t hs_cell_establish_intro_getconst_auth_key(const hs_cell_establish_intro_t *inp, size_t idx);
  103. /** Change the element at position 'idx' of the dynamic array field
  104. * auth_key of the hs_cell_establish_intro_t in 'inp', so that it will
  105. * hold the value 'elt'.
  106. */
  107. int hs_cell_establish_intro_set_auth_key(hs_cell_establish_intro_t *inp, size_t idx, uint8_t elt);
  108. /** Append a new element 'elt' to the dynamic array field auth_key of
  109. * the hs_cell_establish_intro_t in 'inp'.
  110. */
  111. int hs_cell_establish_intro_add_auth_key(hs_cell_establish_intro_t *inp, uint8_t elt);
  112. /** Return a pointer to the variable-length array field auth_key of
  113. * 'inp'.
  114. */
  115. uint8_t * hs_cell_establish_intro_getarray_auth_key(hs_cell_establish_intro_t *inp);
  116. /** As hs_cell_establish_intro_get_auth_key, but take and return a
  117. * const pointer
  118. */
  119. const uint8_t * hs_cell_establish_intro_getconstarray_auth_key(const hs_cell_establish_intro_t *inp);
  120. /** Change the length of the variable-length array field auth_key of
  121. * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
  122. * return -1 and set the error code on 'inp' on failure.
  123. */
  124. int hs_cell_establish_intro_setlen_auth_key(hs_cell_establish_intro_t *inp, size_t newlen);
  125. /** Return the value of the extensions field of the
  126. * hs_cell_establish_intro_t in 'inp'
  127. */
  128. struct cell_extension_st * hs_cell_establish_intro_get_extensions(hs_cell_establish_intro_t *inp);
  129. /** As hs_cell_establish_intro_get_extensions, but take and return a
  130. * const pointer
  131. */
  132. const struct cell_extension_st * hs_cell_establish_intro_getconst_extensions(const hs_cell_establish_intro_t *inp);
  133. /** Set the value of the extensions field of the
  134. * hs_cell_establish_intro_t in 'inp' to 'val'. Free the old value if
  135. * any. Steals the referenceto 'val'.Return 0 on success; return -1
  136. * and set the error code on 'inp' on failure.
  137. */
  138. int hs_cell_establish_intro_set_extensions(hs_cell_establish_intro_t *inp, struct cell_extension_st *val);
  139. /** As hs_cell_establish_intro_set_extensions, but does not free the
  140. * previous value.
  141. */
  142. int hs_cell_establish_intro_set0_extensions(hs_cell_establish_intro_t *inp, struct cell_extension_st *val);
  143. /** Return the position for end_mac_fields when we parsed this object
  144. */
  145. const uint8_t * hs_cell_establish_intro_get_end_mac_fields(const hs_cell_establish_intro_t *inp);
  146. /** Return the (constant) length of the array holding the
  147. * handshake_mac field of the hs_cell_establish_intro_t in 'inp'.
  148. */
  149. size_t hs_cell_establish_intro_getlen_handshake_mac(const hs_cell_establish_intro_t *inp);
  150. /** Return the element at position 'idx' of the fixed array field
  151. * handshake_mac of the hs_cell_establish_intro_t in 'inp'.
  152. */
  153. uint8_t hs_cell_establish_intro_get_handshake_mac(hs_cell_establish_intro_t *inp, size_t idx);
  154. /** As hs_cell_establish_intro_get_handshake_mac, but take and return
  155. * a const pointer
  156. */
  157. uint8_t hs_cell_establish_intro_getconst_handshake_mac(const hs_cell_establish_intro_t *inp, size_t idx);
  158. /** Change the element at position 'idx' of the fixed array field
  159. * handshake_mac of the hs_cell_establish_intro_t in 'inp', so that it
  160. * will hold the value 'elt'.
  161. */
  162. int hs_cell_establish_intro_set_handshake_mac(hs_cell_establish_intro_t *inp, size_t idx, uint8_t elt);
  163. /** Return a pointer to the TRUNNEL_SHA3_256_LEN-element array field
  164. * handshake_mac of 'inp'.
  165. */
  166. uint8_t * hs_cell_establish_intro_getarray_handshake_mac(hs_cell_establish_intro_t *inp);
  167. /** As hs_cell_establish_intro_get_handshake_mac, but take and return
  168. * a const pointer
  169. */
  170. const uint8_t * hs_cell_establish_intro_getconstarray_handshake_mac(const hs_cell_establish_intro_t *inp);
  171. /** Return the value of the sig_len field of the
  172. * hs_cell_establish_intro_t in 'inp'
  173. */
  174. uint16_t hs_cell_establish_intro_get_sig_len(const hs_cell_establish_intro_t *inp);
  175. /** Set the value of the sig_len field of the
  176. * hs_cell_establish_intro_t in 'inp' to 'val'. Return 0 on success;
  177. * return -1 and set the error code on 'inp' on failure.
  178. */
  179. int hs_cell_establish_intro_set_sig_len(hs_cell_establish_intro_t *inp, uint16_t val);
  180. /** Return the position for end_sig_fields when we parsed this object
  181. */
  182. const uint8_t * hs_cell_establish_intro_get_end_sig_fields(const hs_cell_establish_intro_t *inp);
  183. /** Return the length of the dynamic array holding the sig field of
  184. * the hs_cell_establish_intro_t in 'inp'.
  185. */
  186. size_t hs_cell_establish_intro_getlen_sig(const hs_cell_establish_intro_t *inp);
  187. /** Return the element at position 'idx' of the dynamic array field
  188. * sig of the hs_cell_establish_intro_t in 'inp'.
  189. */
  190. uint8_t hs_cell_establish_intro_get_sig(hs_cell_establish_intro_t *inp, size_t idx);
  191. /** As hs_cell_establish_intro_get_sig, but take and return a const
  192. * pointer
  193. */
  194. uint8_t hs_cell_establish_intro_getconst_sig(const hs_cell_establish_intro_t *inp, size_t idx);
  195. /** Change the element at position 'idx' of the dynamic array field
  196. * sig of the hs_cell_establish_intro_t in 'inp', so that it will hold
  197. * the value 'elt'.
  198. */
  199. int hs_cell_establish_intro_set_sig(hs_cell_establish_intro_t *inp, size_t idx, uint8_t elt);
  200. /** Append a new element 'elt' to the dynamic array field sig of the
  201. * hs_cell_establish_intro_t in 'inp'.
  202. */
  203. int hs_cell_establish_intro_add_sig(hs_cell_establish_intro_t *inp, uint8_t elt);
  204. /** Return a pointer to the variable-length array field sig of 'inp'.
  205. */
  206. uint8_t * hs_cell_establish_intro_getarray_sig(hs_cell_establish_intro_t *inp);
  207. /** As hs_cell_establish_intro_get_sig, but take and return a const
  208. * pointer
  209. */
  210. const uint8_t * hs_cell_establish_intro_getconstarray_sig(const hs_cell_establish_intro_t *inp);
  211. /** Change the length of the variable-length array field sig of 'inp'
  212. * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
  213. * -1 and set the error code on 'inp' on failure.
  214. */
  215. int hs_cell_establish_intro_setlen_sig(hs_cell_establish_intro_t *inp, size_t newlen);
  216. /** Return a newly allocated hs_cell_intro_established with all
  217. * elements set to zero.
  218. */
  219. hs_cell_intro_established_t *hs_cell_intro_established_new(void);
  220. /** Release all storage held by the hs_cell_intro_established in
  221. * 'victim'. (Do nothing if 'victim' is NULL.)
  222. */
  223. void hs_cell_intro_established_free(hs_cell_intro_established_t *victim);
  224. /** Try to parse a hs_cell_intro_established from the buffer in
  225. * 'input', using up to 'len_in' bytes from the input buffer. On
  226. * success, return the number of bytes consumed and set *output to the
  227. * newly allocated hs_cell_intro_established_t. On failure, return -2
  228. * if the input appears truncated, and -1 if the input is otherwise
  229. * invalid.
  230. */
  231. ssize_t hs_cell_intro_established_parse(hs_cell_intro_established_t **output, const uint8_t *input, const size_t len_in);
  232. /** Return the number of bytes we expect to need to encode the
  233. * hs_cell_intro_established in 'obj'. On failure, return a negative
  234. * value. Note that this value may be an overestimate, and can even be
  235. * an underestimate for certain unencodeable objects.
  236. */
  237. ssize_t hs_cell_intro_established_encoded_len(const hs_cell_intro_established_t *obj);
  238. /** Try to encode the hs_cell_intro_established from 'input' into the
  239. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  240. * On success, return the number of bytes used. On failure, return -2
  241. * if the buffer was not long enough, and -1 if the input was invalid.
  242. */
  243. ssize_t hs_cell_intro_established_encode(uint8_t *output, size_t avail, const hs_cell_intro_established_t *input);
  244. /** Check whether the internal state of the hs_cell_intro_established
  245. * in 'obj' is consistent. Return NULL if it is, and a short message
  246. * if it is not.
  247. */
  248. const char *hs_cell_intro_established_check(const hs_cell_intro_established_t *obj);
  249. /** Clear any errors that were set on the object 'obj' by its setter
  250. * functions. Return true iff errors were cleared.
  251. */
  252. int hs_cell_intro_established_clear_errors(hs_cell_intro_established_t *obj);
  253. /** Return the value of the extensions field of the
  254. * hs_cell_intro_established_t in 'inp'
  255. */
  256. struct cell_extension_st * hs_cell_intro_established_get_extensions(hs_cell_intro_established_t *inp);
  257. /** As hs_cell_intro_established_get_extensions, but take and return a
  258. * const pointer
  259. */
  260. const struct cell_extension_st * hs_cell_intro_established_getconst_extensions(const hs_cell_intro_established_t *inp);
  261. /** Set the value of the extensions field of the
  262. * hs_cell_intro_established_t in 'inp' to 'val'. Free the old value
  263. * if any. Steals the referenceto 'val'.Return 0 on success; return -1
  264. * and set the error code on 'inp' on failure.
  265. */
  266. int hs_cell_intro_established_set_extensions(hs_cell_intro_established_t *inp, struct cell_extension_st *val);
  267. /** As hs_cell_intro_established_set_extensions, but does not free the
  268. * previous value.
  269. */
  270. int hs_cell_intro_established_set0_extensions(hs_cell_intro_established_t *inp, struct cell_extension_st *val);
  271. #endif