routerparse.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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-2018, 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. #include "core/or/versions.h"
  13. enum networkstatus_type_t;
  14. int router_get_router_hash(const char *s, size_t s_len, char *digest);
  15. int router_get_dir_hash(const char *s, char *digest);
  16. int router_get_networkstatus_v3_hashes(const char *s,
  17. common_digests_t *digests);
  18. int router_get_networkstatus_v3_signed_boundaries(const char *s,
  19. const char **start_out,
  20. const char **end_out);
  21. int router_get_networkstatus_v3_sha3_as_signed(uint8_t *digest_out,
  22. const char *s);
  23. int router_get_extrainfo_hash(const char *s, size_t s_len, char *digest);
  24. #define DIROBJ_MAX_SIG_LEN 256
  25. char *router_get_dirobj_signature(const char *digest,
  26. size_t digest_len,
  27. const crypto_pk_t *private_key);
  28. int router_append_dirobj_signature(char *buf, size_t buf_len,
  29. const char *digest,
  30. size_t digest_len,
  31. crypto_pk_t *private_key);
  32. int router_parse_list_from_string(const char **s, const char *eos,
  33. smartlist_t *dest,
  34. saved_location_t saved_location,
  35. int is_extrainfo,
  36. int allow_annotations,
  37. const char *prepend_annotations,
  38. smartlist_t *invalid_digests_out);
  39. routerinfo_t *router_parse_entry_from_string(const char *s, const char *end,
  40. int cache_copy,
  41. int allow_annotations,
  42. const char *prepend_annotations,
  43. int *can_dl_again_out);
  44. struct digest_ri_map_t;
  45. extrainfo_t *extrainfo_parse_entry_from_string(const char *s, const char *end,
  46. int cache_copy, struct digest_ri_map_t *routermap,
  47. int *can_dl_again_out);
  48. MOCK_DECL(addr_policy_t *, router_parse_addr_policy_item_from_string,
  49. (const char *s, int assume_action, int *malformed_list));
  50. void assert_addr_policy_ok(smartlist_t *t);
  51. void dump_distinct_digest_count(int severity);
  52. int compare_vote_routerstatus_entries(const void **_a, const void **_b);
  53. int networkstatus_verify_bw_weights(networkstatus_t *ns, int);
  54. networkstatus_t *networkstatus_parse_vote_from_string(const char *s,
  55. const char **eos_out,
  56. enum networkstatus_type_t ns_type);
  57. ns_detached_signatures_t *networkstatus_parse_detached_signatures(
  58. const char *s, const char *eos);
  59. smartlist_t *microdescs_parse_from_string(const char *s, const char *eos,
  60. int allow_annotations,
  61. saved_location_t where,
  62. smartlist_t *invalid_digests_out);
  63. authority_cert_t *authority_cert_parse_from_string(const char *s,
  64. const char **end_of_string);
  65. int rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out,
  66. char *desc_id_out,
  67. char **intro_points_encrypted_out,
  68. size_t *intro_points_encrypted_size_out,
  69. size_t *encoded_size_out,
  70. const char **next_out, const char *desc,
  71. int as_hsdir);
  72. int rend_decrypt_introduction_points(char **ipos_decrypted,
  73. size_t *ipos_decrypted_size,
  74. const char *descriptor_cookie,
  75. const char *ipos_encrypted,
  76. size_t ipos_encrypted_size);
  77. int rend_parse_introduction_points(rend_service_descriptor_t *parsed,
  78. const char *intro_points_encoded,
  79. size_t intro_points_encoded_size);
  80. int rend_parse_client_keys(strmap_t *parsed_clients, const char *str);
  81. void routerparse_init(void);
  82. void routerparse_free_all(void);
  83. #ifdef ROUTERPARSE_PRIVATE
  84. STATIC int routerstatus_parse_guardfraction(const char *guardfraction_str,
  85. networkstatus_t *vote,
  86. vote_routerstatus_t *vote_rs,
  87. routerstatus_t *rs);
  88. struct memarea_t;
  89. STATIC routerstatus_t *routerstatus_parse_entry_from_string(
  90. struct memarea_t *area,
  91. const char **s, smartlist_t *tokens,
  92. networkstatus_t *vote,
  93. vote_routerstatus_t *vote_rs,
  94. int consensus_method,
  95. consensus_flavor_t flav);
  96. MOCK_DECL(STATIC int, router_compute_hash_final,(char *digest,
  97. const char *start, size_t len,
  98. digest_algorithm_t alg));
  99. MOCK_DECL(STATIC int, signed_digest_equals,
  100. (const uint8_t *d1, const uint8_t *d2, size_t len));
  101. STATIC void summarize_protover_flags(protover_summary_flags_t *out,
  102. const char *protocols,
  103. const char *version);
  104. #endif /* defined(ROUTERPARSE_PRIVATE) */
  105. #define ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1"
  106. #endif /* !defined(TOR_ROUTERPARSE_H) */