tor

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

hs_circuit.h (4954B)


      1 /* Copyright (c) 2017-2021, The Tor Project, Inc. */
      2 /* See LICENSE for licensing information */
      3 
      4 /**
      5 * \file hs_circuit.h
      6 * \brief Header file containing circuit data for the whole HS subsystem.
      7 **/
      8 
      9 #ifndef TOR_HS_CIRCUIT_H
     10 #define TOR_HS_CIRCUIT_H
     11 
     12 #include "core/or/or.h"
     13 #include "lib/crypt_ops/crypto_ed25519.h"
     14 
     15 #include "feature/hs/hs_cell.h"
     16 #include "feature/hs/hs_service.h"
     17 
     18 /** Pending rendezvous request. This is put in a service priority queue. */
     19 typedef struct pending_rend_t {
     20  /* Intro point authentication pubkey. */
     21  ed25519_public_key_t ip_auth_pubkey;
     22  /* Intro point encryption keypair for the "ntor" type. */
     23  curve25519_keypair_t ip_enc_key_kp;
     24 
     25  /* Rendezvous data for the circuit. */
     26  hs_cell_intro_rdv_data_t rdv_data;
     27 
     28  /** Position of element in the heap */
     29  int idx;
     30 
     31  /** When was this request enqueued. */
     32  time_t enqueued_ts;
     33 } pending_rend_t;
     34 
     35 int top_of_rend_pqueue_is_worthwhile(hs_pow_service_state_t *pow_state);
     36 void rend_pqueue_clear(hs_pow_service_state_t *pow_state);
     37 
     38 /* Cleanup function when the circuit is closed or freed. */
     39 void hs_circ_cleanup_on_close(circuit_t *circ);
     40 void hs_circ_cleanup_on_free(circuit_t *circ);
     41 void hs_circ_cleanup_on_repurpose(circuit_t *circ);
     42 
     43 /* Circuit API. */
     44 int hs_circ_service_intro_has_opened(hs_service_t *service,
     45                                     hs_service_intro_point_t *ip,
     46                                     const hs_service_descriptor_t *desc,
     47                                     origin_circuit_t *circ);
     48 void hs_circ_service_rp_has_opened(const hs_service_t *service,
     49                                   origin_circuit_t *circ);
     50 int hs_circ_launch_intro_point(hs_service_t *service,
     51                               const hs_service_intro_point_t *ip,
     52                               extend_info_t *ei,
     53                               bool direct_conn);
     54 int hs_circ_launch_rendezvous_point(const hs_service_t *service,
     55                                    const curve25519_public_key_t *onion_key,
     56                                    const uint8_t *rendezvous_cookie);
     57 void hs_circ_retry_service_rendezvous_point(const origin_circuit_t *circ);
     58 
     59 origin_circuit_t *hs_circ_service_get_intro_circ(
     60                                      const hs_service_intro_point_t *ip);
     61 origin_circuit_t *hs_circ_service_get_established_intro_circ(
     62                                      const hs_service_intro_point_t *ip);
     63 
     64 /* Cell API. */
     65 int hs_circ_handle_intro_established(const hs_service_t *service,
     66                                     const hs_service_intro_point_t *ip,
     67                                     origin_circuit_t *circ,
     68                                     const uint8_t *payload,
     69                                     size_t payload_len);
     70 struct hs_subcredential_t;
     71 int hs_circ_handle_introduce2(const hs_service_t *service,
     72                              const origin_circuit_t *circ,
     73                              hs_service_intro_point_t *ip,
     74                              const struct hs_subcredential_t *subcredential,
     75                              const uint8_t *payload, size_t payload_len);
     76 int hs_circ_send_introduce1(origin_circuit_t *intro_circ,
     77                            origin_circuit_t *rend_circ,
     78                            const hs_desc_intro_point_t *ip,
     79                            const struct hs_subcredential_t *subcredential,
     80                            const hs_pow_solution_t *pow_solution);
     81 int hs_circ_send_establish_rendezvous(origin_circuit_t *circ);
     82 
     83 /* e2e circuit API. */
     84 
     85 int hs_circuit_setup_e2e_rend_circ(origin_circuit_t *circ,
     86                                   const uint8_t *ntor_key_seed,
     87                                   size_t seed_len,
     88                                   int is_service_side);
     89 int hs_circuit_setup_e2e_rend_circ_legacy_client(origin_circuit_t *circ,
     90                                          const uint8_t *rend_cell_body);
     91 
     92 bool hs_circ_is_rend_sent_in_intro1(const origin_circuit_t *circ);
     93 
     94 void hs_circ_setup_congestion_control(origin_circuit_t *origin_circ,
     95                                      uint8_t sendme_inc,
     96                                      bool is_single_onion);
     97 
     98 #ifdef HS_CIRCUIT_PRIVATE
     99 
    100 struct hs_ntor_rend_cell_keys_t;
    101 
    102 STATIC hs_ident_circuit_t *
    103 create_rp_circuit_identifier(const hs_service_t *service,
    104                             const uint8_t *rendezvous_cookie,
    105                             const curve25519_public_key_t *server_pk,
    106                             const struct hs_ntor_rend_cell_keys_t *keys);
    107 
    108 MOCK_DECL(STATIC void,
    109 launch_rendezvous_point_circuit,(const hs_service_t *service,
    110                                 const ed25519_public_key_t *ip_auth_pubkey,
    111                                 const curve25519_keypair_t *ip_enc_key_kp,
    112                                 const hs_cell_intro_rdv_data_t *rdv_data,
    113                                 time_t now));
    114 
    115 #endif /* defined(HS_CIRCUIT_PRIVATE) */
    116 
    117 #endif /* !defined(TOR_HS_CIRCUIT_H) */