tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

hs_circuitmap.h (3332B)


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