rend-spec.txt 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. Tor Rendezvous Specification
  2. 0. Overview and preliminaries
  3. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
  4. NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
  5. "OPTIONAL" in this document are to be interpreted as described in
  6. RFC 2119.
  7. Read
  8. https://www.torproject.org/doc/design-paper/tor-design.html#sec:rendezvous
  9. before you read this specification. It will make more sense.
  10. Rendezvous points provide location-hidden services (server
  11. anonymity) for the onion routing network. With rendezvous points,
  12. Bob can offer a TCP service (say, a webserver) via the onion
  13. routing network, without revealing the IP of that service.
  14. Bob does this by anonymously advertising a public key for his
  15. service, along with a list of onion routers to act as "Introduction
  16. Points" for his service. He creates forward circuits to those
  17. introduction points, and tells them about his public key. To
  18. connect to Bob, Alice first builds a circuit to an OR to act as
  19. her "Rendezvous Point." She then connects to one of Bob's chosen
  20. introduction points, optionally provides authentication or
  21. authorization information, and asks it to tell him about her Rendezvous
  22. Point (RP). If Bob chooses to answer, he builds a circuit to her
  23. RP, and tells it to connect him to Alice. The RP joins their
  24. circuits together, and begins relaying cells. Alice's 'BEGIN'
  25. cells are received directly by Bob's OP, which passes data to
  26. and from the local server implementing Bob's service.
  27. Below we describe a network-level specification of this service,
  28. along with interfaces to make this process transparent to Alice
  29. (so long as she is using an OP).
  30. 0.1. Notation, conventions and prerequisites
  31. In the specifications below, we use the same notation and terminology
  32. as in "tor-spec.txt". The service specified here also requires the
  33. existence of an onion routing network as specified in that file.
  34. H(x) is a SHA1 digest of x.
  35. PKSign(SK,x) is a PKCS.1-padded RSA signature of x with SK.
  36. PKEncrypt(SK,x) is a PKCS.1-padded RSA encryption of x with SK.
  37. Public keys are all RSA, and encoded in ASN.1.
  38. All integers are stored in network (big-endian) order.
  39. All symmetric encryption uses AES in counter mode, except where
  40. otherwise noted.
  41. In all discussions, "Alice" will refer to a user connecting to a
  42. location-hidden service, and "Bob" will refer to a user running a
  43. location-hidden service.
  44. An OP is (as defined elsewhere) an "Onion Proxy" or Tor client.
  45. An OR is (as defined elsewhere) an "Onion Router" or Tor server.
  46. An "Introduction point" is a Tor server chosen to be Bob's medium-term
  47. 'meeting place'. A "Rendezvous point" is a Tor server chosen by Alice to
  48. be a short-term communication relay between her and Bob. All Tor servers
  49. potentially act as introduction and rendezvous points.
  50. 0.2. Protocol outline
  51. 1. Bob->Bob's OP: "Offer IP:Port as
  52. public-key-name:Port". [configuration]
  53. (We do not specify this step; it is left to the implementor of
  54. Bob's OP.)
  55. 2. Bob's OP generates keypair and rendezvous service descriptor:
  56. "Meet public-key X at introduction point A, B, or C." (signed)
  57. 3. Bob's OP->Introduction point via Tor: [introduction setup]
  58. "This pk is me."
  59. 4. Bob's OP->directory service via Tor: publishes Bob's service
  60. descriptor [advertisement]
  61. 5. Out of band, Alice receives a [x.y.]z.onion:port address.
  62. She opens a SOCKS connection to her OP, and requests
  63. x.y.z.onion:port.
  64. 6. Alice's OP retrieves Bob's descriptor via Tor. [descriptor lookup.]
  65. 7. Alice's OP chooses a rendezvous point, opens a circuit to that
  66. rendezvous point, and establishes a rendezvous circuit. [rendezvous
  67. setup.]
  68. 8. Alice connects to the Introduction point via Tor, and tells it about
  69. her rendezvous point and optional authentication/authorization
  70. information. (Encrypted to Bob.) [Introduction 1]
  71. 9. The Introduction point passes this on to Bob's OP via Tor, along the
  72. introduction circuit. [Introduction 2]
  73. 10. Bob's OP decides whether to connect to Alice, and if so, creates a
  74. circuit to Alice's RP via Tor. Establishes a shared circuit.
  75. [Rendezvous.]
  76. 11. Alice's OP sends begin cells to Bob's OP. [Connection]
  77. 0.3. Constants and new cell types
  78. Relay cell types
  79. 32 -- RELAY_COMMAND_ESTABLISH_INTRO
  80. 33 -- RELAY_COMMAND_ESTABLISH_RENDEZVOUS
  81. 34 -- RELAY_COMMAND_INTRODUCE1
  82. 35 -- RELAY_COMMAND_INTRODUCE2
  83. 36 -- RELAY_COMMAND_RENDEZVOUS1
  84. 37 -- RELAY_COMMAND_RENDEZVOUS2
  85. 38 -- RELAY_COMMAND_INTRO_ESTABLISHED
  86. 39 -- RELAY_COMMAND_RENDEZVOUS_ESTABLISHED
  87. 40 -- RELAY_COMMAND_INTRODUCE_ACK
  88. 0.4. Version overview
  89. There are several parts in the hidden service protocol that have
  90. changed over time, each of them having its own version number, whereas
  91. other parts remained the same. The following list of potentially
  92. versioned protocol parts should help reduce some confusion:
  93. - Hidden service descriptor: the binary-based v0 was the default for
  94. a long time, and an ascii-based v2 has been added by proposal
  95. 114. See 1.3.
  96. - Hidden service descriptor propagation mechanism: currently related to
  97. the hidden service descriptor version -- v0 publishes to the original
  98. hs directory authorities, whereas v2 publishes to a rotating subset
  99. of relays with the "hsdir" flag; see 1.4 and 1.6.
  100. - Introduction protocol for how to generate an introduction cell:
  101. v0 specified a nickname for the rendezvous point and assumed the
  102. relay would know about it, whereas v2 now specifies IP address,
  103. port, and onion key so the relay doesn't need to already recognize
  104. it. See 1.8.
  105. 1. The Protocol
  106. 1.1. Bob configures his local OP.
  107. We do not specify a format for the OP configuration file. However,
  108. OPs SHOULD allow Bob to provide more than one advertised service
  109. per OP, and MUST allow Bob to specify one or more virtual ports per
  110. service. Bob provides a mapping from each of these virtual ports
  111. to a local IP:Port pair.
  112. 1.2. Bob's OP establishes his introduction points.
  113. The OP establishes a new introduction circuit to each introduction
  114. point. These circuits MUST NOT be used for anything but hidden service
  115. introduction. To establish the introduction, Bob sends a
  116. RELAY_COMMAND_ESTABLISH_INTRO cell, containing:
  117. KL Key length [2 octets]
  118. PK Bob's public key [KL octets]
  119. HS Hash of session info [20 octets]
  120. SIG Signature of above information [variable]
  121. [XXX011, need to add auth information here. -RD]
  122. To prevent replay attacks, the HS field contains a SHA-1 hash based on the
  123. shared secret KH between Bob's OP and the introduction point, as
  124. follows:
  125. HS = H(KH | "INTRODUCE")
  126. That is:
  127. HS = H(KH | [49 4E 54 52 4F 44 55 43 45])
  128. (KH, as specified in tor-spec.txt, is H(g^xy | [00]) .)
  129. Upon receiving such a cell, the OR first checks that the signature is
  130. correct with the included public key. If so, it checks whether HS is
  131. correct given the shared state between Bob's OP and the OR. If either
  132. check fails, the OP discards the cell; otherwise, it associates the
  133. circuit with Bob's public key, and dissociates any other circuits
  134. currently associated with PK. On success, the OR sends Bob a
  135. RELAY_COMMAND_INTRO_ESTABLISHED cell with an empty payload.
  136. If a hidden service is configured to publish only v2 hidden service
  137. descriptors, Bob's OP does not include its own public key in the
  138. RELAY_COMMAND_ESTABLISH_INTRO cell, but the public key of a freshly
  139. generated key pair. The OP also includes these fresh public keys in the v2
  140. hidden service descriptor together with the other introduction point
  141. information. The reason is that the introduction point does not need to
  142. and therefore should not know for which hidden service it works, so as
  143. to prevent it from tracking the hidden service's activity. If the hidden
  144. service is configured to publish both, v0 and v2 descriptors, two
  145. separate sets of introduction points are established.
  146. 1.3. Bob's OP generates service descriptors.
  147. The first time the OP provides an advertised service, it generates
  148. a public/private keypair (stored locally).
  149. Beginning with 0.2.0.10-alpha, Bob's OP encodes "V2" descriptors. The
  150. format of a "V2" descriptor is as follows:
  151. "rendezvous-service-descriptor" descriptor-id NL
  152. [At start, exactly once]
  153. Indicates the beginning of the descriptor. "descriptor-id" is a
  154. periodically changing identifier of 160 bits formatted as 32 base32
  155. chars that is calculated by the hidden service and its clients. If
  156. the optional "descriptor-cookie" is used, this "descriptor-id"
  157. cannot be computed by anyone else. (Everyone can verify that this
  158. "descriptor-id" belongs to the rest of the descriptor, even without
  159. knowing the optional "descriptor-cookie", as described below.) The
  160. "descriptor-id" is calculated by performing the following operation:
  161. descriptor-id =
  162. H(permanent-id | H(time-period | descriptor-cookie | replica))
  163. "permanent-id" is the permanent identifier of the hidden service,
  164. consisting of 80 bits. It can be calculated by computing the hash value
  165. of the public hidden service key and truncating after the first 80 bits:
  166. permanent-id = H(public-key)[:10]
  167. "H(time-period | descriptor-cookie | replica)" is the (possibly
  168. secret) id part that is
  169. necessary to verify that the hidden service is the true originator
  170. of this descriptor. It can only be created by the hidden service
  171. and its clients, but the "signature" below can only be created by
  172. the service.
  173. "descriptor-cookie" is an optional secret password of 128 bits that
  174. is shared between the hidden service provider and its clients.
  175. "replica" denotes the number of the non-consecutive replica.
  176. (Each descriptor is replicated on a number of _consecutive_ nodes
  177. in the identifier ring by making every storing node responsible
  178. for the identifier intervals starting from its 3rd predecessor's
  179. ID to its own ID. In addition to that, every service publishes
  180. multiple descriptors with different descriptor IDs in order to
  181. distribute them to different places on the ring. Therefore,
  182. "replica" chooses one of the _non-consecutive_ replicas. -KL)
  183. The "time-period" changes periodically depending on the global time and
  184. as a function of "permanent-id". The current value for "time-period" can
  185. be calculated using the following formula:
  186. time-period = (current-time + permanent-id-byte * 86400 / 256)
  187. / 86400
  188. "current-time" contains the current system time in seconds since
  189. 1970-01-01 00:00, e.g. 1188241957. "permanent-id-byte" is the first
  190. (unsigned) byte of the permanent identifier (which is in network
  191. order), e.g. 143. Adding the product of "permanent-id-byte" and
  192. 86400 (seconds per day), divided by 256, prevents "time-period" from
  193. changing for all descriptors at the same time of the day. The result
  194. of the overall operation is a (network-ordered) 32-bit integer, e.g.
  195. 13753 or 0x000035B9 with the example values given above.
  196. "version" version-number NL
  197. [Exactly once]
  198. The version number of this descriptor's format. In this case: 2.
  199. "permanent-key" NL a public key in PEM format
  200. [Exactly once]
  201. The public key of the hidden service which is required to verify the
  202. "descriptor-id" and the "signature".
  203. "secret-id-part" secret-id-part NL
  204. [Exactly once]
  205. The result of the following operation as explained above, formatted as
  206. 32 base32 chars. Using this secret id part, everyone can verify that
  207. the signed descriptor belongs to "descriptor-id".
  208. secret-id-part = H(time-period | descriptor-cookie | replica)
  209. "publication-time" YYYY-MM-DD HH:MM:SS NL
  210. [Exactly once]
  211. A timestamp when this descriptor has been created.
  212. "protocol-versions" version-string NL
  213. [Exactly once]
  214. A comma-separated list of recognized and permitted version numbers
  215. for use in INTRODUCE cells; these versions are described in section
  216. 1.8 below.
  217. "introduction-points" NL encrypted-string
  218. [At most once]
  219. A list of introduction points. If the optional "descriptor-cookie" is
  220. used, this list is encrypted with AES in CTR mode with a random
  221. initialization vector of 128 bits that is written to
  222. the beginning of the encrypted string, and the "descriptor-cookie" as
  223. secret key of 128 bits length.
  224. The string containing the introduction point data (either encrypted
  225. or not) is encoded in base64, and surrounded with
  226. "-----BEGIN MESSAGE-----" and "-----END MESSAGE-----".
  227. The unencrypted string may begin with:
  228. ["service-authentication" auth-type NL auth-data ... reserved]
  229. [At start, any number]
  230. The service-specific authentication data can be used to perform
  231. client authentication. This data is independent of the selected
  232. introduction point as opposed to "intro-authentication" below.
  233. Subsequently, an arbitrary number of introduction point entries may
  234. follow, each containing the following data:
  235. "introduction-point" identifier NL
  236. [At start, exactly once]
  237. The identifier of this introduction point: the base-32 encoded
  238. hash of this introduction point's identity key.
  239. "ip-address" ip-address NL
  240. [Exactly once]
  241. The IP address of this introduction point.
  242. "onion-port" port NL
  243. [Exactly once]
  244. The TCP port on which the introduction point is listening for
  245. incoming onion requests.
  246. "onion-key" NL a public key in PEM format
  247. [Exactly once]
  248. The public key that can be used to encrypt messages to this
  249. introduction point.
  250. "service-key" NL a public key in PEM format
  251. [Exactly once]
  252. The public key that can be used to encrypt messages to the hidden
  253. service.
  254. ["intro-authentication" auth-type NL auth-data ... reserved]
  255. [Any number]
  256. The introduction-point-specific authentication data can be used
  257. to perform client authentication. This data depends on the
  258. selected introduction point as opposed to "service-authentication"
  259. above.
  260. (This ends the fields in the encrypted portion of the descriptor.)
  261. [It's ok for Bob to advertise 0 introduction points. He might want
  262. to do that if he previously advertised some introduction points,
  263. and now he doesn't have any. -RD]
  264. "signature" NL signature-string
  265. [At end, exactly once]
  266. A signature of all fields above with the private key of the hidden
  267. service.
  268. 1.3.1. Other descriptor formats we don't use.
  269. Support for the V0 descriptor format was dropped in 0.2.2.0-alpha-dev:
  270. KL Key length [2 octets]
  271. PK Bob's public key [KL octets]
  272. TS A timestamp [4 octets]
  273. NI Number of introduction points [2 octets]
  274. Ipt A list of NUL-terminated ORs [variable]
  275. SIG Signature of above fields [variable]
  276. KL is the length of PK, in octets.
  277. TS is the number of seconds elapsed since Jan 1, 1970.
  278. The members of Ipt may be either (a) nicknames, or (b) identity key
  279. digests, encoded in hex, and prefixed with a '$'.
  280. The V1 descriptor format was understood and accepted from
  281. 0.1.1.5-alpha-cvs to 0.2.0.6-alpha-dev, but no Tors generated it and
  282. it was removed:
  283. V Format byte: set to 255 [1 octet]
  284. V Version byte: set to 1 [1 octet]
  285. KL Key length [2 octets]
  286. PK Bob's public key [KL octets]
  287. TS A timestamp [4 octets]
  288. PROTO Protocol versions: bitmask [2 octets]
  289. NI Number of introduction points [2 octets]
  290. For each introduction point: (as in INTRODUCE2 cells)
  291. IP Introduction point's address [4 octets]
  292. PORT Introduction point's OR port [2 octets]
  293. ID Introduction point identity ID [20 octets]
  294. KLEN Length of onion key [2 octets]
  295. KEY Introduction point onion key [KLEN octets]
  296. SIG Signature of above fields [variable]
  297. A hypothetical "V1" descriptor, that has never been used but might
  298. be useful for historical reasons, contains:
  299. V Format byte: set to 255 [1 octet]
  300. V Version byte: set to 1 [1 octet]
  301. KL Key length [2 octets]
  302. PK Bob's public key [KL octets]
  303. TS A timestamp [4 octets]
  304. PROTO Rendezvous protocol versions: bitmask [2 octets]
  305. NA Number of auth mechanisms accepted [1 octet]
  306. For each auth mechanism:
  307. AUTHT The auth type that is supported [2 octets]
  308. AUTHL Length of auth data [1 octet]
  309. AUTHD Auth data [variable]
  310. NI Number of introduction points [2 octets]
  311. For each introduction point: (as in INTRODUCE2 cells)
  312. ATYPE An address type (typically 4) [1 octet]
  313. ADDR Introduction point's IP address [4 or 16 octets]
  314. PORT Introduction point's OR port [2 octets]
  315. AUTHT The auth type that is supported [2 octets]
  316. AUTHL Length of auth data [1 octet]
  317. AUTHD Auth data [variable]
  318. ID Introduction point identity ID [20 octets]
  319. KLEN Length of onion key [2 octets]
  320. KEY Introduction point onion key [KLEN octets]
  321. SIG Signature of above fields [variable]
  322. AUTHT specifies which authentication/authorization mechanism is
  323. required by the hidden service or the introduction point. AUTHD
  324. is arbitrary data that can be associated with an auth approach.
  325. Currently only AUTHT of [00 00] is supported, with an AUTHL of 0.
  326. See section 2 of this document for details on auth mechanisms.
  327. 1.4. Bob's OP advertises his service descriptor(s).
  328. Bob's OP opens a stream to each directory server's directory port via Tor.
  329. (He may re-use old circuits for this.) Over this stream, Bob's OP makes
  330. an HTTP 'POST' request, to a URL "/tor/rendezvous/publish" relative to the
  331. directory server's root, containing as its body Bob's service descriptor.
  332. Bob should upload a service descriptor for each version format that
  333. is supported in the current Tor network.
  334. Upon receiving a descriptor, the directory server checks the signature,
  335. and discards the descriptor if the signature does not match the enclosed
  336. public key. Next, the directory server checks the timestamp. If the
  337. timestamp is more than 24 hours in the past or more than 1 hour in the
  338. future, or the directory server already has a newer descriptor with the
  339. same public key, the server discards the descriptor. Otherwise, the
  340. server discards any older descriptors with the same public key and
  341. version format, and associates the new descriptor with the public key.
  342. The directory server remembers this descriptor for at least 24 hours
  343. after its timestamp. At least every 18 hours, Bob's OP uploads a
  344. fresh descriptor.
  345. Bob's OP publishes v2 descriptors to a changing subset of all v2 hidden
  346. service directories. Therefore, Bob's OP opens a stream via Tor to each
  347. responsible hidden service directory. (He may re-use old circuits
  348. for this.) Over this stream, Bob's OP makes an HTTP 'POST' request to a
  349. URL "/tor/rendezvous2/publish" relative to the hidden service
  350. directory's root, containing as its body Bob's service descriptor.
  351. At any time, there are 6 hidden service directories responsible for
  352. keeping replicas of a descriptor; they consist of 2 sets of 3 hidden
  353. service directories with consecutive onion IDs. Bob's OP learns about
  354. the complete list of hidden service directories by filtering the
  355. consensus status document received from the directory authorities. A
  356. hidden service directory is deemed responsible for all descriptor IDs in
  357. the interval from its direct predecessor, exclusive, to its own ID,
  358. inclusive; it further holds replicas for its 2 predecessors. A
  359. participant only trusts its own routing list and never learns about
  360. routing information from other parties.
  361. Bob's OP publishes a new v2 descriptor once an hour or whenever its
  362. content changes. V2 descriptors can be found by clients within a given
  363. time period of 24 hours, after which they change their ID as described
  364. under 1.3. If a published descriptor would be valid for less than 60
  365. minutes (= 2 x 30 minutes to allow the server to be 30 minutes behind
  366. and the client 30 minutes ahead), Bob's OP publishes the descriptor
  367. under the ID of both, the current and the next publication period.
  368. 1.5. Alice receives a x.y.z.onion address.
  369. When Alice receives a pointer to a location-hidden service, it is as a
  370. hostname of the form "z.onion" or "y.z.onion" or "x.y.z.onion", where
  371. z is a base-32 encoding of a 10-octet hash of Bob's service's public
  372. key, computed as follows:
  373. 1. Let H = H(PK).
  374. 2. Let H' = the first 80 bits of H, considering each octet from
  375. most significant bit to least significant bit.
  376. 2. Generate a 16-character encoding of H', using base32 as defined
  377. in RFC 3548.
  378. (We only use 80 bits instead of the 160 bits from SHA1 because we
  379. don't need to worry about arbitrary collisions, and because it will
  380. make handling the url's more convenient.)
  381. The string "x", if present, is the base-32 encoding of the
  382. authentication/authorization required by the introduction point.
  383. The string "y", if present, is the base-32 encoding of the
  384. authentication/authorization required by the hidden service.
  385. Omitting a string is taken to mean auth type [00 00].
  386. See section 2 of this document for details on auth mechanisms.
  387. [Yes, numbers are allowed at the beginning. See RFC 1123. -NM]
  388. 1.6. Alice's OP retrieves a service descriptor.
  389. Similarly to the description in section 1.4, Alice's OP fetches a v2
  390. descriptor from a randomly chosen hidden service directory out of the
  391. changing subset of 6 nodes. If the request is unsuccessful, Alice retries
  392. the other remaining responsible hidden service directories in a random
  393. order. Alice relies on Bob to care about a potential clock skew between
  394. the two by possibly storing two sets of descriptors (see end of section
  395. 1.4).
  396. Alice's OP opens a stream via Tor to the chosen v2 hidden service
  397. directory. (She may re-use old circuits for this.) Over this stream,
  398. Alice's OP makes an HTTP 'GET' request for the document
  399. "/tor/rendezvous2/<z>", where z is replaced with the encoding of the
  400. descriptor ID. The directory replies with a 404 HTTP response if it does
  401. not recognize <z>, and otherwise returns Bob's most recently uploaded
  402. service descriptor.
  403. If Alice's OP receives a 404 response, it tries the other directory
  404. servers, and only fails the lookup if none recognize the public key hash.
  405. Upon receiving a service descriptor, Alice verifies with the same process
  406. as the directory server uses, described above in section 1.4.
  407. The directory server gives a 400 response if it cannot understand Alice's
  408. request.
  409. Alice should cache the descriptor locally, but should not use
  410. descriptors that are more than 24 hours older than their timestamp.
  411. [Caching may make her partitionable, but she fetched it anonymously,
  412. and we can't very well *not* cache it. -RD]
  413. 1.7. Alice's OP establishes a rendezvous point.
  414. When Alice requests a connection to a given location-hidden service,
  415. and Alice's OP does not have an established circuit to that service,
  416. the OP builds a rendezvous circuit. It does this by establishing
  417. a circuit to a randomly chosen OR, and sending a
  418. RELAY_COMMAND_ESTABLISH_RENDEZVOUS cell to that OR. The body of that cell
  419. contains:
  420. RC Rendezvous cookie [20 octets]
  421. [XXX011 this looks like an auth mechanism. should we generalize here? -RD]
  422. The rendezvous cookie is an arbitrary 20-byte value, chosen randomly by
  423. Alice's OP.
  424. Upon receiving a RELAY_COMMAND_ESTABLISH_RENDEZVOUS cell, the OR associates
  425. the RC with the circuit that sent it. It replies to Alice with an empty
  426. RELAY_COMMAND_RENDEZVOUS_ESTABLISHED cell to indicate success.
  427. Alice's OP MUST NOT use the circuit which sent the cell for any purpose
  428. other than rendezvous with the given location-hidden service.
  429. 1.8. Introduction: from Alice's OP to Introduction Point
  430. Alice builds a separate circuit to one of Bob's chosen introduction
  431. points, and sends it a RELAY_COMMAND_INTRODUCE1 cell containing:
  432. Cleartext
  433. PK_ID Identifier for Bob's PK [20 octets]
  434. Encrypted to Bob's PK: (in the v0 intro protocol)
  435. RP Rendezvous point's nickname [20 octets]
  436. RC Rendezvous cookie [20 octets]
  437. g^x Diffie-Hellman data, part 1 [128 octets]
  438. OR (in the v1 intro protocol)
  439. VER Version byte: set to 1. [1 octet]
  440. RP Rendezvous point nick or ID [42 octets]
  441. RC Rendezvous cookie [20 octets]
  442. g^x Diffie-Hellman data, part 1 [128 octets]
  443. OR (in the v2 intro protocol)
  444. VER Version byte: set to 2. [1 octet]
  445. IP Rendezvous point's address [4 octets]
  446. PORT Rendezvous point's OR port [2 octets]
  447. ID Rendezvous point identity ID [20 octets]
  448. KLEN Length of onion key [2 octets]
  449. KEY Rendezvous point onion key [KLEN octets]
  450. RC Rendezvous cookie [20 octets]
  451. g^x Diffie-Hellman data, part 1 [128 octets]
  452. PK_ID is the hash of Bob's public key. RP is NUL-padded and
  453. terminated. In version 0, it must contain a nickname. In version 1,
  454. it must contain EITHER a nickname or an identity key digest that is
  455. encoded in hex and prefixed with a '$'.
  456. The hybrid encryption to Bob's PK works just like the hybrid
  457. encryption in CREATE cells (see tor-spec). Thus the payload of the
  458. version 0 RELAY_COMMAND_INTRODUCE1 cell on the wire will contain
  459. 20+42+16+20+20+128=246 bytes, and the version 1 and version 2
  460. introduction formats have other sizes.
  461. Through Tor 0.2.0.6-alpha, clients only generated the v0 introduction
  462. format, whereas hidden services have understood and accepted v0,
  463. v1, and v2 since 0.1.1.x. As of Tor 0.2.0.7-alpha and 0.1.2.18,
  464. clients switched to using the v2 intro format.
  465. If Alice has downloaded a v2 descriptor, she uses the contained public
  466. key ("service-key") instead of Bob's public key to create the
  467. RELAY_COMMAND_INTRODUCE1 cell as described above.
  468. 1.8.1. Other introduction formats we don't use.
  469. We briefly speculated about using the following format for the
  470. "encrypted to Bob's PK" part of the introduction, but no Tors have
  471. ever generated these.
  472. VER Version byte: set to 3. [1 octet]
  473. ATYPE An address type (typically 4) [1 octet]
  474. ADDR Rendezvous point's IP address [4 or 16 octets]
  475. PORT Rendezvous point's OR port [2 octets]
  476. AUTHT The auth type that is supported [2 octets]
  477. AUTHL Length of auth data [1 octet]
  478. AUTHD Auth data [variable]
  479. ID Rendezvous point identity ID [20 octets]
  480. KLEN Length of onion key [2 octets]
  481. KEY Rendezvous point onion key [KLEN octets]
  482. RC Rendezvous cookie [20 octets]
  483. g^x Diffie-Hellman data, part 1 [128 octets]
  484. 1.9. Introduction: From the Introduction Point to Bob's OP
  485. If the Introduction Point recognizes PK_ID as a public key which has
  486. established a circuit for introductions as in 1.2 above, it sends the body
  487. of the cell in a new RELAY_COMMAND_INTRODUCE2 cell down the corresponding
  488. circuit. (If the PK_ID is unrecognized, the RELAY_COMMAND_INTRODUCE1 cell is
  489. discarded.)
  490. After sending the RELAY_COMMAND_INTRODUCE2 cell, the OR replies to Alice
  491. with an empty RELAY_COMMAND_INTRODUCE_ACK cell. If no
  492. RELAY_COMMAND_INTRODUCE2 cell can be sent, the OR replies to Alice with a
  493. non-empty cell to indicate an error. (The semantics of the cell body may be
  494. determined later; the current implementation sends a single '1' byte on
  495. failure.)
  496. When Bob's OP receives the RELAY_COMMAND_INTRODUCE2 cell, it decrypts it
  497. with the private key for the corresponding hidden service, and extracts the
  498. rendezvous point's nickname, the rendezvous cookie, and the value of g^x
  499. chosen by Alice.
  500. 1.10. Rendezvous
  501. Bob's OP builds a new Tor circuit ending at Alice's chosen rendezvous
  502. point, and sends a RELAY_COMMAND_RENDEZVOUS1 cell along this circuit,
  503. containing:
  504. RC Rendezvous cookie [20 octets]
  505. g^y Diffie-Hellman [128 octets]
  506. KH Handshake digest [20 octets]
  507. (Bob's OP MUST NOT use this circuit for any other purpose.)
  508. If the RP recognizes RC, it relays the rest of the cell down the
  509. corresponding circuit in a RELAY_COMMAND_RENDEZVOUS2 cell, containing:
  510. g^y Diffie-Hellman [128 octets]
  511. KH Handshake digest [20 octets]
  512. (If the RP does not recognize the RC, it discards the cell and
  513. tears down the circuit.)
  514. When Alice's OP receives a RELAY_COMMAND_RENDEZVOUS2 cell on a circuit which
  515. has sent a RELAY_COMMAND_ESTABLISH_RENDEZVOUS cell but which has not yet
  516. received a reply, it uses g^y and H(g^xy) to complete the handshake as in
  517. the Tor circuit extend process: they establish a 60-octet string as
  518. K = SHA1(g^xy | [00]) | SHA1(g^xy | [01]) | SHA1(g^xy | [02])
  519. and generate
  520. KH = K[0..15]
  521. Kf = K[16..31]
  522. Kb = K[32..47]
  523. Subsequently, the rendezvous point passes relay cells, unchanged, from
  524. each of the two circuits to the other. When Alice's OP sends
  525. RELAY cells along the circuit, it first encrypts them with the
  526. Kf, then with all of the keys for the ORs in Alice's side of the circuit;
  527. and when Alice's OP receives RELAY cells from the circuit, it decrypts
  528. them with the keys for the ORs in Alice's side of the circuit, then
  529. decrypts them with Kb. Bob's OP does the same, with Kf and Kb
  530. interchanged.
  531. 1.11. Creating streams
  532. To open TCP connections to Bob's location-hidden service, Alice's OP sends
  533. a RELAY_COMMAND_BEGIN cell along the established circuit, using the special
  534. address "", and a chosen port. Bob's OP chooses a destination IP and
  535. port, based on the configuration of the service connected to the circuit,
  536. and opens a TCP stream. From then on, Bob's OP treats the stream as an
  537. ordinary exit connection.
  538. [ Except he doesn't include addr in the connected cell or the end
  539. cell. -RD]
  540. Alice MAY send multiple RELAY_COMMAND_BEGIN cells along the circuit, to open
  541. multiple streams to Bob. Alice SHOULD NOT send RELAY_COMMAND_BEGIN cells
  542. for any other address along her circuit to Bob; if she does, Bob MUST reject
  543. them.
  544. 2. Authentication and authorization.
  545. Foo.
  546. 3. Hidden service directory operation
  547. This section has been introduced with the v2 hidden service descriptor
  548. format. It describes all operations of the v2 hidden service descriptor
  549. fetching and propagation mechanism that are required for the protocol
  550. described in section 1 to succeed with v2 hidden service descriptors.
  551. 3.1. Configuring as hidden service directory
  552. Every onion router that has its directory port open can decide whether it
  553. wants to store and serve hidden service descriptors. An onion router which
  554. is configured as such includes the "hidden-service-dir" flag in its router
  555. descriptors that it sends to directory authorities.
  556. The directory authorities include a new flag "HSDir" for routers that
  557. decided to provide storage for hidden service descriptors and that
  558. have been running for at least 24 hours.
  559. 3.2. Accepting publish requests
  560. Hidden service directory nodes accept publish requests for v2 hidden service
  561. descriptors and store them to their local memory. (It is not necessary to
  562. make descriptors persistent, because after restarting, the onion router
  563. would not be accepted as a storing node anyway, because it has not been
  564. running for at least 24 hours.) All requests and replies are formatted as
  565. HTTP messages. Requests are initiated via BEGIN_DIR cells directed to
  566. the router's directory port, and formatted as HTTP POST requests to the URL
  567. "/tor/rendezvous2/publish" relative to the hidden service directory's root,
  568. containing as its body a v2 service descriptor.
  569. A hidden service directory node parses every received descriptor and only
  570. stores it when it thinks that it is responsible for storing that descriptor
  571. based on its own routing table. See section 1.4 for more information on how
  572. to determine responsibility for a certain descriptor ID.
  573. 3.3. Processing fetch requests
  574. Hidden service directory nodes process fetch requests for hidden service
  575. descriptors by looking them up in their local memory. (They do not need to
  576. determine if they are responsible for the passed ID, because it does no harm
  577. if they deliver a descriptor for which they are not (any more) responsible.)
  578. All requests and replies are formatted as HTTP messages. Requests are
  579. initiated via BEGIN_DIR cells directed to the router's directory port,
  580. and formatted as HTTP GET requests for the document "/tor/rendezvous2/<z>",
  581. where z is replaced with the encoding of the descriptor ID.