cell_establish_intro.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /* cell_establish_intro.h -- generated by Trunnel v1.5.2.
  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 trn_cell_extension_st;
  10. #define TRUNNEL_SHA3_256_LEN 32
  11. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_ESTABLISH_INTRO)
  12. struct trn_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 trn_cell_extension_st *extensions;
  18. const uint8_t *end_mac_fields;
  19. uint8_t handshake_mac[TRUNNEL_SHA3_256_LEN];
  20. const uint8_t *end_sig_fields;
  21. uint16_t sig_len;
  22. TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
  23. uint8_t trunnel_error_code_;
  24. };
  25. #endif
  26. typedef struct trn_cell_establish_intro_st trn_cell_establish_intro_t;
  27. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_INTRO_ESTABLISHED)
  28. struct trn_cell_intro_established_st {
  29. struct trn_cell_extension_st *extensions;
  30. uint8_t trunnel_error_code_;
  31. };
  32. #endif
  33. typedef struct trn_cell_intro_established_st trn_cell_intro_established_t;
  34. /** Return a newly allocated trn_cell_establish_intro with all
  35. * elements set to zero.
  36. */
  37. trn_cell_establish_intro_t *trn_cell_establish_intro_new(void);
  38. /** Release all storage held by the trn_cell_establish_intro in
  39. * 'victim'. (Do nothing if 'victim' is NULL.)
  40. */
  41. void trn_cell_establish_intro_free(trn_cell_establish_intro_t *victim);
  42. /** Try to parse a trn_cell_establish_intro from the buffer in
  43. * 'input', using up to 'len_in' bytes from the input buffer. On
  44. * success, return the number of bytes consumed and set *output to the
  45. * newly allocated trn_cell_establish_intro_t. On failure, return -2
  46. * if the input appears truncated, and -1 if the input is otherwise
  47. * invalid.
  48. */
  49. ssize_t trn_cell_establish_intro_parse(trn_cell_establish_intro_t **output, const uint8_t *input, const size_t len_in);
  50. /** Return the number of bytes we expect to need to encode the
  51. * trn_cell_establish_intro in 'obj'. On failure, return a negative
  52. * value. Note that this value may be an overestimate, and can even be
  53. * an underestimate for certain unencodeable objects.
  54. */
  55. ssize_t trn_cell_establish_intro_encoded_len(const trn_cell_establish_intro_t *obj);
  56. /** Try to encode the trn_cell_establish_intro from 'input' into the
  57. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  58. * On success, return the number of bytes used. On failure, return -2
  59. * if the buffer was not long enough, and -1 if the input was invalid.
  60. */
  61. ssize_t trn_cell_establish_intro_encode(uint8_t *output, size_t avail, const trn_cell_establish_intro_t *input);
  62. /** Check whether the internal state of the trn_cell_establish_intro
  63. * in 'obj' is consistent. Return NULL if it is, and a short message
  64. * if it is not.
  65. */
  66. const char *trn_cell_establish_intro_check(const trn_cell_establish_intro_t *obj);
  67. /** Clear any errors that were set on the object 'obj' by its setter
  68. * functions. Return true iff errors were cleared.
  69. */
  70. int trn_cell_establish_intro_clear_errors(trn_cell_establish_intro_t *obj);
  71. /** Return the position for start_cell when we parsed this object
  72. */
  73. const uint8_t * trn_cell_establish_intro_get_start_cell(const trn_cell_establish_intro_t *inp);
  74. /** Return the value of the auth_key_type field of the
  75. * trn_cell_establish_intro_t in 'inp'
  76. */
  77. uint8_t trn_cell_establish_intro_get_auth_key_type(const trn_cell_establish_intro_t *inp);
  78. /** Set the value of the auth_key_type field of the
  79. * trn_cell_establish_intro_t in 'inp' to 'val'. Return 0 on success;
  80. * return -1 and set the error code on 'inp' on failure.
  81. */
  82. int trn_cell_establish_intro_set_auth_key_type(trn_cell_establish_intro_t *inp, uint8_t val);
  83. /** Return the value of the auth_key_len field of the
  84. * trn_cell_establish_intro_t in 'inp'
  85. */
  86. uint16_t trn_cell_establish_intro_get_auth_key_len(const trn_cell_establish_intro_t *inp);
  87. /** Set the value of the auth_key_len field of the
  88. * trn_cell_establish_intro_t in 'inp' to 'val'. Return 0 on success;
  89. * return -1 and set the error code on 'inp' on failure.
  90. */
  91. int trn_cell_establish_intro_set_auth_key_len(trn_cell_establish_intro_t *inp, uint16_t val);
  92. /** Return the length of the dynamic array holding the auth_key field
  93. * of the trn_cell_establish_intro_t in 'inp'.
  94. */
  95. size_t trn_cell_establish_intro_getlen_auth_key(const trn_cell_establish_intro_t *inp);
  96. /** Return the element at position 'idx' of the dynamic array field
  97. * auth_key of the trn_cell_establish_intro_t in 'inp'.
  98. */
  99. uint8_t trn_cell_establish_intro_get_auth_key(trn_cell_establish_intro_t *inp, size_t idx);
  100. /** As trn_cell_establish_intro_get_auth_key, but take and return a
  101. * const pointer
  102. */
  103. uint8_t trn_cell_establish_intro_getconst_auth_key(const trn_cell_establish_intro_t *inp, size_t idx);
  104. /** Change the element at position 'idx' of the dynamic array field
  105. * auth_key of the trn_cell_establish_intro_t in 'inp', so that it
  106. * will hold the value 'elt'.
  107. */
  108. int trn_cell_establish_intro_set_auth_key(trn_cell_establish_intro_t *inp, size_t idx, uint8_t elt);
  109. /** Append a new element 'elt' to the dynamic array field auth_key of
  110. * the trn_cell_establish_intro_t in 'inp'.
  111. */
  112. int trn_cell_establish_intro_add_auth_key(trn_cell_establish_intro_t *inp, uint8_t elt);
  113. /** Return a pointer to the variable-length array field auth_key of
  114. * 'inp'.
  115. */
  116. uint8_t * trn_cell_establish_intro_getarray_auth_key(trn_cell_establish_intro_t *inp);
  117. /** As trn_cell_establish_intro_get_auth_key, but take and return a
  118. * const pointer
  119. */
  120. const uint8_t * trn_cell_establish_intro_getconstarray_auth_key(const trn_cell_establish_intro_t *inp);
  121. /** Change the length of the variable-length array field auth_key of
  122. * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
  123. * return -1 and set the error code on 'inp' on failure.
  124. */
  125. int trn_cell_establish_intro_setlen_auth_key(trn_cell_establish_intro_t *inp, size_t newlen);
  126. /** Return the value of the extensions field of the
  127. * trn_cell_establish_intro_t in 'inp'
  128. */
  129. struct trn_cell_extension_st * trn_cell_establish_intro_get_extensions(trn_cell_establish_intro_t *inp);
  130. /** As trn_cell_establish_intro_get_extensions, but take and return a
  131. * const pointer
  132. */
  133. const struct trn_cell_extension_st * trn_cell_establish_intro_getconst_extensions(const trn_cell_establish_intro_t *inp);
  134. /** Set the value of the extensions field of the
  135. * trn_cell_establish_intro_t in 'inp' to 'val'. Free the old value if
  136. * any. Steals the referenceto 'val'.Return 0 on success; return -1
  137. * and set the error code on 'inp' on failure.
  138. */
  139. int trn_cell_establish_intro_set_extensions(trn_cell_establish_intro_t *inp, struct trn_cell_extension_st *val);
  140. /** As trn_cell_establish_intro_set_extensions, but does not free the
  141. * previous value.
  142. */
  143. int trn_cell_establish_intro_set0_extensions(trn_cell_establish_intro_t *inp, struct trn_cell_extension_st *val);
  144. /** Return the position for end_mac_fields when we parsed this object
  145. */
  146. const uint8_t * trn_cell_establish_intro_get_end_mac_fields(const trn_cell_establish_intro_t *inp);
  147. /** Return the (constant) length of the array holding the
  148. * handshake_mac field of the trn_cell_establish_intro_t in 'inp'.
  149. */
  150. size_t trn_cell_establish_intro_getlen_handshake_mac(const trn_cell_establish_intro_t *inp);
  151. /** Return the element at position 'idx' of the fixed array field
  152. * handshake_mac of the trn_cell_establish_intro_t in 'inp'.
  153. */
  154. uint8_t trn_cell_establish_intro_get_handshake_mac(trn_cell_establish_intro_t *inp, size_t idx);
  155. /** As trn_cell_establish_intro_get_handshake_mac, but take and return
  156. * a const pointer
  157. */
  158. uint8_t trn_cell_establish_intro_getconst_handshake_mac(const trn_cell_establish_intro_t *inp, size_t idx);
  159. /** Change the element at position 'idx' of the fixed array field
  160. * handshake_mac of the trn_cell_establish_intro_t in 'inp', so that
  161. * it will hold the value 'elt'.
  162. */
  163. int trn_cell_establish_intro_set_handshake_mac(trn_cell_establish_intro_t *inp, size_t idx, uint8_t elt);
  164. /** Return a pointer to the TRUNNEL_SHA3_256_LEN-element array field
  165. * handshake_mac of 'inp'.
  166. */
  167. uint8_t * trn_cell_establish_intro_getarray_handshake_mac(trn_cell_establish_intro_t *inp);
  168. /** As trn_cell_establish_intro_get_handshake_mac, but take and return
  169. * a const pointer
  170. */
  171. const uint8_t * trn_cell_establish_intro_getconstarray_handshake_mac(const trn_cell_establish_intro_t *inp);
  172. /** Return the position for end_sig_fields when we parsed this object
  173. */
  174. const uint8_t * trn_cell_establish_intro_get_end_sig_fields(const trn_cell_establish_intro_t *inp);
  175. /** Return the value of the sig_len field of the
  176. * trn_cell_establish_intro_t in 'inp'
  177. */
  178. uint16_t trn_cell_establish_intro_get_sig_len(const trn_cell_establish_intro_t *inp);
  179. /** Set the value of the sig_len field of the
  180. * trn_cell_establish_intro_t in 'inp' to 'val'. Return 0 on success;
  181. * return -1 and set the error code on 'inp' on failure.
  182. */
  183. int trn_cell_establish_intro_set_sig_len(trn_cell_establish_intro_t *inp, uint16_t val);
  184. /** Return the length of the dynamic array holding the sig field of
  185. * the trn_cell_establish_intro_t in 'inp'.
  186. */
  187. size_t trn_cell_establish_intro_getlen_sig(const trn_cell_establish_intro_t *inp);
  188. /** Return the element at position 'idx' of the dynamic array field
  189. * sig of the trn_cell_establish_intro_t in 'inp'.
  190. */
  191. uint8_t trn_cell_establish_intro_get_sig(trn_cell_establish_intro_t *inp, size_t idx);
  192. /** As trn_cell_establish_intro_get_sig, but take and return a const
  193. * pointer
  194. */
  195. uint8_t trn_cell_establish_intro_getconst_sig(const trn_cell_establish_intro_t *inp, size_t idx);
  196. /** Change the element at position 'idx' of the dynamic array field
  197. * sig of the trn_cell_establish_intro_t in 'inp', so that it will
  198. * hold the value 'elt'.
  199. */
  200. int trn_cell_establish_intro_set_sig(trn_cell_establish_intro_t *inp, size_t idx, uint8_t elt);
  201. /** Append a new element 'elt' to the dynamic array field sig of the
  202. * trn_cell_establish_intro_t in 'inp'.
  203. */
  204. int trn_cell_establish_intro_add_sig(trn_cell_establish_intro_t *inp, uint8_t elt);
  205. /** Return a pointer to the variable-length array field sig of 'inp'.
  206. */
  207. uint8_t * trn_cell_establish_intro_getarray_sig(trn_cell_establish_intro_t *inp);
  208. /** As trn_cell_establish_intro_get_sig, but take and return a const
  209. * pointer
  210. */
  211. const uint8_t * trn_cell_establish_intro_getconstarray_sig(const trn_cell_establish_intro_t *inp);
  212. /** Change the length of the variable-length array field sig of 'inp'
  213. * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
  214. * -1 and set the error code on 'inp' on failure.
  215. */
  216. int trn_cell_establish_intro_setlen_sig(trn_cell_establish_intro_t *inp, size_t newlen);
  217. /** Return a newly allocated trn_cell_intro_established with all
  218. * elements set to zero.
  219. */
  220. trn_cell_intro_established_t *trn_cell_intro_established_new(void);
  221. /** Release all storage held by the trn_cell_intro_established in
  222. * 'victim'. (Do nothing if 'victim' is NULL.)
  223. */
  224. void trn_cell_intro_established_free(trn_cell_intro_established_t *victim);
  225. /** Try to parse a trn_cell_intro_established from the buffer in
  226. * 'input', using up to 'len_in' bytes from the input buffer. On
  227. * success, return the number of bytes consumed and set *output to the
  228. * newly allocated trn_cell_intro_established_t. On failure, return -2
  229. * if the input appears truncated, and -1 if the input is otherwise
  230. * invalid.
  231. */
  232. ssize_t trn_cell_intro_established_parse(trn_cell_intro_established_t **output, const uint8_t *input, const size_t len_in);
  233. /** Return the number of bytes we expect to need to encode the
  234. * trn_cell_intro_established in 'obj'. On failure, return a negative
  235. * value. Note that this value may be an overestimate, and can even be
  236. * an underestimate for certain unencodeable objects.
  237. */
  238. ssize_t trn_cell_intro_established_encoded_len(const trn_cell_intro_established_t *obj);
  239. /** Try to encode the trn_cell_intro_established from 'input' into the
  240. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  241. * On success, return the number of bytes used. On failure, return -2
  242. * if the buffer was not long enough, and -1 if the input was invalid.
  243. */
  244. ssize_t trn_cell_intro_established_encode(uint8_t *output, size_t avail, const trn_cell_intro_established_t *input);
  245. /** Check whether the internal state of the trn_cell_intro_established
  246. * in 'obj' is consistent. Return NULL if it is, and a short message
  247. * if it is not.
  248. */
  249. const char *trn_cell_intro_established_check(const trn_cell_intro_established_t *obj);
  250. /** Clear any errors that were set on the object 'obj' by its setter
  251. * functions. Return true iff errors were cleared.
  252. */
  253. int trn_cell_intro_established_clear_errors(trn_cell_intro_established_t *obj);
  254. /** Return the value of the extensions field of the
  255. * trn_cell_intro_established_t in 'inp'
  256. */
  257. struct trn_cell_extension_st * trn_cell_intro_established_get_extensions(trn_cell_intro_established_t *inp);
  258. /** As trn_cell_intro_established_get_extensions, but take and return
  259. * a const pointer
  260. */
  261. const struct trn_cell_extension_st * trn_cell_intro_established_getconst_extensions(const trn_cell_intro_established_t *inp);
  262. /** Set the value of the extensions field of the
  263. * trn_cell_intro_established_t in 'inp' to 'val'. Free the old value
  264. * if any. Steals the referenceto 'val'.Return 0 on success; return -1
  265. * and set the error code on 'inp' on failure.
  266. */
  267. int trn_cell_intro_established_set_extensions(trn_cell_intro_established_t *inp, struct trn_cell_extension_st *val);
  268. /** As trn_cell_intro_established_set_extensions, but does not free
  269. * the previous value.
  270. */
  271. int trn_cell_intro_established_set0_extensions(trn_cell_intro_established_t *inp, struct trn_cell_extension_st *val);
  272. #endif