routerparse.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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-2017, 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_networkstatus_v3_signed_boundaries(const char *s,
  17. const char **start_out,
  18. const char **end_out);
  19. int router_get_networkstatus_v3_sha3_as_signed(uint8_t *digest_out,
  20. const char *s);
  21. int router_get_extrainfo_hash(const char *s, size_t s_len, char *digest);
  22. #define DIROBJ_MAX_SIG_LEN 256
  23. char *router_get_dirobj_signature(const char *digest,
  24. size_t digest_len,
  25. const crypto_pk_t *private_key);
  26. int router_append_dirobj_signature(char *buf, size_t buf_len,
  27. const char *digest,
  28. size_t digest_len,
  29. crypto_pk_t *private_key);
  30. int router_parse_list_from_string(const char **s, const char *eos,
  31. smartlist_t *dest,
  32. saved_location_t saved_location,
  33. int is_extrainfo,
  34. int allow_annotations,
  35. const char *prepend_annotations,
  36. smartlist_t *invalid_digests_out);
  37. routerinfo_t *router_parse_entry_from_string(const char *s, const char *end,
  38. int cache_copy,
  39. int allow_annotations,
  40. const char *prepend_annotations,
  41. int *can_dl_again_out);
  42. extrainfo_t *extrainfo_parse_entry_from_string(const char *s, const char *end,
  43. int cache_copy, struct digest_ri_map_t *routermap,
  44. int *can_dl_again_out);
  45. MOCK_DECL(addr_policy_t *, router_parse_addr_policy_item_from_string,
  46. (const char *s, int assume_action, int *malformed_list));
  47. version_status_t tor_version_is_obsolete(const char *myversion,
  48. const char *versionlist);
  49. int tor_version_parse_platform(const char *platform,
  50. tor_version_t *version_out,
  51. int strict);
  52. int tor_version_as_new_as(const char *platform, const char *cutoff);
  53. int tor_version_parse(const char *s, tor_version_t *out);
  54. int tor_version_compare(tor_version_t *a, tor_version_t *b);
  55. int tor_version_same_series(tor_version_t *a, tor_version_t *b);
  56. void sort_version_list(smartlist_t *lst, int remove_duplicates);
  57. void assert_addr_policy_ok(smartlist_t *t);
  58. void dump_distinct_digest_count(int severity);
  59. int compare_vote_routerstatus_entries(const void **_a, const void **_b);
  60. int networkstatus_verify_bw_weights(networkstatus_t *ns, int);
  61. networkstatus_t *networkstatus_parse_vote_from_string(const char *s,
  62. const char **eos_out,
  63. networkstatus_type_t ns_type);
  64. ns_detached_signatures_t *networkstatus_parse_detached_signatures(
  65. const char *s, const char *eos);
  66. smartlist_t *microdescs_parse_from_string(const char *s, const char *eos,
  67. int allow_annotations,
  68. saved_location_t where,
  69. smartlist_t *invalid_digests_out);
  70. authority_cert_t *authority_cert_parse_from_string(const char *s,
  71. const char **end_of_string);
  72. int rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out,
  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. int rend_decrypt_introduction_points(char **ipos_decrypted,
  80. size_t *ipos_decrypted_size,
  81. const char *descriptor_cookie,
  82. const char *ipos_encrypted,
  83. size_t ipos_encrypted_size);
  84. int rend_parse_introduction_points(rend_service_descriptor_t *parsed,
  85. const char *intro_points_encoded,
  86. size_t intro_points_encoded_size);
  87. int rend_parse_client_keys(strmap_t *parsed_clients, const char *str);
  88. void routerparse_init(void);
  89. void routerparse_free_all(void);
  90. #ifdef ROUTERPARSE_PRIVATE
  91. /*
  92. * One entry in the list of dumped descriptors; filename dumped to, length,
  93. * SHA-256 and timestamp.
  94. */
  95. typedef struct {
  96. char *filename;
  97. size_t len;
  98. uint8_t digest_sha256[DIGEST256_LEN];
  99. time_t when;
  100. } dumped_desc_t;
  101. EXTERN(uint64_t, len_descs_dumped)
  102. EXTERN(smartlist_t *, descs_dumped)
  103. STATIC int routerstatus_parse_guardfraction(const char *guardfraction_str,
  104. networkstatus_t *vote,
  105. vote_routerstatus_t *vote_rs,
  106. routerstatus_t *rs);
  107. MOCK_DECL(STATIC dumped_desc_t *, dump_desc_populate_one_file,
  108. (const char *dirname, const char *f));
  109. STATIC void dump_desc_populate_fifo_from_directory(const char *dirname);
  110. STATIC void dump_desc_fifo_cleanup(void);
  111. struct memarea_t;
  112. STATIC routerstatus_t *routerstatus_parse_entry_from_string(
  113. struct memarea_t *area,
  114. const char **s, smartlist_t *tokens,
  115. networkstatus_t *vote,
  116. vote_routerstatus_t *vote_rs,
  117. int consensus_method,
  118. consensus_flavor_t flav);
  119. MOCK_DECL(STATIC void,dump_desc,(const char *desc, const char *type));
  120. MOCK_DECL(STATIC int, router_compute_hash_final,(char *digest,
  121. const char *start, size_t len,
  122. digest_algorithm_t alg));
  123. MOCK_DECL(STATIC int, signed_digest_equals,
  124. (const uint8_t *d1, const uint8_t *d2, size_t len));
  125. STATIC void summarize_protover_flags(protover_summary_flags_t *out,
  126. const char *protocols,
  127. const char *version);
  128. #endif /* defined(ROUTERPARSE_PRIVATE) */
  129. #define ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1"
  130. #endif /* !defined(TOR_ROUTERPARSE_H) */