Update copyrights to 2021, using "make update-copyright"
[tor.git] / src / core / or / crypt_path_st.h
blob2529b6ee416eb08f61439ab780394a7935660442
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-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * @file crypt_path_st.h
9 * @brief Path structures for origin circuits.
10 **/
12 #ifndef CRYPT_PATH_ST_H
13 #define CRYPT_PATH_ST_H
15 #include "core/or/relay_crypto_st.h"
16 struct crypto_dh_t;
18 #define CRYPT_PATH_MAGIC 0x70127012u
20 struct fast_handshake_state_t;
21 struct ntor_handshake_state_t;
22 struct crypto_dh_t;
23 struct onion_handshake_state_t {
24 uint16_t tag;
25 union {
26 struct fast_handshake_state_t *fast;
27 struct crypto_dh_t *tap;
28 struct ntor_handshake_state_t *ntor;
29 } u;
32 /** Macro to encapsulate private members of a struct.
34 * Renames 'x' to 'x_crypt_path_private_field'.
36 #define CRYPT_PATH_PRIV_FIELD(x) x ## _crypt_path_private_field
38 #ifdef CRYPT_PATH_PRIVATE
40 /* Helper macro to access private members of a struct. */
41 #define pvt_crypto CRYPT_PATH_PRIV_FIELD(crypto)
43 #endif /* defined(CRYPT_PATH_PRIVATE) */
45 /** Holds accounting information for a single step in the layered encryption
46 * performed by a circuit. Used only at the client edge of a circuit. */
47 struct crypt_path_t {
48 uint32_t magic;
50 /** Current state of the handshake as performed with the OR at this
51 * step. */
52 onion_handshake_state_t handshake_state;
53 /** Diffie-hellman handshake state for performing an introduction
54 * operations */
55 struct crypto_dh_t *rend_dh_handshake_state;
57 /** Negotiated key material shared with the OR at this step. */
58 char rend_circ_nonce[DIGEST_LEN];/* KH in tor-spec.txt */
60 /** Information to extend to the OR at this step. */
61 extend_info_t *extend_info;
63 /** Is the circuit built to this step? Must be one of:
64 * - CPATH_STATE_CLOSED (The circuit has not been extended to this step)
65 * - CPATH_STATE_AWAITING_KEYS (We have sent an EXTEND/CREATE to this step
66 * and not received an EXTENDED/CREATED)
67 * - CPATH_STATE_OPEN (The circuit has been extended to this step) */
68 uint8_t state;
69 #define CPATH_STATE_CLOSED 0
70 #define CPATH_STATE_AWAITING_KEYS 1
71 #define CPATH_STATE_OPEN 2
72 struct crypt_path_t *next; /**< Link to next crypt_path_t in the circuit.
73 * (The list is circular, so the last node
74 * links to the first.) */
75 struct crypt_path_t *prev; /**< Link to previous crypt_path_t in the
76 * circuit. */
78 int package_window; /**< How many cells are we allowed to originate ending
79 * at this step? */
80 int deliver_window; /**< How many cells are we willing to deliver originating
81 * at this step? */
83 /*********************** Private members ****************************/
85 /** Private member: Cryptographic state used for encrypting and
86 * authenticating relay cells to and from this hop. */
87 relay_crypto_t CRYPT_PATH_PRIV_FIELD(crypto);
90 #endif /* !defined(CRYPT_PATH_ST_H) */