tor  0.4.0.1-alpha
hs_intropoint.h
Go to the documentation of this file.
1 /* Copyright (c) 2016-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
9 #ifndef TOR_HS_INTRO_H
10 #define TOR_HS_INTRO_H
11 
13 #include "feature/nodelist/torcert.h"
14 
15 /* Authentication key type in an ESTABLISH_INTRO cell. */
16 typedef enum {
17  HS_INTRO_AUTH_KEY_TYPE_LEGACY0 = 0x00,
18  HS_INTRO_AUTH_KEY_TYPE_LEGACY1 = 0x01,
19  HS_INTRO_AUTH_KEY_TYPE_ED25519 = 0x02,
20 } hs_intro_auth_key_type_t;
21 
22 /* INTRODUCE_ACK status code. */
23 typedef enum {
24  HS_INTRO_ACK_STATUS_SUCCESS = 0x0000,
25  HS_INTRO_ACK_STATUS_UNKNOWN_ID = 0x0001,
26  HS_INTRO_ACK_STATUS_BAD_FORMAT = 0x0002,
27  HS_INTRO_ACK_STATUS_CANT_RELAY = 0x0003,
28 } hs_intro_ack_status_t;
29 
30 /* Object containing introduction point common data between the service and
31  * the client side. */
32 typedef struct hs_intropoint_t {
33  /* Does this intro point only supports legacy ID ?. */
34  unsigned int is_only_legacy : 1;
35 
36  /* Authentication key certificate from the descriptor. */
37  tor_cert_t *auth_key_cert;
38  /* A list of link specifier. */
39  smartlist_t *link_specifiers;
41 
42 int hs_intro_received_establish_intro(or_circuit_t *circ,
43  const uint8_t *request,
44  size_t request_len);
45 int hs_intro_received_introduce1(or_circuit_t *circ, const uint8_t *request,
46  size_t request_len);
47 
48 MOCK_DECL(int, hs_intro_send_intro_established_cell,(or_circuit_t *circ));
49 
50 /* also used by rendservice.c */
51 int hs_intro_circuit_is_suitable_for_establish_intro(const or_circuit_t *circ);
52 
53 hs_intropoint_t *hs_intro_new(void);
54 void hs_intropoint_clear(hs_intropoint_t *ip);
55 
56 #ifdef HS_INTROPOINT_PRIVATE
57 
58 #include "trunnel/hs/cell_establish_intro.h"
59 #include "trunnel/hs/cell_introduce1.h"
60 
61 STATIC int
62 verify_establish_intro_cell(const trn_cell_establish_intro_t *out,
63  const uint8_t *circuit_key_material,
64  size_t circuit_key_material_len);
65 
66 STATIC void
68  unsigned int cell_type, const void *cell);
69 
70 STATIC int introduce1_cell_is_legacy(const uint8_t *request);
71 STATIC int handle_introduce1(or_circuit_t *client_circ,
72  const uint8_t *request, size_t request_len);
73 STATIC int validate_introduce1_parsed_cell(const trn_cell_introduce1_t *cell);
74 STATIC int circuit_is_suitable_for_introduce1(const or_circuit_t *circ);
75 
76 #endif /* defined(HS_INTROPOINT_PRIVATE) */
77 
78 #endif /* !defined(TOR_HS_INTRO_H) */
79 
STATIC void get_auth_key_from_cell(ed25519_public_key_t *auth_key_out, unsigned int cell_type, const void *cell)
Definition: hs_intropoint.c:37
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:94
STATIC int verify_establish_intro_cell(const trn_cell_establish_intro_t *cell, const uint8_t *circuit_key_material, size_t circuit_key_material_len)
Definition: hs_intropoint.c:74
Header for crypto_curve25519.c.