rend-spec.txt 27 KB

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