tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

ext_orport.h (2878B)


      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 */
      6 
      7 /**
      8 * @file ext_orport.h
      9 * @brief Header for ext_orport.c
     10 **/
     11 
     12 #ifndef EXT_ORPORT_H
     13 #define EXT_ORPORT_H
     14 
     15 /** States of the Extended ORPort protocol. Be careful before changing
     16 *  the numbers: they matter. */
     17 #define EXT_OR_CONN_STATE_MIN_ 1
     18 /** Extended ORPort authentication is waiting for the authentication
     19 *  type selected by the client. */
     20 #define EXT_OR_CONN_STATE_AUTH_WAIT_AUTH_TYPE 1
     21 /** Extended ORPort authentication is waiting for the client nonce. */
     22 #define EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_NONCE 2
     23 /** Extended ORPort authentication is waiting for the client hash. */
     24 #define EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_HASH 3
     25 #define EXT_OR_CONN_STATE_AUTH_MAX 3
     26 /** Authentication finished and the Extended ORPort is now accepting
     27 *  traffic. */
     28 #define EXT_OR_CONN_STATE_OPEN 4
     29 /** Extended ORPort is flushing its last messages and preparing to
     30 *  start accepting OR connections. */
     31 #define EXT_OR_CONN_STATE_FLUSHING 5
     32 #define EXT_OR_CONN_STATE_MAX_ 5
     33 
     34 #ifdef HAVE_MODULE_RELAY
     35 
     36 int connection_ext_or_start_auth(or_connection_t *or_conn);
     37 
     38 int connection_ext_or_finished_flushing(or_connection_t *conn);
     39 int connection_ext_or_process_inbuf(or_connection_t *or_conn);
     40 char *get_ext_or_auth_cookie_file_name(void);
     41 
     42 /* (No stub needed for these: they are only called within feature/relay.) */
     43 int init_ext_or_cookie_authentication(int is_enabled);
     44 void ext_orport_free_all(void);
     45 
     46 #else /* !defined(HAVE_MODULE_RELAY) */
     47 
     48 static inline int
     49 connection_ext_or_start_auth(or_connection_t *conn)
     50 {
     51  (void)conn;
     52  tor_assert_nonfatal_unreached();
     53  return -1;
     54 }
     55 static inline int
     56 connection_ext_or_finished_flushing(or_connection_t *conn)
     57 {
     58  (void)conn;
     59  tor_assert_nonfatal_unreached();
     60  return -1;
     61 }
     62 static inline int
     63 connection_ext_or_process_inbuf(or_connection_t *conn)
     64 {
     65  (void)conn;
     66  tor_assert_nonfatal_unreached();
     67  return -1;
     68 }
     69 #define get_ext_or_auth_cookie_file_name() \
     70  (NULL)
     71 
     72 #endif /* defined(HAVE_MODULE_RELAY) */
     73 
     74 #ifdef EXT_ORPORT_PRIVATE
     75 STATIC int connection_write_ext_or_command(connection_t *conn,
     76                                           uint16_t command,
     77                                           const char *body,
     78                                           size_t bodylen);
     79 STATIC int handle_client_auth_nonce(const char *client_nonce,
     80                         size_t client_nonce_len,
     81                         char **client_hash_out,
     82                         char **reply_out, size_t *reply_len_out);
     83 
     84 #ifdef TOR_UNIT_TESTS
     85 extern uint8_t *ext_or_auth_cookie;
     86 extern int ext_or_auth_cookie_is_set;
     87 #endif
     88 #endif /* defined(EXT_ORPORT_PRIVATE) */
     89 
     90 #endif /* !defined(EXT_ORPORT_H) */