hs_client.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* Copyright (c) 2017-2019, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file hs_client.h
  5. * \brief Header file containing client data for the HS subsytem.
  6. **/
  7. #ifndef TOR_HS_CLIENT_H
  8. #define TOR_HS_CLIENT_H
  9. #include "lib/crypt_ops/crypto_ed25519.h"
  10. #include "feature/hs/hs_descriptor.h"
  11. #include "feature/hs/hs_ident.h"
  12. /* Status code of a descriptor fetch request. */
  13. typedef enum {
  14. /* Something internally went wrong. */
  15. HS_CLIENT_FETCH_ERROR = -1,
  16. /* The fetch request has been launched successfully. */
  17. HS_CLIENT_FETCH_LAUNCHED = 0,
  18. /* We already have a usable descriptor. No fetch. */
  19. HS_CLIENT_FETCH_HAVE_DESC = 1,
  20. /* No more HSDir available to query. */
  21. HS_CLIENT_FETCH_NO_HSDIRS = 2,
  22. /* The fetch request is not allowed. */
  23. HS_CLIENT_FETCH_NOT_ALLOWED = 3,
  24. /* We are missing information to be able to launch a request. */
  25. HS_CLIENT_FETCH_MISSING_INFO = 4,
  26. /* There is a pending fetch for the requested service. */
  27. HS_CLIENT_FETCH_PENDING = 5,
  28. } hs_client_fetch_status_t;
  29. /** Client-side configuration of authorization for a service. */
  30. typedef struct hs_client_service_authorization_t {
  31. /* An curve25519 secret key used to compute decryption keys that
  32. * allow the client to decrypt the hidden service descriptor. */
  33. curve25519_secret_key_t enc_seckey;
  34. /* An onion address that is used to connect to the onion service. */
  35. char onion_address[HS_SERVICE_ADDR_LEN_BASE32+1];
  36. } hs_client_service_authorization_t;
  37. void hs_client_note_connection_attempt_succeeded(
  38. const edge_connection_t *conn);
  39. int hs_client_decode_descriptor(
  40. const char *desc_str,
  41. const ed25519_public_key_t *service_identity_pk,
  42. hs_descriptor_t **desc);
  43. int hs_client_any_intro_points_usable(const ed25519_public_key_t *service_pk,
  44. const hs_descriptor_t *desc);
  45. int hs_client_refetch_hsdesc(const ed25519_public_key_t *identity_pk);
  46. void hs_client_dir_info_changed(void);
  47. int hs_client_send_introduce1(origin_circuit_t *intro_circ,
  48. origin_circuit_t *rend_circ);
  49. void hs_client_circuit_has_opened(origin_circuit_t *circ);
  50. int hs_client_receive_rendezvous_acked(origin_circuit_t *circ,
  51. const uint8_t *payload,
  52. size_t payload_len);
  53. int hs_client_receive_introduce_ack(origin_circuit_t *circ,
  54. const uint8_t *payload,
  55. size_t payload_len);
  56. int hs_client_receive_rendezvous2(origin_circuit_t *circ,
  57. const uint8_t *payload,
  58. size_t payload_len);
  59. void hs_client_desc_has_arrived(const hs_ident_dir_conn_t *ident);
  60. extend_info_t *hs_client_get_random_intro_from_edge(
  61. const edge_connection_t *edge_conn);
  62. int hs_config_client_authorization(const or_options_t *options,
  63. int validate_only);
  64. int hs_client_reextend_intro_circuit(origin_circuit_t *circ);
  65. void hs_client_close_intro_circuits_from_desc(const hs_descriptor_t *desc);
  66. void hs_client_purge_state(void);
  67. void hs_client_free_all(void);
  68. typedef struct {
  69. time_t timestamp;
  70. size_t size;
  71. char *params;
  72. } HSClientPIRParams;
  73. void hs_client_pir_init(void);
  74. void hs_client_pirparams_insert(const char *digest, size_t size, const char *params);
  75. HSClientPIRParams* hs_client_pirparams_lookup(const char *digest);
  76. #ifdef HS_CLIENT_PRIVATE
  77. STATIC int auth_key_filename_is_valid(const char *filename);
  78. STATIC hs_client_service_authorization_t *
  79. parse_auth_file_content(const char *client_key_str);
  80. STATIC routerstatus_t *
  81. pick_hsdir_v3(const ed25519_public_key_t *onion_identity_pk);
  82. STATIC extend_info_t *
  83. client_get_random_intro(const ed25519_public_key_t *service_pk);
  84. STATIC extend_info_t *
  85. desc_intro_point_to_extend_info(const hs_desc_intro_point_t *ip);
  86. STATIC int handle_rendezvous2(origin_circuit_t *circ, const uint8_t *payload,
  87. size_t payload_len);
  88. MOCK_DECL(STATIC hs_client_fetch_status_t,
  89. fetch_v3_desc, (const ed25519_public_key_t *onion_identity_pk));
  90. STATIC void retry_all_socks_conn_waiting_for_desc(void);
  91. #ifdef TOR_UNIT_TESTS
  92. STATIC digest256map_t *get_hs_client_auths_map(void);
  93. #endif /* defined(TOR_UNIT_TESTS) */
  94. #endif /* defined(HS_CLIENT_PRIVATE) */
  95. #endif /* !defined(TOR_HS_CLIENT_H) */