hs_cell.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. */
  19. typedef struct hs_cell_introduce2_data_t {
  20. /*** Immutable Section. ***/
  21. /* Introduction point authentication public key. */
  22. const ed25519_public_key_t *auth_pk;
  23. /* Introduction point encryption keypair for the ntor handshake. */
  24. const curve25519_keypair_t *enc_kp;
  25. /* Subcredentials of the service. */
  26. const uint8_t *subcredential;
  27. /* Payload of the received encoded cell. */
  28. const uint8_t *payload;
  29. /* Size of the payload of the received encoded cell. */
  30. size_t payload_len;
  31. /* Is this a legacy introduction point? */
  32. unsigned int is_legacy : 1;
  33. /*** Muttable Section. ***/
  34. /* Onion public key computed using the INTRODUCE2 encrypted section. */
  35. curve25519_public_key_t onion_pk;
  36. /* Rendezvous cookie taken from the INTRODUCE2 encrypted section. */
  37. uint8_t rendezvous_cookie[REND_COOKIE_LEN];
  38. /* Client public key from the INTRODUCE2 encrypted section. */
  39. curve25519_public_key_t client_pk;
  40. /* Link specifiers of the rendezvous point. Contains link_specifier_t. */
  41. smartlist_t *link_specifiers;
  42. /* Replay cache of the introduction point. */
  43. replaycache_t *replay_cache;
  44. } hs_cell_introduce2_data_t;
  45. /* Build cell API. */
  46. ssize_t hs_cell_build_establish_intro(const char *circ_nonce,
  47. const hs_service_intro_point_t *ip,
  48. uint8_t *cell_out);
  49. ssize_t hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie,
  50. size_t rendezvous_cookie_len,
  51. const uint8_t *rendezvous_handshake_info,
  52. size_t rendezvous_handshake_info_len,
  53. uint8_t *cell_out);
  54. /* Parse cell API. */
  55. ssize_t hs_cell_parse_intro_established(const uint8_t *payload,
  56. size_t payload_len);
  57. ssize_t hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data,
  58. const origin_circuit_t *circ,
  59. const hs_service_t *service);
  60. #endif /* TOR_HS_CELL_H */