Tor 0.4.9.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"
14#include "feature/hs/hs_pow.h"
15
16/** An INTRODUCE1 cell requires at least this amount of bytes (see section
17 * 3.2.2 of the specification). Below this value, the cell must be padded. */
18#define HS_CELL_INTRODUCE1_MIN_SIZE 246
19
21
22/** This data structure contains data that we need to build an INTRODUCE1 cell
23 * used by the INTRODUCE1 build function. */
25 /** Is this a legacy introduction point? */
26 unsigned int is_legacy : 1;
27 /** (Legacy only) The encryption key for a legacy intro point. Only set if
28 * is_legacy is true. */
30 /** Introduction point authentication public key. */
32 /** Introduction point encryption public key. */
34 /** Subcredentials of the service. */
36 /** Onion public key for the ntor handshake. */
38 /** Rendezvous cookie. */
39 const uint8_t *rendezvous_cookie;
40 /** Public key put before the encrypted data (CLIENT_PK). */
42 /** Rendezvous point link specifiers. */
44 /** Congestion control parameters. */
45 unsigned int cc_enabled : 1;
46 /** PoW solution (Can be NULL if disabled). */
49
50/** Introduction data needed to launch a rendezvous circuit. This is set after
51 * receiving an INTRODUCE2 valid cell. */
53 /** Onion public key computed using the INTRODUCE2 encrypted section. */
55 /** Rendezvous cookie taken from the INTRODUCE2 encrypted section. */
57 /** Client public key from the INTRODUCE2 encrypted section. */
59 /** Link specifiers of the rendezvous point. Contains link_specifier_t. */
61 /** Congestion control parameters. */
62 unsigned int cc_enabled : 1;
63 /** PoW effort. */
64 uint32_t pow_effort;
66
67/** This data structure contains data that we need to parse an INTRODUCE2 cell
68 * which is used by the INTRODUCE2 cell parsing function. On a successful
69 * parsing, the onion_pk and rendezvous_cookie will be populated with the
70 * computed key material from the cell data. This structure is only used during
71 * INTRO2 parsing and discarded after that. */
73 /*** Immutable Section: Set on structure init. ***/
74
75 /** Introduction point authentication public key. Pointer owned by the
76 introduction point object through which we received the INTRO2 cell. */
78 /** Introduction point encryption keypair for the ntor handshake. Pointer
79 owned by the introduction point object through which we received the
80 INTRO2 cell*/
82 /**
83 * Length of the subcredentials array below.
84 **/
86 /** Array of <b>n_subcredentials</b> subcredentials for the service. Pointer
87 * owned by the descriptor that owns the introduction point through which we
88 * received the INTRO2 cell. */
90 /** Payload of the received encoded cell. */
91 const uint8_t *payload;
92 /** Size of the payload of the received encoded cell. */
94
95 /*** Mutable Section: Set upon parsing INTRODUCE2 cell. ***/
96
97 /** Data needed to launch a rendezvous circuit. */
99 /** Replay cache of the introduction point. */
100 replaycache_t *replay_cache;
101 /** Flow control negotiation parameters. */
104
105/* Build cell API. */
106ssize_t hs_cell_build_establish_intro(const char *circ_nonce,
107 const hs_service_config_t *config,
108 const hs_service_intro_point_t *ip,
109 uint8_t *cell_out);
110ssize_t hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie,
111 size_t rendezvous_cookie_len,
112 const uint8_t *rendezvous_handshake_info,
113 size_t rendezvous_handshake_info_len,
114 uint8_t *cell_out);
116 uint8_t *cell_out);
117ssize_t hs_cell_build_establish_rendezvous(const uint8_t *rendezvous_cookie,
118 uint8_t *cell_out);
119
120/* Parse cell API. */
121ssize_t hs_cell_parse_intro_established(const uint8_t *payload,
122 size_t payload_len);
124 const origin_circuit_t *circ,
125 const hs_service_t *service,
126 const hs_service_intro_point_t *ip);
127int hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len);
128int hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len,
129 uint8_t *handshake_info,
130 size_t handshake_info_len);
131
132/* Util API. */
134
135#ifdef TOR_UNIT_TESTS
136
137#include "trunnel/extension.h"
138
139STATIC trn_extension_t *
141 const hs_service_intro_point_t *ip);
142
143#endif /* defined(TOR_UNIT_TESTS) */
144
145#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:632
ssize_t hs_cell_build_establish_rendezvous(const uint8_t *rendezvous_cookie, uint8_t *cell_out)
Definition: hs_cell.c:1216
ssize_t hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data, const origin_circuit_t *circ, const hs_service_t *service, const hs_service_intro_point_t *ip)
Definition: hs_cell.c:973
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:665
ssize_t hs_cell_parse_intro_established(const uint8_t *payload, size_t payload_len)
Definition: hs_cell.c:779
int hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len)
Definition: hs_cell.c:1230
void hs_cell_introduce1_data_clear(hs_cell_introduce1_data_t *data)
Definition: hs_cell.c:1283
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:1141
ssize_t hs_cell_build_introduce1(const hs_cell_introduce1_data_t *data, uint8_t *cell_out)
Definition: hs_cell.c:1176
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:1253
Header file containing PoW denial of service defenses for the HS subsystem for all versions.
Header file containing service data for the HS subsystem.
Master header file for Tor-specific functionality.
#define REND_COOKIE_LEN
Definition: or.h:353
curve25519_public_key_t onion_pk
Definition: hs_cell.h:54
uint8_t rendezvous_cookie[REND_COOKIE_LEN]
Definition: hs_cell.h:56
unsigned int cc_enabled
Definition: hs_cell.h:62
curve25519_public_key_t client_pk
Definition: hs_cell.h:58
smartlist_t * link_specifiers
Definition: hs_cell.h:60
const ed25519_public_key_t * auth_pk
Definition: hs_cell.h:31
const struct hs_subcredential_t * subcredential
Definition: hs_cell.h:35
const hs_pow_solution_t * pow_solution
Definition: hs_cell.h:47
unsigned int is_legacy
Definition: hs_cell.h:26
const curve25519_keypair_t * client_kp
Definition: hs_cell.h:41
const curve25519_public_key_t * enc_pk
Definition: hs_cell.h:33
unsigned int cc_enabled
Definition: hs_cell.h:45
const crypto_pk_t * legacy_key
Definition: hs_cell.h:29
const uint8_t * rendezvous_cookie
Definition: hs_cell.h:39
const curve25519_public_key_t * onion_pk
Definition: hs_cell.h:37
smartlist_t * link_specifiers
Definition: hs_cell.h:43
protover_summary_flags_t pv
Definition: hs_cell.h:102
const ed25519_public_key_t * auth_pk
Definition: hs_cell.h:77
const curve25519_keypair_t * enc_kp
Definition: hs_cell.h:81
replaycache_t * replay_cache
Definition: hs_cell.h:100
const struct hs_subcredential_t * subcredentials
Definition: hs_cell.h:89
const uint8_t * payload
Definition: hs_cell.h:91
hs_cell_intro_rdv_data_t rdv_data
Definition: hs_cell.h:98
#define STATIC
Definition: testsupport.h:32