dir-spec.txt 68 KB

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