routerparse.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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_as_new_as(const char *platform, const char *cutoff);
  45. int tor_version_parse(const char *s, tor_version_t *out);
  46. int tor_version_compare(tor_version_t *a, tor_version_t *b);
  47. int tor_version_same_series(tor_version_t *a, tor_version_t *b);
  48. void sort_version_list(smartlist_t *lst, int remove_duplicates);
  49. void assert_addr_policy_ok(smartlist_t *t);
  50. void dump_distinct_digest_count(int severity);
  51. int compare_vote_routerstatus_entries(const void **_a, const void **_b);
  52. int networkstatus_verify_bw_weights(networkstatus_t *ns, int);
  53. networkstatus_t *networkstatus_parse_vote_from_string(const char *s,
  54. const char **eos_out,
  55. networkstatus_type_t ns_type);
  56. ns_detached_signatures_t *networkstatus_parse_detached_signatures(
  57. const char *s, const char *eos);
  58. smartlist_t *microdescs_parse_from_string(const char *s, const char *eos,
  59. int allow_annotations,
  60. saved_location_t where,
  61. smartlist_t *invalid_digests_out);
  62. authority_cert_t *authority_cert_parse_from_string(const char *s,
  63. const char **end_of_string);
  64. int rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out,
  65. char *desc_id_out,
  66. char **intro_points_encrypted_out,
  67. size_t *intro_points_encrypted_size_out,
  68. size_t *encoded_size_out,
  69. const char **next_out, const char *desc,
  70. int as_hsdir);
  71. int rend_decrypt_introduction_points(char **ipos_decrypted,
  72. size_t *ipos_decrypted_size,
  73. const char *descriptor_cookie,
  74. const char *ipos_encrypted,
  75. size_t ipos_encrypted_size);
  76. int rend_parse_introduction_points(rend_service_descriptor_t *parsed,
  77. const char *intro_points_encoded,
  78. size_t intro_points_encoded_size);
  79. int rend_parse_client_keys(strmap_t *parsed_clients, const char *str);
  80. void routerparse_init(void);
  81. void routerparse_free_all(void);
  82. #ifdef ROUTERPARSE_PRIVATE
  83. /*
  84. * One entry in the list of dumped descriptors; filename dumped to, length,
  85. * SHA-256 and timestamp.
  86. */
  87. typedef struct {
  88. char *filename;
  89. size_t len;
  90. uint8_t digest_sha256[DIGEST256_LEN];
  91. time_t when;
  92. } dumped_desc_t;
  93. EXTERN(uint64_t, len_descs_dumped)
  94. EXTERN(smartlist_t *, descs_dumped)
  95. STATIC int routerstatus_parse_guardfraction(const char *guardfraction_str,
  96. networkstatus_t *vote,
  97. vote_routerstatus_t *vote_rs,
  98. routerstatus_t *rs);
  99. MOCK_DECL(STATIC dumped_desc_t *, dump_desc_populate_one_file,
  100. (const char *dirname, const char *f));
  101. STATIC void dump_desc_populate_fifo_from_directory(const char *dirname);
  102. STATIC void dump_desc_fifo_cleanup(void);
  103. struct memarea_t;
  104. STATIC routerstatus_t *routerstatus_parse_entry_from_string(
  105. struct memarea_t *area,
  106. const char **s, smartlist_t *tokens,
  107. networkstatus_t *vote,
  108. vote_routerstatus_t *vote_rs,
  109. int consensus_method,
  110. consensus_flavor_t flav);
  111. MOCK_DECL(STATIC void,dump_desc,(const char *desc, const char *type));
  112. MOCK_DECL(STATIC int, router_compute_hash_final,(char *digest,
  113. const char *start, size_t len,
  114. digest_algorithm_t alg));
  115. MOCK_DECL(STATIC int, signed_digest_equals,
  116. (const uint8_t *d1, const uint8_t *d2, size_t len));
  117. #endif
  118. #define ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1"
  119. #endif