I understand how the client sends the data through Tor to the sever. Onion routing
Basically, it selects a set of nodes to form a circuit, say nodeA nodeB nodeC.
It then encrypts the data this way:
1. Encrypt it using nodeC's key, append server's address. 2. Encrypt it using nodeB's key, append nodeC's address. 3. Encrypt it using nodeA's key, append nodeB's address.
The data then travels the circuit this way.
Me -> nodeA (decrypt it) -> nodeB (decrypt) -> nodeC (decrypt) -> Server
1. I send the data to nodeA. nodeA decrypts it and will now know where to send the data next. 2. nodeA sends the data to nodeB. nodeB decrypts it and will now know where to send the data next. 3. nodeB sends the data to nodeC. nodesC decrypts it and will now know where to send the data next. 4. nodeC sends the data to the server.
What I don't get is, when the server replies, how is the data encrypted and/or sent back to me.
1. Does the exit node know who I am and sends the reply back the way I send the data to the server (construct a circuit)? 2. Is the session maintained, if so, how is the data encrypted between the nodes?