Tor 0.4.9.0-alpha-dev
|
Code implementing the Extended ORPort. More...
#include "core/or/or.h"
#include "core/mainloop/connection.h"
#include "core/or/connection_or.h"
#include "feature/control/control_events.h"
#include "app/config/config.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_util.h"
#include "feature/relay/ext_orport.h"
#include "core/mainloop/mainloop.h"
#include "core/proto/proto_ext_or.h"
#include "core/or/or_connection_st.h"
Go to the source code of this file.
Variables | |
STATIC int | ext_or_auth_cookie_is_set = 0 |
STATIC uint8_t * | ext_or_auth_cookie = NULL |
Code implementing the Extended ORPort.
The Extended ORPort interface is used by pluggable transports to communicate additional information to a Tor bridge, including address information. For more information on this interface, see pt-spec.txt in torspec.git.
There is no separate structure for extended ORPort connections; they use or_connection_t objects, and share most of their implementation with connection_or.c. Once the handshake is done, an extended ORPort connection turns into a regular OR connection, using connection_ext_or_transition().
Definition in file ext_orport.c.
#define connection_ext_or_auth_send_result_fail | ( | c | ) | connection_ext_or_auth_send_result(c, 0) |
Definition at line 345 of file ext_orport.c.
#define connection_ext_or_auth_send_result_success | ( | c | ) | connection_ext_or_auth_send_result(c, 1) |
Definition at line 343 of file ext_orport.c.
#define EXT_OR_AUTHTYPE_SAFECOOKIE 0x01 |
Definition at line 114 of file ext_orport.c.
#define EXT_OR_CMD_BT_CONTROL 0x1002 |
Definition at line 436 of file ext_orport.c.
#define EXT_OR_CMD_BT_DENY 0x1001 |
Definition at line 435 of file ext_orport.c.
#define EXT_OR_CMD_BT_OKAY 0x1000 |
Extended ORPort commands (Bridge-to-Transport)
Definition at line 434 of file ext_orport.c.
#define EXT_OR_CMD_TB_DONE 0x0000 |
Extended ORPort commands (Transport-to-Bridge)
Definition at line 429 of file ext_orport.c.
#define EXT_OR_CMD_TB_TRANSPORT 0x0002 |
Definition at line 431 of file ext_orport.c.
#define EXT_OR_CMD_TB_USERADDR 0x0001 |
Definition at line 430 of file ext_orport.c.
#define EXT_OR_CONN_STATE_IS_AUTHENTICATING | ( | st | ) | ((st) <= EXT_OR_CONN_STATE_AUTH_MAX) |
Definition at line 539 of file ext_orport.c.
#define EXT_OR_PORT_AUTH_CLIENT_TO_SERVER_CONST "ExtORPort authentication client-to-server hash" |
Definition at line 110 of file ext_orport.c.
#define EXT_OR_PORT_AUTH_COOKIE_HEADER "! Extended ORPort Auth Cookie !\x0a" |
Static cookie file header.
Definition at line 102 of file ext_orport.c.
#define EXT_OR_PORT_AUTH_COOKIE_HEADER_LEN 32 |
Length of the header of the cookie file.
Definition at line 100 of file ext_orport.c.
#define EXT_OR_PORT_AUTH_COOKIE_LEN 32 |
Length of authentication cookie.
Definition at line 98 of file ext_orport.c.
#define EXT_OR_PORT_AUTH_HASH_LEN DIGEST256_LEN |
Length of safe-cookie protocol hashes.
Definition at line 104 of file ext_orport.c.
#define EXT_OR_PORT_AUTH_NONCE_LEN 32 |
Length of safe-cookie protocol nonces.
Definition at line 106 of file ext_orport.c.
#define EXT_OR_PORT_AUTH_SERVER_TO_CLIENT_CONST "ExtORPort authentication server-to-client hash" |
Safe-cookie protocol constants.
Definition at line 108 of file ext_orport.c.
#define EXT_ORPORT_PRIVATE |
Definition at line 19 of file ext_orport.c.
|
static |
Receive the client's hash from conn, validate that it's correct, and then send the authentication results to the client.
Return -1 if there was an error during validation; return 0 if we need more data in conn, and return 1 if we successfully validated the client's hash and sent a happy authentication result.
Definition at line 367 of file ext_orport.c.
Referenced by connection_ext_or_auth_process_inbuf().
|
static |
Read the client's nonce out of conn, setup the safe-cookie crypto, and then send our own hash and nonce to the client
Return -1 if there was an error; return 0 if we need more data in conn, and return 1 if we successfully retrieved the client's nonce and sent our own.
Definition at line 301 of file ext_orport.c.
Referenced by connection_ext_or_auth_process_inbuf().
|
static |
Read data from conn and see if the client sent us the authentication type that they prefer to use in this session.
Return -1 if we received corrupted data or if we don't support the authentication type. Return 0 if we need more data in conn. Return 1 if the authentication type negotiation was successful.
Definition at line 170 of file ext_orport.c.
Referenced by connection_ext_or_auth_process_inbuf().
|
static |
Handle data from or_conn received on Extended ORPort. Return -1 on error. 0 on insufficient data. 1 on correct.
Definition at line 396 of file ext_orport.c.
|
static |
Send authentication results to conn. Successful results if success is set; failure results otherwise.
Definition at line 351 of file ext_orport.c.
int connection_ext_or_finished_flushing | ( | or_connection_t * | conn | ) |
conn finished flushing Extended ORPort messages to the network, and is now ready to accept OR traffic. This function does the transition.
Definition at line 628 of file ext_orport.c.
Referenced by connection_finished_flushing().
|
static |
Process a TRANSPORT command from the Extended ORPort. payload is a payload of size len.
If the TRANSPORT command was well formed, register the name of the transport on conn.
Return 0 on success and -1 on error.
Definition at line 512 of file ext_orport.c.
|
static |
Process a USERADDR command from the Extended ORPort. payload is a payload of size len.
If the USERADDR command was well formed, change the address of conn to the address on the USERADDR command.
Return 0 on success and -1 on error.
Definition at line 446 of file ext_orport.c.
int connection_ext_or_process_inbuf | ( | or_connection_t * | or_conn | ) |
Process Extended ORPort messages from or_conn.
Definition at line 544 of file ext_orport.c.
Referenced by connection_process_inbuf().
int connection_ext_or_start_auth | ( | or_connection_t * | or_conn | ) |
Initiate Extended ORPort authentication, by sending the list of supported authentication types to the client.
Definition at line 640 of file ext_orport.c.
Referenced by connection_init_accepted_conn().
|
static |
Transition from an Extended ORPort which accepts Extended ORPort messages, to an Extended ORport which accepts OR traffic.
Definition at line 87 of file ext_orport.c.
Referenced by connection_ext_or_finished_flushing().
|
static |
Get an Extended ORPort message from conn, and place it in out. Return -1 on fail, 0 if we need more data, and 1 if we successfully extracted an Extended ORPort command from the buffer.
Definition at line 56 of file ext_orport.c.
STATIC int connection_write_ext_or_command | ( | connection_t * | conn, |
uint16_t | command, | ||
const char * | body, | ||
size_t | bodylen | ||
) |
Write an Extended ORPort message to conn. Use command as the command type, bodylen as the body length, and body, if it's present, as the body of the message.
Definition at line 66 of file ext_orport.c.
void ext_or_cmd_free_ | ( | ext_or_cmd_t * | cmd | ) |
Deallocate the Extended ORPort message in cmd.
Definition at line 46 of file ext_orport.c.
ext_or_cmd_t * ext_or_cmd_new | ( | uint16_t | len | ) |
Allocate and return a structure capable of holding an Extended ORPort message of body length len.
Definition at line 36 of file ext_orport.c.
Referenced by fetch_ext_or_command_from_buf().
void ext_orport_free_all | ( | void | ) |
Free any leftover allocated memory of the ext_orport.c subsystem.
Definition at line 661 of file ext_orport.c.
char * get_ext_or_auth_cookie_file_name | ( | void | ) |
Helper: Return a newly allocated string containing a path to the file where we store our authentication cookie.
Definition at line 127 of file ext_orport.c.
Referenced by tor_cleanup().
STATIC int handle_client_auth_nonce | ( | const char * | client_nonce, |
size_t | client_nonce_len, | ||
char ** | client_hash_out, | ||
char ** | reply_out, | ||
size_t * | reply_len_out | ||
) |
Definition at line 192 of file ext_orport.c.
int init_ext_or_cookie_authentication | ( | int | is_enabled | ) |
Definition at line 142 of file ext_orport.c.
STATIC uint8_t* ext_or_auth_cookie = NULL |
If ext_or_auth_cookie_is_set, a secret cookie that we've stored to disk and which we're using to authenticate controllers. (If the controller can read it off disk, it has permission to connect.)
Definition at line 122 of file ext_orport.c.
Referenced by ext_orport_free_all().
STATIC int ext_or_auth_cookie_is_set = 0 |
If true, we've set ext_or_auth_cookie to a secret code and stored it to disk.
Definition at line 118 of file ext_orport.c.
Referenced by connection_ext_or_auth_handle_client_nonce().