hs_intropoint.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Copyright (c) 2016-2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file hs_intropoint.h
  5. * \brief Header file for hs_intropoint.c.
  6. **/
  7. #ifndef TOR_HS_INTRO_H
  8. #define TOR_HS_INTRO_H
  9. #include "crypto_curve25519.h"
  10. #include "torcert.h"
  11. /* Authentication key type in an ESTABLISH_INTRO cell. */
  12. enum hs_intro_auth_key_type {
  13. HS_INTRO_AUTH_KEY_TYPE_LEGACY0 = 0x00,
  14. HS_INTRO_AUTH_KEY_TYPE_LEGACY1 = 0x01,
  15. HS_INTRO_AUTH_KEY_TYPE_ED25519 = 0x02,
  16. };
  17. /* INTRODUCE_ACK status code. */
  18. typedef enum {
  19. HS_INTRO_ACK_STATUS_SUCCESS = 0x0000,
  20. HS_INTRO_ACK_STATUS_UNKNOWN_ID = 0x0001,
  21. HS_INTRO_ACK_STATUS_BAD_FORMAT = 0x0002,
  22. HS_INTRO_ACK_STATUS_CANT_RELAY = 0x0003,
  23. } hs_intro_ack_status_t;
  24. /* Object containing introduction point common data between the service and
  25. * the client side. */
  26. typedef struct hs_intropoint_t {
  27. /* Authentication key certificate from the descriptor. */
  28. tor_cert_t *auth_key_cert;
  29. /* A list of link specifier. */
  30. smartlist_t *link_specifiers;
  31. } hs_intropoint_t;
  32. int hs_intro_received_establish_intro(or_circuit_t *circ,
  33. const uint8_t *request,
  34. size_t request_len);
  35. int hs_intro_received_introduce1(or_circuit_t *circ, const uint8_t *request,
  36. size_t request_len);
  37. MOCK_DECL(int, hs_intro_send_intro_established_cell,(or_circuit_t *circ));
  38. /* also used by rendservice.c */
  39. int hs_intro_circuit_is_suitable_for_establish_intro(const or_circuit_t *circ);
  40. #ifdef HS_INTROPOINT_PRIVATE
  41. #include "hs/cell_establish_intro.h"
  42. #include "hs/cell_introduce1.h"
  43. STATIC int
  44. verify_establish_intro_cell(const trn_cell_establish_intro_t *out,
  45. const uint8_t *circuit_key_material,
  46. size_t circuit_key_material_len);
  47. STATIC void
  48. get_auth_key_from_cell(ed25519_public_key_t *auth_key_out,
  49. unsigned int cell_type, const void *cell);
  50. STATIC int introduce1_cell_is_legacy(const uint8_t *request);
  51. STATIC int handle_introduce1(or_circuit_t *client_circ,
  52. const uint8_t *request, size_t request_len);
  53. STATIC int validate_introduce1_parsed_cell(const trn_cell_introduce1_t *cell);
  54. STATIC int circuit_is_suitable_for_introduce1(const or_circuit_t *circ);
  55. #endif /* HS_INTROPOINT_PRIVATE */
  56. #endif /* TOR_HS_INTRO_H */