code wiki / _hdl_build / nx_pub_tls_serve.nx
nx_pub_tls_serve.nx source
↩ module page · 19 lines · 1341 B
1// nx_pub_tls_serve.nx -- pub_tls: serve the publisher's liveroot over the ecosystem's PROVEN sovereign TLS-1.3 server.
2//
3// The publisher does NOT re-implement TLS. It composes the proven sovereign stack: nx_edge_serve_static_response
4// (builds the HTTP/1.1 response and AEAD-encrypts it via nx_tls13_server_session_app_send under the server app-traffic
5// key) sitting on the TLS-1.3 server arc whose full handshake is proven by nx_tls13_server_full_handshake_test.
6// pub_tls_http_for_file is the publisher-owned bridge: liveroot file -> the served HTTP response (the plaintext the
7// TLS layer then encrypts). pub_tls_serve_file is the over-session path. license_tier: ORIGINAL
8import "nx_syscalls.nx"
9import "nx_publisher.nx"
10import "nx_edge_serve_static.nx"
11const K_MAGIC_1280: i64 = 1280
12
13// build the HTTP/1.1 response for a publisher liveroot file (the plaintext the TLS layer AEAD-encrypts). bytes, or <0.
14func pub_tls_http_for_file(liveroot: *u8, urlpath: *u8, out: *u8, cap: i64) -> i64 {
15 let full: *u8 = sys_mmap(K_MAGIC_1280); pub_join(liveroot, urlpath, full)
16 let lenp: *i64 = sys_mmap(8) as *i64
17 let data: *u8 = sys_read_file(full, lenp)
18 if (data as i64) == 0 { return 0 - 1 } // no fabricated response for a missing file
19 return nx_edge_build_http_response(data, lenp[0], out, cap)
20}