nx_tls12_req.nx
buildroot/runtime/nx_tls12_req.nx
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
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
| 28 | const TR_MAGIC_2048: i64 = 2048 |
| 29 | const TR_MAGIC_4096: i64 = 4096 |
| 30 | const TR_MAGIC_3072: i64 = 3072 |
| 31 | const TR_MAGIC_1024: i64 = 1024 |
| 32 | const TR_MAGIC_16384: i64 = 16384 |
| 33 | const TR_MAGIC_65536: i64 = 65536 |
| 34 | const TR_MAGIC_32768: i64 = 32768 |
| 35 | const TR_MAGIC_4194304: i64 = 4194304 |
| 36 | const TR_MAGIC_40960: i64 = 40960 |
| 37 | const TR_MAGIC_8192: i64 = 8192 |
| 38 | const TR_MAGIC_8300: i64 = 8300 |
| 39 | const TR_MAGIC_262144: i64 = 262144 |
| 41 | const TR_HS: i64 = 22 |
| 42 | const TR_CCS: i64 = 20 |
| 43 | const TR_ALERT: i64 = 21 |
| 246 | const TR_READ_TIMEOUT_SECS: i64 = 20 // declared: per-read ceiling, so a stalling peer fails fast |
functions
| 45 | func 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 |
| 46 | func tr_b1(d: *u8, o: i64, v: i64) -> i64 { d[o]=(v&0xff) as u8; return o+1 } |
| 47 | func 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 } |
| 48 | func 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 } |
| 49 | func 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 } |
| 50 | func 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 |
| 51 | func tr_catn(d: *u8, o: i64, v: i64) -> i64 |
| 57 | func tr_u64be(d: *u8, o: i64, v: i64) -> i64 called by 1: t12_request |
| 62 | func tr_write_all(fd: i64, buf: *u8, n: i64) -> i64 |
| 68 | func tr_prf(secret: *u8, secret_len: i64, label: *u8, label_len: i64, seed: *u8, seed_len: i64, out: *u8, out_len: i64) -> i64 |
| 96 | func tr_client_hello(host: *u8, hlen: i64, cr_out: *u8, out: *u8) -> i64 |
| 116 | func tr_hdr_end(b: *u8, n: i64) -> i64 called by 1: t12_request |
| 121 | func tr_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } called by 1: tr_match_ci |
| 122 | func tr_match_ci(b: *u8, i: i64, n: i64, targ: *u8, tlen: i64) -> i64 |
| 128 | func tr_content_length(b: *u8, n: i64) -> i64 |
| 145 | func tr_is_chunked(b: *u8, hdr_end: i64) -> i64 |
| 156 | func tr_chunk_done(b: *u8, from: i64, n: i64) -> i64 called by 1: t12_request |
| 165 | func 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 |
| 181 | func tr_certs12_to_13(body12: *u8, len12: i64, out13: *u8) -> i64 called by 1: t12_request |
| 211 | func tr_verify_ske_sig(cr: *u8, sr: *u8, ske: *u8, ske_len: i64, leaf_der: *u8, leaf_len: i64) -> i64 |
| 247 | func t12_request(full_url: *u8, method: *u8, mlen: i64, token: *u8, tn: i64, body: *u8, blen: i64, out: *u8, outcap: i64) -> i64 called by 1: gc_run calls 33: sys_mmapnx_url_newnx_https_url_for_fetchtr_slensys_now_realtime_secnx_https_url_connect+27 |