Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I am very new to concepts of cryptography so bear with me and feel free to fill in any information that may seem obvious but something you think someone may not know.

At first I was under impression that people use checksums to determine if files are legit or not. Which didn't make sense for obvious reasons… for example it's not hard to get the same sum for different numbers. So all a hacker has to do is make a file with smaller sum and then fill in the rest with garbage that way file would have equivalent checksum, but completely different content. Then later on, I found out that a checksum isn't used at all for this purpose.

So, what is used instead? I’ve been reading that some asymmetric functions are used and that files are encrypted using the destination's public key.

But I am unable to wrap my head around it and say* “ok, this will work in P2P”*.

Let’s say there are files $A$, $B$, $C$ among 10 seeders and I am the receiver. And chunks of them are being sent. How does uTorrent make sure that the chunk received is the chunk it should be getting. Sometimes there is only 1 seeder. So the option of checking what most people have is out of the question…

Thinking about it ,I am not sure how uTorrent or P2P clients really work after all.

For example:

  • Does each torrent file has some unique ID? If, how is it generated?
  • Am I correct to believe that all torrents connect to a server to get the list of all other people?
share|improve this question
    
people use checksum I'm afraid you've got this wrong. Torrents use hashsums, or as they are better known, cryptographic hash functions. I'm not familiar with the inner workings of the protocol but making such a forgery, much less in a way that the resulting file could be passed as valid to a human, is a highly non-trivial task. –  rath May 22 at 16:57
    
For the rest of the question I think this and similar articles would be of help. –  rath May 22 at 17:01
1  
I know it was wrong and didn't make sense...And finally i am getting somewhere.."hashsums" a lead to wonderland :D thanks. –  Muhammad Umer May 22 at 17:03
    
thanks for the edit –  Muhammad Umer May 22 at 17:12
add comment

1 Answer 1

The only thing that always happens in BitTorrent is that the chunks (pieces of files) are checksummed/hashed with the SHA1 algorithm and compared against the values in the .torrent file. If all the chunks match their hashes, the file is correct – unless there's an SHA1 collision.

Additionally, some .torrent files contain MD5 hashes for each of the files which the client may or may not verify.

Finally, many clients support protocol encryption, where the traffic between peers is encrypted using Diffie-Hellman key exchange, SHA1 and ARC4. This does nothing to guarantee the integrity of files, it is mostly meant to avoid throttling by ISPs and make it more difficult for eavesdroppers to see what you are up to.

share|improve this answer
    
so i could be downloading something else using torrent of something else. –  Muhammad Umer May 22 at 18:28
    
@MuhammadUmer, ummm, no. An SHA1 collision would be the only way that could happen, but no collisions have been found so far. Current best attack has a cost of 2^61. –  otus May 22 at 19:25
    
A peer could of course send you wrong data regardless, but your client (e.g. utorrent) would notice the hash mismatch and ban that peer. –  otus May 22 at 19:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.