tor  0.4.2.0-alpha-dev
hs_cell.h
Go to the documentation of this file.
1 /* Copyright (c) 2017-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
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 /* This data structure contains data that we need to build an INTRODUCE1 cell
20  * used by the INTRODUCE1 build function. */
21 typedef struct hs_cell_introduce1_data_t {
22  /* Is this a legacy introduction point? */
23  unsigned int is_legacy : 1;
24  /* (Legacy only) The encryption key for a legacy intro point. Only set if
25  * is_legacy is true. */
26  const crypto_pk_t *legacy_key;
27  /* Introduction point authentication public key. */
28  const ed25519_public_key_t *auth_pk;
29  /* Introduction point encryption public key. */
30  const curve25519_public_key_t *enc_pk;
31  /* Subcredentials of the service. */
32  const uint8_t *subcredential;
33  /* Onion public key for the ntor handshake. */
34  const curve25519_public_key_t *onion_pk;
35  /* Rendezvous cookie. */
36  const uint8_t *rendezvous_cookie;
37  /* Public key put before the encrypted data (CLIENT_PK). */
38  const curve25519_keypair_t *client_kp;
39  /* Rendezvous point link specifiers. */
40  smartlist_t *link_specifiers;
42 
43 /* This data structure contains data that we need to parse an INTRODUCE2 cell
44  * which is used by the INTRODUCE2 cell parsing function. On a successful
45  * parsing, the onion_pk and rendezvous_cookie will be populated with the
46  * computed key material from the cell data. This structure is only used during
47  * INTRO2 parsing and discarded after that. */
48 typedef struct hs_cell_introduce2_data_t {
49  /*** Immutable Section: Set on structure init. ***/
50 
51  /* Introduction point authentication public key. Pointer owned by the
52  introduction point object through which we received the INTRO2 cell. */
53  const ed25519_public_key_t *auth_pk;
54  /* Introduction point encryption keypair for the ntor handshake. Pointer
55  owned by the introduction point object through which we received the
56  INTRO2 cell*/
57  const curve25519_keypair_t *enc_kp;
58  /* Subcredentials of the service. Pointer owned by the descriptor that owns
59  the introduction point through which we received the INTRO2 cell. */
60  const uint8_t *subcredential;
61  /* Payload of the received encoded cell. */
62  const uint8_t *payload;
63  /* Size of the payload of the received encoded cell. */
64  size_t payload_len;
65 
66  /*** Mutable Section: Set upon parsing INTRODUCE2 cell. ***/
67 
68  /* Onion public key computed using the INTRODUCE2 encrypted section. */
69  curve25519_public_key_t onion_pk;
70  /* Rendezvous cookie taken from the INTRODUCE2 encrypted section. */
71  uint8_t rendezvous_cookie[REND_COOKIE_LEN];
72  /* Client public key from the INTRODUCE2 encrypted section. */
73  curve25519_public_key_t client_pk;
74  /* Link specifiers of the rendezvous point. Contains link_specifier_t. */
75  smartlist_t *link_specifiers;
76  /* Replay cache of the introduction point. */
77  replaycache_t *replay_cache;
79 
80 /* Build cell API. */
81 ssize_t hs_cell_build_establish_intro(const char *circ_nonce,
82  const hs_service_intro_point_t *ip,
83  uint8_t *cell_out);
84 ssize_t hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie,
85  size_t rendezvous_cookie_len,
86  const uint8_t *rendezvous_handshake_info,
87  size_t rendezvous_handshake_info_len,
88  uint8_t *cell_out);
89 ssize_t hs_cell_build_introduce1(const hs_cell_introduce1_data_t *data,
90  uint8_t *cell_out);
91 ssize_t hs_cell_build_establish_rendezvous(const uint8_t *rendezvous_cookie,
92  uint8_t *cell_out);
93 
94 /* Parse cell API. */
95 ssize_t hs_cell_parse_intro_established(const uint8_t *payload,
96  size_t payload_len);
97 ssize_t hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data,
98  const origin_circuit_t *circ,
99  const hs_service_t *service);
100 int hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len);
101 int hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len,
102  uint8_t *handshake_info,
103  size_t handshake_info_len);
104 
105 /* Util API. */
106 void hs_cell_introduce1_data_clear(hs_cell_introduce1_data_t *data);
107 
108 #endif /* !defined(TOR_HS_CELL_H) */
109 
Header file containing service data for the HS subsytem.
Master header file for Tor-specific functionality.
#define REND_COOKIE_LEN
Definition: or.h:399