Tor  0.4.5.0-alpha-dev
Macros | Functions
hs_intropoint.c File Reference

Implement next generation introductions point functionality. More...

#include "core/or/or.h"
#include "app/config/config.h"
#include "core/or/channel.h"
#include "core/or/circuitlist.h"
#include "core/or/circuituse.h"
#include "core/or/relay.h"
#include "feature/rend/rendmid.h"
#include "feature/stats/rephist.h"
#include "lib/crypt_ops/crypto_format.h"
#include "trunnel/ed25519_cert.h"
#include "trunnel/hs/cell_common.h"
#include "trunnel/hs/cell_establish_intro.h"
#include "trunnel/hs/cell_introduce1.h"
#include "feature/hs/hs_circuitmap.h"
#include "feature/hs/hs_common.h"
#include "feature/hs/hs_config.h"
#include "feature/hs/hs_descriptor.h"
#include "feature/hs/hs_dos.h"
#include "feature/hs/hs_intropoint.h"
#include "core/or/or_circuit_st.h"

Go to the source code of this file.

Functions

STATIC void get_auth_key_from_cell (ed25519_public_key_t *auth_key_out, unsigned int cell_type, const void *cell)
 
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)
 
int hs_intro_send_intro_established_cell (or_circuit_t *circ)
 
STATIC bool cell_dos_extension_parameters_are_valid (uint64_t intro2_rate_per_sec, uint64_t intro2_burst_per_sec)
 
static void handle_establish_intro_cell_dos_extension (const trn_cell_extension_field_t *field, or_circuit_t *circ)
 
static void handle_establish_intro_cell_extensions (const trn_cell_establish_intro_t *parsed_cell, or_circuit_t *circ)
 
static int handle_verified_establish_intro_cell (or_circuit_t *circ, const trn_cell_establish_intro_t *parsed_cell)
 
static int handle_establish_intro (or_circuit_t *circ, const uint8_t *request, size_t request_len)
 
static int circuit_is_suitable_intro_point (const or_circuit_t *circ, const char *log_cell_type_str)
 
int hs_intro_circuit_is_suitable_for_establish_intro (const or_circuit_t *circ)
 
int hs_intro_received_establish_intro (or_circuit_t *circ, const uint8_t *request, size_t request_len)
 
static int send_introduce_ack_cell (or_circuit_t *circ, uint16_t status)
 
STATIC int validate_introduce1_parsed_cell (const trn_cell_introduce1_t *cell)
 
STATIC int handle_introduce1 (or_circuit_t *client_circ, const uint8_t *request, size_t request_len)
 
STATIC int introduce1_cell_is_legacy (const uint8_t *request)
 
STATIC int circuit_is_suitable_for_introduce1 (const or_circuit_t *circ)
 
int hs_intro_received_introduce1 (or_circuit_t *circ, const uint8_t *request, size_t request_len)
 
void hs_intropoint_clear (hs_intropoint_t *ip)
 

Detailed Description

Implement next generation introductions point functionality.

Definition in file hs_intropoint.c.

Function Documentation

◆ cell_dos_extension_parameters_are_valid()

STATIC bool cell_dos_extension_parameters_are_valid ( uint64_t  intro2_rate_per_sec,
uint64_t  intro2_burst_per_sec 
)

Validate the cell DoS extension parameters. Return true iff they've been bound check and can be used. Else return false. See proposal 305 for details and reasons about this validation.

Definition at line 189 of file hs_intropoint.c.

◆ circuit_is_suitable_for_introduce1()

STATIC int circuit_is_suitable_for_introduce1 ( const or_circuit_t circ)

Return true iff the circuit circ is suitable for receiving an INTRODUCE1 cell.

Definition at line 740 of file hs_intropoint.c.

◆ circuit_is_suitable_intro_point()

static int circuit_is_suitable_intro_point ( const or_circuit_t circ,
const char *  log_cell_type_str 
)
static

Return True if circuit is suitable for being an intro circuit.

Definition at line 467 of file hs_intropoint.c.

Referenced by circuit_is_suitable_for_introduce1(), and hs_intro_circuit_is_suitable_for_establish_intro().

◆ get_auth_key_from_cell()

STATIC void get_auth_key_from_cell ( ed25519_public_key_t auth_key_out,
unsigned int  cell_type,
const void *  cell 
)

Extract the authentication key from an ESTABLISH_INTRO or INTRODUCE1 using the given cell_type from cell and place it in auth_key_out.

Definition at line 40 of file hs_intropoint.c.

Referenced by handle_verified_establish_intro_cell().

◆ handle_establish_intro()

static int handle_establish_intro ( or_circuit_t circ,
const uint8_t *  request,
size_t  request_len 
)
static

We just received an ESTABLISH_INTRO cell in circ with payload in request. Handle it by making circ an intro circuit. Return 0 if everything went well, or -1 if there were errors.

Definition at line 407 of file hs_intropoint.c.

◆ handle_establish_intro_cell_dos_extension()

static void handle_establish_intro_cell_dos_extension ( const trn_cell_extension_field_t *  field,
or_circuit_t circ 
)
static

Parse the cell DoS extension and apply defenses on the given circuit if validation passes. If the cell extension is malformed or contains unusable values, the DoS defenses is disabled on the circuit.

Definition at line 251 of file hs_intropoint.c.

◆ handle_establish_intro_cell_extensions()

static void handle_establish_intro_cell_extensions ( const trn_cell_establish_intro_t *  parsed_cell,
or_circuit_t circ 
)
static

Parse every cell extension in the given ESTABLISH_INTRO cell.

Definition at line 331 of file hs_intropoint.c.

◆ handle_introduce1()

STATIC int handle_introduce1 ( or_circuit_t client_circ,
const uint8_t *  request,
size_t  request_len 
)

We just received a non legacy INTRODUCE1 cell on client_circ with the payload in request of size request_len. Return 0 if everything went well, or -1 if an error occurred. This function is in charge of sending back an INTRODUCE_ACK cell and will close client_circ on error.

Definition at line 627 of file hs_intropoint.c.

◆ handle_verified_establish_intro_cell()

static int handle_verified_establish_intro_cell ( or_circuit_t circ,
const trn_cell_establish_intro_t *  parsed_cell 
)
static

We received an ESTABLISH_INTRO parsed_cell on circ. It's well-formed and passed our verifications. Perform appropriate actions to establish an intro point.

Definition at line 373 of file hs_intropoint.c.

◆ hs_intro_circuit_is_suitable_for_establish_intro()

int hs_intro_circuit_is_suitable_for_establish_intro ( const or_circuit_t circ)

Return True if circuit is suitable for being service-side intro circuit.

Definition at line 492 of file hs_intropoint.c.

◆ hs_intro_received_establish_intro()

int hs_intro_received_establish_intro ( or_circuit_t circ,
const uint8_t *  request,
size_t  request_len 
)

We just received an ESTABLISH_INTRO cell in circ. Figure out of it's a legacy or a next gen cell, and pass it to the appropriate handler.

Definition at line 500 of file hs_intropoint.c.

◆ hs_intro_received_introduce1()

int hs_intro_received_introduce1 ( or_circuit_t circ,
const uint8_t *  request,
size_t  request_len 
)

We just received an INTRODUCE1 cell on circ. Figure out which type it is and pass it to the appropriate handler. Return 0 on success else a negative value and the circuit is closed.

Definition at line 772 of file hs_intropoint.c.

◆ hs_intro_send_intro_established_cell()

int hs_intro_send_intro_established_cell ( or_circuit_t circ)

Send an INTRO_ESTABLISHED cell to circ.

Definition at line 152 of file hs_intropoint.c.

◆ hs_intropoint_clear()

void hs_intropoint_clear ( hs_intropoint_t ip)

Clear memory allocated by the given intropoint object ip (but don't free the object itself).

Definition at line 815 of file hs_intropoint.c.

◆ introduce1_cell_is_legacy()

STATIC int introduce1_cell_is_legacy ( const uint8_t *  request)

Identify if the encoded cell we just received is a legacy one or not. The request should be at least DIGEST_LEN bytes long.

Definition at line 723 of file hs_intropoint.c.

◆ send_introduce_ack_cell()

static int send_introduce_ack_cell ( or_circuit_t circ,
uint16_t  status 
)
static

Send an INTRODUCE_ACK cell onto the circuit circ with the status value in status. Depending on the status, it can be ACK or a NACK. Return 0 on success else a negative value on error which will close the circuit.

Definition at line 536 of file hs_intropoint.c.

◆ validate_introduce1_parsed_cell()

STATIC int validate_introduce1_parsed_cell ( const trn_cell_introduce1_t *  cell)

Validate a parsed INTRODUCE1 cell. Return 0 if valid or else a negative value for an invalid cell that should be NACKed.

Definition at line 578 of file hs_intropoint.c.

◆ verify_establish_intro_cell()

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 
)

We received an ESTABLISH_INTRO cell. Verify its signature and MAC, given circuit_key_material. Return 0 on success else -1 on error.

Definition at line 77 of file hs_intropoint.c.