code wiki / _hdl_build / _uj_probe.nx

_uj_probe.nx source

↩ module page · 29 lines · 1454 B

1// _uj_probe.nx -- bisect the journey crash: trust-store load, then one 2// sovereign HTTPS fetch, with a marker after each step. 3import "nx_str.nx" 4import "nx_syscalls.nx" 5import "nx_csprng.nx" 6import "nx_x509_trust_store.nx" 7import "nx_pem_loader.nx" 8import "nx_https_get.nx" 9 10func up_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 11func up_putn(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 } 12 13func main() -> i64 { 14 up_puts("P1 alloc\n" as *u8) 15 let store: *TrustStore = trust_store_alloc(400) 16 up_puts("P2 store-ok, loading CA file\n" as *u8) 17 let nroots: i64 = nx_pem_trust_load_file("/etc/ssl/certs/ca-certificates.crt" as *u8, store) 18 up_puts("P3 ca-roots=" as *u8); up_putn(nroots); up_puts("\n" as *u8) 19 if nroots <= 0 { return 1 } 20 let cr: *u8 = sys_mmap(32) 21 let pk: *u8 = sys_mmap(32) 22 nx_csprng_fill(cr, 32) 23 nx_csprng_fill(pk, 32) 24 up_puts("P4 csprng-ok, fetching\n" as *u8) 25 let buf: *u8 = sys_mmap(262144) 26 let rr: i64 = nx_https_get("https://andelinwest.com/" as *u8, cr, pk, store, sys_now_realtime_sec(), buf, 262144) 27 up_puts("P5 rr=" as *u8); up_putn(rr); up_puts("\n" as *u8) 28 return 0 29}