nx_cert_gen.nx
buildroot/runtime/bin/nx_cert_gen.nx
about
nx_cert_gen.nx -- V-HOST-4c: sovereign X.509 self-signed cert CLI driver.
Closes the openssl bridge from NISHI_ANDELINWEST_DEPLOY_PLAYBOOK ยง3.
Full sovereign Zone S cert generation per License Containment Cardinal.
USAGE (V1 hardcoded; V-PROV-1 CLI argv parser extends):
nx_cert_gen.elf \
--domain andelinwest.com \
--san www.andelinwest.com,wiki.andelinwest.com \
--validity-days 365 \
--out-dir /var/nishi-host/certs/andelinwest/
Produces:
/var/nishi-host/certs/andelinwest/cert.der (X.509 v3 self-signed)
/var/nishi-host/certs/andelinwest/priv.ed25519 (32-byte raw priv)
/var/nishi-host/certs/andelinwest/pub.ed25519 (32-byte raw pub; for verify)
COMPOSES (per "avoid duplicate primitives"):
hub/nx_x509_build (V-HOST-4b; X.509 v3 builder)
hub/nx_asn1_write (V-HOST-4a; DER encoder; transitively)
nx_csprng (sovereign CSPRNG; sys_getrandom OR /dev/urandom)
nx_ed25519_signature (ed25519_pub_from_priv just added)
nx_syscalls (sys_now_ms; sys_openat_wr; sys_write; sys_close)
V-HOST-4c SCOPE:
- Generate 32-byte Ed25519 priv via nx_csprng_fill
- Derive 32-byte pub via ed25519_pub_from_priv
- Compute notBefore (now Unix sec -> GeneralizedTime) +
notAfter (now + validity_days)
- Build cert DER via nx_x509_build_self_signed
- Write cert.der + priv.ed25519 + pub.ed25519 to disk
V-HOST-4c NON-SCOPE:
- Full argv parsing (V-PROV-1 CLI; V-HOST-4c uses hardcoded for V1 demo)
- PEM emit (only DER; convert via existing nx_pem_encode if shipped)
- chmod 0600 on priv (operator does this post-creation; or sys_chmod V+1)
Status: V-HOST-4c. 2026-05-27.
dependencies 8 imports · 0 importers
imports: nx_syscalls.nxnx_x509_build.nxnx_asn1_write.nxnx_csprng.nxnx_ed25519_signature.nxnx_u256.nxnx_p256_point.nxnx_p256_scalar_mul.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 51 | const NX_CG_OK: i64 = 0 |
| 52 | const NX_CG_BAD_INPUT: i64 = 3640 |
| 53 | const NX_CG_CSPRNG_FAILED: i64 = 3641 |
| 54 | const NX_CG_KEYGEN_FAILED: i64 = 3642 |
| 55 | const NX_CG_TIME_FAILED: i64 = 3643 |
| 56 | const NX_CG_CERT_BUILD_FAILED: i64 = 3644 |
| 57 | const NX_CG_FILE_WRITE_FAILED: i64 = 3645 |
| 60 | const NX_CG_CERT_DER_CAP: i64 = 8192 |
| 61 | const NX_CG_FILE_OPEN_MODE_PRIV: i64 = 384 // 0o600 (rw-------) |
| 62 | const NX_CG_FILE_OPEN_MODE_PUB: i64 = 420 // 0o644 (rw-r--r--) |
| 63 | const NX_CG_DEFAULT_VALIDITY_DAYS: i64 = 365 |
functions
| 72 | func nx_cg_days_from_civil(y: i64, m: i64, d: i64) -> i64 |
| 84 | func nx_cg_civil_from_days(days: i64, called by 1: nx_cg_format_generalized_time |
| 106 | func nx_cg_format_generalized_time(unix_sec: i64, out_15: *u8) -> i64 called by 2: nx_cert_gen_self_signednx_cert_gen_self_signed_ecdsa_p256 calls 2: sys_mmapnx_cg_civil_from_days |
| 145 | func nx_cg_write_file(path_z: *u8, mode: i64, called by 2: nx_cert_gen_self_signednx_cert_gen_self_signed_ecdsa_p256 calls 3: sys_openat_wrsys_writesys_close |
| 162 | func nx_cert_gen_self_signed( |
| 242 | func nx_cg_ecdsa_p256_keygen(priv_limbs: *i64, |
| 280 | func nx_cert_gen_self_signed_ecdsa_p256( |
| 351 | func main() -> i64 |