tor  0.4.2.0-alpha-dev
hs_intropoint.c
Go to the documentation of this file.
1 /* Copyright (c) 2016-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
9 #define HS_INTROPOINT_PRIVATE
10 
11 #include "core/or/or.h"
12 #include "app/config/config.h"
13 #include "core/or/circuitlist.h"
14 #include "core/or/circuituse.h"
15 #include "core/or/relay.h"
16 #include "feature/rend/rendmid.h"
17 #include "feature/stats/rephist.h"
19 
20 /* Trunnel */
21 #include "trunnel/ed25519_cert.h"
22 #include "trunnel/hs/cell_common.h"
23 #include "trunnel/hs/cell_establish_intro.h"
24 #include "trunnel/hs/cell_introduce1.h"
25 
29 #include "feature/hs/hs_common.h"
30 
31 #include "core/or/or_circuit_st.h"
32 
36 STATIC void
38  unsigned int cell_type, const void *cell)
39 {
40  size_t auth_key_len;
41  const uint8_t *key_array;
42 
43  tor_assert(auth_key_out);
44  tor_assert(cell);
45 
46  switch (cell_type) {
47  case RELAY_COMMAND_ESTABLISH_INTRO:
48  {
49  const trn_cell_establish_intro_t *c_cell = cell;
50  key_array = trn_cell_establish_intro_getconstarray_auth_key(c_cell);
51  auth_key_len = trn_cell_establish_intro_getlen_auth_key(c_cell);
52  break;
53  }
54  case RELAY_COMMAND_INTRODUCE1:
55  {
56  const trn_cell_introduce1_t *c_cell = cell;
57  key_array = trn_cell_introduce1_getconstarray_auth_key(cell);
58  auth_key_len = trn_cell_introduce1_getlen_auth_key(c_cell);
59  break;
60  }
61  default:
62  /* Getting here is really bad as it means we got a unknown cell type from
63  * this file where every call has an hardcoded value. */
64  tor_assert_unreached(); /* LCOV_EXCL_LINE */
65  }
66  tor_assert(key_array);
67  tor_assert(auth_key_len == sizeof(auth_key_out->pubkey));
68  memcpy(auth_key_out->pubkey, key_array, auth_key_len);
69 }
70 
73 STATIC int
74 verify_establish_intro_cell(const trn_cell_establish_intro_t *cell,
75  const uint8_t *circuit_key_material,
76  size_t circuit_key_material_len)
77 {
78  /* We only reach this function if the first byte of the cell is 0x02 which
79  * means that auth_key_type is of ed25519 type, hence this check should
80  * always pass. See hs_intro_received_establish_intro(). */
81  if (BUG(cell->auth_key_type != TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519)) {
82  return -1;
83  }
84 
85  /* Make sure the auth key length is of the right size for this type. For
86  * EXTRA safety, we check both the size of the array and the length which
87  * must be the same. Safety first!*/
88  if (trn_cell_establish_intro_getlen_auth_key(cell) != ED25519_PUBKEY_LEN ||
89  trn_cell_establish_intro_get_auth_key_len(cell) != ED25519_PUBKEY_LEN) {
90  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
91  "ESTABLISH_INTRO auth key length is invalid");
92  return -1;
93  }
94 
95  const uint8_t *msg = cell->start_cell;
96 
97  /* Verify the sig */
98  {
99  ed25519_signature_t sig_struct;
100  const uint8_t *sig_array =
101  trn_cell_establish_intro_getconstarray_sig(cell);
102 
103  /* Make sure the signature length is of the right size. For EXTRA safety,
104  * we check both the size of the array and the length which must be the
105  * same. Safety first!*/
106  if (trn_cell_establish_intro_getlen_sig(cell) != sizeof(sig_struct.sig) ||
107  trn_cell_establish_intro_get_sig_len(cell) != sizeof(sig_struct.sig)) {
108  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
109  "ESTABLISH_INTRO sig len is invalid");
110  return -1;
111  }
112  /* We are now sure that sig_len is of the right size. */
113  memcpy(sig_struct.sig, sig_array, cell->sig_len);
114 
115  ed25519_public_key_t auth_key;
116  get_auth_key_from_cell(&auth_key, RELAY_COMMAND_ESTABLISH_INTRO, cell);
117 
118  const size_t sig_msg_len = cell->end_sig_fields - msg;
119  int sig_mismatch = ed25519_checksig_prefixed(&sig_struct,
120  msg, sig_msg_len,
121  ESTABLISH_INTRO_SIG_PREFIX,
122  &auth_key);
123  if (sig_mismatch) {
124  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
125  "ESTABLISH_INTRO signature not as expected");
126  return -1;
127  }
128  }
129 
130  /* Verify the MAC */
131  {
132  const size_t auth_msg_len = cell->end_mac_fields - msg;
133  uint8_t mac[DIGEST256_LEN];
134  crypto_mac_sha3_256(mac, sizeof(mac),
135  circuit_key_material, circuit_key_material_len,
136  msg, auth_msg_len);
137  if (tor_memneq(mac, cell->handshake_mac, sizeof(mac))) {
138  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
139  "ESTABLISH_INTRO handshake_auth not as expected");
140  return -1;
141  }
142  }
143 
144  return 0;
145 }
146 
147 /* Send an INTRO_ESTABLISHED cell to <b>circ</b>. */
148 MOCK_IMPL(int,
149 hs_intro_send_intro_established_cell,(or_circuit_t *circ))
150 {
151  int ret;
152  uint8_t *encoded_cell = NULL;
153  ssize_t encoded_len, result_len;
154  trn_cell_intro_established_t *cell;
155  trn_cell_extension_t *ext;
156 
157  tor_assert(circ);
158 
159  /* Build the cell payload. */
160  cell = trn_cell_intro_established_new();
161  ext = trn_cell_extension_new();
162  trn_cell_extension_set_num(ext, 0);
163  trn_cell_intro_established_set_extensions(cell, ext);
164  /* Encode the cell to binary format. */
165  encoded_len = trn_cell_intro_established_encoded_len(cell);
166  tor_assert(encoded_len > 0);
167  encoded_cell = tor_malloc_zero(encoded_len);
168  result_len = trn_cell_intro_established_encode(encoded_cell, encoded_len,
169  cell);
170  tor_assert(encoded_len == result_len);
171 
172  ret = relay_send_command_from_edge(0, TO_CIRCUIT(circ),
173  RELAY_COMMAND_INTRO_ESTABLISHED,
174  (char *) encoded_cell, encoded_len,
175  NULL);
176  /* On failure, the above function will close the circuit. */
177  trn_cell_intro_established_free(cell);
178  tor_free(encoded_cell);
179  return ret;
180 }
181 
185 static int
187  const trn_cell_establish_intro_t *parsed_cell)
188 {
189  /* Get the auth key of this intro point */
190  ed25519_public_key_t auth_key;
191  get_auth_key_from_cell(&auth_key, RELAY_COMMAND_ESTABLISH_INTRO,
192  parsed_cell);
193 
194  /* Then notify the hidden service that the intro point is established by
195  sending an INTRO_ESTABLISHED cell */
196  if (hs_intro_send_intro_established_cell(circ)) {
197  log_warn(LD_PROTOCOL, "Couldn't send INTRO_ESTABLISHED cell.");
198  return -1;
199  }
200 
201  /* Associate intro point auth key with this circuit. */
202  hs_circuitmap_register_intro_circ_v3_relay_side(circ, &auth_key);
203  /* Repurpose this circuit into an intro circuit. */
205 
206  return 0;
207 }
208 
212 static int
213 handle_establish_intro(or_circuit_t *circ, const uint8_t *request,
214  size_t request_len)
215 {
216  int cell_ok, retval = -1;
217  trn_cell_establish_intro_t *parsed_cell = NULL;
218 
219  tor_assert(circ);
220  tor_assert(request);
221 
222  log_info(LD_REND, "Received an ESTABLISH_INTRO request on circuit %" PRIu32,
223  circ->p_circ_id);
224 
225  /* Check that the circuit is in shape to become an intro point */
226  if (!hs_intro_circuit_is_suitable_for_establish_intro(circ)) {
227  goto err;
228  }
229 
230  /* Parse the cell */
231  ssize_t parsing_result = trn_cell_establish_intro_parse(&parsed_cell,
232  request, request_len);
233  if (parsing_result < 0) {
234  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
235  "Rejecting %s ESTABLISH_INTRO cell.",
236  parsing_result == -1 ? "invalid" : "truncated");
237  goto err;
238  }
239 
240  cell_ok = verify_establish_intro_cell(parsed_cell,
241  (uint8_t *) circ->rend_circ_nonce,
242  sizeof(circ->rend_circ_nonce));
243  if (cell_ok < 0) {
244  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
245  "Failed to verify ESTABLISH_INTRO cell.");
246  goto err;
247  }
248 
249  /* This cell is legit. Take the appropriate actions. */
250  cell_ok = handle_verified_establish_intro_cell(circ, parsed_cell);
251  if (cell_ok < 0) {
252  goto err;
253  }
254 
255  /* We are done! */
256  retval = 0;
257  goto done;
258 
259  err:
260  /* When sending the intro establish ack, on error the circuit can be marked
261  * as closed so avoid a double close. */
262  if (!TO_CIRCUIT(circ)->marked_for_close) {
263  circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_TORPROTOCOL);
264  }
265 
266  done:
267  trn_cell_establish_intro_free(parsed_cell);
268  return retval;
269 }
270 
271 /* Return True if circuit is suitable for being an intro circuit. */
272 static int
273 circuit_is_suitable_intro_point(const or_circuit_t *circ,
274  const char *log_cell_type_str)
275 {
276  tor_assert(circ);
277  tor_assert(log_cell_type_str);
278 
279  /* Basic circuit state sanity checks. */
280  if (circ->base_.purpose != CIRCUIT_PURPOSE_OR) {
281  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
282  "Rejecting %s on non-OR circuit.", log_cell_type_str);
283  return 0;
284  }
285 
286  if (circ->base_.n_chan) {
287  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
288  "Rejecting %s on non-edge circuit.", log_cell_type_str);
289  return 0;
290  }
291 
292  /* Suitable. */
293  return 1;
294 }
295 
296 /* Return True if circuit is suitable for being service-side intro circuit. */
297 int
298 hs_intro_circuit_is_suitable_for_establish_intro(const or_circuit_t *circ)
299 {
300  return circuit_is_suitable_intro_point(circ, "ESTABLISH_INTRO");
301 }
302 
303 /* We just received an ESTABLISH_INTRO cell in <b>circ</b>. Figure out of it's
304  * a legacy or a next gen cell, and pass it to the appropriate handler. */
305 int
306 hs_intro_received_establish_intro(or_circuit_t *circ, const uint8_t *request,
307  size_t request_len)
308 {
309  tor_assert(circ);
310  tor_assert(request);
311 
312  if (request_len == 0) {
313  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL, "Empty ESTABLISH_INTRO cell.");
314  goto err;
315  }
316 
317  /* Using the first byte of the cell, figure out the version of
318  * ESTABLISH_INTRO and pass it to the appropriate cell handler */
319  const uint8_t first_byte = request[0];
320  switch (first_byte) {
321  case TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_LEGACY0:
322  case TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_LEGACY1:
323  return rend_mid_establish_intro_legacy(circ, request, request_len);
324  case TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519:
325  return handle_establish_intro(circ, request, request_len);
326  default:
327  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
328  "Unrecognized AUTH_KEY_TYPE %u.", first_byte);
329  goto err;
330  }
331 
332  err:
333  circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_TORPROTOCOL);
334  return -1;
335 }
336 
337 /* Send an INTRODUCE_ACK cell onto the circuit <b>circ</b> with the status
338  * value in <b>status</b>. Depending on the status, it can be ACK or a NACK.
339  * Return 0 on success else a negative value on error which will close the
340  * circuit. */
341 static int
342 send_introduce_ack_cell(or_circuit_t *circ, uint16_t status)
343 {
344  int ret = -1;
345  uint8_t *encoded_cell = NULL;
346  ssize_t encoded_len, result_len;
347  trn_cell_introduce_ack_t *cell;
348  trn_cell_extension_t *ext;
349 
350  tor_assert(circ);
351 
352  /* Setup the INTRODUCE_ACK cell. We have no extensions so the N_EXTENSIONS
353  * field is set to 0 by default with a new object. */
354  cell = trn_cell_introduce_ack_new();
355  ret = trn_cell_introduce_ack_set_status(cell, status);
356  /* We have no cell extensions in an INTRODUCE_ACK cell. */
357  ext = trn_cell_extension_new();
358  trn_cell_extension_set_num(ext, 0);
359  trn_cell_introduce_ack_set_extensions(cell, ext);
360  /* A wrong status is a very bad code flow error as this value is controlled
361  * by the code in this file and not an external input. This means we use a
362  * code that is not known by the trunnel ABI. */
363  tor_assert(ret == 0);
364  /* Encode the payload. We should never fail to get the encoded length. */
365  encoded_len = trn_cell_introduce_ack_encoded_len(cell);
366  tor_assert(encoded_len > 0);
367  encoded_cell = tor_malloc_zero(encoded_len);
368  result_len = trn_cell_introduce_ack_encode(encoded_cell, encoded_len, cell);
369  tor_assert(encoded_len == result_len);
370 
371  ret = relay_send_command_from_edge(CONTROL_CELL_ID, TO_CIRCUIT(circ),
372  RELAY_COMMAND_INTRODUCE_ACK,
373  (char *) encoded_cell, encoded_len,
374  NULL);
375  /* On failure, the above function will close the circuit. */
376  trn_cell_introduce_ack_free(cell);
377  tor_free(encoded_cell);
378  return ret;
379 }
380 
381 /* Validate a parsed INTRODUCE1 <b>cell</b>. Return 0 if valid or else a
382  * negative value for an invalid cell that should be NACKed. */
383 STATIC int
384 validate_introduce1_parsed_cell(const trn_cell_introduce1_t *cell)
385 {
386  size_t legacy_key_id_len;
387  const uint8_t *legacy_key_id;
388 
389  tor_assert(cell);
390 
391  /* This code path SHOULD NEVER be reached if the cell is a legacy type so
392  * safety net here. The legacy ID must be zeroes in this case. */
393  legacy_key_id_len = trn_cell_introduce1_getlen_legacy_key_id(cell);
394  legacy_key_id = trn_cell_introduce1_getconstarray_legacy_key_id(cell);
395  if (BUG(!fast_mem_is_zero((char *) legacy_key_id, legacy_key_id_len))) {
396  goto invalid;
397  }
398 
399  /* The auth key of an INTRODUCE1 should be of type ed25519 thus leading to a
400  * known fixed length as well. */
401  if (trn_cell_introduce1_get_auth_key_type(cell) !=
402  TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519) {
403  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
404  "Rejecting invalid INTRODUCE1 cell auth key type. "
405  "Responding with NACK.");
406  goto invalid;
407  }
408  if (trn_cell_introduce1_get_auth_key_len(cell) != ED25519_PUBKEY_LEN ||
409  trn_cell_introduce1_getlen_auth_key(cell) != ED25519_PUBKEY_LEN) {
410  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
411  "Rejecting invalid INTRODUCE1 cell auth key length. "
412  "Responding with NACK.");
413  goto invalid;
414  }
415  if (trn_cell_introduce1_getlen_encrypted(cell) == 0) {
416  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
417  "Rejecting invalid INTRODUCE1 cell encrypted length. "
418  "Responding with NACK.");
419  goto invalid;
420  }
421 
422  return 0;
423  invalid:
424  return -1;
425 }
426 
427 /* We just received a non legacy INTRODUCE1 cell on <b>client_circ</b> with
428  * the payload in <b>request</b> of size <b>request_len</b>. Return 0 if
429  * everything went well, or -1 if an error occurred. This function is in charge
430  * of sending back an INTRODUCE_ACK cell and will close client_circ on error.
431  */
432 STATIC int
433 handle_introduce1(or_circuit_t *client_circ, const uint8_t *request,
434  size_t request_len)
435 {
436  int ret = -1;
437  or_circuit_t *service_circ;
438  trn_cell_introduce1_t *parsed_cell;
439  uint16_t status = TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS;
440 
441  tor_assert(client_circ);
442  tor_assert(request);
443 
444  /* Parse cell. Note that we can only parse the non encrypted section for
445  * which we'll use the authentication key to find the service introduction
446  * circuit and relay the cell on it. */
447  ssize_t cell_size = trn_cell_introduce1_parse(&parsed_cell, request,
448  request_len);
449  if (cell_size < 0) {
450  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
451  "Rejecting %s INTRODUCE1 cell. Responding with NACK.",
452  cell_size == -1 ? "invalid" : "truncated");
453  /* Inform client that the INTRODUCE1 has a bad format. */
454  status = TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT;
455  goto send_ack;
456  }
457 
458  /* Once parsed validate the cell format. */
459  if (validate_introduce1_parsed_cell(parsed_cell) < 0) {
460  /* Inform client that the INTRODUCE1 has bad format. */
461  status = TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT;
462  goto send_ack;
463  }
464 
465  /* Find introduction circuit through our circuit map. */
466  {
467  ed25519_public_key_t auth_key;
468  get_auth_key_from_cell(&auth_key, RELAY_COMMAND_INTRODUCE1, parsed_cell);
469  service_circ = hs_circuitmap_get_intro_circ_v3_relay_side(&auth_key);
470  if (service_circ == NULL) {
471  char b64_key[ED25519_BASE64_LEN + 1];
472  ed25519_public_to_base64(b64_key, &auth_key);
473  log_info(LD_REND, "No intro circuit found for INTRODUCE1 cell "
474  "with auth key %s from circuit %" PRIu32 ". "
475  "Responding with NACK.",
476  safe_str(b64_key), client_circ->p_circ_id);
477  /* Inform the client that we don't know the requested service ID. */
478  status = TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID;
479  goto send_ack;
480  }
481  }
482 
483  /* Relay the cell to the service on its intro circuit with an INTRODUCE2
484  * cell which is the same exact payload. */
485  if (relay_send_command_from_edge(CONTROL_CELL_ID, TO_CIRCUIT(service_circ),
486  RELAY_COMMAND_INTRODUCE2,
487  (char *) request, request_len, NULL)) {
488  log_warn(LD_PROTOCOL, "Unable to send INTRODUCE2 cell to the service.");
489  /* Inform the client that we can't relay the cell. Use the unknown ID
490  * status code since it means that we do not know the service. */
491  status = TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID;
492  goto send_ack;
493  }
494 
495  /* Success! Send an INTRODUCE_ACK success status onto the client circuit. */
496  status = TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS;
497  ret = 0;
498 
499  send_ack:
500  /* Send INTRODUCE_ACK or INTRODUCE_NACK to client */
501  if (send_introduce_ack_cell(client_circ, status) < 0) {
502  log_warn(LD_PROTOCOL, "Unable to send an INTRODUCE ACK status %d "
503  "to client.", status);
504  /* Circuit has been closed on failure of transmission. */
505  goto done;
506  }
507  done:
508  trn_cell_introduce1_free(parsed_cell);
509  return ret;
510 }
511 
512 /* Identify if the encoded cell we just received is a legacy one or not. The
513  * <b>request</b> should be at least DIGEST_LEN bytes long. */
514 STATIC int
515 introduce1_cell_is_legacy(const uint8_t *request)
516 {
517  tor_assert(request);
518 
519  /* If the first 20 bytes of the cell (DIGEST_LEN) are NOT zeroes, it
520  * indicates a legacy cell (v2). */
521  if (!fast_mem_is_zero((const char *) request, DIGEST_LEN)) {
522  /* Legacy cell. */
523  return 1;
524  }
525  /* Not a legacy cell. */
526  return 0;
527 }
528 
529 /* Return true iff the circuit <b>circ</b> is suitable for receiving an
530  * INTRODUCE1 cell. */
531 STATIC int
532 circuit_is_suitable_for_introduce1(const or_circuit_t *circ)
533 {
534  tor_assert(circ);
535 
536  /* Is this circuit an intro point circuit? */
537  if (!circuit_is_suitable_intro_point(circ, "INTRODUCE1")) {
538  return 0;
539  }
540 
541  if (circ->already_received_introduce1) {
542  log_fn(LOG_PROTOCOL_WARN, LD_REND,
543  "Blocking multiple introductions on the same circuit. "
544  "Someone might be trying to attack a hidden service through "
545  "this relay.");
546  return 0;
547  }
548 
549  return 1;
550 }
551 
552 /* We just received an INTRODUCE1 cell on <b>circ</b>. Figure out which type
553  * it is and pass it to the appropriate handler. Return 0 on success else a
554  * negative value and the circuit is closed. */
555 int
556 hs_intro_received_introduce1(or_circuit_t *circ, const uint8_t *request,
557  size_t request_len)
558 {
559  int ret;
560 
561  tor_assert(circ);
562  tor_assert(request);
563 
564  /* A cell that can't hold a DIGEST_LEN is invalid as we need to check if
565  * it's a legacy cell or not using the first DIGEST_LEN bytes. */
566  if (request_len < DIGEST_LEN) {
567  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL, "Invalid INTRODUCE1 cell length.");
568  goto err;
569  }
570 
571  /* Make sure we have a circuit that can have an INTRODUCE1 cell on it. */
572  if (!circuit_is_suitable_for_introduce1(circ)) {
573  /* We do not send a NACK because the circuit is not suitable for any kind
574  * of response or transmission as it's a violation of the protocol. */
575  goto err;
576  }
577  /* Mark the circuit that we got this cell. None are allowed after this as a
578  * DoS mitigation since one circuit with one client can hammer a service. */
579  circ->already_received_introduce1 = 1;
580 
581  /* We are sure here to have at least DIGEST_LEN bytes. */
582  if (introduce1_cell_is_legacy(request)) {
583  /* Handle a legacy cell. */
584  ret = rend_mid_introduce_legacy(circ, request, request_len);
585  } else {
586  /* Handle a non legacy cell. */
587  ret = handle_introduce1(circ, request, request_len);
588  }
589  return ret;
590 
591  err:
592  circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_TORPROTOCOL);
593  return -1;
594 }
595 
596 /* Clear memory allocated by the given intropoint object ip (but don't free the
597  * object itself). */
598 void
599 hs_intropoint_clear(hs_intropoint_t *ip)
600 {
601  if (ip == NULL) {
602  return;
603  }
604  tor_cert_free(ip->auth_key_cert);
605  SMARTLIST_FOREACH(ip->link_specifiers, link_specifier_t *, ls,
606  link_specifier_free(ls));
607  smartlist_free(ip->link_specifiers);
608  memset(ip, 0, sizeof(hs_intropoint_t));
609 }
int ed25519_checksig_prefixed(const ed25519_signature_t *signature, const uint8_t *msg, size_t msg_len, const char *prefix_str, const ed25519_public_key_t *pubkey)
Header file containing common data for the whole HS subsytem.
int rend_mid_introduce_legacy(or_circuit_t *circ, const uint8_t *request, size_t request_len)
Definition: rendmid.c:140
#define TO_CIRCUIT(x)
Definition: or.h:947
Header file for config.c.
int fast_mem_is_zero(const char *mem, size_t len)
Definition: util_string.c:74
STATIC void get_auth_key_from_cell(ed25519_public_key_t *auth_key_out, unsigned int cell_type, const void *cell)
Definition: hs_intropoint.c:37
void ed25519_public_to_base64(char *output, const ed25519_public_key_t *pkey)
#define tor_free(p)
Definition: malloc.h:52
static int handle_verified_establish_intro_cell(or_circuit_t *circ, const trn_cell_establish_intro_t *parsed_cell)
uint8_t purpose
Definition: circuit_st.h:100
char rend_circ_nonce[DIGEST_LEN]
Definition: or_circuit_st.h:51
Header file for rendmid.c.
#define DIGEST256_LEN
Definition: digest_sizes.h:23
tor_assert(buffer)
static int handle_establish_intro(or_circuit_t *circ, const uint8_t *request, size_t request_len)
Header for crypto_format.c.
#define DIGEST_LEN
Definition: digest_sizes.h:20
Master header file for Tor-specific functionality.
Header file for rephist.c.
Header file for circuituse.c.
Header file for hs_descriptor.c.
Header file for hs_intropoint.c.
circid_t p_circ_id
Definition: or_circuit_st.h:31
Header file for hs_circuitmap.c.
#define LD_REND
Definition: log.h:81
Header file for circuitlist.c.
or_circuit_t * hs_circuitmap_get_intro_circ_v3_relay_side(const ed25519_public_key_t *auth_key)
#define CIRCUIT_PURPOSE_INTRO_POINT
Definition: circuitlist.h:41
Header file for relay.c.
#define SMARTLIST_FOREACH(sl, type, var, cmd)
#define CIRCUIT_PURPOSE_OR
Definition: circuitlist.h:38
#define log_fn(severity, domain, args,...)
Definition: log.h:272
int rend_mid_establish_intro_legacy(or_circuit_t *circ, const uint8_t *request, size_t request_len)
Definition: rendmid.c:29
void crypto_mac_sha3_256(uint8_t *mac_out, size_t len_out, const uint8_t *key, size_t key_len, const uint8_t *msg, size_t msg_len)
void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose)
Definition: circuituse.c:3062
STATIC int verify_establish_intro_cell(const trn_cell_establish_intro_t *cell, const uint8_t *circuit_key_material, size_t circuit_key_material_len)
Definition: hs_intropoint.c:74
#define LD_PROTOCOL
Definition: log.h:69
channel_t * n_chan
Definition: circuit_st.h:58