Commit 8e0d5c2
Fix ntor key derivation and implement EXTEND2 circuit extension
- Fix ntor server handshake key assignment: stop swapping forward/backward
labels since CircuitCrypto uses spec convention (Kf=decrypt incoming,
Kb=encrypt outgoing)
- Fix ntor constants: correct sizes for NTOR_SERVER_STR (6B),
NTOR_KEY_STR (36B), NTOR_EXPAND_STR (35B), NTOR_MAC_STR (28B),
NTOR_VERIFY_STR (31B)
- Implement proper stream-level flow control (500-cell window with
pending response queue)
- Add decrypt_relay_cell_or_forward: supports both "for us" and
"forward to next hop" paths with proper digest state management
- Implement EXTEND2 handler: parses link specifiers, opens TLS
connection to target relay, performs Tor link protocol handshake,
forwards CREATE2/CREATED2, sends EXTENDED2 back to client
- Add bidirectional relay cell forwarding with backward encryption
- Preserve RELAY_EARLY flag when forwarding cells (required by spec)
- Result: Tor client achieves 100% bootstrap through C++ bridge
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent d88e4c8 commit 8e0d5c2
3 files changed
+601
-96
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | | - | |
| 43 | + | |
36 | 44 | | |
37 | 45 | | |
38 | 46 | | |
39 | 47 | | |
40 | 48 | | |
41 | | - | |
| 49 | + | |
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
| |||
131 | 139 | | |
132 | 140 | | |
133 | 141 | | |
134 | | - | |
135 | | - | |
| 142 | + | |
| 143 | + | |
136 | 144 | | |
137 | 145 | | |
138 | 146 | | |
| |||
0 commit comments