hs_circuitmap.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. /** Public HS circuitmap API: */
  13. struct or_circuit_t *hs_circuitmap_get_rend_circ(const uint8_t *cookie);
  14. struct or_circuit_t *hs_circuitmap_get_intro_circ_v3(
  15. const ed25519_public_key_t *auth_key);
  16. struct or_circuit_t *hs_circuitmap_get_intro_circ_v2(const uint8_t *digest);
  17. void hs_circuitmap_register_rend_circ(struct or_circuit_t *circ,
  18. const uint8_t *cookie);
  19. void hs_circuitmap_register_intro_circ_v2(struct or_circuit_t *circ,
  20. const uint8_t *digest);
  21. void hs_circuitmap_register_intro_circ_v3(struct or_circuit_t *circ,
  22. const ed25519_public_key_t *auth_key);
  23. void hs_circuitmap_remove_circuit(struct circuit_t *circ);
  24. void hs_circuitmap_init(void);
  25. void hs_circuitmap_free_all(void);
  26. #ifdef HS_CIRCUITMAP_PRIVATE
  27. /** Represents the type of HS token. */
  28. typedef enum {
  29. /** A rendezvous cookie (128bit)*/
  30. HS_TOKEN_REND,
  31. /** A v2 introduction point pubkey (160bit) */
  32. HS_TOKEN_INTRO_V2,
  33. /** A v3 introduction point pubkey (256bit) */
  34. HS_TOKEN_INTRO_V3,
  35. } hs_token_type_t;
  36. /** Represents a token used in the HS protocol. Each such token maps to a
  37. * specific introduction or rendezvous circuit. */
  38. struct hs_token_s {
  39. /* Type of HS token. */
  40. hs_token_type_t type;
  41. /* The size of the token (depends on the type). */
  42. size_t token_len;
  43. /* The token itself. Memory allocated at runtime. */
  44. uint8_t *token;
  45. };
  46. #endif /* HS_CIRCUITMAP_PRIVATE */
  47. #ifdef TOR_UNIT_TESTS
  48. hs_circuitmap_ht *get_hs_circuitmap(void);
  49. #endif /* TOR_UNIT_TESTS */
  50. #endif /* TOR_HS_CIRCUITMAP_H */