From c17a04376de9e0517e611ad164172e7a5de26953 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 2 May 2017 15:50:33 -0400 Subject: [PATCH 1/2] nodelist: Add functions to check for HS v3 support This introduces node_supports_v3_hsdir() and node_supports_ed25519_hs_intro() that checks the routerstatus_t of a node and if not present, checks the routerinfo_t. This is groundwork for proposal 224 service implementation in #20657. Signed-off-by: David Goulet --- src/or/nodelist.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/or/nodelist.h | 2 ++ 2 files changed, 44 insertions(+) diff --git a/src/or/nodelist.c b/src/or/nodelist.c index 0ef9741243..a04f4154b7 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -707,6 +707,48 @@ node_supports_ed25519_link_authentication(const node_t *node) return 0; } +/** Return true iff node supports the hidden service directory version + * 3 protocol (proposal 224). */ +int +node_supports_v3_hsdir(const node_t *node) +{ + tor_assert(node); + + if (node->rs) { + return node->rs->supports_v3_hsdir; + } + if (node->ri) { + if (node->ri->protocol_list == NULL) { + return 0; + } + return protocol_list_supports_protocol(node->ri->protocol_list, + PRT_HSDIR, 2); + } + tor_assert_nonfatal_unreached_once(); + return 0; +} + +/** Return true iff node supports ed25519 authentication as an hidden + * service introduction point.*/ +int +node_supports_ed25519_hs_intro(const node_t *node) +{ + tor_assert(node); + + if (node->rs) { + return node->rs->supports_ed25519_hs_intro; + } + if (node->ri) { + if (node->ri->protocol_list == NULL) { + return 0; + } + return protocol_list_supports_protocol(node->ri->protocol_list, + PRT_HSINTRO, 4); + } + tor_assert_nonfatal_unreached_once(); + return 0; +} + /** Return the RSA ID key's SHA1 digest for the provided node. */ const uint8_t * node_get_rsa_id_digest(const node_t *node) diff --git a/src/or/nodelist.h b/src/or/nodelist.h index 6c063de8a3..f59e767d1e 100644 --- a/src/or/nodelist.h +++ b/src/or/nodelist.h @@ -58,6 +58,8 @@ const ed25519_public_key_t *node_get_ed25519_id(const node_t *node); int node_ed25519_id_matches(const node_t *node, const ed25519_public_key_t *id); int node_supports_ed25519_link_authentication(const node_t *node); +int node_supports_v3_hsdir(const node_t *node); +int node_supports_ed25519_hs_intro(const node_t *node); const uint8_t *node_get_rsa_id_digest(const node_t *node); int node_has_ipv6_addr(const node_t *node); From 551ad20c43b39c384cbab9eee5442d4fa9cfefb1 Mon Sep 17 00:00:00 2001 From: George Kadianakis Date: Wed, 28 Jun 2017 17:22:59 +0300 Subject: [PATCH 2/2] nodelist: Make HSv3 protover magic numbers a bit more readable. --- src/or/nodelist.c | 4 ++-- src/or/protover.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/or/nodelist.c b/src/or/nodelist.c index a04f4154b7..4513e97188 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -722,7 +722,7 @@ node_supports_v3_hsdir(const node_t *node) return 0; } return protocol_list_supports_protocol(node->ri->protocol_list, - PRT_HSDIR, 2); + PRT_HSDIR, PROTOVER_HSDIR_V3); } tor_assert_nonfatal_unreached_once(); return 0; @@ -743,7 +743,7 @@ node_supports_ed25519_hs_intro(const node_t *node) return 0; } return protocol_list_supports_protocol(node->ri->protocol_list, - PRT_HSINTRO, 4); + PRT_HSINTRO, PROTOVER_HS_INTRO_V3); } tor_assert_nonfatal_unreached_once(); return 0; diff --git a/src/or/protover.h b/src/or/protover.h index 22667bed79..2066aeec72 100644 --- a/src/or/protover.h +++ b/src/or/protover.h @@ -17,6 +17,11 @@ /* This is a guess. */ #define FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS "0.2.9.3-alpha" +/** The protover version number that signifies HSDir support for HSv3 */ +#define PROTOVER_HSDIR_V3 2 +/** The protover version number that signifies HSv3 intro point support */ +#define PROTOVER_HS_INTRO_V3 4 + /** List of recognized subprotocols. */ typedef enum protocol_type_t { PRT_LINK,