hs_intropoint.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. typedef enum {
  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. } hs_intro_auth_key_type_t;
  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. /* Does this intro point only supports legacy ID ?. */
  28. unsigned int is_only_legacy : 1;
  29. /* Authentication key certificate from the descriptor. */
  30. tor_cert_t *auth_key_cert;
  31. /* A list of link specifier. */
  32. smartlist_t *link_specifiers;
  33. } hs_intropoint_t;
  34. int hs_intro_received_establish_intro(or_circuit_t *circ,
  35. const uint8_t *request,
  36. size_t request_len);
  37. int hs_intro_received_introduce1(or_circuit_t *circ, const uint8_t *request,
  38. size_t request_len);
  39. MOCK_DECL(int, hs_intro_send_intro_established_cell,(or_circuit_t *circ));
  40. /* also used by rendservice.c */
  41. int hs_intro_circuit_is_suitable_for_establish_intro(const or_circuit_t *circ);
  42. hs_intropoint_t *hs_intro_new(void);
  43. void hs_intropoint_clear(hs_intropoint_t *ip);
  44. #ifdef HS_INTROPOINT_PRIVATE
  45. #include "hs/cell_establish_intro.h"
  46. #include "hs/cell_introduce1.h"
  47. STATIC int
  48. verify_establish_intro_cell(const trn_cell_establish_intro_t *out,
  49. const uint8_t *circuit_key_material,
  50. size_t circuit_key_material_len);
  51. STATIC void
  52. get_auth_key_from_cell(ed25519_public_key_t *auth_key_out,
  53. unsigned int cell_type, const void *cell);
  54. STATIC int introduce1_cell_is_legacy(const uint8_t *request);
  55. STATIC int handle_introduce1(or_circuit_t *client_circ,
  56. const uint8_t *request, size_t request_len);
  57. STATIC int validate_introduce1_parsed_cell(const trn_cell_introduce1_t *cell);
  58. STATIC int circuit_is_suitable_for_introduce1(const or_circuit_t *circ);
  59. #endif /* defined(HS_INTROPOINT_PRIVATE) */
  60. #endif /* !defined(TOR_HS_INTRO_H) */