routerparse.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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-2016, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file routerparse.h
  8. * \brief Header file for routerparse.c.
  9. **/
  10. #ifndef TOR_ROUTERPARSE_H
  11. #define TOR_ROUTERPARSE_H
  12. int router_get_router_hash(const char *s, size_t s_len, char *digest);
  13. int router_get_dir_hash(const char *s, char *digest);
  14. int router_get_networkstatus_v3_hashes(const char *s,
  15. common_digests_t *digests);
  16. int router_get_extrainfo_hash(const char *s, size_t s_len, char *digest);
  17. #define DIROBJ_MAX_SIG_LEN 256
  18. char *router_get_dirobj_signature(const char *digest,
  19. size_t digest_len,
  20. const crypto_pk_t *private_key);
  21. int router_append_dirobj_signature(char *buf, size_t buf_len,
  22. const char *digest,
  23. size_t digest_len,
  24. crypto_pk_t *private_key);
  25. int router_parse_list_from_string(const char **s, const char *eos,
  26. smartlist_t *dest,
  27. saved_location_t saved_location,
  28. int is_extrainfo,
  29. int allow_annotations,
  30. const char *prepend_annotations,
  31. smartlist_t *invalid_digests_out);
  32. routerinfo_t *router_parse_entry_from_string(const char *s, const char *end,
  33. int cache_copy,
  34. int allow_annotations,
  35. const char *prepend_annotations,
  36. int *can_dl_again_out);
  37. extrainfo_t *extrainfo_parse_entry_from_string(const char *s, const char *end,
  38. int cache_copy, struct digest_ri_map_t *routermap,
  39. int *can_dl_again_out);
  40. MOCK_DECL(addr_policy_t *, router_parse_addr_policy_item_from_string,
  41. (const char *s, int assume_action, int *malformed_list));
  42. version_status_t tor_version_is_obsolete(const char *myversion,
  43. const char *versionlist);
  44. int tor_version_parse_platform(const char *platform,
  45. tor_version_t *version_out,
  46. int strict);
  47. int tor_version_as_new_as(const char *platform, const char *cutoff);
  48. int tor_version_parse(const char *s, tor_version_t *out);
  49. int tor_version_compare(tor_version_t *a, tor_version_t *b);
  50. int tor_version_same_series(tor_version_t *a, tor_version_t *b);
  51. void sort_version_list(smartlist_t *lst, int remove_duplicates);
  52. void assert_addr_policy_ok(smartlist_t *t);
  53. void dump_distinct_digest_count(int severity);
  54. int compare_vote_routerstatus_entries(const void **_a, const void **_b);
  55. int networkstatus_verify_bw_weights(networkstatus_t *ns, int);
  56. networkstatus_t *networkstatus_parse_vote_from_string(const char *s,
  57. const char **eos_out,
  58. networkstatus_type_t ns_type);
  59. ns_detached_signatures_t *networkstatus_parse_detached_signatures(
  60. const char *s, const char *eos);
  61. smartlist_t *microdescs_parse_from_string(const char *s, const char *eos,
  62. int allow_annotations,
  63. saved_location_t where,
  64. smartlist_t *invalid_digests_out);
  65. authority_cert_t *authority_cert_parse_from_string(const char *s,
  66. const char **end_of_string);
  67. int rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out,
  68. char *desc_id_out,
  69. char **intro_points_encrypted_out,
  70. size_t *intro_points_encrypted_size_out,
  71. size_t *encoded_size_out,
  72. const char **next_out, const char *desc,
  73. int as_hsdir);
  74. int rend_decrypt_introduction_points(char **ipos_decrypted,
  75. size_t *ipos_decrypted_size,
  76. const char *descriptor_cookie,
  77. const char *ipos_encrypted,
  78. size_t ipos_encrypted_size);
  79. int rend_parse_introduction_points(rend_service_descriptor_t *parsed,
  80. const char *intro_points_encoded,
  81. size_t intro_points_encoded_size);
  82. int rend_parse_client_keys(strmap_t *parsed_clients, const char *str);
  83. void routerparse_init(void);
  84. void routerparse_free_all(void);
  85. #ifdef ROUTERPARSE_PRIVATE
  86. /*
  87. * One entry in the list of dumped descriptors; filename dumped to, length,
  88. * SHA-256 and timestamp.
  89. */
  90. typedef struct {
  91. char *filename;
  92. size_t len;
  93. uint8_t digest_sha256[DIGEST256_LEN];
  94. time_t when;
  95. } dumped_desc_t;
  96. EXTERN(uint64_t, len_descs_dumped)
  97. EXTERN(smartlist_t *, descs_dumped)
  98. STATIC int routerstatus_parse_guardfraction(const char *guardfraction_str,
  99. networkstatus_t *vote,
  100. vote_routerstatus_t *vote_rs,
  101. routerstatus_t *rs);
  102. MOCK_DECL(STATIC dumped_desc_t *, dump_desc_populate_one_file,
  103. (const char *dirname, const char *f));
  104. STATIC void dump_desc_populate_fifo_from_directory(const char *dirname);
  105. STATIC void dump_desc(const char *desc, const char *type);
  106. STATIC void dump_desc_fifo_cleanup(void);
  107. struct memarea_t;
  108. STATIC routerstatus_t *routerstatus_parse_entry_from_string(
  109. struct memarea_t *area,
  110. const char **s, smartlist_t *tokens,
  111. networkstatus_t *vote,
  112. vote_routerstatus_t *vote_rs,
  113. int consensus_method,
  114. consensus_flavor_t flav);
  115. #endif
  116. #define ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1"
  117. #endif