rendcommon.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 rendcommon.h
  8. * \brief Header file for rendcommon.c.
  9. **/
  10. #ifndef TOR_RENDCOMMON_H
  11. #define TOR_RENDCOMMON_H
  12. typedef enum rend_intro_point_failure_t {
  13. INTRO_POINT_FAILURE_GENERIC = 0,
  14. INTRO_POINT_FAILURE_TIMEOUT = 1,
  15. INTRO_POINT_FAILURE_UNREACHABLE = 2,
  16. } rend_intro_point_failure_t;
  17. /** Free all storage associated with <b>data</b> */
  18. static inline void
  19. rend_data_free(rend_data_t *data)
  20. {
  21. if (!data) {
  22. return;
  23. }
  24. /* Cleanup the HSDir identity digest. */
  25. SMARTLIST_FOREACH(data->hsdirs_fp, char *, d, tor_free(d));
  26. smartlist_free(data->hsdirs_fp);
  27. tor_free(data);
  28. }
  29. int rend_cmp_service_ids(const char *one, const char *two);
  30. void rend_process_relay_cell(circuit_t *circ, const crypt_path_t *layer_hint,
  31. int command, size_t length,
  32. const uint8_t *payload);
  33. void rend_service_descriptor_free(rend_service_descriptor_t *desc);
  34. int rend_get_service_id(crypto_pk_t *pk, char *out);
  35. void rend_encoded_v2_service_descriptor_free(
  36. rend_encoded_v2_service_descriptor_t *desc);
  37. void rend_intro_point_free(rend_intro_point_t *intro);
  38. int rend_valid_service_id(const char *query);
  39. int rend_valid_descriptor_id(const char *query);
  40. int rend_valid_client_name(const char *client_name);
  41. int rend_encode_v2_descriptors(smartlist_t *descs_out,
  42. rend_service_descriptor_t *desc, time_t now,
  43. uint8_t period, rend_auth_type_t auth_type,
  44. crypto_pk_t *client_key,
  45. smartlist_t *client_cookies);
  46. int rend_compute_v2_desc_id(char *desc_id_out, const char *service_id,
  47. const char *descriptor_cookie,
  48. time_t now, uint8_t replica);
  49. void rend_get_descriptor_id_bytes(char *descriptor_id_out,
  50. const char *service_id,
  51. const char *secret_id_part);
  52. int hid_serv_get_responsible_directories(smartlist_t *responsible_dirs,
  53. const char *id);
  54. rend_data_t *rend_data_dup(const rend_data_t *data);
  55. rend_data_t *rend_data_client_create(const char *onion_address,
  56. const char *desc_id,
  57. const char *cookie,
  58. rend_auth_type_t auth_type);
  59. rend_data_t *rend_data_service_create(const char *onion_address,
  60. const char *pk_digest,
  61. const uint8_t *cookie,
  62. rend_auth_type_t auth_type);
  63. char *rend_auth_encode_cookie(const uint8_t *cookie_in,
  64. rend_auth_type_t auth_type);
  65. int rend_auth_decode_cookie(const char *cookie_in,
  66. uint8_t *cookie_out,
  67. rend_auth_type_t *auth_type_out,
  68. char **err_msg_out);
  69. #endif