Tor
0.4.7.0-alpha-dev
|
Functions to queue create cells, and parse and create the CREATE cell and its allies. More...
#include "core/or/or.h"
#include "app/config/config.h"
#include "core/crypto/onion_crypto.h"
#include "core/crypto/onion_fast.h"
#include "core/crypto/onion_ntor.h"
#include "core/crypto/onion_tap.h"
#include "core/or/onion.h"
#include "feature/nodelist/networkstatus.h"
#include "core/or/cell_st.h"
#include "trunnel/ed25519_cert.h"
Go to the source code of this file.
Macros | |
#define | NTOR_CREATE_MAGIC "ntorNTORntorNTOR" |
Functions | |
static int | check_create_cell (const create_cell_t *cell, int unknown_ok) |
void | create_cell_init (create_cell_t *cell_out, uint8_t cell_type, uint16_t handshake_type, uint16_t handshake_len, const uint8_t *onionskin) |
static int | parse_create2_payload (create_cell_t *cell_out, const uint8_t *p, size_t p_len) |
int | create_cell_parse (create_cell_t *cell_out, const cell_t *cell_in) |
static int | check_created_cell (const created_cell_t *cell) |
int | created_cell_parse (created_cell_t *cell_out, const cell_t *cell_in) |
static int | check_extend_cell (const extend_cell_t *cell) |
static int | extend_cell_from_extend1_cell_body (extend_cell_t *cell_out, const extend1_cell_body_t *cell) |
static int | create_cell_from_create2_cell_body (create_cell_t *cell_out, const create2_cell_body_t *cell) |
static int | extend_cell_from_extend2_cell_body (extend_cell_t *cell_out, const extend2_cell_body_t *cell) |
int | extend_cell_parse (extend_cell_t *cell_out, const uint8_t command, const uint8_t *payload, size_t payload_length) |
static int | check_extended_cell (const extended_cell_t *cell) |
int | extended_cell_parse (extended_cell_t *cell_out, const uint8_t command, const uint8_t *payload, size_t payload_len) |
static int | create_cell_format_impl (cell_t *cell_out, const create_cell_t *cell_in, int relayed) |
int | create_cell_format (cell_t *cell_out, const create_cell_t *cell_in) |
int | create_cell_format_relayed (cell_t *cell_out, const create_cell_t *cell_in) |
int | created_cell_format (cell_t *cell_out, const created_cell_t *cell_in) |
static int | should_include_ed25519_id_extend_cells (const networkstatus_t *ns, const or_options_t *options) |
int | extend_cell_format (uint8_t *command_out, uint16_t *len_out, uint8_t *payload_out, const extend_cell_t *cell_in) |
int | extended_cell_format (uint8_t *command_out, uint16_t *len_out, uint8_t *payload_out, const extended_cell_t *cell_in) |
Functions to queue create cells, and parse and create the CREATE cell and its allies.
This module has a few functions, all related to the CREATE/CREATED handshake that we use on links in order to create a circuit, and the related EXTEND/EXTENDED handshake that we use over circuits in order to extend them an additional hop.
Clients invoke these functions when creating or extending a circuit, from circuitbuild.c.
Relays invoke these functions when they receive a CREATE or EXTEND cell in command.c or relay.c, in order to queue the pending request. They also invoke them from cpuworker.c, which handles dispatching onionskin requests to different worker threads.
This module also handles:
Definition in file onion.c.
#define NTOR_CREATE_MAGIC "ntorNTORntorNTOR" |
Magic string which, in a CREATE or EXTEND cell, indicates that a seeming TAP payload is really an ntor payload. We'd do away with this if every relay supported EXTEND2, but we want to be able to extend from A to B with ntor even when A doesn't understand EXTEND2 and so can't generate a CREATE2 cell.
|
static |
Helper: return 0 if cell appears valid, -1 otherwise. If unknown_ok is true, allow cells with handshake types we don't recognize.
Definition at line 60 of file onion.c.
Referenced by create_cell_format_impl().
|
static |
Helper: return 0 if cell appears valid, -1 otherwise.
Definition at line 185 of file onion.c.
Referenced by created_cell_format().
|
static |
Helper: return 0 if cell appears valid, -1 otherwise.
Definition at line 241 of file onion.c.
Referenced by extend_cell_format().
|
static |
Helper: return 0 if cell appears valid, -1 otherwise.
Definition at line 445 of file onion.c.
Referenced by extended_cell_format().
|
static |
void create_cell_init | ( | create_cell_t * | cell_out, |
uint8_t | cell_type, | ||
uint16_t | handshake_type, | ||
uint16_t | handshake_len, | ||
const uint8_t * | onionskin | ||
) |
Write the various parameters into the create cell. Separate from create_cell_parse() to make unit testing easier.
int create_cell_parse | ( | create_cell_t * | cell_out, |
const cell_t * | cell_in | ||
) |
int created_cell_format | ( | cell_t * | cell_out, |
const created_cell_t * | cell_in | ||
) |
int created_cell_parse | ( | created_cell_t * | cell_out, |
const cell_t * | cell_in | ||
) |
int extend_cell_format | ( | uint8_t * | command_out, |
uint16_t * | len_out, | ||
uint8_t * | payload_out, | ||
const extend_cell_t * | cell_in | ||
) |
int extend_cell_parse | ( | extend_cell_t * | cell_out, |
const uint8_t | command, | ||
const uint8_t * | payload, | ||
size_t | payload_length | ||
) |
int extended_cell_format | ( | uint8_t * | command_out, |
uint16_t * | len_out, | ||
uint8_t * | payload_out, | ||
const extended_cell_t * | cell_in | ||
) |
int extended_cell_parse | ( | extended_cell_t * | cell_out, |
const uint8_t | command, | ||
const uint8_t * | payload, | ||
size_t | payload_len | ||
) |
|
static |
Helper: parse the CREATE2 payload at p, which could be up to p_len bytes long, and use it to fill the fields of cell_out. Return 0 on success and -1 on failure.
Note that part of the body of an EXTEND2 cell is a CREATE2 payload, so this function is also used for parsing those.
|
static |