Tor  0.4.7.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. */
44 
45 /** This data structure contains data that we need to parse an INTRODUCE2 cell
46  * which is used by the INTRODUCE2 cell parsing function. On a successful
47  * parsing, the onion_pk and rendezvous_cookie will be populated with the
48  * computed key material from the cell data. This structure is only used during
49  * INTRO2 parsing and discarded after that. */
50 typedef struct hs_cell_introduce2_data_t {
51  /*** Immutable Section: Set on structure init. ***/
52 
53  /** Introduction point authentication public key. Pointer owned by the
54  introduction point object through which we received the INTRO2 cell. */
56  /** Introduction point encryption keypair for the ntor handshake. Pointer
57  owned by the introduction point object through which we received the
58  INTRO2 cell*/
60  /**
61  * Length of the subcredentials array below.
62  **/
64  /** Array of <b>n_subcredentials</b> subcredentials for the service. Pointer
65  * owned by the descriptor that owns the introduction point through which we
66  * received the INTRO2 cell. */
68  /** Payload of the received encoded cell. */
69  const uint8_t *payload;
70  /** Size of the payload of the received encoded cell. */
71  size_t payload_len;
72 
73  /*** Mutable Section: Set upon parsing INTRODUCE2 cell. ***/
74 
75  /** Onion public key computed using the INTRODUCE2 encrypted section. */
77  /** Rendezvous cookie taken from the INTRODUCE2 encrypted section. */
79  /** Client public key from the INTRODUCE2 encrypted section. */
81  /** Link specifiers of the rendezvous point. Contains link_specifier_t. */
83  /** Replay cache of the introduction point. */
84  replaycache_t *replay_cache;
86 
87 /* Build cell API. */
88 ssize_t hs_cell_build_establish_intro(const char *circ_nonce,
89  const hs_service_config_t *config,
90  const hs_service_intro_point_t *ip,
91  uint8_t *cell_out);
92 ssize_t hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie,
93  size_t rendezvous_cookie_len,
94  const uint8_t *rendezvous_handshake_info,
95  size_t rendezvous_handshake_info_len,
96  uint8_t *cell_out);
98  uint8_t *cell_out);
99 ssize_t hs_cell_build_establish_rendezvous(const uint8_t *rendezvous_cookie,
100  uint8_t *cell_out);
101 
102 /* Parse cell API. */
103 ssize_t hs_cell_parse_intro_established(const uint8_t *payload,
104  size_t payload_len);
106  const origin_circuit_t *circ,
107  const hs_service_t *service);
108 int hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len);
109 int hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len,
110  uint8_t *handshake_info,
111  size_t handshake_info_len);
112 
113 /* Util API. */
115 
116 #ifdef TOR_UNIT_TESTS
117 
118 #include "trunnel/hs/cell_common.h"
119 
120 STATIC trn_cell_extension_t *
122  const hs_service_intro_point_t *ip);
123 
124 #endif /* defined(TOR_UNIT_TESTS) */
125 
126 #endif /* !defined(TOR_HS_CELL_H) */
STATIC trn_cell_extension_t * build_establish_intro_extensions(const hs_service_config_t *service_config, const hs_service_intro_point_t *ip)
Definition: hs_cell.c:530
ssize_t hs_cell_build_establish_rendezvous(const uint8_t *rendezvous_cookie, uint8_t *cell_out)
Definition: hs_cell.c:985
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:563
ssize_t hs_cell_parse_intro_established(const uint8_t *payload, size_t payload_len)
Definition: hs_cell.c:677
int hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len)
Definition: hs_cell.c:999
void hs_cell_introduce1_data_clear(hs_cell_introduce1_data_t *data)
Definition: hs_cell.c:1052
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:910
ssize_t hs_cell_build_introduce1(const hs_cell_introduce1_data_t *data, uint8_t *cell_out)
Definition: hs_cell.c:945
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:1022
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:768
Header file containing service data for the HS subsystem.
Master header file for Tor-specific functionality.
#define REND_COOKIE_LEN
Definition: or.h:341
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
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:76
const ed25519_public_key_t * auth_pk
Definition: hs_cell.h:55
const curve25519_keypair_t * enc_kp
Definition: hs_cell.h:59
uint8_t rendezvous_cookie[REND_COOKIE_LEN]
Definition: hs_cell.h:78
replaycache_t * replay_cache
Definition: hs_cell.h:84
const struct hs_subcredential_t * subcredentials
Definition: hs_cell.h:67
const uint8_t * payload
Definition: hs_cell.h:69
curve25519_public_key_t client_pk
Definition: hs_cell.h:80
smartlist_t * link_specifiers
Definition: hs_cell.h:82
#define STATIC
Definition: testsupport.h:32