code wiki / (root) / nx_tls12_req.nx

nx_tls12_req.nx

buildroot/runtime/nx_tls12_req.nx

27438 B454 linesdepth 15pulls 95 transitivereach 326 importersview sourcekind librarytopic tls12
docsdependenciesstructsconstsfunctions

about

nx_tls12_req.nx -- REUSABLE sovereign TLS-1.2 HTTPS request (ECDHE-RSA-AES128-GCM-SHA256). LIBRARY (no main): one call t12_request(full_url, method, token, body, ...) does connect -> ECDHE-RSA handshake -> encrypted request -> incremental-decrypt response, returning the plaintext HTTP response (headers+body). This is what gets nx_gpu_ctl (and Porkbun) off curl: console.vast.ai + Porkbun are TLS-1.2-only while the shipped stack is 1.3-only. Composes the shipped crypto primitives (p256_ecdh_*, hmac_sha256 PRF, nx_aes128_gcm_seal/open, sha256_digest). SILENT: no stdout chatter, so a caller gets clean response bytes. Proven end-to-end (authenticated account GET) 2026-07-14. NOTE(security): cert-chain + ServerKeyExchange-signature validation NOT yet wired -- confidential but not yet MITM-authenticated; harden before trusting for adversarial networks. license_tier: ORIGINAL

dependencies 16 imports · 3 importers

nx_syscalls.nx nx_csprng.nx nx_https_url_for_fetch.nx nx_https_url_connect.nx nx_sha256.nx nx_p256_ecdh.nx nx_hmac.nx nx_aes128_gcm.nx nx_trust_store_load_from_certdata. nx_https_cert_pipeline.nx nx_tls12_req.nx nx_gpu_ctl.nx nx_https_fetch_follow.nx nx_reach12_test.nx

diagram shows first 10 each side; +6 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_csprng.nxnx_https_url_for_fetch.nxnx_https_url_connect.nxnx_sha256.nxnx_p256_ecdh.nxnx_hmac.nxnx_aes128_gcm.nxnx_trust_store_load_from_certdata.nxnx_https_cert_pipeline.nxnx_x509_pubkey_rsa.nxnx_x509_pubkey_rsa_4096.nxnx_x509_verify_rsa_pkcs1_sha256.nxnx_x509_verify_rsa_pkcs1_sha256_4096.nxnx_u2048.nxnx_u4096.nx

imported by: nx_gpu_ctl.nxnx_https_fetch_follow.nxnx_reach12_test.nx

structs

none

consts

28const TR_MAGIC_2048: i64 = 2048
29const TR_MAGIC_4096: i64 = 4096
30const TR_MAGIC_3072: i64 = 3072
31const TR_MAGIC_1024: i64 = 1024
32const TR_MAGIC_16384: i64 = 16384
33const TR_MAGIC_65536: i64 = 65536
34const TR_MAGIC_32768: i64 = 32768
35const TR_MAGIC_4194304: i64 = 4194304
36const TR_MAGIC_40960: i64 = 40960
37const TR_MAGIC_8192: i64 = 8192
38const TR_MAGIC_8300: i64 = 8300
39const TR_MAGIC_262144: i64 = 262144
41const TR_HS: i64 = 22
42const TR_CCS: i64 = 20
43const TR_ALERT: i64 = 21
246const TR_READ_TIMEOUT_SECS: i64 = 20 // declared: per-read ceiling, so a stalling peer fails fast

functions

45func tr_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: t12_request
46func tr_b1(d: *u8, o: i64, v: i64) -> i64 { d[o]=(v&0xff) as u8; return o+1 }
47func tr_b2(d: *u8, o: i64, v: i64) -> i64 { d[o]=((v>>8)&0xff) as u8; d[o+1]=(v&0xff) as u8; return o+2 }
48func tr_b3(d: *u8, o: i64, v: i64) -> i64 { d[o]=((v>>16)&0xff) as u8; d[o+1]=((v>>8)&0xff) as u8; d[o+2]=(v&0xff) as u8; return o+3 }
49func tr_bytes(d: *u8, o: i64, s: *u8, n: i64) -> i64 { var i: i64=0; while i<n { d[o+i]=s[i]; i=i+1 } return o+n }
50func tr_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ d[o+i]=s[i]; i=i+1 } return o+i }
called by 1: tr_http_req
51func tr_catn(d: *u8, o: i64, v: i64) -> i64
called by 1: tr_http_req calls 1: sys_mmap
57func tr_u64be(d: *u8, o: i64, v: i64) -> i64
called by 1: t12_request
62func tr_write_all(fd: i64, buf: *u8, n: i64) -> i64
called by 1: t12_request calls 1: sys_write
68func tr_prf(secret: *u8, secret_len: i64, label: *u8, label_len: i64, seed: *u8, seed_len: i64, out: *u8, out_len: i64) -> i64
called by 1: t12_request calls 2: sys_mmaphmac_sha256
96func tr_client_hello(host: *u8, hlen: i64, cr_out: *u8, out: *u8) -> i64
116func tr_hdr_end(b: *u8, n: i64) -> i64
called by 1: t12_request
121func tr_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c }
called by 1: tr_match_ci
122func tr_match_ci(b: *u8, i: i64, n: i64, targ: *u8, tlen: i64) -> i64
128func tr_content_length(b: *u8, n: i64) -> i64
called by 1: t12_request calls 1: tr_match_ci
145func tr_is_chunked(b: *u8, hdr_end: i64) -> i64
called by 1: t12_request calls 1: tr_match_ci
156func tr_chunk_done(b: *u8, from: i64, n: i64) -> i64
called by 1: t12_request
165func tr_http_req(method: *u8, mlen: i64, target: *u8, tlen: i64, host: *u8, hlen: i64, token: *u8, tn: i64, body: *u8, blen: i64, out: *u8) -> i64
called by 1: t12_request calls 3: tr_bytestr_cattr_catn
181func tr_certs12_to_13(body12: *u8, len12: i64, out13: *u8) -> i64
called by 1: t12_request
211func tr_verify_ske_sig(cr: *u8, sr: *u8, ske: *u8, ske_len: i64, leaf_der: *u8, leaf_len: i64) -> i64
247func t12_request(full_url: *u8, method: *u8, mlen: i64, token: *u8, tn: i64, body: *u8, blen: i64, out: *u8, outcap: i64) -> i64