hs_cell.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Copyright (c) 2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file hs_cell.h
  5. * \brief Header file containing cell data for the whole HS subsytem.
  6. **/
  7. #ifndef TOR_HS_CELL_H
  8. #define TOR_HS_CELL_H
  9. #include "or.h"
  10. #include "hs_service.h"
  11. /* Onion key type found in the INTRODUCE1 cell. */
  12. typedef enum {
  13. HS_CELL_ONION_KEY_TYPE_NTOR = 1,
  14. } hs_cell_onion_key_type_t;
  15. /* This data structure contains data that we need to parse an INTRODUCE2 cell
  16. * which is used by the INTRODUCE2 cell parsing function. On a successful
  17. * parsing, the onion_pk and rendezvous_cookie will be populated with the
  18. * computed key material from the cell data. This structure is only used during
  19. * INTRO2 parsing and discarded after that. */
  20. typedef struct hs_cell_introduce2_data_t {
  21. /*** Immutable Section: Set on structure init. ***/
  22. /* Introduction point authentication public key. Pointer owned by the
  23. introduction point object through which we received the INTRO2 cell. */
  24. const ed25519_public_key_t *auth_pk;
  25. /* Introduction point encryption keypair for the ntor handshake. Pointer
  26. owned by the introduction point object through which we received the
  27. INTRO2 cell*/
  28. const curve25519_keypair_t *enc_kp;
  29. /* Subcredentials of the service. Pointer owned by the descriptor that owns
  30. the introduction point through which we received the INTRO2 cell. */
  31. const uint8_t *subcredential;
  32. /* Payload of the received encoded cell. */
  33. const uint8_t *payload;
  34. /* Size of the payload of the received encoded cell. */
  35. size_t payload_len;
  36. /*** Mutable Section: Set upon parsing INTRODUCE2 cell. ***/
  37. /* Onion public key computed using the INTRODUCE2 encrypted section. */
  38. curve25519_public_key_t onion_pk;
  39. /* Rendezvous cookie taken from the INTRODUCE2 encrypted section. */
  40. uint8_t rendezvous_cookie[REND_COOKIE_LEN];
  41. /* Client public key from the INTRODUCE2 encrypted section. */
  42. curve25519_public_key_t client_pk;
  43. /* Link specifiers of the rendezvous point. Contains link_specifier_t. */
  44. smartlist_t *link_specifiers;
  45. /* Replay cache of the introduction point. */
  46. replaycache_t *replay_cache;
  47. } hs_cell_introduce2_data_t;
  48. /* Build cell API. */
  49. ssize_t hs_cell_build_establish_intro(const char *circ_nonce,
  50. const hs_service_intro_point_t *ip,
  51. uint8_t *cell_out);
  52. ssize_t hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie,
  53. size_t rendezvous_cookie_len,
  54. const uint8_t *rendezvous_handshake_info,
  55. size_t rendezvous_handshake_info_len,
  56. uint8_t *cell_out);
  57. /* Parse cell API. */
  58. ssize_t hs_cell_parse_intro_established(const uint8_t *payload,
  59. size_t payload_len);
  60. ssize_t hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data,
  61. const origin_circuit_t *circ,
  62. const hs_service_t *service);
  63. #endif /* TOR_HS_CELL_H */