hs_common.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Copyright (c) 2016-2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file hs_common.h
  5. * \brief Header file containing common data for the whole HS subsytem.
  6. **/
  7. #ifndef TOR_HS_COMMON_H
  8. #define TOR_HS_COMMON_H
  9. #include "or.h"
  10. /* Protocol version 2. Use this instead of hardcoding "2" in the code base,
  11. * this adds a clearer semantic to the value when used. */
  12. #define HS_VERSION_TWO 2
  13. /* Version 3 of the protocol (prop224). */
  14. #define HS_VERSION_THREE 3
  15. /** Try to maintain this many intro points per service by default. */
  16. #define NUM_INTRO_POINTS_DEFAULT 3
  17. /** Maximum number of intro points per service. */
  18. #define NUM_INTRO_POINTS_MAX 10
  19. /** Number of extra intro points we launch if our set of intro nodes is empty.
  20. * See proposal 155, section 4. */
  21. #define NUM_INTRO_POINTS_EXTRA 2
  22. /** If we can't build our intro circuits, don't retry for this long. */
  23. #define INTRO_CIRC_RETRY_PERIOD (60*5)
  24. /** Don't try to build more than this many circuits before giving up for a
  25. * while.*/
  26. #define MAX_INTRO_CIRCS_PER_PERIOD 10
  27. /** How many times will a hidden service operator attempt to connect to a
  28. * requested rendezvous point before giving up? */
  29. #define MAX_REND_FAILURES 1
  30. /** How many seconds should we spend trying to connect to a requested
  31. * rendezvous point before giving up? */
  32. #define MAX_REND_TIMEOUT 30
  33. /* String prefix for the signature of ESTABLISH_INTRO */
  34. #define ESTABLISH_INTRO_SIG_PREFIX "Tor establish-intro cell v1"
  35. /* The default HS time period length */
  36. #define HS_TIME_PERIOD_LENGTH_DEFAULT 1440 /* 1440 minutes == one day */
  37. /* The minimum time period length as seen in prop224 section [TIME-PERIODS] */
  38. #define HS_TIME_PERIOD_LENGTH_MIN 30 /* minutes */
  39. /* The minimum time period length as seen in prop224 section [TIME-PERIODS] */
  40. #define HS_TIME_PERIOD_LENGTH_MAX (60 * 24 * 10) /* 10 days or 14400 minutes */
  41. /* The time period rotation offset as seen in prop224 section [TIME-PERIODS] */
  42. #define HS_TIME_PERIOD_ROTATION_OFFSET (12 * 60) /* minutes */
  43. int hs_check_service_private_dir(const char *username, const char *path,
  44. unsigned int dir_group_readable,
  45. unsigned int create);
  46. int hs_get_service_max_rend_failures(void);
  47. void rend_data_free(rend_data_t *data);
  48. rend_data_t *rend_data_dup(const rend_data_t *data);
  49. rend_data_t *rend_data_client_create(const char *onion_address,
  50. const char *desc_id,
  51. const char *cookie,
  52. rend_auth_type_t auth_type);
  53. rend_data_t *rend_data_service_create(const char *onion_address,
  54. const char *pk_digest,
  55. const uint8_t *cookie,
  56. rend_auth_type_t auth_type);
  57. const char *rend_data_get_address(const rend_data_t *rend_data);
  58. const char *rend_data_get_desc_id(const rend_data_t *rend_data,
  59. uint8_t replica, size_t *len_out);
  60. const uint8_t *rend_data_get_pk_digest(const rend_data_t *rend_data,
  61. size_t *len_out);
  62. uint64_t hs_get_next_time_period_num(time_t now);
  63. #ifdef HS_COMMON_PRIVATE
  64. #ifdef TOR_UNIT_TESTS
  65. STATIC uint64_t get_time_period_length(void);
  66. STATIC uint64_t get_time_period_num(time_t now);
  67. #endif /* TOR_UNIT_TESTS */
  68. #endif /* HS_COMMON_PRIVATE */
  69. #endif /* TOR_HS_COMMON_H */