34 T1(
"ntor-onion-key", K_ONION_KEY_NTOR,
GE(1),
NO_OBJ ),
50 int started_with_annotations;
55 #define CHECK_LENGTH() STMT_BEGIN \
60 #define NEXT_LINE() STMT_BEGIN \
61 s = memchr(s, '\n', eos-s); \
62 if (!s || eos - s <= 1) \
69 started_with_annotations = (*s ==
'@');
71 if (started_with_annotations) {
86 while (eos - s > 32) {
110 const char *location;
113 location =
"download or generated string";
119 location =
"journal";
122 location =
"unknown location";
142 const char *s,
const char *start_of_next_microdesc,
147 const char *cp = tor_memstr(s, start_of_next_microdesc-s,
"onion-key");
149 const bool no_onion_key = (cp == NULL);
154 md->
bodylen = start_of_next_microdesc - cp;
159 md->
body = (
char*)cp;
160 md->
off = cp - start;
164 return no_onion_key ? -1 : 0;
179 const char *s,
const char *start_of_next_microdesc,
180 int allow_annotations,
185 int flags = allow_annotations ? TS_ANNOTATIONS_OK : 0;
190 log_warn(
LD_DIR,
"Unparseable microdescriptor found in %s",
197 log_warn(
LD_DIR,
"Bad last-listed time in microdescriptor");
202 tok = find_by_keyword(tokens, K_ONION_KEY);
205 "Relay's onion key had invalid exponent.");
210 crypto_pk_free(tok->
key);
216 log_warn(
LD_DIR,
"Bogus ntor-onion-key in microdesc");
227 if (!strcmp(t->args[0],
"ed25519")) {
229 log_warn(
LD_DIR,
"Extra ed25519 key in microdesc");
230 smartlist_free(id_lines);
235 log_warn(
LD_DIR,
"Bogus ed25519 key in microdesc");
236 smartlist_free(id_lines);
241 } SMARTLIST_FOREACH_END(t);
242 smartlist_free(id_lines);
249 smartlist_free(a_lines);
266 if (policy_is_reject_star_or_null(md->
exit_policy) &&
276 smartlist_free(tokens);
294 int allow_annotations,
301 const char *start = s;
302 const char *start_of_next_microdesc;
315 if (!start_of_next_microdesc)
316 start_of_next_microdesc = eos;
321 const bool body_not_found =
323 start_of_next_microdesc,
327 if (body_not_found) {
328 log_fn(LOG_PROTOCOL_WARN,
LD_DIR,
"Malformed or truncated descriptor");
334 allow_annotations, where) == 0) {
341 if (! okay && invalid_digests_out) {
347 s = start_of_next_microdesc;
Header file for config.c.
Header for crypto_curve25519.c.
int curve25519_public_from_base64(curve25519_public_key_t *pkey, const char *input)
int crypto_digest256(char *digest, const char *m, size_t len, digest_algorithm_t algorithm)
Header for crypto_ed25519.c.
int crypto_pk_public_exponent_ok(const crypto_pk_t *env)
#define log_fn(severity, domain, args,...)
void memarea_clear(memarea_t *area)
memarea_t * memarea_new(void)
#define memarea_drop_all(area)
Header file for microdesc.c.
static int microdesc_extract_body(microdesc_t *md, const char *start, const char *s, const char *start_of_next_microdesc, saved_location_t where)
static int microdesc_parse_fields(microdesc_t *md, memarea_t *area, const char *s, const char *start_of_next_microdesc, int allow_annotations, saved_location_t where)
static const char * saved_location_to_string(saved_location_t where)
static token_rule_t microdesc_token_table[]
static const char * find_start_of_next_microdesc(const char *s, const char *eos)
smartlist_t * microdescs_parse_from_string(const char *s, const char *eos, int allow_annotations, saved_location_t where, smartlist_t *invalid_digests_out)
Header file for microdesc_parse.c.
Microdescriptor structure.
Header file for nickname.c.
Header file for nodefamily.c.
Master header file for Tor-specific functionality.
void token_clear(directory_token_t *tok)
int tokenize_string(memarea_t *area, const char *start, const char *end, smartlist_t *out, const token_rule_t *table, int flags)
directory_token_t * find_opt_by_keyword(const smartlist_t *s, directory_keyword keyword)
smartlist_t * find_all_by_keyword(const smartlist_t *s, directory_keyword k)
Header file for parsecommon.c.
#define T1_START(s, t, a, o)
short_policy_t * parse_short_policy(const char *summary)
int short_policy_is_reject_star(const short_policy_t *policy)
Header file for policies.c.
Header file for router.c.
int find_single_ipv6_orport(const smartlist_t *list, tor_addr_t *addr_out, uint16_t *port_out)
Header file for routerparse.c.
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
struct short_policy_t * exit_policy
saved_location_bitfield_t saved_location
struct curve25519_public_key_t * onion_curve25519_pkey
char digest[DIGEST256_LEN]
unsigned int policy_is_reject_star
struct nodefamily_t * family
struct ed25519_public_key_t * ed25519_identity_pkey
struct short_policy_t * ipv6_exit_policy
int parse_iso_time(const char *cp, time_t *t)
int strcmpstart(const char *s1, const char *s2)
const char * eat_whitespace_eos(const char *s, const char *eos)