rendservice.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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-2013, 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. #ifdef RENDSERVICE_PRIVATE
  15. /* This can be used for both INTRODUCE1 and INTRODUCE2 */
  16. struct rend_intro_cell_s {
  17. /* Is this an INTRODUCE1 or INTRODUCE2? (set to 1 or 2) */
  18. uint8_t type;
  19. /* Public key digest */
  20. uint8_t pk[DIGEST_LEN];
  21. /* Optionally, store ciphertext here */
  22. uint8_t *ciphertext;
  23. ssize_t ciphertext_len;
  24. /* Optionally, store plaintext */
  25. uint8_t *plaintext;
  26. ssize_t plaintext_len;
  27. /* Have we parsed the plaintext? */
  28. uint8_t parsed;
  29. /* intro protocol version (0, 1, 2 or 3) */
  30. uint8_t version;
  31. /* Version-specific parts */
  32. union {
  33. struct {
  34. /* Rendezvous point nickname */
  35. uint8_t rp[20];
  36. } v0;
  37. struct {
  38. /* Rendezvous point nickname or hex-encoded key digest */
  39. uint8_t rp[42];
  40. } v1;
  41. struct {
  42. /* The extend_info_t struct has everything v2 uses */
  43. extend_info_t *extend_info;
  44. } v2;
  45. struct {
  46. /* Auth type used */
  47. uint8_t auth_type;
  48. /* Length of auth data */
  49. uint16_t auth_len;
  50. /* Auth data */
  51. uint8_t *auth_data;
  52. /* Rendezvous point's IP address/port, identity digest and onion key */
  53. extend_info_t *extend_info;
  54. } v3;
  55. } u;
  56. /* Rendezvous cookie */
  57. uint8_t rc[REND_COOKIE_LEN];
  58. /* Diffie-Hellman data */
  59. uint8_t dh[DH_KEY_LEN];
  60. };
  61. #endif
  62. int num_rend_services(void);
  63. int rend_config_services(const or_options_t *options, int validate_only);
  64. int rend_service_load_all_keys(void);
  65. void rend_services_add_filenames_to_lists(smartlist_t *open_lst,
  66. smartlist_t *stat_lst);
  67. void rend_services_introduce(void);
  68. void rend_consider_services_upload(time_t now);
  69. void rend_hsdir_routers_changed(void);
  70. void rend_consider_descriptor_republication(void);
  71. void rend_service_intro_has_opened(origin_circuit_t *circuit);
  72. int rend_service_intro_established(origin_circuit_t *circuit,
  73. const uint8_t *request,
  74. size_t request_len);
  75. void rend_service_rendezvous_has_opened(origin_circuit_t *circuit);
  76. int rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
  77. size_t request_len);
  78. int rend_service_decrypt_intro(rend_intro_cell_t *request,
  79. crypto_pk_t *key,
  80. char **err_msg_out);
  81. void rend_service_free_intro(rend_intro_cell_t *request);
  82. rend_intro_cell_t * rend_service_begin_parse_intro(const uint8_t *request,
  83. size_t request_len,
  84. uint8_t type,
  85. char **err_msg_out);
  86. int rend_service_parse_intro_plaintext(rend_intro_cell_t *intro,
  87. char **err_msg_out);
  88. int rend_service_validate_intro_early(const rend_intro_cell_t *intro,
  89. char **err_msg_out);
  90. int rend_service_validate_intro_late(const rend_intro_cell_t *intro,
  91. char **err_msg_out);
  92. void rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc);
  93. int rend_service_set_connection_addr_port(edge_connection_t *conn,
  94. origin_circuit_t *circ);
  95. void rend_service_dump_stats(int severity);
  96. void rend_service_free_all(void);
  97. #endif