code wiki / hub / nx_x509_build.nx

nx_x509_build.nx

buildroot/runtime/hub/nx_x509_build.nx

26693 B603 linesdepth 11pulls 30 transitivereach 14 importersview sourcekind librarytopic x509
docsdependenciesstructsconstsfunctions

about

nx_x509_build.nx -- V-HOST-4b: sovereign X.509 v3 self-signed cert builder. Composes hub/nx_asn1_write (V-HOST-4a) + ed25519_sign_full to produce a fully-conformant RFC 5280 X.509 v3 certificate signed with Ed25519 (RFC 8410 + RFC 8032). COMPOSES (per "avoid duplicate primitives"): hub/nx_asn1_write (DER encoder; sibling to existing asn1.nx READ surface) nx_ed25519_signature (ed25519_sign_full per RFC 8032 ยง5.1.6) COMPOSED BY: bin/nx_cert_gen.nx (V-HOST-4c; CLI driver; queued) future: ACME cert request flow integration V-HOST-4b SCOPE per RFC 5280: Certificate { tbsCertificate TBSCertificate, signatureAlgorithm AlgorithmIdentifier, // ed25519 signatureValue BIT STRING // ed25519 64-byte sig } TBSCertificate { version [0] EXPLICIT INTEGER (v3 = 2), serialNumber INTEGER (operator-supplied OR random), signature AlgorithmIdentifier, // ed25519 issuer Name, // self-signed: subject == issuer validity Validity {notBefore, notAfter}, // GeneralizedTime subject Name, // CN=<domain> subjectPublicKeyInfo SubjectPublicKeyInfo,// ed25519 pubkey extensions [3] EXPLICIT Extensions { // V3 extensions subjectAltName // SAN list basicConstraints // CA:FALSE keyUsage // digitalSignature } } V-HOST-4b NON-SCOPE (V+1): - ECDSA / RSA sig algs (only Ed25519 V1) - CA certs (only end-entity / leaf V1) - Cert chain (only self-signed V1) - CRL distribution points / OCSP / AIA extensions

dependencies 9 imports · 10 importers

nx_syscalls.nx nx_asn1_write.nx nx_ed25519_signature.nx nx_ecdsa_p256.nx nx_ecdsa_p256_sign.nx nx_x509_sig_alg.nx nx_u256.nx nx_p256_point.nx nx_sha256.nx nx_x509_build.nx _h2_multistream_curl_daemon.nx _h2_serve_curl_daemon.nx _h2_serve_loopback_gate.nx _nx_pub_from_priv_isolated_test.nx nx_acme_csr.nx nx_cert_gen.nx nx_cms_tls_gate.nx nx_h2_test_leaf.nx nx_mtls_ecdsa.nx nx_tls13_clientauth_ecdsa.nx

imports: nx_syscalls.nxnx_asn1_write.nxnx_ed25519_signature.nxnx_ecdsa_p256.nxnx_ecdsa_p256_sign.nxnx_x509_sig_alg.nxnx_u256.nxnx_p256_point.nxnx_sha256.nx

imported by: _h2_multistream_curl_daemon.nx_h2_serve_curl_daemon.nx_h2_serve_loopback_gate.nx_nx_pub_from_priv_isolated_test.nxnx_acme_csr.nxnx_cert_gen.nxnx_cms_tls_gate.nxnx_h2_test_leaf.nxnx_mtls_ecdsa.nxnx_tls13_clientauth_ecdsa.nx

structs

139struct NxX509BuildInputs

consts

56const NX_X509_OK: i64 = 0
57const NX_X509_BAD_INPUT: i64 = 3620
58const NX_X509_BUF_OVERFLOW: i64 = 3621
59const NX_X509_TOO_MANY_SANS: i64 = 3622
60const NX_X509_BAD_TIME: i64 = 3623
61const NX_X509_SIGN_FAILED: i64 = 3624
62const NX_X509_SERIAL_TOO_LARGE: i64 = 3625
65const NX_X509_MAX_DER_OUT: i64 = 8192 // V1 self-signed cert easily fits
66const NX_X509_MAX_TBS_BUF: i64 = 4096 // TBSCertificate scratch
67const NX_X509_MAX_NAME_BUF: i64 = 256 // CN body
68const NX_X509_MAX_SANS: i64 = 16
69const NX_X509_MAX_SAN_LEN: i64 = 253 // hostname per RFC 1035 + room
70const NX_X509_MAX_VALIDITY_BUF: i64 = 64
71const NX_X509_MAX_SPKI_BUF: i64 = 128
72const NX_X509_MAX_EXT_BUF: i64 = 512
73const NX_X509_MAX_ISSUER_BUF: i64 = 256
74const NX_X509_ED25519_SIG_LEN: i64 = 64
75const NX_X509_ED25519_PUB_LEN: i64 = 32
76const NX_X509_ED25519_PRIV_LEN: i64 = 32
113const NX_X509_OID_ED25519: *u8 = "\x2B\x65\x70" as *u8
114const NX_X509_OID_ED25519_N: i64 = 3
115const NX_X509_OID_SAN: *u8 = "\x55\x1D\x11" as *u8
116const NX_X509_OID_SAN_N: i64 = 3
117const NX_X509_OID_BASIC_CONSTRAINTS: *u8 = "\x55\x1D\x13" as *u8
118const NX_X509_OID_BASIC_CONSTRAINTS_N: i64 = 3
119const NX_X509_OID_KEY_USAGE: *u8 = "\x55\x1D\x0F" as *u8
120const NX_X509_OID_KEY_USAGE_N: i64 = 3
121const NX_X509_OID_CN: *u8 = "\x55\x04\x03" as *u8
122const NX_X509_OID_CN_N: i64 = 3
126const NX_X509_OID_ECDSA_SHA256: *u8 = "\x2A\x86\x48\xCE\x3D\x04\x03\x02" as *u8
127const NX_X509_OID_ECDSA_SHA256_N: i64 = 8
129const NX_X509_OID_EC_PUBLIC_KEY: *u8 = "\x2A\x86\x48\xCE\x3D\x02\x01" as *u8
130const NX_X509_OID_EC_PUBLIC_KEY_N: i64 = 7
132const NX_X509_OID_SECP256R1: *u8 = "\x2A\x86\x48\xCE\x3D\x03\x01\x07" as *u8
133const NX_X509_OID_SECP256R1_N: i64 = 8
135const NX_X509_ECDSA_P256_PUB_LEN: i64 = 65 // 0x04 || X(32B) || Y(32B) uncompressed

functions

97func nx_x509_sig_alg_name(a: i64) -> *u8
166func nx_x509_inputs_init(inp: *NxX509BuildInputs,
201func nx_x509_inputs_init_ecdsa_p256(inp: *NxX509BuildInputs,
240func nx_x509_build_alg_ed25519(out: *u8, cap: i64, off: i64) -> i64
254func nx_x509_build_alg_ecdsa_p256_sha256(out: *u8, cap: i64, off: i64) -> i64
267func nx_x509_build_sig_alg(out: *u8, cap: i64, off: i64, sig_alg: i64) -> i64
288func nx_x509_build_spki_ecdsa_p256(out: *u8, cap: i64, off: i64,
322func nx_x509_build_spki(out: *u8, cap: i64, off: i64, inp: *NxX509BuildInputs) -> i64
339func nx_x509_ecdsa_sig_to_der(r: *i64, s: *i64,
382func nx_x509_build_name_cn(out: *u8, cap: i64, off: i64,
405func nx_x509_build_validity(out: *u8, cap: i64, off: i64,
423func nx_x509_build_spki_ed25519(out: *u8, cap: i64, off: i64,
439func nx_x509_build_ext_san(out: *u8, cap: i64, off: i64,
476func nx_x509_build_extensions(out: *u8, cap: i64, off: i64,
500func nx_x509_build_tbs(out: *u8, cap: i64, off: i64,
546func nx_x509_build_self_signed(inp: *NxX509BuildInputs,