2017-05-02 16:22:00 +03:00
|
|
|
/* Copyright (c) 2017, The Tor Project, Inc. */
|
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file hs_client.h
|
|
|
|
* \brief Header file containing client data for the HS subsytem.
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef TOR_HS_CLIENT_H
|
|
|
|
#define TOR_HS_CLIENT_H
|
|
|
|
|
2017-06-01 14:12:33 +03:00
|
|
|
#include "crypto_ed25519.h"
|
2017-06-01 13:37:11 +03:00
|
|
|
#include "hs_descriptor.h"
|
2017-07-21 14:32:47 -04:00
|
|
|
#include "hs_ident.h"
|
2017-06-01 13:37:11 +03:00
|
|
|
|
2017-09-12 12:24:26 -04:00
|
|
|
/* Status code of a descriptor fetch request. */
|
|
|
|
typedef enum {
|
|
|
|
/* Something internally went wrong. */
|
|
|
|
HS_CLIENT_FETCH_ERROR = -1,
|
|
|
|
/* The fetch request has been launched successfully. */
|
|
|
|
HS_CLIENT_FETCH_LAUNCHED = 0,
|
|
|
|
/* We already have a usable descriptor. No fetch. */
|
|
|
|
HS_CLIENT_FETCH_HAVE_DESC = 1,
|
|
|
|
/* No more HSDir available to query. */
|
|
|
|
HS_CLIENT_FETCH_NO_HSDIRS = 2,
|
|
|
|
/* The fetch request is not allowed. */
|
|
|
|
HS_CLIENT_FETCH_NOT_ALLOWED = 3,
|
|
|
|
/* We are missing information to be able to launch a request. */
|
|
|
|
HS_CLIENT_FETCH_MISSING_INFO = 4,
|
2017-09-26 10:54:46 -04:00
|
|
|
/* There is a pending fetch for the requested service. */
|
|
|
|
HS_CLIENT_FETCH_PENDING = 5,
|
2017-09-12 12:24:26 -04:00
|
|
|
} hs_client_fetch_status_t;
|
|
|
|
|
2017-05-02 16:22:00 +03:00
|
|
|
void hs_client_note_connection_attempt_succeeded(
|
|
|
|
const edge_connection_t *conn);
|
|
|
|
|
2017-06-01 13:37:11 +03:00
|
|
|
int hs_client_decode_descriptor(
|
|
|
|
const char *desc_str,
|
|
|
|
const ed25519_public_key_t *service_identity_pk,
|
|
|
|
hs_descriptor_t **desc);
|
2017-07-27 17:15:19 -04:00
|
|
|
int hs_client_any_intro_points_usable(const ed25519_public_key_t *service_pk,
|
|
|
|
const hs_descriptor_t *desc);
|
2017-06-01 14:12:33 +03:00
|
|
|
int hs_client_refetch_hsdesc(const ed25519_public_key_t *identity_pk);
|
2017-06-01 13:37:11 +03:00
|
|
|
|
2017-07-14 10:16:48 -04:00
|
|
|
int hs_client_send_introduce1(origin_circuit_t *intro_circ,
|
|
|
|
origin_circuit_t *rend_circ);
|
|
|
|
|
2017-07-21 13:56:10 -04:00
|
|
|
void hs_client_circuit_has_opened(origin_circuit_t *circ);
|
|
|
|
|
2017-07-21 14:20:37 -04:00
|
|
|
int hs_client_receive_rendezvous_acked(origin_circuit_t *circ,
|
|
|
|
const uint8_t *payload,
|
|
|
|
size_t payload_len);
|
2017-07-21 17:48:18 -04:00
|
|
|
int hs_client_receive_introduce_ack(origin_circuit_t *circ,
|
|
|
|
const uint8_t *payload,
|
|
|
|
size_t payload_len);
|
2017-07-25 10:14:00 -04:00
|
|
|
int hs_client_receive_rendezvous2(origin_circuit_t *circ,
|
|
|
|
const uint8_t *payload,
|
|
|
|
size_t payload_len);
|
2017-07-21 17:48:18 -04:00
|
|
|
|
2017-07-21 14:32:47 -04:00
|
|
|
void hs_client_desc_has_arrived(const hs_ident_dir_conn_t *ident);
|
|
|
|
|
2017-07-21 15:19:32 -04:00
|
|
|
extend_info_t *hs_client_get_random_intro_from_edge(
|
|
|
|
const edge_connection_t *edge_conn);
|
|
|
|
|
2017-07-27 12:37:52 -04:00
|
|
|
int hs_client_reextend_intro_circuit(origin_circuit_t *circ);
|
|
|
|
|
2017-08-30 09:15:54 -04:00
|
|
|
void hs_client_purge_state(void);
|
|
|
|
|
2017-08-29 16:02:13 -04:00
|
|
|
void hs_client_free_all(void);
|
|
|
|
|
2017-09-08 18:43:45 +03:00
|
|
|
#ifdef HS_CLIENT_PRIVATE
|
|
|
|
|
|
|
|
STATIC routerstatus_t *
|
|
|
|
pick_hsdir_v3(const ed25519_public_key_t *onion_identity_pk);
|
|
|
|
|
2017-08-29 18:28:11 +03:00
|
|
|
STATIC extend_info_t *
|
|
|
|
client_get_random_intro(const ed25519_public_key_t *service_pk);
|
|
|
|
|
|
|
|
STATIC extend_info_t *
|
|
|
|
desc_intro_point_to_extend_info(const hs_desc_intro_point_t *ip);
|
|
|
|
|
2017-09-25 15:00:06 +03:00
|
|
|
STATIC int handle_rendezvous2(origin_circuit_t *circ, const uint8_t *payload,
|
|
|
|
size_t payload_len);
|
|
|
|
|
2017-09-26 12:03:16 -04:00
|
|
|
MOCK_DECL(STATIC hs_client_fetch_status_t,
|
|
|
|
fetch_v3_desc, (const ed25519_public_key_t *onion_identity_pk));
|
|
|
|
|
2017-09-15 16:24:44 -04:00
|
|
|
#endif /* defined(HS_CLIENT_PRIVATE) */
|
2017-09-08 18:43:45 +03:00
|
|
|
|
2017-09-15 16:24:44 -04:00
|
|
|
#endif /* !defined(TOR_HS_CLIENT_H) */
|
2017-05-02 16:22:00 +03:00
|
|
|
|