|
@@ -426,23 +426,16 @@ service_intro_point_free_void(void *obj)
|
|
|
}
|
|
|
|
|
|
|
|
|
- * given extend_info_t ei if non NULL.
|
|
|
- * If is_legacy is true, we also generate the legacy key.
|
|
|
- * If supports_ed25519_link_handshake_any is true, we add the relay's ed25519
|
|
|
- * key to the link specifiers.
|
|
|
+ * given node_t node, if non NULL.
|
|
|
*
|
|
|
- * If ei is NULL, returns a hs_service_intro_point_t with an empty link
|
|
|
+ * If node is NULL, returns a hs_service_intro_point_t with an empty link
|
|
|
* specifier list and no onion key. (This is used for testing.)
|
|
|
* On any other error, NULL is returned.
|
|
|
*
|
|
|
- * ei must be an extend_info_t containing an IPv4 address. (We will add supoort
|
|
|
- * for IPv6 in a later release.) When calling extend_info_from_node(), pass
|
|
|
- * 0 in for_direct_connection to make sure ei always has an IPv4 address. */
|
|
|
+ * node must be an node_t with an IPv4 address. */
|
|
|
STATIC hs_service_intro_point_t *
|
|
|
-service_intro_point_new(const extend_info_t *ei, unsigned int is_legacy,
|
|
|
- unsigned int supports_ed25519_link_handshake_any)
|
|
|
+service_intro_point_new(const node_t *node)
|
|
|
{
|
|
|
- hs_desc_link_specifier_t *ls;
|
|
|
hs_service_intro_point_t *ip;
|
|
|
|
|
|
ip = tor_malloc_zero(sizeof(*ip));
|
|
@@ -472,12 +465,17 @@ service_intro_point_new(const extend_info_t *ei, unsigned int is_legacy,
|
|
|
ip->replay_cache = replaycache_new(0, 0);
|
|
|
|
|
|
|
|
|
- ip->base.link_specifiers = smartlist_new();
|
|
|
+ ip->base.link_specifiers = node_get_link_specifier_smartlist(node, 0);
|
|
|
+
|
|
|
+ if (node == NULL) {
|
|
|
+ goto done;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
curve25519_keypair_generate(&ip->enc_key_kp, 0);
|
|
|
-
|
|
|
- if (is_legacy) {
|
|
|
+
|
|
|
+ * NULL nodes are used in the unit tests. */
|
|
|
+ if (!node_supports_ed25519_hs_intro(node)) {
|
|
|
ip->base.is_only_legacy = 1;
|
|
|
|
|
|
ip->legacy_key = crypto_pk_new();
|
|
@@ -490,40 +488,9 @@ service_intro_point_new(const extend_info_t *ei, unsigned int is_legacy,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (ei == NULL) {
|
|
|
- goto done;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * IPv4 or IPv6 is required, and we always send IPv4. */
|
|
|
- ls = hs_desc_link_specifier_new(ei, LS_IPV4);
|
|
|
-
|
|
|
- if (BUG(!ls)) {
|
|
|
- goto err;
|
|
|
- }
|
|
|
- smartlist_add(ip->base.link_specifiers, ls);
|
|
|
-
|
|
|
- ls = hs_desc_link_specifier_new(ei, LS_LEGACY_ID);
|
|
|
-
|
|
|
- * digest. */
|
|
|
- if (BUG(!ls)) {
|
|
|
- goto err;
|
|
|
- }
|
|
|
- smartlist_add(ip->base.link_specifiers, ls);
|
|
|
-
|
|
|
-
|
|
|
- * ed25519 link authentication, we include it. */
|
|
|
- if (supports_ed25519_link_handshake_any) {
|
|
|
- ls = hs_desc_link_specifier_new(ei, LS_ED25519_ID);
|
|
|
- if (ls) {
|
|
|
- smartlist_add(ip->base.link_specifiers, ls);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- memcpy(&ip->onion_key, &ei->curve25519_onion_key, sizeof(ip->onion_key));
|
|
|
+
|
|
|
+ memcpy(&ip->onion_key, node_get_curve25519_onion_key(node),
|
|
|
+ sizeof(ip->onion_key));
|
|
|
|
|
|
done:
|
|
|
return ip;
|
|
@@ -2106,7 +2073,6 @@ static hs_service_intro_point_t *
|
|
|
pick_intro_point(unsigned int direct_conn, smartlist_t *exclude_nodes)
|
|
|
{
|
|
|
const node_t *node;
|
|
|
- extend_info_t *info = NULL;
|
|
|
hs_service_intro_point_t *ip = NULL;
|
|
|
|
|
|
router_crn_flags_t flags = CRN_NEED_UPTIME | CRN_NEED_DESC;
|
|
@@ -2127,43 +2093,17 @@ pick_intro_point(unsigned int direct_conn, smartlist_t *exclude_nodes)
|
|
|
* we don't want to use that node anymore. */
|
|
|
smartlist_add(exclude_nodes, (void *) node);
|
|
|
|
|
|
-
|
|
|
- * of the node object such as validating ntor support for instance.
|
|
|
- *
|
|
|
- * We must provide an extend_info for clients to connect over a 3-hop path,
|
|
|
- * so we don't pass direct_conn here. */
|
|
|
- info = extend_info_from_node(node, 0);
|
|
|
- if (BUG(info == NULL)) {
|
|
|
- goto err;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * ed25519 identity key of relays that don't actually support the link
|
|
|
- * protocol */
|
|
|
- if (!node_supports_ed25519_link_authentication(node, 0)) {
|
|
|
- tor_assert_nonfatal(ed25519_public_key_is_zero(&info->ed_identity));
|
|
|
- } else {
|
|
|
-
|
|
|
- * Sending an empty key would result in a failure to extend. */
|
|
|
- tor_assert_nonfatal(!ed25519_public_key_is_zero(&info->ed_identity));
|
|
|
- }
|
|
|
+
|
|
|
+ ip = service_intro_point_new(node);
|
|
|
|
|
|
-
|
|
|
- * We don't care if the intro's link auth is compatible with us, because
|
|
|
- * we are sending the ed25519 key to a remote client via the descriptor. */
|
|
|
- ip = service_intro_point_new(info, !node_supports_ed25519_hs_intro(node),
|
|
|
- node_supports_ed25519_link_authentication(node,
|
|
|
- 0));
|
|
|
if (ip == NULL) {
|
|
|
goto err;
|
|
|
}
|
|
|
|
|
|
- log_info(LD_REND, "Picked intro point: %s", extend_info_describe(info));
|
|
|
- extend_info_free(info);
|
|
|
+ log_info(LD_REND, "Picked intro point: %s", node_describe(node));
|
|
|
return ip;
|
|
|
err:
|
|
|
service_intro_point_free(ip);
|
|
|
- extend_info_free(info);
|
|
|
return NULL;
|
|
|
}
|
|
|
|