dir-spec.txt 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  1. $Id$
  2. Tor directory protocol, version 3
  3. 0. Scope and preliminaries
  4. This directory protocol is used by Tor version 0.2.0.x-alpha and later.
  5. See dir-spec-v1.txt for information on the protocol used up to the
  6. 0.1.0.x series, and dir-spec-v2.txt for information on the protocol
  7. used by the 0.1.1.x and 0.1.2.x series.
  8. Caches and authorities must still support older versions of the
  9. directory protocols, until the versions of Tor that require them are
  10. finally out of commission. See Section XXXX on backward compatibility.
  11. This document merges and supersedes the following proposals:
  12. 101 Voting on the Tor Directory System
  13. 103 Splitting identity key from regularly used signing key
  14. 104 Long and Short Router Descriptors
  15. AS OF 3 MAY 2007, THIS SPECIFICATION HAS NOT YET BEEN COMPLETELY
  16. IMPLEMENTED.
  17. 0.1. History
  18. The earliest versions of Onion Routing shipped with a list of known
  19. routers and their keys. When the set of routers changed, users needed to
  20. fetch a new list.
  21. The Version 1 Directory protocol
  22. --------------------------------
  23. [XXX say which versions added what.]
  24. Early versions of Tor introduced "Directory authorities": servers that
  25. served signed "directory" documents containing a list of signed "router
  26. descriptors", along with short summary of the status of each router.
  27. Thus, clients could get up-to-date information on the state of the
  28. network automatically, and be certain that they list they were getting
  29. was attested by a trusted directory authority.
  30. Later versions added directory caches, which download directories from
  31. the authorities and serve them to clients. Non-caches fetch from the
  32. caches in preference to fetching from the authorities, thus distributing
  33. bandwidth requirements.
  34. Also added during the version 1 directory protocol were "router status"
  35. documents: short documents that listed only the up/down status of the
  36. routers on the network, rather than a complete list of all the
  37. descriptors. Clients and caches would fetch these documents far more
  38. frequently than they would fetch full directories.
  39. The Version 2 Directory Protocol
  40. --------------------------------
  41. During the Tor 0.1.1.x series, Tor revised its handling of directory
  42. documents in order to address two major problems:
  43. * Directories had grown quite large (over 1MB), and most directory
  44. downloads consisted mainly of router descriptors that clients
  45. already had.
  46. * Every directory authorities was a trust bottleneck: if a single
  47. directory authority lied, it could make clients believe for a time
  48. an arbitrarily distorted view of the Tor network. (Clients
  49. trusted the most recent signed document they downloaded.) Thus,
  50. adding more authorities would make the system less secure, not
  51. more.
  52. To address these, we extended the directory protocol so that
  53. authorities now published signed "network status" documents. Each
  54. network status listed, for every router in the network: a hash of its
  55. identity key, a hash of its most recent descriptor, and a summary of
  56. what the authority believed about its status. Clients would download
  57. the authorities' network status documents in turn, and believe
  58. statements about routers iff they were attested to by more than half of
  59. the authorities.
  60. Instead of downloading all router descriptors at once, clients
  61. downloaded only the descriptors that they did not have. Descriptors
  62. were indexed by their digests, in order to prevent malicious caches
  63. from giving different versions of a router descriptor to different
  64. clients.
  65. Routers began working harder to upload new descriptors only when their
  66. contents were substantially changed.
  67. 0.2. Goals of the version 3 protocol
  68. Version 3 of the Tor directory protocol tries to solve the following
  69. issues:
  70. * A great deal of bandwidth used to transmit router descriptors was
  71. used by two fields that are not actually used by Tor routers. We
  72. save about 60% by moving them into a separate document that most
  73. clients do not fetch or use.
  74. * It was possible under certain perverse circumstances for clients
  75. to download an unusual set of network status documents, thus
  76. partitioning themselves from clients who have a more recent and/or
  77. typical set of documents. Even under the best of circumstances,
  78. clients were sensitive to the ages of the network status documents
  79. they downloaded. Therefore, instead of having the clients
  80. correlate multiple network status documents, we have the
  81. authorities collectively vote on a single consensus network status
  82. document.
  83. * The most sensitive data in the entire network (the identity keys
  84. of the directory authorities) needed to be stored unencrypted so
  85. that the authorities can sign network-status documents on the fly.
  86. Now, the authorities' identity keys are stored offline, and used
  87. to certify medium-term signing keys that can be rotated.
  88. 0.3. Some Remaining questions
  89. Things we could solve on a v3 timeframe:
  90. The SHA-1 hash is showing its age. We should do something about our
  91. dependency on it. We could probably future-proof ourselves here in
  92. this revision, at least so far as documents from the authorities are
  93. concerned.
  94. Too many things about the authorities are hardcoded by IP.
  95. Perhaps we should start accepting longer identity keys for routers
  96. too.
  97. Things to solve eventually:
  98. Requiring every client to know about every router won't scale forever.
  99. Requiring every directory cache to know every router won't scale
  100. forever.
  101. 1. Outline
  102. There is a small set (say, around 5-10) of semi-trusted directory
  103. authorities. A default list of authorities is shipped with the Tor
  104. software. Users can change this list, but are encouraged not to do so,
  105. in order to avoid partitioning attacks.
  106. Every authority has a very-secret, long-term "Authority Identity Key".
  107. This is stored encrypted and/or offline, and is used to sign "key
  108. certificate" documents. Every key certificate contains a medium-term
  109. (3-12 months) "authority signing key", that is used by the authority to
  110. sign other directory information. (Note that the authority identity
  111. key is distinct from the router identity key that the authority uses
  112. in its role as an ordinary router.)
  113. Routers periodically upload signed "routers descriptors" to the
  114. directory authorities describing their keys, capabilities, and other
  115. information. Routers may also upload signed "extra info documents"
  116. containing information that is not required for the Tor protocol.
  117. Directory authorities serve router descriptors indexed by router
  118. identity, or by hash of the descriptor.
  119. Routers may act as directory caches to reduce load on the directory
  120. authorities. They announce this in their descriptors.
  121. Periodically, each directory authority periodically generates a view of
  122. the current descriptors and status for known routers. They send a
  123. signed summary of this view (a "status vote") to the other
  124. authorities. The authorities compute the result of this vote, and sign
  125. a "consensus status" document containing the result of the vote.
  126. Directory caches download, cache, and re-serve consensus documents.
  127. Clients, directory caches, and directory authorities all use consensus
  128. documents to find out when their list of routers is out-of-date.
  129. (Directory authorities also use vote statuses.) If it is, they download
  130. any missing router descriptors. Clients download missing descriptors
  131. from caches; caches and authorities download from authorities.
  132. Descriptors are downloaded by the hash of the descriptor, not by the
  133. server's identity key: this prevents servers from attacking clients by
  134. giving them descriptors nobody else uses.
  135. All directory information is uploaded and downloaded with HTTP.
  136. [Authorities also generate and caches also cache documents produced and
  137. used by earlier versions of this protocol; see section XXX for notes.]
  138. 1.1. What's different from version 2?
  139. Clients used to download a multiple network status documents,
  140. corresponding roughly to "status votes" above. They would compute the
  141. result of the vote on the client side.
  142. Authorities used sign documents using the same private keys they used
  143. for their roles as routers. This forced them to keep these extremely
  144. sensitive keys in memory unencrypted.
  145. All of the information in extra-info documents used to be kept in the
  146. main descriptors.
  147. 1.2. Document meta-format
  148. Router descriptors, directories, and running-routers documents all obey the
  149. following lightweight extensible information format.
  150. The highest level object is a Document, which consists of one or more
  151. Items. Every Item begins with a KeywordLine, followed by one or more
  152. Objects. A KeywordLine begins with a Keyword, optionally followed by
  153. whitespace and more non-newline characters, and ends with a newline. A
  154. Keyword is a sequence of one or more characters in the set [A-Za-z0-9-].
  155. An Object is a block of encoded data in pseudo-Open-PGP-style
  156. armor. (cf. RFC 2440)
  157. More formally:
  158. Document ::= (Item | NL)+
  159. Item ::= KeywordLine Object*
  160. KeywordLine ::= Keyword NL | Keyword WS ArgumentsChar+ NL
  161. Keyword = KeywordChar+
  162. KeywordChar ::= 'A' ... 'Z' | 'a' ... 'z' | '0' ... '9' | '-'
  163. ArgumentChar ::= any printing ASCII character except NL.
  164. WS = (SP | TAB)+
  165. Object ::= BeginLine Base-64-encoded-data EndLine
  166. BeginLine ::= "-----BEGIN " Keyword "-----" NL
  167. EndLine ::= "-----END " Keyword "-----" NL
  168. The BeginLine and EndLine of an Object must use the same keyword.
  169. When interpreting a Document, software MUST ignore any KeywordLine that
  170. starts with a keyword it doesn't recognize; future implementations MUST NOT
  171. require current clients to understand any KeywordLine not currently
  172. described.
  173. The "opt" keyword was used until Tor 0.1.2.5-alpha for non-critical future
  174. extensions. All implementations MUST ignore any item of the form "opt
  175. keyword ....." when they would not recognize "keyword ....."; and MUST
  176. treat "opt keyword ....." as synonymous with "keyword ......" when keyword
  177. is recognized.
  178. Implementations before 0.1.2.5-alpha rejected any document with a
  179. KeywordLine that started with a keyword that they didn't recognize.
  180. When generating documents that need to be read by older versions of Tor,
  181. implementations MUST prefix items not recognized by older versions of
  182. Tor with an "opt" until those versions of Tor are obsolete. [Note that
  183. key certificates, status vote documents, extra info documents, and
  184. status consensus documents will never by read by older versions of Tor.]
  185. Other implementations that want to extend Tor's directory format MAY
  186. introduce their own items. The keywords for extension items SHOULD start
  187. with the characters "x-" or "X-", to guarantee that they will not conflict
  188. with keywords used by future versions of Tor.
  189. In our document descriptions below, we tag Items with a multiplicity in
  190. brackets. Possible tags are:
  191. "At start, exactly once": These items MUST occur in every instance of
  192. the document type, and MUST appear exactly once, and MUST be the
  193. first item in their documents.
  194. "Exactly once": These items MUST occur exactly one time in every
  195. instance of the document type.
  196. "At end, exactly once": These items MUST occur in every instance of
  197. the document type, and MUST appear exactly once, and MUST be the
  198. last item in their documents.
  199. "At most once": These items MAY occur zero or one times in any
  200. instance of the document type, but MUST NOT occur more than once.
  201. "Any number": These items MAY occur zero, one, or more times in any
  202. instance of the document type.
  203. "Once or more": These items MUST occur at least once in any instance
  204. of the document type, and MAY occur more.
  205. 1.3. Signing documents
  206. Every signable document below is signed in a similar manner, using a
  207. given "Initial Item", a final "Signature Item", a digest algorithm, and
  208. a signing key.
  209. The Initial Item must be the first item in the document.
  210. The Signature Item has the following format:
  211. <signature item keyword> [arguments] NL SIGNATURE NL
  212. The "SIGNATURE" Object contains a signature (using the signing key) of
  213. the PKCS1-padded digest of the entire document, taken from the
  214. beginning of the Initial item, through the newline after the Signature
  215. Item's keyword and its arguments.
  216. Unless otherwise, the digest algorithm is SHA-1.
  217. All documents are invalid unless signed with the correct signing key.
  218. The "Digest" of a document, unless stated otherwise, is its digest *as
  219. signed by this signature scheme*.
  220. 2. Router operation and formats
  221. ORs SHOULD generate a new router descriptor and a new extra-info
  222. document whenever any of the following events have occurred:
  223. - A period of time (18 hrs by default) has passed since the last
  224. time a descriptor was generated.
  225. - A descriptor field other than bandwidth or uptime has changed.
  226. - Bandwidth has changed by more than +/- 50% from the last time a
  227. descriptor was generated, and at least a given interval of time
  228. (20 mins by default) has passed since then.
  229. - Its uptime has been reset (by restarting).
  230. After generating a descriptor, ORs upload them to every directory
  231. authority they know, by posting them (in order) to the URL
  232. http://<hostname:port>/tor/
  233. 2.1. Router descriptor format
  234. Router descriptors consist of the following items. For backward
  235. compatibility, there should be an extra NL at the end of each router
  236. descriptor.
  237. In lines that take multiple arguments, extra arguments SHOULD be
  238. accepted and ignored.
  239. "router" nickname address ORPort SOCKSPort DirPort NL
  240. [At start, exactly once.]
  241. Indicates the beginning of a router descriptor. "address" must be an
  242. IPv4 address in dotted-quad format. The last three numbers indicate
  243. the TCP ports at which this OR exposes functionality. ORPort is a port
  244. at which this OR accepts TLS connections for the main OR protocol;
  245. SOCKSPort is deprecated and should always be 0; and DirPort is the
  246. port at which this OR accepts directory-related HTTP connections. If
  247. any port is not supported, the value 0 is given instead of a port
  248. number.
  249. "bandwidth" bandwidth-avg bandwidth-burst bandwidth-observed NL
  250. [Exactly once]
  251. Estimated bandwidth for this router, in bytes per second. The
  252. "average" bandwidth is the volume per second that the OR is willing to
  253. sustain over long periods; the "burst" bandwidth is the volume that
  254. the OR is willing to sustain in very short intervals. The "observed"
  255. value is an estimate of the capacity this server can handle. The
  256. server remembers the max bandwidth sustained output over any ten
  257. second period in the past day, and another sustained input. The
  258. "observed" value is the lesser of these two numbers.
  259. "platform" string NL
  260. [At most once]
  261. A human-readable string describing the system on which this OR is
  262. running. This MAY include the operating system, and SHOULD include
  263. the name and version of the software implementing the Tor protocol.
  264. "published" YYYY-MM-DD HH:MM:SS NL
  265. [Exactly once]
  266. The time, in GMT, when this descriptor (and its corresponding
  267. extra-info document if any) was generated.
  268. "fingerprint" fingerprint NL
  269. [At most once]
  270. A fingerprint (a HASH_LEN-byte of asn1 encoded public key, encoded in
  271. hex, with a single space after every 4 characters) for this router's
  272. identity key. A descriptor is considered invalid (and MUST be
  273. rejected) if the fingerprint line does not match the public key.
  274. [We didn't start parsing this line until Tor 0.1.0.6-rc; it should
  275. be marked with "opt" until earlier versions of Tor are obsolete.]
  276. "hibernating" bool NL
  277. [At most once]
  278. If the value is 1, then the Tor server was hibernating when the
  279. descriptor was published, and shouldn't be used to build circuits.
  280. [We didn't start parsing this line until Tor 0.1.0.6-rc; it should be
  281. marked with "opt" until earlier versions of Tor are obsolete.]
  282. "uptime" number NL
  283. [At most once]
  284. The number of seconds that this OR process has been running.
  285. "onion-key" NL a public key in PEM format
  286. [Exactly once]
  287. This key is used to encrypt EXTEND cells for this OR. The key MUST be
  288. accepted for at least 1 week after any new key is published in a
  289. subsequent descriptor. It MUST be 1024 bits.
  290. "signing-key" NL a public key in PEM format
  291. [Exactly once]
  292. The OR's long-term identity key. It MUST be 1024 bits.
  293. "accept" exitpattern NL
  294. "reject" exitpattern NL
  295. [Any number]
  296. These lines describe the rules that an OR follows when
  297. deciding whether to allow a new stream to a given address. The
  298. 'exitpattern' syntax is described below. The rules are considered in
  299. order; if no rule matches, the address will be accepted. For clarity,
  300. the last such entry SHOULD be accept *:* or reject *:*.
  301. "router-signature" NL Signature NL
  302. [At end, exactly once]
  303. The "SIGNATURE" object contains a signature of the PKCS1-padded
  304. hash of the entire router descriptor, taken from the beginning of the
  305. "router" line, through the newline after the "router-signature" line.
  306. The router descriptor is invalid unless the signature is performed
  307. with the router's identity key.
  308. "contact" info NL
  309. [At most once]
  310. Describes a way to contact the server's administrator, preferably
  311. including an email address and a PGP key fingerprint.
  312. "family" names NL
  313. [At most once]
  314. 'Names' is a space-separated list of server nicknames or
  315. hexdigests. If two ORs list one another in their "family" entries,
  316. then OPs should treat them as a single OR for the purpose of path
  317. selection.
  318. For example, if node A's descriptor contains "family B", and node B's
  319. descriptor contains "family A", then node A and node B should never
  320. be used on the same circuit.
  321. "read-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  322. [At most once]
  323. "write-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  324. [At most once]
  325. Declare how much bandwidth the OR has used recently. Usage is divided
  326. into intervals of NSEC seconds. The YYYY-MM-DD HH:MM:SS field
  327. defines the end of the most recent interval. The numbers are the
  328. number of bytes used in the most recent intervals, ordered from
  329. oldest to newest.
  330. [We didn't start parsing these lines until Tor 0.1.0.6-rc; they should
  331. be marked with "opt" until earlier versions of Tor are obsolete.]
  332. [See also migration notes in section 2.2.1.]
  333. "caches-extra-info" 0|1 NL
  334. [At most once.]
  335. True if this router is a directory cache that provides extra-info
  336. documents. If absent, the value should be treated as false.
  337. [Versions before 0.2.0.1-alpha don't recognize this, and versions
  338. before 0.1.2.5-alpha will reject descriptors containing it unless
  339. it is prefixed with "opt"; it should be so prefixed until these
  340. versions are obsolete.]
  341. "extra-info-digest" digest NL
  342. [At most once]
  343. "Digest" is a hex-encoded digest (using upper-case characters)
  344. of the router's extra-info document, as signed in the router's
  345. extra-info. (If this field is absent, the router is not uploading
  346. a corresponding extra-info document.)
  347. [Versions before 0.2.0.1-alpha don't recognize this, and versions
  348. before 0.1.2.5-alpha will reject descriptors containing it unless
  349. it is prefixed with "opt"; it should be so prefixed until these
  350. versions are obsolete.]
  351. 2.2. Extra-info documents
  352. Extra-info documents consist of the following items:
  353. "extra-info" Nickname Fingerprint NL
  354. [At start, exactly once.]
  355. Identifies what router this is an extra info descriptor for.
  356. Fingerprint is encoded in hex (using upper-case letters), with
  357. no spaces.
  358. "published"
  359. [Exactly once.]
  360. The time, in GMT, when this document (and its corresponding router
  361. descriptor if any) was generated. It MUST match the published time
  362. in the corresponding router descriptor.
  363. "read-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  364. [At most once.]
  365. "write-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  366. [At most once.]
  367. As documented in 2.1 above. See migration notes in section 2.2.1.
  368. "router-signature" NL Signature NL
  369. [At end, exactly once.]
  370. A document signature as documented in section 1.3, using the
  371. initial item "extra-info" and the final item "router-signature",
  372. signed with the router's identity key.
  373. 2.2.1. Moving history fields to extra-info documents.
  374. Tools that want to use the read-history and write-history values SHOULD
  375. download extra-info documents as well as router descriptors. Such
  376. tools SHOULD accept history values from both sources; if they appear in
  377. both documents, the values in the extra-info documents are authoritative.
  378. At some future time, to save space, new versions of Tor will no longer
  379. generate router descriptors containing read-history or write-history.
  380. Tools should continue to accept read-history and write-history values
  381. in router descriptors produced by older versions of Tor.
  382. 2.3. Nonterminals in router descriptors
  383. nickname ::= between 1 and 19 alphanumeric characters, case-insensitive.
  384. hexdigest ::= a '$', followed by 20 hexadecimal characters.
  385. [Represents a server by the digest of its identity key.]
  386. exitpattern ::= addrspec ":" portspec
  387. portspec ::= "*" | port | port "-" port
  388. port ::= an integer between 1 and 65535, inclusive.
  389. [Some implementations incorrectly generate ports with value 0.
  390. Implementations SHOULD accept this, and SHOULD NOT generate it.]
  391. addrspec ::= "*" | ip4spec | ip6spec
  392. ipv4spec ::= ip4 | ip4 "/" num_ip4_bits | ip4 "/" ip4mask
  393. ip4 ::= an IPv4 address in dotted-quad format
  394. ip4mask ::= an IPv4 mask in dotted-quad format
  395. num_ip4_bits ::= an integer between 0 and 32
  396. ip6spec ::= ip6 | ip6 "/" num_ip6_bits
  397. ip6 ::= an IPv6 address, surrounded by square brackets.
  398. num_ip6_bits ::= an integer between 0 and 128
  399. bool ::= "0" | "1"
  400. 3. Formats produced by directory authorities.
  401. Every authority has two keys used in this protocol: a signing key, and
  402. an authority identity key. (Authorities also have a router identity
  403. key used in their role as a router and by earlier versions of the
  404. directory protocol.) The identity key is used from time to time to
  405. sign new key certificates using new signing keys; it is very sensitive.
  406. The signing key is used to sign key certificates and status documents.
  407. There are three kinds of documents generated by directory authorities:
  408. Key certificates
  409. Status votes
  410. Status consensuses
  411. Each is discussed below.
  412. 3.1. Key certificates
  413. Key certificates consist of the following items:
  414. "dir-key-certificate-version" version NL
  415. [At start, exactly once.]
  416. Determines the version of the key certificate. MUST be "3" for
  417. the protocol described in this document. Implementations MUST
  418. reject formats they don't understand.
  419. "fingerprint" fingerprint NL
  420. [Exactly once.]
  421. Hexadecimal encoding without spaces based on the authority's
  422. identity key.
  423. "dir-identity-key" NL a public key in PEM format
  424. [Exactly once.]
  425. The long-term authority identity key for this authority. This key
  426. SHOULD be at least 2048 bits long; it MUST NOT be shorter than
  427. 1024 bits.
  428. "dir-key-published" YYYY-MM-DD HH:MM:SS NL
  429. [Exactly once.]
  430. The time (in GMT) when this document and corresponding key were
  431. last generated.
  432. "dir-key-expires" YYYY-MM-DD HH:MM:SS NL
  433. [Exactly once.]
  434. A time (in GMT) after which this key is no longer valid.
  435. "dir-signing-key" NL a key in PEM format
  436. [Exactly once.]
  437. The directory server's public signing key. This key MUST be at
  438. least 1024 bits, and MAY be longer.
  439. "dir-key-certification" NL Signature NL
  440. [At end, exactly once.]
  441. A document signature as documented in section 1.3, using the
  442. initial item "dir-key-certificate-version" and the final item
  443. "dir-key-certification", signed with the authority identity key.
  444. Authorities MUST generate a new signing key and corresponding
  445. certificate before the key expires.
  446. 3.2. Vote and consensus status documents
  447. Votes and consensuses are more strictly formatted then other documents
  448. in this specification, since different authorities must be able to
  449. generate exactly the same consensus given the same set of votes.
  450. The procedure for deciding when to generate vote and consensus status
  451. documents are described in section XXX below.
  452. Status documents contain a preamble, an authority section, a list of
  453. router status entries, and one more footers signature, in that order.
  454. Unlike other formats described above, a SP in these documents must be a
  455. single space character (hex 20).
  456. Some items appear only in votes, and some items appear only in
  457. consensuses. Unless specified, items occur in both.
  458. The preamble contains the following items. They MUST occur in the
  459. order given here:
  460. "network-status-version" SP version NL.
  461. [At start, exactly once.]
  462. A document format version. For this specification, the version is
  463. "3".
  464. "vote-status" SP type NL
  465. [Exactly once.]
  466. The status MUST be "vote" or "consensus", depending on the type of
  467. the document.
  468. "published" SP YYYY-MM-DD SP HH:MM:SS NL
  469. [Exactly once for votes; Does not occur in consensuses.]
  470. The publication time for this status document (if a vote).
  471. "valid-after" SP YYYY-MM-DD SP HH:MM:SS NL
  472. [Exactly once.]
  473. The start of the Interval for this vote (if a consensus.)
  474. "valid-until" SP YYYY-MM-DD SP HH:MM:SS NL
  475. [Exactly once.]
  476. A time after which this vote or consensus will no longer be valid.
  477. "client-versions" SP VersionList NL
  478. [At most once.]
  479. A comma-separated list of recommended client versions, in
  480. ascending order. If absent, no opinion is held about client
  481. versions.
  482. "server-versions" SP VersionList NL
  483. [At most once.]
  484. A comma-separated list of recommended server versions, in
  485. ascending order. If absent, no opinion is held about server
  486. versions.
  487. "known-flags" SP FlagList NL
  488. [Exactly once.]
  489. A space-separated list of all of the flags that this document
  490. might contain. A flag is "known" either because the authority
  491. knows about them and might set them (if in a vote), or because
  492. enough votes were counted for the consensus for an authoritative
  493. opinion to have been formed about their status.
  494. The authority section of a vote contains the following items, followed
  495. in turn by the authority's current key certificate:
  496. "dir-source" SP nickname SP identity SP address SP IP SP dirport NL
  497. [Exactly once, at start]
  498. Describes this authority. The nickname is a convenient identifier
  499. for the authority. The identity is a hex fingerprint of the
  500. authority's current identity key. The address is the server's
  501. hostname. The IP is the server's current IP address, and dirport
  502. is its current directory port.
  503. "contact" SP string NL
  504. [At most once.]
  505. An arbitrary string describing how to contact the directory
  506. server's administrator. Administrators should include at least an
  507. email address and a PGP fingerprint.
  508. The authority section of a consensus contains groups the following
  509. items, in the order given, with one group for each authority that
  510. contributed to the consensus:
  511. "dir-source" SP nickname SP address SP IP SP dirport NL
  512. [Exactly once, at start]
  513. As in the authority section of a vote.
  514. "contact" SP string NL
  515. [At most once.]
  516. As in the authority section of a vote.
  517. "fingerprint" SP fingerprint NL
  518. [Exactly once.]
  519. A hex fingerprint, without spaces, of the authority's current
  520. identity key.
  521. "vote-digest" SP digest NL
  522. [Exactly once.]
  523. A digest of the vote from the authority that contributed to this
  524. consensus.
  525. Each router status entry contains the following items. Router status
  526. entries are sorted in ascending order by identity digest.
  527. "r" SP nickname SP identity SP digest SP publication SP IP SP ORPort
  528. SP DirPort NL
  529. [At start, exactly once.]
  530. "Nickname" is the OR's nickname. "Identity" is a hash of its
  531. identity key, encoded in base64, with trailing equals sign(s)
  532. removed. "Digest" is a hash of its most recent descriptor (as
  533. signed), encoded in base64 as "identity". "Publication" is the
  534. publication time of its most recent descriptor, in the form
  535. YYYY-MM-DD HH:MM:SS, in GMT. "IP" is its current IP address;
  536. ORPort is its current OR port, "DirPort" is it's current directory
  537. port, or "0" for "none".
  538. "s" SP Flags NL
  539. [At most once.]
  540. A series of space-separated status flags, in alphabetical order.
  541. Currently documented flags are:
  542. "Authority" if the router is a directory authority.
  543. "BadExit" if the router is believed to be useless as an exit node
  544. (because its ISP censors it, because it is behind a restrictive
  545. proxy, or for some similar reason).
  546. "BadDirectory" if the router is believed to be useless as a
  547. directory cache (because its directory port isn't working,
  548. its bandwidth is always throttled, or for some similar
  549. reason).
  550. "Exit" if the router is useful for building general-purpose exit
  551. circuits.
  552. "Fast" if the router is suitable for high-bandwidth circuits.
  553. "Guard" if the router is suitable for use as an entry guard.
  554. "Named" if the router's identity-nickname mapping is canonical,
  555. and this authority binds names.
  556. "Stable" if the router is suitable for long-lived circuits.
  557. "Running" if the router is currently usable.
  558. "Valid" if the router has been 'validated'.
  559. "V2Dir" if the router implements this protocol.
  560. "v" SP version NL
  561. [At most once.]
  562. The version of the Tor protocol that this server is running. If
  563. the value begins with "Tor" SP, the rest of the string is a Tor
  564. version number, and the protocol is "The Tor protocol as supported
  565. by the given version of Tor." Otherwise, if the value begins with
  566. some other string, Tor has upgraded to a more sophisticated
  567. protocol versioning system, and the protocol is "a version of the
  568. Tor protocol more recent than any we recognize."
  569. The signature section contains the following item, which appears
  570. Exactly Once for a vote, and At Least Once for a consensus.
  571. "directory-signature" SP identity SP digest NL Signature
  572. This is a signature of the status document, with the initial item
  573. "network-status-version", and the signature item
  574. "directory-signature", using the signing key. (In this case, we
  575. take the hash through the _space_ after directory-signature, not
  576. the newline: this ensures that all authorities sign the same
  577. thing.) "identity" is the hex-encoded digest of the authority
  578. identity key of the signing authority, and "digest" is the
  579. hex-encoded digest of the current authority signing key of the
  580. signing authority.
  581. 3.3. Deciding how to vote.
  582. (This section describes how directory authorities choose which status
  583. flags to apply to routers, as of Tor 0.2.0.0-alpha-dev. Later directory
  584. authorities MAY do things differently, so long as clients keep working
  585. well. Clients MUST NOT depend on the exact behaviors in this section.)
  586. In the below definitions, a router is considered "active" if it is
  587. running, valid, and not hibernating.
  588. "Valid" -- a router is 'Valid' if it is running a version of Tor not
  589. known to be broken, and the directory authority has not blacklisted
  590. it as suspicious.
  591. "Named" -- Directory authority administrators may decide to support name
  592. binding. If they do, then they must maintain a file of
  593. nickname-to-identity-key mappings, and try to keep this file consistent
  594. with other directory authorities. If they don't, they act as clients, and
  595. report bindings made by other directory authorities (name X is bound to
  596. identity Y if at least one binding directory lists it, and no directory
  597. binds X to some other Y'.) A router is called 'Named' if the router
  598. believes the given name should be bound to the given key.
  599. "Running" -- A router is 'Running' if the authority managed to connect to
  600. it successfully within the last 30 minutes.
  601. "Stable" -- A router is 'Stable' if it is active, and either its
  602. uptime is at least the median uptime for known active routers, or
  603. its uptime is at least 30 days. Routers are never called stable if
  604. they are running a version of Tor known to drop circuits stupidly.
  605. (0.1.1.10-alpha through 0.1.1.16-rc are stupid this way.)
  606. "Fast" -- A router is 'Fast' if it is active, and its bandwidth is
  607. in the top 7/8ths for known active routers.
  608. "Guard" -- A router is a possible 'Guard' if it is 'Stable' and its
  609. bandwidth is above median for known active routers. If the total
  610. bandwidth of active non-BadExit Exit servers is less than one third
  611. of the total bandwidth of all active servers, no Exit is listed as
  612. a Guard.
  613. "Authority" -- A router is called an 'Authority' if the authority
  614. generating the network-status document believes it is an authority.
  615. "V2Dir" -- A router supports the v2 directory protocol if it has an open
  616. directory port, and it is running a version of the directory protocol that
  617. supports the functionality clients need. (Currently, this is
  618. 0.1.1.9-alpha or later.)
  619. Directory server administrators may label some servers or IPs as
  620. blacklisted, and elect not to include them in their network-status lists.
  621. Thus, the network-status list includes all non-blacklisted,
  622. non-expired, non-superseded descriptors.
  623. 3.4. Computing a consensus from a set of votes
  624. Given a set of votes, authorities compute the contents of the consensus
  625. document as follows:
  626. The "valid-after" is the latest of all valid-after times on the votes.
  627. The "valid-until" is the earliest of all valid-until times on the
  628. votes.
  629. "client-versions" and "server-versions" are sorted in ascending
  630. order; A version is recommended in the consensus if it is recommended
  631. by more than half of the voting authorities that included a
  632. client-versions or server-versions lines in their votes.
  633. The authority item groups (dir-source, contact, fignerprint,
  634. vote-digest) are taken from the votes of the voting
  635. authorities. These groups are sorted by the digests of the
  636. authorities identity keys, in ascending order.
  637. A router status entry is included in the result if it is included by more
  638. than half of the authorities (total authorities, not just those whose
  639. votes we have). A router entry has a flag set if it is included by
  640. more than half of the authorities who care about that flag. Two
  641. router entries are "the same" if they have the same identity digest.
  642. We use whatever descriptor digest is attested to by the most
  643. authorities among the voters, breaking ties in favor of the one with
  644. the most recent publication time.
  645. The signatures at the end of the document appear are sorted in
  646. ascending order by identity digest.
  647. 3.4. Detached signatures
  648. Assuming full connectivity, every authority should compute and sign the
  649. same consensus directory in each period. Therefore, it isn't necessary to
  650. download the consensus computed by each authority; instead, the
  651. authorities only push/fetch each others' signatures. A "detached
  652. signature" document contains items as follows:
  653. "consensus-digest" SP Digest NL
  654. [At start, at most once.]
  655. The digest of the consensus being signed.
  656. "valid-after" SP YYYY-MM-DD SP HH:MM:SS NL
  657. "valid-until" SP YYYY-MM-DD SP HH:MM:SS NL
  658. [As in the consensus]
  659. "directory signature"
  660. [As in the consensus; the signature object is the same as in the
  661. consensus document.]
  662. 4. Directory server operation
  663. All directory authorities and directory caches ("directory servers")
  664. implement this section, except as noted.
  665. 4.1. Accepting uploads (authorities only)
  666. When a router posts a signed descriptor to a directory authority, the
  667. authority first checks whether it is well-formed and correctly
  668. self-signed. If it is, the authority next verifies that the nickname
  669. question is already assigned to a router with a different public key.
  670. Finally, the authority MAY check that the router is not blacklisted
  671. because of its key, IP, or another reason.
  672. If the descriptor passes these tests, and the authority does not already
  673. have a descriptor for a router with this public key, it accepts the
  674. descriptor and remembers it.
  675. If the authority _does_ have a descriptor with the same public key, the
  676. newly uploaded descriptor is remembered if its publication time is more
  677. recent than the most recent old descriptor for that router, and either:
  678. - There are non-cosmetic differences between the old descriptor and the
  679. new one.
  680. - Enough time has passed between the descriptors' publication times.
  681. (Currently, 12 hours.)
  682. Differences between router descriptors are "non-cosmetic" if they would be
  683. sufficient to force an upload as described in section 2 above.
  684. Note that the "cosmetic difference" test only applies to uploaded
  685. descriptors, not to descriptors that the authority downloads from other
  686. authorities.
  687. When a router posts a signed extra-info document to a directory authority,
  688. the authority again checks it for well-formedness and correct signature,
  689. and checks that its matches the extra-info-digest in some router
  690. descriptor that it believes is currently useful. If so, it accepts it and
  691. stores it and serves it as requested. If not, it drops it.
  692. 4.2. Voting (authorities only)
  693. Authorities divide time into Intervals. Authority administrators SHOULD
  694. try to all pick the same interval length, and SHOULD pick intervals that
  695. are commonly used divisions of time (e.g., 5 minutes, 15 minutes, 30
  696. minutes, 60 minutes, 90 minutes). Voting intervals SHOULD be chosen to
  697. divide evenly into a 24-hour day.
  698. Authorities MUST take pains to ensure that their clocks remain accurate,
  699. for example by running NTP.
  700. The first voting period of each day begins at 00:00 (midnight) GMT. If
  701. the last period of the day would be truncated by one-half or more, it is
  702. merged with the second-to-last period.
  703. An authority SHOULD publish its vote immediately at the start of each voting
  704. period. It does this by making it available at
  705. http://<hostname>/tor/status-vote/current/authority.z
  706. and sending it in an HTTP POST request to each other authority at the URL
  707. http://<hostname>/tor/post/vote
  708. If, N minutes after the voting period has begun, an authority does not have
  709. a current statement from another authority, the first authority retrieves
  710. the other's statement.
  711. Once an authority has a vote from another authority, it makes it available
  712. at
  713. http://<hostname>/tor/status-vote/current/<fp>.z
  714. where <fp> is the fingerprint of the other authority's identity key.
  715. The consensus status, along with as many signatures as the server
  716. currently knows, should be available at
  717. http://<hostname>/tor/status-vote/current/consensus.z
  718. All of the detached signatures it knows for consensus status should be
  719. available at:
  720. http://<hostname>/tor/status-vote/current/consensus-signatures.z
  721. Once an authority has computed and signed a consensus network status, it
  722. should send its detached signature to each other authority in an HTTP POST
  723. request to the URL:
  724. http://<hostname>/tor/post/consensus-signature
  725. [XXXX CUTOFF HERE. STUFF BELOW THIS POINT HAS NOT YET BEEN UPDATED FROM V2.]
  726. 4.3. Downloading consensus status documents (authorities caches only)
  727. All directory servers (authorities and mirrors) try to keep a fresh
  728. set of network-status documents from every authority. To do so,
  729. every 5 minutes, each authority asks every other authority for its
  730. most recent network-status document. Every 15 minutes, each mirror
  731. picks a random authority and asks it for the most recent network-status
  732. documents for all the authorities the authority knows about (including
  733. the chosen authority itself).
  734. Directory servers and mirrors remember and serve the most recent
  735. network-status document they have from each authority. Other
  736. network-status documents don't need to be stored. If the most recent
  737. network-status document is over 10 days old, it is discarded anyway.
  738. Mirrors SHOULD store and serve network-status documents from authorities
  739. they don't recognize, but SHOULD NOT use such documents for any other
  740. purpose. Mirrors SHOULD discard network-status documents older than 48
  741. hours.
  742. 4.3. Downloading and storing router descriptors (authorities and caches)
  743. Periodically (currently, every 10 seconds), directory servers check
  744. whether there are any specific descriptors (as identified by descriptor
  745. hash in a network-status document) that they do not have and that they
  746. are not currently trying to download.
  747. If so, the directory server launches requests to the authorities for these
  748. descriptors, such that each authority is only asked for descriptors listed
  749. in its most recent network-status. When more than one authority lists the
  750. descriptor, we choose which to ask at random.
  751. If one of these downloads fails, we do not try to download that descriptor
  752. from the authority that failed to serve it again unless we receive a newer
  753. network-status from that authority that lists the same descriptor.
  754. Directory servers must potentially cache multiple descriptors for each
  755. router. Servers must not discard any descriptor listed by any current
  756. network-status document from any authority. If there is enough space to
  757. store additional descriptors, servers SHOULD try to hold those which
  758. clients are likely to download the most. (Currently, this is judged
  759. based on the interval for which each descriptor seemed newest.)
  760. Authorities SHOULD NOT download descriptors for routers that they would
  761. immediately reject for reasons listed in 3.1.
  762. 4.4. HTTP URLs
  763. "Fingerprints" in these URLs are base-16-encoded SHA1 hashes.
  764. The authoritative network-status published by a host should be available at:
  765. http://<hostname>/tor/status/authority.z
  766. The network-status published by a host with fingerprint
  767. <F> should be available at:
  768. http://<hostname>/tor/status/fp/<F>.z
  769. The network-status documents published by hosts with fingerprints
  770. <F1>,<F2>,<F3> should be available at:
  771. http://<hostname>/tor/status/fp/<F1>+<F2>+<F3>.z
  772. The most recent network-status documents from all known authorities,
  773. concatenated, should be available at:
  774. http://<hostname>/tor/status/all.z
  775. The most recent descriptor for a server whose identity key has a
  776. fingerprint of <F> should be available at:
  777. http://<hostname>/tor/server/fp/<F>.z
  778. The most recent descriptors for servers with identity fingerprints
  779. <F1>,<F2>,<F3> should be available at:
  780. http://<hostname>/tor/server/fp/<F1>+<F2>+<F3>.z
  781. (NOTE: Implementations SHOULD NOT download descriptors by identity key
  782. fingerprint. This allows a corrupted server (in collusion with a cache) to
  783. provide a unique descriptor to a client, and thereby partition that client
  784. from the rest of the network.)
  785. The server descriptor with (descriptor) digest <D> (in hex) should be
  786. available at:
  787. http://<hostname>/tor/server/d/<D>.z
  788. The most recent descriptors with digests <D1>,<D2>,<D3> should be
  789. available at:
  790. http://<hostname>/tor/server/d/<D1>+<D2>+<D3>.z
  791. The most recent descriptor for this server should be at:
  792. http://<hostname>/tor/server/authority.z
  793. [Nothing in the Tor protocol uses this resource yet, but it is useful
  794. for debugging purposes. Also, the official Tor implementations
  795. (starting at 0.1.1.x) use this resource to test whether a server's
  796. own DirPort is reachable.]
  797. A concatenated set of the most recent descriptors for all known servers
  798. should be available at:
  799. http://<hostname>/tor/server/all.z
  800. For debugging, directories SHOULD expose non-compressed objects at URLs like
  801. the above, but without the final ".z".
  802. Clients MUST handle compressed concatenated information in two forms:
  803. - A concatenated list of zlib-compressed objects.
  804. - A zlib-compressed concatenated list of objects.
  805. Directory servers MAY generate either format: the former requires less
  806. CPU, but the latter requires less bandwidth.
  807. Clients SHOULD use upper case letters (A-F) when base16-encoding
  808. fingerprints. Servers MUST accept both upper and lower case fingerprints
  809. in requests.
  810. 5. Client operation: downloading information
  811. Every Tor that is not a directory server (that is, those that do
  812. not have a DirPort set) implements this section.
  813. 5.1. Downloading network-status documents
  814. Each client maintains an ordered list of directory authorities.
  815. Insofar as possible, clients SHOULD all use the same ordered list.
  816. For each network-status document a client has, it keeps track of its
  817. publication time *and* the time when the client retrieved it. Clients
  818. consider a network-status document "live" if it was published within the
  819. last 24 hours.
  820. Clients try to have a live network-status document hours from *every*
  821. authority, and try to periodically get new network-status documents from
  822. each authority in rotation as follows:
  823. If a client is missing a live network-status document for any
  824. authority, it tries to fetch it from a directory cache. On failure,
  825. the client waits briefly, then tries that network-status document
  826. again from another cache. The client does not build circuits until it
  827. has live network-status documents from more than half the authorities
  828. it trusts, and it has descriptors for more than 1/4 of the routers
  829. that it believes are running.
  830. If the most recently _retrieved_ network-status document is over 30
  831. minutes old, the client attempts to download a network-status document.
  832. When choosing which documents to download, clients treat their list of
  833. directory authorities as a circular ring, and begin with the authority
  834. appearing immediately after the authority for their most recently
  835. retrieved network-status document. If this attempt fails, the client
  836. retries at other caches several times, before moving on to the next
  837. network-status document in sequence.
  838. Clients discard all network-status documents over 24 hours old.
  839. If enough mirrors (currently 4) claim not to have a given network status,
  840. we stop trying to download that authority's network-status, until we
  841. download a new network-status that makes us believe that the authority in
  842. question is running. Clients should wait a little longer after each
  843. failure.
  844. Clients SHOULD try to batch as many network-status requests as possible
  845. into each HTTP GET.
  846. (Note: clients can and should pick caches based on the network-status
  847. information they have: once they have first fetched network-status info
  848. from an authority, they should not need to go to the authority directly
  849. again.)
  850. 5.2. Downloading and storing router descriptors
  851. Clients try to have the best descriptor for each router. A descriptor is
  852. "best" if:
  853. * It is the most recently published descriptor listed for that router
  854. by at least two network-status documents.
  855. OR,
  856. * No descriptor for that router is listed by two or more
  857. network-status documents, and it is the most recently published
  858. descriptor listed by any network-status document.
  859. Periodically (currently every 10 seconds) clients check whether there are
  860. any "downloadable" descriptors. A descriptor is downloadable if:
  861. - It is the "best" descriptor for some router.
  862. - The descriptor was published at least 10 minutes in the past.
  863. (This prevents clients from trying to fetch descriptors that the
  864. mirrors have probably not yet retrieved and cached.)
  865. - The client does not currently have it.
  866. - The client is not currently trying to download it.
  867. - The client would not discard it immediately upon receiving it.
  868. - The client thinks it is running and valid (see 6.1 below).
  869. If at least 16 known routers have downloadable descriptors, or if
  870. enough time (currently 10 minutes) has passed since the last time the
  871. client tried to download descriptors, it launches requests for all
  872. downloadable descriptors, as described in 5.3 below.
  873. When a descriptor download fails, the client notes it, and does not
  874. consider the descriptor downloadable again until a certain amount of time
  875. has passed. (Currently 0 seconds for the first failure, 60 seconds for the
  876. second, 5 minutes for the third, 10 minutes for the fourth, and 1 day
  877. thereafter.) Periodically (currently once an hour) clients reset the
  878. failure count.
  879. No descriptors are downloaded until the client has downloaded more than
  880. half of the network-status documents.
  881. Clients retain the most recent descriptor they have downloaded for each
  882. router so long as it is not too old (currently, 48 hours), OR so long as
  883. it is recommended by at least one networkstatus AND no "better"
  884. descriptor has been downloaded. [Versions of Tor before 0.1.2.3-alpha
  885. would discard descriptors simply for being published too far in the past.]
  886. [The code seems to discard descriptors in all cases after they're 5
  887. days old. True? -RD]
  888. 5.3. Managing downloads
  889. When a client has no live network-status documents, it downloads
  890. network-status documents from a randomly chosen authority. In all other
  891. cases, the client downloads from mirrors randomly chosen from among those
  892. believed to be V2 directory servers. (This information comes from the
  893. network-status documents; see 6 below.)
  894. When downloading multiple router descriptors, the client chooses multiple
  895. mirrors so that:
  896. - At least 3 different mirrors are used, except when this would result
  897. in more than one request for under 4 descriptors.
  898. - No more than 128 descriptors are requested from a single mirror.
  899. - Otherwise, as few mirrors as possible are used.
  900. After choosing mirrors, the client divides the descriptors among them
  901. randomly.
  902. After receiving any response client MUST discard any network-status
  903. documents and descriptors that it did not request.
  904. 6. Using directory information
  905. Everyone besides directory authorities uses the approaches in this section
  906. to decide which servers to use and what their keys are likely to be.
  907. (Directory authorities just believe their own opinions, as in 3.1 above.)
  908. 6.1. Choosing routers for circuits.
  909. Tor implementations only pay attention to "live" network-status documents.
  910. A network status is "live" if it is the most recently downloaded network
  911. status document for a given directory server, and the server is a
  912. directory server trusted by the client, and the network-status document is
  913. no more than 1 day old.
  914. For time-sensitive information, Tor implementations focus on "recent"
  915. network-status documents. A network status is "recent" if it is live, and
  916. if it was published in the last 60 minutes. If there are fewer
  917. than 3 such documents, the most recently published 3 are "recent." If
  918. there are fewer than 3 in all, all are "recent.")
  919. Circuits SHOULD NOT be built until the client has enough directory
  920. information: network-statuses (or failed attempts to download
  921. network-statuses) for all authorities, network-statuses for at more than
  922. half of the authorites, and descriptors for at least 1/4 of the servers
  923. believed to be running.
  924. A server is "listed" if it is included by more than half of the live
  925. network status documents. Clients SHOULD NOT use unlisted servers.
  926. Clients believe the flags "Valid", "Exit", "Fast", "Guard", "Stable", and
  927. "V2Dir" about a given router when they are asserted by more than half of
  928. the live network-status documents. Clients believe the flag "Running" if
  929. it is listed by more than half of the recent network-status documents.
  930. These flags are used as follows:
  931. - Clients SHOULD NOT use non-'Valid' or non-'Running' routers unless
  932. requested to do so.
  933. - Clients SHOULD NOT use non-'Fast' routers for any purpose other than
  934. very-low-bandwidth circuits (such as introduction circuits).
  935. - Clients SHOULD NOT use non-'Stable' routers for circuits that are
  936. likely to need to be open for a very long time (such as those used for
  937. IRC or SSH connections).
  938. - Clients SHOULD NOT choose non-'Guard' nodes when picking entry guard
  939. nodes.
  940. - Clients SHOULD NOT download directory information from non-'V2Dir'
  941. caches.
  942. 6.2. Managing naming
  943. In order to provide human-memorable names for individual server
  944. identities, some directory servers bind names to IDs. Clients handle
  945. names in two ways:
  946. When a client encounters a name it has not mapped before:
  947. If all the live "Naming" network-status documents the client has
  948. claim that the name binds to some identity ID, and the client has at
  949. least three live network-status documents, the client maps the name to
  950. ID.
  951. When a user tries to refer to a router with a name that does not have a
  952. mapping under the above rules, the implementation SHOULD warn the user.
  953. After giving the warning, the implementation MAY use a router that at
  954. least one Naming authority maps the name to, so long as no other naming
  955. authority maps that name to a different router. If no Naming authority
  956. maps the name to a router, the implementation MAY use any router that
  957. advertises the name.
  958. Not every router needs a nickname. When a router doesn't configure a
  959. nickname, it publishes with the default nickname "Unnamed". Authorities
  960. SHOULD NOT ever mark a router with this nickname as Named; client software
  961. SHOULD NOT ever use a router in response to a user request for a router
  962. called "Unnamed".
  963. 6.3. Software versions
  964. An implementation of Tor SHOULD warn when it has fetched (or has
  965. attempted to fetch and failed four consecutive times) a network-status
  966. for each authority, and it is running a software version
  967. not listed on more than half of the live "Versioning" network-status
  968. documents.
  969. 6.4. Warning about a router's status.
  970. If a router tries to publish its descriptor to a Naming authority
  971. that has its nickname mapped to another key, the router SHOULD
  972. warn the operator that it is either using the wrong key or is using
  973. an already claimed nickname.
  974. If a router has fetched (or attempted to fetch and failed four
  975. consecutive times) a network-status for every authority, and at
  976. least one of the authorities is "Naming", and no live "Naming"
  977. authorities publish a binding for the router's nickname, the
  978. router MAY remind the operator that the chosen nickname is not
  979. bound to this key at the authorities, and suggest contacting the
  980. authority operators.
  981. ...
  982. 6.5. Router protocol versions
  983. A client should believe that a router supports a given feature if that
  984. feature is supported by the router or protocol versions in more than half
  985. of the live networkstatus's "v" entries for that router. In other words,
  986. if the "v" entries for some router are:
  987. v Tor 0.0.8pre1 (from authority 1)
  988. v Tor 0.1.2.11 (from authority 2)
  989. v FutureProtocolDescription 99 (from authority 3)
  990. then the client should believe that the router supports any feature
  991. supported by 0.1.2.11.
  992. This is currently equivalent to believing the median declared version for
  993. a router in all live networkstatuses.
  994. 7. Standards compliance
  995. All clients and servers MUST support HTTP 1.0.
  996. 7.1. HTTP headers
  997. Servers MAY set the Content-Length: header. Servers SHOULD set
  998. Content-Encoding to "deflate" or "identity".
  999. Servers MAY include an X-Your-Address-Is: header, whose value is the
  1000. apparent IP address of the client connecting to them (as a dotted quad).
  1001. For directory connections tunneled over a BEGIN_DIR stream, servers SHOULD
  1002. report the IP from which the circuit carrying the BEGIN_DIR stream reached
  1003. them. [Servers before version 0.1.2.5-alpha reported 127.0.0.1 for all
  1004. BEGIN_DIR-tunneled connections.]
  1005. Servers SHOULD disable caching of multiple network statuses or multiple
  1006. router descriptors. Servers MAY enable caching of single descriptors,
  1007. single network statuses, the list of all router descriptors, a v1
  1008. directory, or a v1 running routers document. XXX mention times.
  1009. 7.2. HTTP status codes
  1010. XXX We should write down what return codes dirservers send in what situations.
  1011. 8. Backward compatibility and migration plans