hs_circuitmap.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Copyright (c) 2016-2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file hs_circuitmap.h
  5. * \brief Header file for hs_circuitmap.c.
  6. **/
  7. #ifndef TOR_HS_CIRCUITMAP_H
  8. #define TOR_HS_CIRCUITMAP_H
  9. typedef HT_HEAD(hs_circuitmap_ht, circuit_t) hs_circuitmap_ht;
  10. typedef struct hs_token_s hs_token_t;
  11. struct or_circuit_t;
  12. struct origin_circuit_t;
  13. /** Public HS circuitmap API: */
  14. /** Public relay-side API: */
  15. struct or_circuit_t *
  16. hs_circuitmap_get_intro_circ_v3_relay_side(const
  17. ed25519_public_key_t *auth_key);
  18. struct or_circuit_t *
  19. hs_circuitmap_get_intro_circ_v2_relay_side(const uint8_t *digest);
  20. struct or_circuit_t *
  21. hs_circuitmap_get_rend_circ_relay_side(const uint8_t *cookie);
  22. void hs_circuitmap_register_rend_circ_relay_side(struct or_circuit_t *circ,
  23. const uint8_t *cookie);
  24. void hs_circuitmap_register_intro_circ_v2_relay_side(struct or_circuit_t *circ,
  25. const uint8_t *digest);
  26. void hs_circuitmap_register_intro_circ_v3_relay_side(struct or_circuit_t *circ,
  27. const ed25519_public_key_t *auth_key);
  28. /** Public service-side API: */
  29. struct origin_circuit_t *
  30. hs_circuitmap_get_intro_circ_v3_service_side(const
  31. ed25519_public_key_t *auth_key);
  32. struct origin_circuit_t *
  33. hs_circuitmap_get_intro_circ_v2_service_side(const uint8_t *digest);
  34. struct origin_circuit_t *
  35. hs_circuitmap_get_rend_circ_service_side(const uint8_t *cookie);
  36. void hs_circuitmap_register_intro_circ_v2_service_side(
  37. struct origin_circuit_t *circ,
  38. const uint8_t *digest);
  39. void hs_circuitmap_register_intro_circ_v3_service_side(
  40. struct origin_circuit_t *circ,
  41. const ed25519_public_key_t *auth_key);
  42. void hs_circuitmap_register_rend_circ_service_side(
  43. struct origin_circuit_t *circ,
  44. const uint8_t *cookie);
  45. void hs_circuitmap_remove_circuit(struct circuit_t *circ);
  46. void hs_circuitmap_init(void);
  47. void hs_circuitmap_free_all(void);
  48. #ifdef HS_CIRCUITMAP_PRIVATE
  49. /** Represents the type of HS token. */
  50. typedef enum {
  51. /** A rendezvous cookie on a relay (128bit)*/
  52. HS_TOKEN_REND_RELAY_SIDE,
  53. /** A v2 introduction point pubkey on a relay (160bit) */
  54. HS_TOKEN_INTRO_V2_RELAY_SIDE,
  55. /** A v3 introduction point pubkey on a relay (256bit) */
  56. HS_TOKEN_INTRO_V3_RELAY_SIDE,
  57. /** A rendezvous cookie on a hidden service (128bit)*/
  58. HS_TOKEN_REND_SERVICE_SIDE,
  59. /** A v2 introduction point pubkey on a hidden service (160bit) */
  60. HS_TOKEN_INTRO_V2_SERVICE_SIDE,
  61. /** A v3 introduction point pubkey on a hidden service (256bit) */
  62. HS_TOKEN_INTRO_V3_SERVICE_SIDE,
  63. } hs_token_type_t;
  64. /** Represents a token used in the HS protocol. Each such token maps to a
  65. * specific introduction or rendezvous circuit. */
  66. struct hs_token_s {
  67. /* Type of HS token. */
  68. hs_token_type_t type;
  69. /* The size of the token (depends on the type). */
  70. size_t token_len;
  71. /* The token itself. Memory allocated at runtime. */
  72. uint8_t *token;
  73. };
  74. #endif /* HS_CIRCUITMAP_PRIVATE */
  75. #ifdef TOR_UNIT_TESTS
  76. hs_circuitmap_ht *get_hs_circuitmap(void);
  77. #endif /* TOR_UNIT_TESTS */
  78. #endif /* TOR_HS_CIRCUITMAP_H */