tor  0.4.2.1-alpha-dev
Functions | Variables
rendparse.c File Reference
#include "core/or/or.h"
#include "feature/dirparse/parsecommon.h"
#include "feature/dirparse/sigcommon.h"
#include "feature/rend/rendcommon.h"
#include "feature/rend/rendparse.h"
#include "lib/memarea/memarea.h"
#include "core/or/extend_info_st.h"
#include "feature/rend/rend_authorized_client_st.h"
#include "feature/rend/rend_intro_point_st.h"
#include "feature/rend/rend_service_descriptor_st.h"

Go to the source code of this file.

Functions

int rend_parse_v2_service_descriptor (rend_service_descriptor_t **parsed_out, char *desc_id_out, char **intro_points_encrypted_out, size_t *intro_points_encrypted_size_out, size_t *encoded_size_out, const char **next_out, const char *desc, int as_hsdir)
 
int rend_decrypt_introduction_points (char **ipos_decrypted, size_t *ipos_decrypted_size, const char *descriptor_cookie, const char *ipos_encrypted, size_t ipos_encrypted_size)
 
int rend_parse_introduction_points (rend_service_descriptor_t *parsed, const char *intro_points_encoded, size_t intro_points_encoded_size)
 
int rend_parse_client_keys (strmap_t *parsed_clients, const char *ckstr)
 

Variables

static token_rule_t desc_token_table []
 
static token_rule_t ipo_token_table []
 
static token_rule_t client_keys_token_table []
 

Detailed Description

Code to parse and validate v2 hidden service descriptors.

Definition in file rendparse.c.

Function Documentation

◆ rend_decrypt_introduction_points()

int rend_decrypt_introduction_points ( char **  ipos_decrypted,
size_t *  ipos_decrypted_size,
const char *  descriptor_cookie,
const char *  ipos_encrypted,
size_t  ipos_encrypted_size 
)

Decrypt the encrypted introduction points in ipos_encrypted of length ipos_encrypted_size using descriptor_cookie and write the result to a newly allocated string that is pointed to by ipos_decrypted and its length to ipos_decrypted_size. Return 0 if decryption was successful and -1 otherwise.

Definition at line 267 of file rendparse.c.

References tor_assert().

◆ rend_parse_client_keys()

int rend_parse_client_keys ( strmap_t *  parsed_clients,
const char *  ckstr 
)

Parse the content of a client_key file in ckstr and add rend_authorized_client_t's for each parsed client to parsed_clients. Return the number of parsed clients as result or -1 for failure.

Definition at line 516 of file rendparse.c.

References client_keys_token_table, eat_whitespace(), memarea_clear(), memarea_new(), smartlist_clear(), SMARTLIST_FOREACH, strcmpstart(), token_clear(), and tokenize_string().

◆ rend_parse_introduction_points()

int rend_parse_introduction_points ( rend_service_descriptor_t parsed,
const char *  intro_points_encoded,
size_t  intro_points_encoded_size 
)

Parse the encoded introduction points in intro_points_encoded of length intro_points_encoded_size and write the result to the descriptor in parsed; return the number of successfully parsed introduction points or -1 in case of a failure.

Function may only be invoked once.

Definition at line 378 of file rendparse.c.

References rend_service_descriptor_t::intro_nodes, and tor_assert().

◆ rend_parse_v2_service_descriptor()

int rend_parse_v2_service_descriptor ( rend_service_descriptor_t **  parsed_out,
char *  desc_id_out,
char **  intro_points_encrypted_out,
size_t *  intro_points_encrypted_size_out,
size_t *  encoded_size_out,
const char **  next_out,
const char *  desc,
int  as_hsdir 
)

Parse and validate the ASCII-encoded v2 descriptor in desc, write the parsed descriptor to the newly allocated *parsed_out, the binary descriptor ID of length DIGEST_LEN to desc_id_out, the encrypted introduction points to the newly allocated *intro_points_encrypted_out, their encrypted size to *intro_points_encrypted_size_out, the size of the encoded descriptor to *encoded_size_out, and a pointer to the possibly next descriptor to *next_out; return 0 for success (including validation) and -1 for failure.

If as_hsdir is 1, we're parsing this as an HSDir, and we should be strict about time formats.

Definition at line 72 of file rendparse.c.

Referenced by rend_cache_store_v2_desc_as_dir(), rend_cache_store_v2_desc_as_service(), and rend_desc_v2_is_parsable().

Variable Documentation

◆ client_keys_token_table

token_rule_t client_keys_token_table[]
static
Initial value:
= {
T1_START("client-name", C_CLIENT_NAME, CONCAT_ARGS, NO_OBJ),
T1("descriptor-cookie", C_DESCRIPTOR_COOKIE, EQ(1), NO_OBJ),
T01("client-key", C_CLIENT_KEY, NO_ARGS, NEED_SKEY_1024),
}
#define END_OF_TABLE
Definition: parsecommon.h:244
#define T1_START(s, t, a, o)
Definition: parsecommon.h:252
#define NO_ARGS
Definition: parsecommon.h:265
#define EQ(n)
Definition: parsecommon.h:271
#define CONCAT_ARGS
Definition: parsecommon.h:267
#define T1(s, t, a, o)
Definition: parsecommon.h:250
#define T01(s, t, a, o)
Definition: parsecommon.h:258

List of tokens recognized in the (possibly encrypted) list of introduction points of rendezvous service descriptors

Definition at line 51 of file rendparse.c.

Referenced by rend_parse_client_keys().

◆ desc_token_table

token_rule_t desc_token_table[]
static
Initial value:
= {
T1_START("rendezvous-service-descriptor", R_RENDEZVOUS_SERVICE_DESCRIPTOR,
EQ(1), NO_OBJ),
T1("version", R_VERSION, EQ(1), NO_OBJ),
T1("permanent-key", R_PERMANENT_KEY, NO_ARGS, NEED_KEY_1024),
T1("secret-id-part", R_SECRET_ID_PART, EQ(1), NO_OBJ),
T1("publication-time", R_PUBLICATION_TIME, CONCAT_ARGS, NO_OBJ),
T1("protocol-versions", R_PROTOCOL_VERSIONS, EQ(1), NO_OBJ),
T01("introduction-points", R_INTRODUCTION_POINTS, NO_ARGS, NEED_OBJ),
T1_END("signature", R_SIGNATURE, NO_ARGS, NEED_OBJ),
}
#define END_OF_TABLE
Definition: parsecommon.h:244
#define T1_START(s, t, a, o)
Definition: parsecommon.h:252
#define NO_ARGS
Definition: parsecommon.h:265
#define EQ(n)
Definition: parsecommon.h:271
#define CONCAT_ARGS
Definition: parsecommon.h:267
#define T1_END(s, t, a, o)
Definition: parsecommon.h:254
#define T1(s, t, a, o)
Definition: parsecommon.h:250
#define T01(s, t, a, o)
Definition: parsecommon.h:258

List of tokens recognized in rendezvous service descriptors

Definition at line 25 of file rendparse.c.

◆ ipo_token_table

token_rule_t ipo_token_table[]
static
Initial value:
= {
T1_START("introduction-point", R_IPO_IDENTIFIER, EQ(1), NO_OBJ),
T1("ip-address", R_IPO_IP_ADDRESS, EQ(1), NO_OBJ),
T1("onion-port", R_IPO_ONION_PORT, EQ(1), NO_OBJ),
T1("onion-key", R_IPO_ONION_KEY, NO_ARGS, NEED_KEY_1024),
T1("service-key", R_IPO_SERVICE_KEY, NO_ARGS, NEED_KEY_1024),
}
#define END_OF_TABLE
Definition: parsecommon.h:244
#define T1_START(s, t, a, o)
Definition: parsecommon.h:252
#define NO_ARGS
Definition: parsecommon.h:265
#define EQ(n)
Definition: parsecommon.h:271
#define T1(s, t, a, o)
Definition: parsecommon.h:250

List of tokens recognized in the (encrypted) list of introduction points of rendezvous service descriptors

Definition at line 40 of file rendparse.c.