Tor  0.4.5.0-alpha-dev
hs_circuit.c
Go to the documentation of this file.
1 /* Copyright (c) 2017-2020, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 /**
5  * \file hs_circuit.c
6  **/
7 
8 #define HS_CIRCUIT_PRIVATE
9 
10 #include "core/or/or.h"
11 #include "app/config/config.h"
12 #include "core/crypto/hs_ntor.h"
13 #include "core/or/circuitbuild.h"
14 #include "core/or/circuitlist.h"
15 #include "core/or/circuituse.h"
16 #include "core/or/policies.h"
17 #include "core/or/relay.h"
18 #include "core/or/crypt_path.h"
19 #include "core/or/extendinfo.h"
20 #include "feature/client/circpathbias.h"
21 #include "feature/hs/hs_cell.h"
22 #include "feature/hs/hs_circuit.h"
23 #include "feature/hs/hs_ob.h"
25 #include "feature/hs/hs_client.h"
26 #include "feature/hs/hs_ident.h"
27 #include "feature/hs/hs_service.h"
32 #include "feature/stats/rephist.h"
36 
37 /* Trunnel. */
38 #include "trunnel/ed25519_cert.h"
39 #include "trunnel/hs/cell_common.h"
40 #include "trunnel/hs/cell_establish_intro.h"
41 
43 #include "core/or/crypt_path_st.h"
46 
47 /** A circuit is about to become an e2e rendezvous circuit. Check
48  * <b>circ_purpose</b> and ensure that it's properly set. Return true iff
49  * circuit purpose is properly set, otherwise return false. */
50 static int
51 circuit_purpose_is_correct_for_rend(unsigned int circ_purpose,
52  int is_service_side)
53 {
54  if (is_service_side) {
55  if (circ_purpose != CIRCUIT_PURPOSE_S_CONNECT_REND) {
56  log_warn(LD_BUG,
57  "HS e2e circuit setup with wrong purpose (%d)", circ_purpose);
58  return 0;
59  }
60  }
61 
62  if (!is_service_side) {
63  if (circ_purpose != CIRCUIT_PURPOSE_C_REND_READY &&
65  log_warn(LD_BUG,
66  "Client e2e circuit setup with wrong purpose (%d)", circ_purpose);
67  return 0;
68  }
69  }
70 
71  return 1;
72 }
73 
74 /** Create and return a crypt path for the final hop of a v3 prop224 rendezvous
75  * circuit. Initialize the crypt path crypto using the output material from the
76  * ntor key exchange at <b>ntor_key_seed</b>.
77  *
78  * If <b>is_service_side</b> is set, we are the hidden service and the final
79  * hop of the rendezvous circuit is the client on the other side. */
80 static crypt_path_t *
81 create_rend_cpath(const uint8_t *ntor_key_seed, size_t seed_len,
82  int is_service_side)
83 {
84  uint8_t keys[HS_NTOR_KEY_EXPANSION_KDF_OUT_LEN];
85  crypt_path_t *cpath = NULL;
86 
87  /* Do the key expansion */
88  if (hs_ntor_circuit_key_expansion(ntor_key_seed, seed_len,
89  keys, sizeof(keys)) < 0) {
90  goto err;
91  }
92 
93  /* Setup the cpath */
94  cpath = tor_malloc_zero(sizeof(crypt_path_t));
95  cpath->magic = CRYPT_PATH_MAGIC;
96 
97  if (cpath_init_circuit_crypto(cpath, (char*)keys, sizeof(keys),
98  is_service_side, 1) < 0) {
99  tor_free(cpath);
100  goto err;
101  }
102 
103  err:
104  memwipe(keys, 0, sizeof(keys));
105  return cpath;
106 }
107 
108 /** We are a v2 legacy HS client: Create and return a crypt path for the hidden
109  * service on the other side of the rendezvous circuit <b>circ</b>. Initialize
110  * the crypt path crypto using the body of the RENDEZVOUS1 cell at
111  * <b>rend_cell_body</b> (which must be at least DH1024_KEY_LEN+DIGEST_LEN
112  * bytes).
113  */
114 static crypt_path_t *
115 create_rend_cpath_legacy(origin_circuit_t *circ, const uint8_t *rend_cell_body)
116 {
117  crypt_path_t *hop = NULL;
118  char keys[DIGEST_LEN+CPATH_KEY_MATERIAL_LEN];
119 
120  /* first DH1024_KEY_LEN bytes are g^y from the service. Finish the dh
121  * handshake...*/
122  tor_assert(circ->build_state);
124  hop = circ->build_state->pending_final_cpath;
125 
127  if (crypto_dh_compute_secret(LOG_PROTOCOL_WARN, hop->rend_dh_handshake_state,
128  (char*)rend_cell_body, DH1024_KEY_LEN,
129  keys, DIGEST_LEN+CPATH_KEY_MATERIAL_LEN)<0) {
130  log_warn(LD_GENERAL, "Couldn't complete DH handshake.");
131  goto err;
132  }
133  /* ... and set up cpath. */
135  keys+DIGEST_LEN, sizeof(keys)-DIGEST_LEN,
136  0, 0) < 0)
137  goto err;
138 
139  /* Check whether the digest is right... */
140  if (tor_memneq(keys, rend_cell_body+DH1024_KEY_LEN, DIGEST_LEN)) {
141  log_warn(LD_PROTOCOL, "Incorrect digest of key material.");
142  goto err;
143  }
144 
145  /* clean up the crypto stuff we just made */
146  crypto_dh_free(hop->rend_dh_handshake_state);
147  hop->rend_dh_handshake_state = NULL;
148 
149  goto done;
150 
151  err:
152  hop = NULL;
153 
154  done:
155  memwipe(keys, 0, sizeof(keys));
156  return hop;
157 }
158 
159 /** Append the final <b>hop</b> to the cpath of the rend <b>circ</b>, and mark
160  * <b>circ</b> ready for use to transfer HS relay cells. */
161 static void
163  int is_service_side)
164 {
165  tor_assert(circ);
166  tor_assert(hop);
167 
168  /* Notify the circuit state machine that we are splicing this circuit */
169  int new_circ_purpose = is_service_side ?
171  circuit_change_purpose(TO_CIRCUIT(circ), new_circ_purpose);
172 
173  /* All is well. Extend the circuit. */
174  hop->state = CPATH_STATE_OPEN;
175  /* Set the windows to default. */
178 
179  /* Now that this circuit has finished connecting to its destination,
180  * make sure circuit_get_open_circ_or_launch is willing to return it
181  * so we can actually use it. */
182  circ->hs_circ_has_timed_out = 0;
183 
184  /* Append the hop to the cpath of this circuit */
185  cpath_extend_linked_list(&circ->cpath, hop);
186 
187  /* In legacy code, 'pending_final_cpath' points to the final hop we just
188  * appended to the cpath. We set the original pointer to NULL so that we
189  * don't double free it. */
190  if (circ->build_state) {
191  circ->build_state->pending_final_cpath = NULL;
192  }
193 
194  /* Finally, mark circuit as ready to be used for client streams */
195  if (!is_service_side) {
197  }
198 }
199 
200 /** For a given circuit and a service introduction point object, register the
201  * intro circuit to the circuitmap. This supports legacy intro point. */
202 static void
204  origin_circuit_t *circ)
205 {
206  tor_assert(ip);
207  tor_assert(circ);
208 
209  if (ip->base.is_only_legacy) {
211  ip->legacy_key_digest);
212  } else {
214  &ip->auth_key_kp.pubkey);
215  }
216 }
217 
218 /** Return the number of opened introduction circuit for the given circuit that
219  * is matching its identity key. */
220 static unsigned int
222  const hs_service_descriptor_t *desc)
223 {
224  unsigned int count = 0;
225 
226  tor_assert(service);
227  tor_assert(desc);
228 
229  DIGEST256MAP_FOREACH(desc->intro_points.map, key,
230  const hs_service_intro_point_t *, ip) {
231  const circuit_t *circ;
233  if (ocirc == NULL) {
234  continue;
235  }
236  circ = TO_CIRCUIT(ocirc);
239  /* Having a circuit not for the requested service is really bad. */
241  &ocirc->hs_ident->identity_pk));
242  /* Only count opened circuit and skip circuit that will be closed. */
243  if (!circ->marked_for_close && circ->state == CIRCUIT_STATE_OPEN) {
244  count++;
245  }
246  } DIGEST256MAP_FOREACH_END;
247  return count;
248 }
249 
250 /** From a given service, rendezvous cookie and handshake info, create a
251  * rendezvous point circuit identifier. This can't fail. */
254  const uint8_t *rendezvous_cookie,
255  const curve25519_public_key_t *server_pk,
256  const hs_ntor_rend_cell_keys_t *keys)
257 {
258  hs_ident_circuit_t *ident;
259  uint8_t handshake_info[CURVE25519_PUBKEY_LEN + DIGEST256_LEN];
260 
261  tor_assert(service);
262  tor_assert(rendezvous_cookie);
263  tor_assert(server_pk);
264  tor_assert(keys);
265 
266  ident = hs_ident_circuit_new(&service->keys.identity_pk);
267  /* Copy the RENDEZVOUS_COOKIE which is the unique identifier. */
268  memcpy(ident->rendezvous_cookie, rendezvous_cookie,
269  sizeof(ident->rendezvous_cookie));
270  /* Build the HANDSHAKE_INFO which looks like this:
271  * SERVER_PK [32 bytes]
272  * AUTH_INPUT_MAC [32 bytes]
273  */
274  memcpy(handshake_info, server_pk->public_key, CURVE25519_PUBKEY_LEN);
275  memcpy(handshake_info + CURVE25519_PUBKEY_LEN, keys->rend_cell_auth_mac,
276  DIGEST256_LEN);
277  tor_assert(sizeof(ident->rendezvous_handshake_info) ==
278  sizeof(handshake_info));
279  memcpy(ident->rendezvous_handshake_info, handshake_info,
280  sizeof(ident->rendezvous_handshake_info));
281  /* Finally copy the NTOR_KEY_SEED for e2e encryption on the circuit. */
282  tor_assert(sizeof(ident->rendezvous_ntor_key_seed) ==
283  sizeof(keys->ntor_key_seed));
284  memcpy(ident->rendezvous_ntor_key_seed, keys->ntor_key_seed,
285  sizeof(ident->rendezvous_ntor_key_seed));
286  return ident;
287 }
288 
289 /** From a given service and service intro point, create an introduction point
290  * circuit identifier. This can't fail. */
291 static hs_ident_circuit_t *
293  const hs_service_intro_point_t *ip)
294 {
295  hs_ident_circuit_t *ident;
296 
297  tor_assert(service);
298  tor_assert(ip);
299 
300  ident = hs_ident_circuit_new(&service->keys.identity_pk);
301  ed25519_pubkey_copy(&ident->intro_auth_pk, &ip->auth_key_kp.pubkey);
302 
303  return ident;
304 }
305 
306 /** For a given introduction point and an introduction circuit, send the
307  * ESTABLISH_INTRO cell. The service object is used for logging. This can fail
308  * and if so, the circuit is closed and the intro point object is flagged
309  * that the circuit is not established anymore which is important for the
310  * retry mechanism. */
311 static void
314 {
315  ssize_t cell_len;
316  uint8_t payload[RELAY_PAYLOAD_SIZE];
317 
318  tor_assert(service);
319  tor_assert(ip);
320  tor_assert(circ);
321 
322  /* Encode establish intro cell. */
324  &service->config, ip, payload);
325  if (cell_len < 0) {
326  log_warn(LD_REND, "Unable to encode ESTABLISH_INTRO cell for service %s "
327  "on circuit %u. Closing circuit.",
328  safe_str_client(service->onion_address),
329  TO_CIRCUIT(circ)->n_circ_id);
330  goto err;
331  }
332 
333  /* Send the cell on the circuit. */
334  if (relay_send_command_from_edge(CONTROL_CELL_ID, TO_CIRCUIT(circ),
335  RELAY_COMMAND_ESTABLISH_INTRO,
336  (char *) payload, cell_len,
337  circ->cpath->prev) < 0) {
338  log_info(LD_REND, "Unable to send ESTABLISH_INTRO cell for service %s "
339  "on circuit %u.",
340  safe_str_client(service->onion_address),
341  TO_CIRCUIT(circ)->n_circ_id);
342  /* On error, the circuit has been closed. */
343  goto done;
344  }
345 
346  /* Record the attempt to use this circuit. */
348  goto done;
349 
350  err:
351  circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_INTERNAL);
352  done:
353  memwipe(payload, 0, sizeof(payload));
354 }
355 
356 /** Return a string constant describing the anonymity of service. */
357 static const char *
359 {
360  if (service->config.is_single_onion) {
361  return "single onion";
362  } else {
363  return "hidden";
364  }
365 }
366 
367 /** For a given service, the ntor onion key and a rendezvous cookie, launch a
368  * circuit to the rendezvous point specified by the link specifiers. On
369  * success, a circuit identifier is attached to the circuit with the needed
370  * data. This function will try to open a circuit for a maximum value of
371  * MAX_REND_FAILURES then it will give up. */
372 MOCK_IMPL(STATIC void,
374  const hs_service_intro_point_t *ip,
376 {
377  int circ_needs_uptime;
378  time_t now = time(NULL);
379  extend_info_t *info = NULL;
380  origin_circuit_t *circ;
381 
382  tor_assert(service);
383  tor_assert(ip);
384  tor_assert(data);
385 
386  circ_needs_uptime = hs_service_requires_uptime_circ(service->config.ports);
387 
388  /* Get the extend info data structure for the chosen rendezvous point
389  * specified by the given link specifiers. */
391  &data->onion_pk,
392  service->config.is_single_onion);
393  if (info == NULL) {
394  /* We are done here, we can't extend to the rendezvous point. */
395  log_fn(LOG_PROTOCOL_WARN, LD_REND,
396  "Not enough info to open a circuit to a rendezvous point for "
397  "%s service %s.",
399  safe_str_client(service->onion_address));
400  goto end;
401  }
402 
403  for (int i = 0; i < MAX_REND_FAILURES; i++) {
405  if (circ_needs_uptime) {
406  circ_flags |= CIRCLAUNCH_NEED_UPTIME;
407  }
408  /* Firewall and policies are checked when getting the extend info.
409  *
410  * We only use a one-hop path on the first attempt. If the first attempt
411  * fails, we use a 3-hop path for reachability / reliability.
412  * See the comment in retry_service_rendezvous_point() for details. */
413  if (service->config.is_single_onion && i == 0) {
414  circ_flags |= CIRCLAUNCH_ONEHOP_TUNNEL;
415  }
416 
418  circ_flags);
419  if (circ != NULL) {
420  /* Stop retrying, we have a circuit! */
421  break;
422  }
423  }
424  if (circ == NULL) {
425  log_warn(LD_REND, "Giving up on launching a rendezvous circuit to %s "
426  "for %s service %s",
427  safe_str_client(extend_info_describe(info)),
429  safe_str_client(service->onion_address));
430  goto end;
431  }
432  log_info(LD_REND, "Rendezvous circuit launched to %s with cookie %s "
433  "for %s service %s",
434  safe_str_client(extend_info_describe(info)),
435  safe_str_client(hex_str((const char *) data->rendezvous_cookie,
436  REND_COOKIE_LEN)),
438  safe_str_client(service->onion_address));
439  tor_assert(circ->build_state);
440  /* Rendezvous circuit have a specific timeout for the time spent on trying
441  * to connect to the rendezvous point. */
443 
444  /* Create circuit identifier and key material. */
445  {
447  curve25519_keypair_t ephemeral_kp;
448  /* No need for extra strong, this is only for this circuit life time. This
449  * key will be used for the RENDEZVOUS1 cell that will be sent on the
450  * circuit once opened. */
451  curve25519_keypair_generate(&ephemeral_kp, 0);
452  if (hs_ntor_service_get_rendezvous1_keys(&ip->auth_key_kp.pubkey,
453  &ip->enc_key_kp,
454  &ephemeral_kp, &data->client_pk,
455  &keys) < 0) {
456  /* This should not really happened but just in case, don't make tor
457  * freak out, close the circuit and move on. */
458  log_info(LD_REND, "Unable to get RENDEZVOUS1 key material for "
459  "service %s",
460  safe_str_client(service->onion_address));
461  circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_INTERNAL);
462  goto end;
463  }
464  circ->hs_ident = create_rp_circuit_identifier(service,
465  data->rendezvous_cookie,
466  &ephemeral_kp.pubkey, &keys);
467  memwipe(&ephemeral_kp, 0, sizeof(ephemeral_kp));
468  memwipe(&keys, 0, sizeof(keys));
469  tor_assert(circ->hs_ident);
470  }
471 
472  end:
473  extend_info_free(info);
474 }
475 
476 /** Return true iff the given service rendezvous circuit circ is allowed for a
477  * relaunch to the rendezvous point. */
478 static int
480 {
481  tor_assert(circ);
482  /* This is initialized when allocating an origin circuit. */
483  tor_assert(circ->build_state);
485 
486  /* XXX: Retrying under certain condition. This is related to #22455. */
487 
488  /* Avoid to relaunch twice a circuit to the same rendezvous point at the
489  * same time. */
491  log_info(LD_REND, "Rendezvous circuit to %s has already been retried. "
492  "Skipping retry.",
493  safe_str_client(
495  goto disallow;
496  }
497 
498  /* We check failure_count >= hs_get_service_max_rend_failures()-1 below, and
499  * the -1 is because we increment the failure count for our current failure
500  * *after* this clause. */
501  int max_rend_failures = hs_get_service_max_rend_failures() - 1;
502 
503  /* A failure count that has reached maximum allowed or circuit that expired,
504  * we skip relaunching. */
505  if (circ->build_state->failure_count > max_rend_failures ||
506  circ->build_state->expiry_time <= time(NULL)) {
507  log_info(LD_REND, "Attempt to build a rendezvous circuit to %s has "
508  "failed with %d attempts and expiry time %ld. "
509  "Giving up building.",
510  safe_str_client(
512  circ->build_state->failure_count,
513  (long int) circ->build_state->expiry_time);
514  goto disallow;
515  }
516 
517  /* Allowed to relaunch. */
518  return 1;
519  disallow:
520  return 0;
521 }
522 
523 /** Retry the rendezvous point of circ by launching a new circuit to it. */
524 static void
526 {
527  int flags = 0;
528  origin_circuit_t *new_circ;
529  cpath_build_state_t *bstate;
530 
531  tor_assert(circ);
532  /* This is initialized when allocating an origin circuit. */
533  tor_assert(circ->build_state);
535 
536  /* Ease our life. */
537  bstate = circ->build_state;
538 
539  log_info(LD_REND, "Retrying rendezvous point circuit to %s",
540  safe_str_client(extend_info_describe(bstate->chosen_exit)));
541 
542  /* Get the current build state flags for the next circuit. */
543  flags |= (bstate->need_uptime) ? CIRCLAUNCH_NEED_UPTIME : 0;
544  flags |= (bstate->need_capacity) ? CIRCLAUNCH_NEED_CAPACITY : 0;
545  flags |= (bstate->is_internal) ? CIRCLAUNCH_IS_INTERNAL : 0;
546 
547  /* We do NOT add the onehop tunnel flag even though it might be a single
548  * onion service. The reason is that if we failed once to connect to the RP
549  * with a direct connection, we consider that chances are that we will fail
550  * again so try a 3-hop circuit and hope for the best. Because the service
551  * has no anonymity (single onion), this change of behavior won't affect
552  * security directly. */
553 
555  bstate->chosen_exit, flags);
556  if (new_circ == NULL) {
557  log_warn(LD_REND, "Failed to launch rendezvous circuit to %s",
558  safe_str_client(extend_info_describe(bstate->chosen_exit)));
559  goto done;
560  }
561 
562  /* Transfer build state information to the new circuit state in part to
563  * catch any other failures. */
564  new_circ->build_state->failure_count = bstate->failure_count+1;
565  new_circ->build_state->expiry_time = bstate->expiry_time;
566  new_circ->hs_ident = hs_ident_circuit_dup(circ->hs_ident);
567 
568  done:
569  return;
570 }
571 
572 /** Using the given descriptor intro point ip, the node of the
573  * rendezvous point rp_node and the service's subcredential, populate the
574  * already allocated intro1_data object with the needed key material and link
575  * specifiers.
576  *
577  * Return 0 on success or a negative value if we couldn't properly filled the
578  * introduce1 data from the RP node. In other word, it means the RP node is
579  * unusable to use in the introduction. */
580 static int
582  const node_t *rp_node,
583  const hs_subcredential_t *subcredential,
584  hs_cell_introduce1_data_t *intro1_data)
585 {
586  int ret = -1;
587  smartlist_t *rp_lspecs;
588 
589  tor_assert(ip);
590  tor_assert(rp_node);
591  tor_assert(subcredential);
592  tor_assert(intro1_data);
593 
594  /* Build the link specifiers from the node at the end of the rendezvous
595  * circuit that we opened for this introduction. */
596  rp_lspecs = node_get_link_specifier_smartlist(rp_node, 0);
597  if (smartlist_len(rp_lspecs) == 0) {
598  /* We can't rendezvous without link specifiers. */
599  smartlist_free(rp_lspecs);
600  goto end;
601  }
602 
603  /* Populate the introduce1 data object. */
604  memset(intro1_data, 0, sizeof(hs_cell_introduce1_data_t));
605  if (ip->legacy.key != NULL) {
606  intro1_data->is_legacy = 1;
607  intro1_data->legacy_key = ip->legacy.key;
608  }
609  intro1_data->auth_pk = &ip->auth_key_cert->signed_key;
610  intro1_data->enc_pk = &ip->enc_key;
611  intro1_data->subcredential = subcredential;
612  intro1_data->link_specifiers = rp_lspecs;
613  intro1_data->onion_pk = node_get_curve25519_onion_key(rp_node);
614  if (intro1_data->onion_pk == NULL) {
615  /* We can't rendezvous without the curve25519 onion key. */
616  goto end;
617  }
618  /* Success, we have valid introduce data. */
619  ret = 0;
620 
621  end:
622  return ret;
623 }
624 
625 /** Helper: cleanup function for client circuit. This is for every HS version.
626  * It is called from hs_circ_cleanup_on_close() entry point. */
627 static void
629 {
630  tor_assert(circ);
631 
632  if (circuit_is_hs_v3(circ)) {
634  }
635  /* It is possible the circuit has an HS purpose but no identifier (rend_data
636  * or hs_ident). Thus possible that this passes through. */
637 }
638 
639 /** Helper: cleanup function for client circuit. This is for every HS version.
640  * It is called from hs_circ_cleanup_on_free() entry point. */
641 static void
643 {
644  tor_assert(circ);
645 
646  if (circuit_is_hs_v2(circ)) {
648  } else if (circuit_is_hs_v3(circ)) {
650  }
651  /* It is possible the circuit has an HS purpose but no identifier (rend_data
652  * or hs_ident). Thus possible that this passes through. */
653 }
654 
655 /* ========== */
656 /* Public API */
657 /* ========== */
658 
659 /** Return an introduction point circuit matching the given intro point object.
660  * NULL is returned is no such circuit can be found. */
663 {
664  tor_assert(ip);
665 
666  if (ip->base.is_only_legacy) {
668  } else {
670  &ip->auth_key_kp.pubkey);
671  }
672 }
673 
674 /** Return an introduction point established circuit matching the given intro
675  * point object. The circuit purpose has to be CIRCUIT_PURPOSE_S_INTRO. NULL
676  * is returned is no such circuit can be found. */
679 {
680  origin_circuit_t *circ;
681 
682  tor_assert(ip);
683 
684  if (ip->base.is_only_legacy) {
686  } else {
688  &ip->auth_key_kp.pubkey);
689  }
690 
691  /* Only return circuit if it is established. */
692  return (circ && TO_CIRCUIT(circ)->purpose == CIRCUIT_PURPOSE_S_INTRO) ?
693  circ : NULL;
694 }
695 
696 /** Called when we fail building a rendezvous circuit at some point other than
697  * the last hop: launches a new circuit to the same rendezvous point. This
698  * supports legacy service.
699  *
700  * We currently relaunch connections to rendezvous points if:
701  * - A rendezvous circuit timed out before connecting to RP.
702  * - The rendezvous circuit failed to connect to the RP.
703  *
704  * We avoid relaunching a connection to this rendezvous point if:
705  * - We have already tried MAX_REND_FAILURES times to connect to this RP,
706  * - We've been trying to connect to this RP for more than MAX_REND_TIMEOUT
707  * seconds, or
708  * - We've already retried this specific rendezvous circuit.
709  */
710 void
712 {
713  tor_assert(circ);
715 
716  /* Check if we are allowed to relaunch to the rendezvous point of circ. */
718  goto done;
719  }
720 
721  /* Flag the circuit that we are relaunching, to avoid to relaunch twice a
722  * circuit to the same rendezvous point at the same time. */
724 
725  /* Legacy services don't have a hidden service ident. */
726  if (circ->hs_ident) {
728  } else {
730  }
731 
732  done:
733  return;
734 }
735 
736 /** For a given service and a service intro point, launch a circuit to the
737  * extend info ei. If the service is a single onion, and direct_conn is true,
738  * a one-hop circuit will be requested.
739  *
740  * Return 0 if the circuit was successfully launched and tagged
741  * with the correct identifier. On error, a negative value is returned. */
742 int
744  const hs_service_intro_point_t *ip,
745  extend_info_t *ei,
746  bool direct_conn)
747 {
748  /* Standard flags for introduction circuit. */
749  int ret = -1, circ_flags = CIRCLAUNCH_NEED_UPTIME | CIRCLAUNCH_IS_INTERNAL;
750  origin_circuit_t *circ;
751 
752  tor_assert(service);
753  tor_assert(ip);
754  tor_assert(ei);
755 
756  /* Update circuit flags in case of a single onion service that requires a
757  * direct connection. */
758  tor_assert_nonfatal(ip->circuit_retries > 0);
759  /* Only single onion services can make direct conns */
760  if (BUG(!service->config.is_single_onion && direct_conn)) {
761  goto end;
762  }
763  /* We only use a one-hop path on the first attempt. If the first attempt
764  * fails, we use a 3-hop path for reachability / reliability.
765  * (Unlike v2, retries is incremented by the caller before it calls this
766  * function.) */
767  if (direct_conn && ip->circuit_retries == 1) {
768  circ_flags |= CIRCLAUNCH_ONEHOP_TUNNEL;
769  }
770 
771  log_info(LD_REND, "Launching a circuit to intro point %s for service %s.",
772  safe_str_client(extend_info_describe(ei)),
773  safe_str_client(service->onion_address));
774 
775  /* Note down the launch for the retry period. Even if the circuit fails to
776  * be launched, we still want to respect the retry period to avoid stress on
777  * the circuit subsystem. */
778  service->state.num_intro_circ_launched++;
780  ei, circ_flags);
781  if (circ == NULL) {
782  goto end;
783  }
784 
785  /* Setup the circuit identifier and attach it to it. */
786  circ->hs_ident = create_intro_circuit_identifier(service, ip);
787  tor_assert(circ->hs_ident);
788  /* Register circuit in the global circuitmap. */
789  register_intro_circ(ip, circ);
790 
791  /* Success. */
792  ret = 0;
793  end:
794  return ret;
795 }
796 
797 /** Called when a service introduction point circuit is done building. Given
798  * the service and intro point object, this function will send the
799  * ESTABLISH_INTRO cell on the circuit. Return 0 on success. Return 1 if the
800  * circuit has been repurposed to General because we already have too many
801  * opened. */
802 int
805  const hs_service_descriptor_t *desc,
806  origin_circuit_t *circ)
807 {
808  int ret = 0;
809  unsigned int num_intro_circ, num_needed_circ;
810 
811  tor_assert(service);
812  tor_assert(ip);
813  tor_assert(desc);
814  tor_assert(circ);
815 
816  /* Cound opened circuits that have sent ESTABLISH_INTRO cells or are already
817  * established introduction circuits */
818  num_intro_circ = count_opened_desc_intro_point_circuits(service, desc);
819  num_needed_circ = service->config.num_intro_points;
820  if (num_intro_circ > num_needed_circ) {
821  /* There are too many opened valid intro circuit for what the service
822  * needs so repurpose this one. */
823 
824  /* XXX: Legacy code checks options->ExcludeNodes and if not NULL it just
825  * closes the circuit. I have NO idea why it does that so it hasn't been
826  * added here. I can only assume in case our ExcludeNodes list changes but
827  * in that case, all circuit are flagged unusable (config.c). --dgoulet */
828 
829  log_info(LD_CIRC | LD_REND, "Introduction circuit just opened but we "
830  "have enough for service %s. Repurposing "
831  "it to general and leaving internal.",
832  safe_str_client(service->onion_address));
834  /* Remove it from the circuitmap. */
836  /* Cleaning up the hidden service identifier and repurpose. */
837  hs_ident_circuit_free(circ->hs_ident);
838  circ->hs_ident = NULL;
839  if (circuit_should_use_vanguards(TO_CIRCUIT(circ)->purpose))
841  else
843 
844  /* Inform that this circuit just opened for this new purpose. */
845  circuit_has_opened(circ);
846  /* This return value indicate to the caller that the IP object should be
847  * removed from the service because it's corresponding circuit has just
848  * been repurposed. */
849  ret = 1;
850  goto done;
851  }
852 
853  log_info(LD_REND, "Introduction circuit %u established for service %s.",
854  TO_CIRCUIT(circ)->n_circ_id,
855  safe_str_client(service->onion_address));
857 
858  /* Time to send an ESTABLISH_INTRO cell on this circuit. On error, this call
859  * makes sure the circuit gets closed. */
860  send_establish_intro(service, ip, circ);
861 
862  done:
863  return ret;
864 }
865 
866 /** Called when a service rendezvous point circuit is done building. Given the
867  * service and the circuit, this function will send a RENDEZVOUS1 cell on the
868  * circuit using the information in the circuit identifier. If the cell can't
869  * be sent, the circuit is closed. */
870 void
872  origin_circuit_t *circ)
873 {
874  size_t payload_len;
875  uint8_t payload[RELAY_PAYLOAD_SIZE] = {0};
876 
877  tor_assert(service);
878  tor_assert(circ);
879  tor_assert(circ->hs_ident);
880 
881  /* Some useful logging. */
882  log_info(LD_REND, "Rendezvous circuit %u has opened with cookie %s "
883  "for service %s",
884  TO_CIRCUIT(circ)->n_circ_id,
885  hex_str((const char *) circ->hs_ident->rendezvous_cookie,
887  safe_str_client(service->onion_address));
889 
890  /* This can't fail. */
891  payload_len = hs_cell_build_rendezvous1(
893  sizeof(circ->hs_ident->rendezvous_cookie),
895  sizeof(circ->hs_ident->rendezvous_handshake_info),
896  payload);
897 
898  /* Pad the payload with random bytes so it matches the size of a legacy cell
899  * which is normally always bigger. Also, the size of a legacy cell is
900  * always smaller than the RELAY_PAYLOAD_SIZE so this is safe. */
901  if (payload_len < HS_LEGACY_RENDEZVOUS_CELL_SIZE) {
902  crypto_rand((char *) payload + payload_len,
903  HS_LEGACY_RENDEZVOUS_CELL_SIZE - payload_len);
904  payload_len = HS_LEGACY_RENDEZVOUS_CELL_SIZE;
905  }
906 
907  if (relay_send_command_from_edge(CONTROL_CELL_ID, TO_CIRCUIT(circ),
908  RELAY_COMMAND_RENDEZVOUS1,
909  (const char *) payload, payload_len,
910  circ->cpath->prev) < 0) {
911  /* On error, circuit is closed. */
912  log_warn(LD_REND, "Unable to send RENDEZVOUS1 cell on circuit %u "
913  "for service %s",
914  TO_CIRCUIT(circ)->n_circ_id,
915  safe_str_client(service->onion_address));
916  goto done;
917  }
918 
919  /* Setup end-to-end rendezvous circuit between the client and us. */
922  sizeof(circ->hs_ident->rendezvous_ntor_key_seed),
923  1) < 0) {
924  log_warn(LD_GENERAL, "Failed to setup circ");
925  goto done;
926  }
927 
928  done:
929  memwipe(payload, 0, sizeof(payload));
930 }
931 
932 /** Circ has been expecting an INTRO_ESTABLISHED cell that just arrived. Handle
933  * the INTRO_ESTABLISHED cell payload of length payload_len arriving on the
934  * given introduction circuit circ. The service is only used for logging
935  * purposes. Return 0 on success else a negative value. */
936 int
938  const hs_service_intro_point_t *ip,
939  origin_circuit_t *circ,
940  const uint8_t *payload, size_t payload_len)
941 {
942  int ret = -1;
943 
944  tor_assert(service);
945  tor_assert(ip);
946  tor_assert(circ);
947  tor_assert(payload);
948 
949  if (BUG(TO_CIRCUIT(circ)->purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO)) {
950  goto done;
951  }
952 
953  /* Try to parse the payload into a cell making sure we do actually have a
954  * valid cell. For a legacy node, it's an empty payload so as long as we
955  * have the cell, we are good. */
956  if (!ip->base.is_only_legacy &&
957  hs_cell_parse_intro_established(payload, payload_len) < 0) {
958  log_warn(LD_REND, "Unable to parse the INTRO_ESTABLISHED cell on "
959  "circuit %u for service %s",
960  TO_CIRCUIT(circ)->n_circ_id,
961  safe_str_client(service->onion_address));
962  goto done;
963  }
964 
965  /* Switch the purpose to a fully working intro point. */
967  /* Getting a valid INTRODUCE_ESTABLISHED means we've successfully used the
968  * circuit so update our pathbias subsystem. */
970  /* Success. */
971  ret = 0;
972 
973  done:
974  return ret;
975 }
976 
977 /**
978  * Go into <b>data</b> and add the right subcredential to be able to handle
979  * this incoming cell.
980  *
981  * <b>desc_subcred</b> is the subcredential of the descriptor that corresponds
982  * to the intro point that received this intro request. This subcredential
983  * should be used if we are not an onionbalance instance.
984  *
985  * Return 0 if everything went well, or -1 in case of internal error.
986  */
987 static int
990  const hs_subcredential_t *desc_subcred)
991 {
992  /* Handle the simple case first: We are not an onionbalance instance and we
993  * should just use the regular descriptor subcredential */
994  if (!hs_ob_service_is_instance(service)) {
995  data->n_subcredentials = 1;
996  data->subcredentials = desc_subcred;
997  return 0;
998  }
999 
1000  /* This should not happen since we should have made onionbalance
1001  * subcredentials when we created our descriptors. */
1002  if (BUG(!service->state.ob_subcreds)) {
1003  return -1;
1004  }
1005 
1006  /* We are an onionbalance instance: */
1007  data->n_subcredentials = service->state.n_ob_subcreds;
1008  data->subcredentials = service->state.ob_subcreds;
1009 
1010  return 0;
1011 }
1012 
1013 /** We just received an INTRODUCE2 cell on the established introduction circuit
1014  * circ. Handle the INTRODUCE2 payload of size payload_len for the given
1015  * circuit and service. This cell is associated with the intro point object ip
1016  * and the subcredential. Return 0 on success else a negative value. */
1017 int
1019  const origin_circuit_t *circ,
1021  const hs_subcredential_t *subcredential,
1022  const uint8_t *payload, size_t payload_len)
1023 {
1024  int ret = -1;
1025  time_t elapsed;
1027 
1028  tor_assert(service);
1029  tor_assert(circ);
1030  tor_assert(ip);
1031  tor_assert(subcredential);
1032  tor_assert(payload);
1033 
1034  /* Populate the data structure with everything we need for the cell to be
1035  * parsed, decrypted and key material computed correctly. */
1036  data.auth_pk = &ip->auth_key_kp.pubkey;
1037  data.enc_kp = &ip->enc_key_kp;
1038  data.payload = payload;
1039  data.payload_len = payload_len;
1040  data.link_specifiers = smartlist_new();
1041  data.replay_cache = ip->replay_cache;
1042 
1044  &data, subcredential)) {
1045  goto done;
1046  }
1047 
1048  if (hs_cell_parse_introduce2(&data, circ, service) < 0) {
1049  goto done;
1050  }
1051 
1052  /* Check whether we've seen this REND_COOKIE before to detect repeats. */
1055  data.rendezvous_cookie, sizeof(data.rendezvous_cookie),
1056  &elapsed)) {
1057  /* A Tor client will send a new INTRODUCE1 cell with the same REND_COOKIE
1058  * as its previous one if its intro circ times out while in state
1059  * CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT. If we received the first
1060  * INTRODUCE1 cell (the intro-point relay converts it into an INTRODUCE2
1061  * cell), we are already trying to connect to that rend point (and may
1062  * have already succeeded); drop this cell. */
1063  log_info(LD_REND, "We received an INTRODUCE2 cell with same REND_COOKIE "
1064  "field %ld seconds ago. Dropping cell.",
1065  (long int) elapsed);
1066  goto done;
1067  }
1068 
1069  /* At this point, we just confirmed that the full INTRODUCE2 cell is valid
1070  * so increment our counter that we've seen one on this intro point. */
1071  ip->introduce2_count++;
1072 
1073  /* Launch rendezvous circuit with the onion key and rend cookie. */
1074  launch_rendezvous_point_circuit(service, ip, &data);
1075  /* Success. */
1076  ret = 0;
1077 
1078  done:
1079  link_specifier_smartlist_free(data.link_specifiers);
1080  memwipe(&data, 0, sizeof(data));
1081  return ret;
1082 }
1083 
1084 /** Circuit <b>circ</b> just finished the rend ntor key exchange. Use the key
1085  * exchange output material at <b>ntor_key_seed</b> and setup <b>circ</b> to
1086  * serve as a rendezvous end-to-end circuit between the client and the
1087  * service. If <b>is_service_side</b> is set, then we are the hidden service
1088  * and the other side is the client.
1089  *
1090  * Return 0 if the operation went well; in case of error return -1. */
1091 int
1093  const uint8_t *ntor_key_seed, size_t seed_len,
1094  int is_service_side)
1095 {
1096  if (BUG(!circuit_purpose_is_correct_for_rend(TO_CIRCUIT(circ)->purpose,
1097  is_service_side))) {
1098  return -1;
1099  }
1100 
1101  crypt_path_t *hop = create_rend_cpath(ntor_key_seed, seed_len,
1102  is_service_side);
1103  if (!hop) {
1104  log_warn(LD_REND, "Couldn't get v3 %s cpath!",
1105  is_service_side ? "service-side" : "client-side");
1106  return -1;
1107  }
1108 
1109  finalize_rend_circuit(circ, hop, is_service_side);
1110 
1111  return 0;
1112 }
1113 
1114 /** We are a v2 legacy HS client and we just received a RENDEZVOUS1 cell
1115  * <b>rend_cell_body</b> on <b>circ</b>. Finish up the DH key exchange and then
1116  * extend the crypt path of <b>circ</b> so that the hidden service is on the
1117  * other side. */
1118 int
1120  const uint8_t *rend_cell_body)
1121 {
1122 
1124  TO_CIRCUIT(circ)->purpose, 0))) {
1125  return -1;
1126  }
1127 
1128  crypt_path_t *hop = create_rend_cpath_legacy(circ, rend_cell_body);
1129  if (!hop) {
1130  log_warn(LD_GENERAL, "Couldn't get v2 cpath.");
1131  return -1;
1132  }
1133 
1134  finalize_rend_circuit(circ, hop, 0);
1135 
1136  return 0;
1137 }
1138 
1139 /** Given the introduction circuit intro_circ, the rendezvous circuit
1140  * rend_circ, a descriptor intro point object ip and the service's
1141  * subcredential, send an INTRODUCE1 cell on intro_circ.
1142  *
1143  * This will also setup the circuit identifier on rend_circ containing the key
1144  * material for the handshake and e2e encryption. Return 0 on success else
1145  * negative value. Because relay_send_command_from_edge() closes the circuit
1146  * on error, it is possible that intro_circ is closed on error. */
1147 int
1149  origin_circuit_t *rend_circ,
1150  const hs_desc_intro_point_t *ip,
1151  const hs_subcredential_t *subcredential)
1152 {
1153  int ret = -1;
1154  ssize_t payload_len;
1155  uint8_t payload[RELAY_PAYLOAD_SIZE] = {0};
1156  hs_cell_introduce1_data_t intro1_data;
1157 
1158  tor_assert(intro_circ);
1159  tor_assert(rend_circ);
1160  tor_assert(ip);
1161  tor_assert(subcredential);
1162 
1163  /* It is undefined behavior in hs_cell_introduce1_data_clear() if intro1_data
1164  * has been declared on the stack but not initialized. Here, we set it to 0.
1165  */
1166  memset(&intro1_data, 0, sizeof(hs_cell_introduce1_data_t));
1167 
1168  /* This takes various objects in order to populate the introduce1 data
1169  * object which is used to build the content of the cell. */
1170  const node_t *exit_node = build_state_get_exit_node(rend_circ->build_state);
1171  if (exit_node == NULL) {
1172  log_info(LD_REND, "Unable to get rendezvous point for circuit %u. "
1173  "Failing.", TO_CIRCUIT(intro_circ)->n_circ_id);
1174  goto done;
1175  }
1176 
1177  /* We should never select an invalid rendezvous point in theory but if we
1178  * do, this function will fail to populate the introduce data. */
1179  if (setup_introduce1_data(ip, exit_node, subcredential, &intro1_data) < 0) {
1180  log_warn(LD_REND, "Unable to setup INTRODUCE1 data. The chosen rendezvous "
1181  "point is unusable. Closing circuit.");
1182  goto close;
1183  }
1184 
1185  /* Final step before we encode a cell, we setup the circuit identifier which
1186  * will generate both the rendezvous cookie and client keypair for this
1187  * connection. Those are put in the ident. */
1188  intro1_data.rendezvous_cookie = rend_circ->hs_ident->rendezvous_cookie;
1189  intro1_data.client_kp = &rend_circ->hs_ident->rendezvous_client_kp;
1190 
1191  memcpy(intro_circ->hs_ident->rendezvous_cookie,
1192  rend_circ->hs_ident->rendezvous_cookie,
1193  sizeof(intro_circ->hs_ident->rendezvous_cookie));
1194 
1195  /* From the introduce1 data object, this will encode the INTRODUCE1 cell
1196  * into payload which is then ready to be sent as is. */
1197  payload_len = hs_cell_build_introduce1(&intro1_data, payload);
1198  if (BUG(payload_len < 0)) {
1199  goto close;
1200  }
1201 
1202  if (relay_send_command_from_edge(CONTROL_CELL_ID, TO_CIRCUIT(intro_circ),
1203  RELAY_COMMAND_INTRODUCE1,
1204  (const char *) payload, payload_len,
1205  intro_circ->cpath->prev) < 0) {
1206  /* On error, circuit is closed. */
1207  log_warn(LD_REND, "Unable to send INTRODUCE1 cell on circuit %u.",
1208  TO_CIRCUIT(intro_circ)->n_circ_id);
1209  goto done;
1210  }
1211 
1212  /* Success. */
1213  ret = 0;
1214  goto done;
1215 
1216  close:
1217  circuit_mark_for_close(TO_CIRCUIT(rend_circ), END_CIRC_REASON_INTERNAL);
1218  done:
1219  hs_cell_introduce1_data_clear(&intro1_data);
1220  memwipe(payload, 0, sizeof(payload));
1221  return ret;
1222 }
1223 
1224 /** Send an ESTABLISH_RENDEZVOUS cell along the rendezvous circuit circ. On
1225  * success, 0 is returned else -1 and the circuit is marked for close. */
1226 int
1228 {
1229  ssize_t cell_len = 0;
1230  uint8_t cell[RELAY_PAYLOAD_SIZE] = {0};
1231 
1232  tor_assert(circ);
1234 
1235  log_info(LD_REND, "Send an ESTABLISH_RENDEZVOUS cell on circuit %u",
1236  TO_CIRCUIT(circ)->n_circ_id);
1237 
1238  /* Set timestamp_dirty, because circuit_expire_building expects it,
1239  * and the rend cookie also means we've used the circ. */
1240  TO_CIRCUIT(circ)->timestamp_dirty = time(NULL);
1241 
1242  /* We've attempted to use this circuit. Probe it if we fail */
1244 
1245  /* Generate the RENDEZVOUS_COOKIE and place it in the identifier so we can
1246  * complete the handshake when receiving the acknowledgement. */
1248  /* Generate the client keypair. No need to be extra strong, not long term */
1250 
1251  cell_len =
1253  cell);
1254  if (BUG(cell_len < 0)) {
1255  goto err;
1256  }
1257 
1258  if (relay_send_command_from_edge(CONTROL_CELL_ID, TO_CIRCUIT(circ),
1259  RELAY_COMMAND_ESTABLISH_RENDEZVOUS,
1260  (const char *) cell, cell_len,
1261  circ->cpath->prev) < 0) {
1262  /* Circuit has been marked for close */
1263  log_warn(LD_REND, "Unable to send ESTABLISH_RENDEZVOUS cell on "
1264  "circuit %u", TO_CIRCUIT(circ)->n_circ_id);
1265  memwipe(cell, 0, cell_len);
1266  goto err;
1267  }
1268 
1269  memwipe(cell, 0, cell_len);
1270  return 0;
1271  err:
1272  return -1;
1273 }
1274 
1275 /** Circuit cleanup strategy:
1276  *
1277  * What follows is a series of functions that notifies the HS subsystem of 3
1278  * different circuit cleanup phase: close, free and repurpose.
1279  *
1280  * Tor can call any of those in any orders so they have to be safe between
1281  * each other. In other words, the free should never depend on close to be
1282  * called before.
1283  *
1284  * The "on_close()" is called from circuit_mark_for_close() which is
1285  * considered the tor fast path and thus as little work as possible should
1286  * done in that function. Currently, we only remove the circuit from the HS
1287  * circuit map and move on.
1288  *
1289  * The "on_free()" is called from circuit circuit_free_() and it is very
1290  * important that at the end of the function, no state or objects related to
1291  * this circuit remains alive.
1292  *
1293  * The "on_repurpose()" is called from circuit_change_purpose() for which we
1294  * simply remove it from the HS circuit map. We do not have other cleanup
1295  * requirements after that.
1296  *
1297  * NOTE: The onion service code, specifically the service code, cleans up
1298  * lingering objects or state if any of its circuit disappear which is why
1299  * our cleanup strategy doesn't involve any service specific actions. As long
1300  * as the circuit is removed from the HS circuit map, it won't be used.
1301  */
1302 
1303 /** We are about to close this <b>circ</b>. Clean it up from any related HS
1304  * data structures. This function can be called multiple times safely for the
1305  * same circuit. */
1306 void
1308 {
1309  tor_assert(circ);
1310 
1313  }
1314 
1315  /* On close, we simply remove it from the circuit map. It can not be used
1316  * anymore. We keep this code path fast and lean. */
1317 
1318  if (circ->hs_token) {
1320  }
1321 }
1322 
1323 /** We are about to free this <b>circ</b>. Clean it up from any related HS
1324  * data structures. This function can be called multiple times safely for the
1325  * same circuit. */
1326 void
1328 {
1329  tor_assert(circ);
1330 
1331  /* NOTE: Bulk of the work of cleaning up a circuit is done here. */
1332 
1335  }
1336 
1337  /* We have no assurance that the given HS circuit has been closed before and
1338  * thus removed from the HS map. This actually happens in unit tests. */
1339  if (circ->hs_token) {
1341  }
1342 }
1343 
1344 /** We are about to repurpose this <b>circ</b>. Clean it up from any related
1345  * HS data structures. This function can be called multiple times safely for
1346  * the same circuit. */
1347 void
1349 {
1350  tor_assert(circ);
1351 
1352  /* On repurpose, we simply remove it from the circuit map but we do not do
1353  * the on_free actions since we don't treat a repurpose as something we need
1354  * to report in the client cache failure. */
1355 
1356  if (circ->hs_token) {
1358  }
1359 }
1360 
1361 /** Return true iff the given established client rendezvous circuit was sent
1362  * into the INTRODUCE1 cell. This is called so we can take a decision on
1363  * expiring or not the circuit.
1364  *
1365  * The caller MUST make sure the circuit is an established client rendezvous
1366  * circuit (purpose: CIRCUIT_PURPOSE_C_REND_READY).
1367  *
1368  * This function supports all onion service versions. */
1369 bool
1371 {
1372  tor_assert(circ);
1373  /* This can only be called for a rendezvous circuit that is an established
1374  * confirmed rendezsvous circuit but without an introduction ACK. */
1376 
1377  /* The v2 and v3 circuit are handled differently:
1378  *
1379  * v2: A circ's pending_final_cpath field is non-NULL iff it is a rend circ
1380  * and we have tried to send an INTRODUCE1 cell specifying it. Thus, if the
1381  * pending_final_cpath field *is* NULL, then we want to not spare it.
1382  *
1383  * v3: When the INTRODUCE1 cell is sent, the introduction encryption public
1384  * key is copied in the rendezvous circuit hs identifier. If it is a valid
1385  * key, we know that this circuit is waiting the ACK on the introduction
1386  * circuit. We want to _not_ spare the circuit if the key was never set. */
1387 
1388  if (circ->rend_data) {
1389  /* v2. */
1390  if (circ->build_state && circ->build_state->pending_final_cpath != NULL) {
1391  return true;
1392  }
1393  } else if (circ->hs_ident) {
1394  /* v3. */
1396  return true;
1397  }
1398  } else {
1399  /* A circuit with an HS purpose without an hs_ident or rend_data in theory
1400  * can not happen. In case, scream loudly and return false to the caller
1401  * that the rendezvous was not sent in the INTRO1 cell. */
1403  }
1404 
1405  /* The rendezvous has not been specified in the INTRODUCE1 cell. */
1406  return false;
1407 }
log_fn
#define log_fn(severity, domain, args,...)
Definition: log.h:287
hs_circuit_setup_e2e_rend_circ
int hs_circuit_setup_e2e_rend_circ(origin_circuit_t *circ, const uint8_t *ntor_key_seed, size_t seed_len, int is_service_side)
Definition: hs_circuit.c:1092
hs_service_t::config
hs_service_config_t config
Definition: hs_service.h:309
tor_free
#define tor_free(p)
Definition: malloc.h:52
circuit_purpose_is_hs_client
bool circuit_purpose_is_hs_client(const uint8_t purpose)
Definition: circuituse.c:1996
hs_service.h
Header file containing service data for the HS subsytem.
CURVE25519_PUBKEY_LEN
#define CURVE25519_PUBKEY_LEN
Definition: x25519_sizes.h:20
hs_service_intro_point_t::base
hs_intropoint_t base
Definition: hs_service.h:40
MAX_REND_FAILURES
#define MAX_REND_FAILURES
Definition: hs_common.h:47
hex_str
const char * hex_str(const char *from, size_t fromlen)
Definition: binascii.c:34
CIRCUIT_STATE_OPEN
#define CIRCUIT_STATE_OPEN
Definition: circuitlist.h:32
circuit_t::purpose
uint8_t purpose
Definition: circuit_st.h:111
circuit_t::marked_for_close
uint16_t marked_for_close
Definition: circuit_st.h:189
hs_ident.h
Header file containing circuit and connection identifier data for the whole HS subsytem.
memwipe
void memwipe(void *mem, uint8_t byte, size_t sz)
Definition: crypto_util.c:55
get_service_anonymity_string
static const char * get_service_anonymity_string(const hs_service_t *service)
Definition: hs_circuit.c:358
CIRCUIT_PURPOSE_C_GENERAL
#define CIRCUIT_PURPOSE_C_GENERAL
Definition: circuitlist.h:72
hs_cell_build_rendezvous1
ssize_t hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie, size_t rendezvous_cookie_len, const uint8_t *rendezvous_handshake_info, size_t rendezvous_handshake_info_len, uint8_t *cell_out)
Definition: hs_cell.c:971
MOCK_IMPL
#define MOCK_IMPL(rv, funcname, arglist)
Definition: testsupport.h:133
hs_circ_service_rp_has_opened
void hs_circ_service_rp_has_opened(const hs_service_t *service, origin_circuit_t *circ)
Definition: hs_circuit.c:871
hs_cell_introduce1_data_t::legacy_key
const crypto_pk_t * legacy_key
Definition: hs_cell.h:28
crypt_path_t::package_window
int package_window
Definition: crypt_path_st.h:78
crypt_path_t::rend_circ_nonce
char rend_circ_nonce[DIGEST_LEN]
Definition: crypt_path_st.h:58
hs_client_circuit_cleanup_on_free
void hs_client_circuit_cleanup_on_free(const circuit_t *circ)
Definition: hs_client.c:1892
CIRCLAUNCH_NEED_CAPACITY
#define CIRCLAUNCH_NEED_CAPACITY
Definition: circuituse.h:43
tor_assert
#define tor_assert(expr)
Definition: util_bug.h:102
LD_BUG
#define LD_BUG
Definition: log.h:86
ed25519_pubkey_eq
int ed25519_pubkey_eq(const ed25519_public_key_t *key1, const ed25519_public_key_t *key2)
Definition: crypto_ed25519.c:642
hs_circ_send_establish_rendezvous
int hs_circ_send_establish_rendezvous(origin_circuit_t *circ)
Definition: hs_circuit.c:1227
cpath_build_state_st.h
Circuit-build-stse structure.
hs_ident_circuit_t::identity_pk
ed25519_public_key_t identity_pk
Definition: hs_ident.h:45
circuituse.h
Header file for circuituse.c.
LD_GENERAL
#define LD_GENERAL
Definition: log.h:62
RELAY_PAYLOAD_SIZE
#define RELAY_PAYLOAD_SIZE
Definition: or.h:606
crypt_path_t::state
uint8_t state
Definition: crypt_path_st.h:68
describe.h
Header file for describe.c.
rend_service_relaunch_rendezvous
void rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc)
Definition: rendservice.c:3024
cpath_build_state_t::is_internal
unsigned int is_internal
Definition: cpath_build_state_st.h:26
pathbias_count_use_attempt
void pathbias_count_use_attempt(origin_circuit_t *circ)
Definition: circpathbias.c:604
hs_cell_introduce2_data_t::link_specifiers
smartlist_t * link_specifiers
Definition: hs_cell.h:82
setup_introduce1_data
static int setup_introduce1_data(const hs_desc_intro_point_t *ip, const node_t *rp_node, const hs_subcredential_t *subcredential, hs_cell_introduce1_data_t *intro1_data)
Definition: hs_circuit.c:581
replaycache_add_test_and_elapsed
int replaycache_add_test_and_elapsed(replaycache_t *r, const void *data, size_t len, time_t *elapsed)
Definition: replaycache.c:195
CIRCUIT_PURPOSE_C_REND_JOINED
#define CIRCUIT_PURPOSE_C_REND_JOINED
Definition: circuitlist.h:90
hs_cell_introduce1_data_clear
void hs_cell_introduce1_data_clear(hs_cell_introduce1_data_t *data)
Definition: hs_cell.c:1128
ed25519_pubkey_copy
void ed25519_pubkey_copy(ed25519_public_key_t *dest, const ed25519_public_key_t *src)
Definition: crypto_ed25519.c:654
hs_service_intropoints_t::map
digest256map_t * map
Definition: hs_service.h:97
create_intro_circuit_identifier
static hs_ident_circuit_t * create_intro_circuit_identifier(const hs_service_t *service, const hs_service_intro_point_t *ip)
Definition: hs_circuit.c:292
hs_service_config_t::is_single_onion
unsigned int is_single_onion
Definition: hs_service.h:239
hs_cell_introduce2_data_t::subcredentials
const struct hs_subcredential_t * subcredentials
Definition: hs_cell.h:67
hs_cell_build_establish_rendezvous
ssize_t hs_cell_build_establish_rendezvous(const uint8_t *rendezvous_cookie, uint8_t *cell_out)
Definition: hs_cell.c:1049
smartlist_new
smartlist_t * smartlist_new(void)
Definition: smartlist_core.c:26
hs_cell_introduce2_data_t::rendezvous_cookie
uint8_t rendezvous_cookie[REND_COOKIE_LEN]
Definition: hs_cell.h:78
hs_desc_intro_point_t::auth_key_cert
tor_cert_t * auth_key_cert
Definition: hs_descriptor.h:111
hs_circ_service_get_intro_circ
origin_circuit_t * hs_circ_service_get_intro_circ(const hs_service_intro_point_t *ip)
Definition: hs_circuit.c:662
crypt_path.h
Header file for crypt_path.c.
circuit_is_hs_v2
bool circuit_is_hs_v2(const circuit_t *circ)
Definition: circuituse.c:2019
crypt_path_t
Definition: crypt_path_st.h:47
send_establish_intro
static void send_establish_intro(const hs_service_t *service, hs_service_intro_point_t *ip, origin_circuit_t *circ)
Definition: hs_circuit.c:312
hs_cell_introduce1_data_t::subcredential
const struct hs_subcredential_t * subcredential
Definition: hs_cell.h:34
hs_cell_introduce2_data_t::payload
const uint8_t * payload
Definition: hs_cell.h:69
extend_info_describe
const char * extend_info_describe(const extend_info_t *ei)
Definition: describe.c:202
hs_circ_handle_introduce2
int hs_circ_handle_introduce2(const hs_service_t *service, const origin_circuit_t *circ, hs_service_intro_point_t *ip, const hs_subcredential_t *subcredential, const uint8_t *payload, size_t payload_len)
Definition: hs_circuit.c:1018
hs_service_t::state
hs_service_state_t state
Definition: hs_service.h:303
hs_cell.h
Header file containing cell data for the whole HS subsytem.
hs_desc_intro_point_t::legacy
struct hs_desc_intro_point_t::@16 legacy
origin_circuit_t::hs_service_side_rend_circ_has_been_relaunched
unsigned int hs_service_side_rend_circ_has_been_relaunched
Definition: origin_circuit_st.h:219
circuit_t::hs_token
struct hs_token_t * hs_token
Definition: circuit_st.h:216
hs_circ_launch_intro_point
int hs_circ_launch_intro_point(hs_service_t *service, const hs_service_intro_point_t *ip, extend_info_t *ei, bool direct_conn)
Definition: hs_circuit.c:743
hs_cell_introduce1_data_t::auth_pk
const ed25519_public_key_t * auth_pk
Definition: hs_cell.h:30
hs_circ_send_introduce1
int hs_circ_send_introduce1(origin_circuit_t *intro_circ, origin_circuit_t *rend_circ, const hs_desc_intro_point_t *ip, const hs_subcredential_t *subcredential)
Definition: hs_circuit.c:1148
rend_client_circuit_cleanup_on_free
void rend_client_circuit_cleanup_on_free(const circuit_t *circ)
Definition: rendclient.c:1264
origin_circuit_t::hs_circ_has_timed_out
unsigned int hs_circ_has_timed_out
Definition: origin_circuit_st.h:207
hs_cell_introduce2_data_t::enc_kp
const curve25519_keypair_t * enc_kp
Definition: hs_cell.h:59
hs_service_state_t::replay_cache_rend_cookie
replaycache_t * replay_cache_rend_cookie
Definition: hs_service.h:277
CIRCUIT_PURPOSE_C_ESTABLISH_REND
#define CIRCUIT_PURPOSE_C_ESTABLISH_REND
Definition: circuitlist.h:83
hs_client.h
Header file containing client data for the HS subsytem.
crypto_util.h
Common functions for cryptographic routines.
hs_circ_retry_service_rendezvous_point
void hs_circ_retry_service_rendezvous_point(origin_circuit_t *circ)
Definition: hs_circuit.c:711
LD_CIRC
#define LD_CIRC
Definition: log.h:82
hs_intropoint_t::is_only_legacy
unsigned int is_only_legacy
Definition: hs_intropoint.h:19
HS_REND_COOKIE_LEN
#define HS_REND_COOKIE_LEN
Definition: hs_ident.h:30
hs_circuitmap_get_intro_circ_v2_service_side
origin_circuit_t * hs_circuitmap_get_intro_circ_v2_service_side(const uint8_t *digest)
Definition: hs_circuitmap.c:400
hs_circuitmap_remove_circuit
void hs_circuitmap_remove_circuit(circuit_t *circ)
Definition: hs_circuitmap.c:571
cpath_build_state_t::failure_count
int failure_count
Definition: cpath_build_state_st.h:39
hs_service_intro_point_t::enc_key_kp
curve25519_keypair_t enc_key_kp
Definition: hs_service.h:51
hs_circ_cleanup_on_free
void hs_circ_cleanup_on_free(circuit_t *circ)
Definition: hs_circuit.c:1327
circuitlist.h
Header file for circuitlist.c.
hs_desc_intro_point_t::enc_key
curve25519_public_key_t enc_key
Definition: hs_descriptor.h:114
crypt_path_st.h
Path structures for origin circuits.
circuit_log_path
void circuit_log_path(int severity, unsigned int domain, origin_circuit_t *circ)
Definition: circuitbuild.c:352
DIGEST_LEN
#define DIGEST_LEN
Definition: digest_sizes.h:20
finalize_rend_circuit
static void finalize_rend_circuit(origin_circuit_t *circ, crypt_path_t *hop, int is_service_side)
Definition: hs_circuit.c:162
MAX_REND_TIMEOUT
#define MAX_REND_TIMEOUT
Definition: hs_common.h:50
can_relaunch_service_rendezvous_point
static int can_relaunch_service_rendezvous_point(const origin_circuit_t *circ)
Definition: hs_circuit.c:479
hs_cell_introduce1_data_t::link_specifiers
smartlist_t * link_specifiers
Definition: hs_cell.h:42
count_opened_desc_intro_point_circuits
static unsigned int count_opened_desc_intro_point_circuits(const hs_service_t *service, const hs_service_descriptor_t *desc)
Definition: hs_circuit.c:221
cleanup_on_free_client_circ
static void cleanup_on_free_client_circ(circuit_t *circ)
Definition: hs_circuit.c:642
cpath_build_state_t::chosen_exit
extend_info_t * chosen_exit
Definition: cpath_build_state_st.h:20
hs_cell_parse_introduce2
ssize_t hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data, const origin_circuit_t *circ, const hs_service_t *service)
Definition: hs_cell.c:829
crypt_path_t::deliver_window
int deliver_window
Definition: crypt_path_st.h:80
DH1024_KEY_LEN
#define DH1024_KEY_LEN
Definition: dh_sizes.h:20
circuit_is_hs_v3
bool circuit_is_hs_v3(const circuit_t *circ)
Definition: circuituse.c:2027
hs_ident_circuit_t::intro_auth_pk
ed25519_public_key_t intro_auth_pk
Definition: hs_ident.h:51
circuit_try_attaching_streams
void circuit_try_attaching_streams(origin_circuit_t *circ)
Definition: circuituse.c:1768
hs_cell_introduce2_data_t::n_subcredentials
size_t n_subcredentials
Definition: hs_cell.h:63
tor_memneq
#define tor_memneq(a, b, sz)
Definition: di_ops.h:21
tor_assert_nonfatal_unreached
#define tor_assert_nonfatal_unreached()
Definition: util_bug.h:176
node_t
Definition: node_st.h:34
origin_circuit_t
Definition: origin_circuit_st.h:79
hs_ob_service_is_instance
bool hs_ob_service_is_instance(const hs_service_t *service)
Definition: hs_ob.c:201
crypto_dh.h
Headers for crypto_dh.c.
hs_desc_intro_point_t::key
crypto_pk_t * key
Definition: hs_descriptor.h:126
register_intro_circ
static void register_intro_circ(const hs_service_intro_point_t *ip, origin_circuit_t *circ)
Definition: hs_circuit.c:203
CIRCLAUNCH_ONEHOP_TUNNEL
#define CIRCLAUNCH_ONEHOP_TUNNEL
Definition: circuituse.h:39
hs_cell_introduce2_data_t
Definition: hs_cell.h:50
hs_cell_introduce2_data_t::auth_pk
const ed25519_public_key_t * auth_pk
Definition: hs_cell.h:55
CIRCUIT_PURPOSE_HS_VANGUARDS
#define CIRCUIT_PURPOSE_HS_VANGUARDS
Definition: circuitlist.h:130
crypt_path_t::rend_dh_handshake_state
struct crypto_dh_t * rend_dh_handshake_state
Definition: crypt_path_st.h:55
REND_COOKIE_LEN
#define REND_COOKIE_LEN
Definition: or.h:400
hs_service_intro_point_t::legacy_key_digest
uint8_t legacy_key_digest[DIGEST_LEN]
Definition: hs_service.h:58
LD_REND
#define LD_REND
Definition: log.h:84
hs_service_intro_point_t::introduce2_count
uint64_t introduce2_count
Definition: hs_service.h:61
hs_circ_service_get_established_intro_circ
origin_circuit_t * hs_circ_service_get_established_intro_circ(const hs_service_intro_point_t *ip)
Definition: hs_circuit.c:678
hs_ntor_circuit_key_expansion
int hs_ntor_circuit_key_expansion(const uint8_t *ntor_key_seed, size_t seed_len, uint8_t *keys_out, size_t keys_out_len)
Definition: hs_ntor.c:615
circuit_change_purpose
void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose)
Definition: circuituse.c:3117
curve25519_keypair_generate
int curve25519_keypair_generate(curve25519_keypair_t *keypair_out, int extra_strong)
Definition: crypto_curve25519.c:190
circuit_has_opened
void circuit_has_opened(origin_circuit_t *circ)
Definition: circuituse.c:1693
circuit_t
Definition: circuit_st.h:61
nodelist.h
Header file for nodelist.c.
cpath_extend_linked_list
void cpath_extend_linked_list(crypt_path_t **head_ptr, crypt_path_t *new_hop)
Definition: crypt_path.c:45
hs_cell_introduce1_data_t::client_kp
const curve25519_keypair_t * client_kp
Definition: hs_cell.h:40
hs_cell_introduce2_data_t::payload_len
size_t payload_len
Definition: hs_cell.h:71
hs_cell_introduce1_data_t::enc_pk
const curve25519_public_key_t * enc_pk
Definition: hs_cell.h:32
rendservice.h
Header file for rendservice.c.
DIGEST256_LEN
#define DIGEST256_LEN
Definition: digest_sizes.h:23
extendinfo.h
Header for core/or/extendinfo.c.
hs_service_keys_t::identity_pk
ed25519_public_key_t identity_pk
Definition: hs_service.h:172
hs_service_config_t::num_intro_points
unsigned int num_intro_points
Definition: hs_service.h:224
pathbias_mark_use_success
void pathbias_mark_use_success(origin_circuit_t *circ)
Definition: circpathbias.c:661
CIRCWINDOW_START
#define CIRCWINDOW_START
Definition: or.h:502
LOG_INFO
#define LOG_INFO
Definition: log.h:45
crypto_rand.h
Common functions for using (pseudo-)random number generators.
HS_LEGACY_RENDEZVOUS_CELL_SIZE
#define HS_LEGACY_RENDEZVOUS_CELL_SIZE
Definition: hs_common.h:131
hs_get_service_max_rend_failures
int hs_get_service_max_rend_failures(void)
Definition: hs_common.c:234
get_subcredential_for_handling_intro2_cell
static int get_subcredential_for_handling_intro2_cell(const hs_service_t *service, hs_cell_introduce2_data_t *data, const hs_subcredential_t *desc_subcred)
Definition: hs_circuit.c:988
origin_circuit_t::build_state
cpath_build_state_t * build_state
Definition: origin_circuit_st.h:123
hs_cell_introduce2_data_t::replay_cache
replaycache_t * replay_cache
Definition: hs_cell.h:84
circuitbuild.h
Header file for circuitbuild.c.
CIRCUIT_PURPOSE_S_REND_JOINED
#define CIRCUIT_PURPOSE_S_REND_JOINED
Definition: circuitlist.h:112
hs_service_t
Definition: hs_service.h:293
launch_rendezvous_point_circuit
STATIC void launch_rendezvous_point_circuit(const hs_service_t *service, const hs_service_intro_point_t *ip, const hs_cell_introduce2_data_t *data)
Definition: hs_circuit.c:375
curve25519_public_key_is_ok
int curve25519_public_key_is_ok(const curve25519_public_key_t *key)
Definition: crypto_curve25519.c:132
hs_service_t::keys
hs_service_keys_t keys
Definition: hs_service.h:306
crypto_dh_compute_secret
ssize_t crypto_dh_compute_secret(int severity, crypto_dh_t *dh, const char *pubkey, size_t pubkey_len, char *secret_out, size_t secret_bytes_out)
Definition: crypto_dh.c:79
CIRCLAUNCH_IS_INTERNAL
#define CIRCLAUNCH_IS_INTERNAL
Definition: circuituse.h:46
hs_service_state_t::num_intro_circ_launched
unsigned int num_intro_circ_launched
Definition: hs_service.h:270
hs_cell_build_establish_intro
ssize_t hs_cell_build_establish_intro(const char *circ_nonce, const hs_service_config_t *service_config, const hs_service_intro_point_t *ip, uint8_t *cell_out)
Definition: hs_cell.c:614
curve25519_public_key_t
Definition: crypto_curve25519.h:24
create_rp_circuit_identifier
STATIC hs_ident_circuit_t * create_rp_circuit_identifier(const hs_service_t *service, const uint8_t *rendezvous_cookie, const curve25519_public_key_t *server_pk, const hs_ntor_rend_cell_keys_t *keys)
Definition: hs_circuit.c:253
cpath_init_circuit_crypto
int cpath_init_circuit_crypto(crypt_path_t *cpath, const char *key_data, size_t key_data_len, int reverse, int is_hs_v3)
Definition: crypt_path.c:151
create_rend_cpath_legacy
static crypt_path_t * create_rend_cpath_legacy(origin_circuit_t *circ, const uint8_t *rend_cell_body)
Definition: hs_circuit.c:115
hs_cell_introduce1_data_t::onion_pk
const curve25519_public_key_t * onion_pk
Definition: hs_cell.h:36
CIRCLAUNCH_NEED_UPTIME
#define CIRCLAUNCH_NEED_UPTIME
Definition: circuituse.h:41
origin_circuit_t::cpath
crypt_path_t * cpath
Definition: origin_circuit_st.h:129
hs_circ_service_intro_has_opened
int hs_circ_service_intro_has_opened(hs_service_t *service, hs_service_intro_point_t *ip, const hs_service_descriptor_t *desc, origin_circuit_t *circ)
Definition: hs_circuit.c:803
cpath_build_state_t::need_capacity
unsigned int need_capacity
Definition: cpath_build_state_st.h:24
relay.h
Header file for relay.c.
hs_cell_introduce2_data_t::onion_pk
curve25519_public_key_t onion_pk
Definition: hs_cell.h:76
hs_cell_introduce1_data_t
Definition: hs_cell.h:23
CIRCUIT_PURPOSE_C_REND_READY
#define CIRCUIT_PURPOSE_C_REND_READY
Definition: circuitlist.h:85
hs_cell_parse_intro_established
ssize_t hs_cell_parse_intro_established(const uint8_t *payload, size_t payload_len)
Definition: hs_cell.c:738
CIRCUIT_PURPOSE_S_CONNECT_REND
#define CIRCUIT_PURPOSE_S_CONNECT_REND
Definition: circuitlist.h:109
cpath_build_state_t::need_uptime
unsigned int need_uptime
Definition: cpath_build_state_st.h:22
crypt_path_t::prev
struct crypt_path_t * prev
Definition: crypt_path_st.h:75
hs_get_extend_info_from_lspecs
extend_info_t * hs_get_extend_info_from_lspecs(const smartlist_t *lspecs, const curve25519_public_key_t *onion_key, int direct_conn)
Definition: hs_common.c:1714
hs_cell_introduce1_data_t::is_legacy
unsigned int is_legacy
Definition: hs_cell.h:25
hs_subcredential_t
Definition: hs_ntor.h:43
hs_ident_circuit_t
Definition: hs_ident.h:42
hs_circuit_setup_e2e_rend_circ_legacy_client
int hs_circuit_setup_e2e_rend_circ_legacy_client(origin_circuit_t *circ, const uint8_t *rend_cell_body)
Definition: hs_circuit.c:1119
hs_service_requires_uptime_circ
int hs_service_requires_uptime_circ(const smartlist_t *ports)
Definition: hs_common.c:1133
circuit_should_use_vanguards
int circuit_should_use_vanguards(uint8_t purpose)
Definition: circuituse.c:2044
CIRCUIT_PURPOSE_S_ESTABLISH_INTRO
#define CIRCUIT_PURPOSE_S_ESTABLISH_INTRO
Definition: circuitlist.h:103
CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED
#define CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED
Definition: circuitlist.h:88
hs_service_intro_point_t::auth_key_kp
ed25519_keypair_t auth_key_kp
Definition: hs_service.h:48
hs_service_descriptor_t
Definition: hs_service.h:123
hs_cell_introduce1_data_t::rendezvous_cookie
const uint8_t * rendezvous_cookie
Definition: hs_cell.h:38
hs_service_intro_point_t::replay_cache
replaycache_t * replay_cache
Definition: hs_service.h:78
origin_circuit_t::rend_data
rend_data_t * rend_data
Definition: origin_circuit_st.h:132
hs_cell_build_introduce1
ssize_t hs_cell_build_introduce1(const hs_cell_introduce1_data_t *data, uint8_t *cell_out)
Definition: hs_cell.c:1006
CIRCUIT_PURPOSE_S_INTRO
#define CIRCUIT_PURPOSE_S_INTRO
Definition: circuitlist.h:106
hs_client_circuit_cleanup_on_close
void hs_client_circuit_cleanup_on_close(const circuit_t *circ)
Definition: hs_client.c:1861
hs_ident_circuit_t::rendezvous_cookie
uint8_t rendezvous_cookie[HS_REND_COOKIE_LEN]
Definition: hs_ident.h:60
node_st.h
Node information structure.
hs_service_config_t::ports
smartlist_t * ports
Definition: hs_service.h:207
hs_ntor_rend_cell_keys_t
Definition: hs_ntor.h:30
hs_ob.h
Header file for the specific code for onion balance.
policies.h
Header file for policies.c.
hs_circuitmap_get_intro_circ_v3_service_side
origin_circuit_t * hs_circuitmap_get_intro_circ_v3_service_side(const ed25519_public_key_t *auth_key)
Definition: hs_circuitmap.c:375
hs_ntor.h
Header for hs_ntor.c.
hs_circuitmap.h
Header file for hs_circuitmap.c.
hs_ident_circuit_dup
hs_ident_circuit_t * hs_ident_circuit_dup(const hs_ident_circuit_t *src)
Definition: hs_ident.c:37
hs_ident_circuit_t::rendezvous_handshake_info
uint8_t rendezvous_handshake_info[CURVE25519_PUBKEY_LEN+DIGEST256_LEN]
Definition: hs_ident.h:68
config.h
Header file for config.c.
cpath_build_state_t
Definition: cpath_build_state_st.h:16
hs_service_intro_point_t::circuit_retries
uint32_t circuit_retries
Definition: hs_service.h:73
cpath_build_state_t::expiry_time
time_t expiry_time
Definition: cpath_build_state_st.h:41
hs_service_t::onion_address
char onion_address[HS_SERVICE_ADDR_LEN_BASE32+1]
Definition: hs_service.h:296
node_get_curve25519_onion_key
const curve25519_public_key_t * node_get_curve25519_onion_key(const node_t *node)
Definition: nodelist.c:1935
circuit_purpose_is_correct_for_rend
static int circuit_purpose_is_correct_for_rend(unsigned int circ_purpose, int is_service_side)
Definition: hs_circuit.c:51
build_state_get_exit_node
const node_t * build_state_get_exit_node(cpath_build_state_t *state)
Definition: circuitbuild.c:2469
retry_service_rendezvous_point
static void retry_service_rendezvous_point(const origin_circuit_t *circ)
Definition: hs_circuit.c:525
cleanup_on_close_client_circ
static void cleanup_on_close_client_circ(circuit_t *circ)
Definition: hs_circuit.c:628
create_rend_cpath
static crypt_path_t * create_rend_cpath(const uint8_t *ntor_key_seed, size_t seed_len, int is_service_side)
Definition: hs_circuit.c:81
origin_circuit_t::hs_ident
struct hs_ident_circuit_t * hs_ident
Definition: origin_circuit_st.h:136
TO_CIRCUIT
#define TO_CIRCUIT(x)
Definition: or.h:965
crypto_rand
void crypto_rand(char *to, size_t n)
Definition: crypto_rand.c:477
hs_circuitmap_register_intro_circ_v2_service_side
void hs_circuitmap_register_intro_circ_v2_service_side(origin_circuit_t *circ, const uint8_t *digest)
Definition: hs_circuitmap.c:521
tor_cert_t::signed_key
ed25519_public_key_t signed_key
Definition: torcert.h:30
hs_cell_introduce2_data_t::client_pk
curve25519_public_key_t client_pk
Definition: hs_cell.h:80
hs_service_descriptor_t::intro_points
hs_service_intropoints_t intro_points
Definition: hs_service.h:156
STATIC
#define STATIC
Definition: testsupport.h:32
hs_circ_handle_intro_established
int hs_circ_handle_intro_established(const hs_service_t *service, const hs_service_intro_point_t *ip, origin_circuit_t *circ, const uint8_t *payload, size_t payload_len)
Definition: hs_circuit.c:937
cpath_build_state_t::pending_final_cpath
crypt_path_t * pending_final_cpath
Definition: cpath_build_state_st.h:34
hs_ident_circuit_t::rendezvous_ntor_key_seed
uint8_t rendezvous_ntor_key_seed[DIGEST256_LEN]
Definition: hs_ident.h:76
hs_circ_is_rend_sent_in_intro1
bool hs_circ_is_rend_sent_in_intro1(const origin_circuit_t *circ)
Definition: hs_circuit.c:1370
hs_circuit.h
Header file containing circuit data for the whole HS subsytem.
hs_circ_cleanup_on_close
void hs_circ_cleanup_on_close(circuit_t *circ)
Definition: hs_circuit.c:1307
hs_ident_circuit_new
hs_ident_circuit_t * hs_ident_circuit_new(const ed25519_public_key_t *identity_pk)
Definition: hs_ident.c:16
hs_service_intro_point_t
Definition: hs_service.h:38
origin_circuit_st.h
Origin circuit structure.
hs_desc_intro_point_t
Definition: hs_descriptor.h:99
circuit_launch_by_extend_info
origin_circuit_t * circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *extend_info, int flags)
Definition: circuituse.c:2121
smartlist_t
Definition: smartlist_core.h:26
rendclient.h
Header file for rendclient.c.
circuit_t::state
uint8_t state
Definition: circuit_st.h:110
circuit_initial_package_window
int32_t circuit_initial_package_window(void)
Definition: circuitlist.c:977
hs_ident_circuit_t::intro_enc_pk
curve25519_public_key_t intro_enc_pk
Definition: hs_ident.h:55
rephist.h
Header file for rephist.c.
hs_circ_cleanup_on_repurpose
void hs_circ_cleanup_on_repurpose(circuit_t *circ)
Definition: hs_circuit.c:1348
hs_ident_circuit_t::rendezvous_client_kp
curve25519_keypair_t rendezvous_client_kp
Definition: hs_ident.h:72
curve25519_keypair_t
Definition: crypto_curve25519.h:38
extend_info_t
Definition: extend_info_st.h:27
hs_circuitmap_register_intro_circ_v3_service_side
void hs_circuitmap_register_intro_circ_v3_service_side(origin_circuit_t *circ, const ed25519_public_key_t *auth_key)
Definition: hs_circuitmap.c:532
or.h
Master header file for Tor-specific functionality.
LD_PROTOCOL
#define LD_PROTOCOL
Definition: log.h:72