code wiki / _hdl_build / nx_tor_relay.nx

nx_tor_relay.nx

buildroot/runtime/_hdl_build/nx_tor_relay.nx

7585 B162 linesdepth 5pulls 7 transitivereach 1 importersview sourcekind librarytopic tor
docsdependenciesstructsconstsfunctions

about

nx_tor_relay.nx -- Tor circuit-handshake + RELAY-cell payloads (tor-spec sec.5.1/sec.5.1.2/sec.6.1). Phase 3 onion layer: CREATE2/CREATED2 (wrap the Phase-1 ntor onion skin), the RELAY cell format with its running digest + recognized field, per-hop AES-128-CTR onion (de)cryption, and EXTEND2/EXTENDED2 for multi-hop circuit build. STRUCTURAL (no live relay); composes nx_tor_cell + nx_tor_aes + nx_sha1. HONEST SCOPE: this is the cell/onion FRAMING + the recognized/digest mechanism, gated byte-exact and by round-trip/self-consistency. The running digest here is SHA-1(Df_seed || payload) per cell (equivalent to Tor's stateful running digest for the first cell); byte-exact interop vs a live relay is a later phase. anon_is_anonymizing() stays 0. license_tier: ORIGINAL

dependencies 4 imports · 1 importers

nx_syscalls.nx nx_tor_cell.nx nx_tor_aes.nx nx_sha1.nx nx_tor_relay.nx nx_tor_relay_gate.nx

imports: nx_syscalls.nxnx_tor_cell.nxnx_tor_aes.nxnx_sha1.nx

imported by: nx_tor_relay_gate.nx

structs

none

consts

16const TOR_HTYPE_NTOR: i64 = 2
18const TOR_RELAY_BEGIN: i64 = 1
19const TOR_RELAY_DATA: i64 = 2
20const TOR_RELAY_END: i64 = 3
21const TOR_RELAY_EXTEND2: i64 = 14
22const TOR_RELAY_EXTENDED2: i64 = 15
24const TOR_LS_IPV4: i64 = 0
25const TOR_LS_IPV6: i64 = 1
26const TOR_LS_LEGACY_ID: i64 = 2
27const TOR_LS_ED25519: i64 = 3
29const TOR_RELAY_HDR: i64 = 11 // relay_cmd(1) recognized(2) streamid(2) digest(4) length(2)
31const TOR_E_SHORT: i64 = 0 - 1
32const TOR_E_FORMAT: i64 = 0 - 2

functions

36func tor_build_create2(htype: i64, hdata: *u8, hlen: i64, out: *u8) -> i64
called by 1: main calls 1: tc_put_u16
44func tor_parse_create2(pl: *u8, pllen: i64, out_htype: *i64, out_hlen: *i64, out_hoff: *i64) -> i64
called by 1: main calls 1: tc_get_u16
53func tor_build_created2(hdata: *u8, hlen: i64, out: *u8) -> i64
called by 1: main calls 1: tc_put_u16
59func tor_parse_created2(pl: *u8, pllen: i64, out_hlen: *i64, out_hoff: *i64) -> i64
called by 1: main calls 1: tc_get_u16
69func tor_running_digest4(df_seed: *u8, payload509: *u8, out4: *u8) -> i64
81func tor_relay_build(relay_cmd: i64, streamid: i64, data: *u8, dlen: i64, df_seed: *u8, out509: *u8) -> i64
98func tor_relay_recognized(pl509: *u8, df_seed: *u8) -> i64
110func tor_onion_crypt(kf16: *u8, in509: *u8, out509: *u8) -> i64
called by 1: main calls 2: sys_mmaptor_aes128_ctr
117func tor_ls_ipv4(ip4: *u8, port: i64, out: *u8) -> i64
called by 1: main calls 1: tc_put_u16
124func tor_ls_legacy_id(id20: *u8, out: *u8) -> i64
called by 1: main
131func tor_build_extend2(nspec: i64, specs: *u8, specs_len: i64, htype: i64, hdata: *u8, hlen: i64, out: *u8) -> i64
called by 1: main calls 1: tc_put_u16
144func tor_parse_extend2(pl: *u8, pllen: i64, out_nspec: *i64, out_htype: *i64, out_hlen: *i64, out_hoff: *i64) -> i64
called by 1: main calls 1: tc_get_u16