Tor  0.4.8.0-alpha-dev
hs_cell.h
Go to the documentation of this file.
1 /* Copyright (c) 2017-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 /**
5  * \file hs_cell.h
6  * \brief Header file containing cell data for the whole HS subsystem.
7  **/
8 
9 #ifndef TOR_HS_CELL_H
10 #define TOR_HS_CELL_H
11 
12 #include "core/or/or.h"
13 #include "feature/hs/hs_service.h"
14 
15 /** An INTRODUCE1 cell requires at least this amount of bytes (see section
16  * 3.2.2 of the specification). Below this value, the cell must be padded. */
17 #define HS_CELL_INTRODUCE1_MIN_SIZE 246
18 
19 struct hs_subcredential_t;
20 
21 /** This data structure contains data that we need to build an INTRODUCE1 cell
22  * used by the INTRODUCE1 build function. */
23 typedef struct hs_cell_introduce1_data_t {
24  /** Is this a legacy introduction point? */
25  unsigned int is_legacy : 1;
26  /** (Legacy only) The encryption key for a legacy intro point. Only set if
27  * is_legacy is true. */
29  /** Introduction point authentication public key. */
31  /** Introduction point encryption public key. */
33  /** Subcredentials of the service. */
35  /** Onion public key for the ntor handshake. */
37  /** Rendezvous cookie. */
38  const uint8_t *rendezvous_cookie;
39  /** Public key put before the encrypted data (CLIENT_PK). */
41  /** Rendezvous point link specifiers. */
43  /** Congestion control parameters. */
44  unsigned int cc_enabled : 1;
46 
47 /** This data structure contains data that we need to parse an INTRODUCE2 cell
48  * which is used by the INTRODUCE2 cell parsing function. On a successful
49  * parsing, the onion_pk and rendezvous_cookie will be populated with the
50  * computed key material from the cell data. This structure is only used during
51  * INTRO2 parsing and discarded after that. */
52 typedef struct hs_cell_introduce2_data_t {
53  /*** Immutable Section: Set on structure init. ***/
54 
55  /** Introduction point authentication public key. Pointer owned by the
56  introduction point object through which we received the INTRO2 cell. */
58  /** Introduction point encryption keypair for the ntor handshake. Pointer
59  owned by the introduction point object through which we received the
60  INTRO2 cell*/
62  /**
63  * Length of the subcredentials array below.
64  **/
66  /** Array of <b>n_subcredentials</b> subcredentials for the service. Pointer
67  * owned by the descriptor that owns the introduction point through which we
68  * received the INTRO2 cell. */
70  /** Payload of the received encoded cell. */
71  const uint8_t *payload;
72  /** Size of the payload of the received encoded cell. */
73  size_t payload_len;
74 
75  /*** Mutable Section: Set upon parsing INTRODUCE2 cell. ***/
76 
77  /** Onion public key computed using the INTRODUCE2 encrypted section. */
79  /** Rendezvous cookie taken from the INTRODUCE2 encrypted section. */
81  /** Client public key from the INTRODUCE2 encrypted section. */
83  /** Link specifiers of the rendezvous point. Contains link_specifier_t. */
85  /** Replay cache of the introduction point. */
86  replaycache_t *replay_cache;
87  /** Flow control negotiation parameters. */
89  /** Congestion control parameters. */
90  unsigned int cc_enabled : 1;
92 
93 /* Build cell API. */
94 ssize_t hs_cell_build_establish_intro(const char *circ_nonce,
95  const hs_service_config_t *config,
96  const hs_service_intro_point_t *ip,
97  uint8_t *cell_out);
98 ssize_t hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie,
99  size_t rendezvous_cookie_len,
100  const uint8_t *rendezvous_handshake_info,
101  size_t rendezvous_handshake_info_len,
102  uint8_t *cell_out);
104  uint8_t *cell_out);
105 ssize_t hs_cell_build_establish_rendezvous(const uint8_t *rendezvous_cookie,
106  uint8_t *cell_out);
107 
108 /* Parse cell API. */
109 ssize_t hs_cell_parse_intro_established(const uint8_t *payload,
110  size_t payload_len);
112  const origin_circuit_t *circ,
113  const hs_service_t *service);
114 int hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len);
115 int hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len,
116  uint8_t *handshake_info,
117  size_t handshake_info_len);
118 
119 /* Util API. */
121 
122 #ifdef TOR_UNIT_TESTS
123 
124 #include "trunnel/extension.h"
125 
126 STATIC trn_extension_t *
128  const hs_service_intro_point_t *ip);
129 
130 #endif /* defined(TOR_UNIT_TESTS) */
131 
132 #endif /* !defined(TOR_HS_CELL_H) */
STATIC trn_extension_t * build_establish_intro_extensions(const hs_service_config_t *service_config, const hs_service_intro_point_t *ip)
Definition: hs_cell.c:554
ssize_t hs_cell_build_establish_rendezvous(const uint8_t *rendezvous_cookie, uint8_t *cell_out)
Definition: hs_cell.c:1055
ssize_t hs_cell_build_establish_intro(const char *circ_nonce, const hs_service_config_t *config, const hs_service_intro_point_t *ip, uint8_t *cell_out)
Definition: hs_cell.c:587
ssize_t hs_cell_parse_intro_established(const uint8_t *payload, size_t payload_len)
Definition: hs_cell.c:701
int hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len)
Definition: hs_cell.c:1069
void hs_cell_introduce1_data_clear(hs_cell_introduce1_data_t *data)
Definition: hs_cell.c:1122
ssize_t hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie, size_t rendezvous_cookie_len, const uint8_t *rendezvous_handshake_info, size_t rendezvous_handshake_info_len, uint8_t *cell_out)
Definition: hs_cell.c:980
ssize_t hs_cell_build_introduce1(const hs_cell_introduce1_data_t *data, uint8_t *cell_out)
Definition: hs_cell.c:1015
int hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len, uint8_t *handshake_info, size_t handshake_info_len)
Definition: hs_cell.c:1092
ssize_t hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data, const origin_circuit_t *circ, const hs_service_t *service)
Definition: hs_cell.c:817
Header file containing service data for the HS subsystem.
Master header file for Tor-specific functionality.
#define REND_COOKIE_LEN
Definition: or.h:344
const ed25519_public_key_t * auth_pk
Definition: hs_cell.h:30
const struct hs_subcredential_t * subcredential
Definition: hs_cell.h:34
unsigned int is_legacy
Definition: hs_cell.h:25
const curve25519_keypair_t * client_kp
Definition: hs_cell.h:40
const curve25519_public_key_t * enc_pk
Definition: hs_cell.h:32
unsigned int cc_enabled
Definition: hs_cell.h:44
const crypto_pk_t * legacy_key
Definition: hs_cell.h:28
const uint8_t * rendezvous_cookie
Definition: hs_cell.h:38
const curve25519_public_key_t * onion_pk
Definition: hs_cell.h:36
smartlist_t * link_specifiers
Definition: hs_cell.h:42
curve25519_public_key_t onion_pk
Definition: hs_cell.h:78
protover_summary_flags_t pv
Definition: hs_cell.h:88
const ed25519_public_key_t * auth_pk
Definition: hs_cell.h:57
const curve25519_keypair_t * enc_kp
Definition: hs_cell.h:61
uint8_t rendezvous_cookie[REND_COOKIE_LEN]
Definition: hs_cell.h:80
replaycache_t * replay_cache
Definition: hs_cell.h:86
unsigned int cc_enabled
Definition: hs_cell.h:90
const struct hs_subcredential_t * subcredentials
Definition: hs_cell.h:69
const uint8_t * payload
Definition: hs_cell.h:71
curve25519_public_key_t client_pk
Definition: hs_cell.h:82
smartlist_t * link_specifiers
Definition: hs_cell.h:84
#define STATIC
Definition: testsupport.h:32