code wiki / (root) / nx_mse_handshake.nx

nx_mse_handshake.nx

buildroot/runtime/nx_mse_handshake.nx

10742 B130 linesdepth 6pulls 12 transitivereach 0 importersview sourcekind tooltopic mse
docsdependenciesstructsconstsfunctions

about

nx_mse_handshake.nx -- the FULL MSE/PE obfuscated handshake over a real socket (anti-throttle keystone). Two parties complete the Message Stream Encryption handshake so an ISP's DPI sees only high-entropy bytes (no "BitTorrent protocol" string, no fixed structure) and can't fingerprint+throttle the connection: A->B: Ya (DH pubkey; + optional PadA -- 0 here) B->A: Yb A->B: HASH(req1,S) | HASH(req2,SKEY)^HASH(req3,S) | RC4_keyA( VC | crypto_provide | lenPadC=0 | lenIA=0 ) B->A: RC4_keyB( VC | crypto_select | lenPadD=0 ) then: the RC4 streams (keyA A->B, keyB B->A) carry the rest -- e.g. the BT handshake -- ENCRYPTED. Composes nx_mse_keys (DH + keyA/keyB + req-hashes) + nx_rc4 + sockets. GATE = loopback A<->B: negotiate RC4, verify VC both ways, then A sends an ENCRYPTED payload B decrypts to the exact plaintext. (Pads=0 for the gate; live interop adds random pads + B's req1-hash stream-sync scan -- noted, not needed to prove the crypto.) nx_mse_handshake -- no-arg = the loopback GATE license_tier: ORIGINAL module: nishi-core.torrent.mse_handshake depends: mse_keys (dh+rc4+sha1)

dependencies 2 imports · 0 importers

nx_mse_keys.nx nx_connect.nx nx_mse_handshake.nx

imports: nx_mse_keys.nxnx_connect.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main md_p md_load_p md_hex2bytes md_hv bi_from_bytes_be bi_zero hs_sockaddr sys_socket sys_setsockopt sys_set_socket_timeout sys_mmap sys_setsockopt ↻ sys_munmap sys_bind sys_listen sys_fork sys_accept bi_zero ↻ hs_read_n sys_read bi_from_bytes_be ↻ mse_dh_public bi_zero ↻ bi_modexp bi_zero ↻ bi_copy bi_mod bi_zero ↻ bi_shl1 bi_cmp bi_sub bi_mul bi_zero ↻ bi_to_bytes_be hs_write_n mse_dh_shared bi_modexp ↻ mk_derive sha1

structs

none

consts

18const HS_MAGIC_1024: i64 = 1024
20const HS_PORT: i64 = 53811

functions

22func hs_sockaddr(sa: *u8, port: i64, a: i64, b: i64, c: i64, d: i64) -> i64
called by 1: main
27func hs_read_n(fd: i64, buf: *u8, n: i64) -> i64 { var g: i64=0; while g<n { let r: i64=sys_read(fd, buf+g, n-g); if r<=0 { return 0-1 } g=g+r } return g }
called by 1: main calls 1: sys_read
28func hs_write_n(fd: i64, buf: *u8, n: i64) -> i64 { var o: i64=0; while o<n { let w: i64=sys_write(fd, buf+o, n-o); if w<=0 { return 0-1 } o=o+w } return n }
called by 1: main
29func if_zero(v: i64) -> i64 { if v==0 { return 1 } return 0 }
called by 1: main
30func hs_put4(b: *u8, o: i64, v: i64) -> i64 { b[o]=((v>>24)&0xff) as u8; b[o+1]=((v>>16)&0xff) as u8; b[o+2]=((v>>8)&0xff) as u8; b[o+3]=(v&0xff) as u8; return o+4 }
called by 1: main
31func hs_memeq(a: *u8, b: *u8, n: i64) -> i64 { var i: i64=0; while i<n { if a[i]!=b[i] { return 0 } i=i+1 } return 1 }
called by 1: main
32func hs_xor20(a: *u8, b: *u8, out: *u8) -> i64 { var i: i64=0; while i<20 { out[i]=((a[i] as i64) ^ (b[i] as i64)) as u8; i=i+1 } return 0 }
called by 1: main
34func hs_rc4_open(S: *u8, ij: *i64, key20: *u8) -> i64 { rc4_ksa(S, key20, 20); ij[0]=0; ij[1]=0; rc4_skip(S, ij, HS_MAGIC_1024); return 0 }
called by 1: main calls 2: rc4_ksarc4_skip
36func main() -> i64