Tor  0.4.5.0-alpha-dev
Functions
relay_crypto.h File Reference

Header for relay_crypto.c. More...

Go to the source code of this file.

Functions

int relay_crypto_init (relay_crypto_t *crypto, const char *key_data, size_t key_data_len, int reverse, int is_hs_v3)
 
int relay_decrypt_cell (circuit_t *circ, cell_t *cell, cell_direction_t cell_direction, crypt_path_t **layer_hint, char *recognized)
 
void relay_encrypt_cell_outbound (cell_t *cell, origin_circuit_t *or_circ, crypt_path_t *layer_hint)
 
void relay_encrypt_cell_inbound (cell_t *cell, or_circuit_t *or_circ)
 
void relay_crypto_clear (relay_crypto_t *crypto)
 
void relay_crypto_assert_ok (const relay_crypto_t *crypto)
 
uint8_t * relay_crypto_get_sendme_digest (relay_crypto_t *crypto)
 
void relay_crypto_record_sendme_digest (relay_crypto_t *crypto, bool is_foward_digest)
 
void relay_crypt_one_payload (crypto_cipher_t *cipher, uint8_t *in)
 
void relay_set_digest (crypto_digest_t *digest, cell_t *cell)
 

Detailed Description

Header for relay_crypto.c.

Definition in file relay_crypto.h.

Function Documentation

◆ relay_crypt_one_payload()

void relay_crypt_one_payload ( crypto_cipher_t *  cipher,
uint8_t *  in 
)

Apply cipher to CELL_PAYLOAD_SIZE bytes of in (in place).

Note that we use the same operation for encrypting and for decrypting.

Definition at line 95 of file relay_crypto.c.

Referenced by cpath_crypt_cell().

◆ relay_crypto_assert_ok()

void relay_crypto_assert_ok ( const relay_crypto_t crypto)

Assert that crypto is valid and set.

Definition at line 367 of file relay_crypto.c.

◆ relay_crypto_clear()

void relay_crypto_clear ( relay_crypto_t crypto)

Release all storage held inside crypto, but do not free crypto itself: it lives inside another object.

Definition at line 265 of file relay_crypto.c.

Referenced by cpath_free().

◆ relay_crypto_get_sendme_digest()

uint8_t* relay_crypto_get_sendme_digest ( relay_crypto_t crypto)

Return the sendme_digest within the crypto object.

Definition at line 102 of file relay_crypto.c.

Referenced by cpath_get_sendme_digest().

◆ relay_crypto_init()

int relay_crypto_init ( relay_crypto_t crypto,
const char *  key_data,
size_t  key_data_len,
int  reverse,
int  is_hs_v3 
)

Initialize crypto 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 293 of file relay_crypto.c.

Referenced by cpath_init_circuit_crypto().

◆ relay_crypto_record_sendme_digest()

void relay_crypto_record_sendme_digest ( relay_crypto_t crypto,
bool  is_foward_digest 
)

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

Definition at line 111 of file relay_crypto.c.

Referenced by cpath_sendme_record_cell_digest().

◆ relay_decrypt_cell()

int relay_decrypt_cell ( circuit_t circ,
cell_t cell,
cell_direction_t  cell_direction,
crypt_path_t **  layer_hint,
char *  recognized 
)

Do the appropriate en/decryptions for cell arriving on circ in direction cell_direction.

If cell_direction == CELL_DIRECTION_IN:

  • If we're at the origin (we're the OP), for hops 1..N, decrypt cell. If recognized, stop.
  • Else (we're not the OP), encrypt one hop. Cell is not recognized.

If cell_direction == CELL_DIRECTION_OUT:

  • decrypt one hop. Check if recognized.

If cell is recognized, set *recognized to 1, and set *layer_hint to the hop that recognized it.

Return -1 to indicate that we should mark the circuit for close, else return 0.

Definition at line 145 of file relay_crypto.c.

Referenced by circuit_receive_relay_cell().

◆ relay_encrypt_cell_inbound()

void relay_encrypt_cell_inbound ( cell_t cell,
or_circuit_t or_circ 
)

Encrypt a cell cell that we are creating, and sending on circuit to the origin.

The integrity field and recognized field of cell's relay headers must be set to zero.

Definition at line 248 of file relay_crypto.c.

◆ relay_encrypt_cell_outbound()

void relay_encrypt_cell_outbound ( cell_t cell,
origin_circuit_t circ,
crypt_path_t layer_hint 
)

Encrypt a cell cell that we are creating, and sending outbound on circ until the hop corresponding to layer_hint.

The integrity field and recognized field of cell's relay headers must be set to zero.

Definition at line 219 of file relay_crypto.c.

◆ relay_set_digest()

void relay_set_digest ( crypto_digest_t digest,
cell_t cell 
)

Update digest from the payload of cell. Assign integrity part to cell.

Definition at line 31 of file relay_crypto.c.

Referenced by cpath_set_cell_forward_digest(), and relay_encrypt_cell_inbound().