hs_cell.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. } hs_cell_introduce2_data_t;
  43. /* Build cell API. */
  44. ssize_t hs_cell_build_establish_intro(const char *circ_nonce,
  45. const hs_service_intro_point_t *ip,
  46. uint8_t *cell_out);
  47. ssize_t hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie,
  48. size_t rendezvous_cookie_len,
  49. const uint8_t *rendezvous_handshake_info,
  50. size_t rendezvous_handshake_info_len,
  51. uint8_t *cell_out);
  52. /* Parse cell API. */
  53. ssize_t hs_cell_parse_intro_established(const uint8_t *payload,
  54. size_t payload_len);
  55. ssize_t hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data,
  56. const origin_circuit_t *circ,
  57. const hs_service_t *service);
  58. #endif /* TOR_HS_CELL_H */