tor  0.4.2.0-alpha-dev
Macros | Functions
crypt_path.c File Reference
#include "core/or/or.h"
#include "core/or/crypt_path.h"
#include "core/crypto/relay_crypto.h"
#include "core/crypto/onion_crypto.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitlist.h"
#include "lib/crypt_ops/crypto_dh.h"
#include "lib/crypt_ops/crypto_util.h"
#include "core/or/crypt_path_st.h"
#include "core/or/cell_st.h"

Go to the source code of this file.

Functions

void cpath_extend_linked_list (crypt_path_t **head_ptr, crypt_path_t *new_hop)
 
int cpath_append_hop (crypt_path_t **head_ptr, extend_info_t *choice)
 
void cpath_assert_ok (const crypt_path_t *cp)
 
void cpath_assert_layer_ok (const crypt_path_t *cp)
 
int cpath_init_circuit_crypto (crypt_path_t *cpath, const char *key_data, size_t key_data_len, int reverse, int is_hs_v3)
 
void cpath_free (crypt_path_t *victim)
 
void cpath_crypt_cell (const crypt_path_t *cpath, uint8_t *payload, bool is_decrypt)
 
struct crypto_digest_tcpath_get_incoming_digest (const crypt_path_t *cpath)
 
void cpath_set_cell_forward_digest (crypt_path_t *cpath, cell_t *cell)
 
uint8_t * cpath_get_sendme_digest (crypt_path_t *cpath)
 
void cpath_sendme_record_cell_digest (crypt_path_t *cpath, bool is_foward_digest)
 
crypt_path_tcpath_get_next_non_open_hop (crypt_path_t *cpath)
 

Detailed Description

Functions dealing with layered circuit encryption. This file aims to provide an API around the crypt_path_t structure which holds crypto information about a specific hop of a circuit.

TODO: We should eventually move all functions dealing and manipulating crypt_path_t to this file, so that eventually we encapsulate more and more of crypt_path_t. Here are some more functions that can be moved here with some more effort:

Definition in file crypt_path.c.

Function Documentation

◆ cpath_append_hop()

int cpath_append_hop ( crypt_path_t **  head_ptr,
extend_info_t choice 
)

Create a new hop, annotate it with information about its corresponding router choice, and append it to the end of the cpath head_ptr.

Definition at line 61 of file crypt_path.c.

◆ cpath_assert_layer_ok()

void cpath_assert_layer_ok ( const crypt_path_t cp)

Verify that cpath layer cp has all of its invariants correct. Trigger an assert if anything is invalid.

Definition at line 106 of file crypt_path.c.

References crypt_path_t::deliver_window, LD_BUG, LOG_ERR, log_fn, crypt_path_t::package_window, crypt_path_t::rend_dh_handshake_state, crypt_path_t::state, and tor_assert().

Referenced by cpath_assert_ok().

◆ cpath_assert_ok()

void cpath_assert_ok ( const crypt_path_t cp)

Verify that cpath cp has all of its invariants correct. Trigger an assert if anything is invalid.

Definition at line 83 of file crypt_path.c.

References cpath_assert_layer_ok(), crypt_path_t::next, crypt_path_t::prev, crypt_path_t::state, and tor_assert().

◆ cpath_crypt_cell()

void cpath_crypt_cell ( const crypt_path_t cpath,
uint8_t *  payload,
bool  is_decrypt 
)

Encrypt or decrypt payload using the crypto of cpath. Actual operation decided by is_decrypt.

Definition at line 181 of file crypt_path.c.

◆ cpath_extend_linked_list()

void cpath_extend_linked_list ( crypt_path_t **  head_ptr,
crypt_path_t new_hop 
)

Add new_hop to the end of the doubly-linked-list head_ptr. This function is used to extend cpath by another hop.

Definition at line 44 of file crypt_path.c.

References crypt_path_t::next, and crypt_path_t::prev.

◆ cpath_free()

void cpath_free ( crypt_path_t victim)

Deallocate space associated with the cpath node victim.

Definition at line 162 of file crypt_path.c.

References crypt_path_t::handshake_state, and onion_handshake_state_release().

Referenced by circuit_clear_cpath(), and cpath_ref_decref().

◆ cpath_get_incoming_digest()

struct crypto_digest_t* cpath_get_incoming_digest ( const crypt_path_t cpath)

Getter for the incoming digest of cpath.

Definition at line 192 of file crypt_path.c.

◆ cpath_get_next_non_open_hop()

crypt_path_t* cpath_get_next_non_open_hop ( crypt_path_t cpath)

Return the first non-open hop in cpath, or return NULL if all hops are open.

Definition at line 228 of file crypt_path.c.

References crypt_path_t::next, and crypt_path_t::state.

Referenced by circuit_handle_first_hop(), and circuit_send_next_onion_skin().

◆ cpath_get_sendme_digest()

uint8_t* cpath_get_sendme_digest ( crypt_path_t cpath)

Return the sendme_digest of this cpath.

Definition at line 209 of file crypt_path.c.

◆ cpath_init_circuit_crypto()

int cpath_init_circuit_crypto ( crypt_path_t cpath,
const char *  key_data,
size_t  key_data_len,
int  reverse,
int  is_hs_v3 
)

Initialize cpath->{f|b}_{crypto|digest} from the key material in key_data.

If is_hs_v3 is set, this cpath will be used for next gen hidden service circuits and key_data must be at least HS_NTOR_KEY_EXPANSION_KDF_OUT_LEN bytes in length.

If is_hs_v3 is not set, key_data must contain CPATH_KEY_MATERIAL_LEN bytes, which are used as follows:

  • 20 to initialize f_digest
  • 20 to initialize b_digest
  • 16 to key f_crypto
  • 16 to key b_crypto

(If 'reverse' is true, then f_XX and b_XX are swapped.)

Return 0 if init was successful, else -1 if it failed.

Definition at line 150 of file crypt_path.c.

References tor_assert().

◆ cpath_sendme_record_cell_digest()

void cpath_sendme_record_cell_digest ( crypt_path_t cpath,
bool  is_foward_digest 
)

Record the cell digest, indicated by is_foward_digest or not, as the SENDME cell digest.

Definition at line 217 of file crypt_path.c.

References tor_assert().

◆ cpath_set_cell_forward_digest()

void cpath_set_cell_forward_digest ( crypt_path_t cpath,
cell_t cell 
)

Set the right integrity digest on the outgoing cell based on the cell payload and update the forward digest of cpath.

Definition at line 200 of file crypt_path.c.