summaryrefslogtreecommitdiff
path: root/src/or/hs_common.h
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-04-18 15:06:44 -0400
committerNick Mathewson <nickm@torproject.org>2017-08-08 20:29:33 -0400
commit267bc7bc3b574f3e60d7836fde5a24652e3ac9c2 (patch)
treede4b64fa9ea873e5694a67bc6c4b74b816a9ffe4 /src/or/hs_common.h
parent77b279c35c5ecf83c045f9c1d613544d958aef81 (diff)
downloadtor-267bc7bc3b574f3e60d7836fde5a24652e3ac9c2.tar.gz
tor-267bc7bc3b574f3e60d7836fde5a24652e3ac9c2.zip
prop224: Build hsdir index for node_t
This hsdir index value is used to give an index value to all node_t (relays) that supports HSDir v3. An index value is then computed using the blinded key to know where to fetch/upload the service descriptor from/to. To avoid computing that index value everytime the client/service needs it, we do that everytime we get a new consensus which then doesn't change until the next one. The downside is that we need to sort them once we need to compute the set of responsible HSDir. Finally, the "hs_index" function is also added but not used. It will be used in later commits to compute which node_t is a responsible HSDir for the service we want to fetch/upload the descriptor. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_common.h')
-rw-r--r--src/or/hs_common.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/or/hs_common.h b/src/or/hs_common.h
index f9e3f297a9..a70ddc68da 100644
--- a/src/or/hs_common.h
+++ b/src/or/hs_common.h
@@ -101,6 +101,18 @@
#define HS_SUBCREDENTIAL_PREFIX "subcredential"
#define HS_SUBCREDENTIAL_PREFIX_LEN (sizeof(HS_SUBCREDENTIAL_PREFIX) - 1)
+/* Node hidden service stored at index prefix value. */
+#define HS_INDEX_PREFIX "store-at-idx"
+#define HS_INDEX_PREFIX_LEN (sizeof(HS_INDEX_PREFIX) - 1)
+
+/* Node hidden service directory index prefix value. */
+#define HSDIR_INDEX_PREFIX "node-idx"
+#define HSDIR_INDEX_PREFIX_LEN (sizeof(HSDIR_INDEX_PREFIX) - 1)
+
+/* Prefix of the shared random value disaster mode. */
+#define HS_SRV_DISASTER_PREFIX "shared-random-disaster"
+#define HS_SRV_DISASTER_PREFIX_LEN (sizeof(HS_SRV_DISASTER_PREFIX) - 1)
+
/* Type of authentication key used by an introduction point. */
typedef enum {
HS_AUTH_KEY_TYPE_LEGACY = 1,
@@ -122,6 +134,15 @@ typedef struct rend_service_port_config_t {
char unix_addr[FLEXIBLE_ARRAY_MEMBER];
} rend_service_port_config_t;
+/* Hidden service directory index used in a node_t which is set once we set
+ * the consensus. */
+typedef struct hsdir_index_t {
+ /* The hsdir index for the current time period. */
+ uint8_t current[DIGEST256_LEN];
+ /* The hsdir index for the next time period. */
+ uint8_t next[DIGEST256_LEN];
+} hsdir_index_t;
+
void hs_init(void);
void hs_free_all(void);
@@ -172,6 +193,16 @@ link_specifier_t *hs_link_specifier_dup(const link_specifier_t *lspec);
int hs_overlap_mode_is_active(const networkstatus_t *consensus, time_t now);
+uint8_t *hs_get_current_srv(uint64_t time_period_num);
+uint8_t *hs_get_previous_srv(uint64_t time_period_num);
+
+void hs_build_hsdir_index(const ed25519_public_key_t *identity_pk,
+ const uint8_t *srv, uint64_t period_num,
+ uint8_t *hsdir_index_out);
+void hs_build_hs_index(uint64_t replica,
+ const ed25519_public_key_t *blinded_pk,
+ uint64_t period_num, uint8_t *hs_index_out);
+
#ifdef HS_COMMON_PRIVATE
#ifdef TOR_UNIT_TESTS