code wiki / _hdl_build / nx_x509_emit.nx

nx_x509_emit.nx

buildroot/runtime/_hdl_build/nx_x509_emit.nx

18294 B387 linesdepth 10pulls 20 transitivereach 2 importersview sourcekind librarytopic x509
docsdependenciesstructsconstsfunctions

about

nx_x509_emit.nx -- F103e RUNG 9: author a SELF-SIGNED X.509 v3 certificate. The cert that will carry our Secure Boot key. Real EDK2 with MS keys refuses our unsigned .efi (Access Denied) while the same secboot firmware in SETUP mode runs it, so the blocker is the enrolled key set (debt 1786237435). Enrolling means putting a CERT in db. ★OIDs ARE DERIVED, NOT RECALLED. An OID written as a byte string from memory is a fabricated constant. Here `der_oid_from_arcs` ENCODES the arc numbers (X.690 §8.19: first byte = 40*a1 + a2, then base-128 with continuation bits) -- and T1 validates that encoder against a known-good encoding the estate already ships: the SHA-256 OID sitting inside the incumbent's `rsa_pkcs1_sha256_di_byte` DigestInfo table. ★★★★★★**ONE VERIFIED ENCODER TURNS EVERY OTHER OID FROM A REMEMBERED BYTE STRING INTO A DERIVED RESULT — AND THE ARC NUMBERS ARE SPEC FACTS, WHICH THE ENCODER THEN PROVES.** ★THE ORACLE IS THE ESTATE'S OWN READER, END TO END: emit -> `x509_parse` must accept and report a tbs region -> our signer signs exactly that region -> the incumbent `rsa_pkcs1_v1_5_sha256_verify` must accept. Four independently written pieces agreeing. A cert that only round-trips through its own emitter proves nothing. Structure (RFC 5280): Certificate ::= SEQUENCE { tbsCertificate, signatureAlgorithm, signatureValue } TBSCertificate ::= SEQUENCE { [0] v3, serial, sigAlg, issuer, validity, subject, SPKI } ⚠extensions ([3] basicConstraints CA:TRUE) are NOT emitted yet -- named as owed rather than silently absent, because a db entry does not require them but a KEK/PK chain will. Usage: nx_x509_emit selftest Exit: 0 GREEN | 1 RED. Log -> knowledge/status/nishi_os.log, verdict= LAST. license_tier: ORIGINAL

dependencies 15 imports · 2 importers

nx_syscalls.nx nx_sha256.nx nx_u2048.nx nx_u2048_mul.nx nx_rsa2048_mod.nx nx_rsa2048_mod_exp.nx nx_rsa2048_mont.nx nx_rsa2048_mod_exp_big.nx nx_asn1.nx nx_x509.nx nx_x509_emit.nx nx_authenticode_sign.nx nx_efivars_enrol.nx

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

imports: nx_syscalls.nxnx_sha256.nxnx_u2048.nxnx_u2048_mul.nxnx_rsa2048_mod.nxnx_rsa2048_mod_exp.nxnx_rsa2048_mont.nxnx_rsa2048_mod_exp_big.nxnx_asn1.nxnx_x509.nxnx_rsa_pkcs1_v1_5_sha256.nxnx_u2048_millerrabin.nxnx_u2048_smallops.nxnx_rsa_keygen.nxnx_rsa_pkcs1_sign.nx

imported by: nx_authenticode_sign.nxnx_efivars_enrol.nx

structs

none

consts

43const XE_MAGIC_65536: i64 = 65536
44const XE_MAGIC_1024: i64 = 1024
45const XE_MAGIC_113549: i64 = 113549
46const XE_MAGIC_20260808: i64 = 20260808
47const XE_MAGIC_65537: i64 = 65537
48const XE_MAGIC_4097: i64 = 4097
50const XE_BUF: i64 = 8192

functions

52func xe_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
53func xe_fp(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
54func xe_fn(fd: i64, v: i64) -> i64
66func xe_put_len(out: *u8, off: i64, n: i64) -> i64
77func xe_len_size(n: i64) -> i64
83func xe_wrap(out: *u8, off: i64, tag: i64, payload: *u8, plen: i64) -> i64
93func der_oid_from_arcs(out: *u8, off: i64, arcs: *i64, narcs: i64) -> i64
122func xe_algid(out: *u8, off: i64, arcs: *i64, narcs: i64) -> i64
132func xe_name(out: *u8, off: i64, cn: *u8) -> i64
148func xe_spki(out: *u8, off: i64, n: *i64, e: i64) -> i64
195func xe_tbs(out: *u8, off: i64, n: *i64, e: i64, cn: *u8, serial: i64) -> i64
226func x509_emit_selfsigned(out: *u8, n: *i64, d: *i64, e: i64, cn: *u8, serial: i64,
253func xe_selftest() -> i64
385func main(argc: i64, argv: *i64) -> i64