tor-spec.txt 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. $Id$
  2. TOR Spec
  3. Note: This is an attempt to specify TOR as it exists as implemented in
  4. early June, 2003. It is not recommended that others implement this
  5. design as it stands; future versions of TOR will implement improved
  6. protocols.
  7. 0. Notation:
  8. PK -- a public key.
  9. SK -- a private key
  10. K -- a key for a symmetric cypher
  11. a|b -- concatenation of 'a' with 'b'.
  12. a[i:j] -- Bytes 'i' through 'j'-1 (inclusive) of the string a.
  13. All numeric values are encoded in network (big-endian) order.
  14. Unless otherwise specified, all symmetric ciphers are 3DES in OFB
  15. mode, with an IV of all 0 bytes. Asymmetric ciphers are either RSA
  16. with 1024-bit keys and exponents of 65537, or DH with the safe prime
  17. from rfc2409, section 6.2, whose hex representation is:
  18. "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E08"
  19. "8A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B"
  20. "302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9"
  21. "A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE6"
  22. "49286651ECE65381FFFFFFFFFFFFFFFF"
  23. [We will move to AES once we can assume everybody will have it. -RD]
  24. 1. System overview
  25. Tor is a connection-oriented anonymizing communication service. Users
  26. build a path known as a "virtual circuit" through the network, in which
  27. each node knows its predecessor and successor, but no others. Traffic
  28. flowing down the circuit is unwrapped by a symmetric key at each node,
  29. which reveals the downstream node.
  30. 2. Connections
  31. 2.1. Establishing OR connections
  32. When one onion router opens a connection to another, the initiating
  33. OR (called the 'client') and the listening OR (called the 'server')
  34. perform the following handshake.
  35. [or when an op wants to connect to or]
  36. Before the handshake begins, the client and server know one
  37. another's (1024-bit) public keys, IPV4 addresses, and ports.
  38. 1. Client connects to server:
  39. The client generates a pair of 8-byte symmetric keys (one
  40. [K_f] for the 'forward' stream from client to server, and one
  41. [K_b] for the 'backward' stream from server to client.
  42. The client then generates a 'Client authentication' message [M]
  43. containing:
  44. The number 2 to signify OR handshake [2 bytes]
  45. The client's published IPV4 address [4 bytes]
  46. The client's published port [2 bytes]
  47. The server's published IPV4 address [4 bytes]
  48. The server's published port [2 bytes]
  49. The forward key (K_f) [16 bytes]
  50. The backward key (K_f) [16 bytes]
  51. The maximum bandwidth (bytes/s) [4 bytes]
  52. [Total: 50 bytes]
  53. The client then RSA-encrypts [M] with the server's public key
  54. and PKCS1 padding to give an encrypted message.
  55. The client then opens a TCP connection to the server, sends
  56. the 128-byte RSA-encrypted data to the server, and waits for a
  57. reply.
  58. 2. Server authenticates to client:
  59. Upon receiving a TCP connection, the server waits to receive
  60. 128 bytes from the client. It decrypts the message with its
  61. private key, and checks the PKCS1 padding. If the padding is
  62. incorrect, or if the message's length is other than 50 bytes,
  63. the server closes the TCP connection and stops handshaking.
  64. The server then checks the list of known ORs for one with the
  65. address and port given in the client's authentication. If no
  66. such OR is known, or if the server is already connected to
  67. that OR, the server closes the current TCP connection and
  68. stops handshaking.
  69. For later use, the server sets its keys for this connection,
  70. setting K_f to the client's K_b, and K_b to the client's K_f.
  71. The server then creates a server authentication message[M2] as
  72. follows:
  73. Modified client authentication [48 bytes]
  74. A random nonce [N] [8 bytes]
  75. [Total: 56 bytes]
  76. The client authentication is generated from M by replacing
  77. the client's preferred bandwidth [B_c] with the server's
  78. preferred bandwidth [B_s], if B_s < B_c.
  79. The server encrypts M2 with the client's public key (found
  80. from the list of known routers), using PKCS1 padding.
  81. The server sends the 128-byte encrypted message to the client,
  82. and waits for a reply.
  83. 3. Client authenticates to server.
  84. Once the client has received 128 bytes, it decrypts them with
  85. its public key, and checks the PKCS1 padding. If the padding
  86. is invalid, or the decrypted message's length is other than 56
  87. bytes, the client closes the TCP connection.
  88. The client checks that the addresses and keys in the reply
  89. message are the same as the ones it originally sent. If not,
  90. it closes the TCP connection.
  91. The client updates the connection's bandwidth to that set by
  92. the server, and generates the following authentication message [M3]:
  93. The client's published IPV4 address [4 bytes]
  94. The client's published port [2 bytes]
  95. The server's published IPV4 address [4 bytes]
  96. The server's published port [2 bytes]
  97. The server-generated nonce [N] [8 bytes]
  98. [Total: 20 bytes]
  99. Once again, the client encrypts this message using the
  100. server's public key and PKCS1 padding, and sends the resulting
  101. 128-byte message to the server.
  102. 4. Server checks client authentication
  103. The server once again waits to receive 128 bytes from the
  104. client, decrypts the message with its private key, and checks
  105. the PKCS1 padding. If the padding is incorrect, or if the
  106. message's length is other than 20 bytes, the server closes the
  107. TCP connection and stops handshaking.
  108. If the addresses in the decrypted message M3 match those in M
  109. and M2, and if the nonce in M3 is the same as in M2, the
  110. handshake is complete, and the client and server begin sending
  111. cells to one another. Otherwise, the server closes the TCP
  112. connection.
  113. 2.2. Establishing OP-to-OR connections
  114. [wrap this with the above]
  115. When an Onion Proxy (OP) needs to establish a connection to an OR,
  116. the handshake is simpler because the OR does not need to verify the
  117. OP's identity. The OP and OR establish the following steps:
  118. 1. OP connects to OR:
  119. First, the OP generates a pair of 8-byte symmetric keys (one
  120. [K_f] for the 'forward' stream from OP to OR, and one
  121. [K_b] for the 'backward' stream from OR to OP).
  122. The OP generates a message [M] in the following format:
  123. The number 1 to signify OP handshake [2 bytes]
  124. Maximum bandwidth (bytes/s) [4 bytes]
  125. Forward key [K_f] [16 bytes]
  126. Backward key [K_b] [16 bytes]
  127. [Total: 38 bytes]
  128. The OP encrypts M with the OR's public key and PKCS1 padding,
  129. opens a TCP connection to the OR's TCP port, and sends the
  130. resulting 128-byte encrypted message to the OR.
  131. 2. OR receives keys:
  132. When the OR receives a connection from an OP [This is on a
  133. different port, right? How does it know the difference? -NM],
  134. [Correct. The 'or_port' config variable specifies the OR port,
  135. and the op_port variable specified the OP port. -RD]
  136. it waits for 128 bytes of data, and decrypts the resulting
  137. data with its private key, checking the PKCS1 padding. If the
  138. padding is invalid, or the message is not 38 bytes long, the
  139. OR closes the connection.
  140. Otherwise, the connection is established, and the OR is ready
  141. to receive cells.
  142. The server sets its keys for this connection, setting K_f to
  143. the client's K_b, and K_b to the client's K_f.
  144. 2.3. Sending cells and link encryption
  145. Once the handshake is complete, the ORs or OR and OP send cells
  146. (specified below) to one another. Cells are sent serially,
  147. encrypted with the 3DES-OFB keystream specified by the handshake
  148. protocol. Over a connection, communicants encrypt outgoing cells
  149. with the connection's K_f, and decrypt incoming cells with the
  150. connection's K_b.
  151. [Commentary: This means that OR/OP->OR connections are malleable; I
  152. can flip bits in cells as they go across the wire, and see flipped
  153. bits coming out the cells as they are decrypted at the next
  154. server. I need to look more at the data format to see whether
  155. this is exploitable, but if there's no integrity checking there
  156. either, I suspect we may have an attack here. -NM]
  157. [Yes, this protocol is open to tagging attacks. The payloads are
  158. encrypted inside the network, so it's only at the edge node and beyond
  159. that it's a worry. But adversaries can already count packets and
  160. observe/modify timing. It's not worth putting in hashes; indeed, it
  161. would be quite hard, because one of the sides of the circuit doesn't
  162. know the keys that are used for de/encrypting at each hop, so couldn't
  163. craft hashes anyway. See the Bandwidth Throttling (threat model)
  164. thread on http://archives.seul.org/or/dev/Jul-2002/threads.html. -RD]
  165. [Even if I don't control both sides of the connection, I can still
  166. do evil stuff. For instance, if I can guess that a cell is a
  167. TOPIC_COMMAND_BEGIN cell to www.slashdot.org:80 , I can change the
  168. address and port to point to a machine I control. -NM]
  169. 3. Cell Packet format
  170. The basic unit of communication for onion routers and onion
  171. proxies is a fixed-width "cell". Each cell contains the following
  172. fields:
  173. ACI (anonymous circuit identifier) [2 bytes]
  174. Command [1 byte]
  175. Length [1 byte]
  176. Sequence number (unused, set to 0) [4 bytes]
  177. Payload (padded with 0 bytes) [248 bytes]
  178. [Total size: 256 bytes]
  179. The 'Command' field holds one of the following values:
  180. 0 -- PADDING (Padding) (See Sec 6.2)
  181. 1 -- CREATE (Create a circuit) (See Sec 4)
  182. 2 -- CREATED (Acknowledge create) (See Sec 4)
  183. 3 -- RELAY (End-to-end data) (See Sec 5)
  184. 4 -- DESTROY (Stop using a circuit) (See Sec 4)
  185. The interpretation of 'Length' and 'Payload' depend on the type of
  186. the cell.
  187. PADDING: Neither field is used.
  188. CREATE: Length is 144; the payload contains the first phase of the
  189. DH handshake.
  190. CREATED: Length is 128; the payload contains the second phase of
  191. the DH handshake.
  192. RELAY: Length is a value between 8 and 248; the first 'length'
  193. bytes of payload contain useful data.
  194. DESTROY: Neither field is used.
  195. Unused fields are filled with 0 bytes. The payload is padded with
  196. 0 bytes.
  197. PADDING cells are currently used to implement connection
  198. keepalive. ORs and OPs send one another a PADDING cell every few
  199. minutes.
  200. CREATE and DESTROY cells are used to manage circuits; see section
  201. 4 below.
  202. RELAY cells are used to send commands and data along a circuit; see
  203. section 5 below.
  204. 4. Circuit management
  205. 4.1. CREATE and CREATED cells
  206. Users set up circuits incrementally, one hop at a time. To create
  207. a new circuit, users send a CREATE cell to the first node, with the
  208. first half of the DH handshake; that node responds with a CREATED cell
  209. with the second half of the DH handshake. To extend a circuit past
  210. the first hop, the user sends an EXTEND relay cell (see section 5)
  211. which instructs the last node in the circuit to send a CREATE cell
  212. to extend the circuit.
  213. The payload for a CREATE cell is an 'onion skin', consisting of:
  214. RSA-encrypted data [128 bytes]
  215. Symmetrically-encrypted data [16 bytes]
  216. The RSA-encrypted portion contains:
  217. Symmetric key [16 bytes]
  218. First part of DH data (g^x) [112 bytes]
  219. The symmetrically encrypted portion contains:
  220. Second part of DH data (g^x) [16 bytes]
  221. The two parts of the DH data, once decrypted and concatenated, form
  222. g^x as calculated by the client.
  223. The relay payload for an EXTEND relay cell consists of:
  224. Address [4 bytes]
  225. Port [2 bytes]
  226. Onion skin [144 bytes]
  227. The port and address field denote the IPV4 address and port of the
  228. next onion router in the circuit.
  229. 4.2. Setting circuit keys
  230. Once the handshake between the OP and an OR is completed, both
  231. servers can now calculate g^xy with ordinary DH. They divide the
  232. last 32 bytes of this shared secret into two 16-byte keys, the
  233. first of which (called Kf) is used to encrypt the stream of data
  234. going from the OP to the OR, and second of which (called Kb) is
  235. used to encrypt the stream of data going from the OR to the OP.
  236. 4.3. Creating circuits
  237. When creating a circuit through the network, the circuit creator
  238. performs the following steps:
  239. 1. Choose a chain of N onion routers (R_1...R_N) to constitute
  240. the path, such that no router appears in the path twice.
  241. 2. If not already connected to the first router in the chain,
  242. open a new connection to that router.
  243. 3. Choose an ACI not already in use on the connection with the
  244. first router in the chain. If our address/port pair is
  245. numerically higher than the address/port pair of the other
  246. side, then let the high bit of the ACI be 1, else 0.
  247. 4. Send a CREATE cell along the connection, to be received by
  248. the first onion router.
  249. 5. Wait until a CREATED cell is received; finish the handshake
  250. and extract the forward key Kf_1 and the back key Kb_1.
  251. 6. For each subsequent onion router R (R_2 through R_N), extend
  252. the circuit to R.
  253. To extend the circuit by a single onion router R_M, the circuit
  254. creator performs these steps:
  255. 1. Create an onion skin, encrypting the RSA-encrypted part with
  256. R's public key.
  257. 2. Encrypt and send the onion skin in a RELAY_CREATE cell along
  258. the circuit (see section 5).
  259. 3. When a RELAY_CREATED cell is received, calculate the shared
  260. keys. The circuit is now extended.
  261. Upon receiving a CREATE cell along a connection, an OR performs
  262. the following steps:
  263. 1. If we already have an 'open' circuit along this connection
  264. with this ACI, drop the cell.
  265. Otherwise, if we have no circuit along this connection with
  266. this ACI, let L = the integer value of the first 4 bytes of
  267. the payload. Create a half-open circuit with this ACI, and
  268. begin queueing CREATE cells for this circuit.
  269. Otherwise, we have a half-open circuit. If the total payload
  270. length of the CREATE cells for this circuit is exactly equal
  271. to the onion length specified in the first cell (minus 4), then
  272. process the onion. If it is more, then tear down the circuit.
  273. 2. Once we have a complete onion, decrypt the first 128 bytes
  274. of the onion with this OR's RSA private key, and extract
  275. the outmost onion layer. If the version, back cipher, or
  276. forward cipher is unrecognized, or the expiration time is
  277. in the past, then tear down the circuit (see section 4.2).
  278. Compute K1 through K3 as above. Use K1 to decrypt the rest
  279. of the onion using 3DES/OFB.
  280. If we are not the exit node, remove the first layer from the
  281. decrypted onion, and send the remainder to the next OR
  282. on the circuit, as specified above. (Note that we'll
  283. choose a different ACI for this circuit on the connection
  284. with the next OR.)
  285. When an onion router receives an EXTEND relay cell, it sends a
  286. CREATE cell to the next onion router, with the enclosed onion skin
  287. as its payload. The initiating onion router chooses some random
  288. ACI not yet used on the connection between the two onion routers.
  289. Some time after receiving a create cell, an onion router completes
  290. the DH handshake, and replies with a CREATED cell, containing g^y
  291. as its [128 byte] payload. Upon receiving a CREATED cell, an onion
  292. router packs it payload into an EXTENDED relay cell (see section 5),
  293. and sends that cell up the circuit. Upon receiving the EXTENDED
  294. relay cell, the OP can retrieve g^y.
  295. (As an optimization, OR implementations may delay processing onions
  296. until a break in traffic allows time to do so without harming
  297. network latency too greatly.)
  298. 4.2. Tearing down circuits
  299. [Note: this section is untouched; the code doesn't seem to match
  300. what I remembered discussing. Let's sort it out. -NM]
  301. Circuits are torn down when an unrecoverable error occurs along
  302. the circuit, or when all streams on a circuit are closed and the
  303. circuit's intended lifetime is over.
  304. To tear down a circuit, an OR or OP sends a DESTROY cell with that
  305. direction's ACI to the adjacent nodes on that circuit.
  306. Upon receiving a DESTROY cell, an OR frees resources associated
  307. with the corresponding circuit. If it's not the start or end of the
  308. circuit, it sends a DESTROY cell for that circuit to the next OR in
  309. the circuit. If the node is the start or end of the circuit, then
  310. it tears down any associated edge connections (see section 5.1).
  311. After a DESTROY cell has been processed, an OR ignores all data or
  312. destroy cells for the corresponding circuit.
  313. 4.3. Routing data cells
  314. When an OR receives a RELAY cell, it checks the cell's ACI and
  315. determines whether it has a corresponding circuit along that
  316. connection. If not, the OR drops the RELAY cell.
  317. Otherwise, if the OR is not at the OP edge of the circuit (that is,
  318. either an 'exit node' or a non-edge node), it de/encrypts the length
  319. field and the payload with 3DES/OFB, as follows:
  320. 'Forward' relay cell (same direction as CREATE):
  321. Use Kf as key; encrypt.
  322. 'Back' relay cell (opposite direction from CREATE):
  323. Use Kb as key; decrypt.
  324. If the OR recognizes the stream ID on the cell (it is either the ID
  325. of an open stream or the signaling (zero) ID), the OR processes the
  326. contents of the relay cell. Otherwise, it passes the decrypted
  327. relay cell along the circuit if the circuit continues, or drops the
  328. cell if it's the end of the circuit. [Getting an unrecognized
  329. relay cell at the end of the circuit must be allowed for now;
  330. we can reexamine this once we've designed full tcp-style close
  331. handshakes. -RD]
  332. Otherwise, if the data cell is coming from the OP edge of the
  333. circuit, the OP decrypts the length and payload fields with 3DES/OFB as
  334. follows:
  335. OP sends data cell to node R_M:
  336. For I=1...M, decrypt with Kf_I.
  337. Otherwise, if the data cell is arriving at the OP edge if the
  338. circuit, the OP encrypts the length and payload fields with 3DES/OFB as
  339. follows:
  340. OP receives data cell:
  341. For I=N...1,
  342. Encrypt with Kb_I. If the stream ID is a recognized
  343. stream for R_I, or if the stream ID is the signaling
  344. ID (zero), then stop and process the payload.
  345. For more information, see section 5 below.
  346. 5. Application connections and stream management
  347. 5.1. Streams
  348. Within a circuit, the OP and the exit node use the contents of
  349. RELAY packets to tunnel end-to-end commands and TCP connections
  350. ("Streams") across circuits. End-to-end commands can be initiated
  351. by either edge; streams are initiated by the OP.
  352. The first 8 bytes of each relay cell are reserved as follows:
  353. Relay command [1 byte]
  354. Stream ID [7 bytes]
  355. The recognized relay commands are:
  356. 1 -- RELAY_BEGIN
  357. 2 -- RELAY_DATA
  358. 3 -- RELAY_END
  359. 4 -- RELAY_CONNECTED
  360. 5 -- RELAY_SENDME
  361. 6 -- RELAY_EXTEND
  362. 7 -- RELAY_EXTENDED
  363. All RELAY cells pertaining to the same tunneled stream have the
  364. same stream ID. Stream ID's are chosen randomly by the OP. A
  365. stream ID is considered "recognized" on a circuit C by an OP or an
  366. OR if it already has an existing stream established on that
  367. circuit, or if the stream ID is equal to the signaling stream ID,
  368. which is all zero: [00 00 00 00 00 00 00]
  369. To create a new anonymized TCP connection, the OP sends a
  370. RELAY_BEGIN data cell with a payload encoding the address and port
  371. of the destination host. The stream ID is zero. The payload format is:
  372. ADDRESS | ':' | PORT | '\000'
  373. where ADDRESS may be a DNS hostname, or an IPv4 address in
  374. dotted-quad format; and where PORT is encoded in decimal.
  375. Upon receiving this packet, the exit node resolves the address as
  376. necessary, and opens a new TCP connection to the target port. If
  377. the address cannot be resolved, or a connection can't be
  378. established, the exit node replies with a RELAY_END cell.
  379. Otherwise, the exit node replies with a RELAY_CONNECTED cell.
  380. The OP waits for a RELAY_CONNECTED cell before sending any data.
  381. Once a connection has been established, the OP and exit node
  382. package stream data in RELAY_DATA cells, and upon receiving such
  383. cells, echo their contents to the corresponding TCP stream.
  384. [XXX Mention zlib encoding. -NM]
  385. When one side of the TCP stream is closed, the corresponding edge
  386. node sends a RELAY_END cell along the circuit; upon receiving a
  387. RELAY_END cell, the edge node closes the corresponding TCP stream.
  388. [This should probably become:
  389. When one side of the TCP stream is closed, the corresponding edge
  390. node sends a RELAY_END cell along the circuit; upon receiving a
  391. RELAY_END cell, the edge node closes its side of the corresponding
  392. TCP stream (by sending a FIN packet), but continues to accept and
  393. package incoming data until both sides of the TCP stream are
  394. closed. At that point, the edge node sends a second RELAY_END
  395. cell, and drops its record of the topic. -NM]
  396. For creation and handling of RELAY_EXTEND and RELAY_EXTENDED cells,
  397. see section 4. For creating and handling of RELAY_SENDME cells,
  398. see section 6.
  399. 6. Flow control
  400. 6.1. Link throttling
  401. As discussed above in section 2.1, ORs and OPs negotiate a maximum
  402. bandwidth upon startup. The communicants only read up to that
  403. number of bytes per second on average, though they may use mechanisms
  404. to handle spikes (eg token buckets).
  405. Communicants rely on TCP's default flow control to push back when they
  406. stop reading, so nodes that don't obey this bandwidth limit can't do
  407. too much damage.
  408. 6.2. Link padding
  409. Currently nodes are not required to do any sort of link padding or
  410. dummy traffic. Because strong attacks exist even with link padding,
  411. and because link padding greatly increases the bandwidth requirements
  412. for running a node, we plan to leave out link padding until this
  413. tradeoff is better understood.
  414. 6.3. Circuit flow control
  415. To control a circuit's bandwidth usage, each node keeps track of
  416. two 'windows', consisting of how many RELAY_DATA cells it is
  417. allowed to package for transmission, and how many RELAY_DATA cells
  418. it is willing to deliver to a stream outside the network.
  419. Each 'window' value is initially set to 500 data cells
  420. in each direction (cells that are not data cells do not affect
  421. the window).
  422. [Note: I'm not touching the rest of this section... it looks in the
  423. code as if RELAY_COMMAND_SENDME is now doing double duty for both
  424. stream flow control and circuit flow control. I thought we wanted
  425. two different notions of windows. -NM]
  426. [We do have two different 'levels' of windows. The relay sendme command
  427. is talking about a stream for non-zero stream id, and talking about
  428. the circuit for zero stream id. -RD]
  429. Each edge node on a circuit sends a SENDME cell
  430. (with length=100) every time it has received 100 data cells on the
  431. circuit. When a node receives a SENDME cell for a circuit, it increases
  432. the circuit's window in the corresponding direction (that is, for
  433. sending data cells back in the direction from which the sendme arrived)
  434. by the value of the cell's length field. If it's not an edge node,
  435. it passes an equivalent SENDME cell to the next node in the circuit.
  436. If the window value reaches 0 at the edge of a circuit, the OR stops
  437. reading from the edge connections. (It may finish processing what
  438. it's already read, and queue those cells for when a SENDME cell
  439. arrives.) Otherwise (when not at the edge of a circuit), if the
  440. window value is 0 and a data cell arrives, the node must tear down
  441. the circuit.
  442. 6.4. Topic flow control
  443. Edge nodes use RELAY_SENDME data cells to implement end-to-end flow
  444. control for individual connections across circuits. As with circuit
  445. flow control, edge nodes begin with a window of cells (500) per
  446. topic, and increment the window by a fixed value (50) upon receiving
  447. a RELAY_SENDME data cell. Edge nodes initiate TOPIC_SENDME data
  448. cells when both a) the window is <= 450, and b) there are less than
  449. ten cell payloads remaining to be flushed at that edge.
  450. 7. Directories and routers
  451. 7.1. Router descriptor format.
  452. (Unless otherwise noted, tokens on the same line are space-separated.)
  453. Router ::= Router-Line Public-Key Signing-Key? Exit-Policy NL
  454. Router-Line ::= "router" address ORPort OPPort APPort DirPort bandwidth
  455. NL
  456. Public-key ::= a public key in PEM format NL
  457. Signing-Key ::= "signing-key" NL signing key in PEM format NL
  458. Exit-Policy ::= Exit-Line*
  459. Exit-Line ::= ("accept"|"reject") string NL
  460. ORport ::= port where the router listens for other routers (speaking cells)
  461. OPPort ::= where the router listens for onion proxies (speaking cells)
  462. APPort ::= where the router listens for applications (speaking socks)
  463. DirPort ::= where the router listens for directory download requests
  464. bandwidth ::= maximum bandwidth, in bytes/s
  465. Example:
  466. router moria.mit.edu 9001 9011 9021 9031 100000
  467. -----BEGIN RSA PUBLIC KEY-----
  468. MIGJAoGBAMBBuk1sYxEg5jLAJy86U3GGJ7EGMSV7yoA6mmcsEVU3pwTUrpbpCmwS
  469. 7BvovoY3z4zk63NZVBErgKQUDkn3pp8n83xZgEf4GI27gdWIIwaBjEimuJlEY+7K
  470. nZ7kVMRoiXCbjL6VAtNa4Zy1Af/GOm0iCIDpholeujQ95xew7rQnAgMA//8=
  471. -----END RSA PUBLIC KEY-----
  472. signing-key
  473. -----BEGIN RSA PUBLIC KEY-----
  474. 7BvovoY3z4zk63NZVBErgKQUDkn3pp8n83xZgEf4GI27gdWIIwaBjEimuJlEY+7K
  475. MIGJAoGBAMBBuk1sYxEg5jLAJy86U3GGJ7EGMSV7yoA6mmcsEVU3pwTUrpbpCmwS
  476. f/GOm0iCIDpholeujQ95xew7rnZ7kVMRoiXCbjL6VAtNa4Zy1AQnAgMA//8=
  477. -----END RSA PUBLIC KEY-----
  478. reject 18.0.0.0/24
  479. Note: The extra newline at the end of the router block is intentional.
  480. 7.2. Directory format
  481. Directory ::= Directory-Header Directory-Router Router* Signature
  482. Directory-Header ::= "signed-directory" NL Software-Line NL
  483. Software-Line: "recommended-software" comma-separated-version-list
  484. Directory-Router ::= Router
  485. Signature ::= "directory-signature" NL "-----BEGIN SIGNATURE-----" NL
  486. Base-64-encoded-signature NL "-----END SIGNATURE-----" NL
  487. Note: The router block for the directory server must appear first.
  488. The signature is computed by computing the SHA-1 hash of the
  489. directory, from the characters "signed-directory", through the newline
  490. after "directory-signature". This digest is then padded with PKCS.1,
  491. and signed with the directory server's signing key.