1 /* Copyright (c) 2016-2017, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
5 * \file hs_intropoint.h
6 * \brief Header file for hs_intropoint.c.
10 #define TOR_HS_INTRO_H
12 #include "crypto_curve25519.h"
15 /* Authentication key type in an ESTABLISH_INTRO cell. */
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
;
22 /* INTRODUCE_ACK status code. */
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
;
30 /* Object containing introduction point common data between the service and
32 typedef struct hs_intropoint_t
{
33 /* Does this intro point only supports legacy ID ?. */
34 unsigned int is_only_legacy
: 1;
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
;
42 int hs_intro_received_establish_intro(or_circuit_t
*circ
,
43 const uint8_t *request
,
45 int hs_intro_received_introduce1(or_circuit_t
*circ
, const uint8_t *request
,
48 MOCK_DECL(int, hs_intro_send_intro_established_cell
,(or_circuit_t
*circ
));
50 /* also used by rendservice.c */
51 int hs_intro_circuit_is_suitable_for_establish_intro(const or_circuit_t
*circ
);
53 hs_intropoint_t
*hs_intro_new(void);
54 void hs_intropoint_clear(hs_intropoint_t
*ip
);
56 #ifdef HS_INTROPOINT_PRIVATE
58 #include "hs/cell_establish_intro.h"
59 #include "hs/cell_introduce1.h"
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
);
67 get_auth_key_from_cell(ed25519_public_key_t
*auth_key_out
,
68 unsigned int cell_type
, const void *cell
);
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
);
76 #endif /* defined(HS_INTROPOINT_PRIVATE) */
78 #endif /* !defined(TOR_HS_INTRO_H) */