tor  0.4.2.0-alpha-dev
rendparse.c
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
12 #include "core/or/or.h"
16 #include "feature/rend/rendparse.h"
17 #include "lib/memarea/memarea.h"
18 
19 #include "core/or/extend_info_st.h"
20 #include "feature/rend/rend_authorized_client_st.h"
21 #include "feature/rend/rend_intro_point_st.h"
22 #include "feature/rend/rend_service_descriptor_st.h"
23 
26  T1_START("rendezvous-service-descriptor", R_RENDEZVOUS_SERVICE_DESCRIPTOR,
27  EQ(1), NO_OBJ),
28  T1("version", R_VERSION, EQ(1), NO_OBJ),
29  T1("permanent-key", R_PERMANENT_KEY, NO_ARGS, NEED_KEY_1024),
30  T1("secret-id-part", R_SECRET_ID_PART, EQ(1), NO_OBJ),
31  T1("publication-time", R_PUBLICATION_TIME, CONCAT_ARGS, NO_OBJ),
32  T1("protocol-versions", R_PROTOCOL_VERSIONS, EQ(1), NO_OBJ),
33  T01("introduction-points", R_INTRODUCTION_POINTS, NO_ARGS, NEED_OBJ),
34  T1_END("signature", R_SIGNATURE, NO_ARGS, NEED_OBJ),
36 };
37 
41  T1_START("introduction-point", R_IPO_IDENTIFIER, EQ(1), NO_OBJ),
42  T1("ip-address", R_IPO_IP_ADDRESS, EQ(1), NO_OBJ),
43  T1("onion-port", R_IPO_ONION_PORT, EQ(1), NO_OBJ),
44  T1("onion-key", R_IPO_ONION_KEY, NO_ARGS, NEED_KEY_1024),
45  T1("service-key", R_IPO_SERVICE_KEY, NO_ARGS, NEED_KEY_1024),
47 };
48 
52  T1_START("client-name", C_CLIENT_NAME, CONCAT_ARGS, NO_OBJ),
53  T1("descriptor-cookie", C_DESCRIPTOR_COOKIE, EQ(1), NO_OBJ),
54  T01("client-key", C_CLIENT_KEY, NO_ARGS, NEED_SKEY_1024),
56 };
57 
71 int
73  char *desc_id_out,
74  char **intro_points_encrypted_out,
75  size_t *intro_points_encrypted_size_out,
76  size_t *encoded_size_out,
77  const char **next_out, const char *desc,
78  int as_hsdir)
79 {
81  tor_malloc_zero(sizeof(rend_service_descriptor_t));
82  char desc_hash[DIGEST_LEN];
83  const char *eos;
84  smartlist_t *tokens = smartlist_new();
85  directory_token_t *tok;
86  char secret_id_part[DIGEST_LEN];
87  int i, version, num_ok=1;
88  smartlist_t *versions;
89  char public_key_hash[DIGEST_LEN];
90  char test_desc_id[DIGEST_LEN];
91  memarea_t *area = NULL;
92  const int strict_time_fmt = as_hsdir;
93 
94  tor_assert(desc);
95  /* Check if desc starts correctly. */
96  if (strcmpstart(desc, "rendezvous-service-descriptor ")) {
97  log_info(LD_REND, "Descriptor does not start correctly.");
98  goto err;
99  }
100  /* Compute descriptor hash for later validation. */
101  if (router_get_hash_impl(desc, strlen(desc), desc_hash,
102  "rendezvous-service-descriptor ",
103  "\nsignature", '\n', DIGEST_SHA1) < 0) {
104  log_warn(LD_REND, "Couldn't compute descriptor hash.");
105  goto err;
106  }
107  /* Determine end of string. */
108  eos = strstr(desc, "\nrendezvous-service-descriptor ");
109  if (!eos)
110  eos = desc + strlen(desc);
111  else
112  eos = eos + 1;
113  /* Check length. */
114  if (eos-desc > REND_DESC_MAX_SIZE) {
115  /* XXXX+ If we are parsing this descriptor as a server, this
116  * should be a protocol warning. */
117  log_warn(LD_REND, "Descriptor length is %d which exceeds "
118  "maximum rendezvous descriptor size of %d bytes.",
119  (int)(eos-desc), REND_DESC_MAX_SIZE);
120  goto err;
121  }
122  /* Tokenize descriptor. */
123  area = memarea_new();
124  if (tokenize_string(area, desc, eos, tokens, desc_token_table, 0)) {
125  log_warn(LD_REND, "Error tokenizing descriptor.");
126  goto err;
127  }
128  /* Set next to next descriptor, if available. */
129  *next_out = eos;
130  /* Set length of encoded descriptor. */
131  *encoded_size_out = eos - desc;
132  /* Check min allowed length of token list. */
133  if (smartlist_len(tokens) < 7) {
134  log_warn(LD_REND, "Impossibly short descriptor.");
135  goto err;
136  }
137  /* Parse base32-encoded descriptor ID. */
138  tok = find_by_keyword(tokens, R_RENDEZVOUS_SERVICE_DESCRIPTOR);
139  tor_assert(tok == smartlist_get(tokens, 0));
140  tor_assert(tok->n_args == 1);
141  if (!rend_valid_descriptor_id(tok->args[0])) {
142  log_warn(LD_REND, "Invalid descriptor ID: '%s'", tok->args[0]);
143  goto err;
144  }
145  if (base32_decode(desc_id_out, DIGEST_LEN,
147  log_warn(LD_REND,
148  "Descriptor ID has wrong length or illegal characters: %s",
149  tok->args[0]);
150  goto err;
151  }
152  /* Parse descriptor version. */
153  tok = find_by_keyword(tokens, R_VERSION);
154  tor_assert(tok->n_args == 1);
155  result->version =
156  (int) tor_parse_long(tok->args[0], 10, 0, INT_MAX, &num_ok, NULL);
157  if (result->version != 2 || !num_ok) {
158  /* If it's <2, it shouldn't be under this format. If the number
159  * is greater than 2, we bumped it because we broke backward
160  * compatibility. See how version numbers in our other formats
161  * work. */
162  log_warn(LD_REND, "Unrecognized descriptor version: %s",
163  escaped(tok->args[0]));
164  goto err;
165  }
166  /* Parse public key. */
167  tok = find_by_keyword(tokens, R_PERMANENT_KEY);
168  result->pk = tok->key;
169  tok->key = NULL; /* Prevent free */
170  /* Parse secret ID part. */
171  tok = find_by_keyword(tokens, R_SECRET_ID_PART);
172  tor_assert(tok->n_args == 1);
173  if (strlen(tok->args[0]) != REND_SECRET_ID_PART_LEN_BASE32 ||
174  strspn(tok->args[0], BASE32_CHARS) != REND_SECRET_ID_PART_LEN_BASE32) {
175  log_warn(LD_REND, "Invalid secret ID part: '%s'", tok->args[0]);
176  goto err;
177  }
178  if (base32_decode(secret_id_part, DIGEST_LEN, tok->args[0], 32) !=
179  DIGEST_LEN) {
180  log_warn(LD_REND,
181  "Secret ID part has wrong length or illegal characters: %s",
182  tok->args[0]);
183  goto err;
184  }
185  /* Parse publication time -- up-to-date check is done when storing the
186  * descriptor. */
187  tok = find_by_keyword(tokens, R_PUBLICATION_TIME);
188  tor_assert(tok->n_args == 1);
189  if (parse_iso_time_(tok->args[0], &result->timestamp,
190  strict_time_fmt, 0) < 0) {
191  log_warn(LD_REND, "Invalid publication time: '%s'", tok->args[0]);
192  goto err;
193  }
194  /* Parse protocol versions. */
195  tok = find_by_keyword(tokens, R_PROTOCOL_VERSIONS);
196  tor_assert(tok->n_args == 1);
197  versions = smartlist_new();
198  smartlist_split_string(versions, tok->args[0], ",",
199  SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
200  for (i = 0; i < smartlist_len(versions); i++) {
201  version = (int) tor_parse_long(smartlist_get(versions, i),
202  10, 0, INT_MAX, &num_ok, NULL);
203  if (!num_ok) /* It's a string; let's ignore it. */
204  continue;
205  if (version >= REND_PROTOCOL_VERSION_BITMASK_WIDTH)
206  /* Avoid undefined left-shift behaviour. */
207  continue;
208  result->protocols |= 1 << version;
209  }
210  SMARTLIST_FOREACH(versions, char *, cp, tor_free(cp));
211  smartlist_free(versions);
212  /* Parse encrypted introduction points. Don't verify. */
213  tok = find_opt_by_keyword(tokens, R_INTRODUCTION_POINTS);
214  if (tok) {
215  if (strcmp(tok->object_type, "MESSAGE")) {
216  log_warn(LD_DIR, "Bad object type: introduction points should be of "
217  "type MESSAGE");
218  goto err;
219  }
220  *intro_points_encrypted_out = tor_memdup(tok->object_body,
221  tok->object_size);
222  *intro_points_encrypted_size_out = tok->object_size;
223  } else {
224  *intro_points_encrypted_out = NULL;
225  *intro_points_encrypted_size_out = 0;
226  }
227  /* Parse and verify signature. */
228  tok = find_by_keyword(tokens, R_SIGNATURE);
229  if (check_signature_token(desc_hash, DIGEST_LEN, tok, result->pk, 0,
230  "v2 rendezvous service descriptor") < 0)
231  goto err;
232  /* Verify that descriptor ID belongs to public key and secret ID part. */
233  if (crypto_pk_get_digest(result->pk, public_key_hash) < 0) {
234  log_warn(LD_REND, "Unable to compute rend descriptor public key digest");
235  goto err;
236  }
237  rend_get_descriptor_id_bytes(test_desc_id, public_key_hash,
238  secret_id_part);
239  if (tor_memneq(desc_id_out, test_desc_id, DIGEST_LEN)) {
240  log_warn(LD_REND, "Parsed descriptor ID does not match "
241  "computed descriptor ID.");
242  goto err;
243  }
244  goto done;
245  err:
246  rend_service_descriptor_free(result);
247  result = NULL;
248  done:
249  if (tokens) {
251  smartlist_free(tokens);
252  }
253  if (area)
254  memarea_drop_all(area);
255  *parsed_out = result;
256  if (result)
257  return 0;
258  return -1;
259 }
260 
266 int
267 rend_decrypt_introduction_points(char **ipos_decrypted,
268  size_t *ipos_decrypted_size,
269  const char *descriptor_cookie,
270  const char *ipos_encrypted,
271  size_t ipos_encrypted_size)
272 {
273  tor_assert(ipos_encrypted);
274  tor_assert(descriptor_cookie);
275  if (ipos_encrypted_size < 2) {
276  log_warn(LD_REND, "Size of encrypted introduction points is too "
277  "small.");
278  return -1;
279  }
280  if (ipos_encrypted[0] == (int)REND_BASIC_AUTH) {
281  char iv[CIPHER_IV_LEN], client_id[REND_BASIC_AUTH_CLIENT_ID_LEN],
282  session_key[CIPHER_KEY_LEN], *dec;
283  int declen, client_blocks;
284  size_t pos = 0, len, client_entries_len;
285  crypto_digest_t *digest;
286  crypto_cipher_t *cipher;
287  client_blocks = (int) ipos_encrypted[1];
288  client_entries_len = client_blocks * REND_BASIC_AUTH_CLIENT_MULTIPLE *
290  if (ipos_encrypted_size < 2 + client_entries_len + CIPHER_IV_LEN + 1) {
291  log_warn(LD_REND, "Size of encrypted introduction points is too "
292  "small.");
293  return -1;
294  }
295  memcpy(iv, ipos_encrypted + 2 + client_entries_len, CIPHER_IV_LEN);
296  digest = crypto_digest_new();
297  crypto_digest_add_bytes(digest, descriptor_cookie, REND_DESC_COOKIE_LEN);
299  crypto_digest_get_digest(digest, client_id,
301  crypto_digest_free(digest);
302  for (pos = 2; pos < 2 + client_entries_len;
304  if (tor_memeq(ipos_encrypted + pos, client_id,
306  /* Attempt to decrypt introduction points. */
307  cipher = crypto_cipher_new(descriptor_cookie);
308  if (crypto_cipher_decrypt(cipher, session_key, ipos_encrypted
310  CIPHER_KEY_LEN) < 0) {
311  log_warn(LD_REND, "Could not decrypt session key for client.");
312  crypto_cipher_free(cipher);
313  return -1;
314  }
315  crypto_cipher_free(cipher);
316 
317  len = ipos_encrypted_size - 2 - client_entries_len - CIPHER_IV_LEN;
318  dec = tor_malloc_zero(len + 1);
319  declen = crypto_cipher_decrypt_with_iv(session_key, dec, len,
320  ipos_encrypted + 2 + client_entries_len,
321  ipos_encrypted_size - 2 - client_entries_len);
322 
323  if (declen < 0) {
324  log_warn(LD_REND, "Could not decrypt introduction point string.");
325  tor_free(dec);
326  return -1;
327  }
328  if (fast_memcmpstart(dec, declen, "introduction-point ")) {
329  log_warn(LD_REND, "Decrypted introduction points don't "
330  "look like we could parse them.");
331  tor_free(dec);
332  continue;
333  }
334  *ipos_decrypted = dec;
335  *ipos_decrypted_size = declen;
336  return 0;
337  }
338  }
339  log_warn(LD_REND, "Could not decrypt introduction points. Please "
340  "check your authorization for this service!");
341  return -1;
342  } else if (ipos_encrypted[0] == (int)REND_STEALTH_AUTH) {
343  char *dec;
344  int declen;
345  if (ipos_encrypted_size < CIPHER_IV_LEN + 2) {
346  log_warn(LD_REND, "Size of encrypted introduction points is too "
347  "small.");
348  return -1;
349  }
350  dec = tor_malloc_zero(ipos_encrypted_size - CIPHER_IV_LEN - 1 + 1);
351 
352  declen = crypto_cipher_decrypt_with_iv(descriptor_cookie, dec,
353  ipos_encrypted_size -
354  CIPHER_IV_LEN - 1,
355  ipos_encrypted + 1,
356  ipos_encrypted_size - 1);
357 
358  if (declen < 0) {
359  log_warn(LD_REND, "Decrypting introduction points failed!");
360  tor_free(dec);
361  return -1;
362  }
363  *ipos_decrypted = dec;
364  *ipos_decrypted_size = declen;
365  return 0;
366  } else {
367  log_warn(LD_REND, "Unknown authorization type number: %d",
368  ipos_encrypted[0]);
369  return -1;
370  }
371 }
372 
377 int
379  const char *intro_points_encoded,
380  size_t intro_points_encoded_size)
381 {
382  const char *current_ipo, *end_of_intro_points;
383  smartlist_t *tokens = NULL;
384  directory_token_t *tok;
385  rend_intro_point_t *intro;
386  extend_info_t *info;
387  int result, num_ok=1;
388  memarea_t *area = NULL;
389  tor_assert(parsed);
391  tor_assert(!parsed->intro_nodes);
392  if (!intro_points_encoded || intro_points_encoded_size == 0) {
393  log_warn(LD_REND, "Empty or zero size introduction point list");
394  goto err;
395  }
396  /* Consider one intro point after the other. */
397  current_ipo = intro_points_encoded;
398  end_of_intro_points = intro_points_encoded + intro_points_encoded_size;
399  tokens = smartlist_new();
400  parsed->intro_nodes = smartlist_new();
401  area = memarea_new();
402 
403  while (!fast_memcmpstart(current_ipo, end_of_intro_points-current_ipo,
404  "introduction-point ")) {
405  /* Determine end of string. */
406  const char *eos = tor_memstr(current_ipo, end_of_intro_points-current_ipo,
407  "\nintroduction-point ");
408  if (!eos)
409  eos = end_of_intro_points;
410  else
411  eos = eos+1;
412  tor_assert(eos <= intro_points_encoded+intro_points_encoded_size);
413  /* Free tokens and clear token list. */
415  smartlist_clear(tokens);
416  memarea_clear(area);
417  /* Tokenize string. */
418  if (tokenize_string(area, current_ipo, eos, tokens, ipo_token_table, 0)) {
419  log_warn(LD_REND, "Error tokenizing introduction point");
420  goto err;
421  }
422  /* Advance to next introduction point, if available. */
423  current_ipo = eos;
424  /* Check minimum allowed length of introduction point. */
425  if (smartlist_len(tokens) < 5) {
426  log_warn(LD_REND, "Impossibly short introduction point.");
427  goto err;
428  }
429  /* Allocate new intro point and extend info. */
430  intro = tor_malloc_zero(sizeof(rend_intro_point_t));
431  info = intro->extend_info = tor_malloc_zero(sizeof(extend_info_t));
432  /* Parse identifier. */
433  tok = find_by_keyword(tokens, R_IPO_IDENTIFIER);
436  DIGEST_LEN) {
437  log_warn(LD_REND,
438  "Identity digest has wrong length or illegal characters: %s",
439  tok->args[0]);
440  rend_intro_point_free(intro);
441  goto err;
442  }
443  /* Write identifier to nickname. */
444  info->nickname[0] = '$';
445  base16_encode(info->nickname + 1, sizeof(info->nickname) - 1,
446  info->identity_digest, DIGEST_LEN);
447  /* Parse IP address. */
448  tok = find_by_keyword(tokens, R_IPO_IP_ADDRESS);
449  if (tor_addr_parse(&info->addr, tok->args[0])<0) {
450  log_warn(LD_REND, "Could not parse introduction point address.");
451  rend_intro_point_free(intro);
452  goto err;
453  }
454  if (tor_addr_family(&info->addr) != AF_INET) {
455  log_warn(LD_REND, "Introduction point address was not ipv4.");
456  rend_intro_point_free(intro);
457  goto err;
458  }
459 
460  /* Parse onion port. */
461  tok = find_by_keyword(tokens, R_IPO_ONION_PORT);
462  info->port = (uint16_t) tor_parse_long(tok->args[0],10,1,65535,
463  &num_ok,NULL);
464  if (!info->port || !num_ok) {
465  log_warn(LD_REND, "Introduction point onion port %s is invalid",
466  escaped(tok->args[0]));
467  rend_intro_point_free(intro);
468  goto err;
469  }
470  /* Parse onion key. */
471  tok = find_by_keyword(tokens, R_IPO_ONION_KEY);
472  if (!crypto_pk_public_exponent_ok(tok->key)) {
473  log_warn(LD_REND,
474  "Introduction point's onion key had invalid exponent.");
475  rend_intro_point_free(intro);
476  goto err;
477  }
478  info->onion_key = tok->key;
479  tok->key = NULL; /* Prevent free */
480  /* Parse service key. */
481  tok = find_by_keyword(tokens, R_IPO_SERVICE_KEY);
482  if (!crypto_pk_public_exponent_ok(tok->key)) {
483  log_warn(LD_REND,
484  "Introduction point key had invalid exponent.");
485  rend_intro_point_free(intro);
486  goto err;
487  }
488  intro->intro_key = tok->key;
489  tok->key = NULL; /* Prevent free */
490  /* Add extend info to list of introduction points. */
491  smartlist_add(parsed->intro_nodes, intro);
492  }
493  result = smartlist_len(parsed->intro_nodes);
494  goto done;
495 
496  err:
497  result = -1;
498 
499  done:
500  /* Free tokens and clear token list. */
501  if (tokens) {
503  smartlist_free(tokens);
504  }
505  if (area)
506  memarea_drop_all(area);
507 
508  return result;
509 }
510 
515 int
516 rend_parse_client_keys(strmap_t *parsed_clients, const char *ckstr)
517 {
518  int result = -1;
519  smartlist_t *tokens;
520  directory_token_t *tok;
521  const char *current_entry = NULL;
522  memarea_t *area = NULL;
523  char *err_msg = NULL;
524  if (!ckstr || strlen(ckstr) == 0)
525  return -1;
526  tokens = smartlist_new();
527  /* Begin parsing with first entry, skipping comments or whitespace at the
528  * beginning. */
529  area = memarea_new();
530  current_entry = eat_whitespace(ckstr);
531  while (!strcmpstart(current_entry, "client-name ")) {
532  rend_authorized_client_t *parsed_entry;
533  /* Determine end of string. */
534  const char *eos = strstr(current_entry, "\nclient-name ");
535  if (!eos)
536  eos = current_entry + strlen(current_entry);
537  else
538  eos = eos + 1;
539  /* Free tokens and clear token list. */
541  smartlist_clear(tokens);
542  memarea_clear(area);
543  /* Tokenize string. */
544  if (tokenize_string(area, current_entry, eos, tokens,
546  log_warn(LD_REND, "Error tokenizing client keys file.");
547  goto err;
548  }
549  /* Advance to next entry, if available. */
550  current_entry = eos;
551  /* Check minimum allowed length of token list. */
552  if (smartlist_len(tokens) < 2) {
553  log_warn(LD_REND, "Impossibly short client key entry.");
554  goto err;
555  }
556  /* Parse client name. */
557  tok = find_by_keyword(tokens, C_CLIENT_NAME);
558  tor_assert(tok == smartlist_get(tokens, 0));
559  tor_assert(tok->n_args == 1);
560 
561  if (!rend_valid_client_name(tok->args[0])) {
562  log_warn(LD_CONFIG, "Illegal client name: %s. (Length must be "
563  "between 1 and %d, and valid characters are "
564  "[A-Za-z0-9+-_].)", tok->args[0], REND_CLIENTNAME_MAX_LEN);
565  goto err;
566  }
567  /* Check if client name is duplicate. */
568  if (strmap_get(parsed_clients, tok->args[0])) {
569  log_warn(LD_CONFIG, "HiddenServiceAuthorizeClient contains a "
570  "duplicate client name: '%s'. Ignoring.", tok->args[0]);
571  goto err;
572  }
573  parsed_entry = tor_malloc_zero(sizeof(rend_authorized_client_t));
574  parsed_entry->client_name = tor_strdup(tok->args[0]);
575  strmap_set(parsed_clients, parsed_entry->client_name, parsed_entry);
576  /* Parse client key. */
577  tok = find_opt_by_keyword(tokens, C_CLIENT_KEY);
578  if (tok) {
579  parsed_entry->client_key = tok->key;
580  tok->key = NULL; /* Prevent free */
581  }
582 
583  /* Parse descriptor cookie. */
584  tok = find_by_keyword(tokens, C_DESCRIPTOR_COOKIE);
585  tor_assert(tok->n_args == 1);
586  if (rend_auth_decode_cookie(tok->args[0], parsed_entry->descriptor_cookie,
587  NULL, &err_msg) < 0) {
588  tor_assert(err_msg);
589  log_warn(LD_REND, "%s", err_msg);
590  tor_free(err_msg);
591  goto err;
592  }
593  }
594  result = strmap_size(parsed_clients);
595  goto done;
596  err:
597  result = -1;
598  done:
599  /* Free tokens and clear token list. */
601  smartlist_free(tokens);
602  if (area)
603  memarea_drop_all(area);
604  return result;
605 }
int crypto_cipher_decrypt_with_iv(const char *key, char *to, size_t tolen, const char *from, size_t fromlen)
struct crypto_pk_t * key
Definition: parsecommon.h:210
Header file for rendcommon.c.
int rend_auth_decode_cookie(const char *cookie_in, uint8_t *cookie_out, rend_auth_type_t *auth_type_out, char **err_msg_out)
Definition: rendcommon.c:924
#define END_OF_TABLE
Definition: parsecommon.h:244
int rend_valid_descriptor_id(const char *query)
Definition: rendcommon.c:733
void crypto_digest_get_digest(crypto_digest_t *digest, char *out, size_t out_len)
void smartlist_add(smartlist_t *sl, void *element)
#define REND_DESC_MAX_SIZE
Definition: or.h:387
#define REND_DESC_ID_V2_LEN_BASE32
Definition: or.h:354
#define REND_BASIC_AUTH_CLIENT_ID_LEN
Definition: or.h:374
void crypto_digest_add_bytes(crypto_digest_t *digest, const char *data, size_t len)
int rend_parse_introduction_points(rend_service_descriptor_t *parsed, const char *intro_points_encoded, size_t intro_points_encoded_size)
Definition: rendparse.c:378
int strcmpstart(const char *s1, const char *s2)
Definition: util_string.c:206
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)
Definition: rendparse.c:267
#define tor_free(p)
Definition: malloc.h:52
#define CIPHER_KEY_LEN
Definition: crypto_cipher.h:22
#define T1_START(s, t, a, o)
Definition: parsecommon.h:252
void memarea_clear(memarea_t *area)
Definition: memarea.c:178
memarea_t * memarea_new(void)
Definition: memarea.c:153
#define REND_CLIENTNAME_MAX_LEN
Definition: or.h:395
crypto_pk_t * onion_key
#define CIPHER_IV_LEN
Definition: crypto_cipher.h:24
int parse_iso_time_(const char *cp, time_t *t, int strict, int nospace)
Definition: time_fmt.c:336
extend_info_t * extend_info
int base32_decode(char *dest, size_t destlen, const char *src, size_t srclen)
Definition: binascii.c:90
#define NO_ARGS
Definition: parsecommon.h:265
tor_assert(buffer)
static token_rule_t ipo_token_table[]
Definition: rendparse.c:40
static token_rule_t client_keys_token_table[]
Definition: rendparse.c:51
int tor_memeq(const void *a, const void *b, size_t sz)
Definition: di_ops.c:107
char nickname[MAX_HEX_NICKNAME_LEN+1]
#define DIGEST_LEN
Definition: digest_sizes.h:20
Master header file for Tor-specific functionality.
const char * eat_whitespace(const char *s)
Definition: util_string.c:268
#define REND_BASIC_AUTH_CLIENT_ENTRY_LEN
Definition: or.h:383
int tor_addr_parse(tor_addr_t *addr, const char *src)
Definition: address.c:1255
#define REND_SECRET_ID_PART_LEN_BASE32
Definition: or.h:358
struct crypto_pk_t * intro_key
Header for memarea.c.
#define EQ(n)
Definition: parsecommon.h:271
int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix)
Definition: util_string.c:229
void rend_get_descriptor_id_bytes(char *descriptor_id_out, const char *service_id, const char *secret_id_part)
Definition: rendcommon.c:87
int crypto_cipher_decrypt(crypto_cipher_t *env, char *to, const char *from, size_t fromlen)
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
Definition: binascii.c:478
#define CONCAT_ARGS
Definition: parsecommon.h:267
int rend_parse_client_keys(strmap_t *parsed_clients, const char *ckstr)
Definition: rendparse.c:516
#define LD_REND
Definition: log.h:81
int rend_valid_client_name(const char *client_name)
Definition: rendcommon.c:751
directory_token_t * find_opt_by_keyword(const smartlist_t *s, directory_keyword keyword)
Definition: parsecommon.c:450
#define REND_INTRO_POINT_ID_LEN_BASE32
Definition: or.h:362
int crypto_pk_public_exponent_ok(const crypto_pk_t *env)
#define T1_END(s, t, a, o)
Definition: parsecommon.h:254
#define LD_DIR
Definition: log.h:85
static token_rule_t desc_token_table[]
Definition: rendparse.c:25
Header file for parsecommon.c.
#define REND_BASIC_AUTH_CLIENT_MULTIPLE
Definition: or.h:379
crypto_cipher_t * crypto_cipher_new(const char *key)
Definition: crypto_cipher.c:65
#define BASE32_CHARS
Definition: binascii.h:53
int crypto_pk_get_digest(const crypto_pk_t *pk, char *digest_out)
Definition: crypto_rsa.c:356
char identity_digest[DIGEST_LEN]
#define SMARTLIST_FOREACH(sl, type, var, cmd)
const char * escaped(const char *s)
Definition: escape.c:126
#define T1(s, t, a, o)
Definition: parsecommon.h:250
void token_clear(directory_token_t *tok)
Definition: parsecommon.c:41
long tor_parse_long(const char *s, int base, long min, long max, int *ok, char **next)
Definition: parse_int.c:56
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)
Definition: rendparse.c:72
int router_get_hash_impl(const char *s, size_t s_len, char *digest, const char *start_str, const char *end_str, char end_c, digest_algorithm_t alg)
Definition: sigcommon.c:74
int check_signature_token(const char *digest, ssize_t digest_len, directory_token_t *tok, crypto_pk_t *pkey, int flags, const char *doctype)
Definition: sigcommon.c:143
tor_addr_t addr
void smartlist_clear(smartlist_t *sl)
#define REND_DESC_COOKIE_LEN
Definition: or.h:366
int tokenize_string(memarea_t *area, const char *start, const char *end, smartlist_t *out, const token_rule_t *table, int flags)
Definition: parsecommon.c:53
#define T01(s, t, a, o)
Definition: parsecommon.h:258
Header file for sigcommon.c.
#define LD_CONFIG
Definition: log.h:65
crypto_digest_t * crypto_digest_new(void)
static sa_family_t tor_addr_family(const tor_addr_t *a)
Definition: address.h:179
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max)