tor  0.4.2.1-alpha-dev
hs_ident.h
Go to the documentation of this file.
1 /* Copyright (c) 2017-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
21 #ifndef TOR_HS_IDENT_H
22 #define TOR_HS_IDENT_H
23 
25 
26 #include "feature/hs/hs_common.h"
27 
28 /* Length of the rendezvous cookie that is used to connect circuits at the
29  * rendezvous point. */
30 #define HS_REND_COOKIE_LEN DIGEST_LEN
31 
32 /* Type of circuit an hs_ident_t object is associated with. */
33 typedef enum {
34  HS_IDENT_CIRCUIT_INTRO = 1,
35  HS_IDENT_CIRCUIT_RENDEZVOUS = 2,
36 } hs_ident_circuit_type_t;
37 
38 /* Client and service side circuit identifier that is used for hidden service
39  * circuit establishment. Not all fields contain data, it depends on the
40  * circuit purpose. This is attached to an origin_circuit_t. All fields are
41  * used by both client and service. */
42 typedef struct hs_ident_circuit_t {
43  /* (All circuit) The public key used to uniquely identify the service. It is
44  * the one found in the onion address. */
45  ed25519_public_key_t identity_pk;
46 
47  /* (All circuit) Introduction point authentication key. It's also needed on
48  * the rendezvous circuit for the ntor handshake. It's used as the unique key
49  * of the introduction point so it should not be shared between multiple
50  * intro points. */
51  ed25519_public_key_t intro_auth_pk;
52 
53  /* (Only client rendezvous circuit) Introduction point encryption public
54  * key. We keep it in the rendezvous identifier for the ntor handshake. */
55  curve25519_public_key_t intro_enc_pk;
56 
57  /* (Only rendezvous circuit) Rendezvous cookie sent from the client to the
58  * service with an INTRODUCE1 cell and used by the service in an
59  * RENDEZVOUS1 cell. */
60  uint8_t rendezvous_cookie[HS_REND_COOKIE_LEN];
61 
62  /* (Only service rendezvous circuit) The HANDSHAKE_INFO needed in the
63  * RENDEZVOUS1 cell of the service. The construction is as follows:
64  * SERVER_PK [32 bytes]
65  * AUTH_MAC [32 bytes]
66  */
67  uint8_t rendezvous_handshake_info[CURVE25519_PUBKEY_LEN + DIGEST256_LEN];
68 
69  /* (Only client rendezvous circuit) Client ephemeral keypair needed for the
70  * e2e encryption with the service. */
71  curve25519_keypair_t rendezvous_client_kp;
72 
73  /* (Only rendezvous circuit) The NTOR_KEY_SEED needed for key derivation for
74  * the e2e encryption with the client on the circuit. */
75  uint8_t rendezvous_ntor_key_seed[DIGEST256_LEN];
76 
77  /* (Only rendezvous circuit) Number of streams associated with this
78  * rendezvous circuit. We track this because there is a check on a maximum
79  * value. */
80  uint64_t num_rdv_streams;
82 
83 /* Client and service side directory connection identifier used for a
84  * directory connection to identify which service is being queried. This is
85  * attached to a dir_connection_t. */
86 typedef struct hs_ident_dir_conn_t {
87  /* The public key used to uniquely identify the service. It is the one found
88  * in the onion address. */
89  ed25519_public_key_t identity_pk;
90 
91  /* The blinded public key used to uniquely identify the descriptor that this
92  * directory connection identifier is for. Only used by the service-side code
93  * to fine control descriptor uploads. */
94  ed25519_public_key_t blinded_pk;
95 
96  /* XXX: Client authorization. */
98 
99 /* Client and service side edge connection identifier used for an edge
100  * connection to identify which service is being queried. This is attached to
101  * a edge_connection_t. */
102 typedef struct hs_ident_edge_conn_t {
103  /* The public key used to uniquely identify the service. It is the one found
104  * in the onion address. */
105  ed25519_public_key_t identity_pk;
106 
107  /* The original virtual port that was used by the client to access the onion
108  * service, regardless of the internal port forwarding that might have
109  * happened on the service-side. */
110  uint16_t orig_virtual_port;
111  /* XXX: Client authorization. */
113 
114 /* Circuit identifier API. */
115 hs_ident_circuit_t *hs_ident_circuit_new(
116  const ed25519_public_key_t *identity_pk);
117 void hs_ident_circuit_free_(hs_ident_circuit_t *ident);
118 #define hs_ident_circuit_free(id) \
119  FREE_AND_NULL(hs_ident_circuit_t, hs_ident_circuit_free_, (id))
120 hs_ident_circuit_t *hs_ident_circuit_dup(const hs_ident_circuit_t *src);
121 
122 /* Directory connection identifier API. */
123 hs_ident_dir_conn_t *hs_ident_dir_conn_dup(const hs_ident_dir_conn_t *src);
124 void hs_ident_dir_conn_free_(hs_ident_dir_conn_t *ident);
125 #define hs_ident_dir_conn_free(id) \
126  FREE_AND_NULL(hs_ident_dir_conn_t, hs_ident_dir_conn_free_, (id))
127 void hs_ident_dir_conn_init(const ed25519_public_key_t *identity_pk,
128  const ed25519_public_key_t *blinded_pk,
129  hs_ident_dir_conn_t *ident);
130 
131 /* Edge connection identifier API. */
132 hs_ident_edge_conn_t *hs_ident_edge_conn_new(
133  const ed25519_public_key_t *identity_pk);
134 void hs_ident_edge_conn_free_(hs_ident_edge_conn_t *ident);
135 #define hs_ident_edge_conn_free(id) \
136  FREE_AND_NULL(hs_ident_edge_conn_t, hs_ident_edge_conn_free_, (id))
137 
138 /* Validators */
139 int hs_ident_intro_circ_is_valid(const hs_ident_circuit_t *ident);
140 
141 #endif /* !defined(TOR_HS_IDENT_H) */
142 
Header file containing common data for the whole HS subsytem.
#define DIGEST256_LEN
Definition: digest_sizes.h:23
Header for crypto_ed25519.c.
#define CURVE25519_PUBKEY_LEN
Definition: x25519_sizes.h:20