hs_circuitmap.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. struct origin_circuit_t *
  37. hs_circuitmap_get_rend_circ_client_side(const uint8_t *cookie);
  38. struct origin_circuit_t *
  39. hs_circuitmap_get_established_rend_circ_client_side(const uint8_t *cookie);
  40. void hs_circuitmap_register_intro_circ_v2_service_side(
  41. struct origin_circuit_t *circ,
  42. const uint8_t *digest);
  43. void hs_circuitmap_register_intro_circ_v3_service_side(
  44. struct origin_circuit_t *circ,
  45. const ed25519_public_key_t *auth_key);
  46. void hs_circuitmap_register_rend_circ_service_side(
  47. struct origin_circuit_t *circ,
  48. const uint8_t *cookie);
  49. void hs_circuitmap_register_rend_circ_client_side(
  50. struct origin_circuit_t *circ,
  51. const uint8_t *cookie);
  52. void hs_circuitmap_remove_circuit(struct circuit_t *circ);
  53. void hs_circuitmap_init(void);
  54. void hs_circuitmap_free_all(void);
  55. #ifdef HS_CIRCUITMAP_PRIVATE
  56. /** Represents the type of HS token. */
  57. typedef enum {
  58. /** A rendezvous cookie on a relay (128bit)*/
  59. HS_TOKEN_REND_RELAY_SIDE,
  60. /** A v2 introduction point pubkey on a relay (160bit) */
  61. HS_TOKEN_INTRO_V2_RELAY_SIDE,
  62. /** A v3 introduction point pubkey on a relay (256bit) */
  63. HS_TOKEN_INTRO_V3_RELAY_SIDE,
  64. /** A rendezvous cookie on a hidden service (128bit)*/
  65. HS_TOKEN_REND_SERVICE_SIDE,
  66. /** A v2 introduction point pubkey on a hidden service (160bit) */
  67. HS_TOKEN_INTRO_V2_SERVICE_SIDE,
  68. /** A v3 introduction point pubkey on a hidden service (256bit) */
  69. HS_TOKEN_INTRO_V3_SERVICE_SIDE,
  70. /** A rendezvous cookie on the client side (128bit) */
  71. HS_TOKEN_REND_CLIENT_SIDE,
  72. } hs_token_type_t;
  73. /** Represents a token used in the HS protocol. Each such token maps to a
  74. * specific introduction or rendezvous circuit. */
  75. struct hs_token_s {
  76. /* Type of HS token. */
  77. hs_token_type_t type;
  78. /* The size of the token (depends on the type). */
  79. size_t token_len;
  80. /* The token itself. Memory allocated at runtime. */
  81. uint8_t *token;
  82. };
  83. #endif /* defined(HS_CIRCUITMAP_PRIVATE) */
  84. #ifdef TOR_UNIT_TESTS
  85. hs_circuitmap_ht *get_hs_circuitmap(void);
  86. #endif /* TOR_UNIT_TESTS */
  87. #endif /* !defined(TOR_HS_CIRCUITMAP_H) */