Changeset 10560 for dotorg/trunk_fixed/html/beps/bep_0008.html
- Timestamp:
- 02/06/2008 02:55:28 AM (11 months ago)
- Files:
-
- 1 modified
-
dotorg/trunk_fixed/html/beps/bep_0008.html (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dotorg/trunk_fixed/html/beps/bep_0008.html
r10540 r10560 58 58 <p class="topic-title first">Contents</p> 59 59 <ul class="simple"> 60 <li><a class="reference internal" href="#announce-parameter" id="id 7">announce parameter</a></li>61 <li><a class="reference internal" href="#announce-response" id="id 8">announce response</a></li>62 <li><a class="reference internal" href="#peer-list-obfuscation" id="id 9">peer list obfuscation</a></li>63 <li><a class="reference internal" href="#optimizations" id="id1 0">optimizations</a></li>64 <li><a class="reference internal" href="#backwards-compatibility" id="id1 1">backwards compatibility</a></li>65 <li><a class="reference internal" href="#rationale" id="id1 2">rationale</a></li>66 <li><a class="reference internal" href="# id2" id="id13">References</a></li>60 <li><a class="reference internal" href="#announce-parameter" id="id8">Announce Parameter</a></li> 61 <li><a class="reference internal" href="#announce-response" id="id9">Announce Response</a></li> 62 <li><a class="reference internal" href="#peer-list-obfuscation" id="id10">Peer List Obfuscation</a></li> 63 <li><a class="reference internal" href="#optimizations" id="id11">Optimizations</a></li> 64 <li><a class="reference internal" href="#backwards-compatibility" id="id12">Backwards Compatibility</a></li> 65 <li><a class="reference internal" href="#rationale" id="id13">Rationale</a></li> 66 <li><a class="reference internal" href="#references" id="id14">References</a></li> 67 67 </ul> 68 68 </div> 69 69 <p>This extends the tracker protocol to support simple obfuscation of the 70 peers it returns, using the info hash as a shared secret between the70 peers it returns, using the infohash as a shared secret between the 71 71 peer and the tracker. The obfuscation does not provide any security 72 72 against eavesdroppers that know the infohash of the torrent. The goal … … 77 77 <p>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", 78 78 "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are 79 to be interpreted as described in IETF <a class="reference external" href="http://tools.ietf.org/html/rfc2119">RFC 2119</a> <a class="footnote-reference" href="#id 3" id="id4">[1]</a>.</p>79 to be interpreted as described in IETF <a class="reference external" href="http://tools.ietf.org/html/rfc2119">RFC 2119</a> <a class="footnote-reference" href="#id6" id="id7">[5]</a>.</p> 80 80 <div class="section" id="announce-parameter"> 81 <h1> announce parameter</h1>81 <h1>Announce Parameter</h1> 82 82 <p>When using this extension, instead of passing the <tt class="docutils literal"><span class="pre">info_hash</span></tt> parameter 83 83 to the tracker, an <tt class="docutils literal"><span class="pre">sha_ih</span></tt> is passed.</p> … … 94 94 </div> 95 95 <div class="section" id="announce-response"> 96 <h1> announce response</h1>96 <h1>Announce Response</h1> 97 97 <p>If the tracker supports this extension, the response should be exactly the 98 98 same as if the <tt class="docutils literal"><span class="pre">info_hash</span></tt> was passed, except that any field that contains … … 103 103 </div> 104 104 <div class="section" id="peer-list-obfuscation"> 105 <h1> peer list obfuscation</h1>105 <h1>Peer List Obfuscation</h1> 106 106 <p>We distinguish between the <em>tracker peer list</em> and the <em>returned peer 107 107 list</em>. The <em>tracker peer list</em> contains the ip-port pairs of all … … 121 121 recovers the plaintext by generating the same pseudorandom string and 122 122 XOR'ing it with the ciphertext. In generating the pseudorandom 123 string, the tracker and client MUST discard the first 768 bytes. All 124 indices into the pseudorandom string ignore the first 768 bytes, i.e., 125 index 0 refers to the first undiscarded byte.</p> 123 string, the tracker and client MUST discard the first 768 bytes.</p> 126 124 <p>To communicate an initialization vector, the tracker includes in the 127 125 bencoded response the key <tt class="docutils literal"><span class="pre">iv</span></tt> with value set to a byte string … … 131 129 of the infohash are used as the RC4 key. If the tracker provides an 132 130 initialization vector then the RC4 key is generated by appending the 133 vector to the infohash and then hashing with sha1. The first 64 bits 134 of the resulting hash are then used as the RC4 key.</p> 131 vector to the infohash and then hashing with SHA-1. The first 64 bits 132 of the resulting hash are then used as the RC4 key. The string from 133 which the RC4 key is derived whether it be the infohash or the SHA-1 of 134 the initialization vector appended to the infohash is called the 135 <em>intermediate string</em>.</p> 135 136 <p>For example, given infohash <tt class="docutils literal"><span class="pre">aaf4c61ddcc5e8a2dabedef3b482cd9aea9434d</span></tt> 136 137 and initialization vector <tt class="docutils literal"><span class="pre">abcd</span></tt> both represented in hex, the RC4 key 137 138 is derived as follows:</p> 138 139 <pre class="literal-block"> 139 hash= sha1( 'aaf4c61ddcc5e8a2dabedef3b482cd9aea9434dabcd' )140 key = hash[0:64]140 intermediate = sha1( 'aaf4c61ddcc5e8a2dabedef3b482cd9aea9434dabcd' ) 141 key = intermediate[0:64] 141 142 </pre> 142 <p>where [i:j] denotes the ith through jth bit including the ithbut143 excluding the jth. The resulting key in hex is <tt class="docutils literal"><span class="pre">f36e9cae87cf33e0</span></tt>.</p>143 <p>where [i:j] denotes the ith through <em>jth</em> bit including the <em>ith</em> but 144 excluding the <em>jth</em>. The resulting key in hex is <tt class="docutils literal"><span class="pre">f36e9cae87cf33e0</span></tt>.</p> 144 145 <p>A 64-bit key is used to avoid U.S. export restrictions.</p> 145 146 <p>It is RECOMMENDED that the tracker use the initialization vector, and … … 148 149 </div> 149 150 <div class="section" id="optimizations"> 150 <h1> optimizations</h1>151 <h1>Optimizations</h1> 151 152 <p>The described optimizations are OPTIONAL for the tracker, but the 152 corresponding client-side MUST be implemented by thosethat support153 this extension. These extensions hobble the strength of the RC4153 corresponding client-side MUST be implemented by clients that support 154 this extension. These optimizations hobble the strength of the RC4 154 155 encryption in order to improve tracker performance. In the <a class="reference internal" href="#rationale">rationale</a> 155 156 section we discuss why hobbling RC4 is reasonable and in many cases … … 170 171 <p>The tracker MAY also cache the encrypted tracker peer list. To 171 172 support this the tracker must pass two additional keys <em>i</em> and <em>n</em> 172 each with integer values. Decryption starts by XORing from <em>6i</em> bytes 173 for ipv4 (or <em>18i</em> for ipv6) into the pseudorandom string. Assuming 173 each with 32-bit integer values. If the tracker returns <em>i</em> and <em>n</em> 174 then we reserve the first 8 bytes of the RC4 pseudorandom string to 175 obscure <em>i</em> and <em>n</em>. We come back to this momentarily. Decryption 176 starts by XORing from <em>6i</em> bytes for ipv4 (or <em>18i</em> for ipv6) into the 177 pseudorandom string after the discarded and reserved bytes. Assuming 174 178 that the tracker encrypted the tracker peer list starting from the 175 first byte in the pseudorandom string then <em>i</em> also corresponds to the 176 <em>ith</em> ip-port pair in the tracker peer list and the starting point of 177 the copy into the returned request.</p> 179 first byte after the discarded and reserved bytes in the pseudorandom 180 string then <em>i</em> also corresponds to the <em>ith</em> ip-port pair in the 181 tracker peer list and the starting point of the copy into the returned 182 request.</p> 178 183 <p>So that the client and the tracker do not have to generate an 179 184 arbitrarily long pseudorandom string to support large swarms, we 180 185 assume the tracker bounds the length of the pseudorandom string and 181 reports the length in ip-port pairs as the value to key <em>n</em>. We 182 RECOMMEND that <em>n</em> be equal to the length of the tracker peer list or 183 random but within constant factor of the longest peerlist returned by 184 the tracker, whichever is smaller. Thus the tracker encrypts the 185 <em>jth</em> byte of the <em>ith</em> ip-port pair in an ipv4 tracker peer list by 186 XORing with the byte <em>(6i+j)</em> <cite>mod</cite> <em>n</em> bytes into the pseudorandom 187 string.</p> 188 <p>Since providing <em>i</em> and <em>n</em> significantly reduces the cost for an 189 attacker to recover the pseudorandom string, the tracker MUST XOR the 190 value of <em>i</em> with the 32 bits beginning with the 8th least significant 191 byte of the infohash and <em>n</em> with the least significant 32 bits of the 192 infohash. We do not use the first 64 bits of the infohash since the 193 first 64 bits are used as the RC4 key when not specifying an 194 initialization vector.</p> 186 reports the length in ip-port pairs as the value to key <em>n</em>. <em>n</em> 187 excludes reserved and discarded bytes. We RECOMMEND that <em>n</em> be equal 188 to the length of the tracker peer list or random but within constant 189 factor of the longest peerlist returned by the tracker, whichever is 190 smaller. Thus the tracker encrypts the <em>jth</em> byte of the <em>ith</em> 191 ip-port pair in an ipv4 tracker peer list by XORing with the byte 192 <em>(6i+j)</em> <cite>mod</cite> <em>n</em> bytes into the pseudorandom string.</p> 193 <p>Transmitting <em>i</em> and <em>n</em> as plaintext would significantly reduce the 194 cost for an attacker to recover the pseudorandom string. The tracker 195 MUST XOR the value of <em>i</em> with the first 32 bits of the pseudorandom 196 string. The tracker then XORs <em>n</em> with the next 32 bits from the 197 pseudorandom string (see Figure 1).</p> 198 <div class="figure"> 199 <img alt="bep_0008_pseudo.png" src="bep_0008_pseudo.png" /> 200 <p class="caption"><strong>Figure 1:</strong> The first 768 bytes of the RC4 pseudorandom 201 string are discarded. The key <em>i</em> in the tracker response has 202 value <tt class="docutils literal"><span class="pre">x</span> <span class="pre">xor</span> <span class="pre">i</span></tt>. The key <em>n</em> has value <tt class="docutils literal"><span class="pre">y</span> <span class="pre">xor</span> <span class="pre">n</span></tt>.</p> 203 </div> 195 204 <p>We describe encryption in the following example for an ipv4 tracker peer 196 205 list consisting of 3 ip-port pairs, and using an RC4 pseudorandom string 197 206 of length <em>n=2</em>. <em>n</em> is small for purposes of illustration. Also, for the 198 207 purpose of illustration, the tracker returns only 3 peers at a time.</p> 199 <dl class="docutils"> 200 <dt>::</dt> 201 <dd><p class="first">Given the following peer list 202 (208.72.193.86, 6881), (209.81.173.15,14321), (128.213.6.8, 6881)</p> 203 <p>As a packed array represented in hex it becomes</p> 204 <p>d048c1561ae1d151ad0f37f180d506081ae1</p> 205 <p>which we XOR with an RC4 pseudorandom string, e.g.,</p> 206 <p>a496e5f9b83e835013d42226</p> 207 <p>to generate</p> 208 <p class="last">74de24afa2df5201bedb15d72443e3f1a2df</p> 209 </dd> 210 </dl> 208 <pre class="literal-block"> 209 Given the following peer list 210 (208.72.193.86, 6881), (209.81.173.15,14321), (128.213.6.8, 6881) 211 212 As a packed array represented in hex it becomes 213 214 d048c1561ae1d151ad0f37f180d506081ae1 215 216 which we XOR with an RC4 pseudorandom string excluding discarded and 217 reserved bytes, e.g., 218 219 a496e5f9b83e835013d42226 220 221 to generate 222 223 74de24afa2df5201bedb15d72443e3f1a2df 224 </pre> 211 225 <p>Because the RC4 pseudorandom string is shorter than the tracker 212 226 peer list, we wrap to the beginning of the pseudorandom string.</p> 213 <blockquote> 214 <p>In the first response, the tracker would return</p> 215 <p><em>peers=74de24afa2df5201bedb15d7</em>, <em>i=0</em>, <em>n=2</em></p> 216 <p>In the second response, the tracker would return</p> 217 <p><em>peers=5201bedb15d72443e3f1a2df</em>, <em>i=1</em>, <em>n=2</em></p> 218 </blockquote> 227 <p>In the first response, the tracker would return:</p> 228 <pre class="literal-block"> 229 peers=74de24afa2df5201bedb15d7, i=0, n=2 230 </pre> 231 <p>In the second response, the tracker would return:</p> 232 <pre class="literal-block"> 233 peers=5201bedb15d72443e3f1a2df, i=1, n=2 234 </pre> 219 235 <p>The tracker response MUST remain a valid bencoded message.</p> 220 236 </div> 221 237 <div class="section" id="backwards-compatibility"> 222 <h1> backwards compatibility</h1>238 <h1>Backwards Compatibility</h1> 223 239 <p>Trackers that support obfuscation are identified in the .torrent file 224 240 by the inclusion of an <tt class="docutils literal"><span class="pre">obfuscate-announce-list</span></tt> which otherwise has the … … 240 256 in the same request, since that would defeat the purpose of the shared 241 257 secret.</p> 242 <ul class="simple"> 243 <li>any peer that reports a sha_ih is assumed to implement protocol encryption.</li> 244 <li>tracker OPTIONALLY includes a <tt class="docutils literal"><span class="pre">flags</span></tt> key that contains one byte per 245 peer in the reported peer list. The first bit of each byte specifies 246 whether the peer support protocol encryption. (How do we protect 247 the flags field from modification?)</li> 248 <li>if no flags field is present then all peers should be assumed to support protocol encryption</li> 249 <li>if a flags field is present then those peers that support protocol 250 a</li> 251 </ul> 258 <p>Any peer that requests with a <tt class="docutils literal"><span class="pre">sha_ih</span></tt> SHOULD implement Message 259 Stream Encryption (MSE) <a class="footnote-reference" href="#mse" id="id1">[1]</a>. Any peer returned from the tracker 260 in response to a request with a <tt class="docutils literal"><span class="pre">sha_ih</span></tt> SHOULD be assumed to 261 support Message Stream Encryption. We include these provisions 262 because if a peer communicates with another peer without using MSE 263 then the BitTorrent protocol is trivially identified from the first 264 twenty bytes of the BitTorrent header and the <tt class="docutils literal"><span class="pre">info_hash</span></tt> appears in 265 plaintext as the next twenty bytes, hence also defeating the purpose 266 of the shared secret.</p> 267 <p>If the tracker does not know enough peers that support MSE to return 268 the desired number of peers then it MAY include peers that are not 269 assumed to support MSE. If a peer closes a connection in response to 270 an encrypted header then the initiating peer should try other peers in 271 the peer list returning to the peer that closed the connection only 272 when all other peers known or not yet known to support MSE have been 273 tried and have failed to provide "adequate performance." We 274 intentionally omit any definition of "adequate performance."</p> 252 275 </div> 253 276 <div class="section" id="rationale"> 254 <h1> rationale</h1>277 <h1>Rationale</h1> 255 278 <p>This extension directly addresses a known attack on the BitTorrent 256 279 protocol performed by some deployed network hardware. By obscuring … … 262 285 performed such as severely rate limiting or blocking these 263 286 connections.</p> 264 <p>This hardware was presumably deployed to get around <a class="reference external" href="http://www.bittorrent.org/beps/bep_0013.html">BitTorrent265 Protocol Encryption</a> <a class="footnote-reference" href="#id5" id="id6">[2]</a>. Peers implementing BitTorrent Protocol 287 <p>This hardware was presumably deployed to get around BitTorrent 288 Message Stream Encryption <a class="footnote-reference" href="#mse" id="id2">[1]</a>. Peers implementing BitTorrent Message Stream 266 289 Encryption obfuscate peer-to-peer connections by employing RC4 267 290 encryption on every byte from the first byte transferred. BitTorrent 268 ProtocolEncryption thus increases the difficulty for a device291 Message Stream Encryption thus increases the difficulty for a device 269 292 observing passing packets to identify BitTorrent peer-to-peer 270 293 connections.</p> … … 280 303 <p>The obfuscation method meets the following criteria:</p> 281 304 <ul class="simple"> 282 <li>The entire plaintext of the peer list is not easily obtained 283 even if an eavesdropper identifies ip-port pairs from 284 subsequent connections froma peer that has received a tracker response.</li>305 <li>The entire plaintext of the peer list is not easily obtained even if 306 an eavesdropper identifies ip-port pairs from subsequent connections 307 initiated by a peer that has received a tracker response.</li> 285 308 <li>Even when a subsequent connection from a peer that has received a 286 309 tracker response is observed by an eavesdropper, it is difficult to … … 297 320 <p>The objective is NOT to create a cryptographically secure protocol 298 321 that can survive unlimited observation of passing packets and 299 substantial computational resources on network timescales. The object 322 substantial computational resources on network timescales. The objective 300 323 is to raise the bar sufficiently to deter attacks based on observing 301 324 ip-port numbers in peer-to-tracker communications.</p> … … 303 326 and subsequent connections, it is possible to attack the encryption. 304 327 RC4 is known to have a number of weaknesses especially in the way it 305 was used with WEP [and HERE]. However, with tracker peer obfuscation, the 306 number of bytes transferred between the tracker and a client is likely 307 significantly smaller than transfer between a wireless computer and a 308 basestation. An attacker faces a much larger task in obtaining 309 sufficient probable plaintext to directly break the encryption.</p> 328 was used with WEP <a class="footnote-reference" href="#borisov" id="id3">[2]</a> <a class="footnote-reference" href="#scott" id="id4">[3]</a> <a class="footnote-reference" href="#stubblefeld" id="id5">[4]</a>. However, 329 with tracker peer obfuscation, the number of bytes transferred between 330 the tracker and a client is likely significantly smaller than transferred 331 between a wireless computer and a basestation. An attacker faces a 332 much larger task in obtaining sufficient probable plaintext to 333 directly break the encryption.</p> 310 334 <p>Hobbling the RC4 encryption by using a bounded-length RC4 pseudorandom 311 335 string for small swarms is likely to have negilgible impact on … … 333 357 small constant factor more expensive than a shuffle on an input string 334 358 of equal length, 2) the generated pseudorandom string is only <em>n</em> 335 bytes long where recommended <em>n</em> is within a small constant factor 336 larger than the largest response size and thus much smaller than the 337 tracker peer list for large swarms, and 3) the cost of the XOR 338 operation is lighter weight than performing a random shuffle.</p> 359 ip-port pairs long where recommended <em>n</em> is within a small constant 360 factor larger than the largest <em>returned peer list</em> and thus much 361 smaller than the <em>tracker peer list</em> for large swarms, and 3) the cost 362 of the XOR operation is lighter weight than performing a random 363 shuffle.</p> 364 </div> 365 <div class="section" id="references"> 366 <h1>References</h1> 367 <table class="docutils footnote" frame="void" id="mse" rules="none"> 368 <colgroup><col class="label" /><col /></colgroup> 369 <tbody valign="top"> 370 <tr><td class="label">[1]</td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id2">2</a>)</em> BitTorrent Message Stream Encryption 371 (<a class="reference external" href="http://www.azureuswiki.com/index.php/Message_Stream_Encryption">http://www.azureuswiki.com/index.php/Message_Stream_Encryption</a>)</td></tr> 372 </tbody> 373 </table> 374 <table class="docutils footnote" frame="void" id="borisov" rules="none"> 375 <colgroup><col class="label" /><col /></colgroup> 376 <tbody valign="top"> 377 <tr><td class="label"><a class="fn-backref" href="#id3">[2]</a></td><td>Nikita Borisov, Ian Goldberg, and David Wagner. Intercepting 378 mobile communications: the insecurity of 802.11. In ACM MobiCom 2001, 379 pages 180-189. ACM Press, 2001.</td></tr> 380 </tbody> 381 </table> 382 <table class="docutils footnote" frame="void" id="scott" rules="none"> 383 <colgroup><col class="label" /><col /></colgroup> 384 <tbody valign="top"> 385 <tr><td class="label"><a class="fn-backref" href="#id4">[3]</a></td><td>Scott R. Fluhrer, Itsik Mantin, and Adi 386 Shamir. Weaknesses in the key scheduling algorithm of RC4. In Serge 387 Vaudenay and Amr M. Youssef, editors, Selected Areas in 388 Cryptography 2001, volume 2259 of Lecture Notes in Computer 389 Science, pages 1-24. Springer, 2001.</td></tr> 390 </tbody> 391 </table> 392 <table class="docutils footnote" frame="void" id="stubblefeld" rules="none"> 393 <colgroup><col class="label" /><col /></colgroup> 394 <tbody valign="top"> 395 <tr><td class="label"><a class="fn-backref" href="#id5">[4]</a></td><td>Adam Stubblefeld, John Ioannidis, and Aviel 396 D. Rubin. A key recovery attack on the 802.11b wired equivalent 397 privacy protocol (WEP). ACM Transactions on Information and System 398 Security, 7(2):319-332, May 2004.</td></tr> 399 </tbody> 400 </table> 339 401 <!-- Local Variables: 340 402 mode: indented-text … … 344 406 coding: utf-8 345 407 End: --> 346 </div> 347 <div class="section" id="id2"> 348 <h1>References</h1> 349 <table class="docutils footnote" frame="void" id="id3" rules="none"> 408 <table class="docutils footnote" frame="void" id="id6" rules="none"> 350 409 <colgroup><col class="label" /><col /></colgroup> 351 410 <tbody valign="top"> 352 <tr><td class="label"><a class="fn-backref" href="#id4">[1]</a></td><td><a class="reference external" href="http://tools.ietf.org/html/rfc2119">http://tools.ietf.org/html/rfc2119</a></td></tr> 353 </tbody> 354 </table> 355 <table class="docutils footnote" frame="void" id="id5" rules="none"> 356 <colgroup><col class="label" /><col /></colgroup> 357 <tbody valign="top"> 358 <tr><td class="label"><a class="fn-backref" href="#id6">[2]</a></td><td><a class="reference external" href="http://www.bittorrent.org/beps/bep_0013.html">http://www.bittorrent.org/beps/bep_0013.html</a></td></tr> 411 <tr><td class="label"><a class="fn-backref" href="#id7">[5]</a></td><td><a class="reference external" href="http://tools.ietf.org/html/rfc2119">http://tools.ietf.org/html/rfc2119</a></td></tr> 359 412 </tbody> 360 413 </table>