hs_circuitmap.h 3.8 KB

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