rendservice.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2016, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file rendservice.h
  8. * \brief Header file for rendservice.c.
  9. **/
  10. #ifndef TOR_RENDSERVICE_H
  11. #define TOR_RENDSERVICE_H
  12. #include "or.h"
  13. typedef struct rend_intro_cell_s rend_intro_cell_t;
  14. typedef struct rend_service_port_config_s rend_service_port_config_t;
  15. #ifdef RENDSERVICE_PRIVATE
  16. /* This can be used for both INTRODUCE1 and INTRODUCE2 */
  17. struct rend_intro_cell_s {
  18. /* Is this an INTRODUCE1 or INTRODUCE2? (set to 1 or 2) */
  19. uint8_t type;
  20. /* Public key digest */
  21. uint8_t pk[DIGEST_LEN];
  22. /* Optionally, store ciphertext here */
  23. uint8_t *ciphertext;
  24. ssize_t ciphertext_len;
  25. /* Optionally, store plaintext */
  26. uint8_t *plaintext;
  27. ssize_t plaintext_len;
  28. /* Have we parsed the plaintext? */
  29. uint8_t parsed;
  30. /* intro protocol version (0, 1, 2 or 3) */
  31. uint8_t version;
  32. /* Version-specific parts */
  33. union {
  34. struct {
  35. /* Rendezvous point nickname or hex-encoded key digest */
  36. uint8_t rp[42];
  37. } v0_v1;
  38. struct {
  39. /* The extend_info_t struct has everything v2 uses */
  40. extend_info_t *extend_info;
  41. } v2;
  42. struct {
  43. /* Auth type used */
  44. uint8_t auth_type;
  45. /* Length of auth data */
  46. uint16_t auth_len;
  47. /* Auth data */
  48. uint8_t *auth_data;
  49. /* Rendezvous point's IP address/port, identity digest and onion key */
  50. extend_info_t *extend_info;
  51. } v3;
  52. } u;
  53. /* Rendezvous cookie */
  54. uint8_t rc[REND_COOKIE_LEN];
  55. /* Diffie-Hellman data */
  56. uint8_t dh[DH_KEY_LEN];
  57. };
  58. #endif
  59. int num_rend_services(void);
  60. int rend_config_services(const or_options_t *options, int validate_only);
  61. int rend_service_load_all_keys(void);
  62. void rend_services_add_filenames_to_lists(smartlist_t *open_lst,
  63. smartlist_t *stat_lst);
  64. void rend_consider_services_intro_points(void);
  65. void rend_consider_services_upload(time_t now);
  66. void rend_hsdir_routers_changed(void);
  67. void rend_consider_descriptor_republication(void);
  68. void rend_service_intro_has_opened(origin_circuit_t *circuit);
  69. int rend_service_intro_established(origin_circuit_t *circuit,
  70. const uint8_t *request,
  71. size_t request_len);
  72. void rend_service_rendezvous_has_opened(origin_circuit_t *circuit);
  73. int rend_service_receive_introduction(origin_circuit_t *circuit,
  74. const uint8_t *request,
  75. size_t request_len);
  76. int rend_service_decrypt_intro(rend_intro_cell_t *request,
  77. crypto_pk_t *key,
  78. char **err_msg_out);
  79. void rend_service_free_intro(rend_intro_cell_t *request);
  80. rend_intro_cell_t * rend_service_begin_parse_intro(const uint8_t *request,
  81. size_t request_len,
  82. uint8_t type,
  83. char **err_msg_out);
  84. int rend_service_parse_intro_plaintext(rend_intro_cell_t *intro,
  85. char **err_msg_out);
  86. int rend_service_validate_intro_late(const rend_intro_cell_t *intro,
  87. char **err_msg_out);
  88. void rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc);
  89. int rend_service_set_connection_addr_port(edge_connection_t *conn,
  90. origin_circuit_t *circ);
  91. void rend_service_dump_stats(int severity);
  92. void rend_service_free_all(void);
  93. rend_service_port_config_t *rend_service_parse_port_config(const char *string,
  94. const char *sep,
  95. char **err_msg_out);
  96. void rend_service_port_config_free(rend_service_port_config_t *p);
  97. /** Return value from rend_service_add_ephemeral. */
  98. typedef enum {
  99. RSAE_BADVIRTPORT = -4, /**< Invalid VIRTPORT/TARGET(s) */
  100. RSAE_ADDREXISTS = -3, /**< Onion address collision */
  101. RSAE_BADPRIVKEY = -2, /**< Invalid public key */
  102. RSAE_INTERNAL = -1, /**< Internal error */
  103. RSAE_OKAY = 0 /**< Service added as expected */
  104. } rend_service_add_ephemeral_status_t;
  105. rend_service_add_ephemeral_status_t rend_service_add_ephemeral(crypto_pk_t *pk,
  106. smartlist_t *ports,
  107. int max_streams_per_circuit,
  108. int max_streams_close_circuit,
  109. char **service_id_out);
  110. int rend_service_del_ephemeral(const char *service_id);
  111. void directory_post_to_hs_dir(rend_service_descriptor_t *renddesc,
  112. smartlist_t *descs, smartlist_t *hs_dirs,
  113. const char *service_id, int seconds_valid);
  114. void rend_service_desc_has_uploaded(const rend_data_t *rend_data);
  115. #endif