|  | @@ -9,6 +9,85 @@
 | 
	
		
			
				|  |  |   * \brief Code to
 | 
	
		
			
				|  |  |   * maintain and access the global list of routerinfos for known
 | 
	
		
			
				|  |  |   * servers.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * A "routerinfo_t" object represents a single self-signed router
 | 
	
		
			
				|  |  | + * descriptor, as generated by a Tor relay in order to tell the rest of
 | 
	
		
			
				|  |  | + * the world about its keys, address, and capabilities.  An
 | 
	
		
			
				|  |  | + * "extrainfo_t" object represents an adjunct "extra-info" object,
 | 
	
		
			
				|  |  | + * certified by a corresponding router descriptor, reporting more
 | 
	
		
			
				|  |  | + * information about the relay that nearly all users will not need.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Most users will not use router descriptors for most relays.  Instead,
 | 
	
		
			
				|  |  | + * they use the information in microdescriptors and in the consensus
 | 
	
		
			
				|  |  | + * networkstatus.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Right now, routerinfo_t objects are used in these ways:
 | 
	
		
			
				|  |  | + *  <ul>
 | 
	
		
			
				|  |  | + *   <li>By clients, in order to learn about bridge keys and capabilities.
 | 
	
		
			
				|  |  | + *     (Bridges aren't listed in the consensus networkstatus, so they
 | 
	
		
			
				|  |  | + *     can't have microdescriptors.)
 | 
	
		
			
				|  |  | + *   <li>By relays, since relays want more information about other relays
 | 
	
		
			
				|  |  | + *     than they can learn from microdescriptors. (TODO: Is this still true?)
 | 
	
		
			
				|  |  | + *   <li>By authorities, which receive them and use them to generate the
 | 
	
		
			
				|  |  | + *     consensus and the microdescriptors.
 | 
	
		
			
				|  |  | + *   <li>By all directory caches, which download them in case somebody
 | 
	
		
			
				|  |  | + *     else wants them.
 | 
	
		
			
				|  |  | + *  </ul>
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Routerinfos are mostly created by parsing them from a string, in
 | 
	
		
			
				|  |  | + * routerparse.c. We store them to disk on receiving them, and
 | 
	
		
			
				|  |  | + * periodically discard the ones we don't need. On restarting, we
 | 
	
		
			
				|  |  | + * re-read them from disk. (This also applies to extrainfo documents, if
 | 
	
		
			
				|  |  | + * we are configured to fetch them.)
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * In order to keep our list of routerinfos up-to-date, we periodically
 | 
	
		
			
				|  |  | + * check whether there are any listed in the latest consensus (or in the
 | 
	
		
			
				|  |  | + * votes from other authorities, if we are an authority) that we don't
 | 
	
		
			
				|  |  | + * have.  (This also applies to extrainfo documents, if we are
 | 
	
		
			
				|  |  | + * configured to fetch them.)
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Almost nothing in Tor should use a routerinfo_t to refer directly to
 | 
	
		
			
				|  |  | + * a relay; instead, almost everything should use node_t (implemented in
 | 
	
		
			
				|  |  | + * nodelist.c), which provides a common interface to routerinfo_t,
 | 
	
		
			
				|  |  | + * routerstatus_t, and microdescriptor_t.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * <br>
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * This module also has some of the functions used for choosing random
 | 
	
		
			
				|  |  | + * nodes according to different rules and weights.  Historically, they
 | 
	
		
			
				|  |  | + * were all in this module.  Now, they are spread across this module,
 | 
	
		
			
				|  |  | + * nodelist.c, and networkstatus.c.  (TODO: Fix that.)
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * <br>
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * (For historical reasons) this module also contains code for handling
 | 
	
		
			
				|  |  | + * the list of fallback directories, the list of directory authorities,
 | 
	
		
			
				|  |  | + * and the list of authority certificates.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * For the directory authorities, we have a list containing the public
 | 
	
		
			
				|  |  | + * identity key, and contact points, for each authority.  The
 | 
	
		
			
				|  |  | + * authorities receive descriptors from relays, and publish consensuses,
 | 
	
		
			
				|  |  | + * descriptors, and microdescriptors.  This list is pre-configured.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Fallback directories are well-known, stable, but untrusted directory
 | 
	
		
			
				|  |  | + * caches that clients which have not yet bootstrapped can use to get
 | 
	
		
			
				|  |  | + * their first networkstatus consensus, in order to find out where the
 | 
	
		
			
				|  |  | + * Tor network really is.  This list is pre-configured in
 | 
	
		
			
				|  |  | + * fallback_dirs.inc.  Every authority also serves as a fallback.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Both fallback directories and directory authorities are are
 | 
	
		
			
				|  |  | + * represented by a dir_server_t.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Authority certificates are signed with authority identity keys; they
 | 
	
		
			
				|  |  | + * are used to authenticate shorter-term authority signing keys. We
 | 
	
		
			
				|  |  | + * fetch them when we find a consensus or a vote that has been signed
 | 
	
		
			
				|  |  | + * with a signing key we don't recognize.  We cache them on disk and
 | 
	
		
			
				|  |  | + * load them on startup.  Authority operators generate them with the
 | 
	
		
			
				|  |  | + * "tor-gencert" utility.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * TODO: Authority certificates should be a separate module.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * TODO: dir_server_t stuff should be in a separate module.
 | 
	
		
			
				|  |  |   **/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #define ROUTERLIST_PRIVATE
 | 
	
	
		
			
				|  | @@ -46,6 +125,9 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /****************************************************************************/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +/* Typed wrappers for different digestmap types; used to avoid type
 | 
	
		
			
				|  |  | + * confusion. */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  DECLARE_TYPED_DIGESTMAP_FNS(sdmap_, digest_sd_map_t, signed_descriptor_t)
 | 
	
		
			
				|  |  |  DECLARE_TYPED_DIGESTMAP_FNS(rimap_, digest_ri_map_t, routerinfo_t)
 | 
	
		
			
				|  |  |  DECLARE_TYPED_DIGESTMAP_FNS(eimap_, digest_ei_map_t, extrainfo_t)
 | 
	
	
		
			
				|  | @@ -800,7 +882,9 @@ static const char *BAD_SIGNING_KEYS[] = {
 | 
	
		
			
				|  |  |    NULL,
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -/* DOCDOC */
 | 
	
		
			
				|  |  | +/** Return true iff <b>cert</b> authenticates some atuhority signing key
 | 
	
		
			
				|  |  | + * which, because of the old openssl heartbleed vulnerability, should
 | 
	
		
			
				|  |  | + * never be trusted. */
 | 
	
		
			
				|  |  |  int
 | 
	
		
			
				|  |  |  authority_cert_is_blacklisted(const authority_cert_t *cert)
 | 
	
		
			
				|  |  |  {
 |