crypt_path_st.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef CRYPT_PATH_ST_H
  7. #define CRYPT_PATH_ST_H
  8. #include "core/or/relay_crypto_st.h"
  9. struct crypto_dh_t;
  10. #define CRYPT_PATH_MAGIC 0x70127012u
  11. struct fast_handshake_state_t;
  12. struct ntor_handshake_state_t;
  13. struct crypto_dh_t;
  14. struct onion_handshake_state_t {
  15. uint16_t tag;
  16. union {
  17. struct fast_handshake_state_t *fast;
  18. struct crypto_dh_t *tap;
  19. struct ntor_handshake_state_t *ntor;
  20. } u;
  21. };
  22. /** Macro to encapsulate private members of a struct.
  23. *
  24. * Renames 'x' to 'x_crypt_path_private_field'.
  25. */
  26. #define CRYPT_PATH_PRIV_FIELD(x) x ## _crypt_path_private_field
  27. #ifdef CRYPT_PATH_PRIVATE
  28. /* Helper macro to access private members of a struct. */
  29. #define pvt_crypto CRYPT_PATH_PRIV_FIELD(crypto)
  30. #endif /* defined(CRYPT_PATH_PRIVATE) */
  31. /** Holds accounting information for a single step in the layered encryption
  32. * performed by a circuit. Used only at the client edge of a circuit. */
  33. struct crypt_path_t {
  34. uint32_t magic;
  35. /** Current state of the handshake as performed with the OR at this
  36. * step. */
  37. onion_handshake_state_t handshake_state;
  38. /** Diffie-hellman handshake state for performing an introduction
  39. * operations */
  40. struct crypto_dh_t *rend_dh_handshake_state;
  41. /** Negotiated key material shared with the OR at this step. */
  42. char rend_circ_nonce[DIGEST_LEN];/* KH in tor-spec.txt */
  43. /** Information to extend to the OR at this step. */
  44. extend_info_t *extend_info;
  45. /** Is the circuit built to this step? Must be one of:
  46. * - CPATH_STATE_CLOSED (The circuit has not been extended to this step)
  47. * - CPATH_STATE_AWAITING_KEYS (We have sent an EXTEND/CREATE to this step
  48. * and not received an EXTENDED/CREATED)
  49. * - CPATH_STATE_OPEN (The circuit has been extended to this step) */
  50. uint8_t state;
  51. #define CPATH_STATE_CLOSED 0
  52. #define CPATH_STATE_AWAITING_KEYS 1
  53. #define CPATH_STATE_OPEN 2
  54. struct crypt_path_t *next; /**< Link to next crypt_path_t in the circuit.
  55. * (The list is circular, so the last node
  56. * links to the first.) */
  57. struct crypt_path_t *prev; /**< Link to previous crypt_path_t in the
  58. * circuit. */
  59. int package_window; /**< How many cells are we allowed to originate ending
  60. * at this step? */
  61. int deliver_window; /**< How many cells are we willing to deliver originating
  62. * at this step? */
  63. /*********************** Private members ****************************/
  64. /** Private member: Cryptographic state used for encrypting and
  65. * authenticating relay cells to and from this hop. */
  66. relay_crypto_t CRYPT_PATH_PRIV_FIELD(crypto);
  67. };
  68. #endif /* !defined(CRYPT_PATH_ST_H) */