tor

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

process_descs.h (5633B)


      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 process_descs.h
      9 * \brief Header file for process_descs.c.
     10 **/
     11 
     12 #ifndef TOR_RECV_UPLOADS_H
     13 #define TOR_RECV_UPLOADS_H
     14 
     15 // for was_router_added_t.
     16 #include "feature/nodelist/routerlist.h"
     17 
     18 #include "lib/crypt_ops/crypto_ed25519.h"
     19 
     20 struct authdir_config_t;
     21 
     22 /** Target of status_by_digest map. */
     23 typedef uint32_t rtr_flags_t;
     24 
     25 int add_rsa_fingerprint_to_dir(const char *fp, struct authdir_config_t *list,
     26                               rtr_flags_t add_status);
     27 
     28 int add_ed25519_to_dir(const ed25519_public_key_t *edkey,
     29                       struct authdir_config_t *list,
     30                       rtr_flags_t add_status);
     31 
     32 /** List of nickname-\>identity fingerprint mappings for all the routers
     33 * that we name.  Used to prevent router impersonation. */
     34 typedef struct authdir_config_t {
     35  strmap_t *fp_by_name; /**< Map from lc nickname to fingerprint. */
     36  digestmap_t *status_by_digest; /**< Map from digest to router_status_t. */
     37  digest256map_t *status_by_digest256; /**< Map from digest256 to
     38                                        * router_status_t. */
     39 } authdir_config_t;
     40 
     41 #if defined(PROCESS_DESCS_PRIVATE) || defined(TOR_UNIT_TESTS)
     42 
     43 /*                 1  Historically used to indicate Named */
     44 #define RTR_INVALID 2  /**< Believed invalid. */
     45 #define RTR_REJECT  4  /**< We will not publish this router. */
     46 /*                 8  Historically used to avoid using this as a dir. */
     47 #define RTR_BADEXIT 16 /**< We'll tell clients not to use this as an exit. */
     48 /** We'll vote to only use this router as a midpoint. */
     49 #define RTR_MIDDLEONLY 32
     50 #define RTR_STRIPGUARD 64
     51 #define RTR_STRIPHSDIR 128
     52 #define RTR_STRIPV2DIR 256
     53 
     54 #endif /* defined(PROCESS_DESCS_PRIVATE) || defined(TOR_UNIT_TESTS) */
     55 
     56 #ifdef TOR_UNIT_TESTS
     57 
     58 void authdir_init_fingerprint_list(void);
     59 
     60 authdir_config_t *authdir_return_fingerprint_list(void);
     61 
     62 #endif /* defined(TOR_UNIT_TESTS) */
     63 
     64 void dirserv_free_fingerprint_list(void);
     65 
     66 #ifdef HAVE_MODULE_DIRAUTH
     67 int dirserv_load_fingerprint_file(void);
     68 enum was_router_added_t dirserv_add_multiple_descriptors(
     69                                     const char *desc, size_t desclen,
     70                                     uint8_t purpose,
     71                                     const char *source,
     72                                     const char **msg);
     73 enum was_router_added_t dirserv_add_descriptor(routerinfo_t *ri,
     74                                               const char **msg,
     75                                               const char *source);
     76 
     77 int dirserv_would_reject_router(const routerstatus_t *rs,
     78                                const vote_routerstatus_t *vrs);
     79 int authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
     80                                   int complain,
     81                                   int *valid_out);
     82 int dirserv_add_own_fingerprint(crypto_pk_t *pk,
     83                                const ed25519_public_key_t *edkey);
     84 uint32_t dirserv_router_get_status(const routerinfo_t *router,
     85                                   const char **msg,
     86                                   int severity);
     87 void dirserv_set_node_flags_from_authoritative_status(node_t *node,
     88                                                      uint32_t authstatus);
     89 #else /* !defined(HAVE_MODULE_DIRAUTH) */
     90 static inline int
     91 dirserv_load_fingerprint_file(void)
     92 {
     93  return 0;
     94 }
     95 static inline enum was_router_added_t
     96 dirserv_add_multiple_descriptors(const char *desc, size_t desclen,
     97                                 uint8_t purpose,
     98                                 const char *source,
     99                                 const char **msg)
    100 {
    101  (void)desc;
    102  (void)desclen;
    103  (void)purpose;
    104  (void)source;
    105  *msg = "No directory authority support";
    106  return (enum was_router_added_t)0;
    107 }
    108 static inline enum was_router_added_t
    109 dirserv_add_descriptor(routerinfo_t *ri,
    110                       const char **msg,
    111                       const char *source)
    112 {
    113  (void)ri;
    114  (void)source;
    115  *msg = "No directory authority support";
    116  return (enum was_router_added_t)0;
    117 }
    118 static inline int
    119 dirserv_would_reject_router(const routerstatus_t *rs,
    120                            const vote_routerstatus_t *vrs)
    121 {
    122  (void)rs;
    123  (void)vrs;
    124  return 0;
    125 }
    126 static inline int
    127 authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
    128                               int complain,
    129                               int *valid_out)
    130 {
    131  (void)ri;
    132  (void)complain;
    133  *msg = "No directory authority support";
    134  *valid_out = 0;
    135  return 0;
    136 }
    137 static inline int
    138 dirserv_add_own_fingerprint(crypto_pk_t *pk, const ed25519_public_key_t *edkey)
    139 {
    140  (void)pk;
    141  (void)edkey;
    142  return 0;
    143 }
    144 static inline uint32_t
    145 dirserv_router_get_status(const routerinfo_t *router,
    146                          const char **msg,
    147                          int severity)
    148 {
    149  (void)router;
    150  (void)severity;
    151  if (msg)
    152    *msg = "No directory authority support";
    153  return 0;
    154 }
    155 static inline void
    156 dirserv_set_node_flags_from_authoritative_status(node_t *node,
    157                                                 uint32_t authstatus)
    158 {
    159  (void)node;
    160  (void)authstatus;
    161 }
    162 #endif /* defined(HAVE_MODULE_DIRAUTH) */
    163 
    164 #ifdef TOR_UNIT_TESTS
    165 STATIC int dirserv_router_has_valid_address(routerinfo_t *ri);
    166 STATIC bool dirserv_rejects_tor_version(const char *platform,
    167                                        const char **msg);
    168 #endif /* defined(TOR_UNIT_TESTS) */
    169 
    170 #endif /* !defined(TOR_RECV_UPLOADS_H) */