code wiki / (root) / nx_reach12_test.nx

nx_reach12_test.nx source

↩ module page · 57 lines · 2753 B

1// nx_reach12_test.nx -- DISCRIMINATOR for debt 1785519121. nx_tls12_probe reaches usgs.gov over 2// TLS-1.2 (AUTHENTICATED, 200, 1307B) but nx_https_fetch_follow_best's 1.2 leg returns -3 HANDSHAKE 3// on the SAME URL. Two candidates: (a) two DIFFERENT 1.2 impls -- nx_tls12_req.t12_request vs 4// nx_tls12_client_session_run; (b) the two failed 1.3 hellos in _best poison the 1.2 attempt. 5// This runs BOTH impls in ONE process on a FRESH connection each, with no 1.3 attempt before either. 6// A succeeds + B fails => (a), the impls differ. Both succeed => (b), _best's earlier hellos are the cause. 7// expect_exit: 0 license_tier: ORIGINAL 8import "nx_syscalls.nx" 9import "nx_x509_trust_store.nx" 10import "nx_trust_store_load_from_certdata.nx" 11import "nx_tls12_req.nx" 12import "nx_https_fetch_follow.nx" 13 14const R12_CAP: i64 = 1048576 15const R12_CERT: i64 = 4194304 16 17func r12_vlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 18func r12_puts(s: *u8) -> i64 { let n: i64 = r12_vlen(s); sys_write(1, s, n); return 0 } 19func r12_putn(v: i64) -> i64 { 20 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 21 var m: i64 = v 22 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 23 let d: *u8 = sys_mmap(24) 24 var k: i64 = 0 25 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 26 var j: i64 = k - 1 27 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 } 28 return 0 29} 30 31func main() -> i64 { 32 let url: *u8 = "https://waterservices.usgs.gov/nwis/site/?format=rdb&sites=01646500" as *u8 33 r12_puts("=== REACH-12 DISCRIMINATOR (usgs.gov, TLS-1.2 only host) ===\n") 34 35 let outA: *u8 = sys_mmap(R12_CAP) 36 let na: i64 = t12_request(url, "GET" as *u8, 3, "" as *u8, 0, "" as *u8, 0, outA, R12_CAP) 37 r12_puts("A t12_request (nx_tls12_req.nx, probe impl) bytes=") 38 r12_putn(na) 39 r12_puts("\n") 40 41 let tr: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, R12_CERT) 42 if tr <= 0 { r12_puts("certdata load FAILED\n"); return 1 } 43 let store: *TrustStore = tr as *TrustStore 44 let outB: *u8 = sys_mmap(R12_CAP) 45 let st: *i64 = sys_mmap(8) as *i64 46 let nb: i64 = nx_https_fetch_follow_12(url, store, outB, R12_CAP, st) 47 r12_puts("B fetch_follow_12 (nx_tls12_client_session.nx, _best) bytes=") 48 r12_putn(nb) 49 r12_puts(" status=") 50 r12_putn(st[0]) 51 r12_puts("\n") 52 53 if na > 0 { if nb <= 0 { r12_puts("VERDICT (a) IMPL-DIFFERS: t12_request reaches it, client_session does NOT\n") } } 54 if na > 0 { if nb > 0 { r12_puts("VERDICT (b) BOTH 1.2 IMPLS REACH IT -- _best earlier hellos are the cause\n") } } 55 if na <= 0 { r12_puts("VERDICT INCONCLUSIVE: even t12_request failed here\n") } 56 return 0 57}