<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div dir="ltr">Hi Eli,<br><div><br></div></div><div dir="ltr"><blockquote type="cite">On 28 Apr 2020, at 11:47, Eli Vakrat <eli@vakrat.com> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div>But then I looked at the debug log of my guard node (remember that my guard node is on my local machine) and it said that it had received a DESTROY Cell back from the middle node and was passing on a RELAY_TRUNCATED cell to me:</div><div><br><b>Apr 26 16:11:03.014 [debug] command_process_destroy_cell: Received for circID <span>2297363203</span>.</b> <------this is the circuit ID between my gaurd node and the middle node<br><b>Apr 26 16:11:03.014 [debug] command_process_destroy_cell: Delivering 'truncated' back.<br>Apr 26 16:11:03.014 [debug] relay_send_command_from_edge_: delivering 9 cell backward.</b><br><br></div><div>To my understanding what this log means is that some part of the EXTEND cell I sent to the middle node was wrong or malformed and because of this when the middle node tried to extend the circuit, an error occurred, and the circuit needed to be torn down.</div><div><br></div><div>This is very weird because when I send an EXTEND cell that is meant for my guard node (meaning I want to extend the circuit from one hop to two hops) everything works fine, and I can even successfully derive the shared key material for the middle node.</div></div></blockquote><div><br></div><div>It looks like there are at least two bugs here:</div><div>* encryption to the guard node</div><div>* decryption from the guard node</div><div><br></div><blockquote type="cite"><div dir="ltr"><div>So I have several questions regarding this:</div><div><br></div><div>1. First of all, I didn't quite understand the exact format of a RELAY_TRUNCATED cell. Does it contain a relay cell command + recognized+field +digest and so on? or is it just a single octet that immediately follows the cell command field? If some could show me an example of the cell, it would be much appreciated... </div></div></blockquote><div><br></div><div>It's a relay cell, so it contains all the relay cell fields:</div><div><a href="https://github.com/torproject/torspec/blob/master/tor-spec.txt#L1551">https://github.com/torproject/torspec/blob/master/tor-spec.txt#L1551</a></div><div>Then the relay cell's "data" contains a single byte "reason" field.</div><div><br></div><div>I agree it's confusing, I've fixed it in the spec.</div><br><blockquote type="cite"><div dir="ltr"><div>2. What are some common errors that would make an OR drop a RELAY EXTEND cell? I thought maybe it was a problem with my TAP handshake data, but after extensive checking that doesn't seem to be the case.</div></div></blockquote><div dir="ltr"><br></div>Have you tried running the middle relay on your machine as well?</div><div dir="ltr"><br></div><div dir="ltr">You can run a whole tor network on your machine using chutney:</div><div dir="ltr"><a href="https://github.com/torproject/chutney/blob/master/README#L257">https://github.com/torproject/chutney/blob/master/README#L257</a></div><div dir="ltr">(If you're using Windows, Chutney won't work, because directory authorities don't work on Windows.)</div><div dir="ltr"><br></div><div dir="ltr">Try:</div><div dir="ltr">CHUTNEY_STOP_TIME=-1 chutney/tools/test-network.sh</div><div dir="ltr">Then extend to the relays on 127.0.0.1.</div><div dir="ltr"><div dir="ltr"><br></div><div dir="ltr"><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">It looks like you can't encrypt cells to the guard.</span></div><div dir="ltr"><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></span></div><div dir="ltr"><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">Have you tried sending a RELAY_DROP cell to the guard?</span></div><div dir="ltr"><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">That's a good way to test encryption.</span></div><div dir="ltr"><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></span></div><div dir="ltr">It also looks like you can't decrypt cells from the guard.</div><div><br></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">What's the data in the first CREATED cell from the guard?</span></div><div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">Should it be all-zero? (Check the tor source code.)</div></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><div dir="ltr" style="caret-color: rgb(255, 255, 255); color: rgb(255, 255, 255);"><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">Have you tried opening a stream to the guard node?</span></div><div dir="ltr" style="caret-color: rgb(255, 255, 255); color: rgb(255, 255, 255);"><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">That's a good way to test decryption.</span></div><div dir="ltr" style="caret-color: rgb(255, 255, 255); color: rgb(255, 255, 255);"><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></span></div><div dir="ltr" style="caret-color: rgb(255, 255, 255); color: rgb(255, 255, 255);"><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">Most guards are directory caches, so you should be able to open a  RELAY_BEGINDIR stream, and download something small. Like the relay's descriptor.</span></div></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></div><blockquote type="cite"><div dir="ltr"><div>3. If someone could describe the exact steps of extending a circuit to a third node, it would greatly help me to make sure that I didn't miss a step or do something wrong.</div></div></blockquote><div dir="ltr"><br></div><div dir="ltr">Here's the spec for multi-hop circuits:</div><div dir="ltr"><a href="https://github.com/torproject/torspec/blob/master/tor-spec.txt#L1290">https://github.com/torproject/torspec/blob/master/tor-spec.txt#L1290</a></div><div dir="ltr"><br></div>It's hard to know what steps you're missing, without more information. Feel free to share your code, or ask questions about any confusing parts of the spec.</div><div dir="ltr"><br></div><div dir="ltr">T<br><br><div><br></div></div></body></html>