4

Just curious if out of the box does Tor use a Gzip or any other kind of compression? I have done some searches but find only discussions about the Hidden Service directory.

3
  • github.com/katmagic/Tor/search?q=gzip&ref=cmdform this seems to suggest it's only used by the directory Commented Feb 24, 2014 at 6:57
  • Leaving compression to tor makes little sense conceptually. Whatever you are transmitting should be compressed properly (and if appropriate encrypted) before tor gets its hands on it.
    – Caleb
    Commented Mar 1, 2014 at 9:09
  • @Calbeb I am just trying to know if it compresses it already or not. Commented Mar 6, 2014 at 21:49

2 Answers 2

2

From the source code on GitHub I did a search for "gzip" and found the compression code:

https://github.com/katmagic/Tor/search?q=gzip&ref=cmdform

After searching a bit more I was unable to find their compression routines called from anywhere but within the directory. It appears Tor is only using compression for the directory tables

1

Tor encrypts its connections from the client to relays or from relay to another. Encrypted data looks like random data to an outsider. This is a very bad case for compression, because the compression algorithm finds very few similarities to put together. So encrypted data can hardly be compressed. It is more the opposite. Usually encrypted and then compressed data are usually bigger than encrypted data alone. Thatswhy it makes no sense for Tor to compress its data during transport.

It was asked in the comments if Tor couldn't compress first and than encrypt. Tor operates on TCP packets. This is the transport level. Tor doesn't know about protocols at the application layer, like HTTP. But data compression is handled on the application level. For instance a browser could tell the server that it supports gzip compression and the server sends compressed data. If Tor should handle those things it must know every protocol at the application level (HTTP, SMTP, IMAP, DNS etc.), negotiate compression and so on. This would heavily enlarge the binary, probably introduce a large number of bugs and Tor has to do things what an application like a browser, mail client etc. could do better.

1
  • 1. You showed that compression after encryption does not make sense. That is the reason encryption after compression is being used. The first paragraph does not show arguments against compression. --- 2. Tor operates with the TCP data stream (not packets). You are right that Tor does not know which parts of the stream are data but the stream could be compressed completely including the application protocol headers. You do not need to know the application protocol because after lossless decompression you will get exactly the same data as before the compression. Commented Feb 28, 2014 at 21:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .